2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
5 Desc: Main kernel.resource initialization.
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>
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 */
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
=
40 (struct Resident
*)&Kernel_resident
,
51 static const UBYTE version
[] = VERSION_STRING
;
53 void __clear_bss(const struct KernelBSS
*bss
)
57 bzero((void*)bss
->addr
, bss
->len
);
62 extern const APTR
GM_UNIQUENAME(FuncTable
)[];
64 THIS_PROGRAM_HANDLES_SYMBOLSET(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
)
83 struct KernelBase
*KernelBase
= NULL
;
86 D(bug("[KRN] Kernel_Init()\n"));
88 KernelBase
= AllocKernelBase(SysBase
);
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
))
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
);