version 1.4, 2015/06/24 18:23:23 |
version 1.4.18.1, 2019/06/10 22:08:26 |
|
|
|
/* $NetBSD$ */ |
|
|
/* |
/* |
* Copyright 2008 Advanced Micro Devices, Inc. |
* Copyright 2008 Advanced Micro Devices, Inc. |
* Copyright 2008 Red Hat Inc. |
* Copyright 2008 Red Hat Inc. |
|
|
* Alex Deucher |
* Alex Deucher |
* Jerome Glisse |
* Jerome Glisse |
*/ |
*/ |
|
#include <sys/cdefs.h> |
|
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
#include <drm/drmP.h> |
#include <drm/drmP.h> |
#include "radeon_reg.h" |
#include "radeon_reg.h" |
#include "radeon.h" |
#include "radeon.h" |
#include "atom.h" |
#include "atom.h" |
|
|
#include <linux/vga_switcheroo.h> |
|
#include <linux/slab.h> |
#include <linux/slab.h> |
#include <linux/acpi.h> |
#include <linux/acpi.h> |
#include <linux/string.h> |
#include <linux/string.h> |
Line 106 static bool igp_read_bios_from_vram(stru |
|
Line 110 static bool igp_read_bios_from_vram(stru |
|
|
|
static bool radeon_read_bios(struct radeon_device *rdev) |
static bool radeon_read_bios(struct radeon_device *rdev) |
{ |
{ |
uint8_t __iomem *bios; |
uint8_t __iomem *bios, val1, val2; |
size_t size; |
size_t size; |
|
|
rdev->bios = NULL; |
rdev->bios = NULL; |
Line 117 static bool radeon_read_bios(struct rade |
|
Line 121 static bool radeon_read_bios(struct rade |
|
} |
} |
|
|
#ifdef __NetBSD__ |
#ifdef __NetBSD__ |
/* |
|
* Using kmemdup results in >4-byte memory access on 64-bit |
|
* systems, which yields bogus answers on some devices. So we |
|
* use bus_space(9) to do guaranteed byte access with |
|
* bus_space_read_region_1 which seems to work better. |
|
*/ |
|
{ |
|
const bus_space_tag_t bst = rdev->pdev->pd_rom_bst; |
const bus_space_tag_t bst = rdev->pdev->pd_rom_bst; |
const bus_space_handle_t bsh = rdev->pdev->pd_rom_found_bsh; |
const bus_space_handle_t bsh = rdev->pdev->pd_rom_found_bsh; |
|
|
if (size == 0 || |
val1 = bus_space_read_1(bst, bsh, 0); |
bus_space_read_1(bst, bsh, 0) != 0x55 || |
val2 = bus_space_read_1(bst, bsh, 1); |
bus_space_read_1(bst, bsh, 1) != 0xaa) { |
#else |
|
val1 = readb(&bios[0]); |
|
val2 = readb(&bios[1]); |
|
#endif |
|
|
|
if (size == 0 || val1 != 0x55 || val2 != 0xaa) { |
pci_unmap_rom(rdev->pdev, bios); |
pci_unmap_rom(rdev->pdev, bios); |
return false; |
return false; |
} |
} |
rdev->bios = kmalloc(size, GFP_KERNEL); |
rdev->bios = kzalloc(size, GFP_KERNEL); |
if (rdev->bios == NULL) { |
if (rdev->bios == NULL) { |
pci_unmap_rom(rdev->pdev, bios); |
pci_unmap_rom(rdev->pdev, bios); |
return false; |
return false; |
} |
} |
|
#ifdef __NetBSD__ |
bus_space_read_region_1(bst, bsh, 0, rdev->bios, size); |
bus_space_read_region_1(bst, bsh, 0, rdev->bios, size); |
} |
|
#else |
#else |
if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { |
memcpy_fromio(rdev->bios, bios, size); |
pci_unmap_rom(rdev->pdev, bios); |
|
return false; |
|
} |
|
rdev->bios = kmemdup(bios, size, GFP_KERNEL); |
|
if (rdev->bios == NULL) { |
|
pci_unmap_rom(rdev->pdev, bios); |
|
return false; |
|
} |
|
#endif |
#endif |
pci_unmap_rom(rdev->pdev, bios); |
pci_unmap_rom(rdev->pdev, bios); |
return true; |
return true; |
Line 691 static bool radeon_acpi_vfct_bios(struct |
|
Line 685 static bool radeon_acpi_vfct_bios(struct |
|
vhdr->DeviceID != rdev->pdev->device) { |
vhdr->DeviceID != rdev->pdev->device) { |
DRM_INFO("ACPI VFCT table is not for this card\n"); |
DRM_INFO("ACPI VFCT table is not for this card\n"); |
goto out_unmap; |
goto out_unmap; |
}; |
} |
|
|
if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) + vhdr->ImageLength > tbl_size) { |
if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) + vhdr->ImageLength > tbl_size) { |
DRM_ERROR("ACPI VFCT image truncated\n"); |
DRM_ERROR("ACPI VFCT image truncated\n"); |
Line 723 bool radeon_get_bios(struct radeon_devic |
|
Line 717 bool radeon_get_bios(struct radeon_devic |
|
r = igp_read_bios_from_vram(rdev); |
r = igp_read_bios_from_vram(rdev); |
if (r == false) |
if (r == false) |
r = radeon_read_bios(rdev); |
r = radeon_read_bios(rdev); |
if (r == false) { |
if (r == false) |
r = radeon_read_disabled_bios(rdev); |
r = radeon_read_disabled_bios(rdev); |
} |
if (r == false) |
if (r == false) { |
|
r = radeon_read_platform_bios(rdev); |
r = radeon_read_platform_bios(rdev); |
} |
|
if (r == false || rdev->bios == NULL) { |
if (r == false || rdev->bios == NULL) { |
DRM_ERROR("Unable to locate a BIOS ROM\n"); |
DRM_ERROR("Unable to locate a BIOS ROM\n"); |
rdev->bios = NULL; |
rdev->bios = NULL; |