tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Trying to access the Expansion ROM of a video card
Hello,
On Wed, 20 Oct 2021 08:26:25 +0000
Riza Dindir <riza.dindir%gmail.com@localhost> wrote:
> I am using NetBSD 9.2 (amd64). I have a laptop that has a radeon r7
> m265 video card (vendor 0x1002, product 0x6604). The system does not
> recognize this card. It fails with this message:
>
> kern error: [drm:(/export/netbsd/src/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c:725)radeon_get_bios]
> *ERROR* Unable to locate a BIOS ROM
> radeon0: autoconfiguration error: error: Fatal error during GPU init
> radeon0: autoconfiguration error: unable to attach drm: 22
>
> I wanted to see if I can read the bios of that card and added some
> test functions to the file mentioned above. The code is as such:
>
> pci_conf_capture(rdev->pdev->pd_pa.pa_pc, rdev->pdev->pd_pa.pa_tag,
> &conf);
>
> address = PCI_MAPREG_ROM_ADDR(conf.reg[12]);
> size = PCI_MAPREG_ROM_SIZE(address);
> DRM_INFO("rom addr: %x, rom size: %lu\n", address, size);
>
> result = bus_space_map(rdev->pdev->pd_pa.pa_memt,
> PCI_MAPREG_ROM_ADDR(address),
> size, BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, &romh);
> DRM_INFO("result of bus_space_map(): %d\n", result);
>
> bios = (uint8_t *)bus_space_vaddr(rdev->pdev->pd_pa.pa_memt,
> romh);
> DRM_INFO("bios: %p\n", bios);
> if (bios != NULL) {
> DRM_INFO("bios[0]: %X, bios[1]: %X\n", bios[0], bios[1]);
> } else {
> DRM_INFO("bios was NULL\n");
> }
>
> The bus_space_map function returns code 35. Maybe I am doing something
> wrong in the code when I try to read the "expansion rom" of the pci
> card. Anyone has an idea? How should I read the "expansion rom" of a
> PCI card?
Is there something sensible in the ROM BAR? If it's NULL the
bus_space_map() would fail. It also needs to be enabled in the BAR,
which it may or may not be already. Then pray that your chip has
separate decoders for ROM and regular BARs - the specs allow them to
share one which would mean you can not access the rest of the card if
the ROM is enabled - you're meant to turn it on, copy the ROM's
content, turn it off and run the BIOS from RAM.
Finally, I've seen laptops with no separate graphics BIOS at all...
have fun
Michael
Home |
Main Index |
Thread Index |
Old Index