4
* Copyright � 2000 Keith Packard
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation, and that the name of Keith Packard not be used in
11
* advertising or publicity pertaining to distribution of the software without
12
* specific, written prior permission. Keith Packard makes no
13
* representations about the suitability of this software for any purpose. It
14
* is provided "as is" without express or implied warranty.
16
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
* PERFORMANCE OF THIS SOFTWARE.
25
Copyright (c) 2000 by Juliusz Chroboczek
27
Permission is hereby granted, free of charge, to any person obtaining a copy
28
of this software and associated documentation files (the "Software"), to deal
29
in the Software without restriction, including without limitation the rights
30
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
copies of the Software, and to permit persons to whom the Software is
32
furnished to do so, subject to the following conditions:
34
The above copyright notice and this permission notice shall be included in
35
all copies or substantial portions of the Software.
37
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
57
#ifdef NOT_IN_X_SERVER
61
static void ErrorF(char*, ...);
62
#define xalloc(a) malloc(a)
63
#define xcalloc(a,b) calloc(a,b)
64
#define xfree(a) free(a)
67
#include <X11/Xproto.h>
72
typedef unsigned char U8;
73
typedef unsigned short U16;
74
typedef unsigned int U32;
76
/* The whole addressable memory */
77
#define SYSMEM_BASE 0x00000
78
#define SYSMEM_SIZE 0x100000
80
/* Interrupt vectors and BIOS data area */
81
/* This is allocated privately from /dev/mem */
82
#define MAGICMEM_BASE 0x00000
83
#define MAGICMEM_SIZE 0x01000
85
/* The low memory, allocated privately from /dev/zero */
86
/* 64KB should be enough for anyone, as they used to say */
87
#define LOMEM_BASE 0x10000
88
#define LOMEM_SIZE 0x10000
90
/* The video memory and BIOS ROM, allocated shared from /dev/mem */
91
#define HIMEM_BASE 0xA0000
92
#define HIMEM_SIZE (SYSMEM_BASE + SYSMEM_SIZE - HIMEM_BASE)
94
#define HOLE1_BASE (MAGICMEM_BASE + MAGICMEM_SIZE)
95
#define HOLE1_SIZE (LOMEM_BASE - HOLE1_BASE)
97
#define HOLE2_BASE (LOMEM_BASE + LOMEM_SIZE)
98
#define HOLE2_SIZE (HIMEM_BASE - HOLE2_BASE)
101
#define ROM_BASE 0xC0000
102
#define ROM_SIZE 0x30000
104
#define STACK_SIZE 0x1000
106
#define POINTER_SEGMENT(ptr) (((unsigned int)ptr)>>4)
107
#define POINTER_OFFSET(ptr) (((unsigned int)ptr)&0x000F)
108
#define MAKE_POINTER(seg, off) (((((unsigned int)(seg))<<4) + (unsigned int)(off)))
109
#define MAKE_POINTER_1(lw) MAKE_POINTER(((lw)&0xFFFF0000)/0x10000, (lw)&0xFFFF)
110
#define ALLOC_FAIL ((U32)-1)
112
typedef struct _Vm86InfoRec {
113
void *magicMem, *loMem, *hiMem;
116
struct vm86_struct vms;
117
U32 ret_code, stack_base;
118
} Vm86InfoRec, *Vm86InfoPtr;
120
#define LM(vi,i) (((char*)vi->loMem)[i-LOMEM_BASE])
121
#define LMW(vi,i) (*(U16*)(&LM(vi,i)))
122
#define LML(vi,i) (*(U32*)(&LM(vi,i)))
123
#define MM(vi,i) (((char*)vi->magicMem)[i-MAGICMEM_BASE])
124
#define MMW(vi,i) (*(U16*)(&MM(vi,i)))
125
#define MML(vi,i) (*(U32*)(&MM(vi,i)))
126
#define HM(vi,i) (((char*)vi->hiMem)[i-HIMEM_BASE])
127
#define HMW(vi,i) (*(U16*)(&MM(vi,i)))
128
#define HML(vi,i) (*(U32*)(&MM(vi,i)))
134
Vm86Cleanup(Vm86InfoPtr vi);
137
Vm86DoInterrupt(Vm86InfoPtr vi, int num);
140
Vm86DoPOST(Vm86InfoPtr vi);
143
Vm86IsMemory(Vm86InfoPtr vi, U32 i);
146
Vm86Memory(Vm86InfoPtr, U32);
149
Vm86MemoryW(Vm86InfoPtr, U32);
152
Vm86MemoryL(Vm86InfoPtr, U32);
155
Vm86WriteMemory(Vm86InfoPtr, U32, U8);
158
Vm86WriteMemoryW(Vm86InfoPtr, U32, U16);
161
Vm86WriteMemoryL(Vm86InfoPtr, U32, U32);
164
Vm86AllocateMemory(Vm86InfoPtr, int);
167
Vm86MarkMemory (Vm86InfoPtr vi);
170
Vm86ReleaseMemory (Vm86InfoPtr vi, int mark);
173
Vm86Debug(Vm86InfoPtr vi);
175
#endif /* _VM86_H_ */