Pull up CVS idents from FreeBSD to match our current version.
[dragonfly.git] / usr.bin / doscmd / ems.h
blobf210b9e9989f26f47aaa02f7f7bd5f31a6b0d9e5
1 /*-
2 * Copyright (c) 1997 Helmut Wirth <hfwirth@ping.at>
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, witout modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * $FreeBSD: src/usr.bin/doscmd/ems.h,v 1.3 1999/08/28 01:00:13 peter Exp $
29 * $DragonFly: src/usr.bin/doscmd/ems.h,v 1.2 2003/06/17 04:29:26 dillon Exp $
32 #ifndef EMS_H
33 #define EMS_H
35 /* Header for ems.c, the EMS emulation */
37 /* Global definitions, some of them will be configurable in the future */
39 #define EMS_NUM_HANDLES 256 /* Includes OS handle 0 */
40 #define EMS_MAXSIZE 10240 /* In kbytes */
41 #define EMS_MAX_PHYS 4 /* Frame is 64kB */
42 #define EMS_FRAME_ADDR 0xe0000
43 #define EMS_VERSION 0x40 /* Version 4.0 */
44 #define EMS_PAGESIZE (16 *1024) /* page size in bytes */
45 #define EMS_SAVEMAGIC 0xAFFE /* magic number */
47 /* These are the LIM EMS 3.0 calls */
48 #define GET_MANAGER_STATUS 0x40
49 #define GET_PAGE_FRAME_SEGMENT 0x41
50 #define GET_PAGE_COUNTS 0x42
51 #define GET_HANDLE_AND_ALLOCATE 0x43
52 #define MAP_UNMAP 0x44
53 #define DEALLOCATE_HANDLE 0x45
54 #define GET_EMM_VERSION 0x46
55 #define SAVE_PAGE_MAP 0x47
56 #define RESTORE_PAGE_MAP 0x48
57 #define RESERVED_1 0x49
58 #define RESERVED_2 0x4a
59 #define GET_HANDLE_COUNT 0x4b
60 #define GET_PAGES_OWNED 0x4c
61 #define GET_PAGES_FOR_ALL 0x4d
63 /* LIM EMS 4.0 calls */
64 /* Global subfunctions for the LIM EMS 4.0 calls */
65 #define GET 0x0
66 #define SET 0x1
67 /* Modes for Map/Unmap and AlterandCall/AlterAndJump */
68 #define PHYS_ADDR 0x0
69 #define SEG_ADDR 0x0
71 /* Page map functions */
72 #define PAGE_MAP 0x4e
73 #define PAGE_MAP_PARTIAL 0x4f
74 /* Page map subfunctions */
75 #define GET_SET 0x2
76 #define GET_SIZE 0x3
78 #define MAP_UNMAP_MULTI_HANDLE 0x50
80 #define REALLOC_PAGES 0x51
82 #define HANDLE_ATTRIBUTES 0x52
83 /* Subfunctions */
84 #define HANDLE_CAPABILITY 0x2
86 #define HANDLE_NAME 0x53
88 #define HANDLE_DIRECTORY 0x54
89 #define HANDLE_SEARCH 0x1
90 #define GET_TOTAL_HANDLES 0x2
92 #define ALTER_PAGEMAP_JUMP 0x55
93 #define ALTER_PAGEMAP_CALL 0x56
94 /* Subfunction for call */
95 #define GET_STACK_SIZE 0x2
97 #define MOVE_MEMORY_REGION 0x57
98 /* Subfunctions */
99 #define MOVE 0x0
100 #define EXCHANGE 0x1
102 #define GET_MAPPABLE_PHYS_ADDR 0x58
103 /* Subfunctions */
104 #define GET_ARRAY 0x0
105 #define GET_ARRAY_ENTRIES 0x1
107 #define GET_HW_CONFIGURATION 0x59
108 /* Subfunctions */
109 #define GET_HW_ARRAY 0x0
110 #define GET_RAW_PAGE_COUNT 0x1
112 #define ALLOCATE_PAGES 0x5a
113 /* Subfunctions */
114 #define ALLOC_STANDARD 0x0
115 #define ALLOC_RAW 0x1
117 #define ALTERNATE_MAP_REGISTER 0x5b
118 /* Subfunctions */
119 #define GET_SAVE_ARRAY_SIZE 0x2
120 #define ALLOCATE_REGISTER_SET 0x3
121 #define DEALLOCATE_REGISTER_SET 0x4
122 #define ALLOCATE_DMA 0x5
123 #define ENABLE_DMA 0x6
124 #define DISABLE_DMA 0x7
125 #define DEALLOCATE_DMA 0x8
127 #define PREPARE_WARMBOOT 0x5c
129 #define OS_FUNCTION_SET 0x5d
130 /* Subfunctions */
131 #define ENABLE 0x0
132 #define DISABLE 0x1
133 #define RETURN_KEY 0x2
135 /* End of call definitions */
137 /* EMS errors */
139 #define EMS_SUCCESS 0x0
140 #define EMS_SW_MALFUNC 0x80
141 #define EMS_HW_MALFUNC 0x81
142 #define EMS_INV_HANDLE 0x83
143 #define EMS_FUNC_NOSUP 0x84
144 #define EMS_OUT_OF_HANDLES 0x85
145 #define EMS_SAVED_MAP 0x86
146 #define EMS_OUT_OF_PHYS 0x87
147 #define EMS_OUT_OF_LOG 0x88
148 #define EMS_ZERO_PAGES 0x89
149 #define EMS_LOGPAGE_TOOBIG 0x8a
150 #define EMS_ILL_PHYS 0x8b
151 #define EMS_NO_ROOM_TO_SAVE 0x8c
152 #define EMS_ALREADY_SAVED 0x8d
153 #define EMS_NO_SAVED_CONTEXT 0x8e
154 #define EMS_INVALID_SUB 0x8f
155 #define EMS_INVALID_ATTR 0x90
156 #define EMS_FEAT_NOSUP 0x91
157 #define EMS_MOVE_OVERLAP1 0x92
158 #define EMS_MOVE_OVERFLOW 0x93
159 #define EMS_PAGEOFFSET 0x95
160 #define EMS_MOVE_OVERLAP2 0x97
161 #define EMS_HNAME_NOT_FOUND 0xa0
162 #define EMS_NAME_EXISTS 0xa1
163 #define EMS_SAVED_CONTEXT_BAD 0xa3
164 #define EMS_FUNCTION_DISABLED 0xa4
167 * EMS handles: The handle contains at its end an array of pointers to
168 * its allocated pages. The array is of size npages. Handle structs are
169 * malloced at runtime.
170 * Page numbering: Every page is 16kB, always. The pages are numbered
171 * from 0 to highest page, depending on total EMS memory. Every handle
172 * has pages allocated and this pages too are numbered from 0 to highest
173 * page allocated. This are *not* the same numbers, because there may be
174 * holes in the allocation.
175 * Page numbers are unsigned short, which will give us 65536 * 16 kB (1GB)
176 * pages to handle at maximum. This should be enough for the next years.
179 typedef struct {
180 short handle[4]; /* Handle for each mapping */
181 u_char pos_mapped[4]; /* Boolean value, 1 if something is mapped */
182 u_char pos_pagenum[4]; /* Page number currently mapped into position */
183 } EMS_mapping_context;
186 /* This union is for copying operations of the handle name only */
187 typedef union {
188 u_char uc_hn[8];
189 u_long ul_hn[2];
190 } Hname;
192 typedef struct {
193 Hname hname;
194 u_long npages;
195 /* The mapping context for save/restore page map */
196 EMS_mapping_context *mcontext;
197 /* The pagenum here is the number in the system page array. The
198 * logical page number connected with this handle is the index into
199 * this array.
201 u_short pagenum[0];
202 /* Will grow here, depending on allocation */
203 } EMS_handle;
206 * The connection between every page in the system and the handles is
207 * maintained by an array of these structs. The array is indexed by the
208 * page numbers.
211 typedef struct {
212 short handle; /* The handle this page belongs to */
213 #define EMS_FREE 0
214 #define EMS_ALLOCED 1
215 #define EMS_MAPPED 2
216 u_short status; /* room for misc information */
217 } EMS_page;
220 * The combined pointer into EMS memory: offs is the offset into an EMS
221 * page, page is the page index inside the region allocated to a handle.
222 * This depends on EMS_PAGESIZE.
223 * This is used for copy and move operations.
226 typedef struct {
227 u_long offs:14;
228 u_long page:18;
229 } EMS_combi;
231 typedef union {
232 u_long ua_addr; /* Conventional address pointer */
233 EMS_combi ua_emsaddr; /* EMS address pointer */
234 } EMS_addr;
236 #define EMS_OFFS(u) u.ua_emsaddr.offs
237 #define EMS_PAGE(u) u.ua_emsaddr.page
238 #define EMS_PTR(u) u.ua_addr
241 * EMS info structure, only used to pass information to and from
242 * DOS
245 typedef struct {
246 u_short handle __attribute__ ((packed)); /* handle */
247 u_short npages __attribute__ ((packed)); /* pages allocated */
248 } EMShandlepage;
251 * EMS map/unmap multiple, only used to pass information to and from
252 * DOS
255 typedef struct {
256 u_short log __attribute__ ((packed)); /* logical page number */
257 u_short phys __attribute__ ((packed)); /* physical page (position) or
258 segment address inside frame */
259 } EMSmapunmap;
262 * EMS handle directory, only used to pass information to and from
263 * DOS
266 typedef struct {
267 u_short log __attribute__ ((packed)); /* logical page number */
268 Hname name __attribute__ ((packed)); /* Handle name */
270 } EMShandledir;
273 * Structure for get/set page map: This structure is used to save and
274 * restore the page map from DOS memory. A program can get the mapping
275 * context and later set (restore) it. To avoid errors we add a magic
276 * number and a checksum.
279 typedef struct {
280 u_short magic; /* Magic number */
281 u_short checksum; /* Checksum over entire structure */
282 EMS_mapping_context ems_saved_context;
283 } EMScontext;
286 * EMS physical address array, only used to pass information to and from
287 * DOS
290 typedef struct {
291 u_short segm __attribute__ ((packed)); /* segment address inside frame */
292 u_short phys __attribute__ ((packed)); /* physical page (position) */
293 } EMSaddrarray;
296 * EMS move memory call structure, only used to pass information to and from
297 * DOS
300 typedef struct {
301 u_long length __attribute__ ((packed)); /* length of region */
302 #define EMS_MOVE_CONV 0
303 #define EMS_MOVE_EMS 1
304 u_char src_type __attribute__ ((packed)); /* source type (0,1) */
305 u_short src_handle __attribute__ ((packed)); /* source handle */
306 u_short src_offset __attribute__ ((packed)); /* source offset */
307 u_short src_seg __attribute__ ((packed)); /* source type */
308 u_char dst_type __attribute__ ((packed)); /* destination type (0,1) */
309 u_short dst_handle __attribute__ ((packed)); /* destination handle */
310 u_short dst_offset __attribute__ ((packed)); /* destination offset */
311 u_short dst_seg __attribute__ ((packed)); /* destination type */
312 } EMSmovemem;
314 #endif /* EMS_H */