Commit 990cdff2 by triazo

Move print stuff into seperate function

parent 9fc85493
Showing with 21 additions and 7 deletions
...@@ -6,14 +6,12 @@ ...@@ -6,14 +6,12 @@
#include "pci.h" #include "pci.h"
#include "serial.h" #include "serial.h"
// reads a word from the io port using the pci addressing scheme void pciSerialInfo(bus, device, function, offset)
uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset)
{ {
uint32_t address; uint32_t address;
uint32_t lbus = (uint32_t)bus; uint32_t lbus = (uint32_t)bus;
uint32_t lslot = (uint32_t)slot; uint32_t lslot = (uint32_t)slot;
uint32_t lfunc = (uint32_t)func; uint32_t lfunc = (uint32_t)func;
address = (uint32_t)((lbus << 16) | address = (uint32_t)((lbus << 16) |
(lslot << 11) | (lslot << 11) |
(lfunc << 8) | (lfunc << 8) |
...@@ -21,10 +19,8 @@ uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offs ...@@ -21,10 +19,8 @@ uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offs
((uint32_t)0x80000000)); ((uint32_t)0x80000000));
outl(PCI_CONFIG_ACCESS, address); outl(PCI_CONFIG_ACCESS, address);
// return the contents of the address clipped
uint32_t data = inl(PCI_CONFIG_DATA); uint32_t data = inl(PCI_CONFIG_DATA);
if (data != -1)
{
serial_writestring("address 0x"); serial_writestring("address 0x");
serial_hexword(address); serial_hexword(address);
serial_writestring(" returned 0x"); serial_writestring(" returned 0x");
...@@ -38,7 +34,25 @@ uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offs ...@@ -38,7 +34,25 @@ uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offs
serial_writestring(" with offset "); serial_writestring(" with offset ");
serial_hexbyte(offset); serial_hexbyte(offset);
serial_writechar('\n'); serial_writechar('\n');
} }
// reads a word from the io port using the pci addressing scheme
uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset)
{
uint32_t address;
uint32_t lbus = (uint32_t)bus;
uint32_t lslot = (uint32_t)slot;
uint32_t lfunc = (uint32_t)func;
address = (uint32_t)((lbus << 16) |
(lslot << 11) |
(lfunc << 8) |
(offset & 0xfc) |
((uint32_t)0x80000000));
outl(PCI_CONFIG_ACCESS, address);
// return the contents of the address clipped
uint32_t data = inl(PCI_CONFIG_DATA);
return data; return data;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment