aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/int10
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/int10')
-rw-r--r--xorg-server/hw/xfree86/int10/generic.c72
-rw-r--r--xorg-server/hw/xfree86/int10/helper_exec.c52
-rw-r--r--xorg-server/hw/xfree86/int10/xf86int10.c61
-rw-r--r--xorg-server/hw/xfree86/int10/xf86int10.h2
4 files changed, 66 insertions, 121 deletions
diff --git a/xorg-server/hw/xfree86/int10/generic.c b/xorg-server/hw/xfree86/int10/generic.c
index 994085493..fbc9b8507 100644
--- a/xorg-server/hw/xfree86/int10/generic.c
+++ b/xorg-server/hw/xfree86/int10/generic.c
@@ -62,62 +62,6 @@ static void UnmapVRam(xf86Int10InfoPtr pInt);
static void *sysMem = NULL;
-/**
- * Read legacy VGA video BIOS associated with specified domain.
- *
- * Attempts to read up to 128KiB of legacy VGA video BIOS.
- *
- * \return
- * The number of bytes read on success or -1 on failure.
- *
- * \bug
- * PCI ROMs can contain multiple BIOS images (e.g., OpenFirmware, x86 VGA,
- * etc.). How do we know that \c pci_device_read_rom will return the
- * legacy VGA BIOS image?
- */
-#ifndef _PC
-static int
-read_legacy_video_BIOS(struct pci_device *dev, unsigned char *Buf)
-{
- const ADDRESS Base = 0xC0000;
- const int Len = 0x10000 * 2;
- const int pagemask = getpagesize() - 1;
- const ADDRESS offset = Base & ~pagemask;
- const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset;
- unsigned char *ptr, *src;
- int len;
-
-
- /* Try to use the civilized PCI interface first.
- */
- if (pci_device_read_rom(dev, Buf) == 0) {
- return dev->rom_size;
- }
-
- ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, dev, offset, size);
-
- if (!ptr)
- return -1;
-
- /* Using memcpy() here can hang the system */
- src = ptr + (Base - offset);
- for (len = 0; len < (Len / 2); len++) {
- Buf[len] = src[len];
- }
-
- if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) {
- for ( /* empty */ ; len < Len; len++) {
- Buf[len] = src[len];
- }
- }
-
- xf86UnMapVidMem(-1, ptr, size);
-
- return Len;
-}
-#endif /* _PC */
-
-
xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex, int Flags)
{
@@ -159,8 +103,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
MapVRam(pInt);
#ifdef _PC
if (!sysMem)
- sysMem = xf86MapVidMem(screen, VIDMEM_MMIO, V_BIOS,
- BIOS_SIZE + SYS_BIOS - V_BIOS);
+ pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS,
+ PCI_DEV_MAP_FLAG_WRITABLE, &sysMem);
INTPriv(pInt)->sysMem = sysMem;
if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) {
@@ -232,7 +176,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
*/
vbiosMem = (char *)base + V_BIOS;
memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
- if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
+ if (pci_device_read_rom(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
xf86DrvMsg(screen, X_WARNING,
"Unable to retrieve all of segment 0x0C0000.\n");
}
@@ -294,10 +238,8 @@ MapVRam(xf86Int10InfoPtr pInt)
int pagesize = getpagesize();
int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize;
- INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO,
- pInt->dev, V_RAM, size);
-
- pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase;
+ pci_device_map_legacy(pInt->dev, V_RAM, size, PCI_DEV_MAP_FLAG_WRITABLE, &(INTPriv(pInt)->vRam));
+ pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024);
}
static void
@@ -307,7 +249,9 @@ UnmapVRam(xf86Int10InfoPtr pInt)
int pagesize = getpagesize();
int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
- xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size);
+ pci_device_unmap_legacy(pInt->dev, INTPriv(pInt)->vRam, size);
+ pci_device_close_io(pInt->dev, pInt->io);
+ pInt->io = NULL;
}
Bool
diff --git a/xorg-server/hw/xfree86/int10/helper_exec.c b/xorg-server/hw/xfree86/int10/helper_exec.c
index 44d8a7fcd..638f5668b 100644
--- a/xorg-server/hw/xfree86/int10/helper_exec.c
+++ b/xorg-server/hw/xfree86/int10/helper_exec.c
@@ -331,7 +331,7 @@ x_inb(CARD16 port)
}
#endif /* __NOT_YET__ */
} else if (!pciCfg1inb(port, &val)) {
- val = inb(Int10Current->ioBase + port);
+ val = pci_io_read8(Int10Current->io, port);
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" inb(%#x) = %2.2x\n", port, val);
}
@@ -353,7 +353,7 @@ x_inw(CARD16 port)
X_GETTIMEOFDAY(&tv);
val = (CARD16)(tv.tv_usec / 3);
} else if (!pciCfg1inw(port, &val)) {
- val = inw(Int10Current->ioBase + port);
+ val = pci_io_read16(Int10Current->io, port);
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" inw(%#x) = %4.4x\n", port, val);
}
@@ -387,7 +387,7 @@ x_outb(CARD16 port, CARD8 val)
} else if (!pciCfg1outb(port, val)) {
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outb(%#x, %2.2x)\n", port, val);
- outb(Int10Current->ioBase + port, val);
+ pci_io_write8(Int10Current->io, port, val);
}
}
@@ -398,7 +398,7 @@ x_outw(CARD16 port, CARD16 val)
if (!pciCfg1outw(port, val)) {
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outw(%#x, %4.4x)\n", port, val);
- outw(Int10Current->ioBase + port, val);
+ pci_io_write16(Int10Current->io, port, val);
}
}
@@ -408,7 +408,7 @@ x_inl(CARD16 port)
CARD32 val;
if (!pciCfg1in(port, &val)) {
- val = inl(Int10Current->ioBase + port);
+ val = pci_io_read32(Int10Current->io, port);
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" inl(%#x) = %8.8" PRIx32 "\n", port, val);
}
@@ -421,7 +421,7 @@ x_outl(CARD16 port, CARD32 val)
if (!pciCfg1out(port, val)) {
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outl(%#x, %8.8" PRIx32 ")\n", port, val);
- outl(Int10Current->ioBase + port, val);
+ pci_io_write32(Int10Current->io, port, val);
}
}
@@ -475,7 +475,7 @@ static struct pci_device*
pci_device_for_cfg_address (CARD32 addr)
{
struct pci_device *dev = NULL;
- PCITAG tag = PCI_TAG(addr);
+ CARD32 tag = PCI_TAG(addr);
struct pci_slot_match slot_match = {
.domain = PCI_DOM_FROM_TAG(tag),
.bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)),
@@ -650,29 +650,29 @@ bios_checksum(const CARD8 *start, int size)
void
LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
{
- vga->save_msr = inb(pInt->ioBase + 0x03CC);
- vga->save_vse = inb(pInt->ioBase + 0x03C3);
+ vga->save_msr = pci_io_read8(pInt->io, 0x03CC);
+ vga->save_vse = pci_io_read8(pInt->io, 0x03C3);
#ifndef __ia64__
- vga->save_46e8 = inb(pInt->ioBase + 0x46E8);
+ vga->save_46e8 = pci_io_read8(pInt->io, 0x46E8);
#endif
- vga->save_pos102 = inb(pInt->ioBase + 0x0102);
- outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr);
- outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse);
+ vga->save_pos102 = pci_io_read8(pInt->io, 0x0102);
+ pci_io_write8(pInt->io, 0x03C2, ~(CARD8)0x03 & vga->save_msr);
+ pci_io_write8(pInt->io, 0x03C3, ~(CARD8)0x01 & vga->save_vse);
#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
+ pci_io_write8(pInt->io, 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
#endif
- outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
+ pci_io_write8(pInt->io, 0x0102, ~(CARD8)0x01 & vga->save_pos102);
}
void
UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
{
- outb(pInt->ioBase + 0x0102, vga->save_pos102);
+ pci_io_write8(pInt->io, 0x0102, vga->save_pos102);
#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, vga->save_46e8);
+ pci_io_write8(pInt->io, 0x46E8, vga->save_46e8);
#endif
- outb(pInt->ioBase + 0x03C3, vga->save_vse);
- outb(pInt->ioBase + 0x03C2, vga->save_msr);
+ pci_io_write8(pInt->io, 0x03C3, vga->save_vse);
+ pci_io_write8(pInt->io, 0x03C2, vga->save_msr);
}
#if defined (_PC)
@@ -680,10 +680,12 @@ static void
SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
{
int pagesize = getpagesize();
- unsigned char* base = xf86MapVidMem(pInt->scrnIndex,
- VIDMEM_MMIO, 0, pagesize);
+ unsigned char* base;
int i;
+ if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
+ return; /* eek */
+
if (set) {
for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
MEM_WW(pInt, i, *(base + i));
@@ -692,7 +694,7 @@ SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
*(base + i) = MEM_RW(pInt, i);
}
- xf86UnMapVidMem(pInt->scrnIndex,base,pagesize);
+ pci_device_unmap_legacy(pInt->dev, base, pagesize);
}
void
@@ -706,7 +708,9 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
|| (!save && !pInt->BIOSScratch))
return;
- base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize);
+ if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
+ return; /* eek */
+
base += BIOS_SCRATCH_OFF;
if (save) {
if ((pInt->BIOSScratch
@@ -722,7 +726,7 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
}
}
- xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize);
+ pci_device_unmap_legacy(pInt->dev, base, pagesize);
}
#endif
diff --git a/xorg-server/hw/xfree86/int10/xf86int10.c b/xorg-server/hw/xfree86/int10/xf86int10.c
index 51eb91fbb..dd00e5465 100644
--- a/xorg-server/hw/xfree86/int10/xf86int10.c
+++ b/xorg-server/hw/xfree86/int10/xf86int10.c
@@ -84,7 +84,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented (except for clearing the screen) */
{ /* Localise */
- IOADDRESS ioport;
+ unsigned int ioport;
int i;
CARD16 int1d, regvals, tmp;
CARD8 mode, cgamode, cgacolour;
@@ -172,18 +172,15 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Rows */
MEM_WB(pInt, 0x0484, (25 - 1));
- /* Remap I/O port number into its domain */
- ioport += pInt->ioBase;
-
- /* Programme the mode */
- outb(ioport + 4, cgamode & 0x37); /* Turn off screen */
+ /* Program the mode */
+ pci_io_write8(pInt->io, ioport + 4, cgamode & 0x37); /* Turn off screen */
for (i = 0; i < 0x10; i++) {
tmp = MEM_RB(pInt, regvals + i);
- outb(ioport, i);
- outb(ioport + 1, tmp);
+ pci_io_write8(pInt->io, ioport, i);
+ pci_io_write8(pInt->io, ioport + 1, tmp);
}
- outb(ioport + 5, cgacolour); /* Select colour mode */
- outb(ioport + 4, cgamode); /* Turn on screen */
+ pci_io_write8(pInt->io, ioport + 5, cgacolour); /* Select colour mode */
+ pci_io_write8(pInt->io, ioport + 4, cgamode); /* Turn on screen */
}
break;
@@ -194,15 +191,15 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
+ unsigned int ioport = MEM_RW(pInt, 0x0463);
MEM_WB(pInt, 0x0460, X86_CL);
MEM_WB(pInt, 0x0461, X86_CH);
- outb(ioport, 0x0A);
- outb(ioport + 1, X86_CH);
- outb(ioport, 0x0B);
- outb(ioport + 1, X86_CL);
+ pci_io_write8(pInt->io, ioport, 0x0A);
+ pci_io_write8(pInt->io, ioport + 1, X86_CH);
+ pci_io_write8(pInt->io, ioport, 0x0B);
+ pci_io_write8(pInt->io, ioport + 1, X86_CL);
}
break;
@@ -214,7 +211,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport;
+ unsigned int ioport;
CARD16 offset;
MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL);
@@ -226,11 +223,11 @@ int42_handler(xf86Int10InfoPtr pInt)
offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL;
offset += MEM_RW(pInt, 0x044E) << 1;
- ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
- outb(ioport, 0x0E);
- outb(ioport + 1, offset >> 8);
- outb(ioport, 0x0F);
- outb(ioport + 1, offset & 0xFF);
+ ioport = MEM_RW(pInt, 0x0463);
+ pci_io_write8(pInt->io, ioport, 0x0E);
+ pci_io_write8(pInt->io, ioport + 1, offset >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0F);
+ pci_io_write8(pInt->io, ioport + 1, offset & 0xFF);
}
break;
@@ -276,7 +273,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
+ unsigned int ioport = MEM_RW(pInt, 0x0463);
CARD16 start;
CARD8 x, y;
@@ -287,10 +284,10 @@ int42_handler(xf86Int10InfoPtr pInt)
start <<= 1;
/* Update start address */
- outb(ioport, 0x0C);
- outb(ioport + 1, start >> 8);
- outb(ioport, 0x0D);
- outb(ioport + 1, start & 0xFF);
+ pci_io_write8(pInt->io, ioport, 0x0C);
+ pci_io_write8(pInt->io, ioport + 1, start >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0D);
+ pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
/* Switch cursor position */
y = MEM_RB(pInt, (X86_AL << 1) + 0x0450);
@@ -298,10 +295,10 @@ int42_handler(xf86Int10InfoPtr pInt)
start += (y * MEM_RW(pInt, 0x044A)) + x;
/* Update cursor position */
- outb(ioport, 0x0E);
- outb(ioport + 1, start >> 8);
- outb(ioport, 0x0F);
- outb(ioport + 1, start & 0xFF);
+ pci_io_write8(pInt->io, ioport, 0x0E);
+ pci_io_write8(pInt->io, ioport + 1, start >> 8);
+ pci_io_write8(pInt->io, ioport, 0x0F);
+ pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
}
break;
@@ -426,7 +423,7 @@ int42_handler(xf86Int10InfoPtr pInt)
/* Leave: Nothing */
/* Implemented */
{ /* Localise */
- IOADDRESS ioport = MEM_RW(pInt, 0x0463) + 5 + pInt->ioBase;
+ unsigned int ioport = MEM_RW(pInt, 0x0463) + 5;
CARD8 cgacolour = MEM_RB(pInt, 0x0466);
if (X86_BH) {
@@ -438,7 +435,7 @@ int42_handler(xf86Int10InfoPtr pInt)
}
MEM_WB(pInt, 0x0466, cgacolour);
- outb(ioport, cgacolour);
+ pci_io_write8(pInt->io, ioport, cgacolour);
}
break;
diff --git a/xorg-server/hw/xfree86/int10/xf86int10.h b/xorg-server/hw/xfree86/int10/xf86int10.h
index ba9ee5276..5bf326e78 100644
--- a/xorg-server/hw/xfree86/int10/xf86int10.h
+++ b/xorg-server/hw/xfree86/int10/xf86int10.h
@@ -41,7 +41,7 @@ typedef struct {
int flags;
int stackseg;
struct pci_device *dev;
- IOADDRESS ioBase;
+ struct pci_io_handle *io;
} xf86Int10InfoRec, *xf86Int10InfoPtr;
typedef struct _int10Mem {