Drivers now using DriverManagement.
git-svn-id: https://spexeah.com:8443/svn/Asuro@302 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
6b3c4fb634
commit
e3c96aa9f8
@ -75,14 +75,13 @@ function getDeviceInfo(class_code : uint8; subclass_code : uint8; prog_if : uint
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure init();
|
function load(ptr : void) : boolean;
|
||||||
var
|
var
|
||||||
current_bus : uint8;
|
current_bus : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
console.writestringln('PCI: INIT BEGIN.');
|
|
||||||
console.writestringln('PCI: Scanning Bus: 0');
|
console.writestringln('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
|
||||||
@ -93,7 +92,22 @@ begin
|
|||||||
current_bus := current_bus + 1;
|
current_bus := current_bus + 1;
|
||||||
end else break;
|
end else break;
|
||||||
end;
|
end;
|
||||||
|
load:= true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure init();
|
||||||
|
var
|
||||||
|
DevID : TDeviceIdentifier;
|
||||||
|
|
||||||
|
begin
|
||||||
|
console.writestringln('PCI: INIT BEGIN.');
|
||||||
|
DevID.Bus:= biUnknown;
|
||||||
|
DevID.id0:= 0;
|
||||||
|
DevID.id1:= 0;
|
||||||
|
DevID.id2:= 0;
|
||||||
|
DevID.id3:= 0;
|
||||||
|
DevID.ex:= nil;
|
||||||
|
drivermanagement.register_driver_ex('PCI Driver', @DevID, @load, true);
|
||||||
console.writestringln('PCI: INIT END.');
|
console.writestringln('PCI: INIT END.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ uses
|
|||||||
drivertypes,
|
drivertypes,
|
||||||
pmemorymanager,
|
pmemorymanager,
|
||||||
vmemorymanager,
|
vmemorymanager,
|
||||||
util;
|
util,
|
||||||
|
drivermanagement;
|
||||||
|
|
||||||
type
|
type
|
||||||
POHCI_MMR = ^TOHCI_MMR;
|
POHCI_MMR = ^TOHCI_MMR;
|
||||||
@ -39,7 +40,7 @@ procedure init;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure init;
|
function loadOHCI(ptr : void) : boolean;
|
||||||
var
|
var
|
||||||
devices : TDeviceArray;
|
devices : TDeviceArray;
|
||||||
count : uint32;
|
count : uint32;
|
||||||
@ -48,25 +49,6 @@ var
|
|||||||
MMR : POHCI_MMR;
|
MMR : POHCI_MMR;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
console.writestringln('USB: INIT BEGIN.');
|
|
||||||
|
|
||||||
devices:= PCI.getDeviceInfo($0C, $03, $00, count);
|
|
||||||
console.writestring('USB-UHCI: Found ');
|
|
||||||
console.writeint(count);
|
|
||||||
console.writestringln(' USB Controller(s).');
|
|
||||||
if count > 0 then begin
|
|
||||||
for i:=0 to count-1 do begin
|
|
||||||
console.writestring('USB: Controller[');
|
|
||||||
console.writeint(i);
|
|
||||||
console.writestring(']: ');
|
|
||||||
console.writehex(devices[i].device_id);
|
|
||||||
console.writestring(' ');
|
|
||||||
console.writehex(devices[i].vendor_id);
|
|
||||||
console.writestring(' ');
|
|
||||||
console.writehexln(devices[i].prog_if);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
devices:= PCI.getDeviceInfo($0C, $03, $10, count);
|
devices:= PCI.getDeviceInfo($0C, $03, $10, count);
|
||||||
console.writestring('USB-OHCI: Found ');
|
console.writestring('USB-OHCI: Found ');
|
||||||
console.writeint(count);
|
console.writeint(count);
|
||||||
@ -87,7 +69,57 @@ begin
|
|||||||
MMR:= POHCI_MMR(devices[i].address0);
|
MMR:= POHCI_MMR(devices[i].address0);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function loadUHCI(ptr : void) : boolean;
|
||||||
|
var
|
||||||
|
devices : TDeviceArray;
|
||||||
|
count : uint32;
|
||||||
|
i : uint32;
|
||||||
|
|
||||||
|
begin
|
||||||
|
devices:= PCI.getDeviceInfo($0C, $03, $00, count);
|
||||||
|
console.writestring('USB-UHCI: Found ');
|
||||||
|
console.writeint(count);
|
||||||
|
console.writestringln(' USB Controller(s).');
|
||||||
|
if count > 0 then begin
|
||||||
|
for i:=0 to count-1 do begin
|
||||||
|
console.writestring('USB: Controller[');
|
||||||
|
console.writeint(i);
|
||||||
|
console.writestring(']: ');
|
||||||
|
console.writehex(devices[i].device_id);
|
||||||
|
console.writestring(' ');
|
||||||
|
console.writehex(devices[i].vendor_id);
|
||||||
|
console.writestring(' ');
|
||||||
|
console.writehexln(devices[i].prog_if);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure init;
|
||||||
|
var
|
||||||
|
UHCI_ID, OHCI_ID : TDeviceIdentifier;
|
||||||
|
|
||||||
|
begin
|
||||||
|
console.writestringln('USB: INIT BEGIN.');
|
||||||
|
|
||||||
|
UHCI_ID.Bus:= biPCI;
|
||||||
|
UHCI_ID.id0:= idANY;
|
||||||
|
UHCI_ID.id1:= $0000000C;
|
||||||
|
UHCI_ID.id2:= $00000003;
|
||||||
|
UHCI_ID.id3:= $00000000;
|
||||||
|
UHCI_ID.ex:= nil;
|
||||||
|
|
||||||
|
OHCI_ID.Bus:= biPCI;
|
||||||
|
OHCI_ID.id0:= idANY;
|
||||||
|
OHCI_ID.id1:= $0000000C;
|
||||||
|
OHCI_ID.id2:= $00000003;
|
||||||
|
OHCI_ID.id3:= $00000010;
|
||||||
|
OHCI_ID.ex:= nil;
|
||||||
|
|
||||||
|
drivermanagement.register_driver('USB-UHCI Driver', @UHCI_ID, @loadUHCI);
|
||||||
|
drivermanagement.register_driver('USB-OHCI Driver', @OHCI_ID, @loadOHCI);
|
||||||
|
|
||||||
console.writestringln('USB: INIT END.');
|
console.writestringln('USB: INIT END.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ var
|
|||||||
key_matrix_shift : array [1..256] of TKeyInfo;
|
key_matrix_shift : array [1..256] of TKeyInfo;
|
||||||
captin_hook : pp_hook_method = nil;
|
captin_hook : pp_hook_method = nil;
|
||||||
is_shift : boolean = false;
|
is_shift : boolean = false;
|
||||||
|
|
||||||
|
|
||||||
procedure init(keyboard_layout : array of TKeyInfo);
|
procedure init(keyboard_layout : array of TKeyInfo);
|
||||||
procedure hook(proc : pp_hook_method);
|
procedure hook(proc : pp_hook_method);
|
||||||
@ -40,6 +39,8 @@ procedure lang_USA();
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
drivermanagement;
|
||||||
|
|
||||||
procedure callback(scan_code : void);
|
procedure callback(scan_code : void);
|
||||||
begin
|
begin
|
||||||
@ -58,11 +59,27 @@ begin
|
|||||||
if uint8(scan_code) = 170 then is_shift := false;
|
if uint8(scan_code) = 170 then is_shift := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function load(ptr : void) : boolean;
|
||||||
|
begin
|
||||||
|
isr33.hook(uint32(@callback));
|
||||||
|
console.writestringln('PS/2 KEYBOARD: LOADED.');
|
||||||
|
load:= true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure init(keyboard_layout : array of TKeyInfo);
|
procedure init(keyboard_layout : array of TKeyInfo);
|
||||||
|
var
|
||||||
|
devid : TDeviceIdentifier;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
console.writestringln('PS/2 KEYBOARD: INIT BEGIN.');
|
console.writestringln('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();
|
||||||
isr33.hook(uint32(@callback));
|
devid.bus:= biUnknown;
|
||||||
|
devid.id0:= 0;
|
||||||
|
devid.id1:= 0;
|
||||||
|
devid.id2:= 0;
|
||||||
|
devid.id3:= 0;
|
||||||
|
devid.ex:= nil;
|
||||||
|
drivermanagement.register_driver_ex('PS/2 Keyboard', @devid, @load, true);
|
||||||
console.writestringln('PS/2 KEYBOARD: INIT END.');
|
console.writestringln('PS/2 KEYBOARD: INIT END.');
|
||||||
end;
|
end;
|
||||||
//2A AA
|
//2A AA
|
||||||
|
@ -16,7 +16,8 @@ uses
|
|||||||
util,
|
util,
|
||||||
isr44,
|
isr44,
|
||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
strings;
|
strings,
|
||||||
|
drivermanagement;
|
||||||
|
|
||||||
type
|
type
|
||||||
PMousePacket = ^TMousePacket;
|
PMousePacket = ^TMousePacket;
|
||||||
@ -103,10 +104,26 @@ begin
|
|||||||
//console.writehexln(DWORD(raw));
|
//console.writehexln(DWORD(raw));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function load(ptr : void) : boolean;
|
||||||
|
begin
|
||||||
|
isr44.hook(uint32(@callback));
|
||||||
|
console.writestringln('PS/2 MOUSE: LOADED.');
|
||||||
|
load:= true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
|
var
|
||||||
|
devid : TDeviceIdentifier;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
console.writestringln('PS/2 MOUSE: INIT BEGIN.');
|
console.writestringln('PS/2 MOUSE: INIT BEGIN.');
|
||||||
isr44.hook(uint32(@callback));
|
devid.bus:= biUnknown;
|
||||||
|
devid.id0:= 0;
|
||||||
|
devid.id1:= 0;
|
||||||
|
devid.id2:= 0;
|
||||||
|
devid.id3:= 0;
|
||||||
|
devid.ex:= nil;
|
||||||
|
drivermanagement.register_driver_ex('PS/2 Mouse', @devid, @load, true);
|
||||||
console.writestringln('PS/2 MOUSE: INIT END.');
|
console.writestringln('PS/2 MOUSE: INIT END.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ unit drivermanagement;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
console, util, strings, lmemorymanager;
|
console, util, strings, lmemorymanager, terminal;
|
||||||
|
|
||||||
const
|
const
|
||||||
idANY = $FFFFFFFF;
|
idANY = $FFFFFFFF;
|
||||||
@ -55,7 +55,9 @@ type
|
|||||||
Next : PDeviceRegistration;
|
Next : PDeviceRegistration;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure init;
|
||||||
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
||||||
|
procedure register_driver_ex(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback; force_load : boolean);
|
||||||
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -64,6 +66,138 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
procedure writeBusType(Bus : TBusIdentifier);
|
||||||
|
begin
|
||||||
|
case Bus of
|
||||||
|
biUnknown : console.writestring('Unknown');
|
||||||
|
biANY : console.writestring('ANY');
|
||||||
|
bii2c : console.writestring('i2c');
|
||||||
|
biPCI : console.writestring('PCI');
|
||||||
|
biPCIe : console.writestring('PCIe');
|
||||||
|
biUSB : console.writestring('USB');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Terminal Commands }
|
||||||
|
|
||||||
|
procedure terminal_command_drivers(Params : PParamList);
|
||||||
|
var
|
||||||
|
Drv : PDriverRegistration;
|
||||||
|
ex : PDevEx;
|
||||||
|
i : uint32;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Drv:= Root;
|
||||||
|
i:= 1;
|
||||||
|
while Drv <> nil do begin
|
||||||
|
if Drv^.Loaded then begin
|
||||||
|
console.writeint(i);
|
||||||
|
console.writestring(') ');
|
||||||
|
console.writestring(Drv^.Driver_Name);
|
||||||
|
console.writestring(' [');
|
||||||
|
writeBusType(Drv^.Identifier^.Bus);
|
||||||
|
console.writestring(' - ID:');
|
||||||
|
console.writeHex(Drv^.Identifier^.id0);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Drv^.Identifier^.id1);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Drv^.Identifier^.id2);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Drv^.Identifier^.id3);
|
||||||
|
ex:= Drv^.Identifier^.ex;
|
||||||
|
while ex <> nil do begin
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(ex^.idN);
|
||||||
|
ex:= ex^.ex;
|
||||||
|
end;
|
||||||
|
console.writestringln(']');
|
||||||
|
i:= i + 1;
|
||||||
|
end;
|
||||||
|
Drv:= Drv^.Next;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure terminal_command_driversex(Params : PParamList);
|
||||||
|
var
|
||||||
|
Drv : PDriverRegistration;
|
||||||
|
ex : PDevEx;
|
||||||
|
i : uint32;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Drv:= Root;
|
||||||
|
i:= 1;
|
||||||
|
while Drv <> nil do begin
|
||||||
|
console.writeint(i);
|
||||||
|
if Drv^.Loaded then console.writestring('L');
|
||||||
|
console.writestring(') ');
|
||||||
|
console.writestring(Drv^.Driver_Name);
|
||||||
|
console.writestring(' [');
|
||||||
|
writeBusType(Drv^.Identifier^.Bus);
|
||||||
|
console.writestring(' - ID:');
|
||||||
|
console.writeHex(Drv^.Identifier^.id0);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Drv^.Identifier^.id1);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Drv^.Identifier^.id2);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Drv^.Identifier^.id3);
|
||||||
|
ex:= Drv^.Identifier^.ex;
|
||||||
|
while ex <> nil do begin
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(ex^.idN);
|
||||||
|
ex:= ex^.ex;
|
||||||
|
end;
|
||||||
|
console.writestringln(']');
|
||||||
|
i:= i + 1;
|
||||||
|
Drv:= Drv^.Next;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure terminal_command_devices(Params : PParamList);
|
||||||
|
var
|
||||||
|
Dv : PDeviceRegistration;
|
||||||
|
ex : PDevEx;
|
||||||
|
i : uint32;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Dv:= Dev;
|
||||||
|
i:= 1;
|
||||||
|
while Dv <> nil do begin
|
||||||
|
console.writeint(i);
|
||||||
|
console.writestring(') ');
|
||||||
|
console.writestring(Dv^.Device_Name);
|
||||||
|
console.writestring(' [');
|
||||||
|
writeBusType(Dv^.Identifier^.Bus);
|
||||||
|
console.writestring(' - ID:');
|
||||||
|
console.writeHex(Dv^.Identifier^.id0);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Dv^.Identifier^.id1);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Dv^.Identifier^.id2);
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(Dv^.Identifier^.id3);
|
||||||
|
ex:= Dv^.Identifier^.ex;
|
||||||
|
while ex <> nil do begin
|
||||||
|
console.writestring('-');
|
||||||
|
console.writeHex(ex^.idN);
|
||||||
|
ex:= ex^.ex;
|
||||||
|
end;
|
||||||
|
console.writestringln(']');
|
||||||
|
if Dv^.Driver_Loaded then begin
|
||||||
|
console.writestring(' -- Driver Loaded: ');
|
||||||
|
if Dv^.Driver <> nil then begin
|
||||||
|
console.writestringln(Dv^.Driver^.Driver_Name);
|
||||||
|
end else begin
|
||||||
|
console.writestringln('Unknown')
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
i:= i + 1;
|
||||||
|
Dv:= Dv^.Next;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Main Functions }
|
||||||
|
|
||||||
function copy_identifier(DeviceID : PDeviceIdentifier) : PDeviceIdentifier;
|
function copy_identifier(DeviceID : PDeviceIdentifier) : PDeviceIdentifier;
|
||||||
var
|
var
|
||||||
New_DevID : PDeviceIdentifier;
|
New_DevID : PDeviceIdentifier;
|
||||||
@ -127,7 +261,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure init;
|
||||||
|
begin
|
||||||
|
terminal.registerCommand('DRIVERSEX', @terminal_command_driversex, 'List all available drivers.');
|
||||||
|
terminal.registerCommand('DRIVERS', @terminal_command_drivers, 'List loaded drivers.');
|
||||||
|
terminal.registerCommand('DEVICES', @terminal_command_devices, 'List devices.');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
||||||
|
begin
|
||||||
|
register_driver_ex(Driver_Name, DeviceID, Load_Callback, false);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure register_driver_ex(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback; force_load : boolean);
|
||||||
var
|
var
|
||||||
NewReg : PDriverRegistration;
|
NewReg : PDriverRegistration;
|
||||||
RegList : PDriverRegistration;
|
RegList : PDriverRegistration;
|
||||||
@ -149,6 +295,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
RegList^.Next:= NewReg;
|
RegList^.Next:= NewReg;
|
||||||
end;
|
end;
|
||||||
|
if force_load then begin
|
||||||
|
NewReg^.Loaded:= True;
|
||||||
|
NewReg^.Driver_Load(nil);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
||||||
@ -165,6 +315,15 @@ begin
|
|||||||
new_dev^.Driver_Loaded:= false;
|
new_dev^.Driver_Loaded:= false;
|
||||||
new_dev^.Driver:= nil;
|
new_dev^.Driver:= nil;
|
||||||
new_dev^.next:= nil;
|
new_dev^.next:= nil;
|
||||||
|
if Dev = nil then begin
|
||||||
|
Dev:= new_dev;
|
||||||
|
end else begin
|
||||||
|
dev_list:= Dev;
|
||||||
|
While dev_list^.Next <> nil do begin
|
||||||
|
dev_list:= dev_list^.Next;
|
||||||
|
end;
|
||||||
|
dev_list^.Next:= new_dev;
|
||||||
|
end;
|
||||||
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
|
||||||
if drv^.Driver_Load(ptr) then begin
|
if drv^.Driver_Load(ptr) then begin
|
||||||
@ -176,15 +335,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
drv:= drv^.Next;
|
drv:= drv^.Next;
|
||||||
end;
|
end;
|
||||||
if Dev = nil then begin
|
|
||||||
Dev:= new_dev;
|
|
||||||
end else begin
|
|
||||||
dev_list:= Dev;
|
|
||||||
While dev_list^.Next <> nil do begin
|
|
||||||
dev_list:= dev_list^.Next;
|
|
||||||
end;
|
|
||||||
dev_list^.Next:= new_dev;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -78,6 +78,8 @@ begin
|
|||||||
terminal.init();
|
terminal.init();
|
||||||
terminal.registerCommand('MEMINFO', @terminal_command_meminfo, 'Print Simple Memory Information.');
|
terminal.registerCommand('MEMINFO', @terminal_command_meminfo, 'Print Simple Memory Information.');
|
||||||
|
|
||||||
|
drivermanagement.init();
|
||||||
|
|
||||||
console.init();
|
console.init();
|
||||||
|
|
||||||
console.writestringln('Booting Asuro...');
|
console.writestringln('Booting Asuro...');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user