From 5d3defa3092b070ec2040ef3032f8a7b587025c6 Mon Sep 17 00:00:00 2001 From: Eric Voirin Date: Wed, 26 Jul 2023 12:08:47 +0200 Subject: [PATCH] Port code to OpenWatcom. --- ISAWAIT.C | 22 ++++++++--------- ISAWAIT.H | 4 ++- MAIN.C | 1 + MAKEFILE | 30 +++++++++-------------- PCI.C | 73 +++++++++++++++++++++++++++++-------------------------- PCI.H | 2 +- README.md | 11 +++------ TYPES.H | 4 +-- 8 files changed, 72 insertions(+), 75 deletions(-) diff --git a/ISAWAIT.C b/ISAWAIT.C index aa0772a..07bb764 100644 --- a/ISAWAIT.C +++ b/ISAWAIT.C @@ -9,14 +9,14 @@ #include "TYPES.H" #include "PCI.H" -typedef struct isawait_dev; +typedef struct isawait_dev_s; -typedef void (*func_info) (struct isawait_dev *dev); -typedef void (*func_ir8) (struct isawait_dev *dev, int value); -typedef void (*func_ir16) (struct isawait_dev *dev, int value); +typedef void (*func_info) (struct isawait_dev_s *dev); +typedef void (*func_ir8) (struct isawait_dev_s *dev, int value); +typedef void (*func_ir16) (struct isawait_dev_s *dev, int value); -typedef struct { +typedef struct isawait_dev_s{ u16 ven; /* PCI Vendor ID of device */ u16 dev; /* PCI Device ID of device */ u8 variant; /* Variant of the device, to handle different regs */ @@ -103,11 +103,11 @@ static void ir16_sis(isawait_dev *dev, int value) { } static isawait_dev isawait_devs[] = { - { 0x8086, 0x122E, 0x00, "Intel PIIX", info_piix, ir8_piix, ir16_piix }, - { 0x8086, 0x7000, 0x00, "Intel PIIX3", info_piix, ir8_piix, ir16_piix }, + { 0x8086, 0x122E, 0x00, "Intel PIIX", info_piix, ir8_piix, ir16_piix }, + { 0x8086, 0x7000, 0x00, "Intel PIIX3", info_piix, ir8_piix, ir16_piix }, { 0x8086, 0x7110, 0x00, "Intel PIIX4(E)", info_piix, ir8_piix, ir16_piix }, - { 0x1039, 0x5113, 0x51, "SiS 5113", info_sis, ir8_sis, ir16_sis }, - { 0x1039, 0x0008, 0x46, "SiS 559x", info_sis, ir8_sis, ir16_sis }, + { 0x1039, 0x5113, 0x51, "SiS 5113", info_sis, ir8_sis, ir16_sis }, + { 0x1039, 0x0008, 0x46, "SiS 559x", info_sis, ir8_sis, ir16_sis }, }; static const int isawait_dev_count = sizeof(isawait_devs) / sizeof(isawait_devs[0]); @@ -133,7 +133,7 @@ static isawait_dev *isawait_get_device(u8 bus, u8 slot) int isawait_set(int iorec8, int iorec16) { u16 bus, slot; u8 found = 0; - ISAWAIT_dev *dev; + isawait_dev *dev; /* Find device */ @@ -186,4 +186,4 @@ int isawait_set(int iorec8, int iorec16) { dev->print_info(dev); return 1; -} \ No newline at end of file +} diff --git a/ISAWAIT.H b/ISAWAIT.H index d6584eb..ef83426 100644 --- a/ISAWAIT.H +++ b/ISAWAIT.H @@ -36,4 +36,6 @@ typedef union { SIS_BITS bits; } SIS; -#endif \ No newline at end of file +int isawait_set(int iorec8, int iorec16); + +#endif diff --git a/MAIN.C b/MAIN.C index 96dd352..f0be426 100644 --- a/MAIN.C +++ b/MAIN.C @@ -10,6 +10,7 @@ */ #include +#include #include #include "TYPES.H" diff --git a/MAKEFILE b/MAKEFILE index deb1830..5f3119d 100644 --- a/MAKEFILE +++ b/MAKEFILE @@ -1,23 +1,17 @@ +CC = wcc +AS = wasm +LD = wlink +CL = wcl -.AUTODEPEND +CFLAGS = -3 -bt=dos +LDFLAGS = SYSTEM DOS -# *Translator Definitions* -MODEL = s +OBJ = main.obj pci.obj isawait.obj -CC = TCC -LINK = tlink -LIBPATH = C:\TC\LIB -LFLAGS= /v/L$(LIBPATH) -INCLUDEPATH = ..\..\INCLUDE;..\INCLUDE +all : ISAWAIT.EXE +ISAWAIT.EXE : $(OBJ) + $(LD) $(LDFLAGS) NAME ISAWAIT.EXE FILE {$(OBJ)} -OUTPUT = ISAWAIT.EXE - -CFILES = MAIN.C \ - PCI.C \ - ISAWAIT.C - -LIBS = c0$(MODEL) $(LIBPATH)\c$(MODEL).LIB - -$(OUTPUT): - $(CC) -e$(OUTPUT) $(CFILES) +.c.obj : .AUTODEPEND + $(CC) $(CFLAGS) -fo=$@ $< \ No newline at end of file diff --git a/PCI.C b/PCI.C index 83a9a45..7f18e9b 100644 --- a/PCI.C +++ b/PCI.C @@ -4,61 +4,66 @@ #include #include +#include #include "TYPES.H" -#ifndef outportl +#if !defined(outportb) && defined(_outp) + #define outportb _outp +#endif + +#if !defined(outportl) + static u32 inportl(u16 port) /* Emulates 32-bit I/O port reads using manual prefixed 32-bit instructions */ { - u16 retl, reth; - asm { - db 0x50 /* push eax */ - push bx - push dx - mov dx, port - db 0x66, 0xED /* in eax, dx */ - mov retl, ax - db 0x66, 0xC1, 0xE8, 0x10 /* shr eax, 16 */ - mov reth, ax - pop dx - pop bx - db 0x58 /* pop eax */ - } - return (u32) retl | ((u32) reth << 16); + u16 retl, reth; + __asm { + db 0x50 /* push eax */ + push bx + push dx + mov dx, port + db 0x66, 0xED /* in eax, dx */ + mov retl, ax + db 0x66, 0xC1, 0xE8, 0x10 /* shr eax, 16 */ + mov reth, ax + pop dx + pop bx + db 0x58 /* pop eax */ + } + return (u32) retl | ((u32) reth << 16); } static void outportl(u16 port, u32 value) /* Emulates 32-Bit I/O port writes using manual prefixed 32-bit instructions. */ { - u16 vall = (u16) value; - u16 valh = (u16) (value >> 16); + u16 vall = (u16) value; + u16 valh = (u16) (value >> 16); - asm { - db 0x50 /* push eax */ - db 0x53 /* push ebx */ - push dx + __asm { + db 0x50 /* push eax */ + db 0x53 /* push ebx */ + push dx - mov ax, valh - db 0x66, 0xC1, 0xE0, 0x10 /* shl eax, 16 */ - mov dx, vall + mov ax, valh + db 0x66, 0xC1, 0xE0, 0x10 /* shl eax, 16 */ + mov dx, vall - db 0x66, 0x0F, 0xB7, 0xDA /* movzx ebx, dx */ - db 0x66, 0x09, 0xD8 /* or eax, ebx */ + db 0x66, 0x0F, 0xB7, 0xDA /* movzx ebx, dx */ + db 0x66, 0x09, 0xD8 /* or eax, ebx */ - mov dx, port - db 0x66, 0xEF /* out dx, eax */ + mov dx, port + db 0x66, 0xEF /* out dx, eax */ - pop dx - db 0x5B /* pop ebx */ - db 0x58 /* pop eax */ - } + pop dx + db 0x5B /* pop ebx */ + db 0x58 /* pop eax */ + } } #endif - u32 pci_read_32(u32 bus, u32 slot, u32 func, u32 offset) /* Reads DWORD from PCI config space. Assumes offset is DWORD-aligned. */ { diff --git a/PCI.H b/PCI.H index bb5deaf..efd7a50 100644 --- a/PCI.H +++ b/PCI.H @@ -24,4 +24,4 @@ int pci_enum_dev(u8 bus, u8 slot); int pci_test(); -#endif \ No newline at end of file +#endif diff --git a/README.md b/README.md index f37d9e9..4520bb0 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,11 @@ Windows 95 / 98. ## Building -I wrote this in and compiled it with **Borland Turbo C++ 3.0** . +- Download and install the OpenWatcom compiler. +- Change to the repository folder +- Type `wmake` -Assumiung that the compiler tool chain is in your `PATH`, compile the program like this: - -`MAKE` - -It is probably buildable with Microsoft C, DJGPP or (Open)Watcom with little to -no effort. +That's it! ### Difficulties when writing ISAWAIT diff --git a/TYPES.H b/TYPES.H index 9be38e8..cb6a912 100644 --- a/TYPES.H +++ b/TYPES.H @@ -12,6 +12,4 @@ typedef signed long i32; /* Application specific types */ - - -#endif \ No newline at end of file +#endif