2 * PROJECT: ReactOS VT100 emulator
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/base/green/screen.c
5 * PURPOSE: IRP_MJ_PNP operations
6 * PROGRAMMERS: Copyright 2005 Eric Kohl (ekohl@abo.rhein-zeitung.de)
7 * Copyright 2005 Art Yerkes
8 * Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
16 #define ESC ((UCHAR)0x1b)
18 /* Force a move of the cursor on each printer char.
19 * Very useful for debug, but it is very slow...
21 //#define FORCE_POSITION
23 /* UCHAR is promoted to int when passed through '...',
24 * so we get int with va_arg and cast them back to UCHAR.
28 IN PSCREEN_DEVICE_EXTENSION DeviceExtension
,
29 IN ULONG NumberOfChars
,
33 IO_STATUS_BLOCK ioStatus
;
35 PDEVICE_OBJECT SerialDevice
;
40 LARGE_INTEGER ZeroOffset
;
42 ZeroOffset
.QuadPart
= 0;
44 SizeLeft
= sizeof(DeviceExtension
->SendBuffer
) - DeviceExtension
->SendBufferPosition
;
45 if (SizeLeft
< NumberOfChars
* 2 || NumberOfChars
== 0)
47 SerialDevice
= ((PGREEN_DEVICE_EXTENSION
)DeviceExtension
->Green
->DeviceExtension
)->Serial
;
48 Irp
= IoBuildSynchronousFsdRequest(
51 DeviceExtension
->SendBuffer
, DeviceExtension
->SendBufferPosition
,
57 DPRINT1("IoBuildSynchronousFsdRequest() failed. Unable to flush output buffer\n");
61 Status
= IoCallDriver(SerialDevice
, Irp
);
63 if (!NT_SUCCESS(Status
) && Status
!= STATUS_PENDING
)
65 DPRINT1("IoCallDriver() failed. Status = 0x%08lx\n", Status
);
68 DeviceExtension
->SendBufferPosition
= 0;
69 SizeLeft
= sizeof(DeviceExtension
->SendBuffer
);
72 va_start(args
, NumberOfChars
);
73 while (NumberOfChars
-- > 0)
75 CurrentInt
= va_arg(args
, int);
79 CurrentChar
= (UCHAR
)CurrentInt
;
81 /* Why 0xff chars are printed on a 'dir' ? */
82 if (CurrentChar
== 0xff) CurrentChar
= ' ';
84 DeviceExtension
->SendBuffer
[DeviceExtension
->SendBufferPosition
++] = CurrentChar
;
87 else if (CurrentInt
== 0)
89 DeviceExtension
->SendBuffer
[DeviceExtension
->SendBufferPosition
++] = '0';
94 CurrentInt
= -CurrentInt
;
95 ASSERT(CurrentInt
< 100);
98 DeviceExtension
->SendBuffer
[DeviceExtension
->SendBufferPosition
++] =
99 (CurrentInt
/ 10) % 10 + '0';
102 DeviceExtension
->SendBuffer
[DeviceExtension
->SendBufferPosition
++] =
103 CurrentInt
% 10 + '0';
112 IN PDRIVER_OBJECT DriverObject
,
113 IN PDEVICE_OBJECT Pdo
)
115 /* We want to be an upper filter of Blue, if it is existing.
116 * We also *have to* create a Fdo on top of the given Pdo.
117 * Hence, we have 2 cases:
118 * - Blue doesn't exist -> Create a unique Fdo (named Blue) at
119 * the top of the given Pdo
120 * - Blue does exist -> Create a Fdo at the top of the existing
121 * DO, and create a "pass to Green" FDO at the top of the Pdo
123 PDEVICE_OBJECT Fdo
= NULL
;
124 PDEVICE_OBJECT PassThroughFdo
= NULL
;
125 PDEVICE_OBJECT LowerDevice
= NULL
;
126 PDEVICE_OBJECT PreviousBlue
= NULL
;
127 PSCREEN_DEVICE_EXTENSION DeviceExtension
= NULL
;
128 UNICODE_STRING BlueScreenName
= RTL_CONSTANT_STRING(L
"\\Device\\BlueScreen");
131 DPRINT("ScreenInitialize() called\n");
133 /* Try to create a unique Fdo */
134 Status
= IoCreateDevice(
136 sizeof(SCREEN_DEVICE_EXTENSION
),
139 FILE_DEVICE_SECURE_OPEN
,
143 if (Status
== STATUS_OBJECT_NAME_COLLISION
)
145 DPRINT("Attaching to old blue\n");
147 /* Suggested by hpoussin .. Hide previous blue device
148 * This makes us able to coexist with blue, and install
150 Status
= IoCreateDevice(
152 sizeof(SCREEN_DEVICE_EXTENSION
),
155 FILE_DEVICE_SECURE_OPEN
,
158 if (!NT_SUCCESS(Status
))
160 DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status
);
164 /* Initialize some fields, as IoAttachDevice will trigger the
165 * sending of IRP_MJ_CLEANUP/IRP_MJ_CLOSE. We have to know where to
166 * dispatch these IRPs... */
167 ((PSCREEN_DEVICE_EXTENSION
)Fdo
->DeviceExtension
)->Common
.Type
= ScreenPDO
;
168 Status
= IoAttachDevice(
172 if (!NT_SUCCESS(Status
))
174 DPRINT("IoAttachDevice() failed with status 0x%08lx\n", Status
);
177 PreviousBlue
= LowerDevice
;
179 /* Attach a faked FDO to PDO */
180 Status
= IoCreateDevice(
182 sizeof(COMMON_FDO_DEVICE_EXTENSION
),
185 FILE_DEVICE_SECURE_OPEN
,
188 if (!NT_SUCCESS(Status
))
190 DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status
);
193 ((PCOMMON_FDO_DEVICE_EXTENSION
)PassThroughFdo
->DeviceExtension
)->Type
= PassThroughFDO
;
194 ((PCOMMON_FDO_DEVICE_EXTENSION
)PassThroughFdo
->DeviceExtension
)->LowerDevice
= Fdo
;
195 PassThroughFdo
->StackSize
= Fdo
->StackSize
+ 1;
197 else if (NT_SUCCESS(Status
))
199 /* Attach the named Fdo on top of Pdo */
200 LowerDevice
= IoAttachDeviceToDeviceStack(Fdo
, Pdo
);
204 DPRINT("IoCreateDevice() failed with status 0x%08lx\n", Status
);
208 /* We definately have a device object. PreviousBlue may or may
210 DeviceExtension
= (PSCREEN_DEVICE_EXTENSION
)Fdo
->DeviceExtension
;
211 RtlZeroMemory(DeviceExtension
, sizeof(SCREEN_DEVICE_EXTENSION
));
212 DeviceExtension
->Common
.Type
= ScreenFDO
;
213 DeviceExtension
->Common
.LowerDevice
= LowerDevice
;
214 DeviceExtension
->Green
= ((PGREEN_DRIVER_EXTENSION
)IoGetDriverObjectExtension(DriverObject
, DriverObject
))->GreenMainDO
;
215 ((PGREEN_DEVICE_EXTENSION
)DeviceExtension
->Green
->DeviceExtension
)->ScreenFdo
= Fdo
;
216 DeviceExtension
->PreviousBlue
= PreviousBlue
;
217 IoAttachDeviceToDeviceStack(PassThroughFdo
? PassThroughFdo
: Fdo
, Pdo
);
219 /* initialize screen */
220 DeviceExtension
->Columns
= 80;
221 DeviceExtension
->Rows
= 25;
222 DeviceExtension
->ScanLines
= 16;
223 DeviceExtension
->VideoMemory
= (PUCHAR
)ExAllocatePool(
225 2 * DeviceExtension
->Columns
* DeviceExtension
->Rows
* sizeof(UCHAR
));
226 if (!DeviceExtension
->VideoMemory
)
228 DPRINT("ExAllocatePool() failed\n");
229 Status
= STATUS_INSUFFICIENT_RESOURCES
;
232 DeviceExtension
->TabWidth
= 8;
234 /* more initialization */
235 DeviceExtension
->Mode
= ENABLE_PROCESSED_OUTPUT
|
236 ENABLE_WRAP_AT_EOL_OUTPUT
;
238 /* initialize screen at next write */
239 AddToSendBuffer(DeviceExtension
, 2, ESC
, 'c'); /* reset device */
240 AddToSendBuffer(DeviceExtension
, 4, ESC
, '[', '7', 'l'); /* disable line wrap */
241 AddToSendBuffer(DeviceExtension
, 4, ESC
, '[', '3', 'g'); /* clear all tabs */
243 Fdo
->Flags
|= DO_POWER_PAGABLE
;
244 Fdo
->Flags
&= ~DO_DEVICE_INITIALIZING
;
246 Status
= STATUS_SUCCESS
;
249 if (!NT_SUCCESS(Status
))
252 ExFreePool(DeviceExtension
->VideoMemory
);
254 IoDetachDevice(LowerDevice
);
258 IoDeleteDevice(PassThroughFdo
);
266 IN PDEVICE_OBJECT DeviceObject
,
269 PIO_STACK_LOCATION Stack
;
271 PSCREEN_DEVICE_EXTENSION DeviceExtension
;
272 PDEVICE_OBJECT SerialDevice
;
273 PUCHAR VideoMemory
; /* FIXME: is it useful? */
274 ULONG VideoMemorySize
; /* FIXME: is it useful? */
277 ULONG CursorX
, CursorY
;
280 DPRINT("ScreenWrite() called\n");
282 Stack
= IoGetCurrentIrpStackLocation (Irp
);
283 Buffer
= Irp
->UserBuffer
;
284 DeviceExtension
= (PSCREEN_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
285 VideoMemory
= DeviceExtension
->VideoMemory
;
287 SerialDevice
= ((PGREEN_DEVICE_EXTENSION
)DeviceExtension
->Green
->DeviceExtension
)->Serial
;
290 DPRINT1("Calling blue\n");
291 IoSkipCurrentIrpStackLocation(Irp
);
292 return IoCallDriver(DeviceExtension
->PreviousBlue
, Irp
);
295 Columns
= DeviceExtension
->Columns
;
296 Rows
= DeviceExtension
->Rows
;
297 CursorX
= (DeviceExtension
->LogicalOffset
/ 2) % Columns
+ 1;
298 CursorY
= (DeviceExtension
->LogicalOffset
/ 2) / Columns
+ 1;
299 VideoMemorySize
= Columns
* Rows
* 2 * sizeof(UCHAR
);
301 if (!(DeviceExtension
->Mode
& ENABLE_PROCESSED_OUTPUT
))
303 /* raw output mode */
304 Irp
->IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
305 IoCompleteRequest (Irp
, IO_NO_INCREMENT
);
307 return STATUS_NOT_SUPPORTED
;
311 for (i
= 0; i
< Stack
->Parameters
.Write
.Length
; i
++, Buffer
++)
320 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', -(int)CursorX
, 'H');
321 AddToSendBuffer(DeviceExtension
, 1, ' ');
322 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', -(int)CursorX
, 'H');
324 else if (CursorY
> 1)
328 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', -(int)CursorX
, 'H');
336 AddToSendBuffer(DeviceExtension
, 1, '\n');
337 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', '1', 'H');
344 AddToSendBuffer(DeviceExtension
, 4, ESC
, '[', -(int)(CursorX
-1), 'D');
351 ULONG Offset
= DeviceExtension
->TabWidth
- (CursorX
% DeviceExtension
->TabWidth
);
352 for (j
= 0; j
< Offset
; j
++)
354 #ifdef FORCE_POSITION
355 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', -(int)CursorX
, 'H');
357 AddToSendBuffer(DeviceExtension
, 1, ' ');
359 if (CursorX
> Columns
)
369 #ifdef FORCE_POSITION
370 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', -(int)CursorX
, 'H');
372 AddToSendBuffer(DeviceExtension
, 1, *Buffer
);
374 if (CursorX
> Columns
)
377 DPRINT("Y: %lu -> %lu\n", CursorY
, CursorY
+ 1);
379 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', '1', 'H');
386 DPRINT("Y: %lu -> %lu\n", CursorY
, CursorY
- 1);
388 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)1, ';', -(int)(Rows
), 'r');
389 AddToSendBuffer(DeviceExtension
, 2, ESC
, 'D');
390 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[', -(int)CursorY
, ';', -(int)CursorX
, 'H');
395 DeviceExtension
->LogicalOffset
= ((CursorX
-1) + (CursorY
-1) * Columns
) * 2;
397 /* flush output buffer */
398 AddToSendBuffer(DeviceExtension
, 0);
400 /* Call lower driver */
401 IoSkipCurrentIrpStackLocation(Irp
);
402 return IoCallDriver(DeviceExtension
->Common
.LowerDevice
, Irp
);
407 IN PDEVICE_OBJECT DeviceObject
,
410 PIO_STACK_LOCATION Stack
;
411 PSCREEN_DEVICE_EXTENSION DeviceExtension
;
412 PDEVICE_OBJECT SerialDevice
;
415 Stack
= IoGetCurrentIrpStackLocation(Irp
);
416 DeviceExtension
= (PSCREEN_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
417 SerialDevice
= ((PGREEN_DEVICE_EXTENSION
)DeviceExtension
->Green
->DeviceExtension
)->Serial
;
420 DPRINT1("Calling blue\n");
421 IoSkipCurrentIrpStackLocation(Irp
);
422 return IoCallDriver(DeviceExtension
->PreviousBlue
, Irp
);
425 switch (Stack
->Parameters
.DeviceIoControl
.IoControlCode
)
428 case IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
:
430 PCONSOLE_SCREEN_BUFFER_INFO pcsbi
;
431 DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO\n");
433 pcsbi
= (PCONSOLE_SCREEN_BUFFER_INFO
)Irp
->AssociatedIrp
.SystemBuffer
;
435 pcsbi
->dwSize
.X
= DeviceExtension
->Columns
;
436 pcsbi
->dwSize
.Y
= DeviceExtension
->Rows
;
438 pcsbi
->dwCursorPosition
.X
= (SHORT
)(DeviceExtension
->LogicalOffset
% DeviceExtension
->Columns
);
439 pcsbi
->dwCursorPosition
.Y
= (SHORT
)(DeviceExtension
->LogicalOffset
/ DeviceExtension
->Columns
);
441 pcsbi
->wAttributes
= DeviceExtension
->CharAttribute
;
443 pcsbi
->srWindow
.Left
= 1;
444 pcsbi
->srWindow
.Right
= DeviceExtension
->Columns
;
445 pcsbi
->srWindow
.Top
= 1;
446 pcsbi
->srWindow
.Bottom
= DeviceExtension
->Rows
;
448 pcsbi
->dwMaximumWindowSize
.X
= DeviceExtension
->Columns
;
449 pcsbi
->dwMaximumWindowSize
.Y
= DeviceExtension
->Rows
;
451 Irp
->IoStatus
.Information
= sizeof(CONSOLE_SCREEN_BUFFER_INFO
);
452 Status
= STATUS_SUCCESS
;
455 case IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
:
457 PCONSOLE_SCREEN_BUFFER_INFO pcsbi
;
458 DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO\n");
460 pcsbi
= (PCONSOLE_SCREEN_BUFFER_INFO
)Irp
->AssociatedIrp
.SystemBuffer
;
461 /* FIXME: remove */ { pcsbi
->dwCursorPosition
.X
++; }
462 /* FIXME: remove */ { pcsbi
->dwCursorPosition
.Y
++; }
463 ASSERT(pcsbi
->dwCursorPosition
.X
>= 1);
464 ASSERT(pcsbi
->dwCursorPosition
.Y
>= 1);
465 ASSERT(pcsbi
->dwCursorPosition
.X
<= DeviceExtension
->Columns
);
466 ASSERT(pcsbi
->dwCursorPosition
.Y
<= DeviceExtension
->Rows
);
468 DeviceExtension
->LogicalOffset
= (
469 (pcsbi
->dwCursorPosition
.Y
-1) * DeviceExtension
->Columns
+
470 (pcsbi
->dwCursorPosition
.X
-1)) * 2;
471 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[',
472 -(int)pcsbi
->dwCursorPosition
.Y
, ';',
473 -(int)pcsbi
->dwCursorPosition
.X
, 'H');
476 AddToSendBuffer(DeviceExtension
, 0);
478 DeviceExtension
->CharAttribute
= pcsbi
->wAttributes
;
480 Irp
->IoStatus
.Information
= 0;
481 Status
= STATUS_SUCCESS
;
484 case IOCTL_CONSOLE_GET_CURSOR_INFO
:
486 PCONSOLE_CURSOR_INFO pcci
= (PCONSOLE_CURSOR_INFO
)Irp
->AssociatedIrp
.SystemBuffer
;
487 DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_CURSOR_INFO\n");
490 pcci
->bVisible
= TRUE
;
492 Irp
->IoStatus
.Information
= sizeof (CONSOLE_CURSOR_INFO
);
493 Status
= STATUS_SUCCESS
;
496 case IOCTL_CONSOLE_GET_MODE
:
498 PCONSOLE_MODE pcm
= (PCONSOLE_MODE
)Irp
->AssociatedIrp
.SystemBuffer
;
499 DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_MODE\n");
501 pcm
->dwMode
= DeviceExtension
->Mode
;
503 Irp
->IoStatus
.Information
= sizeof(CONSOLE_MODE
);
504 Status
= STATUS_SUCCESS
;
507 case IOCTL_CONSOLE_SET_MODE
:
509 PCONSOLE_MODE pcm
= (PCONSOLE_MODE
)Irp
->AssociatedIrp
.SystemBuffer
;
510 DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_MODE\n");
512 DeviceExtension
->Mode
= pcm
->dwMode
;
514 Irp
->IoStatus
.Information
= 0;
515 Status
= STATUS_SUCCESS
;
518 case IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE
:
520 DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE\n");
521 Status
= STATUS_NOT_IMPLEMENTED
; /* FIXME: IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE */
524 case IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE
:
526 DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE\n");
527 Status
= STATUS_NOT_IMPLEMENTED
; /* FIXME: IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE */
530 case IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE
:
532 DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE\n");
533 Status
= STATUS_NOT_IMPLEMENTED
; /* FIXME: IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE */
536 case IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
:
538 DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE\n");
540 DeviceExtension
->CharAttribute
= (WORD
)*(PWORD
)Irp
->AssociatedIrp
.SystemBuffer
;
541 Irp
->IoStatus
.Information
= 0;
542 Status
= STATUS_SUCCESS
;
545 case IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER
:
547 DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER\n");
548 Status
= STATUS_NOT_IMPLEMENTED
; /* FIXME:IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER */
551 case IOCTL_CONSOLE_READ_OUTPUT_CHARACTER
:
553 DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_CHARACTER\n");
554 Status
= STATUS_NOT_IMPLEMENTED
; /* FIXME: IOCTL_CONSOLE_READ_OUTPUT_CHARACTER */
557 case IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
:
559 DPRINT1("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER\n");
560 Status
= STATUS_NOT_IMPLEMENTED
; /* FIXME: IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER */
563 case IOCTL_CONSOLE_DRAW
:
565 PCONSOLE_DRAW ConsoleDraw
;
568 BOOLEAN DoOptimization
= FALSE
;
569 DPRINT("IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_DRAW\n");
571 ConsoleDraw
= (PCONSOLE_DRAW
)MmGetSystemAddressForMdl(Irp
->MdlAddress
);
572 /* FIXME: remove */ { ConsoleDraw
->X
++; ConsoleDraw
->CursorX
++; }
573 /* FIXME: remove */ { ConsoleDraw
->Y
++; ConsoleDraw
->CursorY
++; }
574 DPRINT1("%lu %lu %lu %lu\n",
575 ConsoleDraw
->X
, ConsoleDraw
->Y
,
576 ConsoleDraw
->SizeX
, ConsoleDraw
->SizeY
);
577 ASSERT(ConsoleDraw
->X
>= 1);
578 ASSERT(ConsoleDraw
->Y
>= 1);
579 ASSERT(ConsoleDraw
->X
<= DeviceExtension
->Columns
);
580 ASSERT(ConsoleDraw
->Y
<= DeviceExtension
->Rows
);
581 ASSERT(ConsoleDraw
->X
+ ConsoleDraw
->SizeX
>= 1);
582 ASSERT(ConsoleDraw
->Y
+ ConsoleDraw
->SizeY
>= 1);
583 ASSERT(ConsoleDraw
->X
+ ConsoleDraw
->SizeX
- 1 <= DeviceExtension
->Columns
);
584 ASSERT(ConsoleDraw
->Y
+ ConsoleDraw
->SizeY
- 1 <= DeviceExtension
->Rows
);
585 ASSERT(ConsoleDraw
->CursorX
>= 1);
586 ASSERT(ConsoleDraw
->CursorY
>= 1);
587 ASSERT(ConsoleDraw
->CursorX
<= DeviceExtension
->Columns
);
588 ASSERT(ConsoleDraw
->CursorY
<= DeviceExtension
->Rows
);
591 if (ConsoleDraw
->X
== 1
592 && ConsoleDraw
->Y
== 1
593 && ConsoleDraw
->SizeX
== DeviceExtension
->Columns
594 && ConsoleDraw
->SizeY
== DeviceExtension
->Rows
)
596 /* search if we need to clear all screen */
597 DoOptimization
= TRUE
;
598 Video
= (PUCHAR
)(ConsoleDraw
+ 1);
600 while (DoOptimization
&& x
< DeviceExtension
->Columns
* DeviceExtension
->Rows
)
602 if (Video
[x
++] != ' ')
604 DoOptimization
= FALSE
;
606 /*if (Video[x++] != DeviceExtension->CharAttribute) DoOptimization = FALSE; */
610 AddToSendBuffer(DeviceExtension
, 4, ESC
, '[', '2', 'J');
614 /* add here more optimizations if needed */
618 for (y
= 0; y
< ConsoleDraw
->SizeY
; y
++)
620 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[',
621 -(int)(ConsoleDraw
->Y
+ y
), ';',
622 -(int)(ConsoleDraw
->X
), 'H');
623 Video
= (PUCHAR
)(ConsoleDraw
+ 1);
624 Video
= &Video
[((ConsoleDraw
->Y
+ y
) * /*DeviceExtension->Columns +*/ ConsoleDraw
->X
) * 2];
625 for (x
= 0; x
< ConsoleDraw
->SizeX
; x
++)
627 AddToSendBuffer(DeviceExtension
, 1, Video
[x
* 2]);
632 DeviceExtension
->LogicalOffset
= (
633 (ConsoleDraw
->CursorY
-1) * DeviceExtension
->Columns
+
634 (ConsoleDraw
->CursorX
-1)) * 2;
635 AddToSendBuffer(DeviceExtension
, 6, ESC
, '[',
636 -(int)(ConsoleDraw
->CursorY
), ';',
637 -(int)(ConsoleDraw
->CursorX
), 'H');
640 AddToSendBuffer(DeviceExtension
, 0);
642 Irp
->IoStatus
.Information
= 0;
643 Status
= STATUS_SUCCESS
;
649 DPRINT1("IRP_MJ_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
650 Stack
->Parameters
.DeviceIoControl
.IoControlCode
);
651 /* Call lower driver */
652 IoSkipCurrentIrpStackLocation(Irp
);
653 return IoCallDriver(DeviceExtension
->Common
.LowerDevice
, Irp
);
657 if (!NT_SUCCESS(Status
))
659 /* Don't call blue (if any), as we encountered an error */
660 Irp
->IoStatus
.Status
= Status
;
661 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
666 /* Call lower driver */
667 IoSkipCurrentIrpStackLocation(Irp
);
668 return IoCallDriver(DeviceExtension
->Common
.LowerDevice
, Irp
);