Skip to content

Commit

Permalink
Port code to OpenWatcom.
Browse files Browse the repository at this point in the history
  • Loading branch information
oerg866 committed Jul 26, 2023
1 parent 62c703d commit 5d3defa
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 75 deletions.
22 changes: 11 additions & 11 deletions ISAWAIT.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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]);
Expand All @@ -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 */

Expand Down Expand Up @@ -186,4 +186,4 @@ int isawait_set(int iorec8, int iorec16) {
dev->print_info(dev);

return 1;
}
}
4 changes: 3 additions & 1 deletion ISAWAIT.H
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ typedef union {
SIS_BITS bits;
} SIS;

#endif
int isawait_set(int iorec8, int iorec16);

#endif
1 change: 1 addition & 0 deletions MAIN.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include <stdio.h>
#include <stdlib.h>
#include <dos.h>

#include "TYPES.H"
Expand Down
30 changes: 12 additions & 18 deletions MAKEFILE
Original file line number Diff line number Diff line change
@@ -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=$@ $<
73 changes: 39 additions & 34 deletions PCI.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,66 @@

#include <stdio.h>
#include <dos.h>
#include <conio.h>

#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. */
{
Expand Down
2 changes: 1 addition & 1 deletion PCI.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ int pci_enum_dev(u8 bus, u8 slot);

int pci_test();

#endif
#endif
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions TYPES.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ typedef signed long i32;

/* Application specific types */



#endif
#endif

0 comments on commit 5d3defa

Please sign in to comment.