White space fixes, detab.
[AROS.git] / rom / kernel / kernel_init.c
blob97f171a554dd7db8ee173fa144dd58b7019144eb
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_debug.h>
24 /* We have own bug(), so don't use aros/debug.h to avoid conflicts */
25 #define D(x)
27 static const UBYTE version[];
28 extern const char LIBEND;
30 AROS_UFP3S(struct KernelBase *, Kernel_Init,
31 AROS_UFPA(ULONG, dummy, D0),
32 AROS_UFPA(BPTR, segList, A0),
33 AROS_UFPA(struct ExecBase *, sysBase, A6));
35 const struct Resident Kernel_resident =
37 RTC_MATCHWORD,
38 (struct Resident *)&Kernel_resident,
39 (APTR)&LIBEND,
40 RTF_SINGLETASK,
41 VERSION_NUMBER,
42 NT_LIBRARY,
43 RESIDENTPRI,
44 MOD_NAME_STRING,
45 (STRPTR)&version[6],
46 Kernel_Init
49 static const UBYTE version[] = VERSION_STRING;
51 void __clear_bss(const struct KernelBSS *bss)
53 while (bss->addr)
55 bzero((void*)bss->addr, bss->len);
56 bss++;
60 extern const APTR GM_UNIQUENAME(FuncTable)[];
62 THIS_PROGRAM_HANDLES_SYMBOLSETS
63 DEFINESET(INITLIB)
66 * Init routine is intentionally written by hands.
67 * It can use kernel's own memory allocator (if implemented) for KernelBase creation.
68 * This allows not to rely on working exec's memory management before kernel.resource
69 * is set up. This can simplify exec.library code on MMU-aware systems.
70 * exec.library catches our AddResource() and sets up its pooled memory manager.
73 AROS_UFH3S(struct KernelBase *, Kernel_Init,
74 AROS_UFHA(ULONG, dummy, D0),
75 AROS_UFHA(BPTR, segList, A0),
76 AROS_UFHA(struct ExecBase *, SysBase, A6)
79 AROS_USERFUNC_INIT
81 struct KernelBase *KernelBase;
82 int i;
84 D(bug("[KRN] Kernel_Init()\n"));
86 KernelBase = AllocKernelBase(SysBase);
87 if (!KernelBase)
88 return NULL;
90 KernelBase->kb_Node.ln_Type = NT_RESOURCE;
91 KernelBase->kb_Node.ln_Pri = RESIDENTPRI;
92 KernelBase->kb_Node.ln_Name = MOD_NAME_STRING;
94 MakeFunctions(KernelBase, GM_UNIQUENAME(FuncTable), NULL);
96 D(bug("[KRN] KernelBase 0x%p\n", KernelBase));
98 for (i=0; i < EXCEPTIONS_COUNT; i++)
99 NEWLIST(&KernelBase->kb_Exceptions[i]);
101 for (i=0; i < IRQ_COUNT; i++)
102 NEWLIST(&KernelBase->kb_Interrupts[i]);
105 * Everything is ok, add our resource.
106 * exec.library catches this call and sets up its memory management.
107 * At this point kernel.resource's debug I/O and memory management must be
108 * fully functional. After this we'll be able to safely call CreatePool() etc.
110 AddResource(KernelBase);
112 /* Call platform-specific init code */
113 if (!set_call_libfuncs(SETNAME(INITLIB), 1, 1, KernelBase))
114 return NULL;
116 D(bug("[KRN] Kernel_Init() done\n"));
118 return KernelBase;
120 AROS_USERFUNC_EXIT;