xref: /inferno-os/os/pc/vga.h (revision 74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a)
1 /*
2  * Generic VGA registers.
3  */
4 enum {
5 	MiscW		= 0x03C2,	/* Miscellaneous Output (W) */
6 	MiscR		= 0x03CC,	/* Miscellaneous Output (R) */
7 	Status0		= 0x03C2,	/* Input status 0 (R) */
8 	Status1		= 0x03DA,	/* Input Status 1 (R) */
9 	FeatureR	= 0x03CA,	/* Feature Control (R) */
10 	FeatureW	= 0x03DA,	/* Feature Control (W) */
11 
12 	Seqx		= 0x03C4,	/* Sequencer Index, Data at Seqx+1 */
13 	Crtx		= 0x03D4,	/* CRT Controller Index, Data at Crtx+1 */
14 	Grx		= 0x03CE,	/* Graphics Controller Index, Data at Grx+1 */
15 	Attrx		= 0x03C0,	/* Attribute Controller Index and Data */
16 
17 	PaddrW		= 0x03C8,	/* Palette Address Register, write */
18 	Pdata		= 0x03C9,	/* Palette Data Register */
19 	Pixmask		= 0x03C6,	/* Pixel Mask Register */
20 	PaddrR		= 0x03C7,	/* Palette Address Register, read */
21 	Pstatus		= 0x03C7,	/* DAC Status (RO) */
22 
23 	Pcolours	= 256,		/* Palette */
24 	Pred		= 0,
25 	Pgreen		= 1,
26 	Pblue		= 2,
27 
28 	Pblack		= 0x00,
29 	Pwhite		= 0xFF,
30 };
31 
32 #define vgai(port)		inb(port)
33 #define vgao(port, data)	outb(port, data)
34 
35 extern int vgaxi(long, uchar);
36 extern int vgaxo(long, uchar, uchar);
37 
38 typedef struct Cursor Cursor;
39 struct	Cursor
40 {
41 	Point	offset;
42 	uchar	clr[2*16];
43 	uchar	set[2*16];
44 };
45 
46 /*
47  * First pass at tidying this up...
48  */
49 typedef struct Mode {
50 	int	x;
51 	int	y;
52 	int	d;
53 
54 	ulong	aperture;		/* this is a physical address */
55 	int	apsize;
56 	int	apshift;
57 } Mode;
58 
59 /*
60  * Definitions of known VGA controllers.
61  */
62 typedef struct Vgac Vgac;
63 struct Vgac {
64 	char*	name;
65 	void	(*page)(int);
66 	void	(*init)(Mode*);
67 	int	(*ident)(void);
68 	void	(*enable)(void);
69 	void	(*disable)(void);
70 	void	(*move)(int, int);
71 	void	(*load)(Cursor*);
72 	Vgac*	link;
73 };
74 
75 extern void addvgaclink(Vgac*);
76