AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
init.c
Go to the documentation of this file.
1
9
10#include <boot/boot.h>
11#include <boot/multiboot.h>
12#include <console/earlycon.h>
13#include <core/kargs.h>
14#include <core/platform.h>
15#include <core/printk.h>
16#include <core/string.h>
17#include <cpu/cpu.h>
18#include <ds/bitmap.h>
19#include <sys/cpu.h>
20#include <sys/lock.h>
21#include <mm/mm.h>
22#include <mm/vm.h>
23#include <video/vbe.h>
24
25struct boot *__kboot;
26
27/* the stack of the boot CPU's idle loop */
28static char bsp_idle_stack[8192] __aligned(16);
29
34void x86_cpu_init(void)
35{
36 /* the boot CPU's own structure, first (curcpu(), curthread) */
37 struct cpu *bsp = &cpus[0];
38 bsp->id = 0;
40 cpus_count = 1;
41
42 x86_gdt_setup(bsp, VMA(0x100000ULL));
43
44 /* hold the kernel lock until the first process runs */
46
48 printk("x86: Welcome to AquilaOS!\n");
49
50 printk("x86: installing IDT\n");
52
53 printk("x86: installing ISRs\n");
55
57
58 printk("x86: processing multiboot info block at %p\n", (uintptr_t) multiboot_info);
59 struct boot *boot = process_multiboot_info((multiboot_info_t *)(uintptr_t) multiboot_info);
60 __kboot = boot;
61
64
65 /* the kernel's command line */
67
68 /* the early console again, as the command line says */
70
72
73 extern void kmain(struct boot *);
74 kmain(boot);
75}
static char bsp_idle_stack[8192]
Definition init.c:22
struct boot * __kboot
Definition init.c:19
void earlycon_reinit(void)
Sets up the early console again, once the kernel's command line has been read, since it may choose an...
Definition earlycon.c:65
void earlycon_init(void)
Sets up the early console at boot, before anything else.
Definition earlycon.c:59
#define VMA(obj)
Definition mm.h:36
void x86_fpu_setup(void)
Sets up the FPU on the running CPU, at boot: CR0.TS set so that the first FPU or SSE instruction rais...
Definition fpu.c:50
void x86_gdt_setup(struct cpu *cpu, uintptr_t sp)
Sets up and loads the running CPU's GDT and TSS, and points gs (or the GS base, on x86_64) at its str...
Definition gdt.c:79
void x86_cpu_init(void)
Sets up the boot CPU, memory and the platform, and starts the kernel (kmain()).
Definition init.c:34
void x86_idt_setup()
Loads the IDT on the running CPU.
Definition idt.c:82
#define __aligned(n)
Definition system.h:31
void mm_setup(struct boot *boot)
Sets up physical memory at boot, from the boot loader's memory map: the page structures,...
Definition mm.c:365
struct cpu cpus[CPUS_MAX]
Definition sched.c:28
int cpus_count
Definition sched.c:29
void x86_isr_setup(void)
Sets the IDT's gates for the exceptions and the system call vector.
Definition isr.c:253
int kargs_parse(const char *_cmdline)
Splits the kernel's command line into arguments, at boot.
Definition kargs.c:31
void kernel_lock(void)
Takes the kernel lock, waiting for its turn if another CPU holds it.
Definition lock.c:32
void kmain(struct boot *boot)
Starts the kernel's generic part, once the architecture has set up the CPU, memory and the platform.
Definition main.c:38
multiboot.h - Multiboot header file.
struct multiboot_info multiboot_info_t
Definition multiboot.h:208
int printk(const char *fmt,...)
Writes a kernel message, to the message buffer and the consoles.
Definition printk.c:249
__SIZE_TYPE__ uintptr_t
Definition stddef.h:12
uintptr_t idle_stack
Definition cpu.h:55
Definition boot.h:35
char * cmdline
Definition boot.h:36
A processor, and what runs on it.
Definition cpu.h:11
int id
Definition cpu.h:13
struct arch_cpu arch
Definition cpu.h:17
int platform_init(void)
Definition init.c:31
void kvmem_setup(void)
Sets up the kernel's allocator at boot, once physical memory and the page tables are ready.
Definition kvmem.c:55