/* * vm86.h * * Copyright (C) 2016 Aleksandar Andrejevic * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #ifndef _VM86_H_ #define _VM86_H_ #include #include #include #define EFLAGS_VM (1<<17) #define EFLAGS_IF (1<<9) #define EFLAGS_DF (1<<10) #define PREFIX_LOCK (1<<0) #define PREFIX_OPSIZE (1<<1) #define PREFIX_ADDRSIZE (1<<2) #define PREFIX_REP (1<<3) #define PREFIX_REPNZ (1<<4) #define PREFIX_ES (1<<5) #define PREFIX_SS (1<<6) #define PREFIX_FS (1<<7) #define PREFIX_GS (1<<8) #define VM86_MEM_START 0x10000 #define VM86_MEM_END 0x90000 #define VM86_MEM_PARAGRAPHS ((VM86_MEM_END - VM86_MEM_START) >> 4) #define VM86_TRAMPOLINE_CS 0x0000 #define VM86_TRAMPOLINE_IP 0xE000 #define VM86_TRAMPOLINE_SS 0x0000 #define VM86_TRAMPOLINE_SP 0xDFFA typedef struct { dword_t edi, esi, ebp, unused, ebx, edx, ecx, eax; dword_t eip, cs, eflags, esp, ss, es, ds, fs, gs; } vm86_registers_t; word_t vm86_alloc(word_t size); void vm86_free(word_t paragraph); void vm86_handler(registers_ext_vm86_t *regs); dword_t vm86_interrupt(byte_t number, vm86_registers_t *regs); #endif