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