summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-12-29 19:32:23 -0700
committerSimon Glass <sjg@chromium.org>2015-01-23 17:24:15 -0700
commit40305240c66ab5e3725c131e321402c7dfe687a2 (patch)
tree28c56e4079fdd3126c9774b9c8766f3cf8861629
parente5bc97578c189a99c291f7fe7ce89092474e43e9 (diff)
downloadu-boot-imx-40305240c66ab5e3725c131e321402c7dfe687a2.zip
u-boot-imx-40305240c66ab5e3725c131e321402c7dfe687a2.tar.gz
u-boot-imx-40305240c66ab5e3725c131e321402c7dfe687a2.tar.bz2
x86: Correct endianness isues in pci_rom
This code is too x86-dependent at present. Correct it so that it can run on big-endian machines. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--drivers/pci/pci_rom.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 7d25cc9..86f0e95 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -66,6 +66,7 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
struct pci_rom_header *rom_header;
struct pci_rom_data *rom_data;
u16 vendor, device;
+ u16 rom_vendor, rom_device;
u32 vendev;
u32 mapped_vendev;
u32 rom_address;
@@ -95,25 +96,27 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
rom_header = (struct pci_rom_header *)rom_address;
debug("PCI expansion ROM, signature %#04x, INIT size %#04x, data ptr %#04x\n",
- le32_to_cpu(rom_header->signature),
- rom_header->size * 512, le32_to_cpu(rom_header->data));
+ le16_to_cpu(rom_header->signature),
+ rom_header->size * 512, le16_to_cpu(rom_header->data));
- if (le32_to_cpu(rom_header->signature) != PCI_ROM_HDR) {
+ if (le16_to_cpu(rom_header->signature) != PCI_ROM_HDR) {
printf("Incorrect expansion ROM header signature %04x\n",
- le32_to_cpu(rom_header->signature));
+ le16_to_cpu(rom_header->signature));
return -EINVAL;
}
- rom_data = (((void *)rom_header) + le32_to_cpu(rom_header->data));
+ rom_data = (((void *)rom_header) + le16_to_cpu(rom_header->data));
+ rom_vendor = le16_to_cpu(rom_data->vendor);
+ rom_device = le16_to_cpu(rom_data->device);
debug("PCI ROM image, vendor ID %04x, device ID %04x,\n",
- rom_data->vendor, rom_data->device);
+ rom_vendor, rom_device);
/* If the device id is mapped, a mismatch is expected */
- if ((vendor != rom_data->vendor || device != rom_data->device) &&
+ if ((vendor != rom_vendor || device != rom_device) &&
(vendev == mapped_vendev)) {
printf("ID mismatch: vendor ID %04x, device ID %04x\n",
- rom_data->vendor, rom_data->device);
+ rom_vendor, rom_device);
return -EPERM;
}
@@ -144,10 +147,10 @@ int pci_rom_load(uint16_t class, struct pci_rom_header *rom_header,
image_size);
rom_data = (struct pci_rom_data *)((void *)rom_header +
- le32_to_cpu(rom_header->data));
+ le16_to_cpu(rom_header->data));
- image_size = le32_to_cpu(rom_data->ilen) * 512;
- } while ((rom_data->type != 0) && (rom_data->indicator != 0));
+ image_size = le16_to_cpu(rom_data->ilen) * 512;
+ } while ((rom_data->type != 0) && (rom_data->indicator == 0));
if (rom_data->type != 0)
return -EACCES;