[OpenBIOS] r320 - openbios-devel/arch/ppc/qemu
svn at openbios.org
svn at openbios.org
Tue Dec 23 16:54:58 CET 2008
Author: blueswirl
Date: 2008-12-23 16:54:58 +0100 (Tue, 23 Dec 2008)
New Revision: 320
Modified:
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/arch/ppc/qemu/tree.fs
Log:
Probe CPU type
Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c 2008-12-23 13:38:11 UTC (rev 319)
+++ openbios-devel/arch/ppc/qemu/init.c 2008-12-23 15:54:58 UTC (rev 320)
@@ -35,6 +35,16 @@
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
+struct cpudef {
+ unsigned long iu_version;
+ const char *name;
+ int icache_size, dcache_size;
+ int icache_sets, dcache_sets;
+ int icache_block_size, dcache_block_size;
+ int clock_frequency;
+ void (*initfn)(const struct cpudef *cpu);
+};
+
extern void unexpected_excep( int vector );
extern void ob_pci_init( void );
extern void setup_timers( void );
@@ -159,6 +169,124 @@
;
}
+static void
+cpu_generic_init(const struct cpudef *cpu)
+{
+ unsigned long iu_version;
+
+ push_str("/cpus");
+ fword("find-device");
+
+ fword("new-device");
+
+ push_str(cpu->name);
+ fword("device-name");
+
+ push_str("cpu");
+ fword("device-type");
+
+ asm("mfpvr %0\n"
+ : "=r"(iu_version) :);
+ PUSH(iu_version);
+ fword("encode-int");
+ push_str("cpu-version");
+ fword("property");
+
+ PUSH(cpu->dcache_size);
+ fword("encode-int");
+ push_str("dcache-size");
+ fword("property");
+
+ PUSH(cpu->icache_size);
+ fword("encode-int");
+ push_str("icache-size");
+ fword("property");
+
+ PUSH(cpu->dcache_sets);
+ fword("encode-int");
+ push_str("dcache-sets");
+ fword("property");
+
+ PUSH(cpu->icache_sets);
+ fword("encode-int");
+ push_str("icache-sets");
+ fword("property");
+
+ PUSH(cpu->dcache_block_size);
+ fword("encode-int");
+ push_str("dcache-block-size");
+ fword("property");
+
+ PUSH(cpu->icache_block_size);
+ fword("encode-int");
+ push_str("icache-block-size");
+ fword("property");
+
+ push_str("running");
+ fword("encode-string");
+ push_str("state");
+ fword("property");
+
+ fword("finish-device");
+}
+
+static void
+cpu_750_init(const struct cpudef *cpu)
+{
+ cpu_generic_init(cpu);
+}
+
+static void
+cpu_g4_init(const struct cpudef *cpu)
+{
+ cpu_generic_init(cpu);
+}
+
+static const struct cpudef ppc_defs[] = {
+ {
+ .iu_version = 0x000080000,
+ .name = "PowerPC,750",
+ .icache_size = 0x8000,
+ .dcache_size = 0x8000,
+ .icache_sets = 0x80,
+ .dcache_sets = 0x80,
+ .icache_block_size = 0x20,
+ .dcache_block_size = 0x20,
+ .clock_frequency = 0x14dc9380,
+ .initfn = cpu_750_init,
+ },
+ {
+ .iu_version = 0x0000c0000,
+ .name = "PowerPC,G4",
+ .icache_size = 0x8000,
+ .dcache_size = 0x8000,
+ .icache_sets = 0x80,
+ .dcache_sets = 0x80,
+ .icache_block_size = 0x20,
+ .dcache_block_size = 0x20,
+ .clock_frequency = 0x1dcd6500,
+ .initfn = cpu_g4_init,
+ },
+};
+
+static const struct cpudef *
+id_cpu(void)
+{
+ unsigned long iu_version;
+ unsigned int i;
+
+ asm("mfpvr %0\n"
+ : "=r"(iu_version) :);
+ iu_version &= 0xffff0000;
+
+ for (i = 0; i < sizeof(ppc_defs)/sizeof(struct cpudef); i++) {
+ if (iu_version == ppc_defs[i].iu_version)
+ return &ppc_defs[i];
+ }
+ printk("Unknown cpu (pvr %lx), freezing!\n", iu_version);
+ for (;;);
+}
+
void
arch_of_init( void )
{
@@ -166,6 +294,7 @@
phandle_t ph;
#endif
uint64_t ram_size;
+ const struct cpudef *cpu;
devtree_init();
@@ -218,6 +347,10 @@
push_str("available");
fword("property");
+ cpu = id_cpu();
+ cpu->initfn(cpu);
+ printk("CPU type %s\n", cpu->name);
+
modules_init();
setup_timers();
#ifdef CONFIG_DRIVER_PCI
Modified: openbios-devel/arch/ppc/qemu/tree.fs
===================================================================
--- openbios-devel/arch/ppc/qemu/tree.fs 2008-12-23 13:38:11 UTC (rev 319)
+++ openbios-devel/arch/ppc/qemu/tree.fs 2008-12-23 15:54:58 UTC (rev 320)
@@ -28,32 +28,10 @@
finish-device
new-device
- " cpu" device-name
- " cpu" device-type
- " " encode-string " translations" property
- 0 encode-phys h# 8000000 encode-int encode+ " available" property
- d# 32 encode-int " d-cache-block-size" property
- 8 encode-int " d-cache-sets" property
- d# 32768 encode-int " d-cache-size" property
- d# 32 encode-int " i-cache-block-size" property
- 8 encode-int " i-cache-sets" property
- d# 32768 encode-int " i-cache-size" property
- " " encode-string " cache-unified" property
- 2 encode-int " i-tlb-sets" property
- d# 128 encode-int " i-tlb-size" property
- 2 encode-int " d-tlb-sets" property
- d# 128 encode-int " d-tlb-size" property
- " " encode-string " tlb-split" property
- 2 encode-int " tlb-sets" property
- d# 256 encode-int " tlb-size" property
- " " encode-string " performance-monitor" property
- " " encode-string " graphics" property
- 4 encode-int " reservation-granule-size" property
- d# 25000000 encode-int " timebase-frequency" property
- d# 300000000 encode-int " clock-frequency" property
- d# 66000000 encode-int " bus-frequency" property
- h# 88201 encode-int " cpu-version" property
- 0 encode-int " reg" property
+ " cpus" device-name
+ " cpus" device-type
+ 1 encode-int " #address-cells" property
+ 0 encode-int " #size-cells" property
finish-device
" /pci" find-device
More information about the OpenBIOS
mailing list