Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Kernel API

English | 한국어

English

This page documents the internal kernel crate API surfaces under kernel/. Most subsystem APIs are exposed through each crate's src/api.rs. Prefer these API modules over reaching into private subsystem modules.

API Surface Map

CrateAPI modulePurpose
kernel-halkernel/hal/src/api.rsGDT/IDT/ACPI/PIC/RTC/SIMD setup, interrupt hooks, CPU helpers.
kernel-mmkernel/mm/src/api.rsheap, paging, physical frames, higher-half address helpers.
kernel-objectkernel/object/src/api.rstyped object/handle/session rights shared by kernel subsystems.
kernel-ipc-runtimekernel/ipc-runtime/src/api.rskernel shared region creation, mapping, frame export.
kernel-pskernel/ps/src/api.rsscheduler, process/thread state, user task lifecycle, waits, snapshots.
kernel-io-managerkernel/io-manager/src/api.rsblock, boot volume, console, device, tty, input, USB, VFS, drivers.
kernel-compatkernel/compat/src/api.rsLinux/Windows compatibility syscall and console host API.
kernel-executivekernel/executive/src/lib.rsboot orchestration and cross-subsystem hook registration.
nucleus-corekernel/nucleus-core/src/debug/mod.rsstructured logging, panic/debug output, boot trace helpers.

Boot-Time Call Order

The kernel entry path in kernel/src/main.rs uses these APIs in strict order:

hal::disable_interrupts
debug::boot_trace::init
hal::init_gdt
hal::init_idt
mm::init_paging
hal::enter_higher_half
hal::call_with_stack
kernel_executive::boot::kernel_main_bootstrap

Do not reorder boot APIs unless the call site and subsystem invariants are reviewed together.

HAL API

Use kernel_hal::api for architecture and interrupt boundaries.

GroupKey APIsNotes
bootinit_gdt, init_idt, init_acpi, enter_higher_half, call_with_stackBoot-only setup and unsafe control transfer helpers.
cpuinit_simd, simd_mode_name, current_ripCPU feature/runtime helpers.
interruptsdisable_interrupts, init_pic, register_task_hooks, register_interrupt_hooks, register_heartbeat_hooksHook registration connects HAL IRQ paths to scheduler/IO/heartbeat behavior.
timeinit_rtcRTC initialization and dispatch registration.

Memory API

Use kernel_mm::api for allocator, paging, physical memory, and virtual address helpers.

GroupKey APIsNotes
allocKernelAllocator, init_heap, handle_alloc_errorKernel global allocator support.
bootinit_paging, init_phys, paging_smoke_testEarly memory bootstrap.
physusable_bytes, free_bytes, alloc_frame, free_framePhysical frame accounting/allocation.
address_spaceProcessAddressSpace, PageTableFlags, debug_direct_map_flags_for_addrProcess address space and debug helpers.
virthigher_half_addr, kernel_virt_offsetHigher-half address conversion.

Process/Scheduler API

Use kernel_ps::api for task scheduling and user process state.

GroupKey APIsNotes
bootinit, is_initialized, service_deferred_workScheduler lifecycle and deferred work.
faultretire_current_user_task_due_to_fault, halt_current_retired_taskUser fault disposition.
processspawn_user_process, spawn_kernel_processProcess creation.
snapshotcurrent_user_snapshot, current_user_process_id, retain_current_user_process_state, with_current_user_process_state_mutCurrent/process state access.
taskyield_now, interrupt handler addresses, console session setters, runtime hooksScheduling and interrupt integration.
waitwait_for_childWait/child status handling.

IO Manager API

Use kernel_io_manager::api for devices, boot volume state, VFS, console, and driver integration.

GroupKey APIsNotes
bootinit_gui, init_boot_info, boot_volume_identity, enter_kernel_vfs_runtime, enter_userspace_runtimeBoot volume and runtime phase transitions.
blockregister_boot_volume_opener, init_block_devices, block_descriptors, lookup_blockBlock device registration and lookup.
consoleinit_console, init_tty, write_console, service_consoleKernel console and TTY service.
deviceopen, read_to_current_user, read_to_user, ioctl_from_user/dev-style device access from kernel/syscall paths.
ttysession input/output and termios helpersConsole session IO.
driverinitialize_loadable_modules_for_class, Linux runtime hooksDriver load/service integration.
inputinit_input, interrupt handlers, service pending countersKeyboard/mouse/HID input.
usbinit_usb, debug countersUSB host path.
vfsinit_vfs, normalize_kernel_path, mount/open/metadata/access/readlink helpersCurrent-process VFS operations.

Object And IPC APIs

CrateKey APIsNotes
kernel_object::apiDeviceHandle, DeviceId, HandleToken, rights types, ConsoleSessionHandleShared object and handle vocabulary.
kernel_ipc_runtime::apicreate_shared_region, map_shared_region, shared_region_framesKernel shared memory region lifecycle.

Compatibility API

Use kernel_compat::api for Linux/Windows compatibility surfaces.

GroupKey APIsNotes
linuxLinux process/syscall state re-exports and offset helpersLinux ABI support.
windowsWindows compatibility re-exportsWindows userland compatibility.
console_hostconsole host helpersConsole-hosted user programs.
syscallinit_syscalls, service_pending, GS-base helpersSyscall and compat runtime service path.

Usage Rules

  • Import API modules with aliases, for example use kernel_mm::api as mm_api.
  • Do not call private subsystem modules from another kernel crate when an api.rs wrapper exists.
  • Boot APIs often have ordering assumptions; follow the call order in kernel/src/main.rs and kernel/executive.
  • APIs that copy to/from user memory must be called only from syscall or process-context-aware paths.
  • Use crate::debug or nucleus_core::debug for kernel logs; see Logging Guide.

한국어

이 문서는 kernel/ 아래 internal kernel crate API surface를 설명합니다. 대부분의 subsystem API는 각 crate의 src/api.rs를 통해 노출됩니다. 다른 kernel crate에서 private subsystem module을 직접 참조하기보다 이 API module을 우선 사용하세요.

API Surface Map

CrateAPI modulePurpose
kernel-halkernel/hal/src/api.rsGDT/IDT/ACPI/PIC/RTC/SIMD setup, interrupt hook, CPU helper
kernel-mmkernel/mm/src/api.rsheap, paging, physical frame, higher-half address helper
kernel-objectkernel/object/src/api.rskernel subsystem이 공유하는 typed object/handle/session rights
kernel-ipc-runtimekernel/ipc-runtime/src/api.rskernel shared region 생성, mapping, frame export
kernel-pskernel/ps/src/api.rsscheduler, process/thread state, user task lifecycle, wait, snapshot
kernel-io-managerkernel/io-manager/src/api.rsblock, boot volume, console, device, tty, input, USB, VFS, driver
kernel-compatkernel/compat/src/api.rsLinux/Windows compatibility syscall과 console host API
kernel-executivekernel/executive/src/lib.rsboot orchestration과 cross-subsystem hook registration
nucleus-corekernel/nucleus-core/src/debug/mod.rsstructured logging, panic/debug output, boot trace helper

Boot-Time Call Order

kernel/src/main.rs의 kernel entry path는 다음 순서로 API를 사용합니다.

hal::disable_interrupts
debug::boot_trace::init
hal::init_gdt
hal::init_idt
mm::init_paging
hal::enter_higher_half
hal::call_with_stack
kernel_executive::boot::kernel_main_bootstrap

boot API는 call site와 subsystem invariant를 같이 검토하지 않는 한 순서를 바꾸지 마세요.

HAL API

architecture와 interrupt boundary는 kernel_hal::api를 사용합니다.

GroupKey APIsNotes
bootinit_gdt, init_idt, init_acpi, enter_higher_half, call_with_stackboot-only setup과 unsafe control transfer helper
cpuinit_simd, simd_mode_name, current_ripCPU feature/runtime helper
interruptsdisable_interrupts, init_pic, register_task_hooks, register_interrupt_hooks, register_heartbeat_hooksHAL IRQ path를 scheduler/IO/heartbeat 동작에 연결
timeinit_rtcRTC initialization과 dispatch registration

Memory API

allocator, paging, physical memory, virtual address helper는 kernel_mm::api를 사용합니다.

GroupKey APIsNotes
allocKernelAllocator, init_heap, handle_alloc_errorkernel global allocator support
bootinit_paging, init_phys, paging_smoke_testearly memory bootstrap
physusable_bytes, free_bytes, alloc_frame, free_framephysical frame accounting/allocation
address_spaceProcessAddressSpace, PageTableFlags, debug_direct_map_flags_for_addrprocess address space와 debug helper
virthigher_half_addr, kernel_virt_offsethigher-half address conversion

Process/Scheduler API

task scheduling과 user process state는 kernel_ps::api를 사용합니다.

GroupKey APIsNotes
bootinit, is_initialized, service_deferred_workscheduler lifecycle과 deferred work
faultretire_current_user_task_due_to_fault, halt_current_retired_taskuser fault disposition
processspawn_user_process, spawn_kernel_processprocess creation
snapshotcurrent_user_snapshot, current_user_process_id, retain_current_user_process_state, with_current_user_process_state_mutcurrent/process state access
taskyield_now, interrupt handler addresses, console session setters, runtime hooksscheduling과 interrupt integration
waitwait_for_childwait/child status handling

IO Manager API

device, boot volume state, VFS, console, driver integration은 kernel_io_manager::api를 사용합니다.

GroupKey APIsNotes
bootinit_gui, init_boot_info, boot_volume_identity, enter_kernel_vfs_runtime, enter_userspace_runtimeboot volume과 runtime phase transition
blockregister_boot_volume_opener, init_block_devices, block_descriptors, lookup_blockblock device registration과 lookup
consoleinit_console, init_tty, write_console, service_consolekernel console과 TTY service
deviceopen, read_to_current_user, read_to_user, ioctl_from_userkernel/syscall path의 /dev style device access
ttysession input/output and termios helpersconsole session IO
driverinitialize_loadable_modules_for_class, Linux runtime hooksdriver load/service integration
inputinit_input, interrupt handlers, service pending counterskeyboard/mouse/HID input
usbinit_usb, debug countersUSB host path
vfsinit_vfs, normalize_kernel_path, mount/open/metadata/access/readlink helperscurrent-process VFS operation

Object And IPC APIs

CrateKey APIsNotes
kernel_object::apiDeviceHandle, DeviceId, HandleToken, rights types, ConsoleSessionHandleshared object/handle vocabulary
kernel_ipc_runtime::apicreate_shared_region, map_shared_region, shared_region_frameskernel shared memory region lifecycle

Compatibility API

Linux/Windows compatibility surface는 kernel_compat::api를 사용합니다.

GroupKey APIsNotes
linuxLinux process/syscall state re-exports and offset helpersLinux ABI support
windowsWindows compatibility re-exportsWindows userland compatibility
console_hostconsole host helpersconsole-hosted user program
syscallinit_syscalls, service_pending, GS-base helperssyscall과 compat runtime service path

Usage Rules

  • use kernel_mm::api as mm_api처럼 API module을 alias해서 import하세요.
  • api.rs wrapper가 있으면 다른 kernel crate에서 private subsystem module을 직접 호출하지 마세요.
  • boot API는 ordering assumption이 강합니다. kernel/src/main.rskernel/executive의 call order를 따르세요.
  • user memory로 copy하는 API는 syscall 또는 process-context-aware path에서만 호출해야 합니다.
  • kernel log는 crate::debug 또는 nucleus_core::debug를 사용하세요. 자세한 내용은 로깅 가이드를 참고하세요.