UnnamedOS
vm86.c File Reference
#include <common.h>
#include <tasks/vm86.h>
#include <tasks/schedule.h>
#include <interrupts/syscall.h>
#include <interrupts/isr.h>
#include <boot/multiboot.h>
#include <mem/gdt.h>
#include <mem/vmm.h>
#include <string.h>
#include <syscall.h>
+ Include dependency graph for vm86.c:

Go to the source code of this file.

Data Structures

struct  vm86_farptr_t
 A real mode far pointer. More...
 

Macros

#define CODE_ADDRESS   ((void*) 0x500)
 Where the assembly code will be located. More...
 
#define IVT_ADDRESS   ((void*) 0)
 The real mode IVT (= Interrupt Vector Table) lies at the start of memory. More...
 
#define OPERAND_SIZE   0x66
 opcode for overriding operand size
 
#define OPCODE_PUSHF   0x9C
 PUSHF triggers a GPF inside VM86 mode.
 
#define OPCODE_POPF   0x9D
 POPF triggers a GPF inside VM86 mode.
 
#define OPCODE_INT_3   0xCC
 INT $3 triggers a GPF inside VM86 mode.
 
#define OPCODE_INT   0xCD
 INT triggers a GPF inside VM86 mode.
 
#define OPCODE_IRET   0xCF
 IRET triggers a GPF inside VM86 mode.
 
#define OPCODE_CLI   0xFA
 CLI triggers a GPF inside VM86 mode.
 
#define OPCODE_STI   0xFB
 STI triggers a GPF inside VM86 mode.
 
#define CASE_IN(opcode, in_func, operand, inc, type)
 Emulates an IN instruction. More...
 
#define CASE_OUT(opcode, out_func, operand, inc)
 Emulates an OUT instruction. More...
 

Functions

static vm86_farptr_t vm86_get_farptr (void *addr)
 Translate an address into a far pointer. More...
 
static void vm86_write_farptr (uint16_t *segment, uint16_t *offset, vm86_farptr_t farptr)
 Writes a far pointer into another location. More...
 
static void * vm86_get_address (vm86_farptr_t farptr)
 Translate a far pointer into an address. More...
 
task_pid_t vm86_create_task (void *code_start, void *code_end, page_directory_t *page_directory, size_t kernel_stack_len, size_t user_stack_len, isr_registers_t *registers)
 Creates a VM86 task. More...
 
void vm86_call_bios (uint8_t interrupt, isr_registers_t *registers)
 Calls a BIOS interrupt. More...
 
static void vm86_push (cpu_state_t *cpu, uint16_t value)
 Emulates a PUSH instruction. More...
 
static uint16_t vm86_pop (cpu_state_t *cpu)
 Emulates a POP instruction. More...
 
static void vm86_increment_eip (cpu_state_t *cpu, size_t inc)
 Emulates the completion of an instruction. More...
 
static uint8_t vm86_monitor (cpu_state_t *cpu)
 Monitors a VM86 task by emulating sensitive instructions. More...
 
static cpu_state_tvm86_handle_gpf (cpu_state_t *cpu)
 Handles general protection faults. More...
 
void vm86_init ()
 Initializes VM86 mode.
 

Variables

static vm86_farptr_tivt = IVT_ADDRESS
 IVT needed to do BIOS calls.
 
const void vm86_call_bios_start
 start of the BIOS call code
 
const void vm86_call_bios_end
 end of the BIOS call code
 
const void vm86_interrupt_hook
 location of INT in the BIOS call code