2 * Copyright (c) 1997 Helmut Wirth <hfwirth@ping.at>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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/xms.h,v 1.2 1999/08/28 01:00:27 peter Exp $
34 #define XMS_VERSION 0x0300 /* version 3.00 */
35 #define XMS_REVISION 0x0100 /* driver revision 1.0 */
37 #define NUM_HANDLES 64 /* number of available handles */
38 #define FIRST_HANDLE 1 /* number of firts valid handle */
39 #define PARAGRAPH 16 /* bytes in a paragraph */
40 #define MAX_BLOCK_LOCKS 256 /* number of locks on a block */
41 #define DEFAULT_EMM_SIZE 512 * 1024 /* default EMM size */
43 /* Register AH codes for XMS functions */
44 #define XMS_GET_VERSION 0x00
45 #define XMS_ALLOCATE_HIGH_MEMORY 0x01
46 #define XMS_FREE_HIGH_MEMORY 0x02
47 #define XMS_GLOBAL_ENABLE_A20 0x03
48 #define XMS_GLOBAL_DISABLE_A20 0x04
49 #define XMS_LOCAL_ENABLE_A20 0x05
50 #define XMS_LOCAL_DISABLE_A20 0x06
51 #define XMS_QUERY_A20 0x07
52 #define XMS_QUERY_FREE_EXTENDED_MEMORY 0x08
53 #define XMS_ALLOCATE_EXTENDED_MEMORY 0x09
54 #define XMS_FREE_EXTENDED_MEMORY 0x0a
55 #define XMS_MOVE_EXTENDED_MEMORY_BLOCK 0x0b
56 #define XMS_LOCK_EXTENDED_MEMORY_BLOCK 0x0c
57 #define XMS_UNLOCK_EXTENDED_MEMORY_BLOCK 0x0d
58 #define XMS_GET_EMB_HANDLE_INFORMATION 0x0e
59 #define XMS_RESIZE_EXTENDED_MEMORY_BLOCK 0x0f
60 #define XMS_ALLOCATE_UMB 0x10
61 #define XMS_DEALLOCATE_UMB 0x11
62 #define XMS_REALLOCATE_UMB 0x12
63 /* New functions for values bigger than 65MB, not implented yet */
64 #define XMS_QUERY_FREE_EXTENDED_MEMORY_LARGE 0x88
65 #define XMS_ALLOCATE_EXTENDED_MEMORY_LARGE 0x89
66 #define XMS_FREE_EXTENDED_MEMORY_LARGE 0x8a
69 /* XMS error return codes */
70 #define XMS_SUCCESS 0x0
71 #define XMS_NOT_IMPLEMENTED 0x80
72 #define XMS_VDISK 0x81 /* If vdisk.sys is present */
73 #define XMS_A20_ERROR 0x82
74 #define XMS_GENERAL_ERROR 0x8e
75 #define XMS_HMA_NOT_MANAGED 0x90
76 #define XMS_HMA_ALREADY_USED 0x91
77 #define XMS_HMA_NOT_ALLOCATED 0x93
78 #define XMS_A20_STILL_ENABLED 0x94
80 #define XMS_OUT_OF_HANDLES 0xa1
81 #define XMS_INVALID_HANDLE 0xa2
82 #define XMS_INVALID_SOURCE_HANDLE 0xa3
83 #define XMS_INVALID_SOURCE_OFFSET 0xa4
84 #define XMS_INVALID_DESTINATION_HANDLE 0xa5
85 #define XMS_INVALID_DESTINATION_OFFSET 0xa6
86 #define XMS_INVALID_LENGTH 0xa7
87 #define XMS_BLOCK_NOT_LOCKED 0xaa
88 #define XMS_BLOCK_IS_LOCKED 0xab
89 #define XMS_BLOCK_LOCKCOUNT_OVERFLOW 0xac
90 #define XMS_REQUESTED_UMB_TOO_BIG 0xb0
91 #define XMS_NO_UMBS_AVAILABLE 0xb1
92 #define XMS_INVALID_UMB_SEGMENT 0xb2
96 * EMM structure for data exchange with DOS caller, hence the
102 u_short src_handle __attribute__ ((packed));
103 u_long src_offset __attribute__ ((packed));
104 u_short dst_handle __attribute__ ((packed));
105 u_long dst_offset __attribute__ ((packed));
109 * XMS info structure, only used to pass information to and from
114 u_char handle; /* the handle */
115 u_char num_locks __attribute__ ((packed)); /* number of locks */
116 u_long size __attribute__ ((packed)); /* size of memory */
117 u_long phys_addr __attribute__ ((packed)); /* "physical" address */
121 * Handle management inside the emulator for extendend memory pages,
126 u_long addr; /* address inside emulator, from malloc() */
127 u_long size; /* size in bytes */
128 u_char num_locks; /* lock count for this handle */
132 * Managment of UMB memory paragraphs (16 bytes). UMB blocks are
133 * directly accessible by VM86 applications and lie between 0xd0000 and
134 * 0xefff0 in VM86 memory space.
138 u_long addr; /* Start address of block */
139 u_long size; /* Size in bytes */
140 struct _UMB_block *next;
143 typedef struct _UMB_block UMB_block;