2011-12-11 03:42:41 +04:00
|
|
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
2011-10-31 10:17:26 +04:00
|
|
|
*
|
|
|
|
* ToAruOS PCI Initialization
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <system.h>
|
|
|
|
|
2011-11-04 02:06:27 +04:00
|
|
|
#define PCI_CONFIG_ADDRESS 0xCF8
|
|
|
|
#define PCI_CONFIG_DATA 0xCFC
|
|
|
|
|
2011-10-31 10:17:26 +04:00
|
|
|
void
|
|
|
|
pci_install() {
|
2011-11-04 02:06:27 +04:00
|
|
|
/* Do nothing */
|
2011-10-31 10:17:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a PCI config value for the given bus/slot/function/offset
|
|
|
|
*/
|
|
|
|
uint16_t
|
|
|
|
pci_read_word(
|
|
|
|
uint32_t bus,
|
|
|
|
uint32_t slot,
|
|
|
|
uint32_t func,
|
|
|
|
uint16_t offset
|
|
|
|
) {
|
|
|
|
uint32_t address = (uint32_t)((bus << 16) || (slot << 11) |
|
|
|
|
(func << 8) | (offset & 0xFC) | ((uint32_t)0x80000000));
|
|
|
|
outportl(PCI_CONFIG_ADDRESS, address);
|
|
|
|
return (uint16_t)((inportl(PCI_CONFIG_DATA) >> ((offset & 2) * 8)) & 0xFFFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a PCI config value for the given bus/slot/function/offset
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
pci_write_word(
|
|
|
|
uint32_t bus,
|
|
|
|
uint32_t slot,
|
|
|
|
uint32_t func,
|
|
|
|
uint16_t offset,
|
|
|
|
uint32_t data
|
|
|
|
) {
|
|
|
|
uint32_t address = (uint32_t)((bus << 16) || (slot << 11) |
|
|
|
|
(func << 8) | (offset & 0xFC) | ((uint32_t)0x80000000));
|
|
|
|
outportl(PCI_CONFIG_ADDRESS, address);
|
|
|
|
outportl(PCI_CONFIG_DATA, data);
|
|
|
|
}
|
|
|
|
|