cdfd2f7e9e1b91c1cfbf300a7f10614618ae6d49
[dosdemo] / src / dos / cdpmi.h
1 #ifndef DPMI_H_
2 #define DPMI_H_
3
4 #ifdef __DJGPP__
5 #include <dpmi.h>
6 #endif
7
8 #include "inttypes.h"
9
10 struct dpmi_regs {
11         uint32_t edi, esi, ebp;
12         uint32_t reserved;
13         uint32_t ebx, edx, ecx, eax;
14         uint16_t flags;
15         uint16_t es, ds, fs, gs;
16         uint16_t ip, cs, sp, ss;
17 };
18
19 uint16_t dpmi_alloc(unsigned int par, uint16_t *sel);
20 void dpmi_free(uint16_t sel);
21 void dpmi_int(int inum, struct dpmi_regs *regs);
22 void *dpmi_mmap(uint32_t phys_addr, unsigned int size);
23 void dpmi_munmap(void *addr);
24
25 #ifdef __WATCOMC__
26 #pragma aux dpmi_alloc = \
27                 "mov ax, 0x100" \
28                 "int 0x31" \
29                 "mov [edi], dx" \
30                 value[ax] \
31                 parm[ebx][edi];
32
33 #pragma aux dpmi_free = \
34                 "mov ax, 0x101" \
35                 "int 0x31" \
36                 parm[dx] \
37                 modify[ax];
38
39 #pragma aux dpmi_int = \
40                 "mov ax, 0x300" \
41                 "xor ecx, ecx" \
42                 "int 0x31" \
43                 parm[ebx][edi] \
44                 modify[ax ecx];
45
46 #pragma aux dpmi_mmap = \
47                 "mov ax, 0x800" \
48                 "mov cx, bx" \
49                 "shr ebx, 16" \
50                 "mov di, si" \
51                 "shr esi, 16" \
52                 "int 0x31" \
53                 "jnc mmap_skip_err" \
54                 "xor bx, bx" \
55                 "xor cx, cx" \
56         "mmap_skip_err:" \
57                 "mov ax, bx" \
58                 "shl eax, 16" \
59                 "mov ax, cx" \
60                 value[eax] \
61                 parm[ebx][esi] \
62                 modify[cx di];
63
64 #pragma aux dpmi_munmap = \
65                 "mov ax, 0x801" \
66                 "mov cx, bx" \
67                 "shr ebx, 16" \
68                 "int 0x31" \
69                 parm[ebx] \
70                 modify[ax];
71 #endif  /* __WATCOMC__ */
72
73 #ifdef __DJGPP__
74 #define dpmi_int(inum, regs) __dpmi_int((inum), (__dpmi_regs*)(regs))
75 #endif
76
77 #endif  /* DPMI_H_ */