revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-native / kernel / boot_utils.c
blobacba3ed79e5c50e470cfea5cd0dab669f430fdcc
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /* Utility functions for boot taglist relocation */
8 #include <proto/arossupport.h>
9 #include <utility/tagitem.h>
11 #include <string.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)
20 const char *s = src;
21 char *d = dest;
22 unsigned long i;
24 for (i = 0; i < size; i++)
25 *d++ = *s++;
28 void RelocateBootMsg(const struct TagItem *msg)
30 struct TagItem *dest;
31 struct TagItem *tag;
32 struct TagItem *tstate = (struct TagItem *)msg;
33 ULONG num = 1;
35 /* First count how much memory we will need */
36 while ((tag = LibNextTagItem(&tstate)))
38 num++;
41 /* Allocate the memory */
42 dest = krnAllocBootMem(num * sizeof(struct TagItem));
43 BootMsg = dest;
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;
51 dest++;
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);