2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 /* Utility functions for boot taglist relocation */
8 #include <proto/arossupport.h>
9 #include <utility/tagitem.h>
13 #include "boot_utils.h"
14 #include "kernel_base.h"
15 #include "kernel_bootmem.h"
17 /* Our own block copier, because memcpy() can rely on CopyMem() which is not available yet */
18 void krnCopyMem(const void *src
, void *dest
, unsigned long size
)
24 for (i
= 0; i
< size
; i
++)
28 void RelocateBootMsg(const struct TagItem
*msg
)
32 struct TagItem
*tstate
= (struct TagItem
*)msg
;
35 /* First count how much memory we will need */
36 while ((tag
= LibNextTagItem(&tstate
)))
41 /* Allocate the memory */
42 dest
= krnAllocBootMem(num
* sizeof(struct TagItem
));
45 /* Now copy tagitems */
46 tstate
= (struct TagItem
*)msg
;
47 while ((tag
= LibNextTagItem(&tstate
)))
49 dest
->ti_Tag
= tag
->ti_Tag
;
50 dest
->ti_Data
= tag
->ti_Data
;
54 /* Make sure the list is terminated */
55 dest
->ti_Tag
= TAG_DONE
;
58 void RelocateTagData(struct TagItem
*tag
, unsigned long size
)
60 char *src
= (char *)tag
->ti_Data
;
61 unsigned char *dest
= krnAllocBootMem(size
);
63 tag
->ti_Data
= (IPTR
)dest
;
64 krnCopyMem(src
, dest
, size
);
67 void RelocateStringData(struct TagItem
*tag
)
69 unsigned int l
= strlen((char *)tag
->ti_Data
) + 1;
71 RelocateTagData(tag
, l
);
74 void RelocateBSSData(struct TagItem
*tag
)
76 struct KernelBSS
*bss
;
77 unsigned int l
= sizeof(struct KernelBSS
);
79 for (bss
= (struct KernelBSS
*)tag
->ti_Data
; bss
->addr
; bss
++)
80 l
+= sizeof(struct KernelBSS
);
82 RelocateTagData(tag
, l
);