diff --git a/linux/pci.c b/linux/pci.c index 729b0a3..c82079d 100644 --- a/linux/pci.c +++ b/linux/pci.c @@ -1,4 +1,6 @@ +#include #include +#include #include #include #include @@ -16,8 +18,9 @@ __attribute__((stdcall)) uint32_t pci_read(uint32_t bus, uint32_t dev, uint32_t value = 0; sprintf(path, "%s/%4.4x:%2.2x:%2.2x.%u/config", pci_path, 0, bus, dev, fun); int fd = open(path, O_RDONLY); - if (!fd) { - // TODO: report an error + if (fd == -1) { +// fprintf(stderr, "[pci] error: failed to open config file '%s': %s\n", +// path, strerror(errno)); return UINT32_MAX; } lseek(fd, offset, SEEK_SET); diff --git a/test/026_#acpi_m000.ref.log b/test/026_#acpi_m000.ref.log index 13d3d1a..77cf9ab 100644 --- a/test/026_#acpi_m000.ref.log +++ b/test/026_#acpi_m000.ref.log @@ -127924,7 +127924,7 @@ aml._.get_node_by_name end 00:08.1 0000:0000 00 1 \_SB_\PCI0\GP17 03:00.0 1002:15DD 34 0 \_SB_\PCI0\GP17\VGA_ 03:00.1 1002:15DE 35 0 \_SB_\PCI0\GP17\D00C - 03:00.5 0000:0000 00 0 \_SB_\PCI0\GP17\D00D + 03:00.5 FFFF:FFFF 00 0 \_SB_\PCI0\GP17\D00D 03:00.6 1022:15E3 36 0 \_SB_\PCI0\GP17\D00E 03:00.7 1022:15E6 37 0 \_SB_\PCI0\GP17\MP2C 03:00.3 1022:15E0 37 0 \_SB_\PCI0\GP17\XHC0 @@ -127932,18 +127932,18 @@ aml._.get_node_by_name end 03:00.2 1022:15DF 36 0 \_SB_\PCI0\GP17\APSP 00:08.2 0000:0000 00 1 \_SB_\PCI0\GP18 04:00.0 1022:7901 36 0 \_SB_\PCI0\GP18\SATA - 04:00.1 0000:0000 00 0 \_SB_\PCI0\GP18\D01C - 04:00.2 0000:0000 00 0 \_SB_\PCI0\GP18\D01D + 04:00.1 FFFF:FFFF 00 0 \_SB_\PCI0\GP18\D01C + 04:00.2 FFFF:FFFF 00 0 \_SB_\PCI0\GP18\D01D 00:14.0 1022:790B 00 0 \_SB_\PCI0\D015 00:14.3 0000:0000 00 1 \_SB_\PCI0\SBRG - 00:14.6 0000:0000 00 0 \_SB_\PCI0\D018 - 00:01.1 0000:0000 00 0 \_SB_\PCI0\GPP0 - 00:01.2 0000:0000 00 0 \_SB_\PCI0\GPP1 - 00:01.3 0000:0000 00 0 \_SB_\PCI0\GPP2 - 00:01.4 0000:0000 00 0 \_SB_\PCI0\GPP3 - 00:01.5 0000:0000 00 0 \_SB_\PCI0\GPP4 + 00:14.6 FFFF:FFFF 00 0 \_SB_\PCI0\D018 + 00:01.1 FFFF:FFFF 00 0 \_SB_\PCI0\GPP0 + 00:01.2 FFFF:FFFF 00 0 \_SB_\PCI0\GPP1 + 00:01.3 FFFF:FFFF 00 0 \_SB_\PCI0\GPP2 + 00:01.4 FFFF:FFFF 00 0 \_SB_\PCI0\GPP3 + 00:01.5 FFFF:FFFF 00 0 \_SB_\PCI0\GPP4 00:01.6 0000:0000 00 1 \_SB_\PCI0\GPP5 01:00.0 10EC:B822 2C 0 \_SB_\PCI0\GPP5\XPDV 00:01.7 0000:0000 00 1 \_SB_\PCI0\GPP6 - 02:00.F 0000:0000 00 0 \_SB_\PCI0\GPP6\D027 + 02:00.F FFFF:FFFF 00 0 \_SB_\PCI0\GPP6\D027 02:00.0 10EC:8168 30 0 \_SB_\PCI0\GPP6\XPDV diff --git a/test/027_#acpi_m001.ref.log b/test/027_#acpi_m001.ref.log index b110388..8c27890 100644 --- a/test/027_#acpi_m001.ref.log +++ b/test/027_#acpi_m001.ref.log @@ -70248,32 +70248,32 @@ name: '_ADR' aml._.get_node_by_name end 00:00.0 0000:0000 00 1 \_SB_\PCI0 00:01.0 1002:990D 11 0 \_SB_\PCI0\VGA_ - 00:02.0 0000:0000 00 0 \_SB_\PCI0\PB2_ - 00:03.0 0000:0000 00 0 \_SB_\PCI0\PB3_ - 00:04.0 0000:0000 00 0 \_SB_\PCI0\PB4_ - 00:05.0 0000:0000 00 0 \_SB_\PCI0\PB5_ - 00:06.0 0000:0000 00 0 \_SB_\PCI0\PB6_ - 00:07.0 0000:0000 00 0 \_SB_\PCI0\PB7_ + 00:02.0 FFFF:FFFF 00 0 \_SB_\PCI0\PB2_ + 00:03.0 FFFF:FFFF 00 0 \_SB_\PCI0\PB3_ + 00:04.0 FFFF:FFFF 00 0 \_SB_\PCI0\PB4_ + 00:05.0 FFFF:FFFF 00 0 \_SB_\PCI0\PB5_ + 00:06.0 FFFF:FFFF 00 0 \_SB_\PCI0\PB6_ + 00:07.0 FFFF:FFFF 00 0 \_SB_\PCI0\PB7_ 00:15.0 0000:0000 00 1 \_SB_\PCI0\SPB0 02:00.0 1969:10A1 10 0 \_SB_\PCI0\SPB0\XPDV 00:15.1 0000:0000 00 1 \_SB_\PCI0\SPB1 03:00.0 168C:0034 11 0 \_SB_\PCI0\SPB1\XPDV - 00:15.2 0000:0000 00 0 \_SB_\PCI0\SPB2 - 00:15.3 0000:0000 00 0 \_SB_\PCI0\SPB3 + 00:15.2 FFFF:FFFF 00 0 \_SB_\PCI0\SPB2 + 00:15.3 FFFF:FFFF 00 0 \_SB_\PCI0\SPB3 00:14.2 1022:780D 10 0 \_SB_\PCI0\AZAL - 00:14.6 0000:0000 00 0 \_SB_\PCI0\GEC_ + 00:14.6 FFFF:FFFF 00 0 \_SB_\PCI0\GEC_ 00:12.0 1022:7807 12 0 \_SB_\PCI0\OHC1 00:13.0 1022:7807 12 0 \_SB_\PCI0\OHC2 - 00:16.0 0000:0000 00 0 \_SB_\PCI0\OHC3 - 00:14.5 0000:0000 00 0 \_SB_\PCI0\OHC4 + 00:16.0 FFFF:FFFF 00 0 \_SB_\PCI0\OHC3 + 00:14.5 FFFF:FFFF 00 0 \_SB_\PCI0\OHC4 00:12.2 1022:7808 11 0 \_SB_\PCI0\EHC1 00:13.2 1022:7808 11 0 \_SB_\PCI0\EHC2 - 00:16.2 0000:0000 00 0 \_SB_\PCI0\EHC3 + 00:16.2 FFFF:FFFF 00 0 \_SB_\PCI0\EHC3 00:10.0 1022:7814 12 0 \_SB_\PCI0\XHC0 - 00:10.1 0000:0000 00 0 \_SB_\PCI0\XHC1 + 00:10.1 FFFF:FFFF 00 0 \_SB_\PCI0\XHC1 00:14.0 1022:780B 00 0 \_SB_\PCI0\SMBS 00:14.3 0000:0000 00 1 \_SB_\PCI0\LPC0 00:14.4 0000:0000 00 1 \_SB_\PCI0\P2P_ 00:11.0 1022:7801 13 0 \_SB_\PCI0\SATA - 00:14.1 0000:0000 00 0 \_SB_\PCI0\IDE_ + 00:14.1 FFFF:FFFF 00 0 \_SB_\PCI0\IDE_ 00:18.3 0000:0000 00 1 \_SB_\PCI0\G3F3 diff --git a/test/032_#acpi_m005.ref.log b/test/032_#acpi_m005.ref.log index ceee0a8..fc30cb7 100644 --- a/test/032_#acpi_m005.ref.log +++ b/test/032_#acpi_m005.ref.log @@ -30565,13 +30565,13 @@ aml._.get_node_by_name begin name: '_ADR' aml._.get_node_by_name end 00:18.0 0000:0000 00 1 \_SB_\PCI0 - 00:01.0 0000:0000 00 0 \_SB_\PCI0\P0P1 + 00:01.0 FFFF:FFFF 00 0 \_SB_\PCI0\P0P1 00:02.0 0000:0000 00 1 \_SB_\PCI0\P0P2 - 00:03.0 0000:0000 00 0 \_SB_\PCI0\P0P3 - 00:04.0 0000:0000 00 0 \_SB_\PCI0\P0P4 - 00:05.0 0000:0000 00 0 \_SB_\PCI0\P0P5 - 00:06.0 0000:0000 00 0 \_SB_\PCI0\P0P6 - 00:07.0 0000:0000 00 0 \_SB_\PCI0\P0P7 + 00:03.0 FFFF:FFFF 00 0 \_SB_\PCI0\P0P3 + 00:04.0 FFFF:FFFF 00 0 \_SB_\PCI0\P0P4 + 00:05.0 FFFF:FFFF 00 0 \_SB_\PCI0\P0P5 + 00:06.0 FFFF:FFFF 00 0 \_SB_\PCI0\P0P6 + 00:07.0 FFFF:FFFF 00 0 \_SB_\PCI0\P0P7 00:1A.0 0000:0000 00 1 \_SB_\PCI0\PE2P 00:1E.0 0000:0000 00 1 \_SB_\PCI0\SBRG 00:1E.1 0000:0000 00 1 \_SB_\PCI0\PMU_ @@ -30580,7 +30580,7 @@ aml._.get_node_by_name end 00:1C.2 10B9:5237 13 0 \_SB_\PCI0\USB2 00:1C.3 10B9:5239 17 0 \_SB_\PCI0\UB20 00:1D.0 10B9:5461 16 0 \_SB_\PCI0\AC97 - 00:1D.1 0000:0000 00 0 \_SB_\PCI0\MC97 - 00:1D.2 0000:0000 00 0 \_SB_\PCI0\AZAL + 00:1D.1 FFFF:FFFF 00 0 \_SB_\PCI0\MC97 + 00:1D.2 FFFF:FFFF 00 0 \_SB_\PCI0\AZAL 00:1F.0 10B9:5229 13 0 \_SB_\PCI0\IDEC 00:1F.1 10B9:5288 13 0 \_SB_\PCI0\SATA diff --git a/test/035_#acpi_m006.ref.log b/test/035_#acpi_m006.ref.log index b5b9c35..63f225c 100644 --- a/test/035_#acpi_m006.ref.log +++ b/test/035_#acpi_m006.ref.log @@ -326592,31 +326592,31 @@ aml._.get_node_by_name end 00:00.0 0000:0000 00 1 \_SB_\PCI0\S00_ 00:02.0 1234:1111 00 0 \_SB_\PCI0\S10_ 00:03.0 8086:100E 00 0 \_SB_\PCI0\S18_ - 00:04.0 0000:0000 00 0 \_SB_\PCI0\S20_ - 00:05.0 0000:0000 00 0 \_SB_\PCI0\S28_ - 00:06.0 0000:0000 00 0 \_SB_\PCI0\S30_ - 00:07.0 0000:0000 00 0 \_SB_\PCI0\S38_ - 00:08.0 0000:0000 00 0 \_SB_\PCI0\S40_ - 00:09.0 0000:0000 00 0 \_SB_\PCI0\S48_ - 00:0A.0 0000:0000 00 0 \_SB_\PCI0\S50_ - 00:0B.0 0000:0000 00 0 \_SB_\PCI0\S58_ - 00:0C.0 0000:0000 00 0 \_SB_\PCI0\S60_ - 00:0D.0 0000:0000 00 0 \_SB_\PCI0\S68_ - 00:0E.0 0000:0000 00 0 \_SB_\PCI0\S70_ - 00:0F.0 0000:0000 00 0 \_SB_\PCI0\S78_ - 00:10.0 0000:0000 00 0 \_SB_\PCI0\S80_ - 00:11.0 0000:0000 00 0 \_SB_\PCI0\S88_ - 00:12.0 0000:0000 00 0 \_SB_\PCI0\S90_ - 00:13.0 0000:0000 00 0 \_SB_\PCI0\S98_ - 00:14.0 0000:0000 00 0 \_SB_\PCI0\SA0_ - 00:15.0 0000:0000 00 0 \_SB_\PCI0\SA8_ - 00:16.0 0000:0000 00 0 \_SB_\PCI0\SB0_ - 00:17.0 0000:0000 00 0 \_SB_\PCI0\SB8_ - 00:18.0 0000:0000 00 0 \_SB_\PCI0\SC0_ - 00:19.0 0000:0000 00 0 \_SB_\PCI0\SC8_ - 00:1A.0 0000:0000 00 0 \_SB_\PCI0\SD0_ - 00:1B.0 0000:0000 00 0 \_SB_\PCI0\SD8_ - 00:1C.0 0000:0000 00 0 \_SB_\PCI0\SE0_ - 00:1D.0 0000:0000 00 0 \_SB_\PCI0\SE8_ - 00:1E.0 0000:0000 00 0 \_SB_\PCI0\SF0_ - 00:1F.0 0000:0000 00 0 \_SB_\PCI0\SF8_ + 00:04.0 FFFF:FFFF 00 0 \_SB_\PCI0\S20_ + 00:05.0 FFFF:FFFF 00 0 \_SB_\PCI0\S28_ + 00:06.0 FFFF:FFFF 00 0 \_SB_\PCI0\S30_ + 00:07.0 FFFF:FFFF 00 0 \_SB_\PCI0\S38_ + 00:08.0 FFFF:FFFF 00 0 \_SB_\PCI0\S40_ + 00:09.0 FFFF:FFFF 00 0 \_SB_\PCI0\S48_ + 00:0A.0 FFFF:FFFF 00 0 \_SB_\PCI0\S50_ + 00:0B.0 FFFF:FFFF 00 0 \_SB_\PCI0\S58_ + 00:0C.0 FFFF:FFFF 00 0 \_SB_\PCI0\S60_ + 00:0D.0 FFFF:FFFF 00 0 \_SB_\PCI0\S68_ + 00:0E.0 FFFF:FFFF 00 0 \_SB_\PCI0\S70_ + 00:0F.0 FFFF:FFFF 00 0 \_SB_\PCI0\S78_ + 00:10.0 FFFF:FFFF 00 0 \_SB_\PCI0\S80_ + 00:11.0 FFFF:FFFF 00 0 \_SB_\PCI0\S88_ + 00:12.0 FFFF:FFFF 00 0 \_SB_\PCI0\S90_ + 00:13.0 FFFF:FFFF 00 0 \_SB_\PCI0\S98_ + 00:14.0 FFFF:FFFF 00 0 \_SB_\PCI0\SA0_ + 00:15.0 FFFF:FFFF 00 0 \_SB_\PCI0\SA8_ + 00:16.0 FFFF:FFFF 00 0 \_SB_\PCI0\SB0_ + 00:17.0 FFFF:FFFF 00 0 \_SB_\PCI0\SB8_ + 00:18.0 FFFF:FFFF 00 0 \_SB_\PCI0\SC0_ + 00:19.0 FFFF:FFFF 00 0 \_SB_\PCI0\SC8_ + 00:1A.0 FFFF:FFFF 00 0 \_SB_\PCI0\SD0_ + 00:1B.0 FFFF:FFFF 00 0 \_SB_\PCI0\SD8_ + 00:1C.0 FFFF:FFFF 00 0 \_SB_\PCI0\SE0_ + 00:1D.0 FFFF:FFFF 00 0 \_SB_\PCI0\SE8_ + 00:1E.0 FFFF:FFFF 00 0 \_SB_\PCI0\SF0_ + 00:1F.0 FFFF:FFFF 00 0 \_SB_\PCI0\SF8_ diff --git a/test/036_#acpi_m007.ref.log b/test/036_#acpi_m007.ref.log index 51bc86f..2be4565 100644 --- a/test/036_#acpi_m007.ref.log +++ b/test/036_#acpi_m007.ref.log @@ -51340,29 +51340,29 @@ aml._.get_node_by_name end 00:1E.0 0000:0000 00 1 \_SB_\PCI0\P0P1 00:1F.0 0000:0000 00 1 \_SB_\PCI0\SBRG 00:1F.2 8086:3A22 13 0 \_SB_\PCI0\SATA - 00:1F.5 0000:0000 00 0 \_SB_\PCI0\SAT1 + 00:1F.5 FFFF:FFFF 00 0 \_SB_\PCI0\SAT1 00:1D.0 8086:3A34 17 0 \_SB_\PCI0\USB0 00:1D.1 8086:3A35 13 0 \_SB_\PCI0\USB1 00:1D.2 8086:3A36 12 0 \_SB_\PCI0\USB2 - 00:1D.3 0000:0000 00 0 \_SB_\PCI0\USB5 + 00:1D.3 FFFF:FFFF 00 0 \_SB_\PCI0\USB5 00:1D.7 8086:3A3A 17 0 \_SB_\PCI0\EUSB 00:1A.0 8086:3A37 10 0 \_SB_\PCI0\USB3 00:1A.1 8086:3A38 15 0 \_SB_\PCI0\USB4 00:1A.2 8086:3A39 13 0 \_SB_\PCI0\USB6 00:1A.7 8086:3A3C 12 0 \_SB_\PCI0\USBE 00:1C.0 0000:0000 00 1 \_SB_\PCI0\P0P4 - 00:1C.1 0000:0000 00 0 \_SB_\PCI0\P0P5 - 00:1C.2 0000:0000 00 0 \_SB_\PCI0\P0P6 - 00:1C.3 0000:0000 00 0 \_SB_\PCI0\P0P7 + 00:1C.1 FFFF:FFFF 00 0 \_SB_\PCI0\P0P5 + 00:1C.2 FFFF:FFFF 00 0 \_SB_\PCI0\P0P6 + 00:1C.3 FFFF:FFFF 00 0 \_SB_\PCI0\P0P7 00:1C.4 0000:0000 00 1 \_SB_\PCI0\P0P8 - 00:1C.5 0000:0000 00 0 \_SB_\PCI0\P0P9 - 00:02.0 0000:0000 00 0 \_SB_\PCI0\NPE2 - 00:04.0 0000:0000 00 0 \_SB_\PCI0\NPE4 - 00:05.0 0000:0000 00 0 \_SB_\PCI0\NPE5 - 00:06.0 0000:0000 00 0 \_SB_\PCI0\NPE6 - 00:08.0 0000:0000 00 0 \_SB_\PCI0\NPE8 - 00:09.0 0000:0000 00 0 \_SB_\PCI0\NPE9 - 00:0A.0 0000:0000 00 0 \_SB_\PCI0\NPEA + 00:1C.5 FFFF:FFFF 00 0 \_SB_\PCI0\P0P9 + 00:02.0 FFFF:FFFF 00 0 \_SB_\PCI0\NPE2 + 00:04.0 FFFF:FFFF 00 0 \_SB_\PCI0\NPE4 + 00:05.0 FFFF:FFFF 00 0 \_SB_\PCI0\NPE5 + 00:06.0 FFFF:FFFF 00 0 \_SB_\PCI0\NPE6 + 00:08.0 FFFF:FFFF 00 0 \_SB_\PCI0\NPE8 + 00:09.0 FFFF:FFFF 00 0 \_SB_\PCI0\NPE9 + 00:0A.0 FFFF:FFFF 00 0 \_SB_\PCI0\NPEA 00:01.0 0000:0000 00 1 \_SB_\PCI0\NPE1 00:03.0 0000:0000 00 1 \_SB_\PCI0\NPE3 00:07.0 0000:0000 00 1 \_SB_\PCI0\NPE7 diff --git a/umka.asm b/umka.asm index ff84f14..b1e73aa 100644 --- a/umka.asm +++ b/umka.asm @@ -70,6 +70,7 @@ public eth_input as 'kos_eth_input' public net_buff_alloc as 'kos_net_buff_alloc' public mem_block_list +public pci_root macro cli { pushfd @@ -101,36 +102,6 @@ coverage_begin: include 'macros.inc' -uglobal -align 64 -os_base: rb 0x1000 -window_data: rb 0x2000 -CURRENT_TASK: rb 4 -TASK_COUNT: rb 12 -TASK_BASE rd 4 -TASK_DATA rd 0x7f8 -TASK_EVENT = TASK_DATA -CDDataBuf: rd 0x1840 -idts rd 0x3c0 -WIN_STACK rw 0x200 -WIN_POS rw 0x600 -FDD_BUFF rb 0x2300 -WIN_TEMP_XY rb 0x100 -KEY_COUNT db ? -KEY_BUFF rb 255 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes -BTN_COUNT db ? -BTN_BUFF rd 0x261 -BTN_ADDR dd ? -MEM_AMOUNT rd 0x1d -SYS_SHUTDOWN db ? -sys_proc rd 0x800 -rb 0xe5c2 ; align SLOT_BASE on 0x10000 -SLOT_BASE: rd 0x8000 -VGABasePtr rb 640*480 -;rb 0x582 ; align HEAP_BASE on page boundary -HEAP_BASE rb UMKA_MEMORY_BYTES - (HEAP_BASE-os_base+4096*sizeof.MEM_BLOCK) -endg - macro diff16 msg,blah2,blah3 { if msg eq "end of .data segment" section '.bss' writeable align 64 @@ -747,6 +718,36 @@ public umka_tool umka_tool dd ? fpu_owner dd ? +uglobal +align 64 +os_base: rb 0x1000 +window_data: rb 0x2000 +CURRENT_TASK: rb 4 +TASK_COUNT: rb 12 +TASK_BASE rd 4 +TASK_DATA rd 0x7f8 +TASK_EVENT = TASK_DATA +CDDataBuf: rd 0x1840 +idts rd 0x3c0 +WIN_STACK rw 0x200 +WIN_POS rw 0x600 +FDD_BUFF rb 0x2300 +WIN_TEMP_XY rb 0x100 +KEY_COUNT db ? +KEY_BUFF rb 255 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes +BTN_COUNT db ? +BTN_BUFF rd 0x261 +BTN_ADDR dd ? +MEM_AMOUNT rd 0x1d +SYS_SHUTDOWN db ? +sys_proc rd 0x800 +rb 0xb782 ; align SLOT_BASE on 0x10000 +SLOT_BASE: rd 0x8000 +VGABasePtr rb 640*480 +;rb 0x582 ; align HEAP_BASE on page boundary +HEAP_BASE rb UMKA_MEMORY_BYTES - (HEAP_BASE-os_base+4096*sizeof.MEM_BLOCK) +endg + uglobal v86_irqhooks rd IRQ_RESERVED*2 cache_ide0 IDE_CACHE