1 /*
2  * COPYRIGHT:       GPLv2+ - See COPYING in the top level directory
3  * PROJECT:         ReactOS Virtual DOS Machine
4  * FILE:            subsystems/mvdm/ntvdm/dos/dos32krnl/himem.h
5  * PURPOSE:         DOS XMS Driver and UMB Provider
6  * PROGRAMMERS:     Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7  *                  Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8  */
9 
10 #ifndef _HIMEM_H_
11 #define _HIMEM_H_
12 
13 /* DEFINITIONS ****************************************************************/
14 
15 #define XMS_ADDRESS     0x110000        // Just above HMA
16 #define XMS_BLOCK_SIZE  1024
17 #define XMS_BLOCKS      ((MAX_ADDRESS - XMS_ADDRESS) / XMS_BLOCK_SIZE)
18 #define XMS_MAX_HANDLES 16              // Specification: min 1, max 128, default 32
19 
20 #define XMS_STATUS_SUCCESS              0x00
21 #define XMS_STATUS_NOT_IMPLEMENTED      0x80
22 #define XMS_STATUS_A20_ERROR            0x82
23 #define XMS_STATUS_HMA_DOES_NOT_EXIST   0x90
24 #define XMS_STATUS_HMA_IN_USE           0x91
25 #define XMS_STATUS_HMA_MIN_SIZE         0x92
26 #define XMS_STATUS_HMA_NOT_ALLOCATED    0x93
27 #define XMS_STATUS_A20_STILL_ENABLED    0x94
28 #define XMS_STATUS_OUT_OF_MEMORY        0xA0
29 #define XMS_STATUS_OUT_OF_HANDLES       0xA1
30 #define XMS_STATUS_INVALID_HANDLE       0xA2
31 #define XMS_STATUS_BAD_SRC_HANDLE       0xA3
32 #define XMS_STATUS_BAD_DEST_HANDLE      0xA4
33 #define XMS_STATUS_BAD_SRC_OFFSET       0xA5
34 #define XMS_STATUS_BAD_DEST_OFFSET      0xA6
35 #define XMS_STATUS_NOT_LOCKED           0xAA
36 #define XMS_STATUS_LOCKED               0xAB
37 #define XMS_STATUS_LOCK_OVERFLOW        0xAC
38 #define XMS_STATUS_CANNOT_LOCK          0xAD
39 #define XMS_STATUS_SMALLER_UMB          0xB0
40 #define XMS_STATUS_OUT_OF_UMBS          0xB1
41 #define XMS_STATUS_INVALID_UMB          0xB2
42 
43 typedef struct _XMS_HANDLE
44 {
45     BYTE Handle;
46     BYTE LockCount;
47     WORD Size;
48     DWORD Address;
49 } XMS_HANDLE, *PXMS_HANDLE;
50 
51 #pragma pack(push, 1)
52 typedef struct _XMS_COPY_DATA
53 {
54     DWORD Count;
55     WORD SourceHandle;
56     DWORD SourceOffset;
57     WORD DestHandle;
58     DWORD DestOffset;
59 } XMS_COPY_DATA, *PXMS_COPY_DATA;
60 #pragma pack(pop)
61 
62 /* FUNCTIONS ******************************************************************/
63 
64 BOOLEAN XmsGetDriverEntry(PDWORD Pointer);
65 VOID XmsInitialize(VOID);
66 VOID XmsCleanup(VOID);
67 
68 #endif /* _HIMEM_H_ */
69