13#include <kernel/drivers/ps2/ps2.h>
58 LOG_DEBUG(
"early init done, jumping to boot thread\n");
83 if (desc->Type == EfiLoaderData)
86 LOG_INFO(
"free boot memory [0x%016lx-0x%016lx]\n", desc->VirtualStart,
135 LOG_INFO(
"spawning init process\n");
136 const char* argv[] = {
"/bin/init",
NULL};
138 if (initThread ==
NULL)
140 panic(
NULL,
"Failed to spawn init process");
151 panic(
NULL,
"Failed to set klog as stdout for init process");
171 LOG_INFO(
"done with boot thread\n");
#define assert(expression)
#define BOOT_MEMORY_MAP_GET_DESCRIPTOR(map, index)
void kmain(const boot_info_t *bootInfo)
Kernel main function.
void init_early(const boot_info_t *bootInfo)
Early kernel initialization.
uint64_t aml_namespace_expose(void)
Expose the entire namespace heirarchy to sysfs.
void aml_init(void)
Initialize the AML subsystem.
void acpi_devices_init(void)
Enumerate and configure ACPI devices.
void acpi_tables_init(rsdp_t *rsdp)
Initialize ACPI tables and call their init handlers.
void acpi_tables_expose(void)
Expose ACPI tables to sysfs.
void acpi_reclaim_memory(const boot_memory_map_t *map)
Reclaim ACPI memory regions.
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.
void smp_bootstrap_init(void)
Initializes the bootstrap CPU structure.
static cpu_t * smp_self_unsafe(void)
Returns a pointer to the cpu_t structure of the current CPU.
void smp_bootstrap_init_early(void)
Early initialization of the bootstrap CPU.
void smp_others_init(void)
Initializes the other CPUs.
void syscall_table_init(void)
Initialize the syscall table.
void ps2_init(void)
Initialize the PS/2 controller.
void statistics_init(void)
Initializes the statistics driver.
#define PATHNAME(string)
Helper to create a pathname.
void ramfs_init(const boot_disk_t *disk)
Registers the ramfs filesystem and mounts it as the root filesystem.
fd_t vfs_ctx_set_fd(vfs_ctx_t *ctx, fd_t fd, file_t *file)
Allocate a specific file descriptor in a VFS context.
file_t * vfs_open(const pathname_t *pathname, process_t *process)
Open a file.
void vfs_init(void)
Initializes the VFS.
void shmem_init(void)
Initializes the shared memory subsystem.
void log_file_expose(void)
Expose the kernel log file to userspace in sysfs.
void panic_symbols_init(const boot_kernel_t *kernel)
Initialize panic symbols from the bootloader-provided kernel information.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define LOG_INFO(format,...)
#define LOG_DEBUG(format,...)
void log_init(const boot_gop_t *gop)
Initialize the logging system.
void pmm_init(const boot_memory_map_t *map)
Initializes the Physical Memory Manager.
void pmm_free_region(void *address, uint64_t count)
Frees a contiguous region of physical pages.
uint64_t pmm_reserved_amount(void)
Retrieves the amount of reserved physical memory.
#define VMM_KERNEL_STACKS_MAX
The maximum address for kernel stacks.
void vmm_init(const boot_memory_t *memory, const boot_gop_t *gop, const boot_kernel_t *kernel)
Initializes the Virtual Memory Manager.
void vmm_unmap_bootloader_lower_half(thread_t *bootThread)
Unmaps the lower half of the address space after kernel initialization.
void vmm_map_bootloader_lower_half(thread_t *bootThread)
Maps the lower half of the address space to the boot thread during kernel initialization.
void module_init(void)
Initializes the module system.
void net_init(void)
Initialize the networking subsystem.
void process_procfs_init(void)
Initializes the /proc directory.
thread_t * loader_spawn(const char **argv, priority_t priority, const path_t *cwd)
Spawns a child process from an executable file.
_NORETURN void thread_jump(thread_t *thread)
Jump to a thread by calling thread_load() and then loading its interrupt frame.
thread_t * thread_get_boot(void)
Retrieves the boot thread.
@ THREAD_RUNNING
Is currently running on a cpu.
void sched_push(thread_t *thread, cpu_t *target)
Pushes a thread onto a scheduling queue.
NORETURN void sched_done_with_boot_thread(void)
Specify that the boot thread is no longer needed.
static void ref_dec(void *ptr)
Decrement reference count.
#define PRIORITY_MAX_USER
#define PAGE_SIZE
Memory page size.
#define NULL
Pointer error value.
#define ERR
Integer error value.
void gop_init(const boot_gop_t *in)
static void init_free_loader_data(const boot_memory_map_t *map)
static void init_process_spawn(void)
static void init_finalize(const boot_info_t *bootInfo)
static thread_t bootThread
#define RFLAGS_ALWAYS_SET
static uint64_t rsp_read()
#define atomic_store(object, desired)
__UINTPTR_TYPE__ uintptr_t
thread_t * runThread
The currently running thread.
clock_t deadline
The time when the time slice will actually expire, only valid while the thread is running.
uintptr_t top
The top of the stack, this address is not inclusive.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.
stack_pointer_t kernelStack
The kernel stack of the thread.
void sysfs_init(void)
Initializes the SysFS.