ds
git-svn-id: https://spexeah.com:8443/svn/Asuro@145 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
d53b41750a
commit
126ec01343
6
.bochsrc
6
.bochsrc
@ -53,7 +53,7 @@
|
|||||||
#display_library: amigaos
|
#display_library: amigaos
|
||||||
#display_library: beos
|
#display_library: beos
|
||||||
#display_library: carbon
|
#display_library: carbon
|
||||||
#display_library: macintosh
|
display_library: sdl
|
||||||
#display_library: nogui
|
#display_library: nogui
|
||||||
#display_library: rfb, options="timeout=60" # time to wait for client
|
#display_library: rfb, options="timeout=60" # time to wait for client
|
||||||
#display_library: sdl, options="fullscreen" # startup in fullscreen mode
|
#display_library: sdl, options="fullscreen" # startup in fullscreen mode
|
||||||
@ -775,5 +775,5 @@ i440fxsupport: enabled=1
|
|||||||
# romimage: file=:bios:BIOS-bochs-latest, address=0xf0000
|
# romimage: file=:bios:BIOS-bochs-latest, address=0xf0000
|
||||||
# floppya: 1_44=[fd:], status=inserted
|
# floppya: 1_44=[fd:], status=inserted
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
display_library: sdl
|
#display_library: sdl
|
||||||
magic_break: enabled=1
|
#magic_break: enabled=1
|
||||||
|
BIN
lib/kernel.ppu
BIN
lib/kernel.ppu
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/libpsystem.a
BIN
lib/libpsystem.a
Binary file not shown.
BIN
lib/multiboot.o
BIN
lib/multiboot.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -24,23 +24,21 @@ implementation
|
|||||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
|
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
|
||||||
var
|
var
|
||||||
c : uint8;
|
c : uint8;
|
||||||
mbi : Pmultiboot_info_t;
|
|
||||||
mbm : uint32;
|
|
||||||
z : uint32;
|
z : uint32;
|
||||||
dds : uint32;
|
dds : uint32;
|
||||||
pint : puint32;
|
pint : puint32;
|
||||||
pint2 : puint32;
|
pint2 : puint32;
|
||||||
|
|
||||||
keyboard_layout : array [0..1] of TKeyInfo;
|
keyboard_layout : array [0..1] of TKeyInfo;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
mbi:= mbinfo;
|
multibootinfo:= mbinfo;
|
||||||
mbm:= mbmagic;
|
multibootmagic:= mbmagic;
|
||||||
|
|
||||||
console.init();
|
console.init();
|
||||||
|
|
||||||
console.writestringln('Booting Asuro...');
|
console.writestringln('Booting Asuro...');
|
||||||
|
|
||||||
if (mbm <> MULTIBOOT_BOOTLOADER_MAGIC) then begin
|
if (multibootmagic <> MULTIBOOT_BOOTLOADER_MAGIC) then begin
|
||||||
console.setdefaultattribute(console.combinecolors(Red, Black));
|
console.setdefaultattribute(console.combinecolors(Red, Black));
|
||||||
console.writestringln('Multiboot Compliant Boot-Loader Needed!');
|
console.writestringln('Multiboot Compliant Boot-Loader Needed!');
|
||||||
console.writestringln('HALTING');
|
console.writestringln('HALTING');
|
||||||
|
@ -54,6 +54,10 @@ type
|
|||||||
mtype: uint32;
|
mtype: uint32;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
multibootinfo : Pmultiboot_info_t = nil;
|
||||||
|
multibootmagic : uint32;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -4,16 +4,20 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
util,
|
util,
|
||||||
console;
|
console,
|
||||||
|
multiboot;
|
||||||
|
|
||||||
type
|
type
|
||||||
TPhysicalMemoryEntry = packed record
|
TPhysicalMemoryEntry = packed record
|
||||||
|
Scanned : Boolean;
|
||||||
Present : Boolean;
|
Present : Boolean;
|
||||||
|
Allocated : Boolean;
|
||||||
MappedTo : uint32;
|
MappedTo : uint32;
|
||||||
end;
|
end;
|
||||||
TPhysicalMemory = array[0..1023] of TPhysicalMemoryEntry;
|
TPhysicalMemory = array[0..1023] of TPhysicalMemoryEntry;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
|
function alloc_block(block : uint16; caller : uint32) : boolean;
|
||||||
function new_block(caller : uint32) : uint16;
|
function new_block(caller : uint32) : uint16;
|
||||||
procedure free_block(block : uint16; caller : uint32);
|
procedure free_block(block : uint16; caller : uint32);
|
||||||
|
|
||||||
@ -21,25 +25,112 @@ implementation
|
|||||||
|
|
||||||
var
|
var
|
||||||
PhysicalMemory : TPhysicalMemory;
|
PhysicalMemory : TPhysicalMemory;
|
||||||
|
nPresent : uint32;
|
||||||
|
|
||||||
|
procedure set_memory_area_present(base : uint64; length : uint64; present : boolean);
|
||||||
|
var
|
||||||
|
BlockHigh, BlockLow : uint16;
|
||||||
|
|
||||||
|
begin
|
||||||
|
BlockLow:= base SHR 22;
|
||||||
|
BlockHigh:= base+length SHR 22;
|
||||||
|
if not present then begin
|
||||||
|
PhysicalMemory[BlockLow].Scanned:= True;
|
||||||
|
PhysicalMemory[BlockHigh].Scanned:= True;
|
||||||
|
PhysicalMemory[BlockLow].Present:= False;
|
||||||
|
PhysicalMemory[BlockHigh].Present:= False;
|
||||||
|
end else begin
|
||||||
|
If not PhysicalMemory[BlockLow].Scanned then begin
|
||||||
|
PhysicalMemory[BlockLow].Scanned:= True;
|
||||||
|
PhysicalMemory[BlockLow].Present:= True;
|
||||||
|
end;
|
||||||
|
If not PhysicalMemory[BlockHigh].Scanned then begin
|
||||||
|
PhysicalMemory[BlockHigh].Scanned:= True;
|
||||||
|
PhysicalMemory[BlockHigh].Present:= True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure walk_memory_map;
|
||||||
|
var
|
||||||
|
mmap : Pmemory_map_t;
|
||||||
|
address : uint32;
|
||||||
|
length : uint32;
|
||||||
|
i : uint16;
|
||||||
|
|
||||||
|
begin
|
||||||
|
address:= multibootinfo^.mmap_addr + KERNEL_VIRTUAL_BASE;
|
||||||
|
length:= multibootinfo^.mmap_length;
|
||||||
|
mmap:= Pmemory_map_t(address);
|
||||||
|
for i:=0 to 1023 do begin
|
||||||
|
PhysicalMemory[i].Present:= True;
|
||||||
|
PhysicalMemory[i].Allocated:= False;
|
||||||
|
PhysicalMemory[i].Scanned:= False;
|
||||||
|
PhysicalMemory[i].MappedTo:= 0;
|
||||||
|
end;
|
||||||
|
while uint32(mmap) < (address + length) do begin
|
||||||
|
console.writewordln(mmap^.mtype);
|
||||||
|
if mmap^.mtype <> $01 then begin
|
||||||
|
set_memory_area_present(mmap^.base_addr, mmap^.length, False);
|
||||||
|
end;
|
||||||
|
mmap:= Pmemory_map_t(uint32(mmap)+mmap^.size+sizeof(mmap^.size));
|
||||||
|
end;
|
||||||
|
nPresent:= 0;
|
||||||
|
for i:=0 to 1023 do begin
|
||||||
|
if PhysicalMemory[i].Present then nPresent:= nPresent + 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure force_alloc_block(block : uint16; caller : uint32);
|
||||||
|
begin
|
||||||
|
PhysicalMemory[block].Allocated:= True;
|
||||||
|
PhysicalMemory[block].MappedTo:= caller;
|
||||||
|
console.writestring('PMM: 4MiB Block Force Allocated @ ');
|
||||||
|
console.writeword(block);
|
||||||
|
console.writestring(' [');
|
||||||
|
console.writehex(block SHL 22);
|
||||||
|
console.writestring(' - ');
|
||||||
|
console.writehex(((block+1) SHL 22));
|
||||||
|
console.writestringln(']');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure init;
|
procedure init;
|
||||||
begin
|
begin
|
||||||
console.writestringln('PMM: INIT BEGIN.');
|
console.writestringln('PMM: INIT BEGIN.');
|
||||||
with PhysicalMemory[0] do begin
|
walk_memory_map;
|
||||||
Present:= True;
|
force_alloc_block(0, 0);
|
||||||
MappedTo:= 0;
|
force_alloc_block(1, 0);
|
||||||
end;
|
force_alloc_block(2, 0); //First 12MiB reserved for Kernel/BIOS.
|
||||||
with PhysicalMemory[1] do begin
|
console.writestring('PMM: ');
|
||||||
Present:= True;
|
console.writeword(nPresent);
|
||||||
MappedTo:= 0;
|
console.writestringln('/1024 Block Available for Allocation.');
|
||||||
end;
|
|
||||||
with PhysicalMemory[2] do begin
|
|
||||||
Present:= True;
|
|
||||||
MappedTo:= 0;
|
|
||||||
end;
|
|
||||||
console.writestringln('PMM: INIT END.');
|
console.writestringln('PMM: INIT END.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function alloc_block(block : uint16; caller : uint32) : boolean;
|
||||||
|
begin
|
||||||
|
alloc_block:= false;
|
||||||
|
if (PhysicalMemory[block].Present) then begin
|
||||||
|
if PhysicalMemory[block].Allocated then begin
|
||||||
|
alloc_block:= false;
|
||||||
|
end else begin
|
||||||
|
PhysicalMemory[block].Allocated:= True;
|
||||||
|
PhysicalMemory[block].MappedTo:= caller;
|
||||||
|
console.writestring('4MiB Block Allocated @ ');
|
||||||
|
console.writeword(block);
|
||||||
|
console.writestring(' [');
|
||||||
|
console.writehex(block SHL 22);
|
||||||
|
console.writestring(' - ');
|
||||||
|
console.writehex(((block+1) SHL 22));
|
||||||
|
console.writestringln(']');
|
||||||
|
alloc_block:= true;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
GPF;
|
||||||
|
alloc_block:= false;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function new_block(caller : uint32) : uint16;
|
function new_block(caller : uint32) : uint16;
|
||||||
var
|
var
|
||||||
i : uint16;
|
i : uint16;
|
||||||
@ -47,21 +138,16 @@ var
|
|||||||
begin
|
begin
|
||||||
new_block:= 0;
|
new_block:= 0;
|
||||||
for i:=2 to 1023 do begin
|
for i:=2 to 1023 do begin
|
||||||
if not PhysicalMemory[i].Present then begin
|
if PhysicalMemory[i].Present then begin
|
||||||
PhysicalMemory[i].Present:= True;
|
if not PhysicalMemory[i].Allocated then begin
|
||||||
PhysicalMemory[i].MappedTo:= caller;
|
if alloc_block(i, caller) then begin
|
||||||
new_block:= i;
|
new_block:= i;
|
||||||
console.writestring('4MiB Block Added @ ');
|
|
||||||
console.writeword(i);
|
|
||||||
console.writestring(' [');
|
|
||||||
console.writehex(i SHL 22);
|
|
||||||
console.writestring(' - ');
|
|
||||||
console.writehex(((i+1) SHL 22));
|
|
||||||
console.writestringln(']');
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure free_block(block : uint16; caller : uint32);
|
procedure free_block(block : uint16; caller : uint32);
|
||||||
begin
|
begin
|
||||||
@ -73,11 +159,15 @@ begin
|
|||||||
GPF;
|
GPF;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
if not PhysicalMemory[block].Present then begin
|
||||||
|
GPF;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
if PhysicalMemory[block].MappedTo <> caller then begin
|
if PhysicalMemory[block].MappedTo <> caller then begin
|
||||||
GPF;
|
GPF;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
PhysicalMemory[block].Present:= false;
|
PhysicalMemory[block].Allocated:= false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -81,14 +81,14 @@ begin
|
|||||||
mov eax, rldpd
|
mov eax, rldpd
|
||||||
mov CR3, eax
|
mov CR3, eax
|
||||||
end;
|
end;
|
||||||
console.writestringln('New Page Added:');
|
console.writestringln('VMM: New Page Added:');
|
||||||
|
|
||||||
console.writestring('- P:');
|
console.writestring('VMM: - P:');
|
||||||
console.writehex(page_number);
|
console.writehex(page_number);
|
||||||
console.writestring('-->B:');
|
console.writestring('-->B:');
|
||||||
console.writehexln(block);
|
console.writehexln(block);
|
||||||
|
|
||||||
console.writestring('- P:[');
|
console.writestring('VMM: - P:[');
|
||||||
console.writehex(page_number SHL 22);
|
console.writehex(page_number SHL 22);
|
||||||
console.writestring(' - ');
|
console.writestring(' - ');
|
||||||
console.writehex(((page_number+1) SHL 22));
|
console.writehex(((page_number+1) SHL 22));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user