2 libgha.h - Library for direct hardware access
4 1996/10/27 - Robin Cutshaw (robin@xfree86.org)
5 XFree86 3.3.3 implementation
6 1999 - Øyvind Aabling.
7 Modified for GATOS/win/gfxdump.
8 2002 - library implementation by Nick Kurshev
10 supported O/S's: SVR4, UnixWare, SCO, Solaris,
11 FreeBSD, NetBSD, 386BSD, BSDI BSD/386,
13 DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd)
23 #define MAX_DEV_PER_VENDOR_CFG1 64
24 #define MAX_PCI_DEVICES_PER_BUS 32
25 #define MAX_PCI_DEVICES 64
26 #define PCI_MULTIFUNC_DEV 0x80
27 #define PCI_COMMAND_IO 0x1 /* Enable response to I/O space */
29 typedef struct pciinfo_s
31 int bus
,card
,func
; /* PCI/AGP bus:card:func */
32 unsigned short command
; /* Device control register */
33 unsigned short vendor
,device
; /* Card vendor+device ID */
34 unsigned base0
,base1
,base2
,baserom
; /* Memory and I/O base addresses */
35 // unsigned base0_limit, base1_limit, base2_limit, baserom_limit;
38 /* needed for mga_vid */
39 extern int pci_config_read(unsigned char bus
, unsigned char dev
, unsigned char func
,
40 unsigned char cmd
, int len
, unsigned long *val
);
41 /* Fill array pci_list which must have size MAX_PCI_DEVICES
42 and return 0 if sucessful */
43 extern int pci_scan(pciinfo_t
*pci_list
,unsigned *num_card
);
46 /* Enables/disables accessing to IO space from application side.
47 Should return 0 if o'k or errno on error. */
48 extern int enable_app_io( void );
49 extern int disable_app_io( void );
51 extern unsigned char INPORT8(unsigned idx
);
52 extern unsigned short INPORT16(unsigned idx
);
53 extern unsigned INPORT32(unsigned idx
);
54 #define INPORT(idx) INPORT32(idx)
55 extern void OUTPORT8(unsigned idx
,unsigned char val
);
56 extern void OUTPORT16(unsigned idx
,unsigned short val
);
57 extern void OUTPORT32(unsigned idx
,unsigned val
);
58 #define OUTPORT(idx,val) OUTPORT32(idx,val)
60 extern void * map_phys_mem(unsigned long base
, unsigned long size
);
61 extern void unmap_phys_mem(void *ptr
, unsigned long size
);
63 /* These are the region types */
64 #define MTRR_TYPE_UNCACHABLE 0
65 #define MTRR_TYPE_WRCOMB 1
66 #define MTRR_TYPE_WRTHROUGH 4
67 #define MTRR_TYPE_WRPROT 5
68 #define MTRR_TYPE_WRBACK 6
69 extern int mtrr_set_type(unsigned base
,unsigned size
,int type
);