63 LOG_INFO(
"early init done, jumping to boot thread\n");
65 if (bootThread ==
NULL)
67 panic(
NULL,
"Failed to create boot thread");
102 panic(
NULL,
"Failed to load modules with BOOT_GOP");
107 LOG_WARN(
"no GOP provided by bootloader\n");
114 panic(
NULL,
"Failed to load modules with BOOT_RSDP");
119 LOG_WARN(
"no RSDP provided by bootloader\n");
124 panic(
NULL,
"Failed to load modules with BOOT_ALWAYS");
131 panic(
NULL,
"No timer source registered, most likely no timer sources with a provided driver was found");
135 panic(
NULL,
"No IRQ chip registered, most likely no IRQ chips with a provided driver was found");
139 panic(
NULL,
"No IPI chip registered, most likely no IPI chips with a provided driver was found");
147 LOG_INFO(
"spawning init process\n");
150 if (initProcess ==
NULL)
152 panic(
NULL,
"Failed to create init process");
158 if (initThread ==
NULL)
160 panic(
NULL,
"Failed to create init thread");
168 panic(
NULL,
"Failed to allocate memory for init executable path");
191 LOG_INFO(
"done with boot thread\n");
#define assert(expression)
#define GID_NONE
Invalid group ID.
void gdt_init(void)
Initialize the GDT.
@ GDT_CS_RING0
Value to load into the CS register for kernel code.
@ GDT_SS_RING0
Value to load into the SS register for kernel data.
void idt_init(void)
Initialize the IDT structure in memory.
uint64_t ipi_chip_amount(void)
Get the number of registered IPI chips.
void irq_init(void)
Initialize the IRQ subsystem.
uint64_t irq_chip_amount(void)
Get the number of registered IRQ chips.
void syscall_table_init(void)
Sort the syscall table and verify that all syscalls are present.
void cpu_init(cpu_t *cpu)
Initializes the CPU represented by the cpu_t structure.
#define CPU_ID_BOOTSTRAP
ID of the bootstrap CPU.
void cpu_init_early(cpu_t *cpu)
Only initialize the parts of the CPU structure needed for early boot.
#define ALIGNED(alignment)
GCC aligned attribute.
uint64_t namespace_set_parent(namespace_t *ns, namespace_t *parent)
Sets the parent of a namespace and inherits all mounts from the parent.
void ramfs_init(void)
Registers the ramfs filesystem and mounts it as the root filesystem.
void boot_info_to_higher_half(void)
Offset all pointers in the boot info structure to the higher half.
boot_info_t * boot_info_get(void)
Gets the boot info structure.
void boot_info_free(void)
Frees the boot info structure and all its associated data.
void init_early(void)
Early kernel initialization.
void kmain(void)
Kernel main function.
void log_file_expose(void)
Expose the kernel log file to userspace in sysfs.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
void log_init(void)
Initialize the logging system.
#define LOG_WARN(format,...)
#define LOG_INFO(format,...)
#define LOG_DEBUG(format,...)
uint64_t pmm_used_amount(void)
Retrieves the amount of reserved physical memory.
void pmm_init(void)
Initializes the Physical Memory Manager.
void vmm_init(void)
Initializes the Virtual Memory Manager.
void vmm_kernel_space_load(void)
Loads the kernel's address space into the current CPU.
void module_init_fake_kernel_module()
Initialize a fake module representing the kernel itself.
uint64_t module_device_attach(const char *type, const char *name, module_load_flags_t flags)
Notify the module system of a device being attached.
@ MODULE_LOAD_ALL
If set, will load all modules matching the device type.
void reaper_init(void)
Initializes the process reaper.
process_t * process_get_kernel(void)
Gets the kernel process.
void process_procfs_init(void)
Initializes the /proc directory.
process_t * process_new(priority_t priority, gid_t gid)
Allocates and initializes a new process.
_NORETURN void loader_exec(const char *executable, char **argv, uint64_t argc)
Causes the currently running thread to load and execute a new program.
thread_t * thread_new(process_t *process)
Creates a new thread structure.
_NORETURN void sched_start(thread_t *bootThread)
Starts the scheduler by jumping to the boot thread.
void sched_submit(thread_t *thread)
Submits a thread to the scheduler.
_NORETURN void sched_thread_exit(void)
Terminates the currently executing thread.
uint64_t timer_source_amount(void)
Get the amount of registered timer sources.
#define PRIORITY_MAX_USER
The maximum priority user space is allowed to specify, inclusive.
#define PAGE_SIZE
The size of a memory page in bytes.
#define NULL
Pointer error value.
#define ERR
Integer error value.
static void init_process_spawn(void)
static void init_finalize(void)
#define RFLAGS_INTERRUPT_ENABLE
#define RFLAGS_ALWAYS_SET
__UINTPTR_TYPE__ uintptr_t
char * strdup(const char *src)
uintptr_t top
The top of the stack, this address is not inclusive.
Thread of execution structure.
stack_pointer_t kernelStack
The kernel stack of the thread.
void sysfs_init(void)
Initializes the SysFS.