First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / int10 / pci.c
blob7ef6328da2c0221823b361fe9ffe4909faff6560
2 /*
3 * XFree86 int10 module
4 * execute BIOS int 10h calls in x86 real mode environment
5 * Copyright 1999 Egbert Eich
6 */
7 #ifdef HAVE_XORG_CONFIG_H
8 #include <xorg-config.h>
9 #endif
11 #include <string.h>
13 #include "xf86Pci.h"
14 #include "xf86.h"
15 #define _INT10_PRIVATE
16 #include "xf86int10.h"
18 int
19 mapPciRom(int pciEntity, unsigned char * address)
21 PCITAG tag;
22 unsigned char *mem, *ptr;
23 int length;
25 pciVideoPtr pvp = xf86GetPciInfoForEntity(pciEntity);
27 if (pvp == NULL) {
28 #ifdef DEBUG
29 ErrorF("mapPciRom: no PCI info\n");
30 #endif
31 return 0;
34 tag = pciTag(pvp->bus,pvp->device,pvp->func);
35 length = 1 << pvp->biosSize;
37 /* Read in entire PCI ROM */
38 mem = ptr = xnfcalloc(length, 1);
39 length = xf86ReadPciBIOS(0, tag, -1, ptr, length);
40 if (length > 0)
41 memcpy(address, ptr, length);
42 /* unmap/close/disable PCI bios mem */
43 xfree(mem);
45 #ifdef DEBUG
46 if (!length)
47 ErrorF("mapPciRom: no BIOS found\n");
48 #ifdef PRINT_PCI
49 else
50 dprint(address,0x20);
51 #endif
52 #endif
54 return length;