1 /* Utility functions for boot taglist relocation */
3 #include <proto/arossupport.h>
4 #include <utility/tagitem.h>
8 #include "boot_utils.h"
9 #include "kernel_base.h"
10 #include "kernel_bootmem.h"
12 /* Our own block copier, because memcpy() can rely on CopyMem() which is not available yet */
13 void krnCopyMem(const void *src
, void *dest
, unsigned long size
)
19 for (i
= 0; i
< size
; i
++)
23 void RelocateBootMsg(const struct TagItem
*msg
)
27 struct TagItem
*tstate
= (struct TagItem
*)msg
;
30 /* First count how much memory we will need */
31 while ((tag
= LibNextTagItem(&tstate
)))
36 /* Allocate the memory */
37 dest
= krnAllocBootMem(num
* sizeof(struct TagItem
));
40 /* Now copy tagitems */
41 tstate
= (struct TagItem
*)msg
;
42 while ((tag
= LibNextTagItem(&tstate
)))
44 dest
->ti_Tag
= tag
->ti_Tag
;
45 dest
->ti_Data
= tag
->ti_Data
;
49 /* Make sure the list is terminated */
50 dest
->ti_Tag
= TAG_DONE
;
53 void RelocateTagData(struct TagItem
*tag
, unsigned long size
)
55 char *src
= (char *)tag
->ti_Data
;
56 unsigned char *dest
= krnAllocBootMem(size
);
58 tag
->ti_Data
= (IPTR
)dest
;
59 krnCopyMem(src
, dest
, size
);
62 void RelocateStringData(struct TagItem
*tag
)
64 unsigned int l
= strlen((char *)tag
->ti_Data
) + 1;
66 RelocateTagData(tag
, l
);
69 void RelocateBSSData(struct TagItem
*tag
)
71 struct KernelBSS
*bss
;
72 unsigned int l
= sizeof(struct KernelBSS
);
74 for (bss
= (struct KernelBSS
*)tag
->ti_Data
; bss
->addr
; bss
++)
75 l
+= sizeof(struct KernelBSS
);
77 RelocateTagData(tag
, l
);