Subversion Repositories shark

Rev

Rev 54 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 pj 1
/* $XConsortium: nvreg.h /main/2 1996/10/28 05:13:41 kaleb $ */
2
/*
3
 * Copyright 1996-1997  David J. McKay
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * copy of this software and associated documentation files (the "Software"),
7
 * to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 * DAVID J. MCKAY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20
 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
 * SOFTWARE.
22
 */
23
 
24
/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/nv/nvreg.h,v 3.2.2.1 1998/01/18 10:35:36 hohndel Exp $ */
25
 
26
#ifndef __NVREG_H_
27
#define __NVREG_H_
28
 
80 pj 29
#include "ll/sys/cdefs.h"
30
 
31
__BEGIN_DECLS
32
 
54 pj 33
/* Little macro to construct bitmask for contiguous ranges of bits */
34
#define BITMASK(t,b) (((unsigned)(1U << (((t)-(b)+1)))-1)  << (b))
35
#define MASKEXPAND(mask) BITMASK(1?mask,0?mask)
36
 
37
/* Macro to set specific bitfields (mask has to be a macro x:y) ! */
38
#define SetBF(mask,value) ((value) << (0?mask))
39
#define GetBF(var,mask) (((unsigned)((var) & MASKEXPAND(mask))) >> (0?mask) )
40
 
41
#define MaskAndSetBF(var,mask,value) (var)=(((var)&(~MASKEXPAND(mask)) \
42
                                             | SetBF(mask,value)))
43
 
44
#define DEVICE_BASE(device) (0?NV##_##device)
45
#define DEVICE_SIZE(device) ((1?NV##_##device) - DEVICE_BASE(device)+1)
46
 
47
/* This is where we will have to have conditional compilation */
48
#define DEVICE_ACCESS(device,reg) \
49
  nv##device##Port[((NV_##device##_##reg)-DEVICE_BASE(device))/4]
50
 
51
#define DEVICE_WRITE(device,reg,value) DEVICE_ACCESS(device,reg)=(value)
52
#define DEVICE_READ(device,reg)        DEVICE_ACCESS(device,reg)
53
#define DEVICE_PRINT(device,reg) \
54
  ErrorF("NV_"#device"_"#reg"=#%08lx\n",DEVICE_ACCESS(device,reg))
55
#define DEVICE_DEF(device,mask,value) \
56
  SetBF(NV_##device##_##mask,NV_##device##_##mask##_##value)
57
#define DEVICE_VALUE(device,mask,value) SetBF(NV_##device##_##mask,value)
58
#define DEVICE_MASK(device,mask) MASKEXPAND(NV_##device##_##mask)
59
 
60
#define PDAC_Write(reg,value)           DEVICE_WRITE(PDAC,reg,value)
61
#define PDAC_Read(reg)                  DEVICE_READ(PDAC,reg)
62
#define PDAC_Print(reg)                 DEVICE_PRINT(PDAC,reg)
63
#define PDAC_Def(mask,value)            DEVICE_DEF(PDAC,mask,value)
64
#define PDAC_Val(mask,value)            DEVICE_VALUE(PDAC,mask,value)
65
#define PDAC_Mask(mask)                 DEVICE_MASK(PDAC,mask)
66
 
67
#define PFB_Write(reg,value)            DEVICE_WRITE(PFB,reg,value)
68
#define PFB_Read(reg)                   DEVICE_READ(PFB,reg)
69
#define PFB_Print(reg)                  DEVICE_PRINT(PFB,reg)
70
#define PFB_Def(mask,value)             DEVICE_DEF(PFB,mask,value)
71
#define PFB_Val(mask,value)             DEVICE_VALUE(PFB,mask,value)
72
#define PFB_Mask(mask)                  DEVICE_MASK(PFB,mask)
73
 
74
#define PRM_Write(reg,value)            DEVICE_WRITE(PRM,reg,value)
75
#define PRM_Read(reg)                   DEVICE_READ(PRM,reg)
76
#define PRM_Print(reg)                  DEVICE_PRINT(PRM,reg)
77
#define PRM_Def(mask,value)             DEVICE_DEF(PRM,mask,value)
78
#define PRM_Val(mask,value)             DEVICE_VALUE(PRM,mask,value)
79
#define PRM_Mask(mask)                  DEVICE_MASK(PRM,mask)
80
 
81
#define PGRAPH_Write(reg,value)         DEVICE_WRITE(PGRAPH,reg,value)
82
#define PGRAPH_Read(reg)                DEVICE_READ(PGRAPH,reg)
83
#define PGRAPH_Print(reg)               DEVICE_PRINT(PGRAPH,reg)
84
#define PGRAPH_Def(mask,value)          DEVICE_DEF(PGRAPH,mask,value)
85
#define PGRAPH_Val(mask,value)          DEVICE_VALUE(PGRAPH,mask,value)
86
#define PGRAPH_Mask(mask)               DEVICE_MASK(PGRAPH,mask)
87
 
88
#define PDMA_Write(reg,value)           DEVICE_WRITE(PDMA,reg,value)
89
#define PDMA_Read(reg)                  DEVICE_READ(PDMA,reg)
90
#define PDMA_Print(reg)                 DEVICE_PRINT(PDMA,reg)
91
#define PDMA_Def(mask,value)            DEVICE_DEF(PDMA,mask,value)
92
#define PDMA_Val(mask,value)            DEVICE_VALUE(PDMA,mask,value)
93
#define PDMA_Mask(mask)                 DEVICE_MASK(PDMA,mask)
94
 
95
#define PFIFO_Write(reg,value)          DEVICE_WRITE(PFIFO,reg,value)
96
#define PFIFO_Read(reg)                 DEVICE_READ(PFIFO,reg)
97
#define PFIFO_Print(reg)                DEVICE_PRINT(PFIFO,reg)
98
#define PFIFO_Def(mask,value)           DEVICE_DEF(PFIFO,mask,value)
99
#define PFIFO_Val(mask,value)           DEVICE_VALUE(PFIFO,mask,value)
100
#define PFIFO_Mask(mask)                DEVICE_MASK(PFIFO,mask)
101
 
102
#define PRAM_Write(reg,value)           DEVICE_WRITE(PRAM,reg,value)
103
#define PRAM_Read(reg)                  DEVICE_READ(PRAM,reg)
104
#define PRAM_Print(reg)                 DEVICE_PRINT(PRAM,reg)
105
#define PRAM_Def(mask,value)            DEVICE_DEF(PRAM,mask,value)
106
#define PRAM_Val(mask,value)            DEVICE_VALUE(PRAM,mask,value)
107
#define PRAM_Mask(mask)                 DEVICE_MASK(PRAM,mask)
108
 
109
#define PRAMFC_Write(reg,value)         DEVICE_WRITE(PRAMFC,reg,value)
110
#define PRAMFC_Read(reg)                DEVICE_READ(PRAMFC,reg)
111
#define PRAMFC_Print(reg)               DEVICE_PRINT(PRAMFC,reg)
112
#define PRAMFC_Def(mask,value)          DEVICE_DEF(PRAMFC,mask,value)
113
#define PRAMFC_Val(mask,value)          DEVICE_VALUE(PRAMFC,mask,value)
114
#define PRAMFC_Mask(mask)               DEVICE_MASK(PRAMFC,mask)
115
 
116
#define PMC_Write(reg,value)            DEVICE_WRITE(PMC,reg,value)
117
#define PMC_Read(reg)                   DEVICE_READ(PMC,reg)
118
#define PMC_Print(reg)                  DEVICE_PRINT(PMC,reg)
119
#define PMC_Def(mask,value)             DEVICE_DEF(PMC,mask,value)
120
#define PMC_Val(mask,value)             DEVICE_VALUE(PMC,mask,value)
121
#define PMC_Mask(mask)                  DEVICE_MASK(PMC,mask)
122
 
123
#define PMC_Write(reg,value)            DEVICE_WRITE(PMC,reg,value)
124
#define PMC_Read(reg)                   DEVICE_READ(PMC,reg)
125
#define PMC_Print(reg)                  DEVICE_PRINT(PMC,reg)
126
#define PMC_Def(mask,value)             DEVICE_DEF(PMC,mask,value)
127
#define PMC_Val(mask,value)             DEVICE_VALUE(PMC,mask,value)
128
#define PMC_Mask(mask)                  DEVICE_MASK(PMC,mask)
129
 
130
 
131
#define PBUS_Write(reg,value)         DEVICE_WRITE(PBUS,reg,value)
132
#define PBUS_Read(reg)                DEVICE_READ(PBUS,reg)
133
#define PBUS_Print(reg)               DEVICE_PRINT(PBUS,reg)
134
#define PBUS_Def(mask,value)          DEVICE_DEF(PBUS,mask,value)
135
#define PBUS_Val(mask,value)          DEVICE_VALUE(PBUS,mask,value)
136
#define PBUS_Mask(mask)               DEVICE_MASK(PBUS,mask)
137
 
138
 
139
#define PRAMDAC_Write(reg,value)         DEVICE_WRITE(PRAMDAC,reg,value)
140
#define PRAMDAC_Read(reg)                DEVICE_READ(PRAMDAC,reg)
141
#define PRAMDAC_Print(reg)               DEVICE_PRINT(PRAMDAC,reg)
142
#define PRAMDAC_Def(mask,value)          DEVICE_DEF(PRAMDAC,mask,value)
143
#define PRAMDAC_Val(mask,value)          DEVICE_VALUE(PRAMDAC,mask,value)
144
#define PRAMDAC_Mask(mask)               DEVICE_MASK(PRAMDAC,mask)
145
 
146
 
147
#define PDAC_ReadExt(reg) \
148
  ((PDAC_Write(INDEX_LO,(NV_PDAC_EXT_##reg) & 0xff)),\
149
  (PDAC_Write(INDEX_HI,((NV_PDAC_EXT_##reg) >> 8) & 0xff)),\
150
  (PDAC_Read(INDEX_DATA)))
151
 
152
#define PDAC_WriteExt(reg,value)\
153
  ((PDAC_Write(INDEX_LO,(NV_PDAC_EXT_##reg) & 0xff)),\
154
  (PDAC_Write(INDEX_HI,((NV_PDAC_EXT_##reg) >> 8) & 0xff)),\
155
  (PDAC_Write(INDEX_DATA,(value))))
156
 
157
#define CRTC_Write(index,value) outb(CRT_IC,(index));outb(CRT_DC,value)
158
#define CRTC_Read(index) (outb(CRT_IC,index),inb(CRT_DC))
159
 
160
#define PCRTC_Write(index,value) __svgalib_outcrtc(NV_PCRTC_##index,value)
161
#define PCRTC_Read(index) __svgalib_incrtc(NV_PCRTC_##index)
162
 
163
#define PCRTC_Def(mask,value)          DEVICE_DEF(PCRTC,mask,value)
164
#define PCRTC_Val(mask,value)          DEVICE_VALUE(PCRTC,mask,value)
165
#define PCRTC_Mask(mask)               DEVICE_MASK(PCRTC,mask)
166
 
167
#define SR_Write(index,value) outb(SEQ_I,(index));outb(SEQ_D,value)
168
#define SR_Read(index) (outb(SEQ_I,index),inb(SEQ_D))
169
 
170
#define PEXTDEV_Read(reg)                   DEVICE_READ(PEXTDEV,reg)
171
 
172
/* These are the variables which actually point at the register blocks */
173
 
174
/*typedef enum {NV1,NV3,NumNVChips} NVChipType;
175
 
176
NVChipType GetChipType(void);
177
*/
178
 
80 pj 179
__END_DECLS
180
 
54 pj 181
#endif
182
 
183