mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NTVDM] Move the def file out of the source files list. Rename some variables and functions. #179
This commit is contained in:
parent
d822478e06
commit
5ef2c4515e
7 changed files with 166 additions and 162 deletions
|
@ -67,12 +67,16 @@ list(APPEND SOURCE
|
||||||
utils.c
|
utils.c
|
||||||
vddsup.c
|
vddsup.c
|
||||||
ntvdm.c
|
ntvdm.c
|
||||||
ntvdm.h
|
ntvdm.h)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/ntvdm.def)
|
|
||||||
|
|
||||||
file(GLOB ntvdm_rc_deps res/*.*)
|
file(GLOB ntvdm_rc_deps res/*.*)
|
||||||
add_rc_deps(ntvdm.rc ${ntvdm_rc_deps})
|
add_rc_deps(ntvdm.rc ${ntvdm_rc_deps})
|
||||||
add_executable(ntvdm ${SOURCE} ntvdm.rc)
|
|
||||||
|
add_executable(ntvdm
|
||||||
|
${SOURCE}
|
||||||
|
ntvdm.rc
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/ntvdm.def)
|
||||||
|
|
||||||
add_pch(ntvdm ntvdm.h SOURCE)
|
add_pch(ntvdm ntvdm.h SOURCE)
|
||||||
set_module_type(ntvdm win32cui UNICODE IMAGEBASE 0x0F000000)
|
set_module_type(ntvdm win32cui UNICODE IMAGEBASE 0x0F000000)
|
||||||
target_link_libraries(ntvdm fast486 ${PSEH_LIB})
|
target_link_libraries(ntvdm fast486 ${PSEH_LIB})
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
VOID BiosCharPrint(CHAR Character)
|
VOID Dem_BiosCharPrint(CHAR Character)
|
||||||
{
|
{
|
||||||
/* Save AX and BX */
|
/* Save AX and BX */
|
||||||
USHORT AX = getAX();
|
USHORT AX = getAX();
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID BiosCharPrint(CHAR Character);
|
VOID Dem_BiosCharPrint(CHAR Character);
|
||||||
#define BiosDisplayMessage(Format, ...) \
|
#define BiosDisplayMessage(Format, ...) \
|
||||||
PrintMessageAnsi(BiosCharPrint, (Format), ##__VA_ARGS__)
|
PrintMessageAnsi(Dem_BiosCharPrint, (Format), ##__VA_ARGS__)
|
||||||
|
|
||||||
VOID DosCharPrint(CHAR Character);
|
VOID DosCharPrint(CHAR Character);
|
||||||
#define DosDisplayMessage(Format, ...) \
|
#define DosDisplayMessage(Format, ...) \
|
||||||
|
|
|
@ -35,9 +35,9 @@
|
||||||
|
|
||||||
static PDOS_DEVICE_NODE Node;
|
static PDOS_DEVICE_NODE Node;
|
||||||
static RTL_BITMAP AllocBitmap;
|
static RTL_BITMAP AllocBitmap;
|
||||||
static PULONG BitmapBuffer = NULL;
|
static PULONG EmsBitmapBuffer = NULL;
|
||||||
static PEMS_PAGE PageTable = NULL;
|
static PEMS_PAGE EmsPageTable = NULL;
|
||||||
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES];
|
static EMS_HANDLE EmsHandleTable[EMS_MAX_HANDLES];
|
||||||
static PVOID Mapping[EMS_PHYSICAL_PAGES] = { NULL };
|
static PVOID Mapping[EMS_PHYSICAL_PAGES] = { NULL };
|
||||||
static PVOID MappingBackup[EMS_PHYSICAL_PAGES] = { NULL };
|
static PVOID MappingBackup[EMS_PHYSICAL_PAGES] = { NULL };
|
||||||
static ULONG EmsTotalPages = 0;
|
static ULONG EmsTotalPages = 0;
|
||||||
|
@ -50,12 +50,12 @@ static VOID InitHandlesTable(VOID)
|
||||||
{
|
{
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(HandleTable); i++)
|
for (i = 0; i < ARRAYSIZE(EmsHandleTable); i++)
|
||||||
{
|
{
|
||||||
HandleTable[i].Allocated = FALSE;
|
EmsHandleTable[i].Allocated = FALSE;
|
||||||
HandleTable[i].PageCount = 0;
|
EmsHandleTable[i].PageCount = 0;
|
||||||
RtlZeroMemory(HandleTable[i].Name, sizeof(HandleTable[i].Name));
|
RtlZeroMemory(EmsHandleTable[i].Name, sizeof(EmsHandleTable[i].Name));
|
||||||
InitializeListHead(&HandleTable[i].PageList);
|
InitializeListHead(&EmsHandleTable[i].PageList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ static PEMS_HANDLE CreateHandle(PUSHORT Handle)
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
/* Handle 0 is reserved (system handle) */
|
/* Handle 0 is reserved (system handle) */
|
||||||
for (i = 1; i < ARRAYSIZE(HandleTable); i++)
|
for (i = 1; i < ARRAYSIZE(EmsHandleTable); i++)
|
||||||
{
|
{
|
||||||
HandleEntry = &HandleTable[i];
|
HandleEntry = &EmsHandleTable[i];
|
||||||
if (!HandleEntry->Allocated)
|
if (!HandleEntry->Allocated)
|
||||||
{
|
{
|
||||||
*Handle = i;
|
*Handle = i;
|
||||||
|
@ -87,10 +87,10 @@ static VOID FreeHandle(PEMS_HANDLE HandleEntry)
|
||||||
// InitializeListHead(&HandleEntry->PageList);
|
// InitializeListHead(&HandleEntry->PageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline PEMS_HANDLE GetHandleRecord(USHORT Handle)
|
static inline PEMS_HANDLE GetEmsHandleRecord(USHORT Handle)
|
||||||
{
|
{
|
||||||
if (Handle >= ARRAYSIZE(HandleTable)) return NULL;
|
if (Handle >= ARRAYSIZE(EmsHandleTable)) return NULL;
|
||||||
return &HandleTable[Handle];
|
return &EmsHandleTable[Handle];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOLEAN ValidateHandle(PEMS_HANDLE HandleEntry)
|
static inline BOOLEAN ValidateHandle(PEMS_HANDLE HandleEntry)
|
||||||
|
@ -101,7 +101,7 @@ static inline BOOLEAN ValidateHandle(PEMS_HANDLE HandleEntry)
|
||||||
static UCHAR EmsFree(USHORT Handle)
|
static UCHAR EmsFree(USHORT Handle)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
PEMS_HANDLE HandleEntry = GetHandleRecord(Handle);
|
PEMS_HANDLE HandleEntry = GetEmsHandleRecord(Handle);
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateHandle(HandleEntry))
|
||||||
return EMS_STATUS_INVALID_HANDLE;
|
return EMS_STATUS_INVALID_HANDLE;
|
||||||
|
@ -111,7 +111,7 @@ static UCHAR EmsFree(USHORT Handle)
|
||||||
Entry = Entry->Flink)
|
Entry = Entry->Flink)
|
||||||
{
|
{
|
||||||
PEMS_PAGE PageEntry = (PEMS_PAGE)CONTAINING_RECORD(Entry, EMS_PAGE, Entry);
|
PEMS_PAGE PageEntry = (PEMS_PAGE)CONTAINING_RECORD(Entry, EMS_PAGE, Entry);
|
||||||
ULONG PageNumber = ARRAY_INDEX(PageEntry, PageTable);
|
ULONG PageNumber = ARRAY_INDEX(PageEntry, EmsPageTable);
|
||||||
|
|
||||||
/* Free the page */
|
/* Free the page */
|
||||||
RtlClearBits(&AllocBitmap, PageNumber, 1);
|
RtlClearBits(&AllocBitmap, PageNumber, 1);
|
||||||
|
@ -158,8 +158,8 @@ static UCHAR EmsAlloc(USHORT NumPages, PUSHORT Handle)
|
||||||
|
|
||||||
for (i = 0; i < RunSize; i++)
|
for (i = 0; i < RunSize; i++)
|
||||||
{
|
{
|
||||||
PageTable[RunStart + i].Handle = *Handle;
|
EmsPageTable[RunStart + i].Handle = *Handle;
|
||||||
InsertTailList(&HandleEntry->PageList, &PageTable[RunStart + i].Entry);
|
InsertTailList(&HandleEntry->PageList, &EmsPageTable[RunStart + i].Entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ static UCHAR InitSystemHandle(USHORT NumPages)
|
||||||
//
|
//
|
||||||
|
|
||||||
ULONG i, CurrentIndex = 0;
|
ULONG i, CurrentIndex = 0;
|
||||||
PEMS_HANDLE HandleEntry = &HandleTable[EMS_SYSTEM_HANDLE];
|
PEMS_HANDLE HandleEntry = &EmsHandleTable[EMS_SYSTEM_HANDLE];
|
||||||
|
|
||||||
/* The system handle must never have been initialized before */
|
/* The system handle must never have been initialized before */
|
||||||
ASSERT(!HandleEntry->Allocated);
|
ASSERT(!HandleEntry->Allocated);
|
||||||
|
@ -209,8 +209,8 @@ static UCHAR InitSystemHandle(USHORT NumPages)
|
||||||
|
|
||||||
for (i = 0; i < RunSize; i++)
|
for (i = 0; i < RunSize; i++)
|
||||||
{
|
{
|
||||||
PageTable[RunStart + i].Handle = EMS_SYSTEM_HANDLE;
|
EmsPageTable[RunStart + i].Handle = EMS_SYSTEM_HANDLE;
|
||||||
InsertTailList(&HandleEntry->PageList, &PageTable[RunStart + i].Entry);
|
InsertTailList(&HandleEntry->PageList, &EmsPageTable[RunStart + i].Entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ static PEMS_PAGE GetLogicalPage(PEMS_HANDLE HandleEntry, USHORT LogicalPage)
|
||||||
static UCHAR EmsMap(USHORT Handle, UCHAR PhysicalPage, USHORT LogicalPage)
|
static UCHAR EmsMap(USHORT Handle, UCHAR PhysicalPage, USHORT LogicalPage)
|
||||||
{
|
{
|
||||||
PEMS_PAGE PageEntry;
|
PEMS_PAGE PageEntry;
|
||||||
PEMS_HANDLE HandleEntry = GetHandleRecord(Handle);
|
PEMS_HANDLE HandleEntry = GetEmsHandleRecord(Handle);
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateHandle(HandleEntry))
|
||||||
return EMS_STATUS_INVALID_HANDLE;
|
return EMS_STATUS_INVALID_HANDLE;
|
||||||
|
@ -253,7 +253,7 @@ static UCHAR EmsMap(USHORT Handle, UCHAR PhysicalPage, USHORT LogicalPage)
|
||||||
if (!PageEntry) return EMS_STATUS_INV_LOGICAL_PAGE;
|
if (!PageEntry) return EMS_STATUS_INV_LOGICAL_PAGE;
|
||||||
|
|
||||||
Mapping[PhysicalPage] = (PVOID)((ULONG_PTR)EmsMemory
|
Mapping[PhysicalPage] = (PVOID)((ULONG_PTR)EmsMemory
|
||||||
+ ARRAY_INDEX(PageEntry, PageTable) * EMS_PAGE_SIZE);
|
+ ARRAY_INDEX(PageEntry, EmsPageTable) * EMS_PAGE_SIZE);
|
||||||
return EMS_STATUS_SUCCESS;
|
return EMS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,9 +344,9 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
USHORT NumOpenHandles = 0;
|
USHORT NumOpenHandles = 0;
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(HandleTable); i++)
|
for (i = 0; i < ARRAYSIZE(EmsHandleTable); i++)
|
||||||
{
|
{
|
||||||
if (HandleTable[i].Allocated)
|
if (EmsHandleTable[i].Allocated)
|
||||||
++NumOpenHandles;
|
++NumOpenHandles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
/* Get Handle Number of Pages */
|
/* Get Handle Number of Pages */
|
||||||
case 0x4C:
|
case 0x4C:
|
||||||
{
|
{
|
||||||
PEMS_HANDLE HandleEntry = GetHandleRecord(getDX());
|
PEMS_HANDLE HandleEntry = GetEmsHandleRecord(getDX());
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateHandle(HandleEntry))
|
||||||
{
|
{
|
||||||
|
@ -378,12 +378,12 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
USHORT NumOpenHandles = 0;
|
USHORT NumOpenHandles = 0;
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(HandleTable); i++)
|
for (i = 0; i < ARRAYSIZE(EmsHandleTable); i++)
|
||||||
{
|
{
|
||||||
if (HandleTable[i].Allocated)
|
if (EmsHandleTable[i].Allocated)
|
||||||
{
|
{
|
||||||
HandlePageInfo->Handle = i;
|
HandlePageInfo->Handle = i;
|
||||||
HandlePageInfo->PageCount = HandleTable[i].PageCount;
|
HandlePageInfo->PageCount = EmsHandleTable[i].PageCount;
|
||||||
++HandlePageInfo;
|
++HandlePageInfo;
|
||||||
++NumOpenHandles;
|
++NumOpenHandles;
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
/* Get/Set Handle Name */
|
/* Get/Set Handle Name */
|
||||||
case 0x53:
|
case 0x53:
|
||||||
{
|
{
|
||||||
PEMS_HANDLE HandleEntry = GetHandleRecord(getDX());
|
PEMS_HANDLE HandleEntry = GetEmsHandleRecord(getDX());
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateHandle(HandleEntry))
|
||||||
{
|
{
|
||||||
|
@ -474,13 +474,13 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
USHORT NumOpenHandles = 0;
|
USHORT NumOpenHandles = 0;
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(HandleTable); i++)
|
for (i = 0; i < ARRAYSIZE(EmsHandleTable); i++)
|
||||||
{
|
{
|
||||||
if (HandleTable[i].Allocated)
|
if (EmsHandleTable[i].Allocated)
|
||||||
{
|
{
|
||||||
HandleDir->Handle = i;
|
HandleDir->Handle = i;
|
||||||
RtlCopyMemory(HandleDir->Name,
|
RtlCopyMemory(HandleDir->Name,
|
||||||
HandleTable[i].Name,
|
EmsHandleTable[i].Name,
|
||||||
sizeof(HandleDir->Name));
|
sizeof(HandleDir->Name));
|
||||||
++HandleDir;
|
++HandleDir;
|
||||||
++NumOpenHandles;
|
++NumOpenHandles;
|
||||||
|
@ -498,20 +498,20 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
PEMS_HANDLE HandleFound = NULL;
|
PEMS_HANDLE HandleFound = NULL;
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(HandleTable); i++)
|
for (i = 0; i < ARRAYSIZE(EmsHandleTable); i++)
|
||||||
{
|
{
|
||||||
if (HandleTable[i].Allocated &&
|
if (EmsHandleTable[i].Allocated &&
|
||||||
RtlCompareMemory(HandleName,
|
RtlCompareMemory(HandleName,
|
||||||
HandleTable[i].Name,
|
EmsHandleTable[i].Name,
|
||||||
sizeof(HandleTable[i].Name)) == sizeof(HandleTable[i].Name))
|
sizeof(EmsHandleTable[i].Name)) == sizeof(EmsHandleTable[i].Name))
|
||||||
{
|
{
|
||||||
HandleFound = &HandleTable[i];
|
HandleFound = &EmsHandleTable[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bail out if no handle was found */
|
/* Bail out if no handle was found */
|
||||||
if (i >= ARRAYSIZE(HandleTable)) // HandleFound == NULL
|
if (i >= ARRAYSIZE(EmsHandleTable)) // HandleFound == NULL
|
||||||
{
|
{
|
||||||
setAH(EMS_STATUS_HANDLE_NOT_FOUND);
|
setAH(EMS_STATUS_HANDLE_NOT_FOUND);
|
||||||
break;
|
break;
|
||||||
|
@ -544,7 +544,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
* a program may request.
|
* a program may request.
|
||||||
*/
|
*/
|
||||||
setAH(EMS_STATUS_SUCCESS);
|
setAH(EMS_STATUS_SUCCESS);
|
||||||
setBX(ARRAYSIZE(HandleTable));
|
setBX(ARRAYSIZE(EmsHandleTable));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -567,7 +567,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
if (Data->SourceType)
|
if (Data->SourceType)
|
||||||
{
|
{
|
||||||
/* Expanded memory */
|
/* Expanded memory */
|
||||||
HandleEntry = GetHandleRecord(Data->SourceHandle);
|
HandleEntry = GetEmsHandleRecord(Data->SourceHandle);
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateHandle(HandleEntry))
|
||||||
{
|
{
|
||||||
setAH(EMS_STATUS_INVALID_HANDLE);
|
setAH(EMS_STATUS_INVALID_HANDLE);
|
||||||
|
@ -582,7 +582,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
SourcePtr = (PUCHAR)((ULONG_PTR)EmsMemory
|
SourcePtr = (PUCHAR)((ULONG_PTR)EmsMemory
|
||||||
+ ARRAY_INDEX(PageEntry, PageTable) * EMS_PAGE_SIZE
|
+ ARRAY_INDEX(PageEntry, EmsPageTable) * EMS_PAGE_SIZE
|
||||||
+ Data->SourceOffset);
|
+ Data->SourceOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -594,7 +594,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
if (Data->DestType)
|
if (Data->DestType)
|
||||||
{
|
{
|
||||||
/* Expanded memory */
|
/* Expanded memory */
|
||||||
HandleEntry = GetHandleRecord(Data->DestHandle);
|
HandleEntry = GetEmsHandleRecord(Data->DestHandle);
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateHandle(HandleEntry))
|
||||||
{
|
{
|
||||||
setAH(EMS_STATUS_INVALID_HANDLE);
|
setAH(EMS_STATUS_INVALID_HANDLE);
|
||||||
|
@ -609,7 +609,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
DestPtr = (PUCHAR)((ULONG_PTR)EmsMemory
|
DestPtr = (PUCHAR)((ULONG_PTR)EmsMemory
|
||||||
+ ARRAY_INDEX(PageEntry, PageTable) * EMS_PAGE_SIZE
|
+ ARRAY_INDEX(PageEntry, EmsPageTable) * EMS_PAGE_SIZE
|
||||||
+ Data->DestOffset);
|
+ Data->DestOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -774,24 +774,24 @@ BOOLEAN EmsDrvInitialize(USHORT Segment, ULONG TotalPages)
|
||||||
if (!UmaDescReserve(&EmsSegment, &Size)) return FALSE;
|
if (!UmaDescReserve(&EmsSegment, &Size)) return FALSE;
|
||||||
|
|
||||||
EmsTotalPages = TotalPages;
|
EmsTotalPages = TotalPages;
|
||||||
BitmapBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
|
EmsBitmapBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
((TotalPages + 31) / 32) * sizeof(ULONG));
|
((TotalPages + 31) / 32) * sizeof(ULONG));
|
||||||
if (BitmapBuffer == NULL)
|
if (EmsBitmapBuffer == NULL)
|
||||||
{
|
{
|
||||||
UmaDescRelease(EmsSegment);
|
UmaDescRelease(EmsSegment);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitializeBitMap(&AllocBitmap, BitmapBuffer, TotalPages);
|
RtlInitializeBitMap(&AllocBitmap, EmsBitmapBuffer, TotalPages);
|
||||||
|
|
||||||
PageTable = (PEMS_PAGE)RtlAllocateHeap(RtlGetProcessHeap(),
|
EmsPageTable = (PEMS_PAGE)RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
TotalPages * sizeof(EMS_PAGE));
|
TotalPages * sizeof(EMS_PAGE));
|
||||||
if (PageTable == NULL)
|
if (EmsPageTable == NULL)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, BitmapBuffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
|
||||||
BitmapBuffer = NULL;
|
EmsBitmapBuffer = NULL;
|
||||||
|
|
||||||
UmaDescRelease(EmsSegment);
|
UmaDescRelease(EmsSegment);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -800,10 +800,10 @@ BOOLEAN EmsDrvInitialize(USHORT Segment, ULONG TotalPages)
|
||||||
EmsMemory = (PVOID)RtlAllocateHeap(RtlGetProcessHeap(), 0, TotalPages * EMS_PAGE_SIZE);
|
EmsMemory = (PVOID)RtlAllocateHeap(RtlGetProcessHeap(), 0, TotalPages * EMS_PAGE_SIZE);
|
||||||
if (EmsMemory == NULL)
|
if (EmsMemory == NULL)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, PageTable);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsPageTable);
|
||||||
PageTable = NULL;
|
EmsPageTable = NULL;
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, BitmapBuffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
|
||||||
BitmapBuffer = NULL;
|
EmsBitmapBuffer = NULL;
|
||||||
|
|
||||||
UmaDescRelease(EmsSegment);
|
UmaDescRelease(EmsSegment);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -821,10 +821,10 @@ BOOLEAN EmsDrvInitialize(USHORT Segment, ULONG TotalPages)
|
||||||
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsMemory);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsMemory);
|
||||||
EmsMemory = NULL;
|
EmsMemory = NULL;
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, PageTable);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsPageTable);
|
||||||
PageTable = NULL;
|
EmsPageTable = NULL;
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, BitmapBuffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
|
||||||
BitmapBuffer = NULL;
|
EmsBitmapBuffer = NULL;
|
||||||
|
|
||||||
UmaDescRelease(EmsSegment);
|
UmaDescRelease(EmsSegment);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -861,16 +861,16 @@ VOID EmsDrvCleanup(VOID)
|
||||||
EmsMemory = NULL;
|
EmsMemory = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageTable)
|
if (EmsPageTable)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, PageTable);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsPageTable);
|
||||||
PageTable = NULL;
|
EmsPageTable = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BitmapBuffer)
|
if (EmsBitmapBuffer)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, BitmapBuffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, EmsBitmapBuffer);
|
||||||
BitmapBuffer = NULL;
|
EmsBitmapBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
UmaDescRelease(EmsSegment);
|
UmaDescRelease(EmsSegment);
|
||||||
|
|
|
@ -169,7 +169,7 @@ Fail:
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
static inline PXMS_HANDLE GetHandleRecord(WORD Handle)
|
static inline PXMS_HANDLE GetXmsHandleRecord(WORD Handle)
|
||||||
{
|
{
|
||||||
PXMS_HANDLE Entry;
|
PXMS_HANDLE Entry;
|
||||||
if (Handle == 0 || Handle >= XMS_MAX_HANDLES) return NULL;
|
if (Handle == 0 || Handle >= XMS_MAX_HANDLES) return NULL;
|
||||||
|
@ -178,7 +178,7 @@ static inline PXMS_HANDLE GetHandleRecord(WORD Handle)
|
||||||
return Entry->Size ? Entry : NULL;
|
return Entry->Size ? Entry : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOLEAN ValidateHandle(PXMS_HANDLE HandleEntry)
|
static inline BOOLEAN ValidateXmsHandle(PXMS_HANDLE HandleEntry)
|
||||||
{
|
{
|
||||||
return (HandleEntry != NULL && HandleEntry->Handle != 0);
|
return (HandleEntry != NULL && HandleEntry->Handle != 0);
|
||||||
}
|
}
|
||||||
|
@ -277,12 +277,12 @@ static UCHAR XmsAlloc(WORD Size, PWORD Handle)
|
||||||
static UCHAR XmsRealloc(WORD Handle, WORD NewSize)
|
static UCHAR XmsRealloc(WORD Handle, WORD NewSize)
|
||||||
{
|
{
|
||||||
DWORD BlockNumber;
|
DWORD BlockNumber;
|
||||||
PXMS_HANDLE HandleEntry = GetHandleRecord(Handle);
|
PXMS_HANDLE HandleEntry = GetXmsHandleRecord(Handle);
|
||||||
DWORD CurrentIndex = 0;
|
DWORD CurrentIndex = 0;
|
||||||
ULONG RunStart;
|
ULONG RunStart;
|
||||||
ULONG RunSize;
|
ULONG RunSize;
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateXmsHandle(HandleEntry))
|
||||||
return XMS_STATUS_INVALID_HANDLE;
|
return XMS_STATUS_INVALID_HANDLE;
|
||||||
|
|
||||||
if (HandleEntry->LockCount)
|
if (HandleEntry->LockCount)
|
||||||
|
@ -360,9 +360,9 @@ static UCHAR XmsRealloc(WORD Handle, WORD NewSize)
|
||||||
static UCHAR XmsFree(WORD Handle)
|
static UCHAR XmsFree(WORD Handle)
|
||||||
{
|
{
|
||||||
DWORD BlockNumber;
|
DWORD BlockNumber;
|
||||||
PXMS_HANDLE HandleEntry = GetHandleRecord(Handle);
|
PXMS_HANDLE HandleEntry = GetXmsHandleRecord(Handle);
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateXmsHandle(HandleEntry))
|
||||||
return XMS_STATUS_INVALID_HANDLE;
|
return XMS_STATUS_INVALID_HANDLE;
|
||||||
|
|
||||||
if (HandleEntry->LockCount)
|
if (HandleEntry->LockCount)
|
||||||
|
@ -379,9 +379,9 @@ static UCHAR XmsFree(WORD Handle)
|
||||||
|
|
||||||
static UCHAR XmsLock(WORD Handle, PDWORD Address)
|
static UCHAR XmsLock(WORD Handle, PDWORD Address)
|
||||||
{
|
{
|
||||||
PXMS_HANDLE HandleEntry = GetHandleRecord(Handle);
|
PXMS_HANDLE HandleEntry = GetXmsHandleRecord(Handle);
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateXmsHandle(HandleEntry))
|
||||||
return XMS_STATUS_INVALID_HANDLE;
|
return XMS_STATUS_INVALID_HANDLE;
|
||||||
|
|
||||||
if (HandleEntry->LockCount == 0xFF)
|
if (HandleEntry->LockCount == 0xFF)
|
||||||
|
@ -396,9 +396,9 @@ static UCHAR XmsLock(WORD Handle, PDWORD Address)
|
||||||
|
|
||||||
static UCHAR XmsUnlock(WORD Handle)
|
static UCHAR XmsUnlock(WORD Handle)
|
||||||
{
|
{
|
||||||
PXMS_HANDLE HandleEntry = GetHandleRecord(Handle);
|
PXMS_HANDLE HandleEntry = GetXmsHandleRecord(Handle);
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateXmsHandle(HandleEntry))
|
||||||
return XMS_STATUS_INVALID_HANDLE;
|
return XMS_STATUS_INVALID_HANDLE;
|
||||||
|
|
||||||
if (!HandleEntry->LockCount)
|
if (!HandleEntry->LockCount)
|
||||||
|
@ -596,8 +596,8 @@ static VOID WINAPI XmsBopProcedure(LPWORD Stack)
|
||||||
|
|
||||||
if (CopyData->SourceHandle)
|
if (CopyData->SourceHandle)
|
||||||
{
|
{
|
||||||
HandleEntry = GetHandleRecord(CopyData->SourceHandle);
|
HandleEntry = GetXmsHandleRecord(CopyData->SourceHandle);
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateXmsHandle(HandleEntry))
|
||||||
{
|
{
|
||||||
setAX(0);
|
setAX(0);
|
||||||
setBL(XMS_STATUS_BAD_SRC_HANDLE);
|
setBL(XMS_STATUS_BAD_SRC_HANDLE);
|
||||||
|
@ -620,8 +620,8 @@ static VOID WINAPI XmsBopProcedure(LPWORD Stack)
|
||||||
|
|
||||||
if (CopyData->DestHandle)
|
if (CopyData->DestHandle)
|
||||||
{
|
{
|
||||||
HandleEntry = GetHandleRecord(CopyData->DestHandle);
|
HandleEntry = GetXmsHandleRecord(CopyData->DestHandle);
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateXmsHandle(HandleEntry))
|
||||||
{
|
{
|
||||||
setAX(0);
|
setAX(0);
|
||||||
setBL(XMS_STATUS_BAD_DEST_HANDLE);
|
setBL(XMS_STATUS_BAD_DEST_HANDLE);
|
||||||
|
@ -686,11 +686,11 @@ static VOID WINAPI XmsBopProcedure(LPWORD Stack)
|
||||||
/* Get Handle Information */
|
/* Get Handle Information */
|
||||||
case 0x0E:
|
case 0x0E:
|
||||||
{
|
{
|
||||||
PXMS_HANDLE HandleEntry = GetHandleRecord(getDX());
|
PXMS_HANDLE HandleEntry = GetXmsHandleRecord(getDX());
|
||||||
UINT i;
|
UINT i;
|
||||||
UCHAR Handles = 0;
|
UCHAR Handles = 0;
|
||||||
|
|
||||||
if (!ValidateHandle(HandleEntry))
|
if (!ValidateXmsHandle(HandleEntry))
|
||||||
{
|
{
|
||||||
setAX(0);
|
setAX(0);
|
||||||
setBL(XMS_STATUS_INVALID_HANDLE);
|
setBL(XMS_STATUS_INVALID_HANDLE);
|
||||||
|
|
|
@ -18,22 +18,22 @@
|
||||||
|
|
||||||
/* PRIVATE VARIABLES **********************************************************/
|
/* PRIVATE VARIABLES **********************************************************/
|
||||||
|
|
||||||
static BOOLEAN Reporting = FALSE;
|
static BOOLEAN KeyboardReporting = FALSE;
|
||||||
static BYTE KeyboardId = 0; // We only support basic old-type keyboard
|
static BYTE KeyboardId = 0; // We only support basic old-type keyboard
|
||||||
static BYTE DataByteWait = 0;
|
static BYTE KbdDataByteWait = 0;
|
||||||
|
|
||||||
static BYTE PS2Port = 0;
|
static BYTE KbdPS2Port = 0;
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
{
|
{
|
||||||
/* Check if we were waiting for a data byte */
|
/* Check if we were waiting for a data byte */
|
||||||
if (DataByteWait)
|
if (KbdDataByteWait)
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
|
|
||||||
switch (DataByteWait)
|
switch (KbdDataByteWait)
|
||||||
{
|
{
|
||||||
/* Set/Reset Mode Indicators */
|
/* Set/Reset Mode Indicators */
|
||||||
case 0xED:
|
case 0xED:
|
||||||
|
@ -52,7 +52,7 @@ static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
// the keyboard by sending keyboard commands and then
|
// the keyboard by sending keyboard commands and then
|
||||||
// performing polling on the port until "valid" data
|
// performing polling on the port until "valid" data
|
||||||
// comes out.
|
// comes out.
|
||||||
DPRINT1("KeyboardCommand(0x%02X) NOT IMPLEMENTED\n", DataByteWait);
|
DPRINT1("KeyboardCommand(0x%02X) NOT IMPLEMENTED\n", KbdDataByteWait);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataByteWait = 0;
|
KbdDataByteWait = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,39 +76,39 @@ static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
/* Set Typematic Rate/Delay */
|
/* Set Typematic Rate/Delay */
|
||||||
case 0xF3:
|
case 0xF3:
|
||||||
{
|
{
|
||||||
DataByteWait = Command;
|
KbdDataByteWait = Command;
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Echo test command */
|
/* Echo test command */
|
||||||
case 0xEE:
|
case 0xEE:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, 0xEE);
|
PS2QueuePush(KbdPS2Port, 0xEE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get Keyboard ID */
|
/* Get Keyboard ID */
|
||||||
case 0xF2:
|
case 0xF2:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
PS2QueuePush(PS2Port, KeyboardId);
|
PS2QueuePush(KbdPS2Port, KeyboardId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable Reporting */
|
/* Enable Reporting */
|
||||||
case 0xF4:
|
case 0xF4:
|
||||||
{
|
{
|
||||||
Reporting = TRUE;
|
KeyboardReporting = TRUE;
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable Reporting */
|
/* Disable Reporting */
|
||||||
case 0xF5:
|
case 0xF5:
|
||||||
{
|
{
|
||||||
Reporting = FALSE;
|
KeyboardReporting = FALSE;
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
case 0xF6:
|
case 0xF6:
|
||||||
{
|
{
|
||||||
// So far, nothing to reset
|
// So far, nothing to reset
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@ static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
* and acknowledged as discussed in:
|
* and acknowledged as discussed in:
|
||||||
* http://stanislavs.org/helppc/keyboard_commands.html
|
* http://stanislavs.org/helppc/keyboard_commands.html
|
||||||
*/
|
*/
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resend */
|
/* Resend */
|
||||||
case 0xFE:
|
case 0xFE:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -144,20 +144,20 @@ static VOID WINAPI KeyboardCommand(LPVOID Param, BYTE Command)
|
||||||
case 0xFF:
|
case 0xFF:
|
||||||
{
|
{
|
||||||
/* Send ACKnowledge */
|
/* Send ACKnowledge */
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ACK);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ACK);
|
||||||
|
|
||||||
// So far, nothing to reset
|
// So far, nothing to reset
|
||||||
|
|
||||||
/* Send the Basic Assurance Test success code and the device ID */
|
/* Send the Basic Assurance Test success code and the device ID */
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_BAT_SUCCESS);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_BAT_SUCCESS);
|
||||||
PS2QueuePush(PS2Port, KeyboardId);
|
PS2QueuePush(KbdPS2Port, KeyboardId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unknown command */
|
/* Unknown command */
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, KEYBOARD_ERROR);
|
PS2QueuePush(KbdPS2Port, KEYBOARD_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
|
||||||
BYTE ScanCode = (BYTE)KeyEvent->wVirtualScanCode;
|
BYTE ScanCode = (BYTE)KeyEvent->wVirtualScanCode;
|
||||||
|
|
||||||
/* Check if we're not reporting */
|
/* Check if we're not reporting */
|
||||||
if (!Reporting) return;
|
if (!KeyboardReporting) return;
|
||||||
|
|
||||||
/* If this is a key release, set the highest bit in the scan code */
|
/* If this is a key release, set the highest bit in the scan code */
|
||||||
if (!KeyEvent->bKeyDown) ScanCode |= 0x80;
|
if (!KeyEvent->bKeyDown) ScanCode |= 0x80;
|
||||||
|
@ -178,8 +178,8 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
|
||||||
/* Push the scan code into the PS/2 queue */
|
/* Push the scan code into the PS/2 queue */
|
||||||
for (i = 0; i < KeyEvent->wRepeatCount; i++)
|
for (i = 0; i < KeyEvent->wRepeatCount; i++)
|
||||||
{
|
{
|
||||||
if (KeyEvent->dwControlKeyState & ENHANCED_KEY) PS2QueuePush(PS2Port, 0xE0);
|
if (KeyEvent->dwControlKeyState & ENHANCED_KEY) PS2QueuePush(KbdPS2Port, 0xE0);
|
||||||
PS2QueuePush(PS2Port, ScanCode);
|
PS2QueuePush(KbdPS2Port, ScanCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Press 0x%X\n", ScanCode);
|
DPRINT("Press 0x%X\n", ScanCode);
|
||||||
|
@ -188,7 +188,7 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
|
||||||
BOOLEAN KeyboardInit(BYTE PS2Connector)
|
BOOLEAN KeyboardInit(BYTE PS2Connector)
|
||||||
{
|
{
|
||||||
/* Finish to plug the keyboard to the specified PS/2 port */
|
/* Finish to plug the keyboard to the specified PS/2 port */
|
||||||
PS2Port = PS2Connector;
|
KbdPS2Port = PS2Connector;
|
||||||
PS2SetDeviceCmdProc(PS2Port, NULL, KeyboardCommand);
|
PS2SetDeviceCmdProc(KbdPS2Port, NULL, KeyboardCommand);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,19 +34,19 @@ static MOUSE_MODE Mode, PreviousMode;
|
||||||
static COORD Position;
|
static COORD Position;
|
||||||
static BYTE Resolution; /* Completely ignored */
|
static BYTE Resolution; /* Completely ignored */
|
||||||
static BOOLEAN Scaling; /* Completely ignored */
|
static BOOLEAN Scaling; /* Completely ignored */
|
||||||
static BOOLEAN Reporting = FALSE;
|
static BOOLEAN MouseReporting = FALSE;
|
||||||
static BYTE MouseId;
|
static BYTE MouseId;
|
||||||
static ULONG ButtonState;
|
static ULONG ButtonState;
|
||||||
static SHORT HorzCounter;
|
static SHORT HorzCounter;
|
||||||
static SHORT VertCounter;
|
static SHORT VertCounter;
|
||||||
static CHAR ScrollCounter;
|
static CHAR ScrollCounter;
|
||||||
static BOOLEAN EventsOccurred = FALSE;
|
static BOOLEAN EventsOccurred = FALSE;
|
||||||
static BYTE DataByteWait = 0;
|
static BYTE MouseDataByteWait = 0;
|
||||||
static BYTE ScrollMagicCounter = 0, ExtraButtonMagicCounter = 0;
|
static BYTE ScrollMagicCounter = 0, ExtraButtonMagicCounter = 0;
|
||||||
|
|
||||||
static UINT MouseCycles = 10;
|
static UINT MouseCycles = 10;
|
||||||
|
|
||||||
static BYTE PS2Port = 1;
|
static BYTE MousePS2Port = 1;
|
||||||
|
|
||||||
/* PUBLIC VARIABLES ***********************************************************/
|
/* PUBLIC VARIABLES ***********************************************************/
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ static VOID MouseResetConfig(VOID)
|
||||||
MouseCycles = 10;
|
MouseCycles = 10;
|
||||||
Resolution = 4;
|
Resolution = 4;
|
||||||
Scaling = FALSE;
|
Scaling = FALSE;
|
||||||
Reporting = FALSE;
|
MouseReporting = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID MouseResetCounters(VOID)
|
static VOID MouseResetCounters(VOID)
|
||||||
|
@ -146,20 +146,20 @@ static VOID MouseGetPacket(PMOUSE_PACKET Packet)
|
||||||
|
|
||||||
static VOID MouseDispatchPacket(PMOUSE_PACKET Packet)
|
static VOID MouseDispatchPacket(PMOUSE_PACKET Packet)
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, Packet->Flags);
|
PS2QueuePush(MousePS2Port, Packet->Flags);
|
||||||
PS2QueuePush(PS2Port, Packet->HorzCounter);
|
PS2QueuePush(MousePS2Port, Packet->HorzCounter);
|
||||||
PS2QueuePush(PS2Port, Packet->VertCounter);
|
PS2QueuePush(MousePS2Port, Packet->VertCounter);
|
||||||
if (MouseId >= 3) PS2QueuePush(PS2Port, Packet->Extra);
|
if (MouseId >= 3) PS2QueuePush(MousePS2Port, Packet->Extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
{
|
{
|
||||||
/* Check if we were waiting for a data byte */
|
/* Check if we were waiting for a data byte */
|
||||||
if (DataByteWait)
|
if (MouseDataByteWait)
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
|
|
||||||
switch (DataByteWait)
|
switch (MouseDataByteWait)
|
||||||
{
|
{
|
||||||
/* Set Resolution */
|
/* Set Resolution */
|
||||||
case 0xE8:
|
case 0xE8:
|
||||||
|
@ -210,7 +210,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataByteWait = 0;
|
MouseDataByteWait = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
*/
|
*/
|
||||||
if (Command != 0xEC && Command != 0xFF)
|
if (Command != 0xEC && Command != 0xFF)
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, Command);
|
PS2QueuePush(MousePS2Port, Command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
case 0xE6:
|
case 0xE6:
|
||||||
{
|
{
|
||||||
Scaling = FALSE;
|
Scaling = FALSE;
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
case 0xE7:
|
case 0xE7:
|
||||||
{
|
{
|
||||||
Scaling = TRUE;
|
Scaling = TRUE;
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,8 +251,8 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
/* Set Sample Rate */
|
/* Set Sample Rate */
|
||||||
case 0xF3:
|
case 0xF3:
|
||||||
{
|
{
|
||||||
DataByteWait = Command;
|
MouseDataByteWait = Command;
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,13 +262,13 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
BYTE Status = ButtonState & 7;
|
BYTE Status = ButtonState & 7;
|
||||||
|
|
||||||
if (Scaling) Status |= 1 << 4;
|
if (Scaling) Status |= 1 << 4;
|
||||||
if (Reporting) Status |= 1 << 5;
|
if (MouseReporting) Status |= 1 << 5;
|
||||||
if (Mode == MOUSE_REMOTE_MODE) Status |= 1 << 6;
|
if (Mode == MOUSE_REMOTE_MODE) Status |= 1 << 6;
|
||||||
|
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
PS2QueuePush(PS2Port, Status);
|
PS2QueuePush(MousePS2Port, Status);
|
||||||
PS2QueuePush(PS2Port, Resolution);
|
PS2QueuePush(MousePS2Port, Resolution);
|
||||||
PS2QueuePush(PS2Port, (BYTE)(1000 / MouseCycles));
|
PS2QueuePush(MousePS2Port, (BYTE)(1000 / MouseCycles));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,14 +278,14 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
MouseResetCounters();
|
MouseResetCounters();
|
||||||
Mode = MOUSE_STREAMING_MODE;
|
Mode = MOUSE_STREAMING_MODE;
|
||||||
|
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read Packet */
|
/* Read Packet */
|
||||||
case 0xEB:
|
case 0xEB:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
MouseGetPacket(&LastPacket);
|
MouseGetPacket(&LastPacket);
|
||||||
MouseDispatchPacket(&LastPacket);
|
MouseDispatchPacket(&LastPacket);
|
||||||
break;
|
break;
|
||||||
|
@ -299,11 +299,11 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
/* Restore the previous mode */
|
/* Restore the previous mode */
|
||||||
MouseResetCounters();
|
MouseResetCounters();
|
||||||
Mode = PreviousMode;
|
Mode = PreviousMode;
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, MOUSE_ERROR);
|
PS2QueuePush(MousePS2Port, MOUSE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -321,7 +321,7 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
MouseResetCounters();
|
MouseResetCounters();
|
||||||
Mode = MOUSE_WRAP_MODE;
|
Mode = MOUSE_WRAP_MODE;
|
||||||
|
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,33 +331,33 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
MouseResetCounters();
|
MouseResetCounters();
|
||||||
Mode = MOUSE_REMOTE_MODE;
|
Mode = MOUSE_REMOTE_MODE;
|
||||||
|
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get Mouse ID */
|
/* Get Mouse ID */
|
||||||
case 0xF2:
|
case 0xF2:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
PS2QueuePush(PS2Port, MouseId);
|
PS2QueuePush(MousePS2Port, MouseId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable Reporting */
|
/* Enable Reporting */
|
||||||
case 0xF4:
|
case 0xF4:
|
||||||
{
|
{
|
||||||
Reporting = TRUE;
|
MouseReporting = TRUE;
|
||||||
MouseResetCounters();
|
MouseResetCounters();
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable Reporting */
|
/* Disable Reporting */
|
||||||
case 0xF5:
|
case 0xF5:
|
||||||
{
|
{
|
||||||
Reporting = FALSE;
|
MouseReporting = FALSE;
|
||||||
MouseResetCounters();
|
MouseResetCounters();
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,14 +367,14 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
/* Reset the configuration and counters */
|
/* Reset the configuration and counters */
|
||||||
MouseResetConfig();
|
MouseResetConfig();
|
||||||
MouseResetCounters();
|
MouseResetCounters();
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resend */
|
/* Resend */
|
||||||
case 0xFE:
|
case 0xFE:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
MouseDispatchPacket(&LastPacket);
|
MouseDispatchPacket(&LastPacket);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -383,20 +383,20 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
|
||||||
case 0xFF:
|
case 0xFF:
|
||||||
{
|
{
|
||||||
/* Send ACKnowledge */
|
/* Send ACKnowledge */
|
||||||
PS2QueuePush(PS2Port, MOUSE_ACK);
|
PS2QueuePush(MousePS2Port, MOUSE_ACK);
|
||||||
|
|
||||||
MouseReset();
|
MouseReset();
|
||||||
|
|
||||||
/* Send the Basic Assurance Test success code and the device ID */
|
/* Send the Basic Assurance Test success code and the device ID */
|
||||||
PS2QueuePush(PS2Port, MOUSE_BAT_SUCCESS);
|
PS2QueuePush(MousePS2Port, MOUSE_BAT_SUCCESS);
|
||||||
PS2QueuePush(PS2Port, MouseId);
|
PS2QueuePush(MousePS2Port, MouseId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unknown command */
|
/* Unknown command */
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
PS2QueuePush(PS2Port, MOUSE_ERROR);
|
PS2QueuePush(MousePS2Port, MOUSE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ static VOID FASTCALL MouseStreamingCallback(ULONGLONG ElapsedTime)
|
||||||
UNREFERENCED_PARAMETER(ElapsedTime);
|
UNREFERENCED_PARAMETER(ElapsedTime);
|
||||||
|
|
||||||
/* Check if we're not in streaming mode, not reporting, or there's nothing to report */
|
/* Check if we're not in streaming mode, not reporting, or there's nothing to report */
|
||||||
if (Mode != MOUSE_STREAMING_MODE || !Reporting || !EventsOccurred) return;
|
if (Mode != MOUSE_STREAMING_MODE || !MouseReporting || !EventsOccurred) return;
|
||||||
|
|
||||||
MouseGetPacket(&LastPacket);
|
MouseGetPacket(&LastPacket);
|
||||||
MouseDispatchPacket(&LastPacket);
|
MouseDispatchPacket(&LastPacket);
|
||||||
|
@ -464,8 +464,8 @@ VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
|
||||||
BOOLEAN MouseInit(BYTE PS2Connector)
|
BOOLEAN MouseInit(BYTE PS2Connector)
|
||||||
{
|
{
|
||||||
/* Finish to plug the mouse to the specified PS/2 port */
|
/* Finish to plug the mouse to the specified PS/2 port */
|
||||||
PS2Port = PS2Connector;
|
MousePS2Port = PS2Connector;
|
||||||
PS2SetDeviceCmdProc(PS2Port, NULL, MouseCommand);
|
PS2SetDeviceCmdProc(MousePS2Port, NULL, MouseCommand);
|
||||||
|
|
||||||
MouseMutex = CreateMutex(NULL, FALSE, NULL);
|
MouseMutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
if (MouseMutex == NULL) return FALSE;
|
if (MouseMutex == NULL) return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue