~ubuntu-branches/ubuntu/lucid/plymouth/lucid

1262 by Scott James Remnant
Include the 16-color VGA frame-buffer renderer. LP: #526892.
1
/* vga.h - inlines for programming the VGA
2
 *
3
 * Copyright (C) 2010 Canonical Ltd.
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2, or (at your option)
8
 * any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18
 * 02111-1307, USA.
19
 *
20
 * Written by: Scott James Remnant <scott@ubuntu.com>
21
 */
22
#ifndef PLY_VGA_H
23
#define PLY_VGA_H
24
25
/* VGA ioports, and the registers we can access from them */
26
#define VGA_REGS_BASE		0x3c0
27
#define VGA_REGS_LEN 		0x10
28
29
#define VGA_SC_INDEX		0x3c4
30
#define VGA_SC_DATA		0x3c5
31
32
#define VGA_SC_MAP_MASK		0x02
33
34
#define VGA_GC_INDEX		0x3ce
35
#define VGA_GC_DATA    		0x3cf
36
37
#define VGA_GC_SET_RESET	0x00
38
#define VGA_GC_ENABLE_SET_RESET	0x01
39
#define VGA_GC_DATA_ROTATE      0x03
40
#define VGA_GC_MODE		0x05
41
#define VGA_GC_BIT_MASK		0x08
42
43
/* Select the VGA write mode. */
44
static inline void
45
vga_mode (int mode)
46
{
47
	outb (VGA_GC_MODE, VGA_GC_INDEX);
48
	outb (mode, VGA_GC_DATA);
49
}
50
51
/* Data Rotate register; we don't use this, we just ensure it's off. */
52
static inline void
53
vga_data_rotate (int op)
54
{
55
	outb (VGA_GC_DATA_ROTATE, VGA_GC_INDEX);
56
	outb (op, VGA_GC_DATA);
57
}
58
59
/* Enable use of the Set/Reset register for the given planes (as a mask).
60
 *
61
 * In effect: set this to 0xf to use all four planes.
62
 */
63
static inline void
64
vga_enable_set_reset (int mask)
65
{
66
	outb (VGA_GC_ENABLE_SET_RESET, VGA_GC_INDEX);
67
	outb (mask, VGA_GC_DATA);
68
}
69
70
/* Set/Reset register; the given planes (as a mask) will have whatever bits
71
 * are true in the Bit Mask register set to 1, and whatever bits are false
72
 * in the Bit Mask register set to 0.  (It's more complicated than that, but
73
 * your brain will explode).
74
 *
75
 * In effect: set this to the colour you want.
76
 */
77
static inline void
78
vga_set_reset (int mask)
79
{
80
	outb (VGA_GC_SET_RESET, VGA_GC_INDEX);
81
	outb (mask, VGA_GC_DATA);
82
}
83
84
/* Bit Mask register; writing to a memory address will write to these bits
85
 * of that byte according to the contents of the Set/Reset register.  Far
86
 * more complicated than that, you *really* don't want to know.
87
 *
88
 * In effect: set this to the pattern we want in the colour we set.
89
 */
90
static inline void
91
vga_bit_mask (int mask)
92
{
93
	outb (VGA_GC_BIT_MASK, VGA_GC_INDEX);
94
	outb (mask, VGA_GC_DATA);
95
}
96
97
/* Map Mask register; we don't use this, but we do make sure it's reset. */
98
static inline void
99
vga_map_mask (int mask)
100
{
101
	outb (VGA_SC_MAP_MASK, VGA_SC_INDEX);
102
	outb (mask, VGA_SC_DATA);
103
}
104
105
#endif /* PLY_VGA_H */
106
/* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
107