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