git-svn-id: https://spexeah.com:8443/svn/Asuro@486 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
5201663d0b
commit
5b07f46d1b
Binary file not shown.
BIN
lib/E1000.ppu
BIN
lib/E1000.ppu
Binary file not shown.
BIN
lib/PCI.ppu
BIN
lib/PCI.ppu
Binary file not shown.
BIN
lib/USB.ppu
BIN
lib/USB.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.
@ -12,6 +12,7 @@ unit PCI;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
tracer,
|
||||||
util,
|
util,
|
||||||
console,
|
console,
|
||||||
drivertypes,
|
drivertypes,
|
||||||
@ -87,6 +88,7 @@ var
|
|||||||
current_bus : uint8;
|
current_bus : uint8;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.load');
|
||||||
console.outputln('PCI', 'Scanning Bus: 0');
|
console.outputln('PCI', 'Scanning Bus: 0');
|
||||||
scanBus(0);
|
scanBus(0);
|
||||||
//while unscanned busses scan busses
|
//while unscanned busses scan busses
|
||||||
@ -100,6 +102,7 @@ begin
|
|||||||
end else break;
|
end else break;
|
||||||
end;
|
end;
|
||||||
load:= true;
|
load:= true;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
@ -107,6 +110,7 @@ var
|
|||||||
DevID : TDeviceIdentifier;
|
DevID : TDeviceIdentifier;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.init');
|
||||||
console.outputln('PCI','INIT BEGIN.');
|
console.outputln('PCI','INIT BEGIN.');
|
||||||
DevID.Bus:= biUnknown;
|
DevID.Bus:= biUnknown;
|
||||||
DevID.id0:= 0;
|
DevID.id0:= 0;
|
||||||
@ -116,6 +120,7 @@ begin
|
|||||||
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.outputln('PCI', 'INIT END.');
|
console.outputln('PCI', 'INIT END.');
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure scanBus(bus : uint8);
|
procedure scanBus(bus : uint8);
|
||||||
@ -125,6 +130,7 @@ var
|
|||||||
result : boolean;
|
result : boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.scanBus');
|
||||||
for slot := 0 to 31 do begin
|
for slot := 0 to 31 do begin
|
||||||
result := loadDeviceConfig(bus, slot, 0);
|
result := loadDeviceConfig(bus, slot, 0);
|
||||||
if result = true then begin
|
if result = true then begin
|
||||||
@ -135,6 +141,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -158,6 +165,7 @@ var
|
|||||||
addr : uint32;
|
addr : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.writeConfig');
|
||||||
addr := ($1 shl 31);
|
addr := ($1 shl 31);
|
||||||
addr := addr or (bus shl 16);
|
addr := addr or (bus shl 16);
|
||||||
addr := addr or ((slot) shl 11);
|
addr := addr or ((slot) shl 11);
|
||||||
@ -165,6 +173,7 @@ begin
|
|||||||
addr := addr or ((row) shl 2);
|
addr := addr or ((row) shl 2);
|
||||||
outl(PCI_PORT_CONF_ADDR, addr);
|
outl(PCI_PORT_CONF_ADDR, addr);
|
||||||
outl(PCI_PORT_CONF_DATA, val);
|
outl(PCI_PORT_CONF_DATA, val);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure setBusMaster(bus : uint8; slot : uint8; func : uint8; master : boolean);
|
procedure setBusMaster(bus : uint8; slot : uint8; func : uint8; master : boolean);
|
||||||
@ -172,6 +181,7 @@ var
|
|||||||
data : uint32;
|
data : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.setBusMaster');
|
||||||
requestConfig(bus, slot, func, 1);
|
requestConfig(bus, slot, func, 1);
|
||||||
data := inl($CFC);
|
data := inl($CFC);
|
||||||
if master then begin
|
if master then begin
|
||||||
@ -180,6 +190,7 @@ begin
|
|||||||
data := data AND $FFFFFFFB;
|
data := data AND $FFFFFFFB;
|
||||||
end;
|
end;
|
||||||
writeConfig(bus, slot, func, 1, data);
|
writeConfig(bus, slot, func, 1, data);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
|
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
|
||||||
@ -187,12 +198,14 @@ var
|
|||||||
addr : uint32;
|
addr : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.requestConfig');
|
||||||
addr := ($1 shl 31);
|
addr := ($1 shl 31);
|
||||||
addr := addr or (bus shl 16);
|
addr := addr or (bus shl 16);
|
||||||
addr := addr or ((slot) shl 11);
|
addr := addr or ((slot) shl 11);
|
||||||
addr := addr or ((func) shl 8);
|
addr := addr or ((func) shl 8);
|
||||||
addr := addr or ((row) shl 2);
|
addr := addr or ((row) shl 2);
|
||||||
outl(PCI_PORT_CONF_ADDR, addr);
|
outl(PCI_PORT_CONF_ADDR, addr);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure loadBusConfig(bus : uint8; slot : uint8; func : uint8; device : TPCI_Device);
|
procedure loadBusConfig(bus : uint8; slot : uint8; func : uint8; device : TPCI_Device);
|
||||||
@ -201,6 +214,7 @@ var
|
|||||||
data : uint32;
|
data : uint32;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.loadBusConfig');
|
||||||
|
|
||||||
busT.device_id := device.device_id;
|
busT.device_id := device.device_id;
|
||||||
busT.vendor_id := device.vendor_id;
|
busT.vendor_id := device.vendor_id;
|
||||||
@ -270,7 +284,7 @@ begin
|
|||||||
|
|
||||||
busses[bus_count] := busT;
|
busses[bus_count] := busT;
|
||||||
bus_count := bus_count + 1;
|
bus_count := bus_count + 1;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function loadDeviceConfig(bus : uint8; slot : uint8; func : uint8) : boolean;
|
function loadDeviceConfig(bus : uint8; slot : uint8; func : uint8) : boolean;
|
||||||
@ -280,7 +294,7 @@ var
|
|||||||
DevID : PDeviceIdentifier;
|
DevID : PDeviceIdentifier;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.loadDeviceConfig');
|
||||||
loadDeviceConfig := false;
|
loadDeviceConfig := false;
|
||||||
|
|
||||||
device.bus:= bus;
|
device.bus:= bus;
|
||||||
@ -292,101 +306,100 @@ begin
|
|||||||
device.device_id := getword(data, false);
|
device.device_id := getword(data, false);
|
||||||
device.vendor_id := getword(data, true);
|
device.vendor_id := getword(data, true);
|
||||||
|
|
||||||
if device.vendor_id = $FFFF then exit;
|
if device.vendor_id <> $FFFF then begin
|
||||||
|
requestConfig(bus, slot, func, 1);
|
||||||
|
data := inl($CFC);
|
||||||
|
device.status := getword(data, false);
|
||||||
|
device.command := getword(data, true);
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 1);
|
requestConfig(bus, slot, func, 2);
|
||||||
data := inl($CFC);
|
data := inl($CFC);
|
||||||
device.status := getword(data, false);
|
device.class_code := getbyte(data, 3);
|
||||||
device.command := getword(data, true);
|
device.subclass_class := getbyte(data, 2);
|
||||||
|
device.prog_if := getbyte(data, 1);
|
||||||
|
device.revision_id := getbyte(data, 0);
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 2);
|
requestConfig(bus, slot, func, 3);
|
||||||
data := inl($CFC);
|
data := inl($CFC);
|
||||||
device.class_code := getbyte(data, 3);
|
device.BIST := getbyte(data, 3);
|
||||||
device.subclass_class := getbyte(data, 2);
|
device.header_type := getbyte(data, 2);
|
||||||
device.prog_if := getbyte(data, 1);
|
device.latency_timer := getbyte(data, 1);
|
||||||
device.revision_id := getbyte(data, 0);
|
device.cache_size := getbyte(data, 0);
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 3);
|
if device.header_type and $7 = 0 then begin
|
||||||
data := inl($CFC);
|
loadDeviceConfig := true;
|
||||||
device.BIST := getbyte(data, 3);
|
requestConfig(bus, slot, func, 4);
|
||||||
device.header_type := getbyte(data, 2);
|
device.address0 := inl($CFC);
|
||||||
device.latency_timer := getbyte(data, 1);
|
requestConfig(bus, slot, func, 5);
|
||||||
device.cache_size := getbyte(data, 0);
|
device.address1 := inl($CFC);
|
||||||
|
requestConfig(bus, slot, func, 6);
|
||||||
|
device.address2 := inl($CFC);
|
||||||
|
requestConfig(bus, slot, func, 7);
|
||||||
|
device.address3 := inl($CFC);
|
||||||
|
requestConfig(bus, slot, func, 8);
|
||||||
|
device.address4 := inl($CFC);
|
||||||
|
requestConfig(bus, slot, func, 9);
|
||||||
|
device.address5 := inl($CFC);
|
||||||
|
|
||||||
if device.header_type and $7 = 0 then begin
|
requestConfig(bus, slot, func, 10);
|
||||||
loadDeviceConfig := true;
|
device.CIS_Pointer := inl($CFC);
|
||||||
end else begin
|
|
||||||
loadBusConfig(bus, slot, func, device);
|
requestConfig(bus, slot, func, 11);
|
||||||
exit(false);
|
data := inl($CFC);
|
||||||
|
device.subsystem_id := getword(data, false);
|
||||||
|
device.subsystem_vid := getword(data, true);
|
||||||
|
|
||||||
|
requestConfig(bus, slot, func, 12);
|
||||||
|
device.exp_rom_addr := inl($CFC);
|
||||||
|
|
||||||
|
requestConfig(bus, slot, func, 13);
|
||||||
|
data := inl($CFC);
|
||||||
|
device.reserved0 := getword(data, false);
|
||||||
|
device.reserved1 := getbyte(data, 1);
|
||||||
|
device.capabilities := getbyte(data, 0);
|
||||||
|
|
||||||
|
requestConfig(bus, slot, func, 14);
|
||||||
|
device.reserved2 := inl($CFC);
|
||||||
|
|
||||||
|
requestConfig(bus, slot, func, 15);
|
||||||
|
data := inl($CFC);
|
||||||
|
device.max_latency := getbyte(data, 3);
|
||||||
|
device.min_grant := getbyte(data, 2);
|
||||||
|
device.interrupt_pin := getbyte(data, 1);
|
||||||
|
device.interrupt_line := getbyte(data, 0);
|
||||||
|
|
||||||
|
DevID:= PDeviceIdentifier(kalloc(sizeof(TDeviceIdentifier)));
|
||||||
|
DevID^.Bus:= biPCI;
|
||||||
|
DevID^.id0:= device.device_id;
|
||||||
|
DevID^.id1:= device.class_code;
|
||||||
|
DevID^.id2:= device.subclass_class;
|
||||||
|
DevID^.id3:= device.prog_if;
|
||||||
|
DevID^.id4:= device.vendor_id;
|
||||||
|
DevID^.ex:= nil;
|
||||||
|
|
||||||
|
console.output('PCI', 'Found Device: ');
|
||||||
|
console.writehex(device.header_type);
|
||||||
|
console.writestring(' ');
|
||||||
|
console.writehex(device.device_id);
|
||||||
|
console.writestring(' ');
|
||||||
|
console.writehex(device.class_code);
|
||||||
|
console.writestring(' ');
|
||||||
|
console.writehex(device.subclass_class);
|
||||||
|
console.writestring(' ');
|
||||||
|
console.writehexln(device.prog_if);
|
||||||
|
|
||||||
|
devices[device_count] := device;
|
||||||
|
device_count := device_count + 1;
|
||||||
|
|
||||||
|
drivermanagement.register_device('PCI Device', DevID, @device);
|
||||||
|
kfree(void(DevID));
|
||||||
|
end else begin
|
||||||
|
loadBusConfig(bus, slot, func, device);
|
||||||
|
end;
|
||||||
|
//TODO implement other types?
|
||||||
end;
|
end;
|
||||||
//TODO implement other types?
|
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 4);
|
|
||||||
device.address0 := inl($CFC);
|
|
||||||
requestConfig(bus, slot, func, 5);
|
|
||||||
device.address1 := inl($CFC);
|
|
||||||
requestConfig(bus, slot, func, 6);
|
|
||||||
device.address2 := inl($CFC);
|
|
||||||
requestConfig(bus, slot, func, 7);
|
|
||||||
device.address3 := inl($CFC);
|
|
||||||
requestConfig(bus, slot, func, 8);
|
|
||||||
device.address4 := inl($CFC);
|
|
||||||
requestConfig(bus, slot, func, 9);
|
|
||||||
device.address5 := inl($CFC);
|
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 10);
|
|
||||||
device.CIS_Pointer := inl($CFC);
|
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 11);
|
|
||||||
data := inl($CFC);
|
|
||||||
device.subsystem_id := getword(data, false);
|
|
||||||
device.subsystem_vid := getword(data, true);
|
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 12);
|
|
||||||
device.exp_rom_addr := inl($CFC);
|
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 13);
|
|
||||||
data := inl($CFC);
|
|
||||||
device.reserved0 := getword(data, false);
|
|
||||||
device.reserved1 := getbyte(data, 1);
|
|
||||||
device.capabilities := getbyte(data, 0);
|
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 14);
|
|
||||||
device.reserved2 := inl($CFC);
|
|
||||||
|
|
||||||
requestConfig(bus, slot, func, 15);
|
|
||||||
data := inl($CFC);
|
|
||||||
device.max_latency := getbyte(data, 3);
|
|
||||||
device.min_grant := getbyte(data, 2);
|
|
||||||
device.interrupt_pin := getbyte(data, 1);
|
|
||||||
device.interrupt_line := getbyte(data, 0);
|
|
||||||
|
|
||||||
DevID:= PDeviceIdentifier(kalloc(sizeof(TDeviceIdentifier)));
|
|
||||||
DevID^.Bus:= biPCI;
|
|
||||||
DevID^.id0:= device.device_id;
|
|
||||||
DevID^.id1:= device.class_code;
|
|
||||||
DevID^.id2:= device.subclass_class;
|
|
||||||
DevID^.id3:= device.prog_if;
|
|
||||||
DevID^.id4:= device.vendor_id;
|
|
||||||
DevID^.ex:= nil;
|
|
||||||
|
|
||||||
console.output('PCI', 'Found Device: ');
|
|
||||||
console.writehex(device.header_type);
|
|
||||||
console.writestring(' ');
|
|
||||||
console.writehex(device.device_id);
|
|
||||||
console.writestring(' ');
|
|
||||||
console.writehex(device.class_code);
|
|
||||||
console.writestring(' ');
|
|
||||||
console.writehex(device.subclass_class);
|
|
||||||
console.writestring(' ');
|
|
||||||
console.writehexln(device.prog_if);
|
|
||||||
|
|
||||||
devices[device_count] := device;
|
|
||||||
device_count := device_count + 1;
|
|
||||||
|
|
||||||
drivermanagement.register_device('PCI Device', DevID, @device);
|
|
||||||
kfree(void(DevID));
|
|
||||||
//if device.class_code = 1 then ata.init(device);
|
//if device.class_code = 1 then ata.init(device);
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function getDeviceInfo(class_code : uint8; subclass_code : uint8; prog_if : uint8; var count : uint32) : TDeviceArray;
|
function getDeviceInfo(class_code : uint8; subclass_code : uint8; prog_if : uint8; var count : uint32) : TDeviceArray;
|
||||||
@ -395,6 +408,7 @@ var
|
|||||||
devices_out : array[0..31] of TPCI_Device;
|
devices_out : array[0..31] of TPCI_Device;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
push_trace('PCI.getDeviceInfo');
|
||||||
count := 0;
|
count := 0;
|
||||||
for i:=0 to device_count do begin
|
for i:=0 to device_count do begin
|
||||||
{writehex(devices[i].class_code);
|
{writehex(devices[i].class_code);
|
||||||
@ -414,6 +428,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
getDeviceInfo := devices_out;
|
getDeviceInfo := devices_out;
|
||||||
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
@ -179,8 +179,6 @@ begin
|
|||||||
console.writestringln('');
|
console.writestringln('');
|
||||||
console.writestringln('Press any key to boot in to Asuro Terminal...');
|
console.writestringln('Press any key to boot in to Asuro Terminal...');
|
||||||
|
|
||||||
//GPF;
|
|
||||||
|
|
||||||
keyboard.hook(@temphook);
|
keyboard.hook(@temphook);
|
||||||
|
|
||||||
util.halt_and_dont_catch_fire;
|
util.halt_and_dont_catch_fire;
|
||||||
|
@ -48,18 +48,19 @@ begin
|
|||||||
push_trace('pmemorymanager.set_memory_area_present');
|
push_trace('pmemorymanager.set_memory_area_present');
|
||||||
FirstBlock:= base SHR 22;
|
FirstBlock:= base SHR 22;
|
||||||
LastBlock:= (base+length) SHR 22;
|
LastBlock:= (base+length) SHR 22;
|
||||||
if (FirstBlock > 1023) then exit;
|
if not (FirstBlock > 1023) then begin
|
||||||
while LastBlock > 1023 do begin
|
while LastBlock > 1023 do begin
|
||||||
LastBlock:= LastBlock-1;
|
LastBlock:= LastBlock-1;
|
||||||
end;
|
end;
|
||||||
for i:=FirstBlock to LastBlock do begin
|
for i:=FirstBlock to LastBlock do begin
|
||||||
if not present then begin
|
if not present then begin
|
||||||
PhysicalMemory[i].Scanned:= True;
|
|
||||||
PhysicalMemory[i].Present:= present;
|
|
||||||
end else begin
|
|
||||||
If not PhysicalMemory[i].Scanned then begin
|
|
||||||
PhysicalMemory[i].Scanned:= True;
|
PhysicalMemory[i].Scanned:= True;
|
||||||
PhysicalMemory[i].Present:= present;
|
PhysicalMemory[i].Present:= present;
|
||||||
|
end else begin
|
||||||
|
If not PhysicalMemory[i].Scanned then begin
|
||||||
|
PhysicalMemory[i].Scanned:= True;
|
||||||
|
PhysicalMemory[i].Present:= present;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -168,7 +169,7 @@ begin
|
|||||||
if not PhysicalMemory[i].Allocated then begin
|
if not PhysicalMemory[i].Allocated then begin
|
||||||
if alloc_block(i, caller) then begin
|
if alloc_block(i, caller) then begin
|
||||||
new_block:= i;
|
new_block:= i;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -181,19 +182,15 @@ begin
|
|||||||
push_trace('pmemorymanager.free_block');
|
push_trace('pmemorymanager.free_block');
|
||||||
if block > 1023 then begin
|
if block > 1023 then begin
|
||||||
GPF;
|
GPF;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
if block < 2 then begin
|
if block < 2 then begin
|
||||||
GPF;
|
GPF;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
if not PhysicalMemory[block].Present then begin
|
if not PhysicalMemory[block].Present then begin
|
||||||
GPF;
|
GPF;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
if PhysicalMemory[block].MappedTo <> caller then begin
|
if PhysicalMemory[block].MappedTo <> caller then begin
|
||||||
GPF;
|
GPF;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
PhysicalMemory[block].Allocated:= false;
|
PhysicalMemory[block].Allocated:= false;
|
||||||
pop_trace;
|
pop_trace;
|
||||||
|
@ -190,14 +190,15 @@ var
|
|||||||
begin
|
begin
|
||||||
push_trace('vmemorymanager.new_page');
|
push_trace('vmemorymanager.new_page');
|
||||||
new_page:= false;
|
new_page:= false;
|
||||||
if PageDirectory^[page_number].Present then exit;
|
if not PageDirectory^[page_number].Present then begin
|
||||||
if PageDirectory^[page_number].Reserved then exit;
|
if not PageDirectory^[page_number].Reserved then begin;
|
||||||
block:= pmemorymanager.new_block(uint32(PageDirectory));
|
block:= pmemorymanager.new_block(uint32(PageDirectory));
|
||||||
if block < 2 then begin
|
if block < 2 then begin
|
||||||
GPF;
|
GPF;
|
||||||
exit;
|
end else begin
|
||||||
end else begin
|
new_page:= map_page(page_number, block);
|
||||||
new_page:= map_page(page_number, block);
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user