2 Copyright © 2017-2018, The AROS Development Team. All rights reserved.
6 #define __KERNEL_NOLIBBASE__
8 #include <proto/exec.h>
9 #include <proto/acpica.h>
10 #include <proto/kernel.h>
12 #include <aros/multiboot.h>
13 #include <aros/symbolsets.h>
16 #include <exec/lists.h>
17 #include <exec/resident.h>
21 #include "kernel_base.h"
22 #include "kernel_debug.h"
23 #include "kernel_intern.h"
24 #include "kernel_ipi.h"
32 * This file contains code that is run once Exec has been brought up - and is launched
33 * via the RomTag/Autoinit routines in Exec.
35 * PlatformPostInit is run during RTF_SINGLETASK.
38 void PlatformPostInit(void)
40 D(bug("[Kernel] %s()\n", __func__
));
44 Here we do the Platform configuration that requires a working "AROS" environment.
47 APTR
PlatformAllocGDT(struct KernelBase
*LIBBASE
, apicid_t _APICID
)
51 GDTalloc
= (APTR
)AllocMem(GDT_SIZE
+ 128, MEMF_24BITDMA
|MEMF_CLEAR
);
52 GDTalloc
= (APTR
)AROS_ROUNDUP2((unsigned long)GDTalloc
, 128);
53 D(bug("[Kernel] %s[%d]: GDT @ 0x%p\n", __func__
, _APICID
, GDTalloc
));
58 APTR
PlatformAllocTLS(struct KernelBase
*LIBBASE
, apicid_t _APICID
)
62 TLSalloc
= (APTR
)AllocMem(TLS_SIZE
+ TLS_ALIGN
, MEMF_24BITDMA
|MEMF_CLEAR
);
63 TLSalloc
= (APTR
)AROS_ROUNDUP2((unsigned long)TLSalloc
, TLS_ALIGN
);
65 D(bug("[Kernel] %s[%d]: TLS @ 0x%p\n", __func__
, _APICID
, TLSalloc
));
70 APTR
PlatformAllocIDT(struct KernelBase
*LIBBASE
, apicid_t _APICID
)
74 IDTalloc
= (APTR
)AllocMem(IDT_SIZE
+ 256, MEMF_24BITDMA
|MEMF_CLEAR
);
75 IDTalloc
= (APTR
)AROS_ROUNDUP2((unsigned long)IDTalloc
, 256);
77 D(bug("[Kernel] %s[%d]: Allocated IDT at 0x%p\n", __func__
, _APICID
, IDTalloc
));
83 * kernel.post is run during RTF_COLDSTART
84 * directly after exec.library.
86 * At this point exec is fully configured, and
87 * multitasking is enabled. It also means
88 * acpica's "full initialization" task will have
92 extern void kernelpost_end(void);
94 static AROS_UFP3 (APTR
, KernelPost
,
95 AROS_UFPA(struct Library
*, lh
, D0
),
96 AROS_UFPA(BPTR
, segList
, A0
),
97 AROS_UFPA(struct ExecBase
*, sysBase
, A6
));
99 static const TEXT kernelpost_namestring
[] = "kernel.post";
100 static const TEXT kernelpost_versionstring
[] = "kernel.post 1.1\n";
102 const struct Resident kernelpost_romtag
=
105 (struct Resident
*)&kernelpost_romtag
,
106 (APTR
)&kernelpost_end
,
111 (STRPTR
)kernelpost_namestring
,
112 (STRPTR
)kernelpost_versionstring
,
116 extern struct syscallx86_Handler x86_SCRebootHandler
;
117 extern struct syscallx86_Handler x86_SCChangePMStateHandler
;
120 struct Hook test_ipi
;
122 AROS_UFH3(void, test_ipi_hook
,
123 AROS_UFHA(struct Hook
*, hook
, A0
),
124 AROS_UFHA(APTR
, object
, A2
),
125 AROS_UFHA(APTR
, message
, A1
))
129 int cpunum
= KrnGetCPUNumber();
131 bug("%s: called on CPU %d, hook=%p, object=%p, message=%p\n", __func__
, cpunum
, hook
, object
, message
);
137 static AROS_UFH3 (APTR
, KernelPost
,
138 AROS_UFHA(struct Library
*, lh
, D0
),
139 AROS_UFHA(BPTR
, segList
, A0
),
140 AROS_UFHA(struct ExecBase
*, SysBase
, A6
)
145 struct KernelBase
*KernelBase
;
146 struct PlatformData
*pdata
;
148 KernelBase
= (struct KernelBase
*)OpenResource("kernel.resource");
152 pdata
= KernelBase
->kb_PlatformData
;
154 D(bug("[Kernel] %s: Checking for ACPI...\n", __func__
));
156 ACPICABase
= OpenLibrary("acpica.library", 0);
157 /* Probe for ACPI configuration */
161 D(bug("[Kernel] %s: Performing late system configuration...\n", __func__
));
165 // Add the default reboot/shutdown handlers if ACPI ones haven't been registered
166 krnAddSysCallHandler(pdata
, &x86_SCRebootHandler
, TRUE
, FALSE
);
167 krnAddSysCallHandler(pdata
, &x86_SCChangePMStateHandler
, TRUE
, FALSE
);
169 D(bug("[Kernel] %s: Attempting to bring up additional cores...\n", __func__
));
172 D(bug("[Kernel] %s: Initializing interrupt controllers...\n", __func__
));
173 ictl_Initialize(KernelBase
);
177 D(bug("[Kernel] %s: Platform Initialization complete\n", __func__
));
180 bug("--- TESTING IPI CALL HOOK ---\n");
181 test_ipi
.h_Entry
= test_ipi_hook
;
182 test_ipi
.h_Data
= KernelBase
;
183 bug("--- SYNCHRONOUS IPI ---\n");
184 core_DoCallIPI(&test_ipi
, (void*)TASKAFFINITY_ALL_BUT_SELF
, 0, KernelBase
);
185 bug("--- ASYNC IPI ---\n");
186 core_DoCallIPI(&test_ipi
, (void*)TASKAFFINITY_ALL_BUT_SELF
, 1, KernelBase
);
194 void kernelpost_end(void) { };