On Thu, 2003-11-06 at 10:48, Jon Smirl wrote:
> I'm working on a function like the one below for copying out the VBIOS ROM. This
> would make a good candidate for a device indepenent DRM IOCTL (with a callout
> for the bug fix). This is something that really should be fixed in X. Mapping
> the ROM in from user space without the kernel's knowledge is asking for trouble
> on hotplug systems.
>
> This could would be even simpler if there was an enable/diable PCI ROM call in
> the PCI driver.
>
> I have a getparam function for getting the VBIOS length so that the buffer can
> be allocated.
>
> int radeon_getbios( DRM_IOCTL_ARGS ) {
> DRM_DEVICE;
> drm_file_t *filp_priv;
> drm_radeon_private_t *dev_priv = dev->dev_private;
> drm_radeon_getbios_t gb;
> unsigned int temp;
> struct resource *r;
> void *rom;
>
> if ( !dev_priv ) {
> DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
> return DRM_ERR( EINVAL );
> }
>
> DRM_GET_PRIV_WITH_RETURN( filp_priv, filp );
>
> DRM_COPY_FROM_USER_IOCTL( gb, ( drm_radeon_getbios_t* )data,
> sizeof( gb ) );
>
> /* Fix from ATI for problem with Radeon hardware not leaving ROM enabled */
> temp = RADEON_READ(RADEON_MPP_TB_CONFIG);
> temp &= 0x00ffffffu;
> temp |= 0x04 << 24;
> RADEON_WRITE(RADEON_MPP_TB_CONFIG, temp);
> temp = RADEON_READ(RADEON_MPP_TB_CONFIG);
>
>
> /* no need to search for the ROM, just ask the card where it is. */
> r = &dev->pdev->resource[PCI_ROM_RESOURCE];
>
> /* assign the ROM an address if it doesn't have one */
> if (r->parent == NULL)
> pci_assign_resource(dev->pdev, PCI_ROM_RESOURCE);
>
> /* enable if needed */
> if (!(r->flags & PCI_ROM_ADDRESS_ENABLE)) {
> pci_write_config_dword(dev->pdev, dev->pdev->rom_base_reg, r->start |
> PCI_ROM_ADDRESS_ENABLE);
> r->flags |= PCI_ROM_ADDRESS_ENABLE;
> }
>
> rom = ioremap(r->start, r->end - r->start + 1);
> if (!rom) {
> printk(KERN_ERR "radeonfb: ROM failed to map\n");
> return -1;
> }
>
> gb.length = min( gb.length, pci_resource_len( dev->pdev, PCI_ROM_RESOURCE ));
> DRM_COPY_TO_USER( rom, gb.data, gb.length);
>
> iounmap(rom);
>
> if (r->parent) {
> release_resource(r);
> r->flags &= ~PCI_ROM_ADDRESS_ENABLE;
> r->end -= r->start;
> r->start = 0;
> }
> /* This will disable and set address to unassigned */
> pci_write_config_dword(dev->pdev, dev->pdev->rom_base_reg, 0);
>
> DRM_COPY_TO_USER_IOCTL( (drm_radeon_getbios_t *)data, gb, sizeof(gb) );
>
> return 0;
> }
Since this is something that will be needed for many devices, more than
there will be DRMs for, this seems like something that ought to be in a
lower-level driver (used by the DRM and fbdev).
--
Eric Anholt [EMAIL PROTECTED]
http://people.freebsd.org/~anholt/ [EMAIL PROTECTED]
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel