[OpenBIOS] [PATCH 2/6] pci: Fix locating Mac driver from PCI rom
Benjamin Herrenschmidt
benh at kernel.crashing.org
Tue Aug 2 07:35:23 CEST 2016
The ROM is not on BAR 1 but BAR 6, I'm not sure what that code ever
did, Qemu uses BAR 6, and I think MOL does too.
Additionally, support using a raw PEF binary without a made up
header.
Eventually we need to support f-code from the ROM but that is not
for today.
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
drivers/pci.c | 54 +++++++++++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 25 deletions(-)
diff --git a/drivers/pci.c b/drivers/pci.c
index 2cffa2f..c748f20 100644
--- a/drivers/pci.c
+++ b/drivers/pci.c
@@ -774,41 +774,45 @@ int macio_keylargo_config_cb (const pci_config_t *config)
int vga_config_cb (const pci_config_t *config)
{
unsigned long rom;
- uint32_t rom_size, size, mask;
- int flags, space_code;
+ uint32_t rom_size, size, bar;
phandle_t ph;
if (config->assigned[0] != 0x00000000) {
setup_video();
- pci_decode_pci_addr(config->assigned[1],
- &flags, &space_code, &mask);
-
- rom = pci_bus_addr_to_host_addr(space_code,
- config->assigned[1] & ~0x0000000F);
-
- rom_size = config->sizes[1];
-
- ph = get_cur_dev();
-
- if (rom_size >= 8) {
- const char *p;
-
- p = (const char *)rom;
- if (p[0] == 'N' && p[1] == 'D' && p[2] == 'R' && p[3] == 'V') {
- size = *(uint32_t*)(p + 4);
- set_property(ph, "driver,AAPL,MacOS,PowerPC", p + 8, size);
- }
+ if (config->assigned[6]) {
+ rom = pci_bus_addr_to_host_addr(MEMORY_SPACE_32,
+ config->assigned[6] & ~0x0000000F);
+ rom_size = config->sizes[6];
+
+ bar = pci_config_read32(config->dev, PCI_ROM_ADDRESS);
+ bar |= PCI_ROM_ADDRESS_ENABLE;
+ pci_config_write32(config->dev, PCI_COMMAND, bar);
+ ph = get_cur_dev();
+
+ if (rom_size >= 8) {
+ const char *p;
+
+ p = (const char *)rom;
+ if (p[0] == 'N' && p[1] == 'D' && p[2] == 'R' && p[3] == 'V') {
+ size = *(uint32_t*)(p + 4);
+ set_property(ph, "driver,AAPL,MacOS,PowerPC",
+ p + 8, size);
+ } else if (p[0] == 'J' && p[1] == 'o' &&
+ p[2] == 'y' && p[3] == '!') {
+ set_property(ph, "driver,AAPL,MacOS,PowerPC",
+ p, rom_size);
+ }
+ }
}
-
- /* Currently we don't read FCode from the hardware but execute it directly */
+ /* Currently we don't read FCode from the hardware but execute
+ * it directly */
feval("['] vga-driver-fcode 2 cells + 1 byte-load");
#ifdef CONFIG_MOL
- /* Install special words for Mac On Linux */
- molvideo_init();
+ /* Install special words for Mac On Linux */
+ molvideo_init();
#endif
-
}
return 0;
--
2.7.4
More information about the OpenBIOS
mailing list