mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 17:05:45 +00:00
[0.4.11][BLUE] Optimize ScrIoControl for speed (#5185)
Optimize IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE and IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER for speed by using cache. a part of CORE-18838 It is faster because it minimizes the amount of pointer dereferences within the for-loops. fix picked from 0.4.15-dev-5881-g3526ffc094
--------- also partially pick unrelated cleanup from: 0.4.14-dev-439-g75f188c200
(only the change in blue.c) --------- and take back with me some whitespace-tweaks to bring the file closer to todays releases/0.4.14
This commit is contained in:
parent
9facbf6b7f
commit
8783260051
1 changed files with 122 additions and 134 deletions
|
@ -1,11 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: services/dd/blue/blue.c
|
* PURPOSE: Driver Management Functions.
|
||||||
* PURPOSE: Console (blue screen) device driver
|
|
||||||
* PROGRAMMER: Eric Kohl
|
* PROGRAMMER: Eric Kohl
|
||||||
* UPDATE HISTORY:
|
|
||||||
* ??? Created
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
@ -15,20 +12,11 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
// ROS Internal. Please deprecate.
|
|
||||||
NTHALAPI
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
HalQueryDisplayOwnership(
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
/* NOTES ******************************************************************/
|
/* NOTES ******************************************************************/
|
||||||
/*
|
/*
|
||||||
* [[character][attribute]][[character][attribute]]....
|
* [[character][attribute]][[character][attribute]]....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* TYPEDEFS ***************************************************************/
|
/* TYPEDEFS ***************************************************************/
|
||||||
|
|
||||||
typedef struct _DEVICE_EXTENSION
|
typedef struct _DEVICE_EXTENSION
|
||||||
|
@ -139,7 +127,7 @@ ScrSetRegisters(const VGA_REGISTERS *Registers)
|
||||||
WRITE_PORT_UCHAR(ATTRIB, Registers->Attribute[i]);
|
WRITE_PORT_UCHAR(ATTRIB, Registers->Attribute[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the PEL mask. */
|
/* Set the PEL mask */
|
||||||
WRITE_PORT_UCHAR(PELMASK, 0xff);
|
WRITE_PORT_UCHAR(PELMASK, 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +140,7 @@ ScrAcquireOwnership(PDEVICE_EXTENSION DeviceExtension)
|
||||||
|
|
||||||
ScrSetRegisters(&VidpMode3Regs);
|
ScrSetRegisters(&VidpMode3Regs);
|
||||||
|
|
||||||
/* Disable screen and enable palette access. */
|
/* Disable screen and enable palette access */
|
||||||
READ_PORT_UCHAR(STATUS);
|
READ_PORT_UCHAR(STATUS);
|
||||||
WRITE_PORT_UCHAR(ATTRIB, 0x00);
|
WRITE_PORT_UCHAR(ATTRIB, 0x00);
|
||||||
|
|
||||||
|
@ -164,7 +152,7 @@ ScrAcquireOwnership(PDEVICE_EXTENSION DeviceExtension)
|
||||||
WRITE_PORT_UCHAR(PELDATA, DefaultPalette[Index * 3 + 2] >> 2);
|
WRITE_PORT_UCHAR(PELDATA, DefaultPalette[Index * 3 + 2] >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable screen and disable palette access. */
|
/* Enable screen and disable palette access */
|
||||||
READ_PORT_UCHAR(STATUS);
|
READ_PORT_UCHAR(STATUS);
|
||||||
WRITE_PORT_UCHAR(ATTRIB, 0x20);
|
WRITE_PORT_UCHAR(ATTRIB, 0x20);
|
||||||
|
|
||||||
|
@ -205,8 +193,7 @@ ScrAcquireOwnership(PDEVICE_EXTENSION DeviceExtension)
|
||||||
data | ((DeviceExtension->ScanLines - 1) & 0x1F));
|
data | ((DeviceExtension->ScanLines - 1) & 0x1F));
|
||||||
|
|
||||||
/* calculate number of text rows */
|
/* calculate number of text rows */
|
||||||
DeviceExtension->Rows =
|
DeviceExtension->Rows = DeviceExtension->Rows / DeviceExtension->ScanLines;
|
||||||
DeviceExtension->Rows / DeviceExtension->ScanLines;
|
|
||||||
#ifdef BOCHS_30ROWS
|
#ifdef BOCHS_30ROWS
|
||||||
DeviceExtension->Rows = 30;
|
DeviceExtension->Rows = 30;
|
||||||
#endif
|
#endif
|
||||||
|
@ -242,7 +229,7 @@ ScrCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* store dummy values here */
|
/* Store dummy values */
|
||||||
DeviceExtension->Columns = 1;
|
DeviceExtension->Columns = 1;
|
||||||
DeviceExtension->Rows = 1;
|
DeviceExtension->Rows = 1;
|
||||||
DeviceExtension->ScanLines = 1;
|
DeviceExtension->ScanLines = 1;
|
||||||
|
@ -261,7 +248,7 @@ ScrCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return (Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH ScrWrite;
|
static DRIVER_DISPATCH ScrWrite;
|
||||||
|
@ -304,7 +291,7 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
cursory = offset / columns;
|
cursory = offset / columns;
|
||||||
cursorx = offset % columns;
|
cursorx = offset % columns;
|
||||||
if( processed == 0 )
|
if (!processed)
|
||||||
{
|
{
|
||||||
/* raw output mode */
|
/* raw output mode */
|
||||||
// FIXME: Does the buffer only contains chars? or chars + attributes?
|
// FIXME: Does the buffer only contains chars? or chars + attributes?
|
||||||
|
@ -587,6 +574,8 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
if (!InbvCheckDisplayOwnership())
|
if (!InbvCheckDisplayOwnership())
|
||||||
{
|
{
|
||||||
|
UCHAR attr = Buf->wAttribute;
|
||||||
|
|
||||||
vidmem = DeviceExtension->VideoMemory;
|
vidmem = DeviceExtension->VideoMemory;
|
||||||
offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
|
offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
|
||||||
(Buf->dwCoord.X * 2) + 1;
|
(Buf->dwCoord.X * 2) + 1;
|
||||||
|
@ -597,7 +586,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
||||||
{
|
{
|
||||||
vidmem[offset + (dwCount * 2)] = (char) Buf->wAttribute;
|
vidmem[offset + (dwCount * 2)] = attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,6 +705,8 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
if (!InbvCheckDisplayOwnership())
|
if (!InbvCheckDisplayOwnership())
|
||||||
{
|
{
|
||||||
|
UCHAR ch = Buf->cCharacter;
|
||||||
|
|
||||||
vidmem = DeviceExtension->VideoMemory;
|
vidmem = DeviceExtension->VideoMemory;
|
||||||
offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
|
offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
|
||||||
(Buf->dwCoord.X * 2);
|
(Buf->dwCoord.X * 2);
|
||||||
|
@ -726,7 +717,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
||||||
{
|
{
|
||||||
vidmem[offset + (dwCount * 2)] = (char) Buf->cCharacter;
|
vidmem[offset + (dwCount * 2)] = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,14 +893,12 @@ ScrDispatch(PDEVICE_OBJECT DeviceObject,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Module entry point
|
* Module entry point
|
||||||
*/
|
*/
|
||||||
|
@ -936,7 +925,6 @@ DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
FILE_DEVICE_SECURE_OPEN,
|
FILE_DEVICE_SECURE_OPEN,
|
||||||
TRUE,
|
TRUE,
|
||||||
&DeviceObject);
|
&DeviceObject);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue