rayzor

view src/dpmi.c @ 0:2a5340a6eee4

rayzor first commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 05 Apr 2014 08:46:27 +0300
parents
children
line source
1 #include "dpmi.h"
3 void dpmi_real_int(int inum, struct dpmi_real_regs *regs)
4 {
5 unsigned char int_num = (unsigned char)inum;
6 __asm {
7 mov eax, 0x300
8 mov edi, regs
9 mov bl, int_num
10 mov bh, 0
11 xor ecx, ecx
12 int 0x31
13 }
14 }
16 void *dpmi_mmap(uint32_t phys_addr, unsigned int size)
17 {
18 uint16_t mem_high, mem_low;
19 uint16_t phys_high = phys_addr >> 16;
20 uint16_t phys_low = phys_addr & 0xffff;
21 uint16_t size_high = size >> 16;
22 uint16_t size_low = size & 0xffff;
23 unsigned int err, res = 0;
25 __asm {
26 mov eax, 0x800
27 mov bx, phys_high
28 mov cx, phys_low
29 mov si, size_high
30 mov di, size_low
31 int 0x31
32 add res, 1
33 mov err, eax
34 mov mem_high, bx
35 mov mem_low, cx
36 }
38 if(res == 2) {
39 return 0;
40 }
41 return (void*)(((uint32_t)mem_high << 16) | ((uint32_t)mem_low));
42 }
44 void dpmi_munmap(void *addr)
45 {
46 uint16_t mem_high = (uint32_t)addr >> 16;
47 uint16_t mem_low = (uint16_t)addr;
49 __asm {
50 mov eax, 0x801
51 mov bx, mem_high
52 mov cx, mem_low
53 int 0x31
54 }
55 }