https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aaa416d36afafb0e44ec3…
commit aaa416d36afafb0e44ec3deccd235bdf5f2f61c1
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sat Apr 25 21:34:16 2020 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Sun Apr 26 14:54:09 2020 +0200
[BLUE] Add an IOCTL to directly choose which font to use (instead of codepage)
---
drivers/setup/blue/blue.c | 53 +++++++++++++++++++++++++++--
drivers/setup/blue/blue.h | 1 +
drivers/setup/blue/font.c | 22 ++++++++++++
sdk/include/reactos/drivers/blue/ntddblue.h | 1 +
4 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/drivers/setup/blue/blue.c b/drivers/setup/blue/blue.c
index def5049fa32..1a911689cef 100644
--- a/drivers/setup/blue/blue.c
+++ b/drivers/setup/blue/blue.c
@@ -38,6 +38,7 @@ typedef struct _DEVICE_EXTENSION
USHORT Rows; /* Number of rows */
USHORT Columns; /* Number of columns */
USHORT CursorX, CursorY; /* Cursor position */
+ PUCHAR FontBitfield; /* Specifies the font. If NULL, use CodePage */
ULONG CodePage; /* Specifies the font associated to this code page */
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
@@ -483,8 +484,15 @@ ScrAcquireOwnership(
// DeviceExtension->CursorX = min(max(DeviceExtension->CursorX, 0),
DeviceExtension->Columns - 1);
DeviceExtension->CursorY = min(max(DeviceExtension->CursorY, 0),
DeviceExtension->Rows - 1);
- /* Upload a default font for the current codepage */
- ScrLoadFontTable(DeviceExtension->CodePage);
+ if (DeviceExtension->FontBitfield)
+ {
+ ScrSetFont(DeviceExtension->FontBitfield);
+ }
+ else
+ {
+ /* Upload a default font for the current codepage */
+ ScrLoadFontTable(DeviceExtension->CodePage);
+ }
DPRINT("%d Columns %d Rows %d Scanlines\n",
DeviceExtension->Columns,
@@ -511,6 +519,12 @@ ScrResetScreen(
DeviceExtension->CursorSize = 5; /* FIXME: value correct?? */
DeviceExtension->CursorVisible = TRUE;
+ if (DeviceExtension->FontBitfield)
+ {
+ ExFreePoolWithTag(DeviceExtension->FontBitfield, TAG_BLUE);
+ DeviceExtension->FontBitfield = NULL;
+ }
+
/* More initialization */
DeviceExtension->CharAttribute = BACKGROUND_BLUE | FOREGROUND_LIGHTGRAY;
DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
@@ -1496,6 +1510,11 @@ ScrIoControl(
}
ASSERT(Irp->AssociatedIrp.SystemBuffer);
+ if (DeviceExtension->FontBitfield)
+ {
+ ExFreePoolWithTag(DeviceExtension->FontBitfield, TAG_BLUE);
+ DeviceExtension->FontBitfield = NULL;
+ }
DeviceExtension->CodePage = *(PULONG)Irp->AssociatedIrp.SystemBuffer;
/* Upload a font for the codepage if needed */
@@ -1507,6 +1526,36 @@ ScrIoControl(
break;
}
+ case IOCTL_CONSOLE_SETFONT:
+ {
+ /* Validate input buffer */
+ if (stk->Parameters.DeviceIoControl.InputBufferLength < 256 * 8)
+ {
+ Status = STATUS_INVALID_PARAMETER;
+ break;
+ }
+ ASSERT(Irp->AssociatedIrp.SystemBuffer);
+
+ DeviceExtension->CodePage = 0;
+ if (DeviceExtension->FontBitfield)
+ ExFreePoolWithTag(DeviceExtension->FontBitfield, TAG_BLUE);
+ DeviceExtension->FontBitfield = ExAllocatePoolWithTag(NonPagedPool, 256 *
8, TAG_BLUE);
+ if (!DeviceExtension->FontBitfield)
+ {
+ Status = STATUS_NO_MEMORY;
+ break;
+ }
+ RtlCopyMemory(DeviceExtension->FontBitfield,
Irp->AssociatedIrp.SystemBuffer, 256 * 8);
+
+ /* Upload the font if needed */
+ if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
+ ScrSetFont(DeviceExtension->FontBitfield);
+
+ Irp->IoStatus.Information = 0;
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
default:
Status = STATUS_NOT_IMPLEMENTED;
}
diff --git a/drivers/setup/blue/blue.h b/drivers/setup/blue/blue.h
index 335313abe15..3a3af7a4511 100644
--- a/drivers/setup/blue/blue.h
+++ b/drivers/setup/blue/blue.h
@@ -145,5 +145,6 @@ typedef struct _CFFILE
#define PELDATA (PUCHAR)0x3c9
VOID ScrLoadFontTable(_In_ ULONG CodePage);
+VOID ScrSetFont(_In_ PUCHAR FontBitfield);
#endif /* _BLUE_PCH_ */
diff --git a/drivers/setup/blue/font.c b/drivers/setup/blue/font.c
index 11f2438dd73..69b3651c49d 100644
--- a/drivers/setup/blue/font.c
+++ b/drivers/setup/blue/font.c
@@ -62,6 +62,28 @@ ScrLoadFontTable(
CloseBitPlane();
}
+VOID
+ScrSetFont(
+ _In_ PUCHAR FontBitfield)
+{
+ PHYSICAL_ADDRESS BaseAddress;
+ PUCHAR Bitplane;
+
+ /* open bit plane for font table access */
+ OpenBitPlane();
+
+ /* get pointer to video memory */
+ BaseAddress.QuadPart = BITPLANE_BASE;
+ Bitplane = (PUCHAR)MmMapIoSpace(BaseAddress, 0xFFFF, MmNonCached);
+
+ LoadFont(Bitplane, FontBitfield);
+
+ MmUnmapIoSpace(Bitplane, 0xFFFF);
+
+ /* close bit plane */
+ CloseBitPlane();
+}
+
/* PRIVATE FUNCTIONS *********************************************************/
NTSTATUS
diff --git a/sdk/include/reactos/drivers/blue/ntddblue.h
b/sdk/include/reactos/drivers/blue/ntddblue.h
index 0d41d0f158d..1c6d22e5008 100644
--- a/sdk/include/reactos/drivers/blue/ntddblue.h
+++ b/sdk/include/reactos/drivers/blue/ntddblue.h
@@ -22,6 +22,7 @@
#define IOCTL_CONSOLE_DRAW CTL_CODE(FILE_DEVICE_SCREEN, 0x830,
METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
#define IOCTL_CONSOLE_LOADFONT CTL_CODE(FILE_DEVICE_SCREEN, 0x840,
METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
+#define IOCTL_CONSOLE_SETFONT CTL_CODE(FILE_DEVICE_SCREEN, 0x841,
METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
/* TYPEDEFS **************************************************************/