ReactOS 0.4.15-dev-8146-gdc0ed6d
emsdrv.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _EMS_HANDLE
 
struct  _EMS_PAGE
 
struct  _EMS_HANDLE_PAGE_INFO
 
struct  _EMS_HANDLE_DIR_ENTRY
 
struct  _EMS_COPY_DATA
 
struct  _EMS_MAPPABLE_PHYS_PAGE
 
struct  _EMS_HARDWARE_INFO
 

Macros

#define EMS_VERSION_NUM   0x40
 
#define EMS_INTERRUPT_NUM   0x67
 
#define EMS_SEGMENT   0xD000
 
#define EMS_MAX_HANDLES   255
 
#define EMS_PAGE_BITS   14
 
#define EMS_PAGE_SIZE   (1 << EMS_PAGE_BITS)
 
#define EMS_PHYSICAL_PAGES   4
 
#define EMS_TOTAL_PAGES   1024
 
#define EMS_STATUS_SUCCESS   0x00
 
#define EMS_STATUS_INTERNAL_ERROR   0x80
 
#define EMS_STATUS_INVALID_HANDLE   0x83
 
#define EMS_STATUS_UNKNOWN_FUNCTION   0x84
 
#define EMS_STATUS_NO_MORE_HANDLES   0x85
 
#define EMS_STATUS_INSUFFICIENT_PAGES   0x88
 
#define EMS_STATUS_ZERO_PAGES   0x89
 
#define EMS_STATUS_INV_LOGICAL_PAGE   0x8A
 
#define EMS_STATUS_INV_PHYSICAL_PAGE   0x8B
 
#define EMS_STATUS_INVALID_SUBFUNCTION   0x8F
 
#define EMS_STATUS_HANDLE_NOT_FOUND   0xA0
 
#define EMS_STATUS_UNNAMED_HANDLE   0xA1
 
#define EMS_STATUS_HANDLE_ALREADY_EXISTS   0xA1
 

Typedefs

typedef struct _EMS_HANDLE EMS_HANDLE
 
typedef struct _EMS_HANDLEPEMS_HANDLE
 
typedef struct _EMS_PAGE EMS_PAGE
 
typedef struct _EMS_PAGEPEMS_PAGE
 
typedef struct _EMS_HANDLE_PAGE_INFO EMS_HANDLE_PAGE_INFO
 
typedef struct _EMS_HANDLE_PAGE_INFOPEMS_HANDLE_PAGE_INFO
 
typedef struct _EMS_HANDLE_DIR_ENTRY EMS_HANDLE_DIR_ENTRY
 
typedef struct _EMS_HANDLE_DIR_ENTRYPEMS_HANDLE_DIR_ENTRY
 
typedef struct _EMS_COPY_DATA EMS_COPY_DATA
 
typedef struct _EMS_COPY_DATAPEMS_COPY_DATA
 
typedef struct _EMS_MAPPABLE_PHYS_PAGE EMS_MAPPABLE_PHYS_PAGE
 
typedef struct _EMS_MAPPABLE_PHYS_PAGEPEMS_MAPPABLE_PHYS_PAGE
 
typedef struct _EMS_HARDWARE_INFO EMS_HARDWARE_INFO
 
typedef struct _EMS_HARDWARE_INFOPEMS_HARDWARE_INFO
 

Functions

BOOLEAN EmsDrvInitialize (USHORT Segment, ULONG TotalPages)
 
VOID EmsDrvCleanup (VOID)
 

Macro Definition Documentation

◆ EMS_INTERRUPT_NUM

#define EMS_INTERRUPT_NUM   0x67

Definition at line 15 of file emsdrv.h.

◆ EMS_MAX_HANDLES

#define EMS_MAX_HANDLES   255

Definition at line 18 of file emsdrv.h.

◆ EMS_PAGE_BITS

#define EMS_PAGE_BITS   14

Definition at line 19 of file emsdrv.h.

◆ EMS_PAGE_SIZE

#define EMS_PAGE_SIZE   (1 << EMS_PAGE_BITS)

Definition at line 20 of file emsdrv.h.

◆ EMS_PHYSICAL_PAGES

#define EMS_PHYSICAL_PAGES   4

Definition at line 21 of file emsdrv.h.

◆ EMS_SEGMENT

#define EMS_SEGMENT   0xD000

Definition at line 16 of file emsdrv.h.

◆ EMS_STATUS_HANDLE_ALREADY_EXISTS

#define EMS_STATUS_HANDLE_ALREADY_EXISTS   0xA1

Definition at line 38 of file emsdrv.h.

◆ EMS_STATUS_HANDLE_NOT_FOUND

#define EMS_STATUS_HANDLE_NOT_FOUND   0xA0

Definition at line 36 of file emsdrv.h.

◆ EMS_STATUS_INSUFFICIENT_PAGES

#define EMS_STATUS_INSUFFICIENT_PAGES   0x88

Definition at line 31 of file emsdrv.h.

◆ EMS_STATUS_INTERNAL_ERROR

#define EMS_STATUS_INTERNAL_ERROR   0x80

Definition at line 27 of file emsdrv.h.

◆ EMS_STATUS_INV_LOGICAL_PAGE

#define EMS_STATUS_INV_LOGICAL_PAGE   0x8A

Definition at line 33 of file emsdrv.h.

◆ EMS_STATUS_INV_PHYSICAL_PAGE

#define EMS_STATUS_INV_PHYSICAL_PAGE   0x8B

Definition at line 34 of file emsdrv.h.

◆ EMS_STATUS_INVALID_HANDLE

#define EMS_STATUS_INVALID_HANDLE   0x83

Definition at line 28 of file emsdrv.h.

◆ EMS_STATUS_INVALID_SUBFUNCTION

#define EMS_STATUS_INVALID_SUBFUNCTION   0x8F

Definition at line 35 of file emsdrv.h.

◆ EMS_STATUS_NO_MORE_HANDLES

#define EMS_STATUS_NO_MORE_HANDLES   0x85

Definition at line 30 of file emsdrv.h.

◆ EMS_STATUS_SUCCESS

#define EMS_STATUS_SUCCESS   0x00

Definition at line 26 of file emsdrv.h.

◆ EMS_STATUS_UNKNOWN_FUNCTION

#define EMS_STATUS_UNKNOWN_FUNCTION   0x84

Definition at line 29 of file emsdrv.h.

◆ EMS_STATUS_UNNAMED_HANDLE

#define EMS_STATUS_UNNAMED_HANDLE   0xA1

Definition at line 37 of file emsdrv.h.

◆ EMS_STATUS_ZERO_PAGES

#define EMS_STATUS_ZERO_PAGES   0x89

Definition at line 32 of file emsdrv.h.

◆ EMS_TOTAL_PAGES

#define EMS_TOTAL_PAGES   1024

Definition at line 24 of file emsdrv.h.

◆ EMS_VERSION_NUM

#define EMS_VERSION_NUM   0x40

Definition at line 14 of file emsdrv.h.

Typedef Documentation

◆ EMS_COPY_DATA

◆ EMS_HANDLE

◆ EMS_HANDLE_DIR_ENTRY

◆ EMS_HANDLE_PAGE_INFO

◆ EMS_HARDWARE_INFO

◆ EMS_MAPPABLE_PHYS_PAGE

◆ EMS_PAGE

◆ PEMS_COPY_DATA

◆ PEMS_HANDLE

◆ PEMS_HANDLE_DIR_ENTRY

◆ PEMS_HANDLE_PAGE_INFO

◆ PEMS_HARDWARE_INFO

◆ PEMS_MAPPABLE_PHYS_PAGE

◆ PEMS_PAGE

Function Documentation

◆ EmsDrvCleanup()

VOID EmsDrvCleanup ( VOID  )

Definition at line 850 of file emsdrv.c.

851{
852 /* Delete the device */
854
857
858 if (EmsMemory)
859 {
860 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsMemory);
861 EmsMemory = NULL;
862 }
863
864 if (EmsPageTable)
865 {
866 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsPageTable);
868 }
869
870 if (EmsBitmapBuffer)
871 {
872 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
874 }
875
877}
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define UlongToPtr(u)
Definition: config.h:106
static PEMS_PAGE EmsPageTable
Definition: emsdrv.c:39
static PULONG EmsBitmapBuffer
Definition: emsdrv.c:38
static USHORT EmsSegment
Definition: emsdrv.c:45
static PVOID EmsMemory
Definition: emsdrv.c:44
#define EMS_PAGE_SIZE
Definition: emsdrv.h:20
#define EMS_PHYSICAL_PAGES
Definition: emsdrv.h:21
#define TO_LINEAR(seg, off)
Definition: emulator.h:26
VOID DosDeleteDevice(PDOS_DEVICE_NODE DeviceNode)
Definition: device.c:419
BOOL MemRemoveFastMemoryHook(PVOID Address, ULONG Size)
Definition: memory.c:353
BOOLEAN UmaDescRelease(IN USHORT Segment)
Definition: umamgr.c:207
Definition: dlist.c:348

◆ EmsDrvInitialize()

BOOLEAN EmsDrvInitialize ( USHORT  Segment,
ULONG  TotalPages 
)

Definition at line 767 of file emsdrv.c.

768{
769 USHORT Size;
770
771 /* Try to allocate our page table in UMA at the given segment */
773 Size = EMS_SEGMENT_SIZE; // Size in paragraphs
774 if (!UmaDescReserve(&EmsSegment, &Size)) return FALSE;
775
776 EmsTotalPages = TotalPages;
777 EmsBitmapBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
779 ((TotalPages + 31) / 32) * sizeof(ULONG));
780 if (EmsBitmapBuffer == NULL)
781 {
783 return FALSE;
784 }
785
787
788 EmsPageTable = (PEMS_PAGE)RtlAllocateHeap(RtlGetProcessHeap(),
790 TotalPages * sizeof(EMS_PAGE));
791 if (EmsPageTable == NULL)
792 {
793 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
795
797 return FALSE;
798 }
799
800 EmsMemory = (PVOID)RtlAllocateHeap(RtlGetProcessHeap(), 0, TotalPages * EMS_PAGE_SIZE);
801 if (EmsMemory == NULL)
802 {
803 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsPageTable);
805 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
807
809 return FALSE;
810 }
811
813 /*
814 * FIXME: We should ensure that the system handle is associated
815 * with mapped pages from conventional memory. DosEmu seems to do
816 * it correctly. 384kB of memory mapped.
817 */
819 {
820 DPRINT1("Impossible to allocate pages for the system handle!\n");
821
822 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsMemory);
823 EmsMemory = NULL;
824 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsPageTable);
826 RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
828
830 return FALSE;
831 }
832
837
838 /* Create the device */
842 Node->IoctlReadRoutine = EmsDrvDispatchIoctlRead;
843
846
847 return TRUE;
848}
#define DPRINT1
Definition: precomp.h:8
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static WORD NTAPI EmsDrvDispatchIoctlRead(PDOS_DEVICE_NODE Device, DWORD Buffer, PWORD Length)
Definition: emsdrv.c:758
static VOID WINAPI EmsIntHandler(LPWORD Stack)
Definition: emsdrv.c:260
static ULONG EmsTotalPages
Definition: emsdrv.c:43
static BOOLEAN FASTCALL EmsWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
Definition: emsdrv.c:736
static VOID InitHandlesTable(VOID)
Definition: emsdrv.c:49
#define EMS_SEGMENT_SIZE
Definition: emsdrv.c:31
static UCHAR InitSystemHandle(USHORT NumPages)
Definition: emsdrv.c:169
static VOID FASTCALL EmsReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
Definition: emsdrv.c:716
static RTL_BITMAP AllocBitmap
Definition: emsdrv.c:37
#define EMS_DEVICE_NAME
Definition: emsdrv.c:29
#define EMS_STATUS_SUCCESS
Definition: emsdrv.h:26
struct _EMS_PAGE * PEMS_PAGE
#define EMS_INTERRUPT_NUM
Definition: emsdrv.h:15
struct _EMS_PAGE EMS_PAGE
#define EMS_SEGMENT
Definition: emsdrv.h:16
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
ULONG RegisterInt32(IN ULONG FarPtr, IN BYTE IntNumber, IN EMULATOR_INT32_PROC IntHandler, OUT PSIZE_T CodeSize OPTIONAL)
Definition: int32.c:118
#define Int16To32StubSize
Definition: int32.h:38
unsigned short USHORT
Definition: pedump.c:61
PDOS_DEVICE_NODE DosCreateDeviceEx(WORD Attributes, PCHAR DeviceName, WORD PrivateDataSize)
Definition: device.c:361
#define DEVICE_PRIVATE_AREA(Driver)
Definition: device.h:16
#define DOS_DEVATTR_IOCTL
Definition: device.h:28
#define DOS_DEVATTR_CHARACTER
Definition: device.h:29
BOOL MemInstallFastMemoryHook(PVOID Address, ULONG Size, PMEMORY_READ_HANDLER ReadHandler, PMEMORY_WRITE_HANDLER WriteHandler)
Definition: memory.c:299
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
BOOLEAN UmaDescReserve(IN OUT PUSHORT Segment, IN OUT PUSHORT Size)
Definition: umamgr.c:84
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Inout_ PVOID Segment
Definition: exfuncs.h:1101

Referenced by DosKRNLInitialize().