~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/kdrive/vesa/vm86.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
Import upstream version 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $RCSId: $
 
3
 *
 
4
 * Copyright � 2000 Keith Packard
 
5
 *
 
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.
 
15
 *
 
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.
 
23
 */
 
24
/* 
 
25
Copyright (c) 2000 by Juliusz Chroboczek
 
26
 
 
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: 
 
33
 
 
34
The above copyright notice and this permission notice shall be included in
 
35
all copies or substantial portions of the Software. 
 
36
 
 
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
 
43
THE SOFTWARE.
 
44
*/
 
45
 
 
46
#ifndef _VM86_H_
 
47
#define _VM86_H_
 
48
 
 
49
#include <stdlib.h>
 
50
#include <errno.h>
 
51
#include <unistd.h>
 
52
#include <fcntl.h>
 
53
#include <sys/mman.h>
 
54
#include <sys/vm86.h>
 
55
#include <sys/io.h>
 
56
 
 
57
#ifdef NOT_IN_X_SERVER
 
58
#include <stdio.h>
 
59
#include <stdarg.h>
 
60
#include <malloc.h>
 
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)
 
65
#else
 
66
#include <X11/X.h>
 
67
#include <X11/Xproto.h>
 
68
#include <X11/Xos.h>
 
69
#include "os.h"
 
70
#endif
 
71
 
 
72
typedef unsigned char   U8;
 
73
typedef unsigned short  U16;
 
74
typedef unsigned int    U32;
 
75
 
 
76
/* The whole addressable memory */
 
77
#define SYSMEM_BASE 0x00000
 
78
#define SYSMEM_SIZE 0x100000
 
79
 
 
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
 
84
 
 
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
 
89
 
 
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)
 
93
 
 
94
#define HOLE1_BASE (MAGICMEM_BASE + MAGICMEM_SIZE)
 
95
#define HOLE1_SIZE (LOMEM_BASE - HOLE1_BASE)
 
96
 
 
97
#define HOLE2_BASE (LOMEM_BASE + LOMEM_SIZE)
 
98
#define HOLE2_SIZE (HIMEM_BASE - HOLE2_BASE)
 
99
 
 
100
/* The BIOS ROM */
 
101
#define ROM_BASE 0xC0000
 
102
#define ROM_SIZE 0x30000
 
103
 
 
104
#define STACK_SIZE 0x1000
 
105
 
 
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)
 
111
 
 
112
typedef struct _Vm86InfoRec {
 
113
    void                *magicMem, *loMem, *hiMem;
 
114
    void                *hole1, *hole2;
 
115
    U32                 brk;
 
116
    struct vm86_struct  vms;
 
117
    U32                 ret_code, stack_base;
 
118
} Vm86InfoRec, *Vm86InfoPtr;
 
119
 
 
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)))
 
129
 
 
130
Vm86InfoPtr
 
131
Vm86Setup(int);
 
132
    
 
133
void
 
134
Vm86Cleanup(Vm86InfoPtr vi);
 
135
 
 
136
int
 
137
Vm86DoInterrupt(Vm86InfoPtr vi, int num);
 
138
 
 
139
int
 
140
Vm86DoPOST(Vm86InfoPtr vi);
 
141
 
 
142
int
 
143
Vm86IsMemory(Vm86InfoPtr vi, U32 i);
 
144
 
 
145
U8
 
146
Vm86Memory(Vm86InfoPtr, U32);
 
147
 
 
148
U16
 
149
Vm86MemoryW(Vm86InfoPtr, U32);
 
150
 
 
151
U32
 
152
Vm86MemoryL(Vm86InfoPtr, U32);
 
153
 
 
154
void
 
155
Vm86WriteMemory(Vm86InfoPtr, U32, U8);
 
156
 
 
157
void
 
158
Vm86WriteMemoryW(Vm86InfoPtr, U32, U16);
 
159
 
 
160
void
 
161
Vm86WriteMemoryL(Vm86InfoPtr, U32, U32);
 
162
 
 
163
int
 
164
Vm86AllocateMemory(Vm86InfoPtr, int);
 
165
 
 
166
int
 
167
Vm86MarkMemory (Vm86InfoPtr vi);
 
168
 
 
169
void
 
170
Vm86ReleaseMemory (Vm86InfoPtr vi, int mark);
 
171
 
 
172
void
 
173
Vm86Debug(Vm86InfoPtr vi);
 
174
 
 
175
#endif /* _VM86_H_ */