Nuke unused macro and comment
[dragonfly.git] / usr.bin / doscmd / video.h
blob4ab6244558b337859eb8c914b50479257d69e964
1 /*
2 * Copyright (c) 1992, 1993, 1996
3 * Berkeley Software Design, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Berkeley Software
16 * Design, Inc.
18 * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
30 * BSDI video.h,v 2.2 1996/04/08 19:33:12 bostic Exp
32 * $FreeBSD: src/usr.bin/doscmd/video.h,v 1.2.2.1 2002/04/25 11:04:51 tg Exp $
33 * $DragonFly: src/usr.bin/doscmd/video.h,v 1.2 2003/06/17 04:29:26 dillon Exp $
37 * The VGA CRT Controller
39 extern u_int8_t VGA_CRTC[];
41 /* CRTC registers
43 We use the VGA register functions and don't care about the MDA. We also
44 leave out the undocumented registers at 0x22, 0x24, 0x3?. */
45 #define CRTC_HorzTotal 0x00
46 #define CRTC_HorzDispEnd 0x01
47 #define CRTC_StartHorzBlank 0x02
48 #define CRTC_EndHorzBlank 0x03
49 #define CRTC_StartHorzRetrace 0x04
50 #define CRTC_EndHorzRetrace 0x05
51 #define CRTC_VertTotal 0x06
52 #define CRTC_Overflow 0x07
53 #define CRTC_ResetRowScan 0x08
54 #define CRTC_MaxScanLine 0x09
55 #define CRTC_CursStart 0x0a
56 #define CRTC_CursEnd 0x0b
57 #define CRTC_StartAddrHi 0x0c
58 #define CRTC_StartAddrLo 0x0d
59 #define CRTC_CurLocHi 0x0e
60 #define CRTC_CurLocLo 0x0f
61 #define CRTC_StartVertRetrace 0x10
62 #define CRTC_EndVertRetrace 0x11
63 #define CRTC_VertDispEnd 0x12
64 #define CRTC_Offset 0x13
65 #define CRTC_UnderlineLoc 0x14
66 #define CRTC_StartVertBlank 0x15
67 #define CRTC_EndVertBlank 0x16
68 #define CRTC_ModeCtrl 0x17
69 #define CRTC_LineCompare 0x18
71 #define CRTC_Size 0x19
73 /* Port addresses for the CRTC
75 The registers are read by
76 OUT index_port, reg_nr
77 IN data_port, res
79 They are written by
80 OUT index_port, reg_nr
81 OUT data_port, value
84 #define CRTC_IndexPortColor 0x03d4 /* CRTC Address Register (Color) */
85 #define CRTC_DataPortColor 0x03d5 /* CRTC Data Register (Color) */
86 #define CRTC_IndexPortMono 0x03b4 /* CRTC Address Register (Mono) */
87 #define CRTC_DataPortMono 0x03b5 /* CRTC Data Register (Mono) */
90 * VGA Attribute Controller
92 extern u_int8_t VGA_ATC[];
94 /* ATC registers
96 The palette registers are here for completeness. We'll always use a
97 separate array 'palette[]' to access them in our code. */
98 #define ATC_Palette0 0x00
99 #define ATC_Palette1 0x01
100 #define ATC_Palette2 0x02
101 #define ATC_Palette3 0x03
102 #define ATC_Palette4 0x04
103 #define ATC_Palette5 0x05
104 #define ATC_Palette6 0x06
105 #define ATC_Palette7 0x07
106 #define ATC_Palette8 0x08
107 #define ATC_Palette9 0x09
108 #define ATC_PaletteA 0x0a
109 #define ATC_PaletteB 0x0b
110 #define ATC_PaletteC 0x0c
111 #define ATC_PaletteD 0x0d
112 #define ATC_PaletteE 0x0e
113 #define ATC_PaletteF 0x0f
114 #define ATC_ModeCtrl 0x10
115 #define ATC_OverscanColor 0x11
116 #define ATC_ColorPlaneEnable 0x12
117 #define ATC_HorzPixelPanning 0x13
118 #define ATC_ColorSelect 0x14
120 #define ATC_Size 0x15
122 /* Port addresses for the ATC
124 The ATC has a combined index/data port at 0x03c0. To quote from Ralf
125 Brown's ports list: ``Every write access to this register will toggle an
126 internal index/data selection flipflop, so that consecutive writes to index
127 & data is possible through this port. To get a defined start condition,
128 each read access to the input status register #1 (3BAh in mono / 3DAh in
129 color) resets the flipflop to load index.'' */
130 #define ATC_WritePort 0x03c0
131 #define ATC_ReadPort 0x03c1
134 * VGA Sequencer Controller
136 extern u_int8_t VGA_TSC[];
138 /* TSC registers
140 We leave out the undocumented register at 0x07. */
141 #define TSC_Reset 0x00
142 #define TSC_ClockingMode 0x01
143 #define TSC_MapMask 0x02
144 #define TSC_CharMapSelect 0x03
145 #define TSC_MemoryMode 0x04
147 #define TSC_Size 0x05
149 /* Port addresses for the TSC */
150 #define TSC_IndexPort 0x03c4
151 #define TSC_DataPort 0x03c5
154 * VGA Graphics Controller
156 extern u_int8_t VGA_GDC[];
158 /* GDC registers */
159 #define GDC_SetReset 0x00
160 #define GDC_EnableSetReset 0x01
161 #define GDC_ColorCompare 0x02
162 #define GDC_DataRotate 0x03
163 #define GDC_ReadMapSelect 0x04
164 #define GDC_Mode 0x05
165 #define GDC_Misc 0x06
166 #define GDC_ColorDontCare 0x07
167 #define GDC_BitMask 0x08
169 #define GDC_Size 0x09
171 /* Port addresses for the GDC */
172 #define GDC_IndexPort 0x03ce
173 #define GDC_DataPort 0x03cf
176 * Miscellaneous VGA registers
178 u_int8_t VGA_InputStatus0;
179 u_int8_t VGA_InputStatus1;
180 u_int8_t VGA_MiscOutput;
182 u_int8_t VGA_DAC_PELData;
183 u_int8_t VGA_DAC_PELMask;
184 u_int8_t VGA_DAC_PELReadAddr;
185 u_int8_t VGA_DAC_PELWriteAddr;
186 u_int8_t VGA_DAC_State;
188 /* Port addresses for miscellaneous VGA registers */
189 #define VGA_InputStatus0Port 0x03c2 /* Read-only */
190 #define VGA_InputStatus1Port 0x03da /* Read-only */
191 #define VGA_MiscOutputPortW 0x03c2 /* Write-only */
192 #define VGA_MiscOutputPortR 0x03cc /* Read-only */
194 /* Port addresses for VGA DAC registers */
195 #define VGA_DAC_PELDataPort 0x03c9 /* Read/Write */
196 #define VGA_DAC_PELMaskPort 0x03c6 /* Read/Write */
197 #define VGA_DAC_PELReadAddrPort 0x03c7 /* Write-only */
198 #define VGA_DAC_PELWriteAddrPort 0x03c8 /* Read/Write */
199 #define VGA_DAC_StatePortOut 0x03c7 /* Read-only */
202 * Additional variables and type definitions
205 /* To ease access to the palette registers, 'palette[]' will overlay the
206 Attribute Controller space. */
207 u_int8_t *palette;
209 /* Entry type for the DAC table. Each value is actually 6 bits wide. */
210 struct dac_colors {
211 u_int8_t red;
212 u_int8_t green;
213 u_int8_t blue;
216 /* We need a working copy of the default DAC table. This is filled from
217 'dac_default{64,256}[]' in 'video.c:init_vga()'. */
218 struct dac_colors *dac_rgb;
221 * Video memory
223 * The video memory of a standard VGA card is 256K. For the standard modes,
224 * this is divided into four planes of 64K which are accessed according to the
225 * GDC state. Mode 0x13 will also fit within 64K. The higher resolution modes
226 * (VESA) require a bit more sophistication; we leave that for later
227 * implementation.
230 /* Video RAM */
231 u_int8_t *vram;
233 /* Pointers to the four bit planes */
234 u_int8_t *vplane0;
235 u_int8_t *vplane1;
236 u_int8_t *vplane2;
237 u_int8_t *vplane3;
239 /* Pointer to the video memory. The base address varies with the video mode.
240 'vmem' is used directly only in the text modes; in the graphics modes, all
241 writes go to 'vram'. */
242 u_int16_t *vmem;
245 * VGA status information
247 * Int 10:1b returns a 64 byte block of status info for the VGA card. This
248 * block also contains a couple of BIOS variables, so we will use it for
249 * general housekeeping.
251 extern u_int8_t vga_status[];
253 /* Access to the VGA status fields. */
254 #define StaticFuncTbl *(u_int32_t *)&vga_status[0]
255 #define VideoMode *(u_int8_t *)&vga_status[4]
256 #define DpyCols *(u_int16_t *)&vga_status[5]
257 #define DpyPageSize *(u_int16_t *)&vga_status[7]
258 #define ActivePageOfs *(u_int16_t *)&vga_status[9]
259 #define CursCol0 *(u_int8_t *)&vga_status[11]
260 #define CursRow0 *(u_int8_t *)&vga_status[12]
261 #define CursCol1 *(u_int8_t *)&vga_status[13]
262 #define CursRow1 *(u_int8_t *)&vga_status[14]
263 #define CursCol2 *(u_int8_t *)&vga_status[15]
264 #define CursRow2 *(u_int8_t *)&vga_status[16]
265 #define CursCol3 *(u_int8_t *)&vga_status[17]
266 #define CursRow3 *(u_int8_t *)&vga_status[18]
267 #define CursCol4 *(u_int8_t *)&vga_status[19]
268 #define CursRow4 *(u_int8_t *)&vga_status[20]
269 #define CursCol5 *(u_int8_t *)&vga_status[21]
270 #define CursRow5 *(u_int8_t *)&vga_status[22]
271 #define CursCol6 *(u_int8_t *)&vga_status[23]
272 #define CursRow6 *(u_int8_t *)&vga_status[24]
273 #define CursCol7 *(u_int8_t *)&vga_status[25]
274 #define CursRow7 *(u_int8_t *)&vga_status[26]
275 #define CursStart *(u_int8_t *)&vga_status[27]
276 #define CursEnd *(u_int8_t *)&vga_status[28]
277 #define ActivePage *(u_int8_t *)&vga_status[29]
278 #define CRTCPort *(u_int16_t *)&vga_status[30]
279 #define CGA_ModeCtrl *(u_int8_t *)&vga_status[32]
280 #define CGA_ColorSelect *(u_int8_t *)&vga_status[33]
281 #define DpyRows *(u_int8_t *)&vga_status[34]
282 #define CharHeight *(u_int16_t *)&vga_status[35]
283 #define ActiveDCC *(u_int8_t *)&vga_status[37]
284 #define SecondDCC *(u_int8_t *)&vga_status[38]
285 #define NumColors *(u_int16_t *)&vga_status[39]
286 #define NumPages *(u_int8_t *)&vga_status[41]
287 #define VertResolution *(u_int8_t *)&vga_status[42]
288 #define PrimaryCharset *(u_int8_t *)&vga_status[43]
289 #define SecondaryCharset *(u_int8_t *)&vga_status[44]
290 #define MiscStatus *(u_int8_t *)&vga_status[45]
292 #define Reserved1 *(u_int16_t *)&vga_status[46]
293 #define Reserved2 *(u_int8_t *)&vga_status[48]
295 #define VMemSize *(u_int8_t *)&vga_status[49]
296 #define SavePointerStatus *(u_int8_t *)&vga_status[50]
298 /* VGA Static Functionality Table
300 This table contains mode-independent VGA status information. It is actually
301 defined in 'vparam.h'; the declaration here is just for completeness. */
302 extern u_int8_t static_functionality_tbl[];
304 /* Add some names for the VGA related BIOS variables. */
305 #define BIOS_VideoMode *(u_int8_t *)&BIOSDATA[0x49]
306 #define BIOS_DpyCols *(u_int16_t *)&BIOSDATA[0x4a]
307 #define BIOS_DpyPageSize *(u_int16_t *)&BIOSDATA[0x4c]
308 #define BIOS_ActivePageOfs *(u_int16_t *)&BIOSDATA[0x4e]
309 #define BIOS_CursCol0 *(u_int8_t *)&BIOSDATA[0x50]
310 #define BIOS_CursRow0 *(u_int8_t *)&BIOSDATA[0x51]
311 #define BIOS_CursCol1 *(u_int8_t *)&BIOSDATA[0x52]
312 #define BIOS_CursRow1 *(u_int8_t *)&BIOSDATA[0x53]
313 #define BIOS_CursCol2 *(u_int8_t *)&BIOSDATA[0x54]
314 #define BIOS_CursRow2 *(u_int8_t *)&BIOSDATA[0x55]
315 #define BIOS_CursCol3 *(u_int8_t *)&BIOSDATA[0x56]
316 #define BIOS_CursRow3 *(u_int8_t *)&BIOSDATA[0x57]
317 #define BIOS_CursCol4 *(u_int8_t *)&BIOSDATA[0x58]
318 #define BIOS_CursRow4 *(u_int8_t *)&BIOSDATA[0x59]
319 #define BIOS_CursCol5 *(u_int8_t *)&BIOSDATA[0x5a]
320 #define BIOS_CursRow5 *(u_int8_t *)&BIOSDATA[0x5b]
321 #define BIOS_CursCol6 *(u_int8_t *)&BIOSDATA[0x5c]
322 #define BIOS_CursRow6 *(u_int8_t *)&BIOSDATA[0x5d]
323 #define BIOS_CursCol7 *(u_int8_t *)&BIOSDATA[0x5e]
324 #define BIOS_CursRow7 *(u_int8_t *)&BIOSDATA[0x5f]
325 #define BIOS_CursStart *(u_int8_t *)&BIOSDATA[0x60]
326 #define BIOS_CursEnd *(u_int8_t *)&BIOSDATA[0x61]
327 #define BIOS_ActivePage *(u_int8_t *)&BIOSDATA[0x62]
328 #define BIOS_CRTCPort *(u_int16_t *)&BIOSDATA[0x63]
329 #define BIOS_CGA_ModeCtrl *(u_int8_t *)&BIOSDATA[0x65]
330 #define BIOS_CGA_ColorSelect *(u_int8_t *)&BIOSDATA[0x66]
331 #define BIOS_DpyRows *(u_int8_t *)&BIOSDATA[0x84]
332 #define BIOS_CharHeight *(u_int16_t *)&BIOSDATA[0x85]
333 #define BIOS_SaveTablePointer *(u_int32_t *)&BIOSDATA[0xa8]
336 * Video modes
338 * This started as a big 'switch' statement in 'video.c:init_mode()' which
339 * soon became too ugly and unmanagable. So, we collect all mode related
340 * information in one table and define a couple of helper function to access
341 * it. This will also benefit the VESA support, whenever we get to that.
343 typedef struct {
344 int modenumber; /* Mode number */
345 int paramindex; /* Index into the parameter table */
346 int type; /* Text or Graphics */
347 int numcolors; /* Number of colors */
348 int numpages; /* Number of display pages */
349 int vrescode; /* 0 = 200, 1 = 350, 2 = 400, 3 = 480 */
350 u_int32_t vmemaddr; /* Video memory address */
351 const char *fontname; /* Font name */
352 } vmode_t;
354 /* Types. 'NOMODE' is one of the 'forbidden' internal modes. */
355 #define TEXT 0
356 #define GRAPHICS 1
357 #define NOMODE -1
359 extern vmode_t vmodelist[];
361 /* Font names */
362 #define FONTVGA "vga"
363 #define FONT8x8 "vga8x8"
364 #define FONT8x14 "vga8x14"
365 #define FONT8x16 "vga8x16" /* same as FONTVGA */
367 /* External functions in 'video.c'. */
368 void init_mode(int);
369 int find_vmode(int);
370 u_int8_t vga_read(u_int32_t);
371 void vga_write(u_int32_t, u_int8_t);
372 void video_bios_init(void);
373 void video_init(void);
374 int vmem_pageflt(struct sigframe *);
376 /* Other external variables, mostly from tty.c. Needs to be cleaned up. */
377 extern int vattr;
378 void write_vram(void *);