dd
git-svn-id: https://spexeah.com:8443/svn/Asuro@170 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
08aee483c5
commit
d1e6d28f90
BIN
bin/kernel.bin
BIN
bin/kernel.bin
Binary file not shown.
Binary file not shown.
BIN
lib/gdt.ppu
BIN
lib/gdt.ppu
Binary file not shown.
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.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
{ ************************************************
|
||||
* Asuro
|
||||
* Unit: ContextSwitcher
|
||||
* Description: Switches context between processes
|
||||
* when preempted by the scheduler.
|
||||
************************************************
|
||||
* Author: K Morris
|
||||
* Contributors:
|
||||
************************************************ }
|
||||
unit contextswitcher;
|
||||
|
||||
interface
|
||||
|
||||
implementation;
|
||||
|
||||
end.
|
11
src/gdt.pas
11
src/gdt.pas
@ -35,6 +35,7 @@ var
|
||||
gdt_pointer : TGDT_Pointer;
|
||||
|
||||
procedure init();
|
||||
procedure set_gate(Gate_Number : uint32; Base : uint32; Limit : uint32; Access : uint8; Granularity : uint8);
|
||||
|
||||
implementation
|
||||
|
||||
@ -71,11 +72,11 @@ begin
|
||||
console.writestringln('GDT: INIT START.');
|
||||
gdt_pointer.limit := (sizeof(TGDT_Entry) * 5) - 1;
|
||||
gdt_pointer.base := uint32(@gdt_entries);
|
||||
set_gate($00, $00, $00, $00, $00);
|
||||
set_gate($01, $00, $FFFFFFFF, $9A, $CF);
|
||||
set_gate($02, $00, $FFFFFFFF, $92, $CF);
|
||||
set_gate($03, $00, $FFFFFFFF, $FA, $CF);
|
||||
set_gate($04, $00, $FFFFFFFF, $F2, $CF);
|
||||
set_gate($00, $00, $00, $00, $00); //OFFSET: 0
|
||||
set_gate($01, $00, $FFFFFFFF, $9A, $CF); //OFFSET: 8
|
||||
set_gate($02, $00, $FFFFFFFF, $92, $CF); //OFFSET: 16
|
||||
set_gate($03, $00, $FFFFFFFF, $FA, $CF); //OFFSET: 24
|
||||
set_gate($04, $00, $FFFFFFFF, $F2, $CF); //OFFSET: 32
|
||||
console.writestringln('GDT: FLUSH.');
|
||||
flush_gdt(uint32(@gdt_pointer));
|
||||
console.writestringln('GDT: INIT END.');
|
||||
|
@ -25,6 +25,7 @@ uses
|
||||
vmemorymanager,
|
||||
pmemorymanager,
|
||||
lmemorymanager,
|
||||
tss,
|
||||
scheduler,
|
||||
PCI;
|
||||
|
||||
@ -64,9 +65,11 @@ begin
|
||||
pmemorymanager.init();
|
||||
vmemorymanager.init();
|
||||
lmemorymanager.init();
|
||||
|
||||
tss.init();
|
||||
scheduler.init();
|
||||
|
||||
while true do begin end;
|
||||
|
||||
STI;
|
||||
isr32.hook(uint32(@bios_data_area.tick_update));
|
||||
|
||||
|
@ -32,6 +32,9 @@ type
|
||||
end;
|
||||
PScheduler_Entry = ^TScheduler_Entry;
|
||||
|
||||
var
|
||||
Active : Boolean;
|
||||
|
||||
procedure init;
|
||||
procedure add_task(priority : uint8);
|
||||
|
||||
@ -70,10 +73,12 @@ end;
|
||||
|
||||
procedure delta(data : void);
|
||||
begin
|
||||
If Active then begin
|
||||
Tick:= Tick + 1;
|
||||
If Tick = 0 then context_switch();
|
||||
If (Current_Task^.Delta + (Current_Task^.Priority * Quantum)) <= Tick then context_switch();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure init;
|
||||
begin
|
||||
@ -85,6 +90,7 @@ begin
|
||||
Root_Task^.Next:= void(Root_Task);
|
||||
Current_Task:= Root_Task;
|
||||
Tick:= 0;
|
||||
Active:= False;
|
||||
isr32.hook(uint32(@delta));
|
||||
console.writestringln('SCHEDULER: INIT END.');
|
||||
end;
|
||||
|
@ -36,17 +36,42 @@ type
|
||||
PPageDirectory = ^TPageDirectory;
|
||||
|
||||
var
|
||||
KERNEL_PAGE_DIRECTORY : PPageDirectory;
|
||||
PageDirectory : PPageDirectory;
|
||||
|
||||
procedure init;
|
||||
function new_page(page_number : uint16) : boolean;
|
||||
function map_page(page_number : uint16; block : uint16) : boolean;
|
||||
function map_page_ex(page_number : uint16; block : uint16; PD : PPageDirectory) : boolean;
|
||||
function new_page_at_address(address : uint32) : boolean;
|
||||
procedure free_page(page_number : uint16);
|
||||
procedure free_page_at_address(address : uint32);
|
||||
function new_page_directory : uint32;
|
||||
function new_kernel_mapped_page_directory : uint32;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
lmemorymanager;
|
||||
|
||||
function new_page_directory : uint32;
|
||||
begin
|
||||
new_page_directory:= uint32(kalloc(sizeof(TPageDirectory)));
|
||||
end;
|
||||
|
||||
function new_kernel_mapped_page_directory : uint32;
|
||||
var
|
||||
PD : PPageDirectory;
|
||||
i : uint32;
|
||||
|
||||
begin
|
||||
PD:= PPageDirectory(new_page_directory);
|
||||
for i:=KERNEL_PAGE_NUMBER to 1023 do begin
|
||||
PD^[i]:= KERNEL_PAGE_DIRECTORY^[i];
|
||||
end;
|
||||
new_kernel_mapped_page_directory:= uint32(PD);
|
||||
end;
|
||||
|
||||
function load_current_page_directory : PPageDirectory;
|
||||
var
|
||||
Directory : uint32;
|
||||
@ -67,30 +92,26 @@ var
|
||||
begin
|
||||
console.writestringln('VMM: INIT BEGIN.');
|
||||
PageDirectory:= load_current_page_directory;
|
||||
KERNEL_PAGE_DIRECTORY:= PageDirectory;
|
||||
map_page(KERNEL_PAGE_NUMBER + 1, 1);
|
||||
map_page(KERNEL_PAGE_NUMBER + 2, 2);
|
||||
map_page(KERNEL_PAGE_NUMBER + 3, 3);
|
||||
console.writestringln('VMM: INIT END.');
|
||||
end;
|
||||
|
||||
function map_page(page_number : uint16; block : uint16) : boolean;
|
||||
function map_page_ex(page_number : uint16; block : uint16; PD : PPageDirectory) : boolean;
|
||||
var
|
||||
addr : ubit20;
|
||||
page : uint16;
|
||||
rldpd : uint32;
|
||||
|
||||
begin
|
||||
map_page:= false;
|
||||
PageDirectory^[page_number].Present:= true;
|
||||
map_page_ex:= false;
|
||||
PD^[page_number].Present:= true;
|
||||
addr:= block;
|
||||
PageDirectory^[page_number].Address:= addr SHL 10;
|
||||
PageDirectory^[page_number].PageSize:= true;
|
||||
PageDirectory^[page_number].Writable:= true;
|
||||
rldpd:= uint32(PageDirectory) - KERNEL_VIRTUAL_BASE;
|
||||
asm
|
||||
mov eax, rldpd
|
||||
mov CR3, eax
|
||||
end;
|
||||
PD^[page_number].Address:= addr SHL 10;
|
||||
PD^[page_number].PageSize:= true;
|
||||
PD^[page_number].Writable:= true;
|
||||
|
||||
console.writestringln('VMM: New Page Added:');
|
||||
|
||||
console.writestring('VMM: - P:');
|
||||
@ -107,7 +128,28 @@ begin
|
||||
console.writestring(' - ');
|
||||
console.writehex(((block+1) SHL 22));
|
||||
console.writestringln(']');
|
||||
map_page:= true;
|
||||
map_page_ex:= true;
|
||||
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 SHL 10;
|
||||
PageDirectory^[page_number].PageSize:= true;
|
||||
PageDirectory^[page_number].Writable:= true;
|
||||
map_page:= map_page_ex(page_number, block, PageDirectory);
|
||||
rldpd:= uint32(PageDirectory) - KERNEL_VIRTUAL_BASE;
|
||||
asm
|
||||
mov eax, rldpd
|
||||
mov CR3, eax
|
||||
end;
|
||||
end;
|
||||
|
||||
function new_page(page_number : uint16) : boolean;
|
||||
|
Loading…
x
Reference in New Issue
Block a user