~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/durango.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/durango.c,v 1.1 2002/12/10 15:12:25 alanh Exp $ */
 
2
/*
 
3
 * $Workfile: durango.c $
 
4
 *
 
5
 * This is the main file used to add Durango graphics support to a software 
 
6
 * project.  The main reason to have a single file include the other files
 
7
 * is that it centralizes the location of the compiler options.  This file
 
8
 * should be tuned for a specific implementation, and then modified as needed
 
9
 * for new Durango releases.  The releases.txt file indicates any updates to
 
10
 * this main file, such as a new definition for a new hardware platform. 
 
11
 *
 
12
 * In other words, this file should be copied from the Durango source files
 
13
 * once when a software project starts, and then maintained as necessary.  
 
14
 * It should not be recopied with new versions of Durango unless the 
 
15
 * developer is willing to tune the file again for the specific project.
 
16
 *
 
17
 * NSC_LIC_ALTERNATIVE_PREAMBLE
 
18
 *
 
19
 * Revision 1.0
 
20
 *
 
21
 * National Semiconductor Alternative GPL-BSD License
 
22
 *
 
23
 * National Semiconductor Corporation licenses this software 
 
24
 * ("Software"):
 
25
 *
 
26
 *      Durango
 
27
 *
 
28
 * under one of the two following licenses, depending on how the 
 
29
 * Software is received by the Licensee.
 
30
 * 
 
31
 * If this Software is received as part of the Linux Framebuffer or
 
32
 * other GPL licensed software, then the GPL license designated 
 
33
 * NSC_LIC_GPL applies to this Software; in all other circumstances 
 
34
 * then the BSD-style license designated NSC_LIC_BSD shall apply.
 
35
 *
 
36
 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */
 
37
 
 
38
/* NSC_LIC_BSD
 
39
 *
 
40
 * National Semiconductor Corporation Open Source License for Durango
 
41
 *
 
42
 * (BSD License with Export Notice)
 
43
 *
 
44
 * Copyright (c) 1999-2001
 
45
 * National Semiconductor Corporation.
 
46
 * All rights reserved.
 
47
 *
 
48
 * Redistribution and use in source and binary forms, with or without 
 
49
 * modification, are permitted provided that the following conditions 
 
50
 * are met: 
 
51
 *
 
52
 *   * Redistributions of source code must retain the above copyright 
 
53
 *     notice, this list of conditions and the following disclaimer. 
 
54
 *
 
55
 *   * Redistributions in binary form must reproduce the above 
 
56
 *     copyright notice, this list of conditions and the following 
 
57
 *     disclaimer in the documentation and/or other materials provided 
 
58
 *     with the distribution. 
 
59
 *
 
60
 *   * Neither the name of the National Semiconductor Corporation nor 
 
61
 *     the names of its contributors may be used to endorse or promote 
 
62
 *     products derived from this software without specific prior 
 
63
 *     written permission. 
 
64
 * 
 
65
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
66
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 
67
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 
68
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 
69
 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 
 
70
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 
71
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
 
72
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 
73
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 
74
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
 
75
 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 
 
76
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 
77
 * OF SUCH DAMAGE.
 
78
 *
 
79
 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 
 
80
 * YOUR JURISDICTION. It is licensee's responsibility to comply with 
 
81
 * any export regulations applicable in licensee's jurisdiction. Under 
 
82
 * CURRENT (2001) U.S. export regulations this software 
 
83
 * is eligible for export from the U.S. and can be downloaded by or 
 
84
 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 
 
85
 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 
 
86
 * Syria, Sudan, Afghanistan and any other country to which the U.S. 
 
87
 * has embargoed goods and services. 
 
88
 *
 
89
 * END_NSC_LIC_BSD */
 
90
 
 
91
/* NSC_LIC_GPL
 
92
 *
 
93
 * National Semiconductor Corporation Gnu General Public License for Durango
 
94
 *
 
95
 * (GPL License with Export Notice)
 
96
 *
 
97
 * Copyright (c) 1999-2001
 
98
 * National Semiconductor Corporation.
 
99
 * All rights reserved.
 
100
 *
 
101
 * Redistribution and use in source and binary forms, with or without 
 
102
 * modification, are permitted under the terms of the GNU General 
 
103
 * Public License as published by the Free Software Foundation; either 
 
104
 * version 2 of the License, or (at your option) any later version  
 
105
 *
 
106
 * In addition to the terms of the GNU General Public License, neither 
 
107
 * the name of the National Semiconductor Corporation nor the names of 
 
108
 * its contributors may be used to endorse or promote products derived 
 
109
 * from this software without specific prior written permission. 
 
110
 *
 
111
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
112
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 
113
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 
114
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 
115
 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 
 
116
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 
117
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
 
118
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 
119
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 
120
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 
 
121
 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 
 
122
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 
123
 * OF SUCH DAMAGE. See the GNU General Public License for more details. 
 
124
 *
 
125
 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 
 
126
 * YOUR JURISDICTION. It is licensee's responsibility to comply with 
 
127
 * any export regulations applicable in licensee's jurisdiction. Under 
 
128
 * CURRENT (2001) U.S. export regulations this software 
 
129
 * is eligible for export from the U.S. and can be downloaded by or 
 
130
 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 
 
131
 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 
 
132
 * Syria, Sudan, Afghanistan and any other country to which the U.S. 
 
133
 * has embargoed goods and services. 
 
134
 *
 
135
 * You should have received a copy of the GNU General Public License 
 
136
 * along with this file; if not, write to the Free Software Foundation, 
 
137
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 
138
 *
 
139
 * END_NSC_LIC_GPL */
 
140
 
 
141
/* COMPILER OPTIONS
 
142
 * These compiler options specify how the Durango routines are compiled 
 
143
 * for the different hardware platforms.  For best performance, a driver 
 
144
 * would build for a specific platform.  The "dynamic" switches are set 
 
145
 * by diagnostic applications such as Darwin that will run on a variety
 
146
 * of platforms and use the appropriate code at runtime.  Each component
 
147
 * may be separately dynamic, so that a driver has the option of being 
 
148
 * tuned for a specific 2D accelerator, but will still run with a variety
 
149
 * of chipsets. 
 
150
 */
 
151
 
 
152
#define GFX_DISPLAY_DYNAMIC                     1       /* runtime selection */
 
153
#define GFX_DISPLAY_GU1                         1       /* 1st generation display controller */
 
154
#define GFX_DISPLAY_GU2                         1       /* 2nd generation display controller */
 
155
 
 
156
#define GFX_INIT_DYNAMIC            1   /* runtime selection */
 
157
#define GFX_INIT_GU1                1   /* Geode family      */
 
158
#define GFX_INIT_GU2                1   /* Redcloud          */
 
159
 
 
160
#define GFX_MSR_DYNAMIC             1   /* runtime selection */
 
161
#define GFX_MSR_REDCLOUD            1   /* Redcloud          */
 
162
 
 
163
#define GFX_2DACCEL_DYNAMIC                     1       /* runtime selection */
 
164
#define GFX_2DACCEL_GU1                         1       /* 1st generation 2D accelerator */
 
165
#define GFX_2DACCEL_GU2                         1       /* 2nd generation 2D accelerator */
 
166
 
 
167
#define GFX_VIDEO_DYNAMIC                       1       /* runtime selection */
 
168
#define GFX_VIDEO_CS5530                        1       /* support for CS5530 */
 
169
#define GFX_VIDEO_SC1200                        1       /* support for SC1200 */
 
170
#define GFX_VIDEO_REDCLOUD          1   /* support for Redcloud */
 
171
 
 
172
#define GFX_VIP_DYNAMIC                         1       /* runtime selection */
 
173
#define GFX_VIP_SC1200                          1       /* support for SC1200 */
 
174
 
 
175
#define GFX_DECODER_DYNAMIC                     1       /* runtime selection */
 
176
#define GFX_DECODER_SAA7114                     1       /* Philips SAA7114 decoder */
 
177
 
 
178
#define GFX_TV_DYNAMIC                          1       /* runtime selection */
 
179
#define GFX_TV_FS451                            1       /* Focus Enhancements FS450 */
 
180
#define GFX_TV_SC1200                           1       /* SC1200 integrated TV encoder */
 
181
 
 
182
#define GFX_I2C_DYNAMIC                         1       /* runtime selection */
 
183
#define GFX_I2C_ACCESS                          1       /* support for ACCESS.BUS */
 
184
#define GFX_I2C_GPIO                            1       /* support for CS5530 GPIOs */
 
185
 
 
186
#define GFX_VGA_DYNAMIC                         1       /* runtime selection */
 
187
#define GFX_VGA_GU1                                     1       /* 1st generation graphics unit */
 
188
 
 
189
#define FB4MB                                           1       /* Set to use 4Mb video ram for Pyramid */
 
190
 
 
191
#define GFX_NO_IO_IN_WAIT_MACROS    0   /* Set to remove I/O accesses in GP bit testing */
 
192
 
 
193
/* ROUTINES TO READ VALUES
 
194
 * These are routines used by Darwin or other diagnostics to read the 
 
195
 * current state of the hardware.  Display drivers or embedded applications can 
 
196
 * reduce the size of the Durango code by not including these routines. 
 
197
 */
 
198
#define GFX_READ_ROUTINES                       1       /* add routines to read values */
 
199
 
 
200
/* VARIABLES USED FOR RUNTIME SELECTION
 
201
 * If part of the graphics subsystem is declared as dynamic, then the 
 
202
 * following variables are used to specify which platform has been detected.
 
203
 * The variables are set in the "gfx_detect_cpu" routine.  The values should 
 
204
 * be bit flags to allow masks to be used to check for multiple platforms.
 
205
 */
 
206
 
 
207
#if GFX_DISPLAY_DYNAMIC
 
208
int gfx_display_type = 0;
 
209
#endif
 
210
 
 
211
#if GFX_INIT_DYNAMIC
 
212
int gfx_init_type = 0;
 
213
#endif
 
214
 
 
215
#if GFX_MSR_DYNAMIC
 
216
int gfx_msr_type = 0;
 
217
#endif
 
218
 
 
219
#if GFX_2DACCEL_DYNAMIC
 
220
int gfx_2daccel_type = 0;
 
221
#endif
 
222
 
 
223
#if GFX_VIDEO_DYNAMIC
 
224
int gfx_video_type = 0;
 
225
#endif
 
226
 
 
227
#if GFX_VIP_DYNAMIC
 
228
int gfx_vip_type = 0;
 
229
#endif
 
230
 
 
231
#if GFX_DECODER_DYNAMIC
 
232
int gfx_decoder_type = 0;
 
233
#endif
 
234
 
 
235
#if GFX_TV_DYNAMIC
 
236
int gfx_tv_type = 0;
 
237
#endif
 
238
 
 
239
#if GFX_I2C_DYNAMIC
 
240
int gfx_i2c_type = 0;
 
241
#endif
 
242
 
 
243
#if GFX_VGA_DYNAMIC
 
244
int gfx_vga_type = 0;
 
245
#endif
 
246
 
 
247
/* HEADER FILE FOR DURANGO ROUTINE DEFINITIONS
 
248
 * Needed since some of the Durango routines call other Durango routines.
 
249
 * Also defines the size of chipset array (GFX_CSPTR_SIZE).
 
250
 */
 
251
#include "gfx_rtns.h"                   /* routine definitions */
 
252
 
 
253
/* DEFINE POINTERS TO MEMORY MAPPED REGIONS
 
254
 * These pointers are used by the Durango routines to access the hardware. 
 
255
 * The variables must be set by the project's initialization code after
 
256
 * mapping the regions in the appropriate manner. 
 
257
 */
 
258
 
 
259
/* DEFINE VIRTUAL ADDRESSES */
 
260
/* Note: These addresses define the starting base expected by all    */
 
261
/*       Durango offsets.  Under an OS that requires these pointers  */
 
262
/*       to be mapped to linear addresses (i.e Windows), it may not  */
 
263
/*       be possible to keep these base offsets.  In these cases,    */
 
264
/*       the addresses are modified to point to the beginning of the */
 
265
/*       relevant memory region and the access macros are adjusted   */
 
266
/*       to subtract the offset from the default base.  For example, */
 
267
/*       the register pointer could be moved to be 0x40008000, while */
 
268
/*       the WRITE_REG* macros are modified to subtract 0x8000 from  */
 
269
/*       the offset.                                                 */
 
270
 
 
271
unsigned char *gfx_virt_regptr = (unsigned char *)0x40000000;
 
272
unsigned char *gfx_virt_fbptr = (unsigned char *)0x40800000;
 
273
unsigned char *gfx_virt_vidptr = (unsigned char *)0x40010000;
 
274
unsigned char *gfx_virt_vipptr = (unsigned char *)0x40015000;
 
275
unsigned char *gfx_virt_spptr = (unsigned char *)0x40000000;
 
276
unsigned char *gfx_virt_gpptr = (unsigned char *)0x40000000;
 
277
 
 
278
/* DEFINE PHYSICAL ADDRESSES */
 
279
 
 
280
unsigned char *gfx_phys_regptr = (unsigned char *)0x40000000;
 
281
unsigned char *gfx_phys_fbptr = (unsigned char *)0x40800000;
 
282
unsigned char *gfx_phys_vidptr = (unsigned char *)0x40010000;
 
283
unsigned char *gfx_phys_vipptr = (unsigned char *)0x40015000;
 
284
 
 
285
/* HEADER FILE FOR GRAPHICS REGISTER DEFINITIONS 
 
286
 * This contains only constant definitions, so it should be able to be 
 
287
 * included in any software project as is.
 
288
 */
 
289
#include "gfx_regs.h"                   /* graphics register definitions */
 
290
 
 
291
/* HEADER FILE FOR REGISTER ACCESS MACROS
 
292
 * This file contains the definitions of the WRITE_REG32 and similar macros
 
293
 * used by the Durango routines to access the hardware.  The file assumes 
 
294
 * that the environment can handle 32-bit pointer access.  If this is not
 
295
 * the case, or if there are special requirements, then this header file 
 
296
 * should not be included and the project must define the macros itself.
 
297
 * (A project may define WRITE_REG32 to call a routine, for example).
 
298
 */
 
299
#include "gfx_defs.h"                   /* register access macros */
 
300
 
 
301
/* IO MACROS AND ROUTINES
 
302
 * These macros must be defined before the initialization or I2C 
 
303
 * routines will work properly. 
 
304
 */
 
305
 
 
306
#if defined(OS_WIN32)                   /* For Windows */
 
307
 
 
308
/* VSA II CALL */
 
309
 
 
310
void
 
311
gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr,
 
312
                 unsigned long *ptrHigh, unsigned long *ptrLow)
 
313
{
 
314
   unsigned long temp1, temp2;
 
315
 
 
316
   _asm {
 
317
      mov dx, 0x0AC1C
 
318
      mov eax, 0x0FC530007
 
319
      out dx, eax 
 
320
      add dl, 2 
 
321
      mov ecx, msrAddr 
 
322
      mov cx, msrReg 
 
323
      in ax, dx;
 
324
      ;EDX:EAX will contain MSR contents.
 
325
      mov temp1, edx 
 
326
      mov temp2, eax
 
327
   }
 
328
 
 
329
   *ptrHigh = temp1;
 
330
   *ptrLow = temp2;
 
331
}
 
332
 
 
333
void
 
334
gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr,
 
335
                  unsigned long *ptrHigh, unsigned long *ptrLow)
 
336
{
 
337
   unsigned long temp1 = *ptrHigh;
 
338
   unsigned long temp2 = *ptrLow;
 
339
 
 
340
   _asm {
 
341
      mov dx, 0x0AC1C
 
342
      mov eax, 0x0FC530007 
 
343
      out dx, eax i
 
344
      add dl, 2 
 
345
      ;ECX contains msrAddr | msrReg 
 
346
      mov ecx, msrAddr
 
347
      mov cx, msrReg
 
348
      ;<OR_mask_hi > 
 
349
      mov ebx, temp1
 
350
 
 
351
      ;<OR_mask_hi > 
 
352
      mov eax, temp2
 
353
      ;<AND_mask_hi > 
 
354
      mov esi, 0
 
355
      ;<AND_mask_lo > 
 
356
      mov edi, 0
 
357
      ;MSR is written at this point
 
358
      out dx, ax
 
359
   }
 
360
}
 
361
 
 
362
unsigned char
 
363
gfx_inb(unsigned short port)
 
364
{
 
365
   unsigned char data;
 
366
 
 
367
   _asm {
 
368
      pushf 
 
369
      mov dx, port 
 
370
      in al, dx 
 
371
      mov data, al 
 
372
      popf
 
373
   }
 
374
   return (data);
 
375
}
 
376
 
 
377
unsigned short
 
378
gfx_inw(unsigned short port)
 
379
{
 
380
   unsigned short data;
 
381
 
 
382
   _asm {
 
383
      pushf 
 
384
      mov dx, port 
 
385
      in ax, dx 
 
386
      mov data, ax 
 
387
      popf
 
388
   }
 
389
   return (data);
 
390
}
 
391
 
 
392
unsigned long
 
393
gfx_ind(unsigned short port)
 
394
{
 
395
   unsigned long data;
 
396
 
 
397
   _asm {
 
398
      pushf 
 
399
      mov dx, port 
 
400
      in eax, dx 
 
401
      mov data, eax 
 
402
      popf
 
403
   }
 
404
   return (data);
 
405
}
 
406
 
 
407
void
 
408
gfx_outb(unsigned short port, unsigned char data)
 
409
{
 
410
   _asm {
 
411
      pushf 
 
412
      mov al, data 
 
413
      mov dx, port 
 
414
      out dx, al 
 
415
      popf
 
416
   }
 
417
}
 
418
 
 
419
void
 
420
gfx_outw(unsigned short port, unsigned short data)
 
421
{
 
422
   _asm {
 
423
      pushf 
 
424
      mov ax, data 
 
425
      mov dx, port 
 
426
      out dx, ax 
 
427
      popf
 
428
   }
 
429
}
 
430
 
 
431
void
 
432
gfx_outd(unsigned short port, unsigned long data)
 
433
{
 
434
   _asm {
 
435
      pushf 
 
436
      mov eax, data 
 
437
      mov dx, port 
 
438
      out dx, eax 
 
439
      popf
 
440
   }
 
441
}
 
442
 
 
443
 
 
444
#elif defined(OS_VXWORKS) || defined (OS_LINUX) /* VxWorks and Linux */
 
445
 
 
446
#if defined(OS_LINUX)
 
447
#include "asm/msr.h"
 
448
#endif
 
449
 
 
450
void
 
451
gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr,
 
452
                 unsigned long *ptrHigh, unsigned long *ptrLow)
 
453
{
 
454
   unsigned long addr, val1, val2;
 
455
 
 
456
   addr = msrAddr | (unsigned long)msrReg;
 
457
   rdmsr(addr, val1, val2);
 
458
 
 
459
   *ptrHigh = val2;
 
460
   *ptrLow = val1;
 
461
}
 
462
 
 
463
void
 
464
gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr,
 
465
                  unsigned long *ptrHigh, unsigned long *ptrLow)
 
466
{
 
467
   unsigned long addr, val1, val2;
 
468
 
 
469
   val2 = *ptrHigh;
 
470
   val1 = *ptrLow;
 
471
 
 
472
   addr = (msrAddr & 0xFFFF0000) | (unsigned long)msrReg;
 
473
   wrmsr(addr, val1, val2);
 
474
}
 
475
 
 
476
unsigned char
 
477
gfx_inb(unsigned short port)
 
478
{
 
479
   unsigned char value;
 
480
   __asm__ volatile ("inb %1,%0":"=a" (value):"d"(port));
 
481
 
 
482
   return value;
 
483
}
 
484
 
 
485
unsigned short
 
486
gfx_inw(unsigned short port)
 
487
{
 
488
   unsigned short value;
 
489
   __asm__ volatile ("in %1,%0":"=a" (value):"d"(port));
 
490
 
 
491
   return value;
 
492
}
 
493
 
 
494
unsigned long
 
495
gfx_ind(unsigned short port)
 
496
{
 
497
   unsigned long value;
 
498
   __asm__ volatile ("inl %1,%0":"=a" (value):"d"(port));
 
499
 
 
500
   return value;
 
501
}
 
502
 
 
503
void
 
504
gfx_outb(unsigned short port, unsigned char data)
 
505
{
 
506
   __asm__ volatile ("outb %0,%1"::"a" (data), "d"(port));
 
507
}
 
508
 
 
509
void
 
510
gfx_outw(unsigned short port, unsigned short data)
 
511
{
 
512
   __asm__ volatile ("out %0,%1"::"a" (data), "d"(port));
 
513
}
 
514
 
 
515
void
 
516
gfx_outd(unsigned short port, unsigned long data)
 
517
{
 
518
   __asm__ volatile ("outl %0,%1"::"a" (data), "d"(port));
 
519
}
 
520
 
 
521
#else /* else nothing */
 
522
 
 
523
unsigned char
 
524
gfx_inb(unsigned short port)
 
525
{
 
526
   /* ADD OS SPECIFIC IMPLEMENTATION */
 
527
   return (0);
 
528
}
 
529
 
 
530
unsigned short
 
531
gfx_inw(unsigned short port)
 
532
{
 
533
   /* ADD OS SPECIFIC IMPLEMENTATION */
 
534
   return (0);
 
535
}
 
536
 
 
537
unsigned long
 
538
gfx_ind(unsigned short port)
 
539
{
 
540
   /* ADD OS SPECIFIC IMPLEMENTATION */
 
541
   return (0);
 
542
}
 
543
 
 
544
void
 
545
gfx_outb(unsigned short port, unsigned char data)
 
546
{
 
547
   /* ADD OS SPECIFIC IMPLEMENTATION */
 
548
}
 
549
 
 
550
void
 
551
gfx_outw(unsigned short port, unsigned short data)
 
552
{
 
553
   /* ADD OS SPECIFIC IMPLEMENTATION */
 
554
}
 
555
 
 
556
void
 
557
gfx_outd(unsigned short port, unsigned long data)
 
558
{
 
559
   /* ADD OS SPECIFIC IMPLEMENTATION */
 
560
}
 
561
#endif
 
562
 
 
563
#define INB(port) gfx_inb(port)
 
564
#define INW(port) gfx_inw(port)
 
565
#define IND(port) gfx_ind(port)
 
566
#define OUTB(port, data) gfx_outb(port, data)
 
567
#define OUTW(port, data) gfx_outw(port, data)
 
568
#define OUTD(port, data) gfx_outd(port, data)
 
569
 
 
570
/* INITIALIZATION ROUTINES 
 
571
 * These routines are used during the initialization of the driver to 
 
572
 * perform such tasks as detecting the type of CPU and video hardware.  
 
573
 * The routines require the use of IO, so the above IO routines need 
 
574
 * to be implemented before the initialization routines will work
 
575
 * properly.
 
576
 */
 
577
 
 
578
#include "gfx_init.c"
 
579
 
 
580
/* INCLUDE MSR ACCESS ROUTINES */
 
581
 
 
582
#include "gfx_msr.c"
 
583
 
 
584
/* INCLUDE GRAPHICS ENGINE ROUTINES 
 
585
 * These routines are used to program the 2D graphics accelerator.  If
 
586
 * the project does not use graphics acceleration (direct frame buffer
 
587
 * access only), then this file does not need to be included. 
 
588
 */
 
589
#include "gfx_rndr.c"                   /* graphics engine routines */
 
590
 
 
591
/* INCLUDE DISPLAY CONTROLLER ROUTINES 
 
592
 * These routines are used if the display mode is set directly.  If the 
 
593
 * project uses VGA registers to set a display mode, then these files
 
594
 * do not need to be included.
 
595
 */
 
596
#include "gfx_mode.h"                   /* display mode tables */
 
597
#include "gfx_disp.c"                   /* display controller routines */
 
598
 
 
599
/* INCLUDE VIDEO OVERLAY ROUTINES
 
600
 * These routines control the video overlay hardware. 
 
601
 */
 
602
#include "gfx_vid.c"                    /* video overlay routines */
 
603
 
 
604
/* VIDEO PORT AND VIDEO DECODER ROUTINES
 
605
 * These routines rely on the I2C routines.
 
606
 */
 
607
#include "gfx_vip.c"                    /* video port routines */
 
608
#include "gfx_dcdr.c"                   /* video decoder routines */
 
609
 
 
610
/* I2C BUS ACCESS ROUTINES
 
611
 * These routines are used by the video decoder and possibly an 
 
612
 * external TV encoer. 
 
613
 */
 
614
#include "gfx_i2c.c"                    /* I2C bus access routines */
 
615
 
 
616
/* TV ENCODER ROUTINES
 
617
 * This file does not need to be included if the system does not
 
618
 * support TV output.
 
619
 */
 
620
#include "gfx_tv.c"                     /* TV encoder routines */
 
621
 
 
622
/* VGA ROUTINES
 
623
 * This file is used if setting display modes using VGA registers.
 
624
 */
 
625
#include "gfx_vga.c"                    /* VGA routines */
 
626
 
 
627
/* END OF FILE */