39 lines
1.6 KiB
C
39 lines
1.6 KiB
C
/* Calcite, kernel/include/paging.h
|
|
* Copyright 2025 Benji Dial
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or (at
|
|
* your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
//kernel physical and virtual bases are passed so that we can compute the
|
|
//physical addresses of the kernel's statically allocated paging structures.
|
|
void init_paging(uint64_t kernel_physical_base, void *kernel_virtual_base);
|
|
|
|
//base and length should be page-aligned
|
|
void mark_physical_memory_free(uint64_t base, uint64_t length);
|
|
|
|
//maps one page. physical and virtual bases should be page-aligned.
|
|
//virtual address should be within kernel range.
|
|
void map_in_kernel_page_table(
|
|
uint64_t physical_base, void *virtual_base, int writable, int executable);
|
|
|
|
//returns a region of contiguous pages in kernel virtual memory where nothing
|
|
//is mapped. length should be page-aligned.
|
|
void *find_free_kernel_region(uint64_t length);
|
|
|
|
//implemented in paging.asm. the continuation should be noreturn.
|
|
[[noreturn]] void switch_to_kernel_page_tables(void (*continuation)());
|