MMU but in C

paging
E. Almqvist 3 years ago
parent 06d9d811d2
commit 7baf28a82d
  1. 10
      kernel/paging.c
  2. 3
      kernel/paging.h

@ -1,8 +1,14 @@
#include "paging.h"
// Page Entry struct
struct page_entry {
unsigned int index;
unsigned int start_addr;
};
} page_table[PAGE_TABLE_SIZE];
page_entry page_table[PAGE_TABLE_SIZE];
int get_phys_addr(int virt_addr) {
int index = virt_addr / PAGE_SIZE; // page index for the virtual address
int offset = virt_addr % PAGE_SIZE; // actual physical offset for the address
return page_table[index].start_addr + offset;
}

@ -2,5 +2,6 @@
#define PAGE_TABLE_SIZE 128
struct page_entry;
// page_entry page_table[PAGE_TABLE_SIZE];
char** heap_alloc(unsigned int size); // Process heap allocation
int get_phys_addr(int virt_addr);

Loading…
Cancel
Save