summaryrefslogtreecommitdiffstats
path: root/usr.bin/doscmd/xms.h
blob: 51890282b24c18821afa3e63ff20d8587b9926b3 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*-
 * Copyright (c) 1997 Helmut Wirth <hfwirth@ping.at>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice immediately at the beginning of the file, witout modification,
 *    this list of conditions, and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD$
 */

#ifndef XMS_H
#define XMS_H

#define XMS_VERSION   0x0300  /* version 3.00 */
#define XMS_REVISION  0x0100  /* driver revision 1.0 */

#define NUM_HANDLES     64	/* number of available handles */
#define FIRST_HANDLE    1	/* number of firts valid handle */
#define PARAGRAPH       16      /* bytes in a paragraph */
#define MAX_BLOCK_LOCKS 256	/* number of locks on a block */
#define DEFAULT_EMM_SIZE 512 * 1024    /* default EMM size */
 
/* Register AH codes for XMS functions */
#define  XMS_GET_VERSION                	0x00
#define  XMS_ALLOCATE_HIGH_MEMORY       	0x01
#define  XMS_FREE_HIGH_MEMORY           	0x02
#define  XMS_GLOBAL_ENABLE_A20          	0x03
#define  XMS_GLOBAL_DISABLE_A20         	0x04
#define  XMS_LOCAL_ENABLE_A20           	0x05
#define  XMS_LOCAL_DISABLE_A20          	0x06
#define  XMS_QUERY_A20                  	0x07
#define  XMS_QUERY_FREE_EXTENDED_MEMORY 	0x08
#define  XMS_ALLOCATE_EXTENDED_MEMORY   	0x09
#define  XMS_FREE_EXTENDED_MEMORY       	0x0a
#define  XMS_MOVE_EXTENDED_MEMORY_BLOCK 	0x0b
#define  XMS_LOCK_EXTENDED_MEMORY_BLOCK 	0x0c
#define  XMS_UNLOCK_EXTENDED_MEMORY_BLOCK 	0x0d
#define  XMS_GET_EMB_HANDLE_INFORMATION 	0x0e
#define  XMS_RESIZE_EXTENDED_MEMORY_BLOCK 	0x0f
#define  XMS_ALLOCATE_UMB               	0x10
#define  XMS_DEALLOCATE_UMB             	0x11
#define  XMS_REALLOCATE_UMB			0x12
/* New functions for values bigger than 65MB, not implented yet */
#define  XMS_QUERY_FREE_EXTENDED_MEMORY_LARGE	0x88
#define  XMS_ALLOCATE_EXTENDED_MEMORY_LARGE   	0x89
#define  XMS_FREE_EXTENDED_MEMORY_LARGE       	0x8a


/* XMS error return codes */
#define XMS_SUCCESS			0x0
#define XMS_NOT_IMPLEMENTED		0x80
#define XMS_VDISK			0x81   /* If vdisk.sys is present */
#define XMS_A20_ERROR			0x82
#define XMS_GENERAL_ERROR		0x8e
#define XMS_HMA_NOT_MANAGED		0x90
#define XMS_HMA_ALREADY_USED		0x91
#define XMS_HMA_NOT_ALLOCATED		0x93
#define XMS_A20_STILL_ENABLED		0x94
#define XMS_FULL			0xa0
#define XMS_OUT_OF_HANDLES		0xa1
#define XMS_INVALID_HANDLE		0xa2
#define XMS_INVALID_SOURCE_HANDLE	0xa3
#define XMS_INVALID_SOURCE_OFFSET	0xa4
#define XMS_INVALID_DESTINATION_HANDLE	0xa5
#define XMS_INVALID_DESTINATION_OFFSET	0xa6
#define XMS_INVALID_LENGTH		0xa7
#define XMS_BLOCK_NOT_LOCKED		0xaa
#define XMS_BLOCK_IS_LOCKED		0xab
#define XMS_BLOCK_LOCKCOUNT_OVERFLOW	0xac
#define XMS_REQUESTED_UMB_TOO_BIG	0xb0
#define XMS_NO_UMBS_AVAILABLE		0xb1
#define XMS_INVALID_UMB_SEGMENT		0xb2


/*
 * EMM structure for data exchange with DOS caller, hence the
 * packed format
 */

struct EMM {
   u_long  nbytes;
   u_short src_handle __attribute__ ((packed));
   u_long  src_offset __attribute__ ((packed));
   u_short dst_handle __attribute__ ((packed));
   u_long  dst_offset __attribute__ ((packed));
} ;

/*
 * XMS info structure, only used to pass information to and from
 * DOS 
 */

struct XMSinfo {
   u_char handle;				/* the handle */
   u_char num_locks __attribute__ ((packed));   /* number of locks */
   u_long size __attribute__ ((packed));	/* size of memory */
   u_long phys_addr __attribute__ ((packed));   /* "physical" address */
};

/*
 * Handle management inside the emulator for extendend memory pages, 
 * invisible to DOS
 */

typedef struct {
   u_long addr;		/* address inside emulator, from malloc() */
   u_long size;		/* size in bytes */
   u_char num_locks;	/* lock count for this handle */
} XMS_handle;

/*
 * Managment of UMB memory paragraphs (16 bytes). UMB blocks are
 * directly accessible by VM86 applications and lie between 0xd0000 and
 * 0xefff0 in VM86 memory space. 
 */

struct _UMB_block {
   u_long addr;			/* Start address of block */
   u_long size;			/* Size in bytes */
   struct _UMB_block *next;   
};

typedef struct _UMB_block UMB_block;

#endif /* XMS_H */
OpenPOWER on IntegriCloud