Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

port.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1992 Microsoft Corporation 00004 00005 Module Name: 00006 00007 port.c 00008 00009 Abstract: 00010 00011 This is the console fullscreen driver for the VGA card. 00012 00013 Environment: 00014 00015 kernel mode only 00016 00017 Notes: 00018 00019 Revision History: 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 VOID 00031 GetHardwareScrollReg( 00032 PDEVICE_EXTENSION deviceExtension 00033 ) 00034 00035 /*++ 00036 00037 Routine Description: 00038 00039 This routine gets the hardware scrolls register value. 00040 00041 Arguments: 00042 00043 Return Value: 00044 00045 --*/ 00046 00047 { 00048 UCHAR low; 00049 UCHAR high; 00050 UCHAR mid; 00051 00052 WRITE_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCAddressPortColor], 00053 IND_START_ADRS_L); 00054 low = READ_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCDataPortColor]); 00055 00056 WRITE_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCAddressPortColor], 00057 IND_START_ADRS_H); 00058 high = READ_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCDataPortColor]); 00059 00060 deviceExtension->EmulateInfo.StartAddress = MAKEWORD(low, high); 00061 00062 WRITE_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCAddressPortColor], 00063 IND_LINE_COMPARE); 00064 low = READ_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCDataPortColor]); 00065 00066 WRITE_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCAddressPortColor], 00067 IND_LINE_COMPARE8); 00068 mid = READ_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCDataPortColor]); 00069 mid = (mid >> 4) & 1; 00070 00071 WRITE_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCAddressPortColor], 00072 IND_LINE_COMPARE9); 00073 high = READ_PORT_UCHAR(deviceExtension->DeviceRegisters[CRTCDataPortColor]); 00074 high = (high >> 5) & 2; 00075 00076 high |= mid; 00077 deviceExtension->EmulateInfo.LineCompare = MAKEWORD(low, high); 00078 } 00079 00080 VOID 00081 SetGRAMWriteMode( 00082 PDEVICE_EXTENSION deviceExtension 00083 ) 00084 00085 /*++ 00086 00087 Routine Description: 00088 00089 This routine sets the write mode of graphics register. 00090 00091 Arguments: 00092 00093 Return Value: 00094 00095 --*/ 00096 00097 { 00098 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00099 MAKEWORD(IND_GRAPH_MODE, M_PROC_WRITE+M_DATA_READ)); 00100 00101 // 00102 // Set up to write data without interacting with the latches. 00103 // 00104 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00105 MAKEWORD(IND_DATA_ROTATE, DR_SET)); 00106 00107 // 00108 // Enable all the available EGA planes. 00109 // 00110 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[SEQUAddressPort], 00111 MAKEWORD(IND_MAP_MASK, GRAPH_ADDR_MASK)); 00112 // 00113 // Use all pixel positions. 00114 // 00115 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00116 MAKEWORD(IND_BIT_MASK, BIT_MASK_DEFAULT)); 00117 00118 } 00119 00120 VOID 00121 SetGRAMCopyMode( 00122 PDEVICE_EXTENSION deviceExtension 00123 ) 00124 00125 /*++ 00126 00127 Routine Description: 00128 00129 This routine sets the copy mode of graphics register. 00130 00131 Arguments: 00132 00133 Return Value: 00134 00135 --*/ 00136 00137 { 00138 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00139 MAKEWORD(IND_GRAPH_MODE, M_LATCH_WRITE+M_COLOR_READ)); 00140 00141 // 00142 // Set up to write data without interacting with the latches. 00143 // 00144 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00145 MAKEWORD(IND_DATA_ROTATE, DR_SET)); 00146 00147 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00148 MAKEWORD(IND_COLOR_DONT_CARE, 0)); 00149 } 00150 00151 VOID 00152 SetGRAMInvertMode( 00153 PDEVICE_EXTENSION deviceExtension 00154 ) 00155 00156 /*++ 00157 00158 Routine Description: 00159 00160 This routine sets the invert mode of graphics register. 00161 00162 Arguments: 00163 00164 Return Value: 00165 00166 --*/ 00167 00168 { 00169 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00170 MAKEWORD(IND_GRAPH_MODE, M_AND_WRITE+M_COLOR_READ)); 00171 00172 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00173 MAKEWORD(IND_DATA_ROTATE, DR_XOR)); 00174 00175 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00176 MAKEWORD(IND_BIT_MASK, BIT_MASK_DEFAULT)); 00177 00178 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00179 MAKEWORD(IND_COLOR_DONT_CARE, 0)); 00180 00181 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00182 MAKEWORD(IND_SET_RESET, 0xff)); 00183 } 00184 00185 VOID 00186 set_opaque_bkgnd_proc( 00187 PDEVICE_EXTENSION deviceExtension, 00188 PUCHAR FrameBuffer, 00189 WORD Attributes 00190 ) 00191 00192 /*++ 00193 00194 set_opaque_bkgnd 00195 00196 Set the VGA registers for drawing a full screen byte with opaque 00197 font and opaque background. 00198 00199 Created. 00200 00201 --*/ 00202 00203 { 00204 BYTE ColorFg = LOBYTE(Attributes) & 0x0f; 00205 BYTE ColorBg = (LOBYTE(Attributes) & 0xf0) >> 4; 00206 00207 if (Attributes & COMMON_LVB_REVERSE_VIDEO) 00208 { 00209 Attributes = ColorBg; 00210 ColorBg = ColorFg; 00211 ColorFg = (BYTE)Attributes; 00212 } 00213 00214 if (deviceExtension->EmulateInfo.ColorFg == ColorFg && 00215 deviceExtension->EmulateInfo.ColorBg == ColorBg) 00216 return; 00217 00218 deviceExtension->EmulateInfo.ColorFg = ColorFg; 00219 deviceExtension->EmulateInfo.ColorBg = ColorBg; 00220 00221 ColorSetDirect(deviceExtension, FrameBuffer, ColorFg, ColorBg); 00222 } 00223 00224 VOID 00225 ColorSetGridMask( 00226 PDEVICE_EXTENSION deviceExtension, 00227 BYTE BitMask 00228 ) 00229 { 00230 00231 // 00232 // That color is used for all planes. 00233 // 00234 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00235 MAKEWORD(IND_SET_RESET_ENABLE, GRAPH_ADDR_MASK)); 00236 00237 // 00238 // Change the Set/Reset register to be all set. 00239 // 00240 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00241 MAKEWORD(IND_SET_RESET, 0x07)); 00242 00243 // 00244 // Use specified pixel positions. 00245 // 00246 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00247 MAKEWORD(IND_BIT_MASK, BitMask)); 00248 00249 // 00250 // Set up to write data without interacting with the latches. 00251 // 00252 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00253 MAKEWORD(IND_DATA_ROTATE, DR_SET)); 00254 } 00255 00256 VOID 00257 ColorSetDirect( 00258 PDEVICE_EXTENSION deviceExtension, 00259 PUCHAR FrameBuffer, 00260 BYTE ColorFg, 00261 BYTE ColorBg 00262 ) 00263 00264 /*++ 00265 00266 ColorSetDirect 00267 00268 Set the VGA registers for drawing a full screen byte with opaque 00269 font and opaque background. 00270 00271 Created. 00272 00273 --*/ 00274 00275 { 00276 // 00277 // Set up to write data without interacting with the latches. 00278 // 00279 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00280 MAKEWORD(IND_DATA_ROTATE, DR_SET)); 00281 00282 // 00283 // Put the background color in the Set/Reset register. 00284 // 00285 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00286 MAKEWORD(IND_SET_RESET, ColorBg)); 00287 00288 // 00289 // That color is used for all planes. 00290 // 00291 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00292 MAKEWORD(IND_SET_RESET_ENABLE, GRAPH_ADDR_MASK)); 00293 00294 // 00295 // This gets our background color into the latches. 00296 // 00297 AccessGRAM_WR(FrameBuffer, GRAPH_ADDR_MASK); 00298 00299 // 00300 // Change the Set/Reset register to be all zeroes. 00301 // 00302 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00303 MAKEWORD(IND_SET_RESET, 0)); 00304 00305 // 00306 // The Set/Reset enable register now flags where the foreground/background colors are the same. 00307 // 00308 ColorFg = ~(ColorFg ^ ColorBg); 00309 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00310 MAKEWORD(IND_SET_RESET_ENABLE, ColorFg)); 00311 00312 // 00313 // Color differences will be xor'd with the latches. 00314 // 00315 WRITE_PORT_USHORT(deviceExtension->DeviceRegisters[GRAPHAddressPort], 00316 MAKEWORD(IND_DATA_ROTATE, DR_XOR)); 00317 00318 00319 }

Generated on Sat May 15 19:41:24 2004 for test by doxygen 1.3.7