1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
Linux Real Mode Interface - A library of DPMI-like functions for Linux.
Copyright (C) 1998 by Josh Vanderhoof
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#define I_S_DEFAULT_INT_VECT 0xFF065
#define SYS_SIZE 0x100000
#define SYS_BIOS 0xF0000
#define BIOS_SIZE 0x10000
#define LOW_PAGE_SIZE 0x600
#define V_RAM 0xA0000
#define VRAM_SIZE 0x20000
#define V_BIOS_SIZE 0x10000
#define V_BIOS 0xC0000
#define BIOS_SCRATCH_OFF 0x449
#define BIOS_SCRATCH_END 0x466
#define BIOS_SCRATCH_LEN (BIOS_SCRATCH_END - BIOS_SCRATCH_OFF + 1)
#define HIGH_MEM V_BIOS
#define HIGH_MEM_SIZE (SYS_BIOS - HIGH_MEM)
#define SEG_ADR(type, seg, reg) type((seg << 4) + (X86_##reg))
#define SEG_EADR(type, seg, reg) type((seg << 4) + (X86_E##reg))
/* TODO: private? */
#define X86_TF_MASK 0x00000100
#define X86_IF_MASK 0x00000200
#define X86_IOPL_MASK 0x00003000
#define X86_NT_MASK 0x00004000
#define X86_VM_MASK 0x00020000
#define X86_AC_MASK 0x00040000
#define X86_VIF_MASK 0x00080000 /* virtual interrupt flag */
#define X86_VIP_MASK 0x00100000 /* virtual interrupt pending */
#define X86_ID_MASK 0x00200000
/* TODO: private? */
#define MEM_RB(name, addr) (*name->mem->rb)(name, addr)
#define MEM_RW(name, addr) (*name->mem->rw)(name, addr)
#define MEM_RL(name, addr) (*name->mem->rl)(name, addr)
#define MEM_WB(name, addr, val) (*name->mem->wb)(name, addr, val)
#define MEM_WW(name, addr, val) (*name->mem->ww)(name, addr, val)
#define MEM_WL(name, addr, val) (*name->mem->wl)(name, addr, val)
/* int10 info structure */
typedef struct {
int entityIndex;
int scrnIndex;
void *cpuRegs;
unsigned short BIOSseg;
unsigned short inb40time;
char * BIOSScratch;
int Flags;
void *private;
struct _int10Mem* mem;
int num;
int ax;
int bx;
int cx;
int dx;
int si;
int di;
int es;
int bp;
int flags;
int stackseg;
struct pci_device *dev;
unsigned long ioBase;
} xf86Int10InfoRec, *xf86Int10InfoPtr;
typedef struct _int10Mem {
unsigned char(*rb)(xf86Int10InfoPtr, int);
unsigned short(*rw)(xf86Int10InfoPtr, int);
unsigned long(*rl)(xf86Int10InfoPtr, int);
void(*wb)(xf86Int10InfoPtr, int, unsigned char);
void(*ww)(xf86Int10InfoPtr, int, unsigned short);
void(*wl)(xf86Int10InfoPtr, int, unsigned long);
} int10MemRec, *int10MemPtr;
void LRMI_init(xf86Int10InfoPtr pInt);
void LRMI_setup(xf86Int10InfoPtr pInt);
void LRMI_fini(xf86Int10InfoPtr pInt);
/* Get the base address of the real memory address space block. */
void *LRMI_base_addr(xf86Int10InfoPtr pInt, unsigned long addr);
void LRMI_set_exit_condition(xf86Int10InfoPtr pInt);
/* Simulate a 16 bit interrupt */
void LRMI_int(xf86Int10InfoPtr pInt);
/* Allocate real mode memory. The returned block is paragraph (16 byte)
aligned */
//void *LRMI_alloc_real(int size);
void *LRMI_alloc_real(xf86Int10InfoPtr pInt, int num, int *off);
/* Free real mode memory */
//void LRMI_free_real(void *m);
void LRMI_free_real(xf86Int10InfoPtr pInt, void *pbase, int num);
|