74 LOG_INFO(
"early init done, jumping to boot thread\n");
76 if (bootThread ==
NULL)
78 panic(
NULL,
"Failed to create boot thread");
89 panic(
NULL,
"sched_start returned unexpectedly");
115 panic(
NULL,
"Failed to load modules with BOOT_GOP");
120 LOG_WARN(
"no GOP provided by bootloader\n");
127 panic(
NULL,
"Failed to load modules with BOOT_RSDP");
132 LOG_WARN(
"no RSDP provided by bootloader\n");
137 panic(
NULL,
"Failed to load modules with BOOT_ALWAYS");
144 panic(
NULL,
"No timer source registered, most likely no timer sources with a provided driver was found");
148 panic(
NULL,
"No IRQ chip registered, most likely no IRQ chips with a provided driver was found");
152 panic(
NULL,
"No IPI chip registered, most likely no IPI chips with a provided driver was found");
160 LOG_INFO(
"spawning init process\n");
163 if (kernelNs ==
NULL)
165 panic(
NULL,
"Failed to get kernel namespace");
172 panic(
NULL,
"Failed to create root namespace");
178 panic(
NULL,
"Failed to copy kernel namespace to root namespace");
182 if (initProcess ==
NULL)
184 panic(
NULL,
"Failed to create init process");
189 if (initThread ==
NULL)
191 panic(
NULL,
"Failed to create init thread");
194 char* argv[] = {
"/sbin/init",
NULL};
197 panic(
NULL,
"Failed to set init process cmdline");
222 LOG_INFO(
"done with boot thread\n");
void gdt_init(void)
Initialize the GDT.
#define GDT_SS_RING0
Value to load into the SS register for kernel data.
#define GDT_CS_RING0
Value to load into the CS register for kernel code.
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.
#define PERCPU_INIT()
Initialize all percpu variables within the current modules .percpu section.
void syscall_table_init(void)
Sort the syscall table and verify that all syscalls are present.
void cpu_init(cpu_t *cpu)
Initializes a CPU structure.
void devfs_init(void)
Initializes the devfs.
void filesystem_expose(void)
Exposes the sysfs fs directory.
uint64_t namespace_copy(namespace_t *dest, namespace_t *src)
Copy mounts from one namespace to another.
namespace_t * namespace_new(namespace_t *parent)
Create a new namespace.
void netfs_init(void)
Initialize the networking filesystem.
void procfs_init(void)
Register the procfs filesystem.
void sysfs_init(void)
Initializes the sysfs and mount an instance at /sys.
void tmpfs_init(void)
Registers the tmpfs filesystem and mounts an instance of it containing the boot ram disk as root.
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.
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,...)
void log_expose(void)
Expose kernel logs via the /dev/klog file.
size_t pmm_used_pages(void)
Get the number of used physical pages.
void pmm_init(void)
Read the boot info memory map and initialize the PMM.
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.
process_t * process_new(priority_t priority, group_member_t *group, namespace_t *ns)
Allocates and initializes a new process.
uint64_t process_set_cmdline(process_t *process, char **argv, uint64_t argc)
Sets the command line arguments for a process.
namespace_t * process_get_ns(process_t *process)
Gets the namespace of a process.
_NORETURN void loader_exec(void)
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 UNREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define TEST_ALL()
Run all registered tests in the ._tests section.
#define ALIGNED(alignment)
GCC aligned attribute.
#define PRIORITY_MAX_USER
The maximum priority user space is allowed to specify, inclusive.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define PAGE_SIZE
The size of a memory page in bytes.
static void init_process_spawn(void)
static void init_finalize(void)
#define RFLAGS_INTERRUPT_ENABLE
#define RFLAGS_ALWAYS_SET
__UINTPTR_TYPE__ uintptr_t
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.