Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 361498
b: refs/heads/master
c: 547b524
h: refs/heads/master
v: v3
  • Loading branch information
Matthew Garrett authored and Linus Torvalds committed Mar 19, 2013
1 parent 9bb6cf4 commit 1bc75c6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5c7c3361d177120a9980971380b52f84c2d9c97d
refs/heads/master: 547b524636249fbe906ab78a50ab0017c490316c
55 changes: 35 additions & 20 deletions trunk/drivers/pci/rom.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
return min((size_t)(image - rom), size);
}

static loff_t pci_find_rom(struct pci_dev *pdev, size_t *size)
{
struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
loff_t start;

/* assign the ROM an address if it doesn't have one */
if (res->parent == NULL && pci_assign_resource(pdev, PCI_ROM_RESOURCE))
return 0;
start = pci_resource_start(pdev, PCI_ROM_RESOURCE);
*size = pci_resource_len(pdev, PCI_ROM_RESOURCE);

if (*size == 0)
return 0;

/* Enable ROM space decodes */
if (pci_enable_rom(pdev))
return 0;

return start;
}

/**
* pci_map_rom - map a PCI ROM to kernel space
* @pdev: pointer to pci device struct
Expand All @@ -114,21 +135,15 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
{
struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
loff_t start;
loff_t start = 0;
void __iomem *rom;

/*
* Some devices may provide ROMs via a source other than the BAR
*/
if (pdev->rom && pdev->romlen) {
*size = pdev->romlen;
return phys_to_virt(pdev->rom);
/*
* IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy
* memory map if the VGA enable bit of the Bridge Control register is
* set for embedded VGA.
*/
} else if (res->flags & IORESOURCE_ROM_SHADOW) {
if (res->flags & IORESOURCE_ROM_SHADOW) {
/* primary video rom always starts here */
start = (loff_t)0xC0000;
*size = 0x20000; /* cover C000:0 through E000:0 */
Expand All @@ -139,21 +154,21 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
return (void __iomem *)(unsigned long)
pci_resource_start(pdev, PCI_ROM_RESOURCE);
} else {
/* assign the ROM an address if it doesn't have one */
if (res->parent == NULL &&
pci_assign_resource(pdev,PCI_ROM_RESOURCE))
return NULL;
start = pci_resource_start(pdev, PCI_ROM_RESOURCE);
*size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
if (*size == 0)
return NULL;

/* Enable ROM space decodes */
if (pci_enable_rom(pdev))
return NULL;
start = pci_find_rom(pdev, size);
}
}

/*
* Some devices may provide ROMs via a source other than the BAR
*/
if (!start && pdev->rom && pdev->romlen) {
*size = pdev->romlen;
return phys_to_virt(pdev->rom);
}

if (!start)
return NULL;

rom = ioremap(start, *size);
if (!rom) {
/* restore enable if ioremap fails */
Expand Down

0 comments on commit 1bc75c6

Please sign in to comment.