git-svn-id: https://spexeah.com:8443/svn/Asuro@142 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron
2017-05-20 16:00:23 +00:00
parent 96e646091b
commit 805f20ca31
8 changed files with 48 additions and 40 deletions

View File

@ -54,12 +54,16 @@ begin
pmemorymanager.init();
vmemorymanager.init();
//
vmemorymanager.new_page(0);
pint:= puint32(0);
console.writestringln('Writing 1234 to Logical Address $00000000');
pint^:= 1234;
if pint^ = 1234 then console.writestringln('Read 1234 back from Logical Address $00000000!!!');
if pint^ = 1234 then begin
console.writestringln('Read 1234 back from Logical Address $00000000!!!');
end;
while true do begin end;
//scheduler.init();

View File

@ -31,6 +31,7 @@ var
procedure init;
function new_page(page_number : uint16) : boolean;
function map_page(page_number : uint16; block : uint16) : boolean;
function new_page_at_address(address : uint32) : boolean;
procedure free_page(page_number : uint16);
procedure free_page_at_address(address : uint32);
@ -57,59 +58,62 @@ var
begin
console.writestringln('VMM: INIT BEGIN.');
PageDirectory:= load_current_page_directory;
PageDirectory^[KERNEL_PAGE_NUMBER + 1].Present:= True;
PageDirectory^[KERNEL_PAGE_NUMBER + 1].PageSize:= True;
PageDirectory^[KERNEL_PAGE_NUMBER + 1].Writable:= True;
PageDirectory^[KERNEL_PAGE_NUMBER + 1].Address:= (1 SHL 22);
PageDirectory^[KERNEL_PAGE_NUMBER + 2].Present:= True;
PageDirectory^[KERNEL_PAGE_NUMBER + 2].PageSize:= True;
PageDirectory^[KERNEL_PAGE_NUMBER + 2].Writable:= True;
PageDirectory^[KERNEL_PAGE_NUMBER + 2].Address:= (2 SHL 22);
map_page(KERNEL_PAGE_NUMBER + 1, 1);
map_page(KERNEL_PAGE_NUMBER + 2, 2);
console.writestringln('VMM: INIT END.');
end;
function map_page(page_number : uint16; block : uint16) : boolean;
var
addr : ubit20;
page : uint16;
rldpd : uint32;
begin
map_page:= false;
PageDirectory^[page_number].Present:= true;
addr:= block;
PageDirectory^[page_number].Address:= addr;
PageDirectory^[page_number].PageSize:= true;
PageDirectory^[page_number].Writable:= true;
rldpd:= uint32(PageDirectory) - KERNEL_VIRTUAL_BASE;
asm
mov eax, rldpd
mov CR3, eax
end;
console.writestringln('New Page Added:');
console.writestring('- P:');
console.writehex(page_number);
console.writestring('-->B:');
console.writehexln(block);
console.writestring('- P:[');
console.writehex(page_number SHL 22);
console.writestring(' - ');
console.writehex(((page_number+1) SHL 22));
console.writestring(']-->B:[');
console.writehex(block SHL 22);
console.writestring(' - ');
console.writehex(((block+1) SHL 22));
console.writestringln(']');
map_page:= true;
end;
function new_page(page_number : uint16) : boolean;
var
block : uint16;
page : uint16;
rldpd : uint32;
begin
new_page:= false;
if PageDirectory^[page_number].Present then exit;
//if PageDirectory^[page_number].Reserved then exit;
if PageDirectory^[page_number].Reserved then exit;
block:= pmemorymanager.new_block(uint32(PageDirectory));
if block < 2 then begin
GPF;
exit;
end else begin
PageDirectory^[page_number].Present:= true;
PageDirectory^[page_number].Address:= block-1;
PageDirectory^[page_number].PageSize:= true;
PageDirectory^[page_number].Writable:= true;
rldpd:= uint32(PageDirectory) - KERNEL_VIRTUAL_BASE;
asm
mov eax, rldpd
mov CR3, eax
end;
new_page:= true;
console.writestringln('New Page Added:');
console.writestring('- P:');
console.writehex(page_number);
console.writestring('-->B:');
console.writehexln(block);
console.writestring('- P:[');
console.writeword(page_number SHL 22);
console.writestring(' - ');
console.writehex(((page_number+1) SHL 22));
console.writestring(']-->B:[');
console.writehex(block SHL 22);
console.writestring(' - ');
console.writehex(((block+1) SHL 22));
console.writestringln(']');
new_page:= map_page(page_number, block);
end;
end;