Driver Management changes.
git-svn-id: https://spexeah.com:8443/svn/Asuro@300 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
c324afcb30
commit
fc3f2f1998
@ -312,7 +312,8 @@ begin
|
|||||||
console.writestring(' ');
|
console.writestring(' ');
|
||||||
console.writehexln(device.prog_if);
|
console.writehexln(device.prog_if);
|
||||||
|
|
||||||
drivermanagement.register_device(DevID, @device);
|
drivermanagement.register_device('PCI Device', DevID, @device);
|
||||||
|
|
||||||
kfree(void(DevID));
|
kfree(void(DevID));
|
||||||
|
|
||||||
devices[device_count] := device;
|
devices[device_count] := device;
|
||||||
|
@ -25,7 +25,7 @@ begin
|
|||||||
devID.id2:= $00000000; { SUBCLASS }
|
devID.id2:= $00000000; { SUBCLASS }
|
||||||
devID.id3:= $00000000; { PROGIF }
|
devID.id3:= $00000000; { PROGIF }
|
||||||
devID.ex:= nil; { NO EXTENDED INFO }
|
devID.ex:= nil; { NO EXTENDED INFO }
|
||||||
drivermanagement.register_driver(@devID, @load);
|
drivermanagement.register_driver('DUMMY DRIVER', @devID, @load);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -39,20 +39,64 @@ type
|
|||||||
|
|
||||||
PDriverRegistration = ^TDriverRegistration;
|
PDriverRegistration = ^TDriverRegistration;
|
||||||
TDriverRegistration = record
|
TDriverRegistration = record
|
||||||
Identifier : TDeviceIdentifier;
|
Driver_Name : PChar;
|
||||||
|
Identifier : PDeviceIdentifier;
|
||||||
Driver_Load : TDriverLoadCallback;
|
Driver_Load : TDriverLoadCallback;
|
||||||
Loaded : Boolean;
|
Loaded : Boolean;
|
||||||
Next : PDriverRegistration;
|
Next : PDriverRegistration;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_driver(DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
PDeviceRegistration = ^TDeviceRegistration;
|
||||||
procedure register_device(DeviceID : PDeviceIdentifier; ptr : void);
|
TDeviceRegistration = record
|
||||||
|
Device_Name : PChar;
|
||||||
|
Identifier : PDeviceIdentifier;
|
||||||
|
Driver_Loaded : Boolean;
|
||||||
|
Driver : PDriverRegistration;
|
||||||
|
Next : PDeviceRegistration;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
||||||
|
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
||||||
|
|
||||||
var
|
var
|
||||||
Root : PDriverRegistration = nil;
|
Root : PDriverRegistration = nil;
|
||||||
|
Dev : PDeviceRegistration = nil;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
function copy_identifier(DeviceID : PDeviceIdentifier) : PDeviceIdentifier;
|
||||||
|
var
|
||||||
|
New_DevID : PDeviceIdentifier;
|
||||||
|
root_ex,
|
||||||
|
param_ex,
|
||||||
|
new_ex: PDevEx;
|
||||||
|
|
||||||
|
begin
|
||||||
|
New_DevID:= PDeviceIdentifier(kalloc(sizeof(TDeviceIdentifier)));
|
||||||
|
New_DevID^.Bus:= DeviceID^.Bus;
|
||||||
|
New_DevID^.id0:= DeviceID^.id0;
|
||||||
|
New_DevID^.id1:= DeviceID^.id1;
|
||||||
|
New_DevID^.id2:= DeviceID^.id2;
|
||||||
|
New_DevID^.id3:= DeviceID^.id3;
|
||||||
|
root_ex:= nil;
|
||||||
|
if DeviceID^.ex <> nil then begin
|
||||||
|
root_ex:= PDevEx(kalloc(sizeof(TDevEx)));
|
||||||
|
param_ex:= DeviceID^.ex;
|
||||||
|
new_ex:= root_ex;
|
||||||
|
new_ex^.idN:= param_ex^.idN;
|
||||||
|
new_ex^.ex:= nil;
|
||||||
|
param_ex:= param_ex^.ex;
|
||||||
|
while param_ex <> nil do begin
|
||||||
|
new_ex^.ex:= PDevEx(kalloc(sizeof(TDevEx)));
|
||||||
|
new_ex:= new_ex^.ex;
|
||||||
|
new_ex^.idN:= param_ex^.idN;
|
||||||
|
param_ex:= param_ex^.ex;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
New_DevID^.ex:= root_ex;
|
||||||
|
copy_identifier:= New_DevID;
|
||||||
|
end;
|
||||||
|
|
||||||
function identifiers_match(i1, i2 : PDeviceIdentifier) : boolean;
|
function identifiers_match(i1, i2 : PDeviceIdentifier) : boolean;
|
||||||
var
|
var
|
||||||
ll1, ll2 : PDevEx;
|
ll1, ll2 : PDevEx;
|
||||||
@ -83,37 +127,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_driver(DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
procedure register_driver(Driver_Name : PChar; DeviceID : PDeviceIdentifier; Load_Callback : TDriverLoadCallback);
|
||||||
var
|
var
|
||||||
NewReg : PDriverRegistration;
|
NewReg : PDriverRegistration;
|
||||||
root_ex,
|
|
||||||
param_ex, new_ex: PDevEx;
|
|
||||||
RegList : PDriverRegistration;
|
RegList : PDriverRegistration;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if DeviceID = nil then exit;
|
if DeviceID = nil then exit;
|
||||||
NewReg:= PDriverRegistration(kalloc(sizeof(TDriverRegistration)));
|
NewReg:= PDriverRegistration(kalloc(sizeof(TDriverRegistration)));
|
||||||
NewReg^.Identifier.Bus:= DeviceID^.Bus;
|
NewReg^.Driver_Name:= stringCopy(Driver_Name);
|
||||||
NewReg^.Identifier.id0:= DeviceID^.id0;
|
NewReg^.Identifier:= copy_identifier(DeviceID);
|
||||||
NewReg^.Identifier.id1:= DeviceID^.id1;
|
|
||||||
NewReg^.Identifier.id2:= DeviceID^.id2;
|
|
||||||
NewReg^.Identifier.id3:= DeviceID^.id3;
|
|
||||||
root_ex:= nil;
|
|
||||||
if DeviceID^.ex <> nil then begin
|
|
||||||
root_ex:= PDevEx(kalloc(sizeof(TDevEx)));
|
|
||||||
param_ex:= DeviceID^.ex;
|
|
||||||
new_ex:= root_ex;
|
|
||||||
new_ex^.idN:= param_ex^.idN;
|
|
||||||
new_ex^.ex:= nil;
|
|
||||||
param_ex:= param_ex^.ex;
|
|
||||||
while param_ex <> nil do begin
|
|
||||||
new_ex^.ex:= PDevEx(kalloc(sizeof(TDevEx)));
|
|
||||||
new_ex:= new_ex^.ex;
|
|
||||||
new_ex^.idN:= param_ex^.idN;
|
|
||||||
param_ex:= param_ex^.ex;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
NewReg^.Identifier.ex:= root_ex;
|
|
||||||
NewReg^.Loaded:= false;
|
NewReg^.Loaded:= false;
|
||||||
NewReg^.Driver_Load:= Load_Callback;
|
NewReg^.Driver_Load:= Load_Callback;
|
||||||
NewReg^.Next:= nil;
|
NewReg^.Next:= nil;
|
||||||
@ -128,21 +151,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register_device(DeviceID : PDeviceIdentifier; ptr : void);
|
procedure register_device(Device_Name : PChar; DeviceID : PDeviceIdentifier; ptr : void);
|
||||||
var
|
var
|
||||||
drv : PDriverRegistration;
|
drv : PDriverRegistration;
|
||||||
|
new_dev : PDeviceRegistration;
|
||||||
|
dev_list : PDeviceRegistration;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
drv:= Root;
|
drv:= Root;
|
||||||
|
new_dev:= PDeviceRegistration(kalloc(sizeof(TDeviceRegistration)));
|
||||||
|
new_dev^.Device_Name:= stringCopy(Device_Name);
|
||||||
|
new_dev^.Identifier:= copy_identifier(DeviceID);
|
||||||
|
new_dev^.Driver_Loaded:= false;
|
||||||
|
new_dev^.Driver:= nil;
|
||||||
|
new_dev^.next:= nil;
|
||||||
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
|
||||||
drv^.Loaded:= true;
|
drv^.Loaded:= true;
|
||||||
|
new_dev^.Driver_Loaded:= true;
|
||||||
|
new_dev^.Driver:= drv;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
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.
|
Loading…
x
Reference in New Issue
Block a user