00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include "stdarg.h"
00024
#include "stdio.h"
00025
#include "ntddk.h"
00026
#include "fsvga.h"
00027
#include "fsvgalog.h"
00028
00029
00030
00031
00032
00033
00034
#if defined(ALLOC_PRAGMA)
00035
#pragma alloc_text(INIT,DriverEntry)
00036
#pragma alloc_text(INIT,FsVgaConfiguration)
00037
#pragma alloc_text(INIT,FsVgaPeripheralCallout)
00038
#pragma alloc_text(INIT,FsVgaServiceParameters)
00039
#pragma alloc_text(INIT,FsVgaBuildResourceList)
00040
#endif
00041
00042
00043
00044
00045
00046
00047
#if DBG
00048
ULONG FsVgaDebug = 0;
00049
#endif
00050
00051
00052
NTSTATUS
00053 DriverEntry(
00054 IN
PDRIVER_OBJECT DriverObject,
00055 IN PUNICODE_STRING RegistryPath
00056 )
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 {
00079
PDEVICE_OBJECT DeviceObject =
NULL;
00080
PDEVICE_EXTENSION deviceExtension =
NULL;
00081
DEVICE_EXTENSION tmpDeviceExtension;
00082
NTSTATUS status = STATUS_SUCCESS;
00083 PCM_RESOURCE_LIST resources =
NULL;
00084 ULONG resourceListSize = 0;
00085 BOOLEAN overrideConflict;
00086 BOOLEAN conflictDetected;
00087 ULONG addressSpace;
00088 PHYSICAL_ADDRESS cardAddress;
00089 ULONG i;
00090 UNICODE_STRING fullFsVgaName;
00091 UNICODE_STRING baseFsVgaName;
00092 UNICODE_STRING deviceNameSuffix;
00093 UNICODE_STRING resourceDeviceClass;
00094 UNICODE_STRING registryPath;
00095
00096
#define NAME_MAX 256
00097
WCHAR FsVgaBuffer[
NAME_MAX];
00098
00099 ULONG uniqueErrorValue;
00100
NTSTATUS errorCode = STATUS_SUCCESS;
00101 ULONG dumpCount = 0;
00102
00103
#define DUMP_COUNT 4
00104
ULONG dumpData[
DUMP_COUNT];
00105
00106
FsVgaPrint((1,
00107
"\n\nFSVGA-FSVGAInitialize: enter\n"));
00108
00109
00110
00111
00112 RtlZeroMemory(&tmpDeviceExtension,
sizeof(
DEVICE_EXTENSION));
00113
00114 fullFsVgaName.MaximumLength = 0;
00115 fullFsVgaName.Length = 0;
00116 deviceNameSuffix.MaximumLength = 0;
00117 deviceNameSuffix.Length = 0;
00118 resourceDeviceClass.MaximumLength = 0;
00119 resourceDeviceClass.Length = 0;
00120 registryPath.MaximumLength = 0;
00121 registryPath.Length = 0;
00122
00123 RtlZeroMemory(FsVgaBuffer,
NAME_MAX *
sizeof(WCHAR));
00124 baseFsVgaName.Buffer = FsVgaBuffer;
00125 baseFsVgaName.Length = 0;
00126 baseFsVgaName.MaximumLength =
NAME_MAX *
sizeof(WCHAR);
00127
00128 RtlZeroMemory(dumpData,
sizeof(dumpData));
00129
00130
00131
00132
00133
00134 registryPath.Buffer =
ExAllocatePool(
PagedPool,
00135 RegistryPath->Length +
sizeof(UNICODE_NULL));
00136
if (!registryPath.Buffer)
00137 {
00138
FsVgaPrint((1,
00139
"FSVGA-FSVGAInitialize: Couldn't allocate pool for registry path\n"));
00140 status = STATUS_UNSUCCESSFUL;
00141 errorCode = FSVGA_INSUFFICIENT_RESOURCES;
00142 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 2;
00143 dumpData[0] = (ULONG) RegistryPath->Length +
sizeof(UNICODE_NULL);
00144 dumpCount = 1;
00145
goto FsVgaInitializeExit;
00146 }
00147
else
00148 {
00149 registryPath.Length = RegistryPath->Length +
sizeof(UNICODE_NULL);
00150 registryPath.MaximumLength = registryPath.Length;
00151
00152 RtlZeroMemory(registryPath.Buffer,
00153 registryPath.Length);
00154 RtlMoveMemory(registryPath.Buffer,
00155 RegistryPath->Buffer,
00156 RegistryPath->Length);
00157 }
00158
00159
00160
00161
00162
00163
FsVgaConfiguration(&tmpDeviceExtension,
00164 ®istryPath,
00165 &baseFsVgaName);
00166
00167
if (!(tmpDeviceExtension.
HardwarePresent &
FSVGA_HARDWARE_PRESENT)) {
00168
00169
00170
00171
00172
00173
00174
FsVgaPrint((1,
00175
"FSVGA-FsVgaInitialize: No Full Screen Video attached.\n"));
00176 status = STATUS_NO_SUCH_DEVICE;
00177 errorCode = FSVGA_NO_SUCH_DEVICE;
00178 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 4;
00179
goto FsVgaInitializeExit;
00180
00181 }
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
RtlInitUnicodeString(&deviceNameSuffix,
00192
NULL);
00193
00194 deviceNameSuffix.MaximumLength = FULLSCREEN_VIDEO_SUFFIX_MAXIMUM *
sizeof(WCHAR);
00195 deviceNameSuffix.MaximumLength +=
sizeof(UNICODE_NULL);
00196
00197 deviceNameSuffix.Buffer =
ExAllocatePool(
PagedPool,
00198 deviceNameSuffix.MaximumLength);
00199
if (!deviceNameSuffix.Buffer) {
00200
FsVgaPrint((1,
00201
"FSVGA-FsVgaInitialize: Couldn't allocate string for device object suffix\n"));
00202
00203 status = STATUS_UNSUCCESSFUL;
00204 errorCode = FSVGA_INSUFFICIENT_RESOURCES;
00205 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 8;
00206 dumpData[0] = (ULONG) deviceNameSuffix.MaximumLength;
00207 dumpCount = 1;
00208
goto FsVgaInitializeExit;
00209 }
00210
00211 RtlZeroMemory(deviceNameSuffix.Buffer,
00212 deviceNameSuffix.MaximumLength);
00213
00214
00215
00216
00217
00218
RtlInitUnicodeString(&fullFsVgaName,
00219
NULL);
00220
00221 fullFsVgaName.MaximumLength =
sizeof(
L"\\Device\\") +
00222 baseFsVgaName.Length +
00223 deviceNameSuffix.MaximumLength;
00224
00225 fullFsVgaName.Buffer =
ExAllocatePool(
PagedPool,
00226 fullFsVgaName.MaximumLength);
00227
if (!fullFsVgaName.Buffer) {
00228
FsVgaPrint((1,
00229
"FSVGA-FsVgaInitialize: Couldn't allocate string for Full Screen Video device object name\n"));
00230
00231 status = STATUS_UNSUCCESSFUL;
00232 errorCode = FSVGA_INSUFFICIENT_RESOURCES;
00233 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 10;
00234 dumpData[0] = (ULONG) fullFsVgaName.MaximumLength;
00235 dumpCount = 1;
00236
goto FsVgaInitializeExit;
00237
00238 }
00239
00240 RtlZeroMemory(fullFsVgaName.Buffer,
00241 fullFsVgaName.MaximumLength);
00242
RtlAppendUnicodeToString(&fullFsVgaName,
00243
L"\\Device\\");
00244
RtlAppendUnicodeToString(&fullFsVgaName,
00245 baseFsVgaName.Buffer);
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 status =
RtlIntegerToUnicodeString( 0,
00256 10,
00257 &deviceNameSuffix);
00258
if (!
NT_SUCCESS(status))
00259 {
00260
FsVgaPrint((1,
00261
"FSVGA-FsVgaInitialize: Could not create suffix number\n"));
00262 errorCode = FSVGA_INSUFFICIENT_RESOURCES;
00263 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 12;
00264 dumpData[0] = (ULONG) 0;
00265 dumpCount = 1;
00266
goto FsVgaInitializeExit;
00267 }
00268
00269
RtlAppendUnicodeStringToString(&fullFsVgaName,
00270 &deviceNameSuffix);
00271
00272
FsVgaPrint((1,
00273
"FSVGA-FSVGAInitialize: Creating device object named %ws\n",
00274 fullFsVgaName.Buffer));
00275
00276
00277
00278
00279
00280
00281 status =
IoCreateDevice(DriverObject,
00282
sizeof(
DEVICE_EXTENSION),
00283 &fullFsVgaName,
00284 FILE_DEVICE_FULLSCREEN_VIDEO,
00285 0,
00286
TRUE,
00287 &DeviceObject);
00288
if (!
NT_SUCCESS(status))
00289 {
00290
FsVgaPrint((1,
00291
"FSVGA-FSVGAInitialize: Couldn't create device object = %ws\n"));
00292 status = STATUS_UNSUCCESSFUL;
00293 errorCode = FSVGA_INSUFFICIENT_RESOURCES;
00294 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 2;
00295 dumpData[0] = (ULONG) RegistryPath->Length +
sizeof(UNICODE_NULL);
00296 dumpCount = 1;
00297
goto FsVgaInitializeExit;
00298 }
00299
00300
00301
00302
00303
00304 deviceExtension = (
PDEVICE_EXTENSION)DeviceObject->
DeviceExtension;
00305 *deviceExtension = tmpDeviceExtension;
00306 deviceExtension->
DeviceObject = DeviceObject;
00307
00308
00309
00310
00311
00312
FsVgaBuildResourceList(deviceExtension, &resources, &resourceListSize);
00313
00314
00315
00316
00317
00318
RtlInitUnicodeString(&resourceDeviceClass,
00319
NULL);
00320
00321 resourceDeviceClass.MaximumLength = baseFsVgaName.Length;
00322
00323 resourceDeviceClass.Buffer =
ExAllocatePool(
PagedPool,
00324 resourceDeviceClass.MaximumLength);
00325
00326
if (!resourceDeviceClass.Buffer) {
00327
00328
FsVgaPrint((1,
00329
"FSVGA-FsVgaInitialize: Couldn't allocate string for resource device class name\n"));
00330
00331 status = STATUS_UNSUCCESSFUL;
00332 errorCode = FSVGA_INSUFFICIENT_RESOURCES;
00333 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 15;
00334 dumpData[0] = (ULONG) resourceDeviceClass.MaximumLength;
00335 dumpCount = 1;
00336
goto FsVgaInitializeExit;
00337
00338 }
00339
00340
00341
00342
00343
00344
00345 RtlZeroMemory(resourceDeviceClass.Buffer,
00346 resourceDeviceClass.MaximumLength);
00347
RtlAppendUnicodeStringToString(&resourceDeviceClass,
00348 &baseFsVgaName);
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 overrideConflict =
TRUE;
00360
#if DBG
00361
if (overrideConflict) {
00362
FsVgaPrint((2,
"We are checking the vga driver resources\n"));
00363 }
else {
00364
FsVgaPrint((2,
"We are NOT checking vga driver resources\n"));
00365 }
00366
#endif
00367
00368 status =
IoReportResourceUsage(&resourceDeviceClass,
00369 DriverObject,
00370
NULL,
00371 0,
00372 DeviceObject,
00373 resources,
00374 resourceListSize,
00375 overrideConflict,
00376 &conflictDetected
00377 );
00378
00379
00380
00381
00382
00383
00384
if ((
NT_SUCCESS(status)) &&
00385 overrideConflict &&
00386 conflictDetected) {
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 conflictDetected =
FALSE;
00405
00406
00407 }
00408
00409
00410
if (conflictDetected) {
00411
00412
00413
00414
00415
00416
00417
FsVgaPrint((1,
00418
"FSVGA-FsVgaInitialize: Resource usage conflict\n"));
00419
00420
00421
00422
00423
00424 status = STATUS_INSUFFICIENT_RESOURCES;
00425 errorCode = FSVGA_RESOURCE_CONFLICT;
00426 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 20;
00427 dumpData[0] = (ULONG)
00428 resources->List[0].PartialResourceList.PartialDescriptors[0].u.Port.Start.LowPart;
00429 dumpData[1] = (ULONG)
00430 resources->List[0].PartialResourceList.PartialDescriptors[1].u.Port.Start.LowPart;
00431 dumpData[2] = (ULONG)
00432 resources->List[0].PartialResourceList.PartialDescriptors[2].u.Port.Start.LowPart;
00433 dumpCount = 3;
00434
00435
goto FsVgaInitializeExit;
00436
00437 }
00438
00439
00440
00441
00442
00443
for (i = 0; i < deviceExtension->
Configuration.
PortListCount; i++) {
00444
00445 addressSpace = (deviceExtension->
Configuration.
PortList[i].Flags
00446 & CM_RESOURCE_PORT_IO) == CM_RESOURCE_PORT_IO? 1:0;
00447
00448
if (!
HalTranslateBusAddress(deviceExtension->
Configuration.
InterfaceType,
00449 deviceExtension->
Configuration.
BusNumber,
00450 deviceExtension->
Configuration.
PortList[i].u.Port.Start,
00451 &addressSpace,
00452 &cardAddress
00453 )) {
00454
00455 addressSpace = 1;
00456 cardAddress.QuadPart = 0;
00457 }
00458
00459
if (!addressSpace) {
00460
00461 deviceExtension->
UnmapRegistersRequired =
TRUE;
00462 deviceExtension->
DeviceRegisters[i] =
00463
MmMapIoSpace(
00464 cardAddress,
00465 deviceExtension->
Configuration.
PortList[i].u.Port.Length,
00466
FALSE
00467 );
00468
00469 }
else {
00470
00471 deviceExtension->
UnmapRegistersRequired =
FALSE;
00472 deviceExtension->
DeviceRegisters[i] = (PVOID)cardAddress.LowPart;
00473
00474 }
00475
00476
if (!deviceExtension->
DeviceRegisters[i]) {
00477
00478
FsVgaPrint((1,
00479
"FSVGA-FsVgaInitialize: Couldn't map the device registers.\n"));
00480 status = STATUS_NONE_MAPPED;
00481
00482
00483
00484
00485
00486 errorCode = FSVGA_REGISTERS_NOT_MAPPED;
00487 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 30;
00488 dumpData[0] = cardAddress.LowPart;
00489 dumpCount = 1;
00490
00491
goto FsVgaInitializeExit;
00492
00493 }
00494 }
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
if (deviceExtension->
HardwarePresent &
FSVGA_HARDWARE_PRESENT) {
00505
00506 status =
RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP,
00507 baseFsVgaName.Buffer,
00508 fullFsVgaName.Buffer,
00509 REG_SZ,
00510 registryPath.Buffer,
00511 registryPath.Length);
00512
00513
if (!
NT_SUCCESS(status))
00514 {
00515
FsVgaPrint((1,
00516
"FSVGA-FSVGAInitialize: Could not store keyboard name in DeviceMap\n"));
00517 errorCode = FSVGA_NO_DEVICEMAP_CREATED;
00518 uniqueErrorValue =
FSVGA_ERROR_VALUE_BASE + 90;
00519 dumpCount = 0;
00520
goto FsVgaInitializeExit;
00521 }
00522
else
00523 {
00524
FsVgaPrint((1,
00525
"FSVGA-FSVGAInitialize: Stored pointer name in DeviceMap\n"));
00526 }
00527 }
00528
00529
ASSERT(status == STATUS_SUCCESS);
00530
00531
00532
00533
00534 DriverObject->MajorFunction[
IRP_MJ_CREATE] =
FsVgaOpenCloseDispatch;
00535 DriverObject->MajorFunction[
IRP_MJ_CLOSE] =
FsVgaOpenCloseDispatch;
00536 DriverObject->MajorFunction[
IRP_MJ_DEVICE_CONTROL] =
FsVgaDeviceControl;
00537
00538 FsVgaInitializeExit:
00539
00540
if (errorCode != STATUS_SUCCESS)
00541 {
00542 PIO_ERROR_LOG_PACKET errorLogEntry;
00543 ULONG i;
00544
00545
00546
00547
00548 errorLogEntry = (PIO_ERROR_LOG_PACKET)
IoAllocateErrorLogEntry(
00549 (DeviceObject ==
NULL) ? (PVOID) DriverObject : (PVOID) DeviceObject,
00550 (UCHAR) (
sizeof(IO_ERROR_LOG_PACKET)
00551 + (dumpCount *
sizeof(ULONG)))
00552 );
00553
00554
if (errorLogEntry !=
NULL)
00555 {
00556 errorLogEntry->ErrorCode = errorCode;
00557 errorLogEntry->DumpDataSize = (
USHORT) dumpCount *
sizeof(ULONG);
00558 errorLogEntry->SequenceNumber = 0;
00559 errorLogEntry->MajorFunctionCode = 0;
00560 errorLogEntry->IoControlCode = 0;
00561 errorLogEntry->RetryCount = 0;
00562 errorLogEntry->UniqueErrorValue = uniqueErrorValue;
00563 errorLogEntry->FinalStatus = status;
00564
for (i = 0; i < dumpCount; i++)
00565 errorLogEntry->DumpData[i] = dumpData[i];
00566
00567
IoWriteErrorLogEntry(errorLogEntry);
00568 }
00569 }
00570
00571
if (!
NT_SUCCESS(status))
00572 {
00573
00574
00575
00576
00577
if (resources) {
00578
00579
00580
00581
00582
00583
00584 resources->Count = 0;
00585
00586
IoReportResourceUsage(&resourceDeviceClass,
00587 DriverObject,
00588
NULL,
00589 0,
00590 DeviceObject,
00591 resources,
00592 resourceListSize,
00593
FALSE,
00594 &conflictDetected
00595 );
00596
00597 }
00598
00599
if (deviceExtension) {
00600
00601
if (deviceExtension->
UnmapRegistersRequired) {
00602
for (i = 0;
00603 i < deviceExtension->
Configuration.
PortListCount; i++){
00604
if (deviceExtension->
DeviceRegisters[i]) {
00605
MmUnmapIoSpace(
00606 deviceExtension->
DeviceRegisters[i],
00607 deviceExtension->
Configuration.
PortList[i].u.Port.Length);
00608 }
00609 }
00610 }
00611 }
00612
00613
if (DeviceObject) {
00614
IoDeleteDevice(DeviceObject);
00615 }
00616 }
00617
00618
00619
00620
00621
00622
00623
00624
00625
if (resources) {
00626
ExFreePool(resources);
00627 }
00628
00629
00630
00631
00632
if (deviceNameSuffix.MaximumLength != 0)
00633
ExFreePool(deviceNameSuffix.Buffer);
00634
if (fullFsVgaName.MaximumLength != 0)
00635
ExFreePool(fullFsVgaName.Buffer);
00636
if (resourceDeviceClass.MaximumLength != 0)
00637
ExFreePool(resourceDeviceClass.Buffer);
00638
if (registryPath.MaximumLength != 0)
00639
ExFreePool(registryPath.Buffer);
00640
00641
FsVgaPrint((1,
00642
"FSVGA-FsVgaInitialize: exit\n"));
00643
00644
return(status);
00645 }
00646
00647
00648
VOID
00649 FsVgaConfiguration(
00650 IN
PDEVICE_EXTENSION DeviceExtension,
00651 IN PUNICODE_STRING RegistryPath,
00652 IN PUNICODE_STRING FsVgaDeviceName
00653 )
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676 {
00677
NTSTATUS status = STATUS_SUCCESS;
00678
PFSVGA_CONFIGURATION_INFORMATION configuration;
00679 INTERFACE_TYPE interfaceType;
00680 ULONG i;
00681
00682
for (i = 0; i < MaximumInterfaceType; i++)
00683 {
00684
00685
00686
00687
00688
00689 interfaceType = i;
00690 status =
IoQueryDeviceDescription(&interfaceType,
00691
NULL,
00692
NULL,
00693
NULL,
00694
NULL,
00695
NULL,
00696
FsVgaPeripheralCallout,
00697 (PVOID) DeviceExtension);
00698
00699
if (DeviceExtension->HardwarePresent &
FSVGA_HARDWARE_PRESENT)
00700 {
00701
00702
00703
00704
00705
00706
FsVgaServiceParameters(DeviceExtension,
00707 RegistryPath,
00708 FsVgaDeviceName);
00709
00710
break;
00711 }
00712
else
00713 {
00714
FsVgaPrint((1,
00715
"FSVGA-FsVgaConfiguration: IoQueryDeviceDescription for bus type %d failed\n",
00716 interfaceType));
00717 }
00718 }
00719 }
00720
00721
NTSTATUS
00722 FsVgaPeripheralCallout(
00723 IN PVOID Context,
00724 IN PUNICODE_STRING PathName,
00725 IN INTERFACE_TYPE BusType,
00726 IN ULONG BusNumber,
00727 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
00728 IN CONFIGURATION_TYPE ControllerType,
00729 IN ULONG ControllerNumber,
00730 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
00731 IN CONFIGURATION_TYPE PeripheralType,
00732 IN ULONG PeripheralNumber,
00733 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
00734 )
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783 {
00784
PDEVICE_EXTENSION deviceExtension;
00785
PFSVGA_CONFIGURATION_INFORMATION configuration;
00786
NTSTATUS status = STATUS_SUCCESS;
00787 CM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
00788
00789
FsVgaPrint((1,
00790
"FSVGA-FsVgaPeripheralCallout: Path @ 0x%x, Bus Type 0x%x, Bus Number 0x%x\n",
00791 PathName, BusType,
BusNumber));
00792
FsVgaPrint((1,
00793
" Controller Type 0x%x, Controller Number 0x%x, Controller info @ 0x%x\n",
00794
ControllerType, ControllerNumber, ControllerInformation));
00795
FsVgaPrint((1,
00796
" Peripheral Type 0x%x, Peripheral Number 0x%x, Peripheral info @ 0x%x\n",
00797
PeripheralType, PeripheralNumber, PeripheralInformation));
00798
00799
00800
00801
00802
00803
00804
00805 deviceExtension = (
PDEVICE_EXTENSION) Context;
00806
if (deviceExtension->
HardwarePresent &
FSVGA_HARDWARE_PRESENT)
00807 {
00808
return (status);
00809 }
00810
00811 configuration = &deviceExtension->
Configuration;
00812
00813 deviceExtension->
HardwarePresent |=
FSVGA_HARDWARE_PRESENT;
00814
00815
00816
00817
00818
00819 configuration->
InterfaceType = BusType;
00820 configuration->
BusNumber =
BusNumber;
00821
00822
00823
00824
00825 ResourceDescriptor.Type = CmResourceTypePort;
00826 ResourceDescriptor.ShareDisposition = CmResourceShareShared;
00827 ResourceDescriptor.Flags = CM_RESOURCE_PORT_IO;
00828
00829 ResourceDescriptor.u.Port.Start.LowPart =
VGA_BASE_IO_PORT+
CRTC_ADDRESS_PORT_COLOR;
00830 ResourceDescriptor.u.Port.Start.HighPart = 0;
00831 ResourceDescriptor.u.Port.Length = 1;
00832 configuration->
PortList[configuration->
PortListCount] = ResourceDescriptor;
00833 configuration->
PortListCount += 1;
00834
00835 ResourceDescriptor.u.Port.Start.LowPart =
VGA_BASE_IO_PORT+
CRTC_DATA_PORT_COLOR;
00836 ResourceDescriptor.u.Port.Start.HighPart = 0;
00837 ResourceDescriptor.u.Port.Length = 1;
00838 configuration->
PortList[configuration->
PortListCount] = ResourceDescriptor;
00839 configuration->
PortListCount += 1;
00840
00841 ResourceDescriptor.u.Port.Start.LowPart =
VGA_BASE_IO_PORT+
GRAPH_ADDRESS_PORT;
00842 ResourceDescriptor.u.Port.Start.HighPart = 0;
00843 ResourceDescriptor.u.Port.Length = 2;
00844 configuration->
PortList[configuration->
PortListCount] = ResourceDescriptor;
00845 configuration->
PortListCount += 1;
00846
00847 ResourceDescriptor.u.Port.Start.LowPart =
VGA_BASE_IO_PORT+
SEQ_ADDRESS_PORT;
00848 ResourceDescriptor.u.Port.Start.HighPart = 0;
00849 ResourceDescriptor.u.Port.Length = 2;
00850 configuration->
PortList[configuration->
PortListCount] = ResourceDescriptor;
00851 configuration->
PortListCount += 1;
00852
00853
return(status);
00854 }
00855
00856
00857
VOID
00858 FsVgaServiceParameters(
00859 IN
PDEVICE_EXTENSION DeviceExtension,
00860 IN PUNICODE_STRING RegistryPath,
00861 IN PUNICODE_STRING FsVgaDeviceName
00862 )
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887 {
00888
PFSVGA_CONFIGURATION_INFORMATION configuration;
00889 UNICODE_STRING parametersPath;
00890 PWSTR
path;
00891 PRTL_QUERY_REGISTRY_TABLE parameters =
NULL;
00892
USHORT queriesPlusOne = 4;
00893
NTSTATUS status = STATUS_SUCCESS;
00894
#define PARAMETER_MAX 256
00895
ULONG EmulationMode;
00896 ULONG HardwareCursor;
00897 ULONG HardwareScroll;
00898
USHORT defaultEmulationMode = 0;
00899
USHORT defaultHardwareCursor =
NO_HARDWARE_CURSOR;
00900
USHORT defaultHardwareScroll =
NO_HARDWARE_SCROLL;
00901 UNICODE_STRING defaultFsVgaName;
00902
00903 configuration = &DeviceExtension->Configuration;
00904 parametersPath.Buffer =
NULL;
00905
00906
00907
00908
00909
00910
path = RegistryPath->Buffer;
00911
00912
00913
00914
00915
00916 parameters =
ExAllocatePool(
PagedPool,
00917
sizeof(RTL_QUERY_REGISTRY_TABLE) * queriesPlusOne);
00918
if (!parameters)
00919 {
00920
FsVgaPrint((1,
00921
"FSVGA-FsVgaServiceParameters: Couldn't allocate table for Rtl query to parameters for %ws\n",
00922
path));
00923 status = STATUS_UNSUCCESSFUL;
00924 }
00925
else
00926 {
00927 RtlZeroMemory(parameters,
00928
sizeof(RTL_QUERY_REGISTRY_TABLE) * queriesPlusOne);
00929
00930
00931
00932
00933
00934
RtlInitUnicodeString(¶metersPath,
00935
NULL);
00936
00937 parametersPath.MaximumLength = RegistryPath->Length +
00938
sizeof(
L"\\Parameters");
00939 parametersPath.Buffer =
ExAllocatePool(
PagedPool,
00940 parametersPath.MaximumLength);
00941
if (!parametersPath.Buffer)
00942 {
00943
FsVgaPrint((1,
00944
"FSVGA-FsVgaServiceParameters: Couldn't allocate string for path to parameters for %ws\n",
00945
path));
00946 status = STATUS_UNSUCCESSFUL;
00947 }
00948 }
00949
00950
if (
NT_SUCCESS(status))
00951 {
00952
00953
00954
00955 RtlZeroMemory(parametersPath.Buffer,
00956 parametersPath.MaximumLength);
00957
RtlAppendUnicodeToString(¶metersPath,
00958
path);
00959
RtlAppendUnicodeToString(¶metersPath,
00960
L"\\Parameters");
00961
00962
FsVgaPrint((1,
00963
"FsVga-FsVgaServiceParameters: parameters path is %ws\n",
00964 parametersPath.Buffer));
00965
00966
00967
00968
00969
00970 parameters[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
00971 parameters[0].Name =
L"ConsoleFullScreen.EmulationMode";
00972 parameters[0].EntryContext = &EmulationMode;
00973 parameters[0].DefaultType = REG_DWORD;
00974 parameters[0].DefaultData = &defaultEmulationMode;
00975 parameters[0].DefaultLength =
sizeof(
USHORT);
00976
00977 parameters[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
00978 parameters[1].Name =
L"ConsoleFullScreen.HardwareCursor";
00979 parameters[1].EntryContext = &HardwareCursor;
00980 parameters[1].DefaultType = REG_DWORD;
00981 parameters[1].DefaultData = &defaultHardwareCursor;
00982 parameters[1].DefaultLength =
sizeof(
USHORT);
00983
00984 parameters[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
00985 parameters[2].Name =
L"ConsoleFullScreen.HardwareScroll";
00986 parameters[2].EntryContext = &HardwareScroll;
00987 parameters[2].DefaultType = REG_DWORD;
00988 parameters[2].DefaultData = &defaultHardwareScroll;
00989 parameters[2].DefaultLength =
sizeof(
USHORT);
00990
00991 status =
RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
00992 parametersPath.Buffer,
00993 parameters,
00994
NULL,
00995
NULL);
00996
if (!
NT_SUCCESS(status))
00997 {
00998
FsVgaPrint((1,
00999
"FsVga-FsVgaServiceParameters: RtlQueryRegistryValues failed with 0x%x\n",
01000 status));
01001 }
01002 }
01003
01004
if (!
NT_SUCCESS(status))
01005 {
01006
01007
01008
01009 configuration->
EmulationMode = defaultEmulationMode;
01010 configuration->
HardwareCursor = defaultHardwareCursor;
01011 configuration->
HardwareScroll = defaultHardwareScroll;
01012 }
01013
else
01014 {
01015 configuration->
EmulationMode = (
USHORT)EmulationMode;
01016 configuration->
HardwareCursor = (
USHORT)HardwareCursor;
01017 configuration->
HardwareScroll = (
USHORT)HardwareScroll;
01018 }
01019
01020
01021
01022
01023
01024
01025
RtlInitUnicodeString(&defaultFsVgaName,
01026 DD_FULLSCREEN_PORT_BASE_NAME_U);
01027
RtlCopyUnicodeString(FsVgaDeviceName, &defaultFsVgaName);
01028
01029
FsVgaPrint((1,
01030
"FsVga-FsVgaServiceParameters: Full Screen Video port base name = %ws\n",
01031 FsVgaDeviceName->Buffer));
01032
01033
FsVgaPrint((1,
01034
"FsVga-FsVgaServiceParameters: Emulation Mode = %d\n",
01035 configuration->
EmulationMode));
01036
01037
FsVgaPrint((1,
01038
"FsVga-FsVgaServiceParameters: Hardware Cursor = %d\n",
01039 configuration->
HardwareCursor));
01040
01041
FsVgaPrint((1,
01042
"FsVga-FsVgaServiceParameters: Hardware Scroll = %d\n",
01043 configuration->
HardwareScroll));
01044
01045
01046
01047
01048
01049
if (parametersPath.Buffer)
01050
ExFreePool(parametersPath.Buffer);
01051
if (parameters)
01052
ExFreePool(parameters);
01053 }
01054
01055
VOID
01056 FsVgaBuildResourceList(
01057 IN
PDEVICE_EXTENSION DeviceExtension,
01058 OUT PCM_RESOURCE_LIST *ResourceList,
01059 OUT PULONG ResourceListSize
01060 )
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091 {
01092 ULONG count = 0;
01093 ULONG i = 0;
01094 ULONG j = 0;
01095
#define DUMP_COUNT 4
01096
ULONG dumpData[
DUMP_COUNT];
01097
01098 count += DeviceExtension->Configuration.PortListCount;
01099
01100 *ResourceListSize =
sizeof(CM_RESOURCE_LIST) +
01101 ((count - 1) *
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
01102
01103 *ResourceList = (PCM_RESOURCE_LIST)
ExAllocatePool(
PagedPool,
01104 *ResourceListSize);
01105
01106
01107
01108
01109
01110
01111
if (!*ResourceList) {
01112
01113
01114
01115
01116
01117
FsVgaPrint((1,
01118
"FSVGA-FsVgaBuildResourceList: Could not allocate resource list\n"));
01119
01120
01121
01122
01123
01124 dumpData[0] = *ResourceListSize;
01125 *ResourceListSize = 0;
01126
01127
FsVgaLogError(DeviceExtension->DeviceObject,
01128 FSVGA_INSUFFICIENT_RESOURCES,
01129
FSVGA_ERROR_VALUE_BASE + 110,
01130 STATUS_INSUFFICIENT_RESOURCES,
01131 dumpData,
01132 1
01133 );
01134
01135
return;
01136 }
01137
01138 RtlZeroMemory(*ResourceList,
01139 *ResourceListSize);
01140
01141
01142
01143
01144
01145 (*ResourceList)->Count = 1;
01146
01147 (*ResourceList)->List[0].InterfaceType =
01148 DeviceExtension->Configuration.InterfaceType;
01149 (*ResourceList)->List[0].BusNumber =
01150 DeviceExtension->Configuration.BusNumber;
01151
01152
01153
01154
01155
01156
01157 (*ResourceList)->List[0].PartialResourceList.Count = count;
01158
01159
for (j = 0; j < DeviceExtension->Configuration.PortListCount; j++) {
01160 (*ResourceList)->List[0].PartialResourceList.PartialDescriptors[i++] =
01161 DeviceExtension->Configuration.PortList[j];
01162 }
01163
01164 }
01165
01166
NTSTATUS
01167 FsVgaOpenCloseDispatch(
01168 IN
PDEVICE_OBJECT DeviceObject,
01169 IN
PIRP Irp
01170 )
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191 {
01192 UNREFERENCED_PARAMETER(DeviceObject);
01193
01194
FsVgaPrint((3,
"FSVGA-FsVgaOpenCloseDispatch: enter\n"));
01195
01196
PAGED_CODE();
01197
01198
01199
01200
01201
01202
Irp->
IoStatus.Status = STATUS_SUCCESS;
01203
Irp->
IoStatus.Information = 0;
01204
IoCompleteRequest(
Irp,
IO_NO_INCREMENT);
01205
01206
FsVgaPrint((3,
"FSVGA-FsVgaOpenCloseDispatch: exit\n"));
01207
01208
return(STATUS_SUCCESS);
01209
01210 }
01211
01212
NTSTATUS
01213 FsVgaDeviceControl(
01214 IN
PDEVICE_OBJECT DeviceObject,
01215 IN
PIRP Irp
01216 )
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236 {
01237
PIO_STACK_LOCATION irpSp;
01238 PVOID ioBuffer;
01239 ULONG inputBufferLength;
01240 ULONG outputBufferLength;
01241
PDEVICE_EXTENSION deviceExtension;
01242
NTSTATUS status = STATUS_SUCCESS;
01243
01244
FsVgaPrint((2,
"FSVGA-FsVgaDeviceControl: enter\n"));
01245
01246
PAGED_CODE();
01247
01248
01249
01250
01251
01252 deviceExtension = DeviceObject->DeviceExtension;
01253
01254
01255
01256
01257
01258
Irp->
IoStatus.Information = 0;
01259
01260
01261
01262
01263
01264
01265 irpSp =
IoGetCurrentIrpStackLocation(
Irp);
01266
01267
01268
01269
01270
01271 ioBuffer =
Irp->
AssociatedIrp.SystemBuffer;
01272 inputBufferLength = irpSp->
Parameters.DeviceIoControl.InputBufferLength;
01273 outputBufferLength = irpSp->
Parameters.DeviceIoControl.OutputBufferLength;
01274
01275
01276
01277
01278
01279
01280
switch (irpSp->
Parameters.DeviceIoControl.IoControlCode)
01281 {
01282
case IOCTL_FSVIDEO_COPY_FRAME_BUFFER:
01283
FsVgaPrint((2,
"FsVgaDeviceControl - CopyFrameBuffer\n"));
01284 status =
FsVgaCopyFrameBuffer(deviceExtension,
01285 (PFSVIDEO_COPY_FRAME_BUFFER) ioBuffer,
01286 inputBufferLength);
01287
break;
01288
01289
case IOCTL_FSVIDEO_WRITE_TO_FRAME_BUFFER:
01290
FsVgaPrint((2,
"FsVgaDeviceControl - WriteToFrameBuffer\n"));
01291 status =
FsVgaWriteToFrameBuffer(deviceExtension,
01292 (PFSVIDEO_WRITE_TO_FRAME_BUFFER) ioBuffer,
01293 inputBufferLength);
01294
break;
01295
01296
case IOCTL_FSVIDEO_REVERSE_MOUSE_POINTER:
01297
FsVgaPrint((2,
"FsVgaDeviceControl - ReverseMousePointer\n"));
01298 status =
FsVgaReverseMousePointer(deviceExtension,
01299 (PFSVIDEO_REVERSE_MOUSE_POINTER) ioBuffer,
01300 inputBufferLength);
01301
break;
01302
01303
case IOCTL_FSVIDEO_SET_CURRENT_MODE:
01304
FsVgaPrint((2,
"FsVgaDeviceControl - SetCurrentModes\n"));
01305 status =
FsVgaSetMode(deviceExtension,
01306 (PFSVIDEO_MODE_INFORMATION) ioBuffer,
01307 inputBufferLength);
01308
break;
01309
01310
case IOCTL_FSVIDEO_SET_SCREEN_INFORMATION:
01311
FsVgaPrint((2,
"FsVgaDeviceControl - SetScreenInformation\n"));
01312 status =
FsVgaSetScreenInformation(deviceExtension,
01313 (PFSVIDEO_SCREEN_INFORMATION) ioBuffer,
01314 inputBufferLength);
01315
break;
01316
01317
case IOCTL_FSVIDEO_SET_CURSOR_POSITION:
01318
FsVgaPrint((2,
"FsVgaDeviceControl - SetCursorPosition\n"));
01319 status =
FsVgaSetCursorPosition(deviceExtension,
01320 (PFSVIDEO_CURSOR_POSITION) ioBuffer,
01321 inputBufferLength);
01322
break;
01323
01324
case IOCTL_VIDEO_SET_CURSOR_ATTR:
01325
FsVgaPrint((2,
"FsVgaDeviceControl - SetCursorAttribute\n"));
01326 status =
FsVgaSetCursorAttribute(deviceExtension,
01327 (PVIDEO_CURSOR_ATTRIBUTES) ioBuffer,
01328 inputBufferLength);
01329
break;
01330
01331
default:
01332
FsVgaPrint((1,
01333
"FSVGA-FsVgaDeviceControl: INVALID REQUEST (0x%x)\n",
01334 irpSp->
Parameters.DeviceIoControl.IoControlCode));
01335
01336 status = STATUS_INVALID_DEVICE_REQUEST;
01337
break;
01338 }
01339
01340
Irp->
IoStatus.Status = status;
01341
IoCompleteRequest(
Irp,
IO_NO_INCREMENT);
01342
01343
FsVgaPrint((2,
"FSVGA-FsVgaDeviceControl: exit\n"));
01344
01345
return(status);
01346 }
01347
01348
NTSTATUS
01349 FsVgaCopyFrameBuffer(
01350
PDEVICE_EXTENSION DeviceExtension,
01351 PFSVIDEO_COPY_FRAME_BUFFER CopyFrameBuffer,
01352 ULONG inputBufferLength
01353 )
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378 {
01379
01380
01381
01382
01383
if (inputBufferLength <
sizeof(FSVIDEO_COPY_FRAME_BUFFER)) {
01384
return STATUS_INVALID_BUFFER_SIZE;
01385 }
01386
01387
if (CopyFrameBuffer->SrcScreen.nNumberOfChars != CopyFrameBuffer->DestScreen.nNumberOfChars) {
01388
return STATUS_INVALID_PARAMETER;
01389 }
01390
01391
if (! (DeviceExtension->
CurrentMode.VideoMode.AttributeFlags & VIDEO_MODE_GRAPHICS))
01392 {
01393
01394
01395
01396
01397 ULONG OffsSrc;
01398 ULONG OffsDest;
01399 PUCHAR pFrameBuf = DeviceExtension->
CurrentMode.VideoMemory.FrameBufferBase;
01400
01401 OffsSrc =
SCREEN_BUFFER_POINTER(CopyFrameBuffer->SrcScreen.Position.X,
01402 CopyFrameBuffer->SrcScreen.Position.Y,
01403 CopyFrameBuffer->SrcScreen.ScreenSize.X,
01404
sizeof(VGA_CHAR));
01405
01406 OffsDest =
SCREEN_BUFFER_POINTER(CopyFrameBuffer->DestScreen.Position.X,
01407 CopyFrameBuffer->DestScreen.Position.Y,
01408 CopyFrameBuffer->DestScreen.ScreenSize.X,
01409
sizeof(VGA_CHAR));
01410
01411 RtlMoveMemory(pFrameBuf + OffsDest,
01412 pFrameBuf + OffsSrc,
01413 CopyFrameBuffer->SrcScreen.nNumberOfChars *
sizeof(VGA_CHAR));
01414 }
01415
else
01416 {
01417
01418
01419
01420
return FsgCopyFrameBuffer(DeviceExtension,
01421 CopyFrameBuffer,
01422 inputBufferLength);
01423 }
01424
01425
return STATUS_SUCCESS;
01426 }
01427
01428
NTSTATUS
01429 FsVgaWriteToFrameBuffer(
01430
PDEVICE_EXTENSION DeviceExtension,
01431 PFSVIDEO_WRITE_TO_FRAME_BUFFER WriteFrameBuffer,
01432 ULONG inputBufferLength
01433 )
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458 {
01459
01460
01461
01462
01463
if (inputBufferLength <
sizeof(FSVIDEO_WRITE_TO_FRAME_BUFFER)) {
01464
return STATUS_INVALID_BUFFER_SIZE;
01465 }
01466
01467
if (WriteFrameBuffer->DestScreen.Position.X < 0 ||
01468 WriteFrameBuffer->DestScreen.Position.X > DeviceExtension->
ScreenAndFont.ScreenSize.X ||
01469 (
SHORT)(WriteFrameBuffer->DestScreen.Position.X +
01470 WriteFrameBuffer->DestScreen.nNumberOfChars)
01471 > DeviceExtension->
ScreenAndFont.ScreenSize.X ||
01472 WriteFrameBuffer->DestScreen.Position.Y < 0 ||
01473 WriteFrameBuffer->DestScreen.Position.Y > DeviceExtension->
ScreenAndFont.ScreenSize.Y) {
01474
return STATUS_INVALID_BUFFER_SIZE;
01475 }
01476
01477
if (! (DeviceExtension->
CurrentMode.VideoMode.AttributeFlags & VIDEO_MODE_GRAPHICS))
01478 {
01479
01480
01481
01482
01483 ULONG Offs;
01484 PUCHAR pFrameBuf = DeviceExtension->
CurrentMode.VideoMemory.FrameBufferBase;
01485 PCHAR_IMAGE_INFO pCharInfoUni = WriteFrameBuffer->SrcBuffer;
01486 PCHAR_IMAGE_INFO pCharInfoAsc;
01487
DWORD Length = WriteFrameBuffer->DestScreen.nNumberOfChars;
01488 PVOID pCapBuffer =
NULL;
01489 ULONG cCapBuffer = 0;
01490
01491 Offs =
SCREEN_BUFFER_POINTER(WriteFrameBuffer->DestScreen.Position.X,
01492 WriteFrameBuffer->DestScreen.Position.Y,
01493 WriteFrameBuffer->DestScreen.ScreenSize.X,
01494
sizeof(VGA_CHAR));
01495
01496 cCapBuffer = Length *
sizeof(CHAR_IMAGE_INFO);
01497 pCapBuffer =
ExAllocatePool(
PagedPool, cCapBuffer);
01498
01499
if (!pCapBuffer) {
01500
#define DUMP_COUNT 4
01501
ULONG dumpData[
DUMP_COUNT];
01502
01503
FsVgaPrint((1,
01504
"FSVGA-FsVgaWriteToFrameBuffer: Could not allocate resource list\n"));
01505
01506
01507
01508 dumpData[0] = cCapBuffer;
01509
FsVgaLogError(DeviceExtension->
DeviceObject,
01510 FSVGA_INSUFFICIENT_RESOURCES,
01511
FSVGA_ERROR_VALUE_BASE + 200,
01512 STATUS_INSUFFICIENT_RESOURCES,
01513 dumpData,
01514 1
01515 );
01516
return STATUS_UNSUCCESSFUL;
01517 }
01518
01519
TranslateOutputToOem(pCapBuffer, pCharInfoUni, Length);
01520
01521 pCharInfoAsc = pCapBuffer;
01522 pFrameBuf += Offs;
01523
while (Length--)
01524 {
01525 *pFrameBuf++ = pCharInfoAsc->CharInfo.Char.AsciiChar;
01526 *pFrameBuf++ = (UCHAR) (pCharInfoAsc->CharInfo.Attributes);
01527 pCharInfoAsc++;
01528 }
01529
01530
ExFreePool(pCapBuffer);
01531 }
01532
else
01533 {
01534
01535
01536
01537
return FsgWriteToFrameBuffer(DeviceExtension,
01538 WriteFrameBuffer,
01539 inputBufferLength);
01540 }
01541
01542
return STATUS_SUCCESS;
01543 }
01544
01545
NTSTATUS
01546 FsVgaReverseMousePointer(
01547
PDEVICE_EXTENSION DeviceExtension,
01548 PFSVIDEO_REVERSE_MOUSE_POINTER MouseBuffer,
01549 ULONG inputBufferLength
01550 )
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575 {
01576
01577
01578
01579
01580
if (inputBufferLength <
sizeof(FSVIDEO_REVERSE_MOUSE_POINTER)) {
01581
return STATUS_INVALID_BUFFER_SIZE;
01582 }
01583
01584
if (! (DeviceExtension->
CurrentMode.VideoMode.AttributeFlags & VIDEO_MODE_GRAPHICS))
01585 {
01586
01587
01588
01589
01590 ULONG Offs;
01591 PUCHAR pFrameBuf = DeviceExtension->
CurrentMode.VideoMemory.FrameBufferBase;
01592
BYTE Attribute;
01593
01594 Offs =
SCREEN_BUFFER_POINTER(MouseBuffer->Screen.Position.X,
01595 MouseBuffer->Screen.Position.Y,
01596 MouseBuffer->Screen.ScreenSize.X,
01597
sizeof(VGA_CHAR));
01598 pFrameBuf += Offs;
01599
01600 Attribute = (*(pFrameBuf + 1) & 0xF0) >> 4;
01601 Attribute |= (*(pFrameBuf + 1) & 0x0F) << 4;
01602 *(pFrameBuf + 1) = Attribute;
01603 }
01604
else
01605 {
01606
01607
01608
01609
return FsgReverseMousePointer(DeviceExtension,
01610 MouseBuffer,
01611 inputBufferLength);
01612 }
01613
01614
return STATUS_SUCCESS;
01615 }
01616
01617
NTSTATUS
01618 FsVgaSetMode(
01619
PDEVICE_EXTENSION DeviceExtension,
01620 PFSVIDEO_MODE_INFORMATION ModeInformation,
01621 ULONG inputBufferLength
01622 )
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648 {
01649
01650
01651
01652
01653
if (inputBufferLength <
sizeof(FSVIDEO_MODE_INFORMATION)) {
01654
return STATUS_INVALID_BUFFER_SIZE;
01655 }
01656
01657 DeviceExtension->
CurrentMode = *ModeInformation;
01658
01659
return STATUS_SUCCESS;
01660 }
01661
01662
NTSTATUS
01663 FsVgaSetScreenInformation(
01664
PDEVICE_EXTENSION DeviceExtension,
01665 PFSVIDEO_SCREEN_INFORMATION ScreenInformation,
01666 ULONG inputBufferLength
01667 )
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693 {
01694
01695
01696
01697
01698
if (inputBufferLength <
sizeof(FSVIDEO_SCREEN_INFORMATION)) {
01699
return STATUS_INVALID_BUFFER_SIZE;
01700 }
01701
01702 DeviceExtension->
ScreenAndFont = *ScreenInformation;
01703
01704
FsgVgaInitializeHWFlags(DeviceExtension);
01705
01706
return STATUS_SUCCESS;
01707 }
01708
01709
NTSTATUS
01710 FsVgaSetCursorPosition(
01711
PDEVICE_EXTENSION DeviceExtension,
01712 PFSVIDEO_CURSOR_POSITION CursorPosition,
01713 ULONG inputBufferLength
01714 )
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740 {
01741
01742
01743
01744
01745
if (inputBufferLength <
sizeof(VIDEO_CURSOR_POSITION)) {
01746
return STATUS_INVALID_BUFFER_SIZE;
01747 }
01748
01749
if (DeviceExtension->
CurrentMode.VideoMode.AttributeFlags & VIDEO_MODE_GRAPHICS)
01750 {
01751
FsgInvertCursor(DeviceExtension,
FALSE);
01752 }
01753
01754 DeviceExtension->
EmulateInfo.
CursorPosition = *CursorPosition;
01755
01756
if (DeviceExtension->
CurrentMode.VideoMode.AttributeFlags & VIDEO_MODE_GRAPHICS)
01757 {
01758
FsgInvertCursor(DeviceExtension,
TRUE);
01759
return STATUS_SUCCESS;
01760 }
01761
else
01762 {
01763
01764
01765
01766
01767
01768
01769
01770
01771
return STATUS_UNSUCCESSFUL;
01772 }
01773 }
01774
01775
01776
NTSTATUS
01777 FsVgaSetCursorAttribute(
01778
PDEVICE_EXTENSION DeviceExtension,
01779 PVIDEO_CURSOR_ATTRIBUTES CursorAttributes,
01780 ULONG inputBufferLength
01781 )
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807 {
01808
01809
01810
01811
01812
if (inputBufferLength <
sizeof(VIDEO_CURSOR_ATTRIBUTES)) {
01813
return STATUS_INVALID_BUFFER_SIZE;
01814 }
01815
01816
if (DeviceExtension->
CurrentMode.VideoMode.AttributeFlags & VIDEO_MODE_GRAPHICS)
01817 {
01818
FsgInvertCursor(DeviceExtension,
FALSE);
01819 }
01820
01821 DeviceExtension->
EmulateInfo.
CursorAttributes = *CursorAttributes;
01822
01823
if (DeviceExtension->
CurrentMode.VideoMode.AttributeFlags & VIDEO_MODE_GRAPHICS)
01824 {
01825
FsgInvertCursor(DeviceExtension,
TRUE);
01826
return STATUS_SUCCESS;
01827 }
01828
else
01829 {
01830
01831
01832
01833
01834
01835
01836
01837
01838
return STATUS_UNSUCCESSFUL;
01839 }
01840 }
01841
01842
01843
VOID
01844 FsVgaLogError(
01845 IN
PDEVICE_OBJECT DeviceObject,
01846 IN NTSTATUS ErrorCode,
01847 IN ULONG UniqueErrorValue,
01848 IN NTSTATUS FinalStatus,
01849 IN PULONG DumpData,
01850 IN ULONG DumpCount
01851 )
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885 {
01886 PIO_ERROR_LOG_PACKET errorLogEntry;
01887 ULONG i;
01888
01889 errorLogEntry = (PIO_ERROR_LOG_PACKET)
IoAllocateErrorLogEntry(
01890 DeviceObject,
01891 (UCHAR)
01892 (
sizeof(IO_ERROR_LOG_PACKET)
01893 + (DumpCount *
sizeof(ULONG)))
01894 );
01895
01896
if (errorLogEntry !=
NULL) {
01897
01898 errorLogEntry->ErrorCode = ErrorCode;
01899 errorLogEntry->DumpDataSize = (
USHORT) (DumpCount *
sizeof(ULONG));
01900 errorLogEntry->SequenceNumber = 0;
01901 errorLogEntry->MajorFunctionCode = 0;
01902 errorLogEntry->IoControlCode = 0;
01903 errorLogEntry->RetryCount = 0;
01904 errorLogEntry->UniqueErrorValue = UniqueErrorValue;
01905 errorLogEntry->FinalStatus = FinalStatus;
01906
for (i = 0; i < DumpCount; i++)
01907 errorLogEntry->DumpData[i] = DumpData[i];
01908
01909
IoWriteErrorLogEntry(errorLogEntry);
01910 }
01911 }
01912
01913
01914
#if DBG
01915
VOID
01916 FsVgaDebugPrint(
01917 ULONG DebugPrintLevel,
01918 PCCHAR DebugMessage,
01919 ...
01920 )
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938 {
01939 va_list ap;
01940
01941 va_start(ap, DebugMessage);
01942
01943
if (DebugPrintLevel <= FsVgaDebug) {
01944
01945
char buffer[128];
01946
01947 (
VOID) vsprintf(buffer, DebugMessage, ap);
01948
01949
DbgPrint(buffer);
01950 }
01951
01952 va_end(ap);
01953
01954 }
01955
#endif
01956