dos3d

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/dpmi.c	Sat Sep 21 18:17:55 2013 +0300
     1.3 @@ -0,0 +1,55 @@
     1.4 +#include "dpmi.h"
     1.5 +
     1.6 +void dpmi_real_int(int inum, struct dpmi_real_regs *regs)
     1.7 +{
     1.8 +	unsigned char int_num = (unsigned char)inum;
     1.9 +	__asm {
    1.10 +		mov eax, 0x300
    1.11 +		mov edi, regs
    1.12 +		mov bl, int_num
    1.13 +		mov bh, 0
    1.14 +		xor ecx, ecx
    1.15 +		int 0x31
    1.16 +	}
    1.17 +}
    1.18 +
    1.19 +void *dpmi_mmap(uint32_t phys_addr, unsigned int size)
    1.20 +{
    1.21 +	uint16_t mem_high, mem_low;
    1.22 +	uint16_t phys_high = phys_addr >> 16;
    1.23 +	uint16_t phys_low = phys_addr & 0xffff;
    1.24 +	uint16_t size_high = size >> 16;
    1.25 +	uint16_t size_low = size & 0xffff;
    1.26 +	unsigned int err, res = 0;
    1.27 +
    1.28 +	__asm {
    1.29 +		mov eax, 0x800
    1.30 +		mov bx, phys_high
    1.31 +		mov cx, phys_low
    1.32 +		mov si, size_high
    1.33 +		mov di, size_low
    1.34 +		int 0x31
    1.35 +		add res, 1
    1.36 +		mov err, eax
    1.37 +		mov mem_high, bx
    1.38 +		mov mem_low, cx
    1.39 +	}
    1.40 +
    1.41 +	if(res == 2) {
    1.42 +		return 0;
    1.43 +	}
    1.44 +	return (void*)(((uint32_t)mem_high << 16) | ((uint32_t)mem_low));
    1.45 +}
    1.46 +
    1.47 +void dpmi_munmap(void *addr)
    1.48 +{
    1.49 +	uint16_t mem_high = (uint32_t)addr >> 16;
    1.50 +	uint16_t mem_low = (uint16_t)addr;
    1.51 +
    1.52 +	__asm {
    1.53 +		mov eax, 0x801
    1.54 +		mov bx, mem_high
    1.55 +		mov cx, mem_low
    1.56 +		int 0x31
    1.57 +	}
    1.58 +}