commit d0eb9a06a05e664306f6d150c733e4538823b743
parent edc41424546eacd625603cf9338b26cb3cbc987c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 10 Apr 2024 12:58:05 +0900
rename
Diffstat:
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/sys/src/kernel/amd64/pci.c b/sys/src/kernel/amd64/pci.c
@@ -2,36 +2,39 @@
#include "pci.h"
uint32
-pci_address(uint8 bus, uint8 dev, uint8 func, uint8 reg_off)
+pci_config_make_address(uint8 bus, uint8 dev, uint8 func, uint8 reg_off)
{
return 1 << 31 | // enable bit.
- bus << 16 |
- (dev&0x1f) << 11 |
- (func&3) << 8 |
+ (uint32) bus << 16 |
+ (uint32) (dev&0x1f) << 11 |
+ (uint32) (func&3) << 8 |
(reg_off&0xfc); // the least 2 bits should be 0.
}
void
-write_pci_address(uint32 addr)
+pci_config_write_address(uint32 addr)
{
io_out32(pci_config_address, addr);
}
void
-write_pci_data(uint32 value)
+pci_config_write_data(uint32 value)
{
io_out32(pci_config_data, value);
}
uint32
-read_pci_data()
+pci_config_read_data()
{
return io_in32(pci_config_data);
}
uint16
-read_pci_vendor_id(uint8 bus, uint8 device, uint8 func)
+pci_config_read16(){}
+
+uint16
+pci_config_read_vendor_id(uint8 bus, uint8 device, uint8 func)
{
- write_pci_address(pci_address(bus, device, func, 0x00));
- return read_pci_data() & 0xffff;
+ pci_config_write_address(pci_config_make_address(bus, device, func, 0x00));
+ return pci_config_read_data() & 0xffff;
}
diff --git a/sys/src/kernel/amd64/pci.h b/sys/src/kernel/amd64/pci.h
@@ -3,11 +3,11 @@
const uint16 pci_config_address = 0xcf8;
const uint16 pci_config_data = 0xcfc;
-uint32 pci_address(uint8 bus, uint8 device, uint8 function, uint8 reg_addr);
+uint32 pci_config_make_address(uint8 bus, uint8 device, uint8 function, uint8 reg_addr);
void io_out32(uint16 addr, uint32 data);
uint32 io_in32(uint16 addr);
-void write_pci_address(uint32 addr);
-void write_pci_data(uint32 value);
-uint32 read_pci_data();
-uint16 read_pci_vendor_id(uint8 bus, uint8 device, uint8 func);
-\ No newline at end of file
+void pci_config_write_address(uint32 addr);
+void pci_config_write_data(uint32 value);
+uint32 pci_config_read_data();
+uint16 pci_config_read_vendor_id(uint8 bus, uint8 device, uint8 func);
+\ No newline at end of file
diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c
@@ -47,7 +47,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
draw_mouse(&root_window, &m);
cons_printf(&con0, "hello world!\n");
cons_printf(&con0, "pixel at {%d, %d}: %x\n", p.x, p.y, get_pixel(&root_window, p));
- cons_printf(&con0, "bus 0 vendor id: %x\n", read_pci_vendor_id(0, 0, 0));
+ cons_printf(&con0, "bus 0 vendor id: %x\n", pci_config_read_vendor_id(0, 0, 0));
halt:
for(;;) { __asm__("hlt"); }