eobish

annotate src/dos/dpmi.c @ 7:6a350c554e46

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