vm86.h

Go to the documentation of this file.
00001 /*
00002  ** vm86.h
00003  ** 
00004  ** Copyright(c)2004 Olivier Dembour
00005  ** 
00006  ** Started on  Fri Dec 24 11:13:57 2004 Olivier Dembour
00007  ** Last update Fri Feb 18 19:29:22 2005 Olivier Dembour
00008  */
00009 
00010 #ifndef   __VM86_H__
00011 #define   __VM86_H__
00012 
00013 /* Eflags */
00014 
00015 #define IF      (1 << 9) /* Interrupt Flag */
00016 #define IOPL    ( (1 << 12) | (1 << 13) )
00017 #define NT      (1 << 14) /* Nested Flag */
00018 #define RF      (1 << 16) /* Resume Flag */
00019 #define VM      (1 << 17) /* Virtual Flag */
00020 #define VIF     (1 << 19) /* Virtual Interrupt Flag */
00021 #define VIP     (1 << 20) /* Virtual Interrupt Pending */
00022 
00023 #define SEGMENT_TO_LINEAR(segment, offset) ((segment << 4) +  (offset))
00024 
00025 #define CLI             0xfa
00026 #define HLT             0xf4
00027 #define INTn            0xcd
00028 #define IRET            0xcf
00029 #define POPF            0x9d
00030 #define PUSHF           0x9c
00031 #define STI             0xfb
00032 #define OPERAND32       0x66
00033 #define ADDRESS32       0x67
00034  
00035 /* This memory must be free for vm86() */
00036 #define MAX_VM86_MEM    (0xffff + (0xffff << 4))
00037 
00038 #ifdef __KERNEL__
00039 
00040 
00041 /* Actually IOPL cannot be changed */
00042 #define VM86_RW_FLAGS   0x1d5 /* Only TF, under and ~(reserved bits 1 3 5) */
00043 #define VM86_RO_FLAGS   0xdff /* IOPL ~IF TF and under */ 
00044 
00045 #define VM86_REG_CPY(dst, src) \
00046 do {\
00047         dst.eip  = src.eip; \
00048         dst.eax  = src.eax; \
00049         dst.ecx  = src.ecx; \
00050         dst.edx  = src.edx; \
00051         dst.ebx  = src.ebx; \
00052         dst.esp  = src.esp; \
00053         dst.ebp  = src.ebp; \
00054         dst.esi  = src.esi; \
00055         dst.edi  = src.edi; \
00056         dst.es = src.es; \
00057         dst.cs = src.cs; \
00058         dst.ss = src.ss; \
00059         dst.ds = src.ds; \
00060         dst.fs = src.fs; \
00061         dst.gs = src.gs; \
00062 } while (0);
00063 
00064 typedef struct  vm86ivt {
00065   uint16_t      offset;
00066   uint16_t      segment;
00067 }               t_vm86ivt;
00068 
00069 int     vm86_enter_virtual(struct s_tcb_full *, struct vm86 *, struct vm86 *);
00070 int     vm86_return(struct s_tcb_full *, int);
00071 int     vm86_handle_trap(struct s_tcb_full *);
00072 
00073 int     vm86_handle_INTn(struct s_tcb_full *, u_int8_t *);
00074 int     vm86_handle_IRET(struct s_tcb_full *);
00075 int     vm86_handle_POPF(struct s_tcb_full *, u_int8_t);
00076 int     vm86_handle_PUSHF(struct s_tcb_full *, u_int8_t);
00077 int     vm86_handle_CLI(struct s_tcb_full *);
00078 int     vm86_handle_STI(struct s_tcb_full *);
00079 
00080 #endif /* __KERNEL__ */
00081 
00082 
00083 #endif /* __VM86_H__ */

Generated on Wed May 24 23:04:16 2006 for LSE/OS by  doxygen 1.4.6