Skip to content

Commit ed711d7

Browse files
more asm code transfered to assembly files
1 parent 715918e commit ed711d7

File tree

16 files changed

+370
-189
lines changed

16 files changed

+370
-189
lines changed

MPXPLAY/MEMORY.C

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@
1616

1717
#include <stdint.h>
1818
#include <malloc.h>
19-
#include <dpmi.h>
20-
#include <sys/segments.h> /* for _my_ds() */
2119

2220
void *pds_calloc( unsigned int nitems, unsigned int itemsize)
2321
/////////////////////////////////////////////////////////////
2422
{
2523
void *p = calloc( nitems, itemsize + 8 );
26-
/* ensure that DS limit remains 4G */
27-
__dpmi_set_segment_limit(_my_ds(), 0xFFFFFFFF);
2824
return p;
2925
}
3026

MPXPLAY/PCIBIOS.C

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include <stdint.h>
2020
#include <stdbool.h>
2121
#include <go32.h>
22-
#include <dpmi.h>
22+
//#include <dpmi.h>
2323

24+
#include "DJDPMI.H"
2425
#include "NEWFUNC.H"
2526
#include "PCIBIOS.H"
2627

@@ -374,8 +375,9 @@ void pcibios_enable_BM_MM( struct pci_config_s *ppkey)
374375
//////////////////////////////////////////////////////
375376
{
376377
unsigned int cmd;
377-
cmd = pcibios_ReadConfig_Byte(ppkey, PCIR_PCICMD);
378-
cmd &= ~0x01; /* disable io-port mapping */
378+
cmd = pcibios_ReadConfig_Word(ppkey, PCIR_PCICMD);
379+
cmd &= ~0x01; /* disable io-port mapping */
379380
cmd |= 0x02 | 0x04; /* enable memory mapping and busmaster */
380-
pcibios_WriteConfig_Byte(ppkey, PCIR_PCICMD, cmd);
381+
cmd &= ~0x400; /* reset "interrupt disable */
382+
pcibios_WriteConfig_Word(ppkey, PCIR_PCICMD, cmd);
381383
}

MPXPLAY/PHYSMEM.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
#include <stdint.h>
1818
#include <stdio.h>
19-
#include <dpmi.h>
20-
#include <sys/exceptn.h>
19+
//#include <dpmi.h>
2120

21+
#include "DJDPMI.H"
2222
#include "CONFIG.H"
2323
#include "NEWFUNC.H"
2424

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ OBJFILES=\
3333
$(OUTD)/dmairq.o $(OUTD)/pcibios.o $(OUTD)/memory.o $(OUTD)/physmem.o $(OUTD)/time.o\
3434
$(OUTD)/sc_e1371.o $(OUTD)/sc_ich.o $(OUTD)/sc_inthd.o $(OUTD)/sc_via82.o $(OUTD)/sc_sbliv.o $(OUTD)/sc_sbl24.o\
3535
$(OUTD)/stackio.o $(OUTD)/stackisr.o $(OUTD)/int31.o $(OUTD)/rmwrap.o $(OUTD)/mixer.o\
36-
$(OUTD)/hapi.o $(OUTD)/dprintf.o $(OUTD)/vioout.o $(OUTD)/djdpmi.o
36+
$(OUTD)/hapi.o $(OUTD)/dprintf.o $(OUTD)/vioout.o $(OUTD)/djdpmi.o $(OUTD)/uninst.o
3737

3838
INCLUDE_DIRS=src mpxplay
3939
SRC_DIRS=src mpxplay
@@ -103,6 +103,7 @@ $(OUTD)/sndisr.o:: sndisr.c linear.h vopl3.h pic.h platform.h config.h vsb.
103103
$(OUTD)/stackio.o:: stackio.asm
104104
$(OUTD)/stackisr.o:: stackisr.asm
105105
$(OUTD)/time.o:: time.c mpxplay.h au_cards.h newfunc.h
106+
$(OUTD)/uninst.o:: uninst.asm
106107
$(OUTD)/vdma.o:: vdma.c linear.h platform.h ptrap.h vdma.h config.h
107108
$(OUTD)/vioout.o:: vioout.asm
108109
$(OUTD)/virq.o:: virq.c linear.h pic.h platform.h ptrap.h virq.h config.h

src/DJDPMI.ASM

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
;--- reimplement the djgpp __dpmi_xxx() functions that are used.
3+
;--- all functions return -1 on error, 0 on success
34

45
.386
56
.MODEL small, c
@@ -8,7 +9,7 @@
89

910
PREMAPDMA equ 0
1011

11-
if 1 ; optionally, activate if another compiler (watcom?) is to be used
12+
if 1 ; it's optional
1213

1314
MEMINFO struct
1415
dwHdl dd ?
@@ -18,6 +19,40 @@ MEMINFO ends
1819

1920
.code
2021

22+
__dpmi_get_segment_base_address proc c public uses ebx dwSeg:dword, pBase:ptr dword
23+
mov ebx, dwSeg
24+
mov ax, 6
25+
int 31h
26+
sbb eax, eax
27+
jnz @F
28+
mov ebx, pBase
29+
mov word ptr [ebx+0], dx
30+
mov word ptr [ebx+2], cx
31+
@@:
32+
ret
33+
align 4
34+
__dpmi_get_segment_base_address endp
35+
36+
__dpmi_set_segment_limit proc c public uses ebx dwSeg:dword, dwLimit:dword
37+
mov dx, word ptr dwLimit+0
38+
mov cx, word ptr dwLimit+2
39+
mov ebx, dwSeg
40+
mov ax, 8
41+
int 31h
42+
sbb eax, eax
43+
ret
44+
align 4
45+
__dpmi_set_segment_limit endp
46+
47+
__dpmi_free_dos_memory proc c public dwSelector:dword
48+
mov edx, dwSelector
49+
mov ax,101h
50+
int 31h
51+
sbb eax, eax
52+
ret
53+
align 4
54+
__dpmi_free_dos_memory endp
55+
2156
__dpmi_simulate_real_mode_interrupt proc c public uses ebx edi intno:byte, pRegs:ptr
2257
mov edi, pRegs
2358
movzx ebx, intno
@@ -26,6 +61,7 @@ __dpmi_simulate_real_mode_interrupt proc c public uses ebx edi intno:byte, pRegs
2661
int 31h
2762
sbb eax, eax
2863
ret
64+
align 4
2965
__dpmi_simulate_real_mode_interrupt endp
3066

3167
__dpmi_simulate_real_mode_procedure_retf proc c public uses ebx edi pRegs:ptr
@@ -36,6 +72,7 @@ __dpmi_simulate_real_mode_procedure_retf proc c public uses ebx edi pRegs:ptr
3672
int 31h
3773
sbb eax, eax
3874
ret
75+
align 4
3976
__dpmi_simulate_real_mode_procedure_retf endp
4077

4178
__dpmi_simulate_real_mode_procedure_iret proc c public uses ebx edi pRegs:ptr
@@ -46,32 +83,31 @@ __dpmi_simulate_real_mode_procedure_iret proc c public uses ebx edi pRegs:ptr
4683
int 31h
4784
sbb eax, eax
4885
ret
86+
align 4
4987
__dpmi_simulate_real_mode_procedure_iret endp
5088

51-
__dpmi_get_segment_base_address proc c public uses ebx dwSeg:dword, pBase:ptr dword
52-
mov ebx, dwSeg
53-
mov ax, 6
89+
__dpmi_free_real_mode_callback proc c public pRMCB:ptr
90+
mov eax, pRMCB
91+
mov dx, [eax+0]
92+
mov cx, [eax+2]
93+
mov ax, 304h
5494
int 31h
5595
sbb eax, eax
56-
jnz @F
57-
mov ebx, pBase
58-
mov word ptr [ebx+0], dx
59-
mov word ptr [ebx+2], cx
60-
@@:
6196
ret
62-
__dpmi_get_segment_base_address endp
97+
align 4
98+
__dpmi_free_real_mode_callback endp
6399

64-
__dpmi_set_segment_limit proc c public uses ebx dwSeg:dword, dwLimit:dword
65-
mov dx, word ptr dwLimit+0
66-
mov cx, word ptr dwLimit+2
67-
mov ebx, dwSeg
68-
mov ax, 8
100+
if PREMAPDMA
101+
102+
__dpmi_free_memory proc c public uses esi edi dwHandle:dword
103+
mov di, word ptr dwHandle+0
104+
mov si, word ptr dwHandle+2
105+
mov ax, 502h
69106
int 31h
70107
sbb eax, eax
71108
ret
72-
__dpmi_set_segment_limit endp
73-
74-
if PREMAPDMA
109+
align 4
110+
__dpmi_free_memory endp
75111

76112
__dpmi_allocate_linear_memory proc c public uses ebx edi esi pInfo:ptr, commit:dword
77113
mov edi, pInfo
@@ -86,21 +122,11 @@ __dpmi_allocate_linear_memory proc c public uses ebx edi esi pInfo:ptr, commit:d
86122
mov [edi].MEMINFO.dwAddress, ebx
87123
@@:
88124
ret
125+
align 4
89126
__dpmi_allocate_linear_memory endp
90127

91-
__dpmi_free_memory proc c public uses esi edi dwHandle:dword
92-
mov di, word ptr dwHandle+0
93-
mov si, word ptr dwHandle+2
94-
mov ax, 502h
95-
int 31h
96-
sbb eax, eax
97-
ret
98-
__dpmi_free_memory endp
99-
100128
endif
101129

102-
;--- return -1 on error, 0 on success
103-
104130
__dpmi_physical_address_mapping proc c public uses ebx esi edi pInfo:ptr
105131
mov eax, pInfo
106132
mov di, word ptr [eax].MEMINFO.dwSize+0
@@ -116,6 +142,7 @@ __dpmi_physical_address_mapping proc c public uses ebx esi edi pInfo:ptr
116142
mov word ptr [edx].MEMINFO.dwAddress+2, bx
117143
@@:
118144
ret
145+
align 4
119146
__dpmi_physical_address_mapping endp
120147

121148
__dpmi_free_physical_address_mapping proc c public uses ebx pInfo:ptr
@@ -126,22 +153,16 @@ __dpmi_free_physical_address_mapping proc c public uses ebx pInfo:ptr
126153
int 31h
127154
sbb eax, eax ; C=-1, NC=0
128155
ret
156+
align 4
129157
__dpmi_free_physical_address_mapping endp
130158

131-
__dpmi_free_dos_memory proc c public dwSelector:dword
132-
mov edx, dwSelector
133-
mov ax,101h
134-
int 31h
135-
sbb eax, eax
136-
ret
137-
__dpmi_free_dos_memory endp
138-
139159
__dpmi_set_coprocessor_emulation proc c public uses ebx bMode:byte
140160
mov bl, bMode
141161
mov ax, 0e01h
142162
int 31h
143163
sbb eax, eax
144164
ret
165+
align 4
145166
__dpmi_set_coprocessor_emulation endp
146167

147168
endif

src/DJDPMI.H

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
/* C interface for __dpmi_xxx replacement functions implemented by djdpmi.asm */
3+
4+
typedef union {
5+
struct {
6+
unsigned long edi;
7+
unsigned long esi;
8+
unsigned long ebp;
9+
unsigned long res;
10+
unsigned long ebx;
11+
unsigned long edx;
12+
unsigned long ecx;
13+
unsigned long eax;
14+
} d;
15+
struct {
16+
unsigned short di, di_hi;
17+
unsigned short si, si_hi;
18+
unsigned short bp, bp_hi;
19+
unsigned short res, res_hi;
20+
unsigned short bx, bx_hi;
21+
unsigned short dx, dx_hi;
22+
unsigned short cx, cx_hi;
23+
unsigned short ax, ax_hi;
24+
unsigned short flags;
25+
unsigned short es;
26+
unsigned short ds;
27+
unsigned short fs;
28+
unsigned short gs;
29+
unsigned short ip;
30+
unsigned short cs;
31+
unsigned short sp;
32+
unsigned short ss;
33+
} x;
34+
struct {
35+
unsigned char edi[4];
36+
unsigned char esi[4];
37+
unsigned char ebp[4];
38+
unsigned char res[4];
39+
unsigned char bl, bh, ebx_b2, ebx_b3;
40+
unsigned char dl, dh, edx_b2, edx_b3;
41+
unsigned char cl, ch, ecx_b2, ecx_b3;
42+
unsigned char al, ah, eax_b2, eax_b3;
43+
} h;
44+
} __dpmi_regs;
45+
46+
typedef struct {
47+
unsigned long handle;
48+
unsigned long size;
49+
unsigned long address;
50+
} __dpmi_meminfo;
51+
52+
typedef struct {
53+
unsigned short offset16;
54+
unsigned short segment;
55+
} __dpmi_raddr;
56+
57+
int __dpmi_get_segment_base_address(int _selector, unsigned long *_addr);
58+
int __dpmi_set_segment_limit(int _selector, unsigned long _limit);
59+
int __dpmi_free_dos_memory(int _selector);
60+
int __dpmi_simulate_real_mode_interrupt(int _vector, __dpmi_regs *_regs);
61+
int __dpmi_simulate_real_mode_procedure_retf(__dpmi_regs *_regs);
62+
int __dpmi_simulate_real_mode_procedure_iret(__dpmi_regs *_regs);
63+
int __dpmi_free_real_mode_callback(__dpmi_raddr *_addr);
64+
int __dpmi_free_memory(unsigned long _handle);
65+
int __dpmi_allocate_linear_memory(__dpmi_meminfo *_info, int _commit);
66+
int __dpmi_physical_address_mapping(__dpmi_meminfo *_info);
67+
int __dpmi_free_physical_address_mapping(__dpmi_meminfo *_info);
68+
int __dpmi_set_coprocessor_emulation(int _flags);
69+
70+

src/DPRINTF.ASM

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -229,35 +229,20 @@ dbgprintf ENDP
229229

230230
if 0
231231

232-
_GO32_INFO_BLOCK struct
233-
dwSize dd ?
234-
dwPrimaryScreen dd ?
235-
dwSecondaryScreen dd ?
236-
dwTransferBuffer dd ? ; linear_address_of_transfer_buffer;
237-
dwSizeTransferBuf dd ? ; size_of_transfer_buffer; /* >= 4k */
238-
dwPid dd ?
239-
bMasterPICBase db ? ; master_interrupt_controller_base;
240-
bSlavePICBase db ? ; slave_interrupt_controller_base;
241-
wFlat dw ? ; selector_for_linear_memory (0-10FFFF only);
242-
dwStubInfo dd ? ; linear_address_of_stub_info_structure;
243-
dwPSP dd ? ; linear_address_of_original_psp;
244-
wRunMode dw ? ; run_mode;
245-
wRunModeInfo dw ? ; run_mode_info;
246-
_GO32_INFO_BLOCK ends
247-
248-
comm c _go32_info_block:_GO32_INFO_BLOCK
232+
.data
233+
externdef c DSBase:dword
234+
.code
249235

250236
;--- display 32-bit number on screen
251237
;--- low-level.
252238

253239
dbgprintcnt proc c public number:dword, pos:dword
254240

255241
pushad
256-
push ds
257-
mov ds, cs:[_go32_info_block.wFlat]
258242
mov ebx, pos
259243
shl ebx, 1
260244
add ebx, 0B8000h
245+
sub ebx, cs:[DSBase]
261246
mov eax, number
262247
mov edi, 10
263248
@@nextdigit:
@@ -272,7 +257,6 @@ dbgprintcnt proc c public number:dword, pos:dword
272257
sub ebx, 2
273258
and eax, eax
274259
jne @@nextdigit
275-
pop ds
276260
exit:
277261
popad
278262
ret

src/LINEAR.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "LINEAR.H"
1010

11-
int _crt0_startup_flags = _CRT0_FLAG_PRESERVE_FILENAME_CASE | _CRT0_FLAG_KEEP_QUOTES;
11+
int _crt0_startup_flags = _CRT0_FLAG_PRESERVE_FILENAME_CASE | _CRT0_FLAG_KEEP_QUOTES | _CRT0_FLAG_NEARPTR;
1212

1313
uint32_t DSBase = 0;
1414

0 commit comments

Comments
 (0)