bump copyright date on affected files and version
[AROS.git] / arch / all-native / kernel / boot_utils.c
blob3a20a35cbe8fc2276a849d538cb6393edbb4cf12
1 /* Utility functions for boot taglist relocation */
3 #include <proto/arossupport.h>
4 #include <utility/tagitem.h>
6 #include <string.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)
15 const char *s = src;
16 char *d = dest;
17 unsigned long i;
19 for (i = 0; i < size; i++)
20 *d++ = *s++;
23 void RelocateBootMsg(const struct TagItem *msg)
25 struct TagItem *dest;
26 struct TagItem *tag;
27 struct TagItem *tstate = (struct TagItem *)msg;
28 ULONG num = 1;
30 /* First count how much memory we will need */
31 while ((tag = LibNextTagItem(&tstate)))
33 num++;
36 /* Allocate the memory */
37 dest = krnAllocBootMem(num * sizeof(struct TagItem));
38 BootMsg = dest;
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;
46 dest++;
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);