git-svn-id: https://spexeah.com:8443/svn/Asuro@388 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron 2018-04-07 20:00:43 +00:00
parent 4eb04ec8ef
commit df1fbd44b0
14 changed files with 90 additions and 16 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.

View File

@ -19,6 +19,10 @@ uses
vmemorymanager,
drivermanagement;
const
PCI_PORT_CONF_ADDR = $CF8;
PCI_PORT_CONF_DATA = $CFC;
type
TPCI_Device_Bridge = bitpacked record
@ -72,6 +76,8 @@ procedure init();
procedure scanBus(bus : uint8);
function loadDeviceConfig(bus : uint8; slot : uint8; func : uint8) : boolean;
function getDeviceInfo(class_code : uint8; subclass_code : uint8; prog_if : uint8; var count : uint32) : TdeviceArray; //(Will in future)returns TPCI_DEVICE.vendor_id := 0xFFFF if no device found.
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32);
implementation
@ -131,18 +137,47 @@ begin
end;
end;
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
{
void pci_config_write_dword(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset, uint32_t val)
uint32_t addr;
uint32_t lbus = (uint32_t)bus;
uint32_t lslot = (uint32_t)slot;
uint32_t lfunc = (uint32_t)func;
addr = (uint32_t)((lbus<<16) | (lslot << 11) | (lfunc << 8) |
(offset & 0xfc) | ((uint32_t)0x80000000));
outl(PCI_PORT_CONF_ADDR, addr);
io_wait();
outl(PCI_PORT_CONF_DATA, val);
io_wait();
}
procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32);
var
packet : uint32;
addr : uint32;
begin
packet := ($1 shl 31);
packet := packet or (bus shl 16);
packet := packet or ((slot) shl 11);
packet := packet or ((func) shl 8);
packet := packet or ((row) shl 2);
addr := ($1 shl 31);
addr := addr or (bus shl 16);
addr := addr or ((slot) shl 11);
addr := addr or ((func) shl 8);
addr := addr or ((row) shl 2);
outl(PCI_PORT_CONF_ADDR, addr);
outl(PCI_PORT_CONF_DATA, val);
end;
outl($CF8, uint32(packet));
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
var
addr : uint32;
begin
addr := ($1 shl 31);
addr := addr or (bus shl 16);
addr := addr or ((slot) shl 11);
addr := addr or ((func) shl 8);
addr := addr or ((row) shl 2);
outl(PCI_PORT_CONF_ADDR, addr);
end;
procedure loadBusConfig(bus : uint8; slot : uint8; func : uint8; device : TPCI_Device);
@ -233,6 +268,10 @@ begin
loadDeviceConfig := false;
device.bus:= bus;
device.slot:= slot;
device.func:= func;
requestConfig(bus, slot, func, 0);
data := inl($CFC);
device.device_id := getword(data, false);

View File

@ -14,6 +14,9 @@ type
PPCI_Device = ^TPCI_Device;
TPCI_Device = bitpacked record
bus : uint8;
slot : uint8;
func : uint8;
device_id : uint16;
vendor_id : uint16;
status : uint16;

View File

@ -9,7 +9,9 @@ uses
lmemorymanager,
drivermanagement,
drivertypes,
util;
util,
IDT,
PCI;
const
INTEL_VEND = $8086;
@ -125,7 +127,6 @@ type
TCardType = (ctUnknown, ctE1000, ctI217, ct82577LM);
procedure init();
procedure fire();
function getMACAddress : puint8;
function sendPacket(p_data : void; p_len : uint16) : sint32;
@ -323,7 +324,9 @@ end;
procedure enableInturrupt();
begin
writeCommand(REG_IMASK, $1F6DC);
writeCommand(REG_IMASK, $FF AND NOT(4));
readCommand($C0);
end;
procedure handleReceive();
@ -355,9 +358,33 @@ begin
console.writestringln(' ');
end;
procedure fire(); interrupt;
var
status : uint32;
begin
status:= readCommand($0C);
console.writehexln(status);
case status of
$04:begin
end;
$10:begin
end;
$80:begin
end;
end;
console.writestringln('Fired.');
end;
function load(ptr : void) : boolean;
var
PCI_Info : PPCI_Device;
i : uint32;
data : uint32;
iline : uint8;
begin
console.outputln('E1000 Driver', 'Load Start.');
@ -384,6 +411,16 @@ begin
writeMACAddress();
startLink();
for i:=0 to $80 do begin
writeCommand($5200 + i*4, 0);
end;
IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0);
enableInturrupt();
rxinit();
txinit();
load:= true;
console.outputln('E1000 Driver', 'Load Finish.');
end;
@ -435,11 +472,6 @@ begin
drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load82577LM);
end;
procedure fire();
begin
end;
function getMACAddress : puint8;
begin
getMACAddress:= puint8(@mac[0]);