vbeinfo

view src/dpmi.c @ 3:5b0ef094b8fd

backported changes from more recent VBE projects
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 07 Jan 2019 12:07:53 +0200
parents 4b33fa83e381
children
line source
1 #ifdef __WATCOMC__
2 #include "dpmi.h"
4 void dpmi_real_int(int inum, struct dpmi_real_regs *regs)
5 {
6 unsigned char int_num = (unsigned char)inum;
7 __asm {
8 mov eax, 0x300
9 mov edi, regs
10 mov bl, int_num
11 mov bh, 0
12 xor ecx, ecx
13 int 0x31
14 }
15 }
17 void *dpmi_mmap(uint32_t phys_addr, unsigned int size)
18 {
19 uint16_t mem_high, mem_low;
20 uint16_t phys_high = phys_addr >> 16;
21 uint16_t phys_low = phys_addr & 0xffff;
22 uint16_t size_high = size >> 16;
23 uint16_t size_low = size & 0xffff;
24 unsigned int err, res = 0;
26 __asm {
27 mov eax, 0x800
28 mov bx, phys_high
29 mov cx, phys_low
30 mov si, size_high
31 mov di, size_low
32 int 0x31
33 add res, 1
34 mov err, eax
35 mov mem_high, bx
36 mov mem_low, cx
37 }
39 if(res == 2) {
40 return 0;
41 }
42 return (void*)(((uint32_t)mem_high << 16) | ((uint32_t)mem_low));
43 }
45 void dpmi_munmap(void *addr)
46 {
47 uint16_t mem_high = (uint32_t)addr >> 16;
48 uint16_t mem_low = (uint16_t)addr;
50 __asm {
51 mov eax, 0x801
52 mov bx, mem_high
53 mov cx, mem_low
54 int 0x31
55 }
56 }
57 #else
58 int stop_gcc_crying_about_empty_translation_units = 0;
59 #endif /* __WATCOM__ */