[OpenBIOS] r388 - in openbios-devel: arch/ppc/qemu drivers include/openbios
svn at openbios.org
svn at openbios.org
Sun Jan 11 02:03:16 CET 2009
Author: laurent
Date: 2009-01-11 02:03:16 +0100 (Sun, 11 Jan 2009)
New Revision: 388
Modified:
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/arch/ppc/qemu/tree.fs
openbios-devel/drivers/cuda.c
openbios-devel/drivers/pci.c
openbios-devel/include/openbios/drivers.h
Log:
Create properties for an oldworld machine if needed.
If arch is ppc and machine arch id is heathrow, we create:
- properties in root node for a powermac beige
(Linux says "Powermac G3 (Silk)")
- "AAPL,interrupts" and "AAPL,address" properties in PCI device tree.
Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c 2009-01-11 00:34:08 UTC (rev 387)
+++ openbios-devel/arch/ppc/qemu/init.c 2009-01-11 01:03:16 UTC (rev 388)
@@ -24,6 +24,7 @@
#include "openbios/bindings.h"
#include "openbios/pci.h"
#include "openbios/nvram.h"
+#include "openbios/drivers.h"
#include "qemu/qemu.h"
#include "ofmem.h"
#include "openbios-version.h"
@@ -46,8 +47,9 @@
void (*initfn)(const struct cpudef *cpu);
};
+static uint16_t machine_id = 0;
+
extern void unexpected_excep( int vector );
-extern void ob_pci_init( void );
extern void setup_timers( void );
void
@@ -64,6 +66,16 @@
ARCH_HEATHROW,
};
+int is_apple(void)
+{
+ return 1;
+}
+
+int is_oldworld(void)
+{
+ return machine_id == ARCH_HEATHROW;
+}
+
static const pci_arch_t known_arch[] = {
[ARCH_PREP] = { "PREP", 0x1057, 0x4801, 0x80800000, 0x800c0000,
0x80000000, 0x00100000, 0xf0000000, 0x10000000,
@@ -120,7 +132,6 @@
entry( void )
{
uint32_t temp = 0;
- uint16_t machine_id = 0;
char buf[5], qemu_uuid[16];
arch = &known_arch[ARCH_HEATHROW];
@@ -430,6 +441,88 @@
const struct cpudef *cpu;
char buf[64];
+ /* set device tree root info */
+
+ push_str("/");
+ fword("find-device");
+
+ switch(machine_id) {
+ case ARCH_HEATHROW: /* OldWord */
+
+ /* model */
+
+ push_str("Power Macintosh");
+ fword("model");
+
+ /* compatible */
+
+ push_str("AAPL,PowerMac G3");
+ fword("encode-string");
+ push_str("MacRISC");
+ fword("encode-string");
+ fword("encode+");
+ push_str("compatible");
+ fword("property");
+
+ /* misc */
+
+ push_str("device-tree");
+ fword("encode-string");
+ push_str("AAPL,original-name");
+ fword("property");
+
+ PUSH(0);
+ fword("encode-int");
+ push_str("AAPL,cpu-id");
+ fword("property");
+
+ PUSH(66 * 1000 * 1000);
+ fword("encode-int");
+ push_str("clock-frequency");
+ fword("property");
+ break;
+
+ case ARCH_MAC99:
+ case ARCH_PREP:
+ default:
+
+ /* model */
+
+ push_str("PowerMac1,1");
+ fword("model");
+
+ /* compatible */
+
+ push_str("PowerMac1,1");
+ fword("encode-string");
+ push_str("MacRISC");
+ fword("encode-string");
+ fword("encode+");
+ push_str("Power Macintosh");
+ fword("encode-string");
+ fword("encode+");
+ push_str("compatible");
+ fword("property");
+
+ /* misc */
+
+ push_str("bootrom");
+ fword("device-type");
+
+ PUSH(100 * 1000 * 1000);
+ fword("encode-int");
+ push_str("clock-frequency");
+ fword("property");
+ break;
+ }
+
+ /* Perhaps we can store UUID here ? */
+
+ push_str("0000000000000");
+ fword("encode-string");
+ push_str("system-id");
+ fword("property");
+
/* memory info */
push_str("/memory");
Modified: openbios-devel/arch/ppc/qemu/tree.fs
===================================================================
--- openbios-devel/arch/ppc/qemu/tree.fs 2009-01-11 00:34:08 UTC (rev 387)
+++ openbios-devel/arch/ppc/qemu/tree.fs 2009-01-11 01:03:16 UTC (rev 388)
@@ -11,12 +11,6 @@
" /" find-device
-" bootrom" device-type
-" PowerMac1,1" model
-" PowerMac1,1" encode-string
-" MacRisc" encode-string encode+
-" Power Macintosh" encode-string encode+ " compatible" property
-" 0000000000000" encode-string " system-id" property
1 encode-int " #address-cells" property
1 encode-int " #size-cells" property
h# 05f5e100 encode-int " clock-frequency" property
Modified: openbios-devel/drivers/cuda.c
===================================================================
--- openbios-devel/drivers/cuda.c 2009-01-11 00:34:08 UTC (rev 387)
+++ openbios-devel/drivers/cuda.c 2009-01-11 01:03:16 UTC (rev 388)
@@ -1,5 +1,6 @@
#include "openbios/config.h"
#include "openbios/bindings.h"
+#include "openbios/drivers.h"
#include "libc/byteorder.h"
#include "libc/vsprintf.h"
@@ -200,7 +201,7 @@
* non-standard oldworld property (needed by linux 2.6.18)
*/
- set_int_property(ph, "AAPL,interrupts", 0x12);
+ OLDWORLD(set_int_property(ph, "AAPL,interrupts", 0x12));
bind_func("ppc32-reset-all", ppc32_reset_all);
push_str("' ppc32-reset-all to reset-all");
Modified: openbios-devel/drivers/pci.c
===================================================================
--- openbios-devel/drivers/pci.c 2009-01-11 00:34:08 UTC (rev 387)
+++ openbios-devel/drivers/pci.c 2009-01-11 01:03:16 UTC (rev 388)
@@ -291,6 +291,30 @@
}
}
+/*
+ * "Designing PCI Cards and Drivers for Power Macintosh Computers", p. 454
+ *
+ * "AAPL,address" provides an array of 32-bit logical addresses
+ * Nth entry corresponding to Nth "assigned-address" base address entry.
+ */
+
+static void pci_set_AAPL_address(const pci_config_t *config)
+{
+ phandle_t dev = get_cur_dev();
+ cell props[7];
+ int ncells, i;
+
+ ncells = 0;
+ for (i = 0; i < 6; i++) {
+ if (!config->assigned[i] || !config->sizes[i])
+ continue;
+ props[ncells++] = config->assigned[i] & ~0x0000000F;
+ }
+ if (ncells)
+ set_property(dev, "AAPL,address", (char *)props,
+ ncells * sizeof(cell));
+}
+
static void pci_set_assigned_addresses(const pci_config_t *config)
{
phandle_t dev = get_cur_dev();
@@ -452,8 +476,11 @@
set_int_property(dev, "revision-id", rev);
set_int_property(dev, "class-code", class_code << 8);
- if (config->irq_pin)
+ if (config->irq_pin) {
+ OLDWORLD(set_int_property(dev, "AAPL,interrupts",
+ config->irq_line));
set_int_property(dev, "interrupts", config->irq_pin);
+ }
set_int_property(dev, "min-grant", pci_config_read8(addr, PCI_MIN_GNT));
set_int_property(dev, "max-latency", pci_config_read8(addr, PCI_MAX_LAT));
@@ -510,6 +537,7 @@
pci_set_reg(config);
pci_set_assigned_addresses(config);
+ OLDWORLD(pci_set_AAPL_address(config));
#ifdef CONFIG_DEBUG_PCI
printk("\n");
Modified: openbios-devel/include/openbios/drivers.h
===================================================================
--- openbios-devel/include/openbios/drivers.h 2009-01-11 00:34:08 UTC (rev 387)
+++ openbios-devel/include/openbios/drivers.h 2009-01-11 01:03:16 UTC (rev 388)
@@ -16,7 +16,22 @@
#ifdef CONFIG_DRIVER_PCI
/* drivers/pci.c */
int ob_pci_init(void);
+#ifdef CONFIG_PPC
+extern int is_apple(void);
+extern int is_oldworld(void);
+#else
+static inline int is_apple(void)
+{
+ return 0;
+}
+static inline int is_oldworld(void)
+{
+ return 0;
+}
#endif
+#define AAPL(_cmd) do { if (is_apple()) _cmd; } while(0)
+#define OLDWORLD(_cmd) do { if (is_oldworld()) _cmd; } while(0)
+#endif
#ifdef CONFIG_DRIVER_SBUS
/* drivers/sbus.c */
int ob_sbus_init(uint64_t base, int machine_id);
More information about the OpenBIOS
mailing list