summaryrefslogtreecommitdiff
path: root/src/arch/amd64/drivers/pci.c
diff options
context:
space:
mode:
authortrimill <trimill@trimillxyz.org>2024-02-03 21:05:27 -0500
committertrimill <trimill@trimillxyz.org>2024-02-03 21:08:36 -0500
commit85a94437048e85aa97991899abbdd0cc927ca671 (patch)
tree2cb682af2be6ec7e94ebc3f010a780d1b4037c93 /src/arch/amd64/drivers/pci.c
parentfix lib (diff)
downloadcorn-85a94437048e85aa97991899abbdd0cc927ca671.tar.gz
corn-85a94437048e85aa97991899abbdd0cc927ca671.tar.bz2
corn-85a94437048e85aa97991899abbdd0cc927ca671.zip
formatting
Diffstat (limited to 'src/arch/amd64/drivers/pci.c')
-rw-r--r--src/arch/amd64/drivers/pci.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/arch/amd64/drivers/pci.c b/src/arch/amd64/drivers/pci.c
index 410eb7e..7aa11c8 100644
--- a/src/arch/amd64/drivers/pci.c
+++ b/src/arch/amd64/drivers/pci.c
@@ -88,7 +88,7 @@ static void print_device(struct pci_table_entry *entry) {
}
static struct pci_table_entry *load_device(struct pci_device dev) {
- if(pci_table_next >= TABLE_LEN) panic("Too many PCI devices: limit is %d", TABLE_LEN);
+ if (pci_table_next >= TABLE_LEN) panic("Too many PCI devices: limit is %d", TABLE_LEN);
struct pci_table_entry *entry = &pci_table[pci_table_next++];
entry->device = dev;
uint32_t dword0 = pci_rcfg_d(dev, 0);
@@ -108,25 +108,25 @@ static struct pci_table_entry *load_device(struct pci_device dev) {
void pci_init(void) {
pci_table_next = 0;
struct pci_device pcidev;
- for(int bus = 0; bus < 256; bus++) {
+ for (int bus = 0; bus < 256; bus++) {
pcidev.bus = bus;
- for(int dev = 0; dev < 32; dev++) {
+ for (int dev = 0; dev < 32; dev++) {
pcidev.device = dev;
pcidev.function = 0;
uint16_t vendor = pci_rcfg_w(pcidev, 0);
- if(vendor == 0xFFFF) continue;
+ if (vendor == 0xFFFF) continue;
load_device(pcidev);
uint8_t header_type = pci_rcfg_b(pcidev, 14);
- if(!(header_type & 0x80)) continue;
- for(int func = 1; func < 8; func++) {
+ if (!(header_type & 0x80)) continue;
+ for (int func = 1; func < 8; func++) {
pcidev.function = func;
uint16_t vendor = pci_rcfg_w(pcidev, 0);
- if(vendor == 0xFFFF) continue;
+ if (vendor == 0xFFFF) continue;
load_device(pcidev);
}
@@ -141,10 +141,10 @@ void pci_init(void) {
bool pci_findby_class(struct pci_device *dest, uint8_t class, uint8_t subclass, size_t *offset) {
size_t o = 0;
- if(offset == NULL) offset = &o;
- for(; *offset < pci_table_next; (*offset)++) {
+ if (offset == NULL) offset = &o;
+ for (; *offset < pci_table_next; (*offset)++) {
struct pci_table_entry *entry = &pci_table[*offset];
- if(entry->class == class && entry->subclass == subclass) {
+ if (entry->class == class && entry->subclass == subclass) {
*dest = entry->device;
return true;
}
@@ -154,10 +154,10 @@ bool pci_findby_class(struct pci_device *dest, uint8_t class, uint8_t subclass,
bool pci_findby_id(struct pci_device *dest, uint16_t device, uint16_t vendor, size_t *offset) {
size_t o = 0;
- if(offset == NULL) offset = &o;
- for(; *offset < pci_table_next; (*offset)++) {
+ if (offset == NULL) offset = &o;
+ for (; *offset < pci_table_next; (*offset)++) {
struct pci_table_entry *entry = &pci_table[*offset];
- if(entry->device_id == device && entry->vendor_id == vendor) {
+ if (entry->device_id == device && entry->vendor_id == vendor) {
*dest = entry->device;
return true;
}