[OpenBIOS] [commit] r971 - trunk/openbios-devel/arch/ppc/qemu
repository service
svn at openbios.org
Sat Nov 27 17:29:33 CET 2010
Author: afaerber
Date: Sat Nov 27 17:29:32 2010
New Revision: 971
URL: http://tracker.coreboot.org/trac/openbios/changeset/971
Log:
ppc: Coding style cleanup
Adopt QEMU coding style for indentation, spacing and parenthesis.
Avoid empty statement in for loops. Move comment out of function body.
No functional changes.
Signed-off-by: Andreas Färber <andreas.faerber at web.de>
Modified:
trunk/openbios-devel/arch/ppc/qemu/init.c
trunk/openbios-devel/arch/ppc/qemu/ofmem.c
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/init.c Sat Nov 27 01:46:44 2010 (r970)
+++ trunk/openbios-devel/arch/ppc/qemu/init.c Sat Nov 27 17:29:32 2010 (r971)
@@ -49,14 +49,14 @@
static uint16_t machine_id = 0;
-extern void unexpected_excep( int vector );
+extern void unexpected_excep(int vector);
void
-unexpected_excep( int vector )
+unexpected_excep(int vector)
{
- printk("openbios panic: Unexpected exception %x\n", vector );
- for( ;; )
- ;
+ printk("openbios panic: Unexpected exception %x\n", vector);
+ for (;;) {
+ }
}
enum {
@@ -79,7 +79,7 @@
int is_newworld(void)
{
return (machine_id == ARCH_MAC99) ||
- (machine_id == ARCH_MAC99_U3);
+ (machine_id == ARCH_MAC99_U3);
}
static const pci_arch_t known_arch[] = {
@@ -155,39 +155,40 @@
unsigned long isa_io_base;
void
-entry( void )
+entry(void)
{
- uint32_t temp = 0;
- char buf[5];
+ uint32_t temp = 0;
+ char buf[5];
- arch = &known_arch[ARCH_HEATHROW];
+ arch = &known_arch[ARCH_HEATHROW];
- fw_cfg_init();
+ fw_cfg_init();
- fw_cfg_read(FW_CFG_SIGNATURE, buf, 4);
- buf[4] = '\0';
- if (strncmp(buf, "QEMU", 4) == 0) {
- temp = fw_cfg_read_i32(FW_CFG_ID);
- if (temp == 1) {
- machine_id = fw_cfg_read_i16(FW_CFG_MACHINE_ID);
- arch = &known_arch[machine_id];
- }
+ fw_cfg_read(FW_CFG_SIGNATURE, buf, 4);
+ buf[4] = '\0';
+ if (strncmp(buf, "QEMU", 4) == 0) {
+ temp = fw_cfg_read_i32(FW_CFG_ID);
+ if (temp == 1) {
+ machine_id = fw_cfg_read_i16(FW_CFG_MACHINE_ID);
+ arch = &known_arch[machine_id];
}
+ }
- isa_io_base = arch->io_base;
+ isa_io_base = arch->io_base;
- if (temp != 1) {
- printk("Incompatible configuration device version, freezing\n");
- for(;;);
+ if (temp != 1) {
+ printk("Incompatible configuration device version, freezing\n");
+ for (;;) {
}
+ }
+
+ ofmem_init();
+ initialize_forth();
+ /* won't return */
- ofmem_init();
- initialize_forth();
- /* won't return */
-
- printk("of_startup returned!\n");
- for( ;; )
- ;
+ printk("of_startup returned!\n");
+ for (;;) {
+ }
}
static void
@@ -316,8 +317,8 @@
*isi = 0x48002202;
// Invalidate the cache lines
- asm ( "icbi 0, %0" : : "r"(dsi) );
- asm ( "icbi 0, %0" : : "r"(isi) );
+ asm ("icbi 0, %0" : : "r"(dsi));
+ asm ("icbi 0, %0" : : "r"(isi));
}
#endif
@@ -508,352 +509,355 @@
: "=r"(iu_version) :);
iu_version &= 0xffff0000;
- for (i = 0; i < sizeof(ppc_defs)/sizeof(struct cpudef); i++) {
+ 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 (;;);
+ for (;;) {
+ }
}
-static void go( void );
+static void go(void);
static void
-go( void )
+go(void)
{
ucell addr;
feval("saved-program-state >sps.entry @");
addr = POP();
- call_elf( 0, 0, addr);
+ call_elf(0, 0, addr);
}
static void kvm_of_init(void)
{
- char hypercall[4 * 4];
- uint32_t *hc32;
+ char hypercall[4 * 4];
+ uint32_t *hc32;
+
+ /* Don't expose /hypervisor when not in KVM */
+ if (!fw_cfg_read_i32(FW_CFG_PPC_IS_KVM))
+ return;
+
+ push_str("/");
+ fword("find-device");
+
+ fword("new-device");
+
+ push_str("hypervisor");
+ fword("device-name");
+
+ push_str("hypervisor");
+ fword("device-type");
+
+ /* compatible */
+
+ push_str("linux,kvm");
+ fword("encode-string");
+ push_str("epapr,hypervisor-0.2");
+ fword("encode-string");
+ fword("encode+");
+ push_str("compatible");
+ fword("property");
+
+ /* Tell the guest about the hypercall instructions */
+ fw_cfg_read(FW_CFG_PPC_KVM_HC, hypercall, 4 * 4);
+ hc32 = (uint32_t*)hypercall;
+ PUSH(hc32[0]);
+ fword("encode-int");
+ PUSH(hc32[1]);
+ fword("encode-int");
+ fword("encode+");
+ PUSH(hc32[2]);
+ fword("encode-int");
+ fword("encode+");
+ PUSH(hc32[3]);
+ fword("encode-int");
+ fword("encode+");
+ push_str("hcall-instructions");
+ fword("property");
- /* Don't expose /hypervisor when not in KVM */
- if (!fw_cfg_read_i32(FW_CFG_PPC_IS_KVM))
- return;
-
- push_str("/");
- fword("find-device");
-
- fword("new-device");
-
- push_str("hypervisor");
- fword("device-name");
-
- push_str("hypervisor");
- fword("device-type");
-
- /* compatible */
-
- push_str("linux,kvm");
- fword("encode-string");
- push_str("epapr,hypervisor-0.2");
- fword("encode-string");
- fword("encode+");
- push_str("compatible");
- fword("property");
-
- /* Tell the guest about the hypercall instructions */
- fw_cfg_read(FW_CFG_PPC_KVM_HC, hypercall, 4 * 4);
- hc32 = (uint32_t*)hypercall;
- PUSH(hc32[0]);
- fword("encode-int");
- PUSH(hc32[1]);
- fword("encode-int");
- fword("encode+");
- PUSH(hc32[2]);
- fword("encode-int");
- fword("encode+");
- PUSH(hc32[3]);
- fword("encode-int");
- fword("encode+");
- push_str("hcall-instructions");
- fword("property");
-
- /* ePAPR requires us to provide a unique guest id */
- PUSH(fw_cfg_read_i32(FW_CFG_PPC_KVM_PID));
- fword("encode-int");
- push_str("guest-id");
- fword("property");
-
- /* ePAPR requires us to provide a guest name */
- push_str("KVM guest");
- fword("encode-string");
- push_str("guest-name");
- fword("property");
+ /* ePAPR requires us to provide a unique guest id */
+ PUSH(fw_cfg_read_i32(FW_CFG_PPC_KVM_PID));
+ fword("encode-int");
+ push_str("guest-id");
+ fword("property");
- fword("finish-device");
+ /* ePAPR requires us to provide a guest name */
+ push_str("KVM guest");
+ fword("encode-string");
+ push_str("guest-name");
+ fword("property");
+
+ fword("finish-device");
}
void
-arch_of_init( void )
+arch_of_init(void)
{
#ifdef CONFIG_RTAS
- phandle_t ph;
+ phandle_t ph;
#endif
- uint64_t ram_size;
- const struct cpudef *cpu;
- char buf[64], qemu_uuid[16];
- const char *stdin_path, *stdout_path, *boot_path;
- uint32_t temp = 0;
+ uint64_t ram_size;
+ const struct cpudef *cpu;
+ char buf[64], qemu_uuid[16];
+ const char *stdin_path, *stdout_path, *boot_path;
+ uint32_t temp = 0;
ofmem_t *ofmem = ofmem_arch_get_private();
- openbios_init();
- modules_init();
- setup_timers();
+ openbios_init();
+ modules_init();
+ setup_timers();
#ifdef CONFIG_DRIVER_PCI
- ob_pci_init();
+ ob_pci_init();
#endif
- printk("\n");
- printk("=============================================================\n");
- printk(PROGRAM_NAME " " OPENBIOS_VERSION_STR " [%s]\n",
- OPENBIOS_BUILD_DATE);
-
- fw_cfg_read(FW_CFG_SIGNATURE, buf, 4);
- buf[4] = '\0';
- printk("Configuration device id %s", buf);
+ printk("\n");
+ printk("=============================================================\n");
+ printk(PROGRAM_NAME " " OPENBIOS_VERSION_STR " [%s]\n",
+ OPENBIOS_BUILD_DATE);
- temp = fw_cfg_read_i32(FW_CFG_ID);
- printk(" version %d machine id %d\n", temp, machine_id);
-
- temp = fw_cfg_read_i32(FW_CFG_NB_CPUS);
-
- printk("CPUs: %x\n", temp);
-
- ram_size = ofmem->ramsize;
-
- printk("Memory: %lldM\n", ram_size / 1024 / 1024);
-
- fw_cfg_read(FW_CFG_UUID, qemu_uuid, 16);
+ fw_cfg_read(FW_CFG_SIGNATURE, buf, 4);
+ buf[4] = '\0';
+ printk("Configuration device id %s", buf);
- printk("UUID: " UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1], qemu_uuid[2],
- qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], qemu_uuid[6],
- qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], qemu_uuid[10],
- qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], qemu_uuid[14],
- qemu_uuid[15]);
+ temp = fw_cfg_read_i32(FW_CFG_ID);
+ printk(" version %d machine id %d\n", temp, machine_id);
- /* set device tree root info */
+ temp = fw_cfg_read_i32(FW_CFG_NB_CPUS);
- push_str("/");
- fword("find-device");
+ printk("CPUs: %x\n", temp);
- switch(machine_id) {
- case ARCH_HEATHROW: /* OldWorld */
+ ram_size = ofmem->ramsize;
- /* model */
+ printk("Memory: %lldM\n", ram_size / 1024 / 1024);
- push_str("Power Macintosh");
- fword("model");
+ fw_cfg_read(FW_CFG_UUID, qemu_uuid, 16);
- /* compatible */
+ printk("UUID: " UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1], qemu_uuid[2],
+ qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], qemu_uuid[6],
+ qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], qemu_uuid[10],
+ qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], qemu_uuid[14],
+ qemu_uuid[15]);
- push_str("AAPL,PowerMac G3");
- fword("encode-string");
- push_str("MacRISC");
- fword("encode-string");
- fword("encode+");
- push_str("compatible");
- fword("property");
+ /* set device tree root info */
- /* misc */
+ push_str("/");
+ fword("find-device");
- push_str("device-tree");
- fword("encode-string");
- push_str("AAPL,original-name");
- fword("property");
+ switch(machine_id) {
+ case ARCH_HEATHROW: /* OldWorld */
- PUSH(0);
- fword("encode-int");
- push_str("AAPL,cpu-id");
- fword("property");
+ /* model */
- PUSH(66 * 1000 * 1000);
- fword("encode-int");
- push_str("clock-frequency");
- fword("property");
- break;
+ push_str("Power Macintosh");
+ fword("model");
- case ARCH_MAC99:
- case ARCH_MAC99_U3:
- case ARCH_PREP:
- default:
+ /* compatible */
+
+ push_str("AAPL,PowerMac G3");
+ fword("encode-string");
+ push_str("MacRISC");
+ fword("encode-string");
+ fword("encode+");
+ push_str("compatible");
+ fword("property");
- /* model */
+ /* misc */
- push_str("PowerMac2,1");
- fword("model");
+ push_str("device-tree");
+ fword("encode-string");
+ push_str("AAPL,original-name");
+ fword("property");
- /* compatible */
+ PUSH(0);
+ fword("encode-int");
+ push_str("AAPL,cpu-id");
+ fword("property");
- push_str("PowerMac2,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");
+ PUSH(66 * 1000 * 1000);
+ fword("encode-int");
+ push_str("clock-frequency");
+ fword("property");
+ break;
- /* misc */
+ case ARCH_MAC99:
+ case ARCH_MAC99_U3:
+ case ARCH_PREP:
+ default:
+
+ /* model */
+
+ push_str("PowerMac2,1");
+ fword("model");
+
+ /* compatible */
+
+ push_str("PowerMac2,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");
- push_str("bootrom");
- fword("device-type");
+ /* misc */
- PUSH(100 * 1000 * 1000);
- fword("encode-int");
- push_str("clock-frequency");
- fword("property");
- break;
- }
+ push_str("bootrom");
+ fword("device-type");
- /* Perhaps we can store UUID here ? */
+ PUSH(100 * 1000 * 1000);
+ fword("encode-int");
+ push_str("clock-frequency");
+ fword("property");
+ break;
+ }
- push_str("0000000000000");
- fword("encode-string");
- push_str("system-id");
- fword("property");
+ /* Perhaps we can store UUID here ? */
- /* memory info */
+ push_str("0000000000000");
+ fword("encode-string");
+ push_str("system-id");
+ fword("property");
- push_str("/memory");
- fword("find-device");
+ /* memory info */
- /* all memory */
+ push_str("/memory");
+ fword("find-device");
- /* TODO Adjust this when #address-cells gets increased for ppc64. */
- PUSH(0);
- fword("encode-phys");
- /* This needs adjusting if #size-cells gets increased.
- Alternatively use multiple (address, size) tuples. */
- PUSH(ram_size & 0xffffffff);
- fword("encode-int");
- fword("encode+");
- push_str("reg");
- fword("property");
+ /* all memory */
- cpu = id_cpu();
- cpu->initfn(cpu);
- printk("CPU type %s\n", cpu->name);
+ /* TODO Adjust this when #address-cells gets increased for ppc64. */
+ PUSH(0);
+ fword("encode-phys");
+ /* This needs adjusting if #size-cells gets increased.
+ Alternatively use multiple (address, size) tuples. */
+ PUSH(ram_size & 0xffffffff);
+ fword("encode-int");
+ fword("encode+");
+ push_str("reg");
+ fword("property");
- snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name);
- ofmem_register(find_dev("/memory"), find_dev(buf));
- node_methods_init(buf);
+ cpu = id_cpu();
+ cpu->initfn(cpu);
+ printk("CPU type %s\n", cpu->name);
+
+ snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name);
+ ofmem_register(find_dev("/memory"), find_dev(buf));
+ node_methods_init(buf);
#ifdef CONFIG_RTAS
- /* OldWorld Macs don't have an /rtas node. */
- switch (machine_id) {
- case ARCH_MAC99:
- case ARCH_MAC99_U3:
- if (!(ph = find_dev("/rtas"))) {
- printk("Warning: No /rtas node\n");
- } else {
- unsigned long size = 0x1000;
- while (size < (unsigned long)of_rtas_end - (unsigned long)of_rtas_start)
- size *= 2;
- set_property(ph, "rtas-size", (char*)&size, sizeof(size));
- set_int_property(ph, "rtas-version", is_apple() ? 0x41 : 1);
- }
- break;
- }
+ /* OldWorld Macs don't have an /rtas node. */
+ switch (machine_id) {
+ case ARCH_MAC99:
+ case ARCH_MAC99_U3:
+ if (!(ph = find_dev("/rtas"))) {
+ printk("Warning: No /rtas node\n");
+ } else {
+ unsigned long size = 0x1000;
+ while (size < (unsigned long)of_rtas_end - (unsigned long)of_rtas_start)
+ size *= 2;
+ set_property(ph, "rtas-size", (char*)&size, sizeof(size));
+ set_int_property(ph, "rtas-version", is_apple() ? 0x41 : 1);
+ }
+ break;
+ }
#endif
- if (fw_cfg_read_i16(FW_CFG_NOGRAPHIC)) {
- if (CONFIG_SERIAL_PORT) {
- stdin_path = "scca";
- stdout_path = "scca";
- } else {
- stdin_path = "sccb";
- stdout_path = "sccb";
- }
-
- /* Some bootloaders force the output to the screen device, so
- let's create a screen alias for the serial device too */
- push_str("/aliases");
- fword("find-device");
-
- push_str(stdout_path);
- fword("pathres-resolve-aliases");
- fword("encode-string");
- push_str("screen");
- fword("property");
+ if (fw_cfg_read_i16(FW_CFG_NOGRAPHIC)) {
+ if (CONFIG_SERIAL_PORT) {
+ stdin_path = "scca";
+ stdout_path = "scca";
} else {
- stdin_path = "adb-keyboard";
- stdout_path = "screen";
+ stdin_path = "sccb";
+ stdout_path = "sccb";
}
- kvm_of_init();
+ /* Some bootloaders force the output to the screen device, so
+ let's create a screen alias for the serial device too */
- /* Setup nvram variables */
- push_str("/options");
+ push_str("/aliases");
fword("find-device");
- uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
- switch (boot_device) {
- case 'c':
- boot_path = "hd";
- break;
- default:
- case 'd':
- boot_path = "cd";
- break;
- }
-
- /* Setup default boot devices */
- snprintf(buf, sizeof(buf), "%s:,\\\\:tbxi %s:,\\ppc\\bootinfo.txt", boot_path, boot_path);
- push_str(buf);
- fword("encode-string");
- push_str("boot-device");
- fword("property");
+ push_str(stdout_path);
+ fword("pathres-resolve-aliases");
+ fword("encode-string");
+ push_str("screen");
+ fword("property");
+ } else {
+ stdin_path = "adb-keyboard";
+ stdout_path = "screen";
+ }
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
+ kvm_of_init();
- push_str(stdin_path);
- fword("open-dev");
- fword("encode-int");
- push_str("stdin");
- fword("property");
+ /* Setup nvram variables */
+ push_str("/options");
+ fword("find-device");
- push_str(stdout_path);
- fword("open-dev");
- fword("encode-int");
- push_str("stdout");
- fword("property");
+ uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
+ switch (boot_device) {
+ case 'c':
+ boot_path = "hd";
+ break;
+ default:
+ case 'd':
+ boot_path = "cd";
+ break;
+ }
- push_str(stdin_path);
- fword("pathres-resolve-aliases");
- push_str("input-device");
- fword("$setenv");
+ /* Setup default boot devices */
+ snprintf(buf, sizeof(buf), "%s:,\\\\:tbxi %s:,\\ppc\\bootinfo.txt", boot_path, boot_path);
+ push_str(buf);
+ fword("encode-string");
+ push_str("boot-device");
+ fword("property");
- push_str(stdout_path);
- fword("pathres-resolve-aliases");
- push_str("output-device");
- fword("$setenv");
+ /* Set up other properties */
- push_str(stdin_path);
- fword("input");
+ push_str("/chosen");
+ fword("find-device");
- push_str(stdout_path);
- fword("output");
+ push_str(stdin_path);
+ fword("open-dev");
+ fword("encode-int");
+ push_str("stdin");
+ fword("property");
+
+ push_str(stdout_path);
+ fword("open-dev");
+ fword("encode-int");
+ push_str("stdout");
+ fword("property");
+
+ push_str(stdin_path);
+ fword("pathres-resolve-aliases");
+ push_str("input-device");
+ fword("$setenv");
+
+ push_str(stdout_path);
+ fword("pathres-resolve-aliases");
+ push_str("output-device");
+ fword("$setenv");
+
+ push_str(stdin_path);
+ fword("input");
+
+ push_str(stdout_path);
+ fword("output");
#if 0
- if( getbool("tty-interface?") == 1 )
+ if(getbool("tty-interface?") == 1)
#endif
- fword("activate-tty-interface");
+ fword("activate-tty-interface");
- device_end();
+ device_end();
- bind_func("platform-boot", boot );
- bind_func("(go)", go);
+ bind_func("platform-boot", boot);
+ bind_func("(go)", go);
}
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sat Nov 27 01:46:44 2010 (r970)
+++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sat Nov 27 17:29:32 2010 (r971)
@@ -23,12 +23,12 @@
#include "mmutypes.h"
#include "asm/processor.h"
-#define BIT(n) (1U<<(31-(n)))
+#define BIT(n) (1U << (31 - (n)))
/* called from assembly */
-extern void dsi_exception( void );
-extern void isi_exception( void );
-extern void setup_mmu( unsigned long code_base );
+extern void dsi_exception(void);
+extern void isi_exception(void);
+extern void setup_mmu(unsigned long code_base);
/*
* From Apple's BootX source comments:
@@ -60,98 +60,98 @@
#define SEGR_BASE 0x0400
static inline unsigned long
-get_hash_base( void )
+get_hash_base(void)
{
return (mfsdr1() & SDR1_HTABORG_MASK);
}
static inline unsigned long
-get_rom_base( void )
+get_rom_base(void)
{
- ofmem_t *ofmem = ofmem_arch_get_private();
- return ofmem->ramsize - 0x00100000;
+ ofmem_t *ofmem = ofmem_arch_get_private();
+ return ofmem->ramsize - 0x00100000;
}
unsigned long
-get_ram_top( void )
+get_ram_top(void)
{
- return get_hash_base() - (32 + 64 + 64) * 1024 - OFMEM_SIZE;
+ return get_hash_base() - (32 + 64 + 64) * 1024 - OFMEM_SIZE;
}
unsigned long
-get_ram_bottom( void )
+get_ram_bottom(void)
{
- return (unsigned long)FREE_BASE;
+ return (unsigned long)FREE_BASE;
}
-static ucell get_heap_top( void )
+static ucell get_heap_top(void)
{
- return get_hash_base() - (32 + 64 + 64) * 1024;
+ return get_hash_base() - (32 + 64 + 64) * 1024;
}
static inline size_t ALIGN_SIZE(size_t x, size_t a)
{
- return (x + a - 1) & ~(a-1);
+ return (x + a - 1) & ~(a - 1);
}
ofmem_t* ofmem_arch_get_private(void)
{
- return (ofmem_t*)cell2pointer(get_heap_top() - OFMEM_SIZE);
+ return (ofmem_t*)cell2pointer(get_heap_top() - OFMEM_SIZE);
}
void* ofmem_arch_get_malloc_base(void)
{
- return (char*)ofmem_arch_get_private() + ALIGN_SIZE(sizeof(ofmem_t), 4);
+ return (char*)ofmem_arch_get_private() + ALIGN_SIZE(sizeof(ofmem_t), 4);
}
ucell ofmem_arch_get_heap_top(void)
{
- return get_heap_top();
+ return get_heap_top();
}
ucell ofmem_arch_get_virt_top(void)
{
- return IO_BASE;
+ return IO_BASE;
}
void ofmem_arch_unmap_pages(ucell virt, ucell size)
{
- /* kill page mappings in provided range */
+ /* kill page mappings in provided range */
}
void ofmem_arch_early_map_pages(ucell phys, ucell virt, ucell size, ucell mode)
{
- /* none yet */
+ /* none yet */
}
retain_t *ofmem_arch_get_retained(void)
{
- /* not implemented */
- return NULL;
+ /* not implemented */
+ return NULL;
}
+/* Return size of a single MMU package translation property entry in cells */
int ofmem_arch_get_translation_entry_size(void)
{
- /* Return size of a single MMU package translation property entry in cells */
- return 4;
+ return 4;
}
+/* Generate translation property entry for PPC.
+ * According to the platform bindings for PPC
+ * (http://playground.sun.com/1275/bindings/ppc/release/ppc-2_1.html#REF34579)
+ * a translation property entry has the following layout:
+ *
+ * virtual address
+ * length
+ * physical address
+ * mode
+ */
void ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t)
{
- /* Generate translation property entry for PPC. According to the
- platform bindings for PPC (http://playground.sun.com/1275/bindings/ppc/release/ppc-2_1.html#REF34579)
- a translation property entry has the following layout:
-
- virtual address
- length
- physical address
- mode
- */
-
- transentry[0] = t->virt;
- transentry[1] = t->size;
- transentry[2] = t->phys;
- transentry[3] = t->mode;
+ transentry[0] = t->virt;
+ transentry[1] = t->size;
+ transentry[2] = t->phys;
+ transentry[3] = t->mode;
}
/************************************************************************/
@@ -159,21 +159,21 @@
/************************************************************************/
void *
-malloc( int size )
+malloc(int size)
{
- return ofmem_malloc(size);
+ return ofmem_malloc(size);
}
void
-free( void *ptr )
+free(void *ptr)
{
- ofmem_free(ptr);
+ ofmem_free(ptr);
}
void *
-realloc( void *ptr, size_t size )
+realloc(void *ptr, size_t size)
{
- return ofmem_realloc(ptr, size);
+ return ofmem_realloc(ptr, size);
}
@@ -181,12 +181,12 @@
/* misc */
/************************************************************************/
-ucell ofmem_arch_default_translation_mode( ucell phys )
+ucell ofmem_arch_default_translation_mode(ucell phys)
{
- /* XXX: Guard bit not set as it should! */
- if( phys < IO_BASE )
- return 0x02; /*0xa*/ /* wim GxPp */
- return 0x6a; /* WIm GxPp, I/O */
+ /* XXX: Guard bit not set as it should! */
+ if (phys < IO_BASE)
+ return 0x02; /*0xa*/ /* wim GxPp */
+ return 0x6a; /* WIm GxPp, I/O */
}
@@ -195,185 +195,185 @@
/************************************************************************/
static ucell
-ea_to_phys( ucell ea, ucell *mode )
+ea_to_phys(ucell ea, ucell *mode)
{
- ucell phys;
+ ucell phys;
- if (ea >= OF_CODE_START) {
- /* ROM into RAM */
- ea -= OF_CODE_START;
- phys = get_rom_base() + ea;
- *mode = 0x02;
+ if (ea >= OF_CODE_START) {
+ /* ROM into RAM */
+ ea -= OF_CODE_START;
+ phys = get_rom_base() + ea;
+ *mode = 0x02;
return phys;
- }
+ }
- phys = ofmem_translate(ea, mode);
- if( phys == -1 ) {
- phys = ea;
- *mode = ofmem_arch_default_translation_mode( phys );
-
- /* print_virt_range(); */
- /* print_phys_range(); */
- /* print_trans(); */
- }
- return phys;
+ phys = ofmem_translate(ea, mode);
+ if (phys == -1) {
+ phys = ea;
+ *mode = ofmem_arch_default_translation_mode(phys);
+
+ /* print_virt_range(); */
+ /* print_phys_range(); */
+ /* print_trans(); */
+ }
+ return phys;
}
static void
-hash_page_64( ucell ea, ucell phys, ucell mode )
+hash_page_64(ucell ea, ucell phys, ucell mode)
{
- static int next_grab_slot=0;
- uint64_t vsid_mask, page_mask, pgidx, hash;
- uint64_t htab_mask, mask, avpn;
- unsigned long pgaddr;
- int i, found;
- unsigned int vsid, vsid_sh, sdr, sdr_sh, sdr_mask;
- mPTE_64_t *pp;
-
- vsid = (ea >> 28) + SEGR_BASE;
- vsid_sh = 7;
- vsid_mask = 0x00003FFFFFFFFF80ULL;
- sdr = mfsdr1();
- sdr_sh = 18;
- sdr_mask = 0x3FF80;
- page_mask = 0x0FFFFFFF; // XXX correct?
- pgidx = (ea & page_mask) >> PAGE_SHIFT;
- avpn = (vsid << 12) | ((pgidx >> 4) & 0x0F80);;
-
- hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask;
- htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F));
- mask = (htab_mask << sdr_sh) | sdr_mask;
- pgaddr = sdr | (hash & mask);
- pp = (mPTE_64_t *)pgaddr;
-
- /* replace old translation */
- for( found=0, i=0; !found && i<8; i++ )
- if( pp[i].avpn == avpn )
- found=1;
-
- /* otherwise use a free slot */
- for( i=0; !found && i<8; i++ )
- if( !pp[i].v )
- found=1;
-
- /* out of slots, just evict one */
- if( !found ) {
- i = next_grab_slot + 1;
- next_grab_slot = (next_grab_slot + 1) % 8;
- }
- i--;
- {
- mPTE_64_t p = {
- // .avpn_low = avpn,
- .avpn = avpn >> 7,
- .h = 0,
- .v = 1,
-
- .rpn = (phys & ~0xfff) >> 12,
- .r = mode & (1 << 8) ? 1 : 0,
- .c = mode & (1 << 7) ? 1 : 0,
- .w = mode & (1 << 6) ? 1 : 0,
- .i = mode & (1 << 5) ? 1 : 0,
- .m = mode & (1 << 4) ? 1 : 0,
- .g = mode & (1 << 3) ? 1 : 0,
- .n = mode & (1 << 2) ? 1 : 0,
- .pp = mode & 3,
- };
- pp[i] = p;
- }
+ static int next_grab_slot = 0;
+ uint64_t vsid_mask, page_mask, pgidx, hash;
+ uint64_t htab_mask, mask, avpn;
+ unsigned long pgaddr;
+ int i, found;
+ unsigned int vsid, vsid_sh, sdr, sdr_sh, sdr_mask;
+ mPTE_64_t *pp;
+
+ vsid = (ea >> 28) + SEGR_BASE;
+ vsid_sh = 7;
+ vsid_mask = 0x00003FFFFFFFFF80ULL;
+ sdr = mfsdr1();
+ sdr_sh = 18;
+ sdr_mask = 0x3FF80;
+ page_mask = 0x0FFFFFFF; // XXX correct?
+ pgidx = (ea & page_mask) >> PAGE_SHIFT;
+ avpn = (vsid << 12) | ((pgidx >> 4) & 0x0F80);;
+
+ hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask;
+ htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F));
+ mask = (htab_mask << sdr_sh) | sdr_mask;
+ pgaddr = sdr | (hash & mask);
+ pp = (mPTE_64_t *)pgaddr;
+
+ /* replace old translation */
+ for (found = 0, i = 0; !found && i < 8; i++)
+ if (pp[i].avpn == avpn)
+ found = 1;
+
+ /* otherwise use a free slot */
+ for (i = 0; !found && i < 8; i++)
+ if (!pp[i].v)
+ found = 1;
+
+ /* out of slots, just evict one */
+ if (!found) {
+ i = next_grab_slot + 1;
+ next_grab_slot = (next_grab_slot + 1) % 8;
+ }
+ i--;
+ {
+ mPTE_64_t p = {
+ // .avpn_low = avpn,
+ .avpn = avpn >> 7,
+ .h = 0,
+ .v = 1,
+
+ .rpn = (phys & ~0xfff) >> 12,
+ .r = mode & (1 << 8) ? 1 : 0,
+ .c = mode & (1 << 7) ? 1 : 0,
+ .w = mode & (1 << 6) ? 1 : 0,
+ .i = mode & (1 << 5) ? 1 : 0,
+ .m = mode & (1 << 4) ? 1 : 0,
+ .g = mode & (1 << 3) ? 1 : 0,
+ .n = mode & (1 << 2) ? 1 : 0,
+ .pp = mode & 3,
+ };
+ pp[i] = p;
+ }
- asm volatile( "tlbie %0" :: "r"(ea) );
+ asm volatile("tlbie %0" :: "r"(ea));
}
static void
-hash_page_32( ucell ea, ucell phys, ucell mode )
+hash_page_32(ucell ea, ucell phys, ucell mode)
{
#ifndef __powerpc64__
- static int next_grab_slot=0;
- unsigned long *upte, cmp, hash1;
- int i, vsid, found;
- mPTE_t *pp;
-
- vsid = (ea>>28) + SEGR_BASE;
- cmp = BIT(0) | (vsid << 7) | ((ea & 0x0fffffff) >> 22);
-
- hash1 = vsid;
- hash1 ^= (ea >> 12) & 0xffff;
- hash1 &= (((mfsdr1() & 0x1ff) << 16) | 0xffff) >> 6;
-
- pp = (mPTE_t*)(get_hash_base() + (hash1 << 6));
- upte = (unsigned long*)pp;
-
- /* replace old translation */
- for( found=0, i=0; !found && i<8; i++ )
- if( cmp == upte[i*2] )
- found=1;
-
- /* otherwise use a free slot */
- for( i=0; !found && i<8; i++ )
- if( !pp[i].v )
- found=1;
-
- /* out of slots, just evict one */
- if( !found ) {
- i = next_grab_slot + 1;
- next_grab_slot = (next_grab_slot + 1) % 8;
- }
- i--;
- upte[i*2] = cmp;
- upte[i*2+1] = (phys & ~0xfff) | mode;
+ static int next_grab_slot = 0;
+ unsigned long *upte, cmp, hash1;
+ int i, vsid, found;
+ mPTE_t *pp;
+
+ vsid = (ea >> 28) + SEGR_BASE;
+ cmp = BIT(0) | (vsid << 7) | ((ea & 0x0fffffff) >> 22);
+
+ hash1 = vsid;
+ hash1 ^= (ea >> 12) & 0xffff;
+ hash1 &= (((mfsdr1() & 0x1ff) << 16) | 0xffff) >> 6;
+
+ pp = (mPTE_t*)(get_hash_base() + (hash1 << 6));
+ upte = (unsigned long*)pp;
+
+ /* replace old translation */
+ for (found = 0, i = 0; !found && i < 8; i++)
+ if (cmp == upte[i*2])
+ found = 1;
+
+ /* otherwise use a free slot */
+ for (i = 0; !found && i < 8; i++)
+ if (!pp[i].v)
+ found = 1;
+
+ /* out of slots, just evict one */
+ if (!found) {
+ i = next_grab_slot + 1;
+ next_grab_slot = (next_grab_slot + 1) % 8;
+ }
+ i--;
+ upte[i * 2] = cmp;
+ upte[i * 2 + 1] = (phys & ~0xfff) | mode;
- asm volatile( "tlbie %0" :: "r"(ea) );
+ asm volatile("tlbie %0" :: "r"(ea));
#endif
}
static int is_ppc64(void)
{
#ifdef __powerpc64__
- return 1;
+ return 1;
#elif defined(CONFIG_PPC_64BITSUPPORT)
- unsigned int pvr = mfpvr();
- return ((pvr >= 0x330000) && (pvr < 0x70330000));
+ unsigned int pvr = mfpvr();
+ return ((pvr >= 0x330000) && (pvr < 0x70330000));
#else
- return 0;
+ return 0;
#endif
}
/* XXX Remove these ugly constructs when legacy 64-bit support is dropped. */
-static void hash_page( unsigned long ea, unsigned long phys, ucell mode )
+static void hash_page(unsigned long ea, unsigned long phys, ucell mode)
{
- if ( is_ppc64() )
- hash_page_64(ea, phys, mode);
- else
- hash_page_32(ea, phys, mode);
+ if (is_ppc64())
+ hash_page_64(ea, phys, mode);
+ else
+ hash_page_32(ea, phys, mode);
}
void
-dsi_exception( void )
+dsi_exception(void)
{
- unsigned long dar, dsisr;
- ucell mode;
- ucell phys;
+ unsigned long dar, dsisr;
+ ucell mode;
+ ucell phys;
- asm volatile("mfdar %0" : "=r" (dar) : );
- asm volatile("mfdsisr %0" : "=r" (dsisr) : );
+ asm volatile("mfdar %0" : "=r" (dar) : );
+ asm volatile("mfdsisr %0" : "=r" (dsisr) : );
- phys = ea_to_phys(dar, &mode);
- hash_page( dar, phys, mode );
+ phys = ea_to_phys(dar, &mode);
+ hash_page(dar, phys, mode);
}
void
-isi_exception( void )
+isi_exception(void)
{
- unsigned long nip, srr1;
- ucell mode;
- ucell phys;
+ unsigned long nip, srr1;
+ ucell mode;
+ ucell phys;
- asm volatile("mfsrr0 %0" : "=r" (nip) : );
- asm volatile("mfsrr1 %0" : "=r" (srr1) : );
+ asm volatile("mfsrr0 %0" : "=r" (nip) : );
+ asm volatile("mfsrr1 %0" : "=r" (srr1) : );
- phys = ea_to_phys(nip, &mode);
- hash_page( nip, phys, mode );
+ phys = ea_to_phys(nip, &mode);
+ hash_page(nip, phys, mode);
}
@@ -382,69 +382,69 @@
/************************************************************************/
void
-setup_mmu( unsigned long ramsize )
+setup_mmu(unsigned long ramsize)
{
- ofmem_t *ofmem;
+ ofmem_t *ofmem;
#ifndef __powerpc64__
- unsigned long sr_base;
+ unsigned long sr_base;
#endif
- unsigned long hash_base;
- unsigned long hash_mask = ~0x000fffffUL; /* alignment for ppc64 */
- int i;
-
- /* SDR1: Storage Description Register 1 */
-
- hash_base = (ramsize - 0x00100000 - HASH_SIZE) & hash_mask;
- memset((void *)hash_base, 0, HASH_SIZE);
- if (is_ppc64())
- mtsdr1(hash_base | MAX(HASH_BITS - 18, 0));
- else
- mtsdr1(hash_base | ((HASH_SIZE - 1) >> 16));
+ unsigned long hash_base;
+ unsigned long hash_mask = ~0x000fffffUL; /* alignment for ppc64 */
+ int i;
+
+ /* SDR1: Storage Description Register 1 */
+
+ hash_base = (ramsize - 0x00100000 - HASH_SIZE) & hash_mask;
+ memset((void *)hash_base, 0, HASH_SIZE);
+ if (is_ppc64())
+ mtsdr1(hash_base | MAX(HASH_BITS - 18, 0));
+ else
+ mtsdr1(hash_base | ((HASH_SIZE - 1) >> 16));
#ifdef __powerpc64__
- /* Segment Lookaside Buffer */
+ /* Segment Lookaside Buffer */
- slbia(); /* Invalidate all SLBs except SLB 0 */
- for (i = 0; i < 16; i++) {
- unsigned long rs = ((0x400 + i) << 12) | (0x10 << 7);
- unsigned long rb = ((unsigned long)i << 28) | (1 << 27) | i;
- slbmte(rs, rb);
- }
+ slbia(); /* Invalidate all SLBs except SLB 0 */
+ for (i = 0; i < 16; i++) {
+ unsigned long rs = ((0x400 + i) << 12) | (0x10 << 7);
+ unsigned long rb = ((unsigned long)i << 28) | (1 << 27) | i;
+ slbmte(rs, rb);
+ }
#else
- /* Segment Register */
+ /* Segment Register */
- sr_base = SEGR_USER | SEGR_BASE ;
- for( i=0; i<16; i++ ) {
- int j = i << 28;
- asm volatile("mtsrin %0,%1" :: "r" (sr_base + i), "r" (j) );
- }
+ sr_base = SEGR_USER | SEGR_BASE ;
+ for (i = 0; i < 16; i++) {
+ int j = i << 28;
+ asm volatile("mtsrin %0,%1" :: "r" (sr_base + i), "r" (j));
+ }
#endif
- ofmem = ofmem_arch_get_private();
- memset(ofmem, 0, sizeof(ofmem_t));
- ofmem->ramsize = ramsize;
+ ofmem = ofmem_arch_get_private();
+ memset(ofmem, 0, sizeof(ofmem_t));
+ ofmem->ramsize = ramsize;
- memcpy((void *)get_rom_base(), (void *)OF_CODE_START, 0x00100000);
+ memcpy((void *)get_rom_base(), (void *)OF_CODE_START, 0x00100000);
- /* Enable MMU */
+ /* Enable MMU */
- mtmsr(mfmsr() | MSR_IR | MSR_DR);
+ mtmsr(mfmsr() | MSR_IR | MSR_DR);
}
void
-ofmem_init( void )
+ofmem_init(void)
{
- ofmem_t *ofmem = ofmem_arch_get_private();
+ ofmem_t *ofmem = ofmem_arch_get_private();
- ofmem_claim_phys(0, get_ram_bottom(), 0);
- ofmem_claim_virt(0, get_ram_bottom(), 0);
- ofmem_map( 0, 0, get_ram_bottom(), 0 );
+ ofmem_claim_phys(0, get_ram_bottom(), 0);
+ ofmem_claim_virt(0, get_ram_bottom(), 0);
+ ofmem_map(0, 0, get_ram_bottom(), 0);
- ofmem_claim_phys(get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
- ofmem_claim_virt(get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
- ofmem_map( get_ram_top(), get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
+ ofmem_claim_phys(get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
+ ofmem_claim_virt(get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
+ ofmem_map(get_ram_top(), get_ram_top(), ofmem->ramsize - get_ram_top(), 0);
}
More information about the OpenBIOS
mailing list