Nabend zusammen,
habe mir noch einmal den Code angeschaut und ihn elementarer gemacht.
Leider geht es immer noch nicht.
Mein File zum Paging sieht jetzt so aus:
#include <kernel32.h>
#include <memory/mmu.h>
#include <memory/pmmu.h>
//internal methods
void map_pages(physaddr_t , virtaddr_t , cond_flags , size_t);
void directory_init();
void printReserved(int , int);
//methods from the asm-file
extern void _write_cr3(dword);
extern void _write_cr0(dword);
extern dword _read_cr0();
extern dword _read_cr3();
page_table_t directory;
extern dword bitmap_length;
extern dword *bitmap_virt;
void paging_init(){
size_t param;
//initialize the directory
directory_init();
//map the kernel
param = ((dword)kernel_end - (dword)kernel_start) / BLOCK_SIZE;
map_pages(kernel_start , kernel_mem_start , PAGE_READWRITE | PAGE_PRESENT , param);
//map the video
param = 80 * 25 * 2 / BLOCK_SIZE + 1;
map_pages((physaddr_t)0xB8000 , (virtaddr_t)0xB8000 , PAGE_READWRITE | PAGE_PRESENT , param);
//map the directory
map_pages(directory , directory , PAGE_READWRITE | PAGE_PRESENT , 1);
//map the bitmap
param = bitmap_length / BLOCK_SIZE;
map_pages(bitmap_virt , bitmap_virt , PAGE_READWRITE | PAGE_PRESENT , param);
_write_cr3((dword)directory);
_write_cr0((_read_cr0() | 0x80000000));
}
void directory_init(){
size_t i;
directory = phys_alloc(TABLE_SIZE * sizeof(page_table_t) / BLOCK_SIZE);
memset(directory , 0 , TABLE_SIZE);
}
void map_pages(physaddr_t paddr , virtaddr_t vaddr , cond_flags flags , size_t size){
size_t i , offset = ((dword)vaddr >> SHIFT_PAGE) % TABLE_SIZE;
page_table_t table;
dword phys_addr;
if(size >= TABLE_SIZE - offset){
//TODO: change parameters
}
if(directory[(dword)vaddr >> SHIFT_DIRECTORY] == NULL){
puts("Generating new table\n");
//prepare the table
table = phys_alloc(TABLE_SIZE * sizeof(page_table_t) / BLOCK_SIZE);
memset(table , 0 , TABLE_SIZE);
//register in the directory
directory[(dword)vaddr >> SHIFT_DIRECTORY] = (dword)table | PAGE_PRESENT | PAGE_READWRITE;
}
table = (page_table_t)directory[(dword)vaddr >> SHIFT_DIRECTORY];
for(i = 0; i <= size; i++){
phys_addr = (dword)paddr + i * BLOCK_SIZE;
table[offset + i] = phys_addr | flags;
}
}
Habe immer noch keine Ahnung woran das liegt.
Die Berechnung müsste ja an sich stimmen.
Seht ihr nun vllt den Fehler?
Gruß
rizor
[EDIT]
Stimmt meine Theorie überhaupt, dass ich einfach nur die Offset-Adresse berechne und Dann in meinem Array einfach solange hoch zählen muss, bis alles gemappt ist, was im physischen Speicher liegt?