1 /* 2 * PROJECT: ReactOS Console Text-Mode Device Driver 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: Loading specific fonts into VGA. 5 * COPYRIGHT: Copyright 2008-2019 Aleksey Bragin (aleksey@reactos.org) 6 * Copyright 2008-2019 Colin Finck (mail@colinfinck.de) 7 * Copyright 2008-2019 Christoph von Wittich (christoph_vw@reactos.org) 8 */ 9 10 /* INCLUDES ***************************************************************/ 11 12 #include "blue.h" 13 14 // 15 // FIXME: For the moment we support only a fixed 256-char 8-bit font. 16 // 17 18 VOID OpenBitPlane(VOID); 19 VOID CloseBitPlane(VOID); 20 VOID LoadFont(_In_ PUCHAR Bitplane, _In_ PUCHAR FontBitfield); 21 22 /* FUNCTIONS ****************************************************************/ 23 24 VOID 25 ScrSetFont( 26 _In_ PUCHAR FontBitfield) 27 { 28 PHYSICAL_ADDRESS BaseAddress; 29 PUCHAR Bitplane; 30 31 /* open bit plane for font table access */ 32 OpenBitPlane(); 33 34 /* get pointer to video memory */ 35 BaseAddress.QuadPart = BITPLANE_BASE; 36 Bitplane = (PUCHAR)MmMapIoSpace(BaseAddress, 0xFFFF, MmNonCached); 37 38 LoadFont(Bitplane, FontBitfield); 39 40 MmUnmapIoSpace(Bitplane, 0xFFFF); 41 42 /* close bit plane */ 43 CloseBitPlane(); 44 } 45 46 /* PRIVATE FUNCTIONS *********************************************************/ 47 48 /* Font-load specific funcs */ 49 VOID 50 OpenBitPlane(VOID) 51 { 52 /* disable interrupts */ 53 _disable(); 54 55 /* sequence reg */ 56 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_RESET); WRITE_PORT_UCHAR(SEQ_DATA, 0x01); 57 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_ENABLE_WRT_PLANE); WRITE_PORT_UCHAR(SEQ_DATA, 0x04); 58 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_MEM_MODE); WRITE_PORT_UCHAR(SEQ_DATA, 0x07); 59 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_RESET); WRITE_PORT_UCHAR(SEQ_DATA, 0x03); 60 61 /* graphic reg */ 62 WRITE_PORT_UCHAR(GCT_COMMAND, GCT_READ_PLANE); WRITE_PORT_UCHAR(GCT_DATA, 0x02); 63 WRITE_PORT_UCHAR(GCT_COMMAND, GCT_RW_MODES); WRITE_PORT_UCHAR(GCT_DATA, 0x00); 64 WRITE_PORT_UCHAR(GCT_COMMAND, GCT_GRAPH_MODE); WRITE_PORT_UCHAR(GCT_DATA, 0x00); 65 66 /* enable interrupts */ 67 _enable(); 68 } 69 70 VOID 71 CloseBitPlane(VOID) 72 { 73 /* disable interrupts */ 74 _disable(); 75 76 /* sequence reg */ 77 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_RESET); WRITE_PORT_UCHAR(SEQ_DATA, 0x01); 78 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_ENABLE_WRT_PLANE); WRITE_PORT_UCHAR(SEQ_DATA, 0x03); 79 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_MEM_MODE); WRITE_PORT_UCHAR(SEQ_DATA, 0x03); 80 WRITE_PORT_UCHAR(SEQ_COMMAND, SEQ_RESET); WRITE_PORT_UCHAR(SEQ_DATA, 0x03); 81 82 /* graphic reg */ 83 WRITE_PORT_UCHAR(GCT_COMMAND, GCT_READ_PLANE); WRITE_PORT_UCHAR(GCT_DATA, 0x00); 84 WRITE_PORT_UCHAR(GCT_COMMAND, GCT_RW_MODES); WRITE_PORT_UCHAR(GCT_DATA, 0x10); 85 WRITE_PORT_UCHAR(GCT_COMMAND, GCT_GRAPH_MODE); WRITE_PORT_UCHAR(GCT_DATA, 0x0e); 86 87 /* enable interrupts */ 88 _enable(); 89 } 90 91 VOID 92 LoadFont( 93 _In_ PUCHAR Bitplane, 94 _In_ PUCHAR FontBitfield) 95 { 96 UINT32 i, j; 97 98 for (i = 0; i < 256; i++) 99 { 100 for (j = 0; j < 8; j++) 101 { 102 *Bitplane = FontBitfield[i * 8 + j]; 103 Bitplane++; 104 } 105 106 // padding 107 for (j = 8; j < 32; j++) 108 { 109 *Bitplane = 0; 110 Bitplane++; 111 } 112 } 113 } 114