1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-11-27 11:24:34 -05:00

Do not pass PFA to paging

This commit is contained in:
Alex Kotov 2021-12-19 07:13:51 +05:00
parent 59885bca4e
commit 411b2f73ae
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 8 additions and 16 deletions

View file

@ -64,8 +64,8 @@ void main(
// TODO: maybe rename to init? // TODO: maybe rename to init?
paging_clear(&paging); paging_clear(&paging);
paging_identity(&paging, &pfa); paging_identity(&paging);
paging_mapkernel(&paging, &pfa, &kinfo); paging_mapkernel(&paging, &kinfo);
paging_load(&paging); paging_load(&paging);
paging_enable(); paging_enable();

View file

@ -4,12 +4,7 @@
#include <kernaux/libc.h> #include <kernaux/libc.h>
#include <kernaux/stdlib.h> #include <kernaux/stdlib.h>
static void mapping( static void mapping(struct Paging *paging, uint32_t virt, uint32_t phys);
struct Paging *paging,
KernAux_PFA pfa,
uint32_t virt,
uint32_t phys
);
void paging_load(struct Paging *const paging) void paging_load(struct Paging *const paging)
{ {
@ -52,17 +47,16 @@ void paging_clear(struct Paging *const paging)
memset(paging, 0, sizeof(*paging)); memset(paging, 0, sizeof(*paging));
} }
void paging_identity(struct Paging *const paging, const KernAux_PFA pfa) void paging_identity(struct Paging *const paging)
{ {
for (size_t i = 0; i < PAGE_DIR_LENGTH; ++i) { for (size_t i = 0; i < PAGE_DIR_LENGTH; ++i) {
const size_t addr = i * PAGE_BIG_SIZE; const size_t addr = i * PAGE_BIG_SIZE;
mapping(paging, pfa, addr, addr); mapping(paging, addr, addr);
} }
} }
void paging_mapkernel( void paging_mapkernel(
struct Paging *const paging, struct Paging *const paging,
const KernAux_PFA pfa,
const struct Kernel_Info *const kinfo const struct Kernel_Info *const kinfo
) { ) {
assert(!(kinfo->kernel_phys_base % PAGE_BIG_SIZE), "Kernel physical address is not aligned."); assert(!(kinfo->kernel_phys_base % PAGE_BIG_SIZE), "Kernel physical address is not aligned.");
@ -73,7 +67,7 @@ void paging_mapkernel(
size_t mapped = 0; size_t mapped = 0;
while (mapped < kinfo->kernel_size) { while (mapped < kinfo->kernel_size) {
mapping(paging, pfa, virt, phys); mapping(paging, virt, phys);
phys += PAGE_BIG_SIZE; phys += PAGE_BIG_SIZE;
virt += PAGE_BIG_SIZE; virt += PAGE_BIG_SIZE;
@ -83,7 +77,6 @@ void paging_mapkernel(
void mapping( void mapping(
struct Paging *const paging, struct Paging *const paging,
const KernAux_PFA pfa,
const uint32_t virt, const uint32_t virt,
const uint32_t phys const uint32_t phys
) { ) {

View file

@ -5,7 +5,6 @@
#include "info.h" #include "info.h"
#include <kernaux/arch/i386.h> #include <kernaux/arch/i386.h>
#include <kernaux/pfa.h>
#define PAGE_DIR_ALIGN 4096 #define PAGE_DIR_ALIGN 4096
@ -27,7 +26,7 @@ void paging_enable();
void paging_clear(struct Paging *paging); void paging_clear(struct Paging *paging);
void paging_identity(struct Paging *paging, KernAux_PFA pfa); void paging_identity(struct Paging *paging);
void paging_mapkernel(struct Paging *paging, KernAux_PFA pfa, const struct Kernel_Info *kinfo); void paging_mapkernel(struct Paging *paging, const struct Kernel_Info *kinfo);
#endif #endif