git-svn-id: https://spexeah.com:8443/svn/Asuro@670 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
45
src/driver/bus/EHCI.pas
Normal file
45
src/driver/bus/EHCI.pas
Normal file
@ -0,0 +1,45 @@
|
||||
unit EHCI;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer,
|
||||
Console,
|
||||
PCI,
|
||||
drivertypes,
|
||||
pmemorymanager,
|
||||
vmemorymanager,
|
||||
util,
|
||||
drivermanagement;
|
||||
|
||||
function load : boolean;
|
||||
|
||||
implementation
|
||||
|
||||
function load : boolean;
|
||||
var
|
||||
devices : TDeviceArray;
|
||||
count : uint32;
|
||||
i : uint32;
|
||||
|
||||
begin
|
||||
devices:= PCI.getDeviceInfo($0C, $03, $20, count);
|
||||
console.output('USB-EHCI Driver', 'Found ');
|
||||
console.writeint(count);
|
||||
console.writestringln(' USB Controller(s).');
|
||||
if count > 0 then begin
|
||||
for i:=0 to count-1 do begin
|
||||
console.output('USB-OHCI Driver', '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;
|
||||
load:= true;
|
||||
end;
|
||||
|
||||
end.
|
76
src/driver/bus/OHCI.pas
Normal file
76
src/driver/bus/OHCI.pas
Normal file
@ -0,0 +1,76 @@
|
||||
unit OHCI;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer,
|
||||
Console,
|
||||
PCI,
|
||||
drivertypes,
|
||||
pmemorymanager,
|
||||
vmemorymanager,
|
||||
util,
|
||||
drivermanagement;
|
||||
|
||||
type
|
||||
POHCI_MMR = ^TOHCI_MMR;
|
||||
TOHCI_MMR = packed record
|
||||
HcRevision : uint32;
|
||||
HcControl : uint32;
|
||||
HcCommandStatus : uint32;
|
||||
HcIntStatus : uint32;
|
||||
HcIntEnable : uint32;
|
||||
HcIntDisable : uint32;
|
||||
HcHCCA : uint32;
|
||||
HcPeriodCurrentED : uint32;
|
||||
HcControlHeadED : uint32;
|
||||
HcControlCurrentED : uint32;
|
||||
HcBulkHeadED : uint32;
|
||||
HcBulkCurrentED : uint32;
|
||||
HcDoneHead : uint32;
|
||||
HcFmRemaining : uint32;
|
||||
HcFmNumber : uint32;
|
||||
HcPeriodicStart : uint32;
|
||||
HcLSThreshold : uint32;
|
||||
HcRhDescriptorA : uint32;
|
||||
HcRhDescriptorB : uint32;
|
||||
HcRhStatus : uint32;
|
||||
end;
|
||||
|
||||
function load : boolean;
|
||||
|
||||
implementation
|
||||
|
||||
function load : boolean;
|
||||
var
|
||||
devices : TDeviceArray;
|
||||
count : uint32;
|
||||
i : uint32;
|
||||
block : uint32;
|
||||
MMR : POHCI_MMR;
|
||||
|
||||
begin
|
||||
devices:= PCI.getDeviceInfo($0C, $03, $10, count);
|
||||
console.output('USB-OHCI Driver', 'Found ');
|
||||
console.writeint(count);
|
||||
console.writestringln(' USB Controller(s).');
|
||||
if count > 0 then begin
|
||||
for i:=0 to count-1 do begin
|
||||
console.output('USB-OHCI Driver', '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);
|
||||
block:= devices[i].address0 SHR 22;
|
||||
force_alloc_block(block, 0);
|
||||
map_page(block, block);
|
||||
MMR:= POHCI_MMR(devices[i].address0);
|
||||
end;
|
||||
end;
|
||||
load:= true;
|
||||
end;
|
||||
|
||||
end.
|
45
src/driver/bus/UHCI.pas
Normal file
45
src/driver/bus/UHCI.pas
Normal file
@ -0,0 +1,45 @@
|
||||
unit UHCI;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer,
|
||||
Console,
|
||||
PCI,
|
||||
drivertypes,
|
||||
pmemorymanager,
|
||||
vmemorymanager,
|
||||
util,
|
||||
drivermanagement;
|
||||
|
||||
function load : boolean;
|
||||
|
||||
implementation
|
||||
|
||||
function load : boolean;
|
||||
var
|
||||
devices : TDeviceArray;
|
||||
count : uint32;
|
||||
i : uint32;
|
||||
|
||||
begin
|
||||
devices:= PCI.getDeviceInfo($0C, $03, $00, count);
|
||||
console.output('USB-UHCI Driver','Found ');
|
||||
console.writeint(count);
|
||||
console.writestringln(' USB Controller(s).');
|
||||
if count > 0 then begin
|
||||
for i:=0 to count-1 do begin
|
||||
console.output('USB-UHCI Driver','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;
|
||||
load:= true;
|
||||
end;
|
||||
|
||||
end.
|
@ -10,102 +10,34 @@ uses
|
||||
pmemorymanager,
|
||||
vmemorymanager,
|
||||
util,
|
||||
drivermanagement;
|
||||
|
||||
type
|
||||
POHCI_MMR = ^TOHCI_MMR;
|
||||
TOHCI_MMR = packed record
|
||||
HcRevision : uint32;
|
||||
HcControl : uint32;
|
||||
HcCommandStatus : uint32;
|
||||
HcIntStatus : uint32;
|
||||
HcIntEnable : uint32;
|
||||
HcIntDisable : uint32;
|
||||
HcHCCA : uint32;
|
||||
HcPeriodCurrentED : uint32;
|
||||
HcControlHeadED : uint32;
|
||||
HcControlCurrentED : uint32;
|
||||
HcBulkHeadED : uint32;
|
||||
HcBulkCurrentED : uint32;
|
||||
HcDoneHead : uint32;
|
||||
HcFmRemaining : uint32;
|
||||
HcFmNumber : uint32;
|
||||
HcPeriodicStart : uint32;
|
||||
HcLSThreshold : uint32;
|
||||
HcRhDescriptorA : uint32;
|
||||
HcRhDescriptorB : uint32;
|
||||
HcRhStatus : uint32;
|
||||
end;
|
||||
drivermanagement,
|
||||
OHCI, UHCI, EHCI;
|
||||
|
||||
procedure init;
|
||||
|
||||
implementation
|
||||
|
||||
function loadOHCI(ptr : void) : boolean;
|
||||
var
|
||||
devices : TDeviceArray;
|
||||
count : uint32;
|
||||
i : uint32;
|
||||
block : uint32;
|
||||
MMR : POHCI_MMR;
|
||||
function loadEHCI(ptr : void) : boolean;
|
||||
begin
|
||||
push_trace('USB.loadEHCI');
|
||||
loadEHCI:= EHCI.load;
|
||||
end;
|
||||
|
||||
function loadOHCI(ptr : void) : boolean;
|
||||
begin
|
||||
push_trace('USB.loadOHCI');
|
||||
devices:= PCI.getDeviceInfo($0C, $03, $10, count);
|
||||
console.output('USB-OHCI Driver', 'Found ');
|
||||
console.writeint(count);
|
||||
console.writestringln(' USB Controller(s).');
|
||||
if count > 0 then begin
|
||||
for i:=0 to count-1 do begin
|
||||
console.output('USB-OHCI Driver', '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);
|
||||
block:= devices[i].address0 SHR 22;
|
||||
force_alloc_block(block, 0);
|
||||
map_page(block, block);
|
||||
MMR:= POHCI_MMR(devices[i].address0);
|
||||
end;
|
||||
end;
|
||||
loadOHCI:= true;
|
||||
pop_trace;
|
||||
loadOHCI:= OHCI.load;
|
||||
end;
|
||||
|
||||
function loadUHCI(ptr : void) : boolean;
|
||||
var
|
||||
devices : TDeviceArray;
|
||||
count : uint32;
|
||||
i : uint32;
|
||||
|
||||
begin
|
||||
push_trace('USB.loadUHCI');
|
||||
devices:= PCI.getDeviceInfo($0C, $03, $00, count);
|
||||
console.output('USB-UHCI Driver','Found ');
|
||||
console.writeint(count);
|
||||
console.writestringln(' USB Controller(s).');
|
||||
if count > 0 then begin
|
||||
for i:=0 to count-1 do begin
|
||||
console.output('USB-UHCI Driver','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;
|
||||
loadUHCI:= true;
|
||||
pop_trace;
|
||||
loadUHCI:= UHCI.load;
|
||||
end;
|
||||
|
||||
procedure init;
|
||||
var
|
||||
UHCI_ID, OHCI_ID : TDeviceIdentifier;
|
||||
UHCI_ID, OHCI_ID, EHCI_ID: TDeviceIdentifier;
|
||||
|
||||
begin
|
||||
push_trace('USB.init');
|
||||
@ -127,8 +59,17 @@ begin
|
||||
OHCI_ID.id4:= $FFFFFFFF;
|
||||
OHCI_ID.ex:= nil;
|
||||
|
||||
EHCI_ID.Bus:= biPCI;
|
||||
EHCI_ID.id0:= idANY;
|
||||
EHCI_ID.id1:= $0000000C;
|
||||
EHCI_ID.id2:= $00000003;
|
||||
EHCI_ID.id3:= $00000020;
|
||||
EHCI_ID.id4:= $FFFFFFFF;
|
||||
EHCI_ID.ex:= nil;
|
||||
|
||||
drivermanagement.register_driver('USB-UHCI Driver', @UHCI_ID, @loadUHCI);
|
||||
drivermanagement.register_driver('USB-OHCI Driver', @OHCI_ID, @loadOHCI);
|
||||
drivermanagement.register_driver('USB-EHCI Driver', @EHCI_ID, @loadEHCI);
|
||||
|
||||
console.outputln('USB Driver', 'INIT END.');
|
||||
pop_trace;
|
||||
|
Reference in New Issue
Block a user