|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "kstack.h"#include "memory_layout.h"#include "phys.h"#include "pmm.h"#include "arch/arch.h"#include "common/memory.h"#include "kernel/process/process.h"#include "kernel/sync/spinlock.h"#include "kernel/memory/tlb.h"Macros | |
| #define | KSTACK_SLOT_SIZE (KSTACK_GUARD_SIZE + KERNEL_STACK_SIZE) |
| #define | KSTACK_SLOTS PROCESS_MAX |
| #define | KSTACK_PAGES (KERNEL_STACK_SIZE / PAGE_SIZE) |
| #define | KSTACK_REGION_END (KSTACK_REGION_BASE + KSTACK_SLOTS * KSTACK_SLOT_SIZE) |
Functions | |
| void | kstack_init (void) |
| reserve the kernel stack region. | |
| uintptr_t | kstack_alloc (void) |
| allocate and map a zeroed kernel stack. | |
| void | kstack_free (uintptr_t base) |
| unmap a kernel stack and return its frames and slot. | |
| bool | kstack_is_guard (uintptr_t addr) |
| check whether an address falls in the guard page of any stack slot. | |
| #define KSTACK_SLOT_SIZE (KSTACK_GUARD_SIZE + KERNEL_STACK_SIZE) |
| #define KSTACK_SLOTS PROCESS_MAX |
| #define KSTACK_PAGES (KERNEL_STACK_SIZE / PAGE_SIZE) |
| #define KSTACK_REGION_END (KSTACK_REGION_BASE + KSTACK_SLOTS * KSTACK_SLOT_SIZE) |
| void kstack_init | ( | void | ) |
reserve the kernel stack region.
must run after paging_init() and before the first address space is created (process_create()).
| uintptr_t kstack_alloc | ( | void | ) |
allocate and map a zeroed kernel stack.
| void kstack_free | ( | uintptr_t | base | ) |
unmap a kernel stack and return its frames and slot.
never free the stack the CPU is currently running on.
| base | the value kstack_alloc() returned. |