Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1029 serge 1
 
2
//#define ATOM_BIOS_PARSER 1
3
4
 
5
6
 
7
8
 
9
10
 
11
#define TRUE    1
12
13
 
14
15
 
16
17
 
18
typedef unsigned short u16_t;
19
typedef unsigned int   u32_t;
20
21
 
22
typedef unsigned int size_t;
23
24
 
25
#define MAX_VREFRESH 8
26
#define INTERLACE_REFRESH_WEIGHT  1.5
27
#define SYNC_TOLERANCE		0.01	/* 1 percent */
28
#define CLOCK_TOLERANCE		2000	/* Clock matching tolerance (2MHz) */
29
30
 
31
32
 
33
 
34
#define IMPORT __attribute__ ((dllimport))
35
36
 
37
 
38
void*  STDCALL KernelAlloc(unsigned size)__asm__("KernelAlloc");
39
int KernelFree(void *);
40
41
 
42
43
 
44
u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16");
45
u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32");
46
47
 
48
        PciRead32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
49
50
 
51
u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16");
52
u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32");
53
54
 
55
        PciWrite32(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg),(val))
56
57
 
58
59
 
60
61
 
62
void *calloc( size_t num, size_t size );
63
void *realloc(void*, size_t);
64
void free(void*);
65
66
 
67
 
68
#define xnfalloc  malloc
69
70
 
71
#define xnfcalloc calloc
72
73
 
74
75
 
76
77
 
78
79
 
80
void* memcpy(void * dest, const void *src, size_t n);
81
int   memcmp(const void *s1, const void *s2, size_t n);
82
83
 
84
char*  strcpy(char *to, const char *from);
85
char*  strcat(char *s, const char *append);
86
char*  strdup(const char *s);
87
char*  strchr(const char *s, int c);
88
int    strcmp(const char *s1, const char *s2);
89
90
 
91
92
 
93
94
 
95
int printf(const char* format, ...);
96
int dbg_open(char *path);
97
int dbgprintf(const char* format, ...);
98
99
 
100
101
 
102
typedef enum {
103
    MODE_OK	= 0,	/* Mode OK */
104
    MODE_HSYNC,		/* hsync out of range */
105
    MODE_VSYNC,		/* vsync out of range */
106
    MODE_H_ILLEGAL,	/* mode has illegal horizontal timings */
107
    MODE_V_ILLEGAL,	/* mode has illegal horizontal timings */
108
    MODE_BAD_WIDTH,	/* requires an unsupported linepitch */
109
    MODE_NOMODE,	/* no mode with a maching name */
110
    MODE_NO_INTERLACE,	/* interlaced mode not supported */
111
    MODE_NO_DBLESCAN,	/* doublescan mode not supported */
112
    MODE_NO_VSCAN,	/* multiscan mode not supported */
113
    MODE_MEM,		/* insufficient video memory */
114
    MODE_VIRTUAL_X,	/* mode width too large for specified virtual size */
115
    MODE_VIRTUAL_Y,	/* mode height too large for specified virtual size */
116
    MODE_MEM_VIRT,	/* insufficient video memory given virtual size */
117
    MODE_NOCLOCK,	/* no fixed clock available */
118
    MODE_CLOCK_HIGH,	/* clock required is too high */
119
    MODE_CLOCK_LOW,	/* clock required is too low */
120
    MODE_CLOCK_RANGE,	/* clock/mode isn't in a ClockRange */
121
    MODE_BAD_HVALUE,	/* horizontal timing was out of range */
122
    MODE_BAD_VVALUE,	/* vertical timing was out of range */
123
    MODE_BAD_VSCAN,	/* VScan value out of range */
124
    MODE_HSYNC_NARROW,	/* horizontal sync too narrow */
125
    MODE_HSYNC_WIDE,	/* horizontal sync too wide */
126
    MODE_HBLANK_NARROW,	/* horizontal blanking too narrow */
127
    MODE_HBLANK_WIDE,	/* horizontal blanking too wide */
128
    MODE_VSYNC_NARROW,	/* vertical sync too narrow */
129
    MODE_VSYNC_WIDE,	/* vertical sync too wide */
130
    MODE_VBLANK_NARROW,	/* vertical blanking too narrow */
131
    MODE_VBLANK_WIDE,	/* vertical blanking too wide */
132
    MODE_PANEL,         /* exceeds panel dimensions */
133
    MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
134
    MODE_ONE_WIDTH,     /* only one width is supported */
135
    MODE_ONE_HEIGHT,    /* only one height is supported */
136
    MODE_ONE_SIZE,      /* only one resolution is supported */
137
    MODE_BAD = -2,	/* unspecified reason */
138
    MODE_ERROR	= -1	/* error condition */
139
} ModeStatus;
140
141
 
142
    V_PHSYNC	= 0x0001,
143
    V_NHSYNC	= 0x0002,
144
    V_PVSYNC	= 0x0004,
145
    V_NVSYNC	= 0x0008,
146
    V_INTERLACE	= 0x0010,
147
    V_DBLSCAN	= 0x0020,
148
    V_CSYNC	= 0x0040,
149
    V_PCSYNC	= 0x0080,
150
    V_NCSYNC	= 0x0100,
151
    V_HSKEW	= 0x0200,	/* hskew provided */
152
    V_BCAST	= 0x0400,
153
    V_PIXMUX	= 0x1000,
154
    V_DBLCLK	= 0x2000,
155
    V_CLKDIV2	= 0x4000
156
} ModeFlags;
157
158
 
159
# define M_T_USERDEF 0x20	/* One of the modes from the config file */
160
161
 
162
 
163
typedef struct _DisplayModeRec {
164
    struct _DisplayModeRec *	prev;
165
    struct _DisplayModeRec *	next;
166
    char *      name;         /* identifier for the mode */
167
    ModeStatus			status;
168
    int				type;
169
170
 
171
    int       Clock;          /* pixel clock freq */
172
    int       HDisplay;       /* horizontal timing */
173
    int				HSyncStart;
174
    int				HSyncEnd;
175
    int				HTotal;
176
    int				HSkew;
177
    int       VDisplay;       /* vertical timing */
178
    int				VSyncStart;
179
    int				VSyncEnd;
180
    int				VTotal;
181
    int				VScan;
182
    int				Flags;
183
184
 
185
    int				ClockIndex;
186
    int       SynthClock;     /* Actual clock freq to
187
					  	 * be programmed */
188
    int				CrtcHDisplay;
189
    int				CrtcHBlankStart;
190
    int				CrtcHSyncStart;
191
    int				CrtcHSyncEnd;
192
    int				CrtcHBlankEnd;
193
    int				CrtcHTotal;
194
    int				CrtcHSkew;
195
    int				CrtcVDisplay;
196
    int				CrtcVBlankStart;
197
    int				CrtcVSyncStart;
198
    int				CrtcVSyncEnd;
199
    int				CrtcVBlankEnd;
200
    int				CrtcVTotal;
201
    Bool			CrtcHAdjusted;
202
    Bool			CrtcVAdjusted;
203
    int				PrivSize;
204
    CARD32*   Private;
205
    int				PrivFlags;
206
207
 
208
} DisplayModeRec, *DisplayModePtr;
209
210
 
211
{
212
    unsigned short	red, green, blue;
213
} LOCO;
214
215
 
216
 
217
__clear (void * dst, unsigned len)
218
{ u32_t tmp;
219
  asm __volatile__
220
  (
221
    "xor eax, eax \n\t"
222
    "cld \n\t"
223
    "rep stosb"
224
    :"=c"(tmp),"=D"(tmp)
225
    :"c"(len),"D"(dst)
226
    :"memory","eax","cc"
227
  );
228
};
229
230
 
231
abs (int i)
232
{
233
  return i < 0 ? -i : i;
234
};
235
236
 
237
#define DPMSModeStandby	1
238
#define DPMSModeSuspend	2
239
#define DPMSModeOff	3
240
241
 
242
 
243
 
244
#define min(x,y)  (((y)<(x))?(y):(x))
245
246
 
247
 
248
249