1 /*
2 Copyright 2008 Haiku, Inc. All rights reserved.
3 Distributed under the terms of the MIT license.
4
5 Authors:
6 Gerald Zajac 2008
7 */
8
9 #ifndef __REGISTER_IO_H__
10 #define __REGISTER_IO_H__
11
12
13 // PIO address of various VGA registers. If accessing these registers using
14 // MMIO, add 0x8000 to thses addresses.
15
16 #define VGA_ENABLE 0x3c3
17 #define MISC_OUT_R 0x3cc // read
18 #define MISC_OUT_W 0x3c2 // write
19 #define CRTC_INDEX 0x3d4
20 #define CRTC_DATA 0x3d5
21 #define SEQ_INDEX 0x3c4
22 #define SEQ_DATA 0x3c5
23
24
25 // Prototypes of I/O functions for accessing registers using PIO.
26
27 uint32 ReadPIO(uint32 addr, uint8 numBytes);
28 void WritePIO(uint32 addr, uint8 numBytes, uint32 value);
29
ReadPIO_8(uint32 addr)30 inline uint8 ReadPIO_8(uint32 addr) { return ReadPIO(addr, 1); }
WritePIO_8(uint32 addr,uint8 value)31 inline void WritePIO_8(uint32 addr, uint8 value) { WritePIO(addr, 1, value); }
32
33
34 // Prototypes of I/O functions for accessing registers using PIO or MMIO
35 // depending upon the type of S3 chip.
36
37 uint8 ReadReg8(uint32 addr);
38 uint16 ReadReg16(uint32 addr);
39 uint32 ReadReg32(uint32 addr);
40
41 void WriteReg8(uint32 addr, uint8 value);
42 void WriteReg16(uint32 addr, uint16 value);
43 void WriteReg32(uint32 addr, uint32 value);
44
45 uint8 ReadCrtcReg(uint8 index);
46 void WriteCrtcReg(uint8 index, uint8 value);
47 void WriteCrtcReg(uint8 index, uint8 value, uint8 mask);
48
49 uint8 ReadSeqReg(uint8 index);
50 void WriteSeqReg(uint8 index, uint8 value);
51 void WriteSeqReg(uint8 index, uint8 value, uint8 mask);
52
53 uint8 ReadMiscOutReg();
54 void WriteMiscOutReg(uint8 value);
55
56 void WriteIndexedColor(uint8 index, uint8 red, uint8 green, uint8 blue);
57
58
59 #endif // __REGISTER_IO_H__
60