git-svn-id: https://spexeah.com:8443/svn/Asuro@372 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
kieron 2018-04-07 16:44:40 +00:00
parent 1fbdf09f72
commit 37d442edfc
70 changed files with 360 additions and 71 deletions

BIN
Asuro.iso

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -71,7 +71,7 @@ end;
procedure init(); procedure init();
begin begin
console.writestringln('BDA: Loaded.'); console.outputln('BDA','Loaded.');
//TO-DO search for important structures like the MCFG or the EBDA. //TO-DO search for important structures like the MCFG or the EBDA.
end; end;

View File

@ -42,6 +42,9 @@ procedure writecharln(character : char);
procedure writecharex(character : char; attributes : char); procedure writecharex(character : char; attributes : char);
procedure writecharlnex(character : char; attributes : char); procedure writecharlnex(character : char; attributes : char);
procedure Output(identifier : PChar; str : PChar);
procedure Outputln(identifier : PChar; str : PChar);
procedure writestring(str: PChar); procedure writestring(str: PChar);
procedure writestringln(str: PChar); procedure writestringln(str: PChar);
procedure writestringex(str: PChar; attributes : char); procedure writestringex(str: PChar; attributes : char);
@ -57,6 +60,7 @@ procedure writewordln(i: DWORD);
procedure writewordex(i: DWORD; attributes : char); procedure writewordex(i: DWORD; attributes : char);
procedure writewordlnex(i: DWORD; attributes : char); procedure writewordlnex(i: DWORD; attributes : char);
procedure writehexpair(b : uint8);
procedure writehex(i: DWORD); procedure writehex(i: DWORD);
procedure writehexln(i: DWORD); procedure writehexln(i: DWORD);
procedure writehexex(i : DWORD; attributes : char); procedure writehexex(i : DWORD; attributes : char);
@ -278,6 +282,36 @@ begin
console._safeincrement_x(); console._safeincrement_x();
end; end;
procedure writehexpair(b : uint8);
var
bn : Array[0..1] of uint8;
i : uint8;
begin
bn[0]:= b SHR 4;
bn[1]:= b AND $0F;
for i:=0 to 1 do begin
case bn[i] of
0:writestring('0');
1:writestring('1');
2:writestring('2');
3:writestring('3');
4:writestring('4');
5:writestring('5');
6:writestring('6');
7:writestring('7');
8:writestring('8');
9:writestring('9');
10:writestring('A');
11:writestring('B');
12:writestring('C');
13:writestring('D');
14:writestring('E');
15:writestring('F');
end;
end;
end;
procedure writehexex(i : dword; attributes: char); [public, alias: 'console_writehexex']; procedure writehexex(i : dword; attributes: char); [public, alias: 'console_writehexex'];
var var
Hex : Array[0..7] of Byte; Hex : Array[0..7] of Byte;
@ -340,6 +374,20 @@ begin
writehexlnex(i, Console_Properties.Default_Attribute); writehexlnex(i, Console_Properties.Default_Attribute);
end; end;
procedure Output(identifier : PChar; str : PChar);
begin
writestring('[');
writestring(identifier);
writestring('] ');
writestring(str);
end;
procedure Outputln(identifier : PChar; str : PChar);
begin
Output(identifier, str);
writestringln(' ');
end;
procedure writestringex(str: PChar; attributes: char); [public, alias: 'console_writestringex']; procedure writestringex(str: PChar; attributes: char); [public, alias: 'console_writestringex'];
var var
i : integer; i : integer;

View File

@ -62,7 +62,7 @@ end;
function load(ptr : void) : boolean; function load(ptr : void) : boolean;
begin begin
isr33.hook(uint32(@callback)); isr33.hook(uint32(@callback));
console.writestringln('PS/2 KEYBOARD: LOADED.'); console.outputln('PS/2 KEYBOARD', 'LOADED.');
load:= true; load:= true;
end; end;
@ -71,7 +71,7 @@ var
devid : TDeviceIdentifier; devid : TDeviceIdentifier;
begin begin
console.writestringln('PS/2 KEYBOARD: INIT BEGIN.'); console.outputln('PS/2 KEYBOARD', 'INIT BEGIN.');
if keyboard_layout[1].key_code = 0 then lang_USA(); if keyboard_layout[1].key_code = 0 then lang_USA();
devid.bus:= biUnknown; devid.bus:= biUnknown;
devid.id0:= 0; devid.id0:= 0;
@ -81,7 +81,7 @@ begin
devid.id4:= 0; devid.id4:= 0;
devid.ex:= nil; devid.ex:= nil;
drivermanagement.register_driver_ex('PS/2 Keyboard', @devid, @load, true); drivermanagement.register_driver_ex('PS/2 Keyboard', @devid, @load, true);
console.writestringln('PS/2 KEYBOARD: INIT END.'); console.outputln('PS/2 KEYBOARD', 'INIT END.');
end; end;
//2A AA //2A AA

View File

@ -107,7 +107,7 @@ end;
function load(ptr : void) : boolean; function load(ptr : void) : boolean;
begin begin
isr44.hook(uint32(@callback)); isr44.hook(uint32(@callback));
console.writestringln('PS/2 MOUSE: LOADED.'); console.outputln('PS/2 MOUSE', 'LOADED.');
load:= true; load:= true;
end; end;
@ -116,7 +116,7 @@ var
devid : TDeviceIdentifier; devid : TDeviceIdentifier;
begin begin
console.writestringln('PS/2 MOUSE: INIT BEGIN.'); console.outputln('PS/2 MOUSE', 'INIT BEGIN.');
devid.bus:= biUnknown; devid.bus:= biUnknown;
devid.id0:= 0; devid.id0:= 0;
devid.id1:= 0; devid.id1:= 0;
@ -125,7 +125,7 @@ begin
devid.id4:= 0; devid.id4:= 0;
devid.ex:= nil; devid.ex:= nil;
drivermanagement.register_driver_ex('PS/2 Mouse', @devid, @load, true); drivermanagement.register_driver_ex('PS/2 Mouse', @devid, @load, true);
console.writestringln('PS/2 MOUSE: INIT END.'); console.outputln('PS/2 MOUSE', 'INIT END.');
end; end;
end. end.

View File

@ -79,14 +79,14 @@ var
current_bus : uint8; current_bus : uint8;
begin begin
console.writestringln('PCI: Scanning Bus: 0'); console.outputln('PCI', 'Scanning Bus: 0');
scanBus(0); scanBus(0);
//while unscanned busses scan busses //while unscanned busses scan busses
current_bus := 1; current_bus := 1;
while true do begin while true do begin
if current_bus < bus_count then begin if current_bus < bus_count then begin
console.writestringln('PCI: Scanning Bus: '); console.output('PCI', 'Scanning Bus: ');
console.writeint(bus_count); console.writeintln(bus_count);
scanBus(current_bus); scanBus(current_bus);
current_bus := current_bus + 1; current_bus := current_bus + 1;
end else break; end else break;
@ -99,7 +99,7 @@ var
DevID : TDeviceIdentifier; DevID : TDeviceIdentifier;
begin begin
console.writestringln('PCI: INIT BEGIN.'); console.outputln('PCI','INIT BEGIN.');
DevID.Bus:= biUnknown; DevID.Bus:= biUnknown;
DevID.id0:= 0; DevID.id0:= 0;
DevID.id1:= 0; DevID.id1:= 0;
@ -107,7 +107,7 @@ begin
DevID.id3:= 0; DevID.id3:= 0;
DevID.ex:= nil; DevID.ex:= nil;
drivermanagement.register_driver_ex('PCI Driver', @DevID, @load, true); drivermanagement.register_driver_ex('PCI Driver', @DevID, @load, true);
console.writestringln('PCI: INIT END.'); console.outputln('PCI', 'INIT END.');
end; end;
procedure scanBus(bus : uint8); procedure scanBus(bus : uint8);
@ -315,7 +315,7 @@ begin
DevID^.id4:= device.vendor_id; DevID^.id4:= device.vendor_id;
DevID^.ex:= nil; DevID^.ex:= nil;
console.writestring('PCI: Found Device: '); console.output('PCI', 'Found Device: ');
console.writehex(device.header_type); console.writehex(device.header_type);
console.writestring(' '); console.writestring(' ');
console.writehex(device.device_id); console.writehex(device.device_id);

View File

@ -50,12 +50,12 @@ var
begin begin
devices:= PCI.getDeviceInfo($0C, $03, $10, count); devices:= PCI.getDeviceInfo($0C, $03, $10, count);
console.writestring('USB-OHCI: Found '); console.output('USB-OHCI Driver', 'Found ');
console.writeint(count); console.writeint(count);
console.writestringln(' USB Controller(s).'); console.writestringln(' USB Controller(s).');
if count > 0 then begin if count > 0 then begin
for i:=0 to count-1 do begin for i:=0 to count-1 do begin
console.writestring('USB: Controller['); console.output('USB-OHCI Driver', 'Controller[');
console.writeint(i); console.writeint(i);
console.writestring(']: '); console.writestring(']: ');
console.writehex(devices[i].device_id); console.writehex(devices[i].device_id);
@ -80,12 +80,12 @@ var
begin begin
devices:= PCI.getDeviceInfo($0C, $03, $00, count); devices:= PCI.getDeviceInfo($0C, $03, $00, count);
console.writestring('USB-UHCI: Found '); console.output('USB-UHCI Driver','Found ');
console.writeint(count); console.writeint(count);
console.writestringln(' USB Controller(s).'); console.writestringln(' USB Controller(s).');
if count > 0 then begin if count > 0 then begin
for i:=0 to count-1 do begin for i:=0 to count-1 do begin
console.writestring('USB: Controller['); console.output('USB-UHCI Driver','Controller[');
console.writeint(i); console.writeint(i);
console.writestring(']: '); console.writestring(']: ');
console.writehex(devices[i].device_id); console.writehex(devices[i].device_id);
@ -103,7 +103,7 @@ var
UHCI_ID, OHCI_ID : TDeviceIdentifier; UHCI_ID, OHCI_ID : TDeviceIdentifier;
begin begin
console.writestringln('USB: INIT BEGIN.'); console.outputln('USB Driver', 'INIT BEGIN.');
UHCI_ID.Bus:= biPCI; UHCI_ID.Bus:= biPCI;
UHCI_ID.id0:= idANY; UHCI_ID.id0:= idANY;
@ -124,7 +124,7 @@ begin
drivermanagement.register_driver('USB-UHCI Driver', @UHCI_ID, @loadUHCI); drivermanagement.register_driver('USB-UHCI Driver', @UHCI_ID, @loadUHCI);
drivermanagement.register_driver('USB-OHCI Driver', @OHCI_ID, @loadOHCI); drivermanagement.register_driver('USB-OHCI Driver', @OHCI_ID, @loadOHCI);
console.writestringln('USB: INIT END.'); console.outputln('USB Driver', 'INIT END.');
end; end;
end. end.

View File

@ -7,7 +7,9 @@ uses
strings, strings,
vmemorymanager, vmemorymanager,
lmemorymanager, lmemorymanager,
drivermanagement; drivermanagement,
drivertypes,
util;
const const
INTEL_VEND = $8086; INTEL_VEND = $8086;
@ -95,6 +97,9 @@ const
TSTA_LC = (1 SHL 2); // Late Collision TSTA_LC = (1 SHL 2); // Late Collision
LSTA_TU = (1 SHL 3); // Transmit Underrun LSTA_TU = (1 SHL 3); // Transmit Underrun
E1000_NUM_RX_DESC = 32;
E1000_NUM_TX_DESC = 8;
type type
PE1000_rx_desc = ^TE1000_rx_desc; PE1000_rx_desc = ^TE1000_rx_desc;
TE1000_rx_desc = bitpacked record TE1000_rx_desc = bitpacked record
@ -117,62 +122,203 @@ type
special : uint16; special : uint16;
end; end;
TCardType = (ctUnknown, ctE1000, ctI217, ct82577LM);
procedure init(); procedure init();
procedure fire(); procedure fire();
function getMACAddress : uint8; function getMACAddress : puint8;
function sendPacket(p_data : void; p_len : uint16) : sint32; function sendPacket(p_data : void; p_len : uint16) : sint32;
implementation implementation
var var
loaded : boolean;
card_type : TCardType;
bar_type : uint8; bar_type : uint8;
io_base : uint16; io_base : uint16;
mem_base : uint64; mem_base : uint64;
eeprom_exists : boolean; eeprom_exists : boolean;
mac : array[0..5] of uint8; mac : array[0..5] of uint8;
rx_descs : array[0..65535] of TE1000_rx_desc; rx_descs : array[0..E1000_NUM_RX_DESC-1] of PE1000_rx_desc;
tx_descs : array[0..65535] of TE1000_tx_desc; tx_descs : array[0..E1000_NUM_TX_DESC-1] of PE1000_tx_desc;
rx_curr : uint16; rx_curr : uint16;
tx_curr : uint16; tx_curr : uint16;
procedure writeCommand(p_address : uint16; p_value : uint32); procedure writeCommand(p_address : uint16; p_value : uint32);
var
mem : puint32;
begin begin
if (bar_type = 0) then begin
mem:= puint32(mem_base + p_address);
mem^:= p_value;
end else begin
outl(io_base + 0, p_address);
outl(io_base + 4, p_address)
end;
end; end;
function readCommand(p_address : uint16) : uint32; function readCommand(p_address : uint16) : uint32;
var
mem : puint32;
begin begin
if (bar_type = 0) then begin
mem:= puint32(mem_base + p_address);
readCommand:= mem^;
end else begin
outl(io_base, p_address);
readCommand:= inl(io_base + 4);
end;
end; end;
function detectEEPROM() : boolean; function detectEEPROM() : boolean;
begin var
val, i : uint32;
begin
val:= 0;
writeCommand(REG_EEPROM, $1);
for i:=0 to 1000 do begin
if eeprom_exists then break;
val:= readCommand(REG_EEPROM);
if (val and $10) > 0 then eeprom_exists:= true else eeprom_exists:= false;
end;
detectEEPROM:= eeprom_exists;
end; end;
function EEPROMRead( address : uint8 ) : uint32; function EEPROMRead( address : uint8 ) : uint32;
begin var
data : uint16;
tmp : uint32;
begin
tmp:= 0;
if (eeprom_exists) then begin
writeCommand( REG_EEPROM, 1 OR (uint32(address) SHL 8) );
while (tmp AND (1 SHL 4)) = 0 do begin
tmp:= readCommand(REG_EEPROM); //Might be wrong?
end;
end else begin
writeCommand( REG_EEPROM, 1 OR (uint32(address) SHL 2) );
while (tmp AND (1 SHL 1)) = 0 do begin
tmp:= readCommand(REG_EEPROM); //Might be wrong?
end;
end;
data:= uint16( (tmp SHR 16) AND ($FFFF) );
EEPROMRead:= data;
end; end;
function readMACAddress() : boolean; function readMACAddress() : boolean;
begin var
temp : uint32;
mem_base_mac_8 : puint8;
mem_base_mac_32 : puint32;
res : boolean;
i : uint32;
begin
res:= true;
if (eeprom_exists) then begin
temp:= EEPROMRead(0);
mac[0]:= temp AND $FF;
mac[1]:= temp SHR 8;
temp:= EEPROMRead(1);
mac[2]:= temp AND $FF;
mac[3]:= temp SHR 8;
temp:= EEPROMRead(2);
mac[4]:= temp AND $FF;
mac[5]:= temp SHR 8;
end else begin
mem_base_mac_8:= puint8(mem_base + $5400);
mem_base_mac_32:= puint32(mem_base + $5400);
if (mem_base_mac_32[0] <> 0) then begin
for i:=0 to 6 do begin
mac[i]:= mem_base_mac_8[i];
end;
end else begin
res:= false;
end;
end;
readMACAddress:= res;
end; end;
procedure startLink(); procedure startLink();
begin var
val : uint32;
begin
val:= readCommand(REG_CTRL);
writeCommand(REG_CTRL, val OR ECTRL_SLU);
end; end;
procedure rxinit(); procedure rxinit();
begin var
ptr : puint8;
outptr : puint8;
descs : PE1000_rx_desc;
i : uint32;
begin
ptr:= puint8(kalloc(sizeof(TE1000_rx_desc) * E1000_NUM_RX_DESC + 16));
descs:= PE1000_rx_desc(ptr);
for i:=0 to E1000_NUM_RX_DESC do begin
rx_descs[i]:= PE1000_rx_desc(uint32(descs + i*16));
rx_descs[i]^.address:= uint64(kalloc(8192 + 16));
rx_descs[i]^.status:= 0;
end;
outptr:= puint8(uint32(ptr) - KERNEL_VIRTUAL_BASE);
writeCommand(REG_TXDESCLO, uint32(uint64(outptr) SHR 32));
writeCommand(REG_TXDESCHI, uint32(uint64(outptr) AND $FFFFFFFF));
writeCommand(REG_RXDESCLO, uint32(outptr));
writeCommand(REG_RXDESCHI, 0);
writeCommand(REG_RXDESCLEN, E1000_NUM_RX_DESC * 16);
writeCommand(REG_RXDESCHEAD, 0);
writeCommand(REG_RXDESCTAIL, E1000_NUM_RX_DESC-1);
rx_curr:= 0;
writeCommand(REG_RCTRL, RCTL_EN OR RCTL_SBP OR RCTL_UPE OR RCTL_MPE OR RCTL_LBM_NONE OR RTCL_RDMTS_HALF OR RCTL_BAM OR RCTL_SECRC OR RCTL_BSIZE_2048);
end; end;
procedure txinit(); procedure txinit();
begin var
ptr : puint8;
outptr : puint8;
descs : PE1000_tx_desc;
i : uint32;
begin
ptr:= puint8(kalloc(sizeof(TE1000_tx_desc) * E1000_NUM_TX_DESC + 16));
descs:= PE1000_tx_desc(ptr);
for i:=0 to E1000_NUM_TX_DESC do begin
tx_descs[i]:= PE1000_tx_desc(uint32(descs + i*16));
tx_descs[i]^.address:= 0;
tx_descs[i]^.cmd:= 0;
tx_descs[i]^.status:= TSTA_DD;
end;
outptr:= puint8(uint32(ptr) - KERNEL_VIRTUAL_BASE);
writeCommand(REG_TXDESCHI, uint32(uint64(outptr) SHR 32));
writeCommand(REG_TXDESCLO, uint32(uint64(outptr) AND $FFFFFFFF));
writeCommand(REG_TXDESCLEN, E1000_NUM_TX_DESC * 16);
writeCommand( REG_TXDESCHEAD, 0 );
writeCommand( REG_TXDESCTAIL, 0 );
tx_curr:= 0;
writeCommand(REG_TCTRL, TCTL_EN OR TCTL_PSP OR (15 SHL TCTL_CT_SHIFT) OR (64 SHL TCTL_COLD_SHIFT) OR TCTL_RTLC);
//The following is needed for I217 & 82577LM
if (card_type = ct82577LM) OR (card_type = ctI217) then begin
writeCommand(REG_TCTRL, $3003F0FA);
writeCommand(REG_TIPG, $0060200A);
end;
end; end;
procedure enableInturrupt(); procedure enableInturrupt();
@ -185,9 +331,88 @@ begin
end; end;
function load(ptr : void) : boolean; procedure writeCardType();
begin begin
load:= true; console.output('E1000 Driver', 'Card Type: ');
case card_type of
ctUnknown:writestringln('Unknown');
ct82577LM:writestringln('82577LM');
ctE1000:writestringln('Generic E1000');
ctI217:writestringln('I217');
end;
end;
procedure writeMACAddress();
var
i : integer;
begin
console.writehexpair(mac[0]);
for i:=1 to 5 do begin
console.writestring(':');
console.writehexpair(mac[i]);
end;
console.writestringln(' ');
end;
function load(ptr : void) : boolean;
var
PCI_Info : PPCI_Device;
begin
console.outputln('E1000 Driver', 'Load Start.');
writeCardType();
PCI_Info:= PPCI_Device(ptr);
bar_type:= PCI_Info^.address0 AND $00000001;
io_base:= PCI_Info^.address0 AND $FFFFFFF0;
mem_base:= PCI_INFO^.address0 AND $FFFFFFFC;
{ !!!!! Dirty way to alloc the pages, needs fixing !!!!! }
kpalloc(io_base);
kpalloc(mem_base);
eeprom_exists:= false;
detectEEPROM();
if eeprom_exists then console.outputln('E1000 Driver', 'EEPROM Exists: YES.') else console.outputln('E1000 Driver', 'EEPROM Exists: NO.');
if not readMACAddress() then begin
console.outputln('E1000 Driver', 'MAC Read Failed.');
load:= false;
exit;
end;
console.output('E1000 Driver', 'MAC Address: ');
writeMACAddress();
startLink();
load:= true;
console.outputln('E1000 Driver', 'Load Finish.');
end;
function loadE1000(ptr : void) : boolean;
begin
loadE1000:= false;
if not Loaded then begin
card_type:= ctE1000;
loadE1000:= load(ptr);
end;
end;
function load82577LM(ptr : void) : boolean;
begin
load82577LM:= false;
if not Loaded then begin
card_type:= ct82577LM;
load82577LM:= load(ptr);
end;
end;
function loadI217(ptr : void) : boolean;
begin
loadI217:= false;
if not Loaded then begin
card_type:= ctI217;
loadI217:= load(ptr);
end;
end; end;
procedure init(); procedure init();
@ -195,6 +420,7 @@ var
dev : TDeviceIdentifier; dev : TDeviceIdentifier;
begin begin
card_type:= ctUnknown;
dev.Bus:= biPCI; dev.Bus:= biPCI;
dev.id0:= INTEL_VEND; dev.id0:= INTEL_VEND;
dev.id1:= idANY; dev.id1:= idANY;
@ -202,11 +428,11 @@ begin
dev.id3:= idANY; dev.id3:= idANY;
dev.id4:= E1000_DEV; dev.id4:= E1000_DEV;
dev.ex:= nil; dev.ex:= nil;
drivermanagement.register_driver('E1000 Ethernet Driver', @dev, @load); drivermanagement.register_driver('E1000 Ethernet Driver', @dev, @loadE1000);
dev.id4:= I217_DEV; dev.id4:= I217_DEV;
drivermanagement.register_driver('I217 Ethernet Driver', @dev, @load); drivermanagement.register_driver('I217 Ethernet Driver', @dev, @loadI217);
dev.id4:= LM82577_DEV; dev.id4:= LM82577_DEV;
drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load); drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load82577LM);
end; end;
procedure fire(); procedure fire();
@ -214,9 +440,9 @@ begin
end; end;
function getMACAddress : uint8; function getMACAddress : puint8;
begin begin
getMACAddress:= puint8(@mac[0]);
end; end;
function sendPacket(p_data : void; p_len : uint16) : sint32; function sendPacket(p_data : void; p_len : uint16) : sint32;

View File

@ -11,7 +11,7 @@ implementation
function load(ptr : void) : boolean; function load(ptr : void) : boolean;
begin begin
console.writestringln('DUMMY DRIVER LOADED.') console.outputln('DUMMY DRIVER', 'LOADED.')
end; end;
procedure init; procedure init;

View File

@ -307,7 +307,12 @@ begin
end; end;
RegList^.Next:= NewReg; RegList^.Next:= NewReg;
end; end;
console.output('Driver Management', 'New Driver Registered: ');
console.writestringln(NewReg^.Driver_Name);
if force_load then begin if force_load then begin
console.output('Driver Management', 'Driver (');
console.writestring(NewReg^.Driver_Name);
console.writestringln(') forced to load.');
NewReg^.Loaded:= True; NewReg^.Loaded:= True;
NewReg^.Driver_Load(nil); NewReg^.Driver_Load(nil);
end; end;
@ -336,9 +341,18 @@ begin
end; end;
dev_list^.Next:= new_dev; dev_list^.Next:= new_dev;
end; end;
console.output('Driver Management', 'New Device Registered: ');
console.writestringln(new_dev^.Device_Name);
while drv <> nil do begin while drv <> nil do begin
if identifiers_match(drv^.Identifier, DeviceID) then begin if identifiers_match(drv^.Identifier, DeviceID) then begin
console.output('Driver Management', 'Device/Driver Match: ');
console.writestring(new_dev^.Device_Name);
console.writestring('->');
console.writestringln(drv^.Driver_Name);
if drv^.Driver_Load(ptr) then begin if drv^.Driver_Load(ptr) then begin
console.output('Driver Management', 'Driver (');
console.writestring(drv^.Driver_Name);
console.writestringln(') successfully loaded.');
drv^.Loaded:= true; drv^.Loaded:= true;
new_dev^.Driver_Loaded:= true; new_dev^.Driver_Loaded:= true;
new_dev^.Driver:= drv; new_dev^.Driver:= drv;

View File

@ -58,7 +58,7 @@ end;
procedure flush; procedure flush;
begin begin
console.writestringln('GDT: FLUSH.'); console.outputln('GDT','FLUSH.');
flush_gdt(uint32(@gdt_pointer)); flush_gdt(uint32(@gdt_pointer));
end; end;
@ -70,7 +70,7 @@ end;
procedure reload; procedure reload;
begin begin
console.writestringln('GDT: RELOAD.'); console.outputln('GDT','RELOAD.');
reload_gdt(uint32(@gdt_pointer)); reload_gdt(uint32(@gdt_pointer));
end; end;
@ -90,14 +90,14 @@ begin
gdt_entries[Gate_Number].limit_low := (Limit AND $FFFF); gdt_entries[Gate_Number].limit_low := (Limit AND $FFFF);
gdt_entries[Gate_Number].granularity := ((Limit SHR 16) AND $0F) OR (Granularity AND $F0); gdt_entries[Gate_Number].granularity := ((Limit SHR 16) AND $0F) OR (Granularity AND $F0);
gdt_entries[Gate_Number].access := Access; gdt_entries[Gate_Number].access := Access;
console.writestring('GDT: GATE '); console.output('GDT','GATE ');
console.writeint(Gate_Number); console.writeint(Gate_Number);
console.writestringln(' SET.'); console.writestringln(' SET.');
end; end;
procedure init(); procedure init();
begin begin
console.writestringln('GDT: INIT START.'); console.outputln('GDT','INIT START.');
gdt_pointer.limit:= 0; gdt_pointer.limit:= 0;
gdt_pointer.base := uint32(@gdt_entries); gdt_pointer.base := uint32(@gdt_entries);
set_gate($00, $00, $00, $00, $00); //OFFSET: 0 set_gate($00, $00, $00, $00, $00); //OFFSET: 0
@ -106,7 +106,7 @@ begin
set_gate($03, $00, $FFFFFFFF, $FA, $CF); //OFFSET: 24 set_gate($03, $00, $FFFFFFFF, $FA, $CF); //OFFSET: 24
set_gate($04, $00, $FFFFFFFF, $F2, $CF); //OFFSET: 32 set_gate($04, $00, $FFFFFFFF, $F2, $CF); //OFFSET: 32
flush; flush;
console.writestringln('GDT: INIT END.'); console.outputln('GDT','INIT END.');
end; end;
end. end.

View File

@ -52,7 +52,7 @@ begin
IDT_Entries[Number].selector:= Selector; IDT_Entries[Number].selector:= Selector;
IDT_Entries[Number].flags:= Flags; IDT_Entries[Number].flags:= Flags;
IDT_Entries[Number].always_0:= $00; IDT_Entries[Number].always_0:= $00;
console.writestring('IDT: GATE '); console.output('IDT','GATE ');
console.writeint(Number); console.writeint(Number);
console.writestringln(' SET.'); console.writestringln(' SET.');
end; end;
@ -65,14 +65,14 @@ end;
procedure init(); procedure init();
begin begin
console.writestringln('IDT: INIT START.'); console.outputln('IDT','INIT START.');
IDT_Pointer.limit:= (sizeof(TIDT_Entry) * 256) - 1; IDT_Pointer.limit:= (sizeof(TIDT_Entry) * 256) - 1;
IDT_Pointer.base:= uint32(@IDT_Entries); IDT_Pointer.base:= uint32(@IDT_Entries);
console.writestringln('IDT: CLEAR.'); console.outputln('IDT','CLEAR.');
util.memset(uint32(@IDT_Entries[0]), 0, sizeof(TIDT_Entry) * 256); util.memset(uint32(@IDT_Entries[0]), 0, sizeof(TIDT_Entry) * 256);
console.writestringln('IDT: LOAD.'); console.outputln('IDT','LOAD.');
load(uint32(@IDT_Pointer)); load(uint32(@IDT_Pointer));
console.writestringln('IDT: INIT END.'); console.outputln('IDT','INIT END.');
end; end;
end. end.

View File

@ -19,7 +19,7 @@ implementation
procedure init(); procedure init();
begin begin
console.writestringln('IRQ: INIT START.'); console.outputln('IRQ','INIT START.');
outb($20, $11); outb($20, $11);
outb($A0, $11); outb($A0, $11);
outb($21, $20); outb($21, $20);
@ -30,7 +30,7 @@ begin
outb($A1, $01); outb($A1, $01);
outb($21, $00); outb($21, $00);
outb($A1, $00); outb($A1, $00);
console.writestringln('IRQ: INIT END.'); console.outputln('IRQ','INIT END.');
end; end;
end. end.

View File

@ -24,7 +24,7 @@ implementation
procedure init(); procedure init();
begin begin
console.writestringln('ISR: INIT START.'); console.outputln('ISR','INIT START.');
ISR0.register(); // Divide-By-Zero ISR0.register(); // Divide-By-Zero
ISR1.register(); // Debug ISR1.register(); // Debug
ISR2.register(); // Non-Maskable Inturrupt ISR2.register(); // Non-Maskable Inturrupt
@ -49,7 +49,7 @@ begin
ISR33.register(); // Keyboard ISR33.register(); // Keyboard
ISR40.register(); // 1024/s Timer ISR40.register(); // 1024/s Timer
ISR44.register(); // Mouse ISR44.register(); // Mouse
console.writestringln('ISR: INIT END.'); console.outputln('ISR','INIT END.');
end; end;
end. end.

View File

@ -89,8 +89,8 @@ begin
if (multibootmagic <> 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.outputln('KERNEL', 'Multiboot Compliant Boot-Loader Needed!');
console.writestringln('HALTING'); console.outputln('KERNEL', 'HALTING.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
@ -99,9 +99,10 @@ begin
MOV dds, CS MOV dds, CS
end; end;
if dds = $08 then begin if dds = $08 then begin
console.writestringlnex('GDT: LOAD SUCCESS.', console.combinecolors(Green, Black)); console.outputln('KERNEL', 'GDT: LOAD SUCCESS.');
end else begin end else begin
console.writestringlnex('GDT: LOAD FAIL.', console.combinecolors(Red, Black)); console.outputln('KERNEL', 'GDT: LOAD FAIL.');
console.outputln('KERNEL', 'HALTING.');
halt_and_catch_fire; halt_and_catch_fire;
end; end;
@ -121,7 +122,7 @@ begin
isr32.hook(uint32(@bios_data_area.tick_update)); isr32.hook(uint32(@bios_data_area.tick_update));
//drivers //drivers
console.writestringln('DRIVERS: INIT BEGIN.'); console.outputln('KERNEL', 'DRIVERS: INIT BEGIN.');
keyboard.init(keyboard_layout); keyboard.init(keyboard_layout);
mouse.init(); mouse.init();
testdriver.init(); testdriver.init();
@ -130,7 +131,7 @@ begin
//Nothing beyond here //Nothing beyond here
USB.init(); USB.init();
pci.init(); pci.init();
console.writestringln('DRIVERS: INIT END.'); console.outputln('KERNEL', 'DRIVERS: INIT END.');
console.writestringln(''); console.writestringln('');
console.setdefaultattribute(console.combinecolors(Green, Black)); console.setdefaultattribute(console.combinecolors(Green, Black));

View File

@ -86,7 +86,7 @@ var
i : uint32; i : uint32;
begin begin
console.writestringln('LMM: INIT BEGIN.'); console.outputln('LMM','INIT BEGIN.');
Root_Page:= PHeapPage(new_lmm_page); Root_Page:= PHeapPage(new_lmm_page);
Search_Page:= Root_Page; Search_Page:= Root_Page;
Root_Page^.Next_Page:= 0; Root_Page^.Next_Page:= 0;
@ -96,7 +96,7 @@ begin
Root_Page^.Entries[i].Root:= False; Root_Page^.Entries[i].Root:= False;
Root_Page^.Entries[i].Last:= False; Root_Page^.Entries[i].Last:= False;
end; end;
console.writestringln('LMM: INIT END.'); console.outputln('LMM','INIT END.');
end; end;
function kpalloc(address : uint32) : void; function kpalloc(address : uint32) : void;

View File

@ -109,15 +109,15 @@ end;
procedure init; procedure init;
begin begin
console.writestringln('PMM: INIT BEGIN.'); console.outputln('PMM','INIT BEGIN.');
walk_memory_map; walk_memory_map;
force_alloc_block(0, 0); force_alloc_block(0, 0);
force_alloc_block(1, 0); force_alloc_block(1, 0);
force_alloc_block(2, 0); //First 12MiB reserved for Kernel/BIOS. force_alloc_block(2, 0); //First 12MiB reserved for Kernel/BIOS.
console.writestring('PMM: '); console.output('PMM',' ');
console.writeword(nPresent); console.writeword(nPresent);
console.writestringln('/1024 Block Available for Allocation.'); console.writestringln('/1024 Block Available for Allocation.');
console.writestringln('PMM: INIT END.'); console.outputln('PMM','INIT END.');
end; end;
function alloc_block(block : uint16; caller : uint32) : boolean; function alloc_block(block : uint16; caller : uint32) : boolean;

View File

@ -105,7 +105,7 @@ end;
procedure init; procedure init;
begin begin
console.writestringln('SCHEDULER: INIT BEGIN.'); console.outputln('SCHEDULER','INIT BEGIN.');
Root_Task:= PScheduler_Entry(kalloc(sizeof(TScheduler_Entry))); Root_Task:= PScheduler_Entry(kalloc(sizeof(TScheduler_Entry)));
Root_Task^.ThreadID:= 0; Root_Task^.ThreadID:= 0;
Root_Task^.Priority:= 1; Root_Task^.Priority:= 1;
@ -116,7 +116,7 @@ begin
Active:= False; Active:= False;
isr32.hook(uint32(@delta)); isr32.hook(uint32(@delta));
terminal.registerCommand('TASKS', @terminal_command_tasks, 'List Active Processes.'); terminal.registerCommand('TASKS', @terminal_command_tasks, 'List Active Processes.');
console.writestringln('SCHEDULER: INIT END.'); console.outputln('SCHEDULER','INIT END.');
end; end;
end. end.

View File

@ -79,7 +79,7 @@ var
cCR3 : uint32; cCR3 : uint32;
begin begin
console.writestringln('TSS: INIT BEGIN.'); console.outputln('TSS','INIT BEGIN.');
ptrTaskStateSegment^.ss0:= $08; ptrTaskStateSegment^.ss0:= $08;
ptrTaskStateSegment^.iomap:= sizeof(TTaskStateSegment)-1; ptrTaskStateSegment^.iomap:= sizeof(TTaskStateSegment)-1;
asm asm
@ -95,7 +95,7 @@ begin
mov AX, 40 mov AX, 40
ltr AX ltr AX
end; end;
console.writestringln('TSS: INIT END.'); console.outputln('TSS','INIT END.');
end; end;
end. end.

View File

@ -90,13 +90,13 @@ var
i : uint32; i : uint32;
begin begin
console.writestringln('VMM: INIT BEGIN.'); console.outputln('VMM','INIT BEGIN.');
PageDirectory:= load_current_page_directory; PageDirectory:= load_current_page_directory;
KERNEL_PAGE_DIRECTORY:= PageDirectory; KERNEL_PAGE_DIRECTORY:= PageDirectory;
map_page(KERNEL_PAGE_NUMBER + 1, 1); map_page(KERNEL_PAGE_NUMBER + 1, 1);
map_page(KERNEL_PAGE_NUMBER + 2, 2); map_page(KERNEL_PAGE_NUMBER + 2, 2);
map_page(KERNEL_PAGE_NUMBER + 3, 3); map_page(KERNEL_PAGE_NUMBER + 3, 3);
console.writestringln('VMM: INIT END.'); console.outputln('VMM','INIT END.');
end; end;
function map_page_ex(page_number : uint16; block : uint16; PD : PPageDirectory) : boolean; function map_page_ex(page_number : uint16; block : uint16; PD : PPageDirectory) : boolean;
@ -139,7 +139,7 @@ var
rldpd : uint32; rldpd : uint32;
begin begin
map_page:= false; map_page:= false;
PageDirectory^[page_number].Present:= true; PageDirectory^[page_number].Present:= true;
addr:= block; addr:= block;
PageDirectory^[page_number].Address:= addr SHL 10; PageDirectory^[page_number].Address:= addr SHL 10;