Merging NList MCC 0.119 into the main branch.
[AROS.git] / arch / all-unix / kernel / allockernelbase.c
blob28cc7009b15ee055042a8f34d5101a64e3f4a6fa
1 #include <exec/execbase.h>
2 #include <exec/memory.h>
3 #include <proto/exec.h>
5 #include LC_LIBDEFS_FILE /* we want FUNCTIONS_COUNT */
7 #include <kernel_debug.h>
8 #include <kernel_globals.h>
9 #include "kernel_intern.h"
10 #include "kernel_unix.h"
12 #define D(x)
14 struct KernelBase *AllocKernelBase(struct ExecBase *SysBase)
16 APTR mem;
17 struct KernelBase *KernelBase;
18 ULONG i = FUNCTIONS_COUNT * LIB_VECTSIZE;
20 /* Align vector table size */
21 i = ((i - 1) / sizeof(IPTR) + 1) * sizeof(IPTR);
23 /* Allocate the memory. Note that we have platform-specific portion in KernelBase. */
24 mem = AllocMem(i + sizeof(struct UnixKernelBase), MEMF_PUBLIC|MEMF_CLEAR);
25 if (!mem)
26 return NULL;
28 /* Skip past the vector table */
29 KernelBase = mem + i;
31 KernelBase->kb_PlatformData = AllocMem(sizeof(struct PlatformData), MEMF_ANY);
32 D(bug("[KRN] PlatformData %p\n", KernelBase->kb_PlatformData));
34 if (!KernelBase->kb_PlatformData)
35 return NULL;
37 /* Set global KernelBase storage and return */
38 setKernelBase(KernelBase);
39 return KernelBase;