summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/roms/openbios/drivers')
-rw-r--r--qemu/roms/openbios/drivers/cuda.c21
-rw-r--r--qemu/roms/openbios/drivers/escc.c112
-rw-r--r--qemu/roms/openbios/drivers/escc.h2
-rw-r--r--qemu/roms/openbios/drivers/ide.c82
-rw-r--r--qemu/roms/openbios/drivers/ide.h2
-rw-r--r--qemu/roms/openbios/drivers/obio.c66
-rw-r--r--qemu/roms/openbios/drivers/pci.c147
-rw-r--r--qemu/roms/openbios/drivers/pci.fs68
-rw-r--r--qemu/roms/openbios/drivers/pci.h9
-rw-r--r--qemu/roms/openbios/drivers/sbus.c25
-rw-r--r--qemu/roms/openbios/drivers/usbohci_private.h28
-rw-r--r--qemu/roms/openbios/drivers/vga.fs11
12 files changed, 290 insertions, 283 deletions
diff --git a/qemu/roms/openbios/drivers/cuda.c b/qemu/roms/openbios/drivers/cuda.c
index 9555dea49..ff5d22de2 100644
--- a/qemu/roms/openbios/drivers/cuda.c
+++ b/qemu/roms/openbios/drivers/cuda.c
@@ -144,8 +144,22 @@ static int cuda_adb_req (void *host, const uint8_t *snd_buf, int len,
// CUDA_DPRINTF("len: %d %02x\n", len, snd_buf[0]);
len = cuda_request(host, ADB_PACKET, snd_buf, len, buffer);
if (len > 1 && buffer[0] == ADB_PACKET) {
- pos = buffer + 2;
- len -= 2;
+ /* We handle 2 types of ADB packet here:
+ Normal: <type> <status> <data> ...
+ Error : <type> <status> <cmd> (<data> ...)
+ Ideally we should use buffer[1] (status) to determine whether this
+ is a normal or error packet but this requires a corresponding fix
+ in QEMU <= 2.4. Hence we temporarily handle it this way to ease
+ the transition. */
+ if (len > 2 && buffer[2] == snd_buf[0]) {
+ /* Error */
+ pos = buffer + 3;
+ len -= 3;
+ } else {
+ /* Normal */
+ pos = buffer + 2;
+ len -= 2;
+ }
} else {
pos = buffer + 1;
len = -1;
@@ -380,7 +394,8 @@ powermgt_init(char *path)
ph = find_dev(buf);
set_property(ph, "device_type", "power-mgt", 10);
- set_property(ph, "compatible", "power-mgt", 10);
+ set_property(ph, "mgt-kind", "min-consumption-pwm-led", strlen("min-consumption-pwm-led") + 1);
+ set_property(ph, "compatible", "cuda", strlen("cuda") + 1);
}
cuda_t *cuda_init (const char *path, phys_addr_t base)
diff --git a/qemu/roms/openbios/drivers/escc.c b/qemu/roms/openbios/drivers/escc.c
index 240043be3..1990e798d 100644
--- a/qemu/roms/openbios/drivers/escc.c
+++ b/qemu/roms/openbios/drivers/escc.c
@@ -380,12 +380,44 @@ ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, int keyboard)
static void
escc_add_channel(const char *path, const char *node, phys_addr_t addr,
- uint32_t offset)
+ int esnum)
{
char buf[64], tty[32];
phandle_t dnode, aliases;
- int len;
- cell props[2];
+
+ cell props[10];
+ ucell offset;
+ int index;
+ int legacy;
+
+ int dbdma_offsets[2][2] = {
+ /* ch-b */
+ { 0x6, 0x7 },
+ /* ch-a */
+ { 0x4, 0x5 }
+ };
+
+ int reg_offsets[2][2][3] = {
+ {
+ /* ch-b */
+ { 0x00, 0x10, 0x40 },
+ /* ch-a */
+ { 0x20, 0x30, 0x50 }
+ },{
+ /* legacy ch-b */
+ { 0x0, 0x2, 0x8 },
+ /* legacy ch-a */
+ { 0x4, 0x6, 0xa }
+ }
+ };
+
+ switch (esnum) {
+ case 2: index = 1; legacy = 0; break;
+ case 3: index = 0; legacy = 0; break;
+ case 4: index = 1; legacy = 1; break;
+ case 5: index = 0; legacy = 1; break;
+ default: return;
+ }
/* add device */
@@ -411,31 +443,49 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr,
set_property(dnode, "device_type", "serial",
strlen("serial") + 1);
- snprintf(buf, sizeof(buf), "ch-%s", node);
- len = strlen(buf) + 1;
- snprintf(buf + len, sizeof(buf) - len, "CHRP,es2");
- set_property(dnode, "compatible", buf, len + 9);
+ snprintf(buf, sizeof(buf), "chrp,es%d", esnum);
+ set_property(dnode, "compatible", buf, 9);
- props[0] = IO_ESCC_OFFSET + offset * 0x20;
- props[1] = 0x00000020;
- set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell));
+ if (legacy) {
+ offset = IO_ESCC_LEGACY_OFFSET;
+ } else {
+ offset = IO_ESCC_OFFSET;
+ }
- props[0] = addr + IO_ESCC_OFFSET + offset * 0x20;
+ props[0] = offset + reg_offsets[legacy][index][0];
+ props[1] = 0x1;
+ props[2] = offset + reg_offsets[legacy][index][1];
+ props[3] = 0x1;
+ props[4] = offset + reg_offsets[legacy][index][2];
+ props[5] = 0x1;
+ props[6] = 0x8000 + dbdma_offsets[index][0] * 0x100;
+ props[7] = 0x100;
+ props[8] = 0x8000 + dbdma_offsets[index][1] * 0x100;
+ props[9] = 0x100;
+ set_property(dnode, "reg", (char *)&props, 10 * sizeof(cell));
+
+ props[0] = addr + offset + reg_offsets[legacy][index][0];
OLDWORLD(set_property(dnode, "AAPL,address",
(char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - offset;
+ props[0] = 0x10 - index;
OLDWORLD(set_property(dnode, "AAPL,interrupts",
(char *)&props, 1 * sizeof(cell)));
- props[0] = (0x24) + offset;
- props[1] = 0;
+ props[0] = (0x24) + index;
+ props[1] = 0x1;
+ props[2] = dbdma_offsets[index][0];
+ props[3] = 0x0;
+ props[4] = dbdma_offsets[index][1];
+ props[5] = 0x0;
NEWWORLD(set_property(dnode, "interrupts",
- (char *)&props, 2 * sizeof(cell)));
+ (char *)&props, 6 * sizeof(cell)));
+
+ set_int_property(dnode, "slot-names", 0);
device_end();
- uart_init_line((unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20,
+ uart_init_line((unsigned char*)addr + offset + reg_offsets[legacy][index][0],
CONFIG_SERIAL_SPEED);
}
@@ -464,13 +514,39 @@ escc_init(const char *path, phys_addr_t addr)
set_property(dnode, "device_type", "escc",
strlen("escc") + 1);
set_property(dnode, "compatible", "escc\0CHRP,es0", 14);
+ set_property(dnode, "ranges", "", 0);
fword("finish-device");
- escc_add_channel(buf, "a", addr, 1);
- escc_add_channel(buf, "b", addr, 0);
+ escc_add_channel(buf, "a", addr, 2);
+ escc_add_channel(buf, "b", addr, 3);
escc_serial_dev = (unsigned char *)addr + IO_ESCC_OFFSET +
(CONFIG_SERIAL_PORT ? 0 : 0x20);
+
+ push_str(path);
+ fword("find-device");
+ fword("new-device");
+
+ push_str("escc-legacy");
+ fword("device-name");
+
+ snprintf(buf, sizeof(buf), "%s/escc-legacy", path);
+
+ dnode = find_dev(buf);
+
+ set_int_property(dnode, "#address-cells", 1);
+ props[0] = __cpu_to_be32(IO_ESCC_LEGACY_OFFSET);
+ props[1] = __cpu_to_be32(IO_ESCC_LEGACY_SIZE);
+ set_property(dnode, "reg", (char *)&props, sizeof(props));
+ set_property(dnode, "device_type", "escc-legacy",
+ strlen("escc-legacy") + 1);
+ set_property(dnode, "compatible", "chrp,es1", 9);
+ set_property(dnode, "ranges", "", 0);
+
+ fword("finish-device");
+
+ escc_add_channel(buf, "a", addr, 4);
+ escc_add_channel(buf, "b", addr, 5);
}
#endif
diff --git a/qemu/roms/openbios/drivers/escc.h b/qemu/roms/openbios/drivers/escc.h
index caaf00d40..e73f267b2 100644
--- a/qemu/roms/openbios/drivers/escc.h
+++ b/qemu/roms/openbios/drivers/escc.h
@@ -1,6 +1,8 @@
#define IO_ESCC_SIZE 0x00001000
#define IO_ESCC_OFFSET 0x00013000
+#define IO_ESCC_LEGACY_SIZE 0x00001000
+#define IO_ESCC_LEGACY_OFFSET 0x00012000
#define ZS_REGS 8
diff --git a/qemu/roms/openbios/drivers/ide.c b/qemu/roms/openbios/drivers/ide.c
index 327c64a40..1da60c895 100644
--- a/qemu/roms/openbios/drivers/ide.c
+++ b/qemu/roms/openbios/drivers/ide.c
@@ -73,13 +73,13 @@ static inline void ide_add_channel(struct ide_channel *chan)
channels = chan;
}
-static struct ide_channel *ide_seek_channel(const char *name)
+static struct ide_channel *ide_seek_channel(phandle_t ph)
{
struct ide_channel *current;
current = channels;
while (current) {
- if (!strcmp(current->name, name))
+ if (current->ph == ph)
return current;
current = current->next;
}
@@ -1247,11 +1247,10 @@ ob_ide_initialize(int *idx)
static void
ob_ide_open(int *idx)
{
- int ret=1, len;
+ int ret=1;
phandle_t ph;
struct ide_drive *drive;
struct ide_channel *chan;
- char *idename;
int unit;
fword("my-unit");
@@ -1260,9 +1259,8 @@ ob_ide_open(int *idx)
fword("my-parent");
fword("ihandle>phandle");
ph=(phandle_t)POP();
- idename=get_property(ph, "name", &len);
- chan = ide_seek_channel(idename);
+ chan = ide_seek_channel(ph);
drive = &chan->drives[unit];
*(struct ide_drive **)idx = drive;
@@ -1380,9 +1378,6 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
chan = malloc(sizeof(struct ide_channel));
- snprintf(chan->name, sizeof(chan->name),
- DEV_NAME, current_channel);
-
chan->mmio = 0;
for (j = 0; j < 8; j++)
@@ -1424,9 +1419,9 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
snprintf(nodebuff, sizeof(nodebuff), "%s/" DEV_NAME, path,
current_channel);
- REGISTER_NAMED_NODE(ob_ide_ctrl, nodebuff);
+ REGISTER_NAMED_NODE_PHANDLE(ob_ide_ctrl, nodebuff, dnode);
- dnode = find_dev(nodebuff);
+ chan->ph = dnode;
#if !defined(CONFIG_PPC) && !defined(CONFIG_SPARC64)
props[0]=14; props[1]=0;
@@ -1468,11 +1463,9 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
break;
}
IDE_DPRINTF("%s]: %s\n", media, drive->model);
- snprintf(nodebuff, sizeof(nodebuff),
- "%s/" DEV_NAME "/%s", path, current_channel,
- media);
- REGISTER_NAMED_NODE(ob_ide, nodebuff);
- dnode=find_dev(nodebuff);
+ snprintf(nodebuff, sizeof(nodebuff), "%s/%s",
+ get_path_from_ph(dnode), media);
+ REGISTER_NAMED_NODE_PHANDLE(ob_ide, nodebuff, dnode);
set_int_property(dnode, "reg", j);
/* create aliases */
@@ -1488,6 +1481,28 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
return 0;
}
+void ob_ide_quiesce(void)
+{
+ struct ide_channel *channel;
+ int i;
+
+ channel = channels;
+ while (channel) {
+ for (i = 0; i < 2; i++) {
+ struct ide_drive *drive = &channel->drives[i];
+
+ if (!drive->present)
+ continue;
+
+ ob_ide_select_drive(drive);
+ ob_ide_software_reset(drive);
+ ob_ide_device_type_check(drive);
+ }
+
+ channel = channel->next;
+ }
+}
+
#if defined(CONFIG_DRIVER_MACIO)
static unsigned char
macio_ide_inb(struct ide_channel *chan, unsigned int port)
@@ -1527,16 +1542,13 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
struct ide_channel *chan;
/* IDE ports on Macs are numbered from 3.
- * Also see comments in macio.c:openpic_init() */
+ * Also see comments in pci.c:ob_pci_host_set_interrupt_map() */
current_channel = 3;
- for (i = 0; i < nb_channels; i++, current_channel++) {
+ for (i = 0; i < nb_channels; i++) {
chan = malloc(sizeof(struct ide_channel));
- snprintf(chan->name, sizeof(chan->name),
- DEV_NAME, current_channel);
-
chan->mmio = addr + MACIO_IDE_OFFSET + i * MACIO_IDE_SIZE;
chan->obide_inb = macio_ide_inb;
@@ -1574,13 +1586,19 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
snprintf(nodebuff, sizeof(nodebuff), "%s/" DEV_NAME, path,
current_channel);
- REGISTER_NAMED_NODE(ob_ide_ctrl, nodebuff);
+ REGISTER_NAMED_NODE_PHANDLE(ob_ide_ctrl, nodebuff, dnode);
- dnode = find_dev(nodebuff);
+ chan->ph = dnode;
set_property(dnode, "compatible", (is_oldworld() ?
"heathrow-ata" : "keylargo-ata"), 13);
+ set_property(dnode, "model", ((current_channel == 3) ?
+ "ata-3" : "ata-4"), strlen("ata-*") + 1);
+
+ set_property(dnode, "AAPL,connector", "ata",
+ strlen("ata") + 1);
+
props[0] = 0x00000526;
props[1] = 0x00000085;
props[2] = 0x00000025;
@@ -1589,8 +1607,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
props[5] = 0x00000000;
props[6] = 0x00000000;
props[7] = 0x00000000;
- OLDWORLD(set_property(dnode, "AAPL,pio-timing",
- (char *)&props, 8*sizeof(props[0])));
+ set_property(dnode, "AAPL,pio-timing",
+ (char *)&props, 8*sizeof(props[0]));
/* The first interrupt entry is the ide interrupt, the second
the dbdma interrupt */
@@ -1633,9 +1651,9 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
OLDWORLD(set_property(dnode, "AAPL,address",
(char *)&props, 2*sizeof(props[0])));
- props[0] = 0;
- OLDWORLD(set_property(dnode, "AAPL,bus-id", (char*)props,
- 1 * sizeof(props[0])));
+ props[0] = i;
+ set_property(dnode, "AAPL,bus-id", (char*)props,
+ 1 * sizeof(props[0]));
IDE_DPRINTF(DEV_NAME": [io ports 0x%lx]\n",
current_channel, chan->mmio);
@@ -1663,11 +1681,9 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
break;
}
IDE_DPRINTF("%s]: %s\n", media, drive->model);
- snprintf(nodebuff, sizeof(nodebuff),
- "%s/" DEV_NAME "/%s", path, current_channel,
- media);
- REGISTER_NAMED_NODE(ob_ide, nodebuff);
- dnode = find_dev(nodebuff);
+ snprintf(nodebuff, sizeof(nodebuff), "%s/%s",
+ get_path_from_ph(dnode), media);
+ REGISTER_NAMED_NODE_PHANDLE(ob_ide, nodebuff, dnode);
set_int_property(dnode, "reg", j);
/* create aliases */
diff --git a/qemu/roms/openbios/drivers/ide.h b/qemu/roms/openbios/drivers/ide.h
index d6c4b9f5d..8983c8ecf 100644
--- a/qemu/roms/openbios/drivers/ide.h
+++ b/qemu/roms/openbios/drivers/ide.h
@@ -167,7 +167,7 @@ struct ide_drive {
struct ide_channel {
- char name[32];
+ phandle_t ph;
struct ide_channel *next;
/*
diff --git a/qemu/roms/openbios/drivers/obio.c b/qemu/roms/openbios/drivers/obio.c
index 7c135a362..4ac063188 100644
--- a/qemu/roms/openbios/drivers/obio.c
+++ b/qemu/roms/openbios/drivers/obio.c
@@ -26,8 +26,6 @@
#define PROMDEV_SCREEN 0 /* output to screen */
#define PROMDEV_TTYA 1 /* in/out to ttya */
-/* DECLARE data structures for the nodes. */
-DECLARE_UNNAMED_NODE( ob_obio, INSTALL_OPEN, sizeof(int) );
void
ob_new_obio_device(const char *name, const char *type)
@@ -397,45 +395,6 @@ ob_smp_init(unsigned long mem_size)
}
static void
-ob_obio_open(__attribute__((unused))int *idx)
-{
- int ret=1;
- RET ( -ret );
-}
-
-static void
-ob_obio_close(__attribute__((unused))int *idx)
-{
- selfword("close-deblocker");
-}
-
-static void
-ob_obio_initialize(__attribute__((unused))int *idx)
-{
- push_str("/");
- fword("find-device");
- fword("new-device");
-
- push_str("obio");
- fword("device-name");
-
- push_str("hierarchical");
- fword("device-type");
-
- PUSH(2);
- fword("encode-int");
- push_str("#address-cells");
- fword("property");
-
- PUSH(1);
- fword("encode-int");
- push_str("#size-cells");
- fword("property");
-
- fword("finish-device");
-}
-
-static void
ob_set_obio_ranges(uint64_t base)
{
push_str("/obio");
@@ -458,27 +417,6 @@ ob_set_obio_ranges(uint64_t base)
fword("property");
}
-static void
-ob_obio_decodeunit(__attribute__((unused)) int *idx)
-{
- fword("decode-unit-sbus");
-}
-
-
-static void
-ob_obio_encodeunit(__attribute__((unused)) int *idx)
-{
- fword("encode-unit-sbus");
-}
-
-NODE_METHODS(ob_obio) = {
- { NULL, ob_obio_initialize },
- { "open", ob_obio_open },
- { "close", ob_obio_close },
- { "encode-unit", ob_obio_encodeunit },
- { "decode-unit", ob_obio_decodeunit },
-};
-
int
ob_obio_init(uint64_t slavio_base, unsigned long fd_offset,
@@ -491,10 +429,6 @@ ob_obio_init(uint64_t slavio_base, unsigned long fd_offset,
// http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
//printk("Initializing OBIO devices...\n");
-#if 0 // XXX
- REGISTER_NAMED_NODE(ob_obio, "/obio");
- device_end();
-#endif
ob_set_obio_ranges(slavio_base);
// Zilog Z8530 serial ports, see http://www.zilog.com
diff --git a/qemu/roms/openbios/drivers/pci.c b/qemu/roms/openbios/drivers/pci.c
index 366f4a17f..5062f302f 100644
--- a/qemu/roms/openbios/drivers/pci.c
+++ b/qemu/roms/openbios/drivers/pci.c
@@ -144,9 +144,16 @@ static void dump_reg_property(const char* description, int nreg, u32 *reg)
}
#endif
-static unsigned long pci_bus_addr_to_host_addr(uint32_t ba)
+static unsigned long pci_bus_addr_to_host_addr(int space, uint32_t ba)
{
- return arch->host_pci_base + (unsigned long)ba;
+ if (space == IO_SPACE) {
+ return arch->io_base + (unsigned long)ba;
+ } else if (space == MEMORY_SPACE_32) {
+ return arch->host_pci_base + (unsigned long)ba;
+ } else {
+ /* Return unaltered to aid debugging property values */
+ return (unsigned long)ba;
+ }
}
static void
@@ -340,22 +347,27 @@ ob_pci_encode_unit(int *idx)
ss, dev, fn, buf);
}
-/* ( pci-addr.lo pci-addr.hi size -- virt ) */
+/* ( pci-addr.lo pci-addr.mid pci-addr.hi size -- virt ) */
static void
ob_pci_map_in(int *idx)
{
phys_addr_t phys;
uint32_t ba;
- ucell size, virt;
+ ucell size, virt, tmp;
+ int space;
PCI_DPRINTF("ob_pci_bar_map_in idx=%p\n", idx);
size = POP();
+ tmp = POP();
POP();
ba = POP();
- phys = pci_bus_addr_to_host_addr(ba);
+ /* Get the space from the pci-addr.hi */
+ space = ((tmp & PCI_RANGE_TYPE_MASK) >> 24);
+
+ phys = pci_bus_addr_to_host_addr(space, ba);
#if defined(CONFIG_OFMEM)
ofmem_claim_phys(phys, size, 0);
@@ -448,13 +460,18 @@ static void pci_host_set_ranges(const pci_config_t *config)
int ncells;
ncells = 0;
- /* first encode PCI configuration space */
- {
- ncells += pci_encode_phys_addr(props + ncells, 0, CONFIGURATION_SPACE,
+
+#ifdef CONFIG_SPARC64
+ /* While configuration space isn't mentioned in the IEEE-1275 PCI
+ bindings, it appears in the PCI host bridge ranges property in
+ real device trees. Hence we disable this range for all host
+ bridges except for SPARC, particularly as it causes Darwin/OS X
+ to incorrectly calculated PCI memory space ranges on PPC. */
+ ncells += pci_encode_phys_addr(props + ncells, 0, CONFIGURATION_SPACE,
config->dev, 0, 0);
ncells += host_encode_phys_addr(props + ncells, arch->cfg_addr);
ncells += pci_encode_size(props + ncells, arch->cfg_len);
- }
+#endif
if (arch->io_base) {
ncells += pci_encode_phys_addr(props + ncells, 0, IO_SPACE,
@@ -585,13 +602,18 @@ static void pci_set_AAPL_address(const pci_config_t *config)
{
phandle_t dev = get_cur_dev();
cell props[7];
- int ncells, i;
+ uint32_t mask;
+ int ncells, i, flags, space_code;
ncells = 0;
for (i = 0; i < 6; i++) {
if (!config->assigned[i] || !config->sizes[i])
continue;
- props[ncells++] = config->assigned[i] & ~0x0000000F;
+ pci_decode_pci_addr(config->assigned[i],
+ &flags, &space_code, &mask);
+
+ props[ncells++] = pci_bus_addr_to_host_addr(space_code,
+ config->assigned[i] & ~mask);
}
if (ncells)
set_property(dev, "AAPL,address", (char *)props,
@@ -752,13 +774,19 @@ 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;
+ uint32_t rom_size, size, mask;
+ int flags, space_code;
phandle_t ph;
if (config->assigned[0] != 0x00000000) {
setup_video();
- rom = pci_bus_addr_to_host_addr(config->assigned[1] & ~0x0000000F);
+ 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();
@@ -824,7 +852,7 @@ int ebus_config_cb(const pci_config_t *config)
ncells += pci_encode_phys_addr(props + ncells,
flags, space_code, config->dev,
PCI_BASE_ADDR_0 + (i * sizeof(uint32_t)),
- 0);
+ config->assigned[i] & ~mask);
props[ncells++] = config->sizes[i];
}
@@ -997,7 +1025,10 @@ static void ob_pci_add_properties(phandle_t phandle,
}
pci_set_assigned_addresses(phandle, config, num_bars);
- OLDWORLD(pci_set_AAPL_address(config));
+
+ if (is_apple()) {
+ pci_set_AAPL_address(config);
+ }
PCI_DPRINTF("\n");
}
@@ -1397,9 +1428,11 @@ static void ob_pci_set_available(phandle_t host, unsigned long mem_base, unsigne
static void ob_pci_host_set_interrupt_map(phandle_t host)
{
- phandle_t dnode = 0;
- u32 props[128];
- int i;
+ phandle_t dnode = 0, pci_childnode = 0;
+ u32 props[128], intno;
+ int i, ncells, len;
+ u32 *val, addr;
+ char *reg;
#if defined(CONFIG_PPC)
phandle_t target_node;
@@ -1420,16 +1453,22 @@ static void ob_pci_host_set_interrupt_map(phandle_t host)
target_node = find_dev("/pci/mac-io/escc/ch-b");
set_int_property(target_node, "interrupt-parent", dnode);
+ target_node = find_dev("/pci/mac-io/escc-legacy/ch-a");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
+ target_node = find_dev("/pci/mac-io/escc-legacy/ch-b");
+ set_int_property(target_node, "interrupt-parent", dnode);
+
/* QEMU only emulates 2 of the 3 ata buses currently */
/* On a new world Mac these are not numbered but named by the
* ATA version they support. Thus we have: ata-3, ata-3, ata-4
* On g3beige they all called just ide.
- * We take ata-3 and ata-4 which seems to work for both
- * at least for clients we care about */
- target_node = find_dev("/pci/mac-io/ata-3");
+ * We take 2 x ata-3 buses which seems to work for
+ * at least the clients we care about */
+ target_node = find_dev("/pci/mac-io/ata-3@20000");
set_int_property(target_node, "interrupt-parent", dnode);
- target_node = find_dev("/pci/mac-io/ata-4");
+ target_node = find_dev("/pci/mac-io/ata-3@21000");
set_int_property(target_node, "interrupt-parent", dnode);
target_node = find_dev("/pci/mac-io/via-cuda");
@@ -1437,69 +1476,61 @@ static void ob_pci_host_set_interrupt_map(phandle_t host)
target_node = find_dev("/pci");
set_int_property(target_node, "interrupt-parent", dnode);
-
- /* openpic interrupt mapping */
- for (i = 0; i < (7*8); i += 7) {
- props[i + PCI_INT_MAP_PCI0] = 0;
- props[i + PCI_INT_MAP_PCI1] = 0;
- props[i + PCI_INT_MAP_PCI2] = 0;
- props[i + PCI_INT_MAP_PCI_INT] = (i / 7) + 1; // starts at PINA=1
- props[i + PCI_INT_MAP_PIC_HANDLE] = dnode;
- props[i + PCI_INT_MAP_PIC_INT] = arch->irqs[i / 7];
- props[i + PCI_INT_MAP_PIC_POL] = 3;
- }
- set_property(host, "interrupt-map", (char *)props, 7 * 8 * sizeof(props[0]));
-
- props[PCI_INT_MAP_PCI0] = 0;
- props[PCI_INT_MAP_PCI1] = 0;
- props[PCI_INT_MAP_PCI2] = 0;
- props[PCI_INT_MAP_PCI_INT] = 0x7;
-
- set_property(host, "interrupt-map-mask", (char *)props, 4 * sizeof(props[0]));
}
-#elif defined(CONFIG_SPARC64)
- int ncells, len;
- u32 *val, addr;
- char *reg;
+#else
+ /* PCI host bridge is the default interrupt controller */
+ dnode = host;
+#endif
/* Set interrupt-map for PCI devices with an interrupt pin present */
ncells = 0;
PUSH(host);
fword("child");
- dnode = POP();
- while (dnode) {
- if (get_int_property(dnode, "interrupts", &len)) {
- reg = get_property(dnode, "reg", &len);
- if (reg) {
+ pci_childnode = POP();
+ while (pci_childnode) {
+ intno = get_int_property(pci_childnode, "interrupts", &len);
+ if (len && intno) {
+ reg = get_property(pci_childnode, "reg", &len);
+ if (len && reg) {
val = (u32 *)reg;
for (i = 0; i < (len / sizeof(u32)); i += 5) {
addr = val[i];
/* Device address is in 1st 32-bit word of encoded PCI address for config space */
- if (!(addr & 0x03000000)) {
+ if ((addr & PCI_RANGE_TYPE_MASK) == PCI_RANGE_CONFIG) {
+#if defined(CONFIG_SPARC64)
ncells += pci_encode_phys_addr(props + ncells, 0, 0, addr, 0, 0);
- props[ncells++] = 1; /* always interrupt pin 1 for QEMU */
- props[ncells++] = host;
- props[ncells++] = SUN4U_INTERRUPT(addr, 1);
+ props[ncells++] = intno;
+ props[ncells++] = dnode;
+ props[ncells++] = SUN4U_INTERRUPT(addr, intno);
+#elif defined(CONFIG_PPC)
+ ncells += pci_encode_phys_addr(props + ncells, 0, 0, addr, 0, 0);
+ props[ncells++] = intno;
+ props[ncells++] = dnode;
+ props[ncells++] = arch->irqs[intno - 1];
+ props[ncells++] = 3;
+#else
+ /* Keep compiler quiet */
+ dnode = dnode;
+#endif
}
}
}
}
- PUSH(dnode);
+ PUSH(pci_childnode);
fword("peer");
- dnode = POP();
+ pci_childnode = POP();
}
set_property(host, "interrupt-map", (char *)props, ncells * sizeof(props[0]));
props[0] = 0x0000f800;
props[1] = 0x0;
props[2] = 0x0;
- props[3] = 7;
+ props[3] = 0x7;
set_property(host, "interrupt-map-mask", (char *)props, 4 * sizeof(props[0]));
-#endif
}
int ob_pci_init(void)
diff --git a/qemu/roms/openbios/drivers/pci.fs b/qemu/roms/openbios/drivers/pci.fs
index 563b652a4..a7b56e1f8 100644
--- a/qemu/roms/openbios/drivers/pci.fs
+++ b/qemu/roms/openbios/drivers/pci.fs
@@ -12,59 +12,19 @@
rot encode-int encode+
;
-\ Get region offset for BAR reg
-: pci-bar-offset@ ( bar-reg -- off.lo off.hi -1 | 0 )
- " reg" active-package get-package-property 0= if
- begin
- decode-phys \ ( reg prop prop-len phys.lo phys.mid phys.hi )
- ff and 5 pick = if
- >r >r 3drop r> r>
- -1 exit
- else
- 2drop
- then
- \ Drop the size as we don't need it
- decode-int drop decode-int drop
- dup 0=
- until
- 3drop
- 0 exit
- else
- 0
- then
- ;
-
-\ Get region size for BAR reg
-: pci-bar-size@ ( bar-reg -- size )
- " reg" active-package get-package-property 0= if
- begin
- decode-phys \ ( reg prop prop-len phys.lo phys.mid phys.hi )
- ff and 5 pick = if
- 2drop decode-int drop
- decode-int
- >r 3drop r>
- exit
- else
- 2drop decode-int drop
- decode-int drop
- then
- dup 0=
- until
- 3drop
- 0 \ default size of 0 if BAR not found
- then
- ;
-
-\ Get base address for configured BAR reg
-: pci-bar-base@ ( bar-reg -- addr.lo addr.hi -1 | 0 )
+\ Get PCI physical address and size for configured BAR reg
+: pci-bar>pci-addr ( bar-reg -- addr.lo addr.mid addr.hi size -1 | 0 )
" assigned-addresses" active-package get-package-property 0= if
begin
decode-phys \ ( reg prop prop-len phys.lo phys.mid phys.hi )
- ff and 5 pick = if
- >r >r 3drop r> r>
+ dup ff and 6 pick = if
+ >r >r >r rot drop
+ decode-int drop decode-int
+ -rot 2drop
+ r> swap r> r> rot
-1 exit
else
- 2drop
+ 3drop
then
\ Drop the size as we don't need it
decode-int drop decode-int drop
@@ -77,16 +37,4 @@
then
;
-\ Get PCI bus address and size for configured BAR reg
-: pci-bar>pci-region ( bar-reg -- addr.lo addr.hi size )
- dup
- >r pci-bar-offset@ if
- swap r@ pci-bar-base@ if
- swap d+
- then
- swap r@ pci-bar-size@
- then
- r> drop
- ;
-
[THEN]
diff --git a/qemu/roms/openbios/drivers/pci.h b/qemu/roms/openbios/drivers/pci.h
index 84a2b2cf6..d5aa5f84a 100644
--- a/qemu/roms/openbios/drivers/pci.h
+++ b/qemu/roms/openbios/drivers/pci.h
@@ -59,6 +59,15 @@
#define PCI_MIN_GNT 0x3e /* 8 bits */
#define PCI_MAX_LAT 0x3f /* 8 bits */
+#define PCI_RANGE_RELOCATABLE 0x80000000
+#define PCI_RANGE_PREFETCHABLE 0x40000000
+#define PCI_RANGE_ALIASED 0x20000000
+#define PCI_RANGE_TYPE_MASK 0x03000000
+#define PCI_RANGE_MMIO_64BIT 0x03000000
+#define PCI_RANGE_MMIO 0x02000000
+#define PCI_RANGE_IOPORT 0x01000000
+#define PCI_RANGE_CONFIG 0x00000000
+
typedef struct {
u16 signature;
u8 reserved[0x16];
diff --git a/qemu/roms/openbios/drivers/sbus.c b/qemu/roms/openbios/drivers/sbus.c
index a9b26c0a0..4caa59aaf 100644
--- a/qemu/roms/openbios/drivers/sbus.c
+++ b/qemu/roms/openbios/drivers/sbus.c
@@ -369,31 +369,6 @@ sbus_probe_slot_ss600mp(unsigned int slot, uint64_t base)
}
}
-static void
-ob_sbus_open(void)
-{
- int ret=1;
- RET ( -ret );
-}
-
-static void
-ob_sbus_close(void)
-{
- selfword("close-deblocker");
-}
-
-static void
-ob_sbus_initialize(void)
-{
-}
-
-
-NODE_METHODS(ob_sbus_node) = {
- { NULL, ob_sbus_initialize },
- { "open", ob_sbus_open },
- { "close", ob_sbus_close },
-};
-
struct sbus_offset {
int slot, type;
uint64_t base;
diff --git a/qemu/roms/openbios/drivers/usbohci_private.h b/qemu/roms/openbios/drivers/usbohci_private.h
index b3a723e21..99c964100 100644
--- a/qemu/roms/openbios/drivers/usbohci_private.h
+++ b/qemu/roms/openbios/drivers/usbohci_private.h
@@ -43,7 +43,7 @@
// FIXME: fake
typedef enum { CMD} reg;
- enum {
+ extern enum {
NumberDownstreamPorts = 1<<0,
PowerSwitchingMode = 1<<8,
NoPowerSwitching = 1<<9,
@@ -53,17 +53,17 @@
PowerOnToPowerGoodTime = 1<<24
} HcRhDescriptorAReg;
- enum {
+ extern enum {
NumberDownstreamPortsMask = MASK(0, 8),
PowerOnToPowerGoodTimeMask = MASK(24, 8)
} HcRhDescriptorAMask;
- enum {
+ extern enum {
DeviceRemovable = 1<<0,
PortPowerControlMask = 1<<16
} HcRhDescriptorBReg;
- enum {
+ extern enum {
CurrentConnectStatus = 1<<0,
PortEnableStatus = 1<<1,
PortSuspendStatus = 1<<2,
@@ -77,7 +77,7 @@
PortOverCurrentIndicatorChange = 1<<19,
PortResetStatusChange = 1<<20
} HcRhPortStatusRead;
- enum {
+ extern enum {
ClearPortEnable = 1<<0,
SetPortEnable = 1<<1,
SetPortSuspend = 1<<2,
@@ -87,7 +87,7 @@
ClearPortPower = 1<<9,
} HcRhPortStatusSet;
- enum {
+ extern enum {
LocalPowerStatus = 1<<0,
OverCurrentIndicator = 1<<1,
DeviceRemoteWakeupEnable = 1<<15,
@@ -96,18 +96,18 @@
ClearRemoteWakeupEnable = 1<<31
} HcRhStatusReg;
- enum {
+ extern enum {
FrameInterval = 1<<0,
FSLargestDataPacket = 1<<16,
FrameIntervalToggle = 1<<31
} HcFmIntervalOffset;
- enum {
+ extern enum {
FrameIntervalMask = MASK(0, 14),
FSLargestDataPacketMask = MASK(16, 15),
FrameIntervalToggleMask = MASK(31, 1)
} HcFmIntervalMask;
- enum {
+ extern enum {
ControlBulkServiceRatio = 1<<0,
PeriodicListEnable = 1<<2,
IsochronousEnable = 1<<3,
@@ -119,7 +119,7 @@
RemoteWakeupEnable = 1<<10
} HcControlReg;
- enum {
+ extern enum {
ControlBulkServiceRatioMask = MASK(0, 2),
HostControllerFunctionalStateMask = MASK(6, 2)
} HcControlMask;
@@ -131,7 +131,7 @@
USBSuspend = 3*HostControllerFunctionalState
};
- enum {
+ extern enum {
HostControllerReset = 1<<0,
ControlListFilled = 1<<1,
BulkListFilled = 1<<2,
@@ -139,16 +139,16 @@
SchedulingOverrunCount = 1<<16
} HcCommandStatusReg;
- enum {
+ extern enum {
SchedulingOverrunCountMask = MASK(16, 2)
} HcCommandStatusMask;
- enum {
+ extern enum {
FrameRemaining = 1<<0,
FrameRemainingToggle = 1<<31
} HcFmRemainingReg;
- enum {
+ extern enum {
SchedulingOverrung = 1<<0,
WritebackDoneHead = 1<<1,
StartofFrame = 1<<2,
diff --git a/qemu/roms/openbios/drivers/vga.fs b/qemu/roms/openbios/drivers/vga.fs
index ec4c6c5f1..29a043a7a 100644
--- a/qemu/roms/openbios/drivers/vga.fs
+++ b/qemu/roms/openbios/drivers/vga.fs
@@ -109,16 +109,17 @@ h# 1 constant VBE_DISPI_ENABLED
\ PCI
\
-" pci-bar>pci-region" (find-xt) value pci-bar>pci-region-xt
-: pci-bar>pci-region pci-bar>pci-region-xt execute ;
+" pci-bar>pci-addr" (find-xt) value pci-bar>pci-addr-xt
+: pci-bar>pci-addr pci-bar>pci-addr-xt execute ;
h# 10 constant cfg-bar0 \ Framebuffer BAR
-1 value fb-addr
: map-fb ( -- )
- cfg-bar0 pci-bar>pci-region \ ( pci-addr.lo pci-addr.hi size )
- " pci-map-in" $call-parent
- to fb-addr
+ cfg-bar0 pci-bar>pci-addr if \ ( pci-addr.lo pci-addr.mid pci-addr.hi size )
+ " pci-map-in" $call-parent
+ to fb-addr
+ then
;
\