dos3d

annotate src/dpmi.c @ 21:00d84ab1ef26

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