Skip to content

Commit 283b976

Browse files
committed
Merge branch 'master' of git@bitbucket.org:neozeed/q2dos.git
2 parents cb61d16 + 57432b0 commit 283b976

21 files changed

Lines changed: 407 additions & 466 deletions

dos/3rdparty/lib/libau.a

954 Bytes
Binary file not shown.

dos/3rdparty/lib_dxe/sndpci.dxe

1.14 KB
Binary file not shown.
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
CC = gcc
2-
# NOTE: -O2, -O3 and -Os are borked
32
CFLAGS = -O1 -Wall
43
CPPFLAGS = -DHAVE_STDINT_H
54
#CPPFLAGS+= -DZDM
65
AR = ar
76
OBJS = au.o ac97_def.o dpmi_c.o mdma.o pcibios.o sc_cmi.o sc_e1371.o sc_ich.o sc_inthd.o sc_sbl24.o sc_sbliv.o sc_sbxfi.o sc_via82.o tim.o
8-
# __udivdi3() is generated for the uint64 division in tim.c.
9-
# use a local x86 asm version from llvm compiler_rt project,
10-
# instead of making the dxe to rely on libgcc symbols..
11-
DXE_OBJS = udivdi3.o
7+
DXE_LIBS = -lgcc
128

139
all: libau.a sndpci.dxe
1410

1511
libau.a: $(OBJS)
1612
$(AR) rs libau.a $(OBJS)
1713

18-
sndpci.dxe: $(OBJS) $(DXE_OBJS)
19-
-dxe3gen -o sndpci.dxe -E _AU_ -U $(OBJS) $(DXE_OBJS)
14+
sndpci.dxe: $(OBJS)
15+
-dxe3gen -o sndpci.dxe -E _AU_ -U $(OBJS) $(DXE_LIBS)
2016

2117
clean:
2218
rm -f *.o
@@ -25,5 +21,3 @@ distclean: clean
2521

2622
%.o : %.c
2723
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
28-
%.o : %.S
29-
$(CC) $(CFLAGS) $(CPPFLAGS) -x assembler-with-cpp -c $< -o $@

dos/3rdparty/libau.src/src/dpmi_c.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ void pds_dpmi_dos_freemem(void)
1111
unsigned short sel = dm->selector;
1212

1313
#ifdef __DJGPP__
14-
__asm__("movw %0,%%dx"::"m"(sel));
15-
__asm__("movw $0x101,%ax");
16-
__asm__("int $0x31");
17-
14+
__asm__("movw %0, %%dx \n"
15+
"movw $0x101,%%ax \n"
16+
"int $0x31 \n"
17+
: : "m"(sel) : "ax","dx"
18+
);
1819
#else /* WATCOM */
1920
_asm {
2021
mov ax,101h
@@ -36,19 +37,21 @@ struct dosmem_t *pds_dpmi_dos_allocmem(unsigned int size)
3637
return NULL;
3738
#endif
3839

39-
__asm__("movl %0,%%ebx"::"m"(size));
40-
__asm__("movw $0x100,%ax \n"
41-
"addl $16,%ebx \n"
42-
"shrl $4,%ebx \n"
40+
__asm__("movl %2,%%ebx \n"
41+
"movw $0x100,%%ax \n"
42+
"addl $16,%%ebx \n"
43+
"shrl $4,%%ebx \n"
4344
"int $0x31 \n"
44-
"jnc go \n"
45-
"xorl %edx,%edx \n"
46-
"go: \n"
47-
"movzx %ax,%eax \n"
48-
"shll $4,%eax");
49-
__asm__("movl %%eax,%0":"=m"(lin));
50-
__asm__("movw %%dx,%0":"=m"(sel));
51-
45+
"jnc 1f \n"
46+
"xorl %%edx,%%edx \n"
47+
"1: \n"
48+
"movzx %%ax,%%eax \n"
49+
"shll $4,%%eax \n"
50+
"movl %%eax,%0 \n"
51+
"movw %%dx, %1 \n"
52+
:"=m"(lin),"=m"(sel)
53+
: "m"(size) : "eax","ebx","edx"
54+
);
5255
#else /*WATCOM*/
5356
_asm {
5457
mov ax,100h

dos/3rdparty/libau.src/src/libaudef.h

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#ifndef LIBAU_DEF_H
22
#define LIBAU_DEF_H
33

4+
#include <stdint.h>
45
#include <stdlib.h>
56
#include <stdio.h>
67
#include <string.h>
7-
#include <io.h>
8-
#include <fcntl.h>
98

109
#include <dos.h>
1110

@@ -32,21 +31,14 @@ struct dosmem_t{
3231
char *linearptr;
3332
};
3433

35-
typedef long long mpxp_int64_t;
36-
typedef unsigned long long mpxp_uint64_t;
37-
typedef long mpxp_int32_t;
38-
typedef unsigned long mpxp_uint32_t;
39-
typedef short mpxp_int16_t;
40-
typedef unsigned short mpxp_uint16_t;
41-
typedef signed char mpxp_int8_t;
42-
typedef unsigned char mpxp_uint8_t;
43-
typedef float mpxp_float_t;
44-
typedef double mpxp_double_t;
45-
typedef char mpxp_char_t;
46-
typedef long mpxp_ptrsize_t;
47-
48-
#define NEWFUNC_ASM
49-
#if defined(NEWFUNC_ASM) && defined(__WATCOMC__)
34+
#ifdef __WATCOMC__
35+
#define outb(reg,val) outp(reg,val)
36+
#define outw(reg,val) outpw(reg,val)
37+
#define outl(reg,val) outpd(reg,val)
38+
#define inb(reg) inp(reg)
39+
#define inw(reg) inpw(reg)
40+
#define inl(reg) inpd(reg)
41+
5042
#define ENTER_CRITICAL IRQ_PUSH_OFF()
5143
void IRQ_PUSH_OFF (void);
5244
#pragma aux IRQ_PUSH_OFF = \
@@ -62,15 +54,6 @@ typedef long mpxp_ptrsize_t;
6254
modify [esp];
6355
#endif
6456

65-
#ifdef __WATCOMC__
66-
#define outb(reg,val) outp(reg,val)
67-
#define outw(reg,val) outpw(reg,val)
68-
#define outl(reg,val) outpd(reg,val)
69-
#define inb(reg) inp(reg)
70-
#define inw(reg) inpw(reg)
71-
#define inl(reg) inpd(reg)
72-
#endif
73-
7457
#ifdef __DJGPP__
7558
#define outb(reg,val) outportb(reg,val)
7659
#define outw(reg,val) outportw(reg,val)
@@ -88,15 +71,15 @@ typedef long mpxp_ptrsize_t;
8871
#endif
8972

9073
// note LE: lowest byte first, highest byte last
91-
#define PDS_GETB_8S(p) *((mpxp_int8_t *)p) // signed 8 bit (1 byte)
92-
#define PDS_GETB_8U(p) *((mpxp_uint8_t *)p) // unsigned 8 bit (1 byte)
93-
#define PDS_GETB_LE16(p) *((mpxp_int16_t *)p) // 2bytes LE to short
94-
#define PDS_GETB_LEU16(p) *((mpxp_uint16_t *)p) // 2bytes LE to unsigned short
95-
#define PDS_GETB_LE32(p) *((mpxp_int32_t *)p) // 4bytes LE to long
74+
#define PDS_GETB_8S(p) *((int8_t *)p) // signed 8 bit (1 byte)
75+
#define PDS_GETB_8U(p) *((uint8_t *)p) // unsigned 8 bit (1 byte)
76+
#define PDS_GETB_LE16(p) *((int16_t *)p) // 2bytes LE to short
77+
#define PDS_GETB_LEU16(p) *((uint16_t *)p) // 2bytes LE to unsigned short
78+
#define PDS_GETB_LE32(p) *((int32_t *)p) // 4bytes LE to long
9679
#define PDS_GETB_LE24(p) ((PDS_GETB_LE32(p))&0x00ffffff)
9780

98-
#define PDS_PUTB_LE16(p,v) *((mpxp_int16_t *)p)=v //
99-
#define PDS_PUTB_LE32(p,v) *((mpxp_int32_t *)p)=v // long to 4bytes LE
81+
#define PDS_PUTB_LE16(p,v) *((int16_t *)p)=v //
82+
#define PDS_PUTB_LE32(p,v) *((int32_t *)p)=v // long to 4bytes LE
10083

10184
#define funcbit_test(var,bit) ((var)&(bit))
10285
#define funcbit_enable(var,bit) ((var)|=(bit))
@@ -118,6 +101,8 @@ typedef long mpxp_ptrsize_t;
118101
#define funcbit_smp_value_increment(var) var++
119102
#define funcbit_smp_value_decrement(var) var--
120103

104+
struct mpxplay_audioout_info_s;
105+
121106
//dpmi.c
122107
extern struct dosmem_t *pds_dpmi_dos_allocmem(unsigned int size);
123108
extern void pds_dpmi_dos_freemem(void);
@@ -132,7 +117,6 @@ extern void pds_dpmi_unmap_physycal_memory(unsigned long linear_address);
132117
#define DMAMODE_AUTOINIT_OFF 0
133118
#define DMAMODE_AUTOINIT_ON 0x10
134119

135-
struct mpxplay_audioout_info_s;
136120
extern unsigned int MDma_get_max_pcmoutbufsize(unsigned int pagesize,unsigned int samplesize);
137121
extern unsigned int MDma_init_pcmoutbuf(struct mpxplay_audioout_info_s *aui,unsigned int maxbufsize,unsigned int pagesize);
138122
extern void MDma_clearbuf(struct mpxplay_audioout_info_s *aui);
@@ -286,8 +270,6 @@ typedef struct aucards_onemixerchan_s{
286270

287271
typedef struct aucards_onemixerchan_s* aucards_allmixerchan_s;
288272

289-
struct mpxplay_audioout_info_s;
290-
291273
typedef struct one_sndcard_info{
292274
const char *shortname;
293275
unsigned long infobits;
@@ -347,7 +329,7 @@ typedef struct mpxplay_audioout_info_s{
347329
}mpxplay_audioout_info_s;
348330

349331
extern void pds_delay_10us(unsigned int ticks);
350-
extern mpxp_uint64_t pds_gettimeu(void); // usec
332+
extern int64_t pds_gettimeu(void); // usec
351333

352334
#ifdef MPXPLAY_USE_DEBUGF
353335
#include <stdarg.h>

dos/3rdparty/libau.src/src/pcibios.c

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//* This file is part of the *
33
//* Mpxplay - audio player. *
44
//* The source code of Mpxplay is *
5-
//* (C) copyright 1998-2008 by PDSoft (Attila Padar) *
5+
//* (C) copyright 1998-2023 by PDSoft (Attila Padar) *
66
//* http://mpxplay.sourceforge.net *
77
//* email: mpxplay@freemail.hu *
88
//**************************************************************************
@@ -17,9 +17,30 @@
1717

1818
#include <string.h>
1919
#include <dos.h>
20+
#ifdef __WATCOMC__
21+
#include <conio.h>
22+
#endif
23+
2024
#include "pcibios.h"
2125

22-
struct pci_config_s libau_pci;
26+
struct pci_config_s libau_pci = { 0,0,0,0,0,NULL,0 };
27+
28+
#define PCIBIOS_DIRECTPORT_RW 1
29+
30+
#if PCIBIOS_DIRECTPORT_RW
31+
#ifdef __WATCOMC__
32+
#define pcibios_outportl(reg,val) outpd(reg,val)
33+
#define pcibios_inportl(reg) inpd(reg)
34+
#endif
35+
#ifdef __DJGPP__
36+
#define pcibios_outportl(reg,val) outportl(reg,val)
37+
#define pcibios_inportl(reg) inportl(reg)
38+
#endif
39+
#define PCI_IOPORT_ADDR 0x0CF8
40+
#define PCI_IOPORT_DATA 0x0CFC
41+
#define PCI_ENABLE_BIT 0x80000000
42+
#define PCI_PORTADDR_VALUE(p, a) (PCI_ENABLE_BIT | ((uint32_t)(p)->bBus << 16) | ((uint32_t)(p)->bDev << 11) | ((uint32_t)(p)->bFunc << 8) | ((uint32_t)(a) & 0xFC))
43+
#endif
2344

2445
#define PCIDEVNUM(bParam) (bParam >> 3)
2546
#define PCIFUNCNUM(bParam) (bParam & 0x07)
@@ -87,8 +108,15 @@ uint8_t pcibios_search_devices(pci_device_s devices[],pci_config_s *ppkey)
87108
return PCI_DEVICE_NOTFOUND;
88109
}
89110

90-
uint8_t pcibios_ReadConfig_Byte(pci_config_s * ppkey, uint16_t wAdr)
111+
uint8_t pcibios_ReadConfig_Byte(pci_config_s *ppkey, uint16_t wAdr)
91112
{
113+
#if PCIBIOS_DIRECTPORT_RW
114+
const int shift = ((wAdr & 3) * 8);
115+
const uint32_t val = PCI_PORTADDR_VALUE(ppkey, wAdr);
116+
pcibios_outportl(PCI_IOPORT_ADDR, val);
117+
return (pcibios_inportl(PCI_IOPORT_DATA) >> shift) & 0xFF;
118+
119+
#else
92120
union REGS reg;
93121

94122
memset(&reg,0,sizeof(reg));
@@ -101,10 +129,22 @@ uint8_t pcibios_ReadConfig_Byte(pci_config_s * ppkey, uint16_t wAdr)
101129
int386(PCI_SERVICE, &reg, &reg);
102130

103131
return reg.h.cl;
132+
#endif
104133
}
105134

106-
uint16_t pcibios_ReadConfig_Word(pci_config_s * ppkey, uint16_t wAdr)
135+
uint16_t pcibios_ReadConfig_Word(pci_config_s *ppkey, uint16_t wAdr)
107136
{
137+
#if PCIBIOS_DIRECTPORT_RW
138+
if ((wAdr & 3) <= 2) {
139+
const int shift = ((wAdr & 3) * 8);
140+
const uint32_t val = PCI_PORTADDR_VALUE(ppkey, wAdr);
141+
pcibios_outportl(PCI_IOPORT_ADDR, val);
142+
return (pcibios_inportl(PCI_IOPORT_DATA) >> shift) & 0xFFFF;
143+
}
144+
145+
return (uint16_t)pcibios_ReadConfig_Byte(ppkey, wAdr) | ((uint16_t)pcibios_ReadConfig_Byte(ppkey, wAdr + 1) << 8);
146+
147+
#else
108148
union REGS reg;
109149

110150
memset(&reg,0,sizeof(reg));
@@ -117,20 +157,39 @@ uint16_t pcibios_ReadConfig_Word(pci_config_s * ppkey, uint16_t wAdr)
117157
int386(PCI_SERVICE, &reg, &reg);
118158

119159
return reg.w.cx;
160+
#endif
120161
}
121162

122-
uint32_t pcibios_ReadConfig_Dword(pci_config_s * ppkey, uint16_t wAdr)
163+
uint32_t pcibios_ReadConfig_Dword(pci_config_s *ppkey, uint16_t wAdr)
123164
{
165+
#if PCIBIOS_DIRECTPORT_RW
166+
if ((wAdr & 3) == 0) {
167+
const uint32_t val = PCI_PORTADDR_VALUE(ppkey, wAdr);
168+
pcibios_outportl(PCI_IOPORT_ADDR, val);
169+
return pcibios_inportl(PCI_IOPORT_DATA);
170+
}
171+
172+
return ((uint32_t)pcibios_ReadConfig_Word(ppkey, (uint8_t)(wAdr + 2)) << 16L) | pcibios_ReadConfig_Word(ppkey, wAdr);
173+
174+
#else
124175
uint32_t dwData;
125176

126177
dwData = (uint32_t)pcibios_ReadConfig_Word(ppkey, wAdr + 2) << 16;
127178
dwData |= (uint32_t)pcibios_ReadConfig_Word(ppkey, wAdr);
128179

129180
return dwData;
181+
#endif
130182
}
131183

132-
void pcibios_WriteConfig_Byte(pci_config_s * ppkey, uint16_t wAdr, uint8_t bData)
184+
void pcibios_WriteConfig_Byte(pci_config_s *ppkey, uint16_t wAdr, uint8_t bData)
133185
{
186+
#if PCIBIOS_DIRECTPORT_RW
187+
const int shift = ((wAdr & 3) * 8);
188+
const uint32_t val = PCI_PORTADDR_VALUE(ppkey, wAdr);
189+
pcibios_outportl(PCI_IOPORT_ADDR, val);
190+
pcibios_outportl(PCI_IOPORT_DATA, (uint32_t)(pcibios_inportl(PCI_IOPORT_DATA) & ~(0xFFU << shift)) | ((uint32_t)bData << shift));
191+
192+
#else
134193
union REGS reg;
135194

136195
memset(&reg,0,sizeof(reg));
@@ -142,10 +201,23 @@ void pcibios_WriteConfig_Byte(pci_config_s * ppkey, uint16_t wAdr, uint8_t bData
142201
reg.w.di = wAdr;
143202

144203
int386(PCI_SERVICE, &reg, &reg);
204+
#endif
145205
}
146206

147-
void pcibios_WriteConfig_Word(pci_config_s * ppkey, uint16_t wAdr, uint16_t wData)
207+
void pcibios_WriteConfig_Word(pci_config_s *ppkey, uint16_t wAdr, uint16_t wData)
148208
{
209+
#if PCIBIOS_DIRECTPORT_RW
210+
if ((wAdr & 3) <= 2) {
211+
const int shift = ((wAdr & 3) * 8);
212+
const uint32_t val = PCI_PORTADDR_VALUE(ppkey, wAdr);
213+
pcibios_outportl(PCI_IOPORT_ADDR, val);
214+
pcibios_outportl(PCI_IOPORT_DATA, (pcibios_inportl(PCI_IOPORT_DATA) & ~(0xFFFFU << shift)) | ((uint32_t)wData << shift));
215+
} else {
216+
pcibios_WriteConfig_Byte(ppkey, wAdr , (uint8_t)(wData & 0xFF));
217+
pcibios_WriteConfig_Byte(ppkey, wAdr + 1, (uint8_t)(wData >> 8));
218+
}
219+
220+
#else
149221
union REGS reg;
150222

151223
memset(&reg,0,sizeof(reg));
@@ -157,12 +229,24 @@ void pcibios_WriteConfig_Word(pci_config_s * ppkey, uint16_t wAdr, uint16_t wDat
157229
reg.w.di = wAdr;
158230

159231
int386(PCI_SERVICE, &reg, &reg);
232+
#endif
160233
}
161234

162-
void pcibios_WriteConfig_Dword(pci_config_s * ppkey, uint16_t wAdr, uint32_t dwData)
235+
void pcibios_WriteConfig_Dword(pci_config_s *ppkey, uint16_t wAdr, uint32_t dwData)
163236
{
164-
pcibios_WriteConfig_Word(ppkey, wAdr, LoW(dwData ));
237+
#if PCIBIOS_DIRECTPORT_RW
238+
if ((wAdr & 3) == 0) {
239+
const uint32_t val = PCI_PORTADDR_VALUE(ppkey, wAdr);
240+
pcibios_outportl(PCI_IOPORT_ADDR, val);
241+
pcibios_outportl(PCI_IOPORT_DATA, dwData);
242+
} else {
243+
pcibios_WriteConfig_Word(ppkey, wAdr , LoW(dwData));
244+
pcibios_WriteConfig_Word(ppkey, wAdr + 2, HiW(dwData));
245+
}
246+
#else
247+
pcibios_WriteConfig_Word(ppkey, wAdr , LoW(dwData));
165248
pcibios_WriteConfig_Word(ppkey, wAdr + 2, HiW(dwData));
249+
#endif
166250
}
167251

168252
void pcibios_set_master(pci_config_s *ppkey)

dos/3rdparty/libau.src/src/pcibios.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
#ifndef pcibios_h
22
#define pcibios_h
33

4-
#if defined(HAVE_STDINT_H) || (defined(__WATCOMC__) && __WATCOMC__ >= 1240) /* OW 1.4 */
5-
64
#include <stdint.h>
75

8-
#else
9-
10-
typedef unsigned char uint8_t;
11-
typedef unsigned short uint16_t;
12-
typedef long int32_t;
13-
typedef unsigned long uint32_t;
14-
15-
#endif
16-
17-
#define HiW(dw) (uint16_t)((uint32_t)dw >> 16)
186
#define LoW(dw) (uint16_t)((uint32_t)dw & 0xFFFF)
7+
#define HiW(dw) (uint16_t)((uint32_t)dw >> 16)
198

209
#define PCI_FUNCTION_ID 0xB1
2110
#define PCI_BIOS_PRESENT 0x01

0 commit comments

Comments
 (0)