2 ; NTS: We use NASM to achieve our goals here because WASM sucks donkey balls
3 ; Maybe when they bother to implement a proper conditional macro system, I'll consider it...
7 global _pci_bios_read_dword_16
8 global _pci_bios_write_dword_16
9 extern _pci_bios_protmode_entry_point ; 32-bit
10 extern _pci_bios_hw_characteristics ; 8-bit
11 extern _pci_bios_last_bus ; 16-bit
12 extern _pci_bios_interface_level ; 16-bit
16 %if TARGET_MSDOS == 32
34 %if TARGET_MSDOS == 16
36 %error You must specify MMODE variable (memory model) for 16-bit real mode code
40 %if TARGET_MSDOS == 16
41 ; large & medium memory models have far pointers for code segments
43 %define MMODE_FAR_CALL
46 %define MMODE_FAR_CALL
50 %define retnative retf
51 %define cdecl_param_offset 6 ; RETF addr + PUSH BP
54 %define cdecl_param_offset 4 ; RET addr + PUSH BP
58 %define cdecl_param_offset 8 ; RET addr + PUSH EBP
61 ; int try_pci_bios2();
65 xor edi,edi ; BUGFIX: Some BIOSes don't set EDI so the "entry point" address we get is whatever Watcom left on the stack.
66 ; This fix resolves the weird erratic values seen when running under Microsoft Virtual PC 2007.
76 @2: cmp edx,0x20494350 ; EDX = 'PCI '?
79 @3: mov dword [_pci_bios_protmode_entry_point],edi
80 mov byte [_pci_bios_hw_characteristics],al
81 mov byte [_pci_bios_interface_level],bl
82 mov byte [_pci_bios_interface_level+1],bh
84 mov word [_pci_bios_last_bus],cx
93 ; int try_pci_bios1();
99 cmp dx,0x4350 ; DX:CX should spell out 'PCI '
110 %if TARGET_MSDOS == 16
111 ; uint32_t __cdecl pci_bios_read_dword_16(uint16_t bx,uint16_t di)
112 _pci_bios_read_dword_16:
119 mov bx,[bp+cdecl_param_offset]
120 mov di,[bp+cdecl_param_offset+2]
123 jc @2r ; CF=1 means failure
125 jz @1r ; AH!=0 means failure
138 ; void __cdecl pci_bios_write_dword_16(uint16_t bx,uint16_t di,uint32_t data);
139 _pci_bios_write_dword_16:
146 mov bx,[bp+cdecl_param_offset]
147 mov di,[bp+cdecl_param_offset+2]
148 mov ecx,[bp+cdecl_param_offset+4]