Listtree.mcc: forward a number of SET/GET calls to embedded NListtree object.
[AROS.git] / rom / kernel / kernel_init.c
blob47264f771dc123c98f398ac9415f29256755b379
1 /*
2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Main kernel.resource initialization.
6 Lang: english
7 */
9 #include <aros/asmcall.h>
10 #include <aros/kernel.h>
11 #include <aros/symbolsets.h>
12 #include <exec/resident.h>
13 #include <proto/arossupport.h>
14 #include <proto/exec.h>
16 #include <inttypes.h>
17 #include <stdlib.h>
18 #include <string.h>
20 #include LC_LIBDEFS_FILE
22 #include <kernel_globals.h>
24 #include <kernel_debug.h>
26 /* We have own bug(), so don't use aros/debug.h to avoid conflicts */
27 #define D(x)
29 static const UBYTE version[];
30 extern const char LIBEND;
32 AROS_UFP3S(struct KernelBase *, Kernel_Init,
33 AROS_UFPA(ULONG, dummy, D0),
34 AROS_UFPA(BPTR, segList, A0),
35 AROS_UFPA(struct ExecBase *, sysBase, A6));
37 const struct Resident Kernel_resident =
39 RTC_MATCHWORD,
40 (struct Resident *)&Kernel_resident,
41 (APTR)&LIBEND,
42 RTF_SINGLETASK,
43 VERSION_NUMBER,
44 NT_LIBRARY,
45 RESIDENTPRI,
46 MOD_NAME_STRING,
47 (STRPTR)&version[6],
48 Kernel_Init
51 static const UBYTE version[] = VERSION_STRING;
53 void __clear_bss(const struct KernelBSS *bss)
55 while (bss->addr)
57 bzero((void*)bss->addr, bss->len);
58 bss++;
62 extern const APTR GM_UNIQUENAME(FuncTable)[];
64 THIS_PROGRAM_HANDLES_SYMBOLSET(INITLIB)
65 DEFINESET(INITLIB)
68 * Init routine is intentionally written by hands.
69 * It can use kernel's own memory allocator (if implemented) for KernelBase creation.
70 * This allows not to rely on working exec's memory management before kernel.resource
71 * is set up. This can simplify exec.library code on MMU-aware systems.
72 * exec.library catches our AddResource() and sets up its pooled memory manager.
75 AROS_UFH3S(struct KernelBase *, Kernel_Init,
76 AROS_UFHA(ULONG, dummy, D0),
77 AROS_UFHA(BPTR, segList, A0),
78 AROS_UFHA(struct ExecBase *, SysBase, A6)
81 AROS_USERFUNC_INIT
83 struct KernelBase *KernelBase = NULL;
84 int i;
86 D(bug("[KRN] Kernel_Init()\n"));
88 KernelBase = AllocKernelBase(SysBase);
89 if (!KernelBase)
90 return NULL;
92 KernelBase->kb_Node.ln_Type = NT_RESOURCE;
93 KernelBase->kb_Node.ln_Pri = RESIDENTPRI;
94 KernelBase->kb_Node.ln_Name = MOD_NAME_STRING;
96 MakeFunctions(KernelBase, GM_UNIQUENAME(FuncTable), NULL);
98 D(bug("[KRN] KernelBase 0x%p\n", KernelBase));
100 for (i=0; i < EXCEPTIONS_COUNT; i++)
101 NEWLIST(&KernelBase->kb_Exceptions[i]);
103 for (i=0; i < IRQ_COUNT; i++)
104 NEWLIST(&KernelBase->kb_Interrupts[i]);
107 * Everything is ok, add our resource.
108 * exec.library catches this call and sets up its memory management.
109 * At this point kernel.resource's debug I/O and memory management must be
110 * fully functional. After this we'll be able to safely call CreatePool() etc.
112 AddResource(KernelBase);
114 /* Call platform-specific init code */
115 if (!set_call_libfuncs(SETNAME(INITLIB), 1, 1, KernelBase))
116 return NULL;
118 D(bug("[KRN] Kernel_Init() done\n"));
120 /* Set global KernelBase storage and return */
121 D(bug("[%s] Set global KernelBase\n"));
122 setKernelBase(KernelBase);
124 return KernelBase;
126 AROS_USERFUNC_EXIT;