Esempio n. 1
0
void *
vga_pci_map_bios(device_t dev, size_t *size)
{
	int rid;
	struct resource *res;

#if defined(__amd64__) || defined(__i386__) || defined(__ia64__)
	if (vga_pci_is_boot_display(dev)) {
		/*
		 * On x86, the System BIOS copy the default display
		 * device's Video BIOS at a fixed location in system
		 * memory (0xC0000, 128 kBytes long) at boot time.
		 *
		 * We use this copy for the default boot device, because
		 * the original ROM may not be valid after boot.
		 */

		*size = VGA_PCI_BIOS_SHADOW_SIZE;
		return (pmap_mapbios(VGA_PCI_BIOS_SHADOW_ADDR, *size));
	}
#endif

	rid = PCIR_BIOS;
	res = vga_pci_alloc_resource(dev, NULL, SYS_RES_MEMORY, &rid, 0ul,
	    ~0ul, 1, RF_ACTIVE);
	if (res == NULL) {
		return (NULL);
	}

	*size = rman_get_size(res);
	return (rman_get_virtual(res));
}
Esempio n. 2
0
void
vga_pci_unmap_bios(device_t dev, void *bios)
{
	struct vga_resource *vr;

	if (bios == NULL) {
		return;
	}

#if defined(__amd64__) || defined(__i386__) || defined(__ia64__)
	if (vga_pci_is_boot_display(dev)) {
		/* We mapped the BIOS shadow copy located at 0xC0000. */
		pmap_unmapdev((vm_offset_t)bios, VGA_PCI_BIOS_SHADOW_SIZE);

		return;
	}
#endif

	/*
	 * Look up the PCIR_BIOS resource in our softc.  It should match
	 * the address we returned previously.
	 */
	vr = lookup_res(device_get_softc(dev), PCIR_BIOS);
	KASSERT(vr->vr_res != NULL, ("vga_pci_unmap_bios: bios not mapped"));
	KASSERT(rman_get_virtual(vr->vr_res) == bios,
	    ("vga_pci_unmap_bios: mismatch"));
	vga_pci_release_resource(dev, NULL, SYS_RES_MEMORY, PCIR_BIOS,
	    vr->vr_res);
}
Esempio n. 3
0
int
vga_pci_repost(device_t dev)
{
#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
	x86regs_t regs;

	if (!vga_pci_is_boot_display(dev))
		return (EINVAL);

	if (x86bios_get_orm(VGA_PCI_BIOS_SHADOW_ADDR) == NULL)
		return (ENOTSUP);

	x86bios_init_regs(&regs);

	regs.R_AH = pci_get_bus(dev);
	regs.R_AL = (pci_get_slot(dev) << 3) | (pci_get_function(dev) & 0x07);
	regs.R_DL = 0x80;

	device_printf(dev, "REPOSTing\n");
	x86bios_call(&regs, X86BIOS_PHYSTOSEG(VGA_PCI_BIOS_SHADOW_ADDR + 3),
	    X86BIOS_PHYSTOOFF(VGA_PCI_BIOS_SHADOW_ADDR + 3));

	x86bios_get_intr(0x10);

	return (0);
#else
	return (ENOTSUP);
#endif
}
Esempio n. 4
0
static int
vga_pci_attach(device_t dev)
{

	bus_generic_probe(dev);

	/* Always create a drm child for now to make it easier on drm. */
	device_add_child(dev, "drm", -1);
	device_add_child(dev, "drmn", -1);
	bus_generic_attach(dev);

	if (vga_pci_is_boot_display(dev))
		device_printf(dev, "Boot video device\n");

	return (0);
}
Esempio n. 5
0
static int
vga_pci_probe(device_t dev)
{

	switch (pci_get_class(dev)) {
	case PCIC_DISPLAY:
		break;
	case PCIC_OLD:
		if (pci_get_subclass(dev) != PCIS_OLD_VGA)
			return (ENXIO);
		break;
	default:
		return (ENXIO);
	}

	/* Probe default display. */
	vga_pci_is_boot_display(dev);

	device_set_desc(dev, "VGA-compatible display");
	return (BUS_PROBE_GENERIC);
}