diff options
author | Yang Zhang <yang.z.zhang@intel.com> | 2015-08-28 09:58:54 +0800 |
---|---|---|
committer | Yang Zhang <yang.z.zhang@intel.com> | 2015-09-01 12:44:00 +0800 |
commit | e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch) | |
tree | 66b09f592c55df2878107a468a91d21506104d3f /qemu/roms/openbios/arch/ppc/pearpc | |
parent | 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff) |
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/roms/openbios/arch/ppc/pearpc')
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/console.c | 43 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/init.c | 136 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/kernel.c | 16 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/main.c | 145 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/methods.c | 329 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/pearpc.c | 206 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/pearpc.fs | 116 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/pearpc.h | 26 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/tree.c | 23 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/tree.fs | 305 | ||||
-rw-r--r-- | qemu/roms/openbios/arch/ppc/pearpc/vfd.c | 42 |
11 files changed, 1387 insertions, 0 deletions
diff --git a/qemu/roms/openbios/arch/ppc/pearpc/console.c b/qemu/roms/openbios/arch/ppc/pearpc/console.c new file mode 100644 index 000000000..3869cbab5 --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/console.c @@ -0,0 +1,43 @@ + +/* + * <console.c> + * + * Simple text console + * + * Copyright (C) 2005 Stefan Reinauer <stepan@openbios.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + +#include "config.h" +#include "libopenbios/bindings.h" +#include "libc/diskio.h" +#include "libopenbios/ofmem.h" +#include "pearpc/pearpc.h" + + +typedef struct osi_fb_info { + unsigned long mphys; + int rb, w, h, depth; +} osi_fb_info_t; + + +int PearPC_GetFBInfo( osi_fb_info_t *fb ) +{ + + fb->w=1024; + fb->h=768; + fb->depth=15; + fb->rb=2048; + fb->mphys=0x84000000; + + return 0; +} + +#define openbios_GetFBInfo(x) PearPC_GetFBInfo(x) + +#include "../../../packages/video.c" +#include "../../../libopenbios/console_common.c" diff --git a/qemu/roms/openbios/arch/ppc/pearpc/init.c b/qemu/roms/openbios/arch/ppc/pearpc/init.c new file mode 100644 index 000000000..ca6da0a44 --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/init.c @@ -0,0 +1,136 @@ +/* + * Creation Date: <2004/08/28 18:38:22 greg> + * Time-stamp: <2004/08/28 18:38:22 greg> + * + * <init.c> + * + * Initialization for pearpc + * + * Copyright (C) 2004 Greg Watson + * Copyright (C) 2005 Stefan Reinauer + * + * based on mol/init.c: + * + * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Samuel & David Rydh + * (samuel@ibrium.se, dary@lindesign.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + +#include "config.h" +#include "libopenbios/openbios.h" +#include "libopenbios/bindings.h" +#include "arch/common/nvram.h" +#include "pearpc/pearpc.h" +#include "libopenbios/ofmem.h" +#include "openbios-version.h" + +extern void unexpected_excep( int vector ); +extern void ob_pci_init( void ); +extern void ob_adb_init( void ); +extern void setup_timers( void ); + +#if 0 +int +get_bool_res( const char *res ) +{ + char buf[8], *p; + + p = BootHGetStrRes( res, buf, sizeof(buf) ); + if( !p ) + return -1; + if( !strcasecmp(p,"true") || !strcasecmp(p,"yes") || !strcasecmp(p,"1") ) + return 1; + return 0; +} +#endif + +void +unexpected_excep( int vector ) +{ + printk("openbios panic: Unexpected exception %x\n", vector ); + for( ;; ) + ; +} + +unsigned long isa_io_base; + +void +entry( void ) +{ + isa_io_base = 0x80000000; + + printk("\n"); + printk("=============================================================\n"); + printk(PROGRAM_NAME " " OPENBIOS_VERSION_STR " [%s]\n", + OPENBIOS_BUILD_DATE); + + ofmem_init(); + initialize_forth(); + /* won't return */ + + printk("of_startup returned!\n"); + for( ;; ) + ; +} + +static void +setenv( char *env, char *value ) +{ + push_str( value ); + push_str( env ); + fword("$setenv"); +} + +void +arch_of_init( void ) +{ +#if CONFIG_RTAS + phandle_t ph; +#endif + int autoboot; + + devtree_init(); + nvram_init("/pci/mac-io/nvram"); + openbios_init(); + modules_init(); + setup_timers(); +#ifdef CONFIG_DRIVER_PCI + ob_pci_init(); +#endif + node_methods_init(); + init_video(); + +#if CONFIG_RTAS + 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) ); + } +#endif + +#if 0 + /* tweak boot settings */ + autoboot = !!get_bool_res("autoboot"); +#endif + autoboot = 0; + if( !autoboot ) + printk("Autobooting disabled - dropping into OpenFirmware\n"); + setenv("auto-boot?", autoboot ? "true" : "false" ); + setenv("boot-command", "pearpcboot"); + +#if 0 + if( get_bool_res("tty-interface") == 1 ) +#endif + fword("activate-tty-interface"); + + /* hack */ + device_end(); + bind_func("pearpcboot", boot ); +} diff --git a/qemu/roms/openbios/arch/ppc/pearpc/kernel.c b/qemu/roms/openbios/arch/ppc/pearpc/kernel.c new file mode 100644 index 000000000..6408e421e --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/kernel.c @@ -0,0 +1,16 @@ +/* + * Creation Date: <2004/08/28 18:03:25 stepan> + * Time-stamp: <2004/08/28 18:03:25 stepan> + * + * <pearpc/kernel.c> + * + * Copyright (C) 2005 Stefan Reinauer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 + * + */ + +#include "pearpc-dict.h" +#include "../kernel.c" diff --git a/qemu/roms/openbios/arch/ppc/pearpc/main.c b/qemu/roms/openbios/arch/ppc/pearpc/main.c new file mode 100644 index 000000000..085494e56 --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/main.c @@ -0,0 +1,145 @@ +/* + * Creation Date: <2004/08/28 18:38:22 greg> + * Time-stamp: <2004/08/28 18:38:22 greg> + * + * <main.c> + * + * Copyright (C) 2004 Greg Watson + * + * Based on MOL specific code which is + * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + + +#include "config.h" +#include "libopenbios/bindings.h" +#include "libopenbios/elfload.h" +#include "arch/common/nvram.h" +#include "libc/diskio.h" +#include "libc/vsprintf.h" +#include "pearpc/pearpc.h" +#include "libopenbios/ofmem.h" + +static void +transfer_control_to_elf( unsigned long entry ) +{ + extern void call_elf( unsigned long entry ); + printk("Starting ELF image at 0x%08lX\n", entry); + call_elf( 0x400000 ); + //call_elf( entry ); + + fatal_error("call_elf returned unexpectedly\n"); +} + +static int +load_elf_rom( unsigned long *entry, int fd ) +{ + int i, lszz_offs, elf_offs; + char buf[128], *addr; + Elf_ehdr ehdr; + Elf_phdr *phdr; + size_t s; + + printk("Loading '%s'\n", get_file_path(fd)); + + /* the ELF-image (usually) starts at offset 0x4000 */ + if( (elf_offs=find_elf(fd)) < 0 ) { + printk("----> %s is not an ELF image\n", buf ); + exit(1); + } + if( !(phdr=elf_readhdrs(fd, elf_offs, &ehdr)) ) + fatal_error("elf_readhdrs failed\n"); + + *entry = ehdr.e_entry; + + /* load segments. Compressed ROM-image assumed to be located immediately + * after the last segment */ + lszz_offs = elf_offs; + for( i=0; i<ehdr.e_phnum; i++ ) { + /* p_memsz, p_flags */ + s = MIN( phdr[i].p_filesz, phdr[i].p_memsz ); + seek_io( fd, elf_offs + phdr[i].p_offset ); + + /* printk("filesz: %08lX memsz: %08lX p_offset: %08lX p_vaddr %08lX\n", + phdr[i].p_filesz, phdr[i].p_memsz, phdr[i].p_offset, + phdr[i].p_vaddr ); */ + + if( phdr[i].p_vaddr != phdr[i].p_paddr ) + printk("WARNING: ELF segment virtual addr != physical addr\n"); + lszz_offs = MAX( lszz_offs, elf_offs + phdr[i].p_offset + phdr[i].p_filesz ); + if( !s ) + continue; + if( ofmem_claim( phdr[i].p_vaddr, phdr[i].p_memsz, 0 ) == -1 ) + fatal_error("Claim failed!\n"); + + addr = (char*)phdr[i].p_vaddr; + if( read_io(fd, addr, s) != s ) + fatal_error("read failed\n"); + +#if 0 + /* patch CODE segment */ + if( *entry >= phdr[i].p_vaddr && *entry < phdr[i].p_vaddr + s ) { + patch_newworld_rom( (char*)phdr[i].p_vaddr, s ); + newworld_timer_hack( (char*)phdr[i].p_vaddr, s ); + } +#endif + flush_icache_range( addr, addr+s ); + + /*printk("ELF ROM-section loaded at %08lX (size %08lX)\n", + (unsigned long)phdr[i].p_vaddr, (unsigned long)phdr[i].p_memsz );*/ + } + free( phdr ); + return lszz_offs; +} + + +static void +encode_bootpath( const char *spec, const char *args ) +{ + phandle_t chosen_ph = find_dev("/chosen"); + set_property( chosen_ph, "bootpath", spec, strlen(spec)+1 ); + set_property( chosen_ph, "bootargs", args, strlen(args)+1 ); +} + +/************************************************************************/ +/* pearpc booting */ +/************************************************************************/ + +static void +pearpc_startup( void ) +{ + const char *paths[] = { "hd:0,\\zImage.chrp", NULL }; + const char *args[] = { "root=/dev/hda2 console=ttyS0,115200", NULL }; + unsigned long entry; + int i, fd; + + for( i=0; paths[i]; i++ ) { + if( (fd=open_io(paths[i])) == -1 ) + continue; + (void) load_elf_rom( &entry, fd ); + close_io( fd ); + encode_bootpath( paths[i], args[i] ); + + update_nvram(); + transfer_control_to_elf( entry ); + /* won't come here */ + } + printk("*** Boot failure! No secondary bootloader specified ***\n"); +} + + +/************************************************************************/ +/* entry */ +/************************************************************************/ + +void +boot( void ) +{ + fword("update-chosen"); + pearpc_startup(); +} diff --git a/qemu/roms/openbios/arch/ppc/pearpc/methods.c b/qemu/roms/openbios/arch/ppc/pearpc/methods.c new file mode 100644 index 000000000..f505b6cea --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/methods.c @@ -0,0 +1,329 @@ +/* + * Creation Date: <2004/08/28 18:38:22 greg> + * Time-stamp: <2004/08/28 18:38:22 greg> + * + * <methods.c> + * + * Misc device node methods + * + * Copyright (C) 2004 Greg Watson + * + * Based on MOL specific code which is + * + * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 + * + */ + +#include "config.h" +#include "libopenbios/bindings.h" +#include "libc/string.h" +#include "pearpc/pearpc.h" +#include "libopenbios/ofmem.h" + +/************************************************************************/ +/* RTAS (run-time abstraction services) */ +/************************************************************************/ + +#ifdef CONFIG_RTAS +DECLARE_NODE( rtas, INSTALL_OPEN, 0, "+/rtas" ); + +/* ( physbase -- rtas_callback ) */ +static void +rtas_instantiate( void ) +{ + int physbase = POP(); + int s=0x1000, size = (int)of_rtas_end - (int)of_rtas_start; + unsigned long virt; + + while( s < size ) + s += 0x1000; + virt = ofmem_claim_virt( 0, s, 0x1000 ); + ofmem_map( physbase, virt, s, -1 ); + memcpy( (char*)virt, of_rtas_start, size ); + + printk("RTAS instantiated at %08x\n", physbase ); + flush_icache_range( (char*)virt, (char*)virt + size ); + + PUSH( physbase ); +} + +NODE_METHODS( rtas ) = { + { "instantiate", rtas_instantiate }, + { "instantiate-rtas", rtas_instantiate }, +}; +#endif + + +/************************************************************************/ +/* stdout */ +/************************************************************************/ + +DECLARE_NODE( video_stdout, INSTALL_OPEN, 0, "Tdisplay" ); + +/* ( addr len -- actual ) */ +static void +stdout_write( void ) +{ + int len = POP(); + char *addr = (char*)POP(); + + printk( "%s", s ); + //vfd_draw_str( s ); + console_draw_fstr(addr, len); + + PUSH( len ); +} + +NODE_METHODS( video_stdout ) = { + { "write", stdout_write }, +}; + + +/************************************************************************/ +/* tty */ +/************************************************************************/ + +DECLARE_NODE( tty, INSTALL_OPEN, 0, "/packages/terminal-emulator" ); + +/* ( addr len -- actual ) */ +static void +tty_read( void ) +{ + int ch, len = POP(); + char *p = (char*)POP(); + int ret=0; + + if( len > 0 ) { + ret = 1; + ch = getchar(); + if( ch >= 0 ) { + *p = ch; + } else { + ret = 0; + } + } + PUSH( ret ); +} + +/* ( addr len -- actual ) */ +static void +tty_write( void ) +{ + int i, len = POP(); + char *p = (char*)POP(); + for( i=0; i<len; i++ ) + putchar( *p++ ); + RET( len ); +} + +NODE_METHODS( tty ) = { + { "read", tty_read }, + { "write", tty_write }, +}; + +/************************************************************************/ +/* client interface 'quiesce' */ +/************************************************************************/ + +DECLARE_NODE( ciface, 0, 0, "/packages/client-iface" ); + +/* ( -- ) */ +static void +ciface_quiesce( unsigned long args[], unsigned long ret[] ) +{ +#if 0 + unsigned long msr; + /* This seems to be the correct thing to do - but I'm not sure */ + asm volatile("mfmsr %0" : "=r" (msr) : ); + msr &= ~(MSR_IR | MSR_DR); + asm volatile("mtmsr %0" :: "r" (msr) ); +#endif + printk("=============================================================\n\n"); +} + +/* ( -- ms ) */ +static void +ciface_milliseconds( unsigned long args[], unsigned long ret[] ) +{ + extern unsigned long get_timer_freq(); + static unsigned long mticks=0, usecs=0; + unsigned long t; + + asm volatile("mftb %0" : "=r" (t) : ); + if( mticks ) + usecs += get_timer_freq() / 1000000 * ( t-mticks ); + mticks = t; + + PUSH( usecs/1000 ); +} + + +NODE_METHODS( ciface ) = { + { "quiesce", ciface_quiesce }, + { "milliseconds", ciface_milliseconds }, +}; + + +/************************************************************************/ +/* MMU/memory methods */ +/************************************************************************/ + +DECLARE_NODE( memory, INSTALL_OPEN, 0, "/memory" ); +DECLARE_NODE( mmu, INSTALL_OPEN, 0, "/cpu@0" ); +DECLARE_NODE( mmu_ciface, 0, 0, "/packages/client-iface" ); + + +/* ( phys size align --- base ) */ +static void +mem_claim( void ) +{ + ucell align = POP(); + ucell size = POP(); + ucell phys = POP(); + ucell ret = ofmem_claim_phys( phys, size, align ); + + if( ret == (ucell)-1 ) { + printk("MEM: claim failure\n"); + throw( -13 ); + return; + } + PUSH( ret ); +} + +/* ( phys size --- ) */ +static void +mem_release( void ) +{ + POP(); POP(); +} + +/* ( phys size align --- base ) */ +static void +mmu_claim( void ) +{ + ucell align = POP(); + ucell size = POP(); + ucell phys = POP(); + ucell ret = ofmem_claim_virt( phys, size, align ); + + if( ret == -1 ) { + printk("MMU: CLAIM failure\n"); + throw( -13 ); + return; + } + PUSH( ret ); +} + +/* ( phys size --- ) */ +static void +mmu_release( void ) +{ + POP(); POP(); +} + +/* ( phys virt size mode -- [ret???] ) */ +static void +mmu_map( void ) +{ + ucell mode = POP(); + ucell size = POP(); + ucell virt = POP(); + ucell phys = POP(); + ucell ret; + + /* printk("mmu_map: %x %x %x %x\n", phys, virt, size, mode ); */ + ret = ofmem_map( phys, virt, size, mode ); + + if( ret ) { + printk("MMU: map failure\n"); + throw( -13 ); + return; + } +} + +/* ( virt size -- ) */ +static void +mmu_unmap( void ) +{ + POP(); POP(); +} + +/* ( virt -- false | phys mode true ) */ +static void +mmu_translate( void ) +{ + ucell mode; + ucell virt = POP(); + ucell phys = ofmem_translate( virt, &mode ); + + if( phys == -1 ) { + PUSH( 0 ); + } else { + PUSH( phys ); + PUSH( mode ); + PUSH( -1 ); + } +} + +/* ( virt size align -- baseaddr|-1 ) */ +static void +ciface_claim( void ) +{ + ucell align = POP(); + ucell size = POP(); + ucell virt = POP(); + ucell ret = ofmem_claim( virt, size, align ); + + /* printk("ciface_claim: %08x %08x %x\n", virt, size, align ); */ + PUSH( ret ); +} + +/* ( virt size -- ) */ +static void +ciface_release( void ) +{ + POP(); + POP(); +} + + +NODE_METHODS( memory ) = { + { "claim", mem_claim }, + { "release", mem_release }, +}; + +NODE_METHODS( mmu ) = { + { "claim", mmu_claim }, + { "release", mmu_release }, + { "map", mmu_map }, + { "unmap", mmu_unmap }, + { "translate", mmu_translate }, +}; + +NODE_METHODS( mmu_ciface ) = { + { "cif-claim", ciface_claim }, + { "cif-release", ciface_release }, +}; + + +/************************************************************************/ +/* init */ +/************************************************************************/ + +void +node_methods_init( void ) +{ +#ifdef CONFIG_RTAS + REGISTER_NODE( rtas ); +#endif + REGISTER_NODE( video_stdout ); + REGISTER_NODE( ciface ); + REGISTER_NODE( memory ); + REGISTER_NODE( mmu ); + REGISTER_NODE( mmu_ciface ); + REGISTER_NODE( tty ); +} diff --git a/qemu/roms/openbios/arch/ppc/pearpc/pearpc.c b/qemu/roms/openbios/arch/ppc/pearpc/pearpc.c new file mode 100644 index 000000000..234052ce4 --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/pearpc.c @@ -0,0 +1,206 @@ +/* + * Creation Date: <2004/08/28 18:38:22 greg> + * Time-stamp: <2004/08/28 18:38:22 greg> + * + * <pearpc.c> + * + * Copyright (C) 2004, Greg Watson + * + * derived from mol.c + * + * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 + * + */ + +#include "config.h" +#include "kernel/kernel.h" +#include "arch/common/nvram.h" +#include "libc/vsprintf.h" +#include "libc/string.h" +#include "pearpc/pearpc.h" +#include <stdarg.h> + +#define UART_BASE 0x3f8 + +// FIXME +unsigned long virt_offset = 0; + + +void +exit( int status ) +{ + for (;;); +} + +void +fatal_error( const char *err ) +{ + printk("Fatal error: %s\n", err ); + exit(0); +} + +void +panic( const char *err ) +{ + printk("Panic: %s\n", err ); + exit(0); + + /* won't come here... this keeps the gcc happy */ + for( ;; ) + ; +} + + +/************************************************************************/ +/* print using OSI interface */ +/************************************************************************/ + +static int do_indent; + +int +printk( const char *fmt, ... ) +{ + char *p, buf[1024]; + va_list args; + int i; + + va_start(args, fmt); + i = vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + + for( p=buf; *p; p++ ) { + if( *p == '\n' ) + do_indent = 0; + if( do_indent++ == 1 ) { + putchar( '>' ); + putchar( '>' ); + putchar( ' ' ); + } + putchar( *p ); + } + return i; +} + + +/************************************************************************/ +/* TTY iface */ +/************************************************************************/ + +static int ttychar = -1; + +static int +tty_avail( void ) +{ + return 1; +} + +static int +tty_putchar( int c ) +{ + if( tty_avail() ) { + while (!(inb(UART_BASE + 0x05) & 0x20)) + ; + outb(c, UART_BASE); + while (!(inb(UART_BASE + 0x05) & 0x40)) + ; + } + return c; +} + +int +availchar( void ) +{ + if( !tty_avail() ) + return 0; + + if( ttychar < 0 ) + ttychar = inb(UART_BASE); + return (ttychar >= 0); +} + +int +getchar( void ) +{ + int ch; + + if( !tty_avail() ) + return 0; + + if( ttychar < 0 ) + return inb(UART_BASE); + ch = ttychar; + ttychar = -1; + return ch; +} + +int +putchar( int c ) +{ + if (c == '\n') + tty_putchar('\r'); + return tty_putchar(c); +} + + +/************************************************************************/ +/* briQ specific stuff */ +/************************************************************************/ + +#define IO_NVRAM_PA_START 0x80860000 +#define IO_NVRAM_PA_END 0x80880000 + +static char *nvram=(char *)IO_NVRAM_PA_START; + +void +dump_nvram(void) +{ + static char hexdigit[] = "0123456789abcdef"; + int i; + for (i = 0; i < 16*4; i++) + { + printk ("%c", hexdigit[nvram[i<<4] >> 4]); + printk ("%c", hexdigit[nvram[i<<4] % 16]); + if (!((i + 1) % 16)) + { + printk ("\n"); + } + else + { + printk (" "); + } + } +} + + +int +arch_nvram_size( void ) +{ + return (IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; +} + +void +arch_nvram_put( char *buf ) +{ + int i; + for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++) + nvram[i<<4]=buf[i]; + // memcpy(nvram, buf, IO_NVRAM_PA_END-IO_NVRAM_PA_START); + printk("new nvram:\n"); + dump_nvram(); +} + +void +arch_nvram_get( char *buf ) +{ + int i; + for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++) + buf[i]=nvram[i<<4]; + + //memcpy(buf, nvram, IO_NVRAM_PA_END-IO_NVRAM_PA_START); + printk("current nvram:\n"); + dump_nvram(); +} diff --git a/qemu/roms/openbios/arch/ppc/pearpc/pearpc.fs b/qemu/roms/openbios/arch/ppc/pearpc/pearpc.fs new file mode 100644 index 000000000..0d018b1c3 --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/pearpc.fs @@ -0,0 +1,116 @@ +\ pearpc specific initialization code +\ +\ Copyright (C) 2005 Stefan Reinauer +\ +\ This program is free software; you can redistribute it and/or +\ modify it under the terms of the GNU General Public License +\ as published by the Free Software Foundation +\ + + +\ ------------------------------------------------------------------------- +\ initialization +\ ------------------------------------------------------------------------- + +: make-openable ( path ) + find-dev if + begin ?dup while + \ install trivial open and close methods + dup active-package! is-open + parent + repeat + then +; + +: preopen ( chosen-str node-path ) + 2dup make-openable + + " /chosen" find-device + open-dev ?dup if + encode-int 2swap property + else + 2drop + then +; + +\ preopen device nodes (and store the ihandles under /chosen) +:noname + " rtc" " /pci/isa/rtc" preopen + " memory" " /memory" preopen + " mmu" " /cpu@0" preopen + \ " stdout" " /packages/terminal-emulator" preopen + " stdout" " /pci/pci6666,6666" preopen + " stdin" " /pci/via-cuda/adb" preopen + +; SYSTEM-initializer + + +\ ------------------------------------------------------------------------- +\ device tree fixing +\ ------------------------------------------------------------------------- + +\ add decode-address methods +: (make-decodable) ( phandle -- ) + + dup " #address-cells" rot get-package-property 0= if + decode-int nip nip + over " decode-unit" rot find-method if 2drop else + ( save phandle ncells ) + + over active-package! + case + 1 of ['] parse-hex " decode-unit" is-xt-func endof + 3 of + " bus-range" active-package get-package-property 0= if + decode-int nip nip + ['] encode-unit-pci " encode-unit" is-xt-func + " decode-unit" is-func-begin + ['] (lit) , , + ['] decode-unit-pci-bus , + is-func-end + then + endof + endcase + then + then + drop +; + +: init-pearpc-tree ( -- ) + active-package + + iterate-tree-begin + begin ?dup while + + dup (make-decodable) + + iterate-tree + repeat + + active-package! +; + +\ use the tty interface if available +: activate-tty-interface + " /packages/terminal-emulator" find-dev if drop + " /pci/via-cuda/adb" " input-device" $setenv + " /pci/pci6666,6666" " output-device" $setenv + then +; + +:noname + " keyboard" input +; CONSOLE-IN-initializer + + +\ ------------------------------------------------------------------------- +\ pre-booting +\ ------------------------------------------------------------------------- + +: update-chosen + " /chosen" find-device + stdin @ encode-int " stdin" property + stdout @ encode-int " stdout" property + " /pci/isa/interrupt-controller" find-dev if encode-int " interrupt-controller" property then + device-end +; diff --git a/qemu/roms/openbios/arch/ppc/pearpc/pearpc.h b/qemu/roms/openbios/arch/ppc/pearpc/pearpc.h new file mode 100644 index 000000000..44497d79e --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/pearpc.h @@ -0,0 +1,26 @@ +/* + * Creation Date: <2004/08/28 17:50:12 stepan> + * Time-stamp: <2004/08/28 17:50:12 stepan> + * + * <pearpc.h> + * + * Copyright (C) 2005 Stefan Reinauer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 + * + */ + +#ifndef _H_PEARPC +#define _H_PEARPC + +/* vfd.c */ +extern int vfd_draw_str( const char *str ); +extern void vfd_close( void ); + +extern int console_draw_fstr(const char *str, int len); + +#include "kernel.h" + +#endif /* _H_PEARPC */ diff --git a/qemu/roms/openbios/arch/ppc/pearpc/tree.c b/qemu/roms/openbios/arch/ppc/pearpc/tree.c new file mode 100644 index 000000000..abd1bf024 --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/tree.c @@ -0,0 +1,23 @@ +/* + * Creation Date: <2004/08/28 18:38:22 greg> + * Time-stamp: <2004/08/28 18:38:22 greg> + * + * <tree.c> + * + * device tree setup + * + * Copyright (C) 2004 Greg Watson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 + * + */ + +#include "config.h" +#include "libopenbios/bindings.h" + +void devtree_init( void ) +{ + fword("init-pearpc-tree"); +} diff --git a/qemu/roms/openbios/arch/ppc/pearpc/tree.fs b/qemu/roms/openbios/arch/ppc/pearpc/tree.fs new file mode 100644 index 000000000..d19b485f8 --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/tree.fs @@ -0,0 +1,305 @@ +\ PearPC specific initialization code +\ +\ Copyright (C) 2005 Stefan Reinauer +\ +\ This program is free software; you can redistribute it and/or +\ modify it under the terms of the GNU General Public License +\ as published by the Free Software Foundation +\ + +\ ------------------------------------------------------------- +\ device-tree +\ ------------------------------------------------------------- + +" /" find-device + +" chrp" device-type +" OpenSource,PEARPC" model +h# 80000000 encode-int " isa-io-base" property +1 encode-int " #interrupt-cells" property +1 encode-int " #size-cells" property + +new-device + " memory" device-name + " memory" device-type + 0 encode-int h# 1E00000 encode-int encode+ + h# 2000000 encode-int encode+ h# 40000000 encode-int encode+ + " available" property + 0 h# 40000000 reg + external + : open true ; + : close ; +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 +finish-device + +" /pci" find-device + h# 01000000 encode-int 0 encode-int encode+ 0 encode-int encode+ + h# 80000000 encode-int encode+ 0 encode-int encode+ + h# 01000000 encode-int encode+ + h# 02000000 encode-int encode+ 0 encode-int encode+ 0 encode-int encode+ + h# C0000000 encode-int encode+ 0 encode-int encode+ + h# 08000000 encode-int encode+ + " ranges" property + " IBM,CPC710" model + h# FF5F7700 encode-int " 8259-interrupt-acknowledge" property + h# 0000F800 encode-int 0 encode-int encode+ 0 encode-int encode+ + 7 encode-int encode+ + " interrupt-map-mask" property + 1 encode-int " #interrupt-cells" property + h# 80000000 encode-int " system-dma-base" property + d# 33333333 encode-int " clock-frequency" property + " " encode-string " primary-bridge" property + 0 encode-int " pci-bridge-number" property + h# FEC00000 encode-int h# 100000 encode-int encode+ " reg" property + 0 encode-int 0 encode-int encode+ " bus-range" property + +new-device + " isa" device-name + " isa" device-type + 2 encode-int " #address-cells" property + 1 encode-int " #size-cells" property + + external + : open true ; + : close ; + +finish-device + +: ?devalias ( alias-str alias-len device-str device-len -- + \ alias-str alias-len false | true ) + active-package >r + " /aliases" find-device + \ 2dup ." Checking " type + 2dup find-dev if \ check if device exists + drop + 2over find-dev if \ do we already have an alias? + \ ." alias exists" cr + drop 2drop false + else + \ ." device exists" cr + encode-string + 2swap property + true + then + else + \ ." device doesn't exist" cr + 2drop false + then + r> active-package! + ; + +:noname + " hd" + " /pci/pci-ata/ata-1/disk@0" ?devalias not if + " /pci/pci-ata/ata-1/disk@1" ?devalias not if + " /pci/pci-ata/ata-2/disk@0" ?devalias not if + " /pci/pci-ata/ata-2/disk@1" ?devalias not if + 2drop ." No disk found." cr + then + then + then + then + + " cdrom" + " /pci/pci-ata/ata-1/cdrom@0" ?devalias not if + " /pci/pci-ata/ata-1/cdrom@1" ?devalias not if + " /pci/pci-ata/ata-2/cdrom@0" ?devalias not if + " /pci/pci-ata/ata-2/cdrom@1" ?devalias not if + 2drop ." No cdrom found" cr + then + then + then + then +; SYSTEM-initializer + +new-device + " ide" device-name + " ide" device-type + " WINBOND,82C553" model + h# 28 encode-int " max-latency" property + h# 2 encode-int " min-grant" property + h# 1 encode-int " devsel-speed" property + h# 0 encode-int " subsystem-vendor-id" property + h# 0 encode-int " subsystem-id" property + h# 1018A encode-int " class-code" property + h# 5 encode-int " revision-id" property + h# 105 encode-int " device-id" property + h# 10AD encode-int " vendor-id" property + h# 1003110 encode-int 0 encode-int encode+ h# 10020 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + h# 1003114 encode-int 0 encode-int encode+ h# 10030 encode-int encode+ + h# 4 encode-int encode+ 0 encode-int encode+ + h# 1003118 encode-int 0 encode-int encode+ h# 10040 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + h# 100311C encode-int 0 encode-int encode+ h# 10034 encode-int encode+ + h# 4 encode-int encode+ 0 encode-int encode+ + h# 1003120 encode-int 0 encode-int encode+ h# 10050 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + h# 1003124 encode-int 0 encode-int encode+ h# 10060 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + " assigned-addresses" property + h# 3100 encode-int 0 encode-int encode+ 0 encode-int encode+ + 0 encode-int encode+ 0 encode-int encode+ + h# 1003110 encode-int 0 encode-int encode+ h# 0 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + h# 1003114 encode-int 0 encode-int encode+ h# 0 encode-int encode+ + h# 4 encode-int encode+ 0 encode-int encode+ + h# 1003118 encode-int 0 encode-int encode+ h# 0 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + h# 100311C encode-int 0 encode-int encode+ h# 0 encode-int encode+ + h# 4 encode-int encode+ 0 encode-int encode+ + h# 1003120 encode-int 0 encode-int encode+ h# 0 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + h# 1003124 encode-int 0 encode-int encode+ h# 0 encode-int encode+ + h# 10 encode-int encode+ 0 encode-int encode+ + " reg" property +finish-device + +new-device + " ethernet" device-name + " network" device-type + " AMD,79C973" model + h# 3800 encode-int 0 encode-int encode+ 0 encode-int encode+ + 0 encode-int encode+ 0 encode-int encode+ + " reg" property +finish-device + +" /pci/isa" find-device + 0 0 " assigned-addresses" property + 0 0 " ranges" property + 0 encode-int " slot-names" property + d# 8333333 encode-int " clock-frequency" property + 0 encode-int " eisa-slots" property + 2 encode-int " #interrupt-cells" property + " W83C553F" encode-string " compatible" property + " WINBOND,82C553" model + 0 encode-int " max-latency" property + 0 encode-int " min-grant" property + 1 encode-int " devsel-speed" property + 0 encode-int " subsystem-vendor-id" property + 0 encode-int " subsystem-id" property + h# 60100 encode-int " class-code" property + h# 10 encode-int " revision-id" property + h# 565 encode-int " device-id" property + h# 10AD encode-int " vendor-id" property + h# 3000 encode-int 0 encode-int encode+ 0 encode-int encode+ + 0 encode-int encode+ 0 encode-int encode+ " reg" property + +new-device + " rtc" device-name + " rtc" device-type + " DS17285S" model + " MC146818" encode-string + " DS17285S" encode-string encode+ + " pnpPNP,b00" encode-string encode+ " compatible" property + 8 encode-int 0 encode-int encode+ " interrupts" property + h# 70 encode-int 1 encode-int encode+ + 2 encode-int encode+ " reg" property +finish-device + +new-device + " interrupt-controller" device-name + " interrupt-controller" device-type + " 8259" model + " " encode-string " interrupt-controller" property + 2 encode-int " #interrupt-cells" property + 1 encode-int + 2 encode-int encode+ + 3 encode-int encode+ + 6 encode-int encode+ + " reserved-interrupts" property + " 8259" encode-string + " chrp,iic" encode-string encode+ + " compatible" property + h# 20 encode-int 1 encode-int encode+ + 2 encode-int encode+ " reg" property +finish-device + +new-device + " serial" device-name + " serial" device-type + " no" encode-string " ctsrts" property + " no" encode-string " xon" property + " no" encode-string " parity" property + d# 115200 encode-int " bps" property + 1 encode-int " stop-bits" property + 8 encode-int " data-bits" property + h# 70800 encode-int " divisor" property + h# 708000 encode-int " clock-frequency" property + 4 encode-int 0 encode-int encode+ " interrupts" property + h# 3F8 encode-int 1 encode-int encode+ + 8 encode-int encode+ " reg" property +finish-device + +" /pci" find-device + " /pci/isa/interrupt-controller" find-dev if + encode-int " interrupt-parent" property + then + h# 3800 encode-int 0 encode-int encode+ + 0 encode-int encode+ 1 encode-int encode+ + " /pci/isa/interrupt-controller" find-dev if + encode-int encode+ + then + h# 0C encode-int encode+ 1 encode-int encode+ + " interrupt-map" property + +" /pci/isa" find-device + " /pci/isa/interrupt-controller" find-dev if + encode-int " interrupt-parent" property + then + +\ ------------------------------------------------------------- +\ /packages +\ ------------------------------------------------------------- + +" /packages" find-device + + " packages" device-name + external + \ allow packages to be opened with open-dev + : open true ; + : close ; + +\ /packages/terminal-emulator +new-device + " terminal-emulator" device-name + external + : open true ; + : close ; + \ : write ( addr len -- actual ) + \ dup -rot type + \ ; +finish-device + +\ ------------------------------------------------------------- +\ The END +\ ------------------------------------------------------------- +device-end diff --git a/qemu/roms/openbios/arch/ppc/pearpc/vfd.c b/qemu/roms/openbios/arch/ppc/pearpc/vfd.c new file mode 100644 index 000000000..06485f2dc --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/pearpc/vfd.c @@ -0,0 +1,42 @@ +/* + * Creation Date: <2004/08/28 17:29:43 greg> + * Time-stamp: <2004/08/28 17:29:43 greg> + * + * <vfd.c> + * + * Simple text console + * + * Copyright (C) 2004 Greg Watson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + +#include "config.h" +#include "libopenbios/bindings.h" +#include "pearpc/pearpc.h" + +static int vfd_is_open; + +static int +vfd_init( void ) +{ + vfd_is_open = 1; + return 0; +} + +void +vfd_close( void ) +{ +} + +int +vfd_draw_str( const char *str ) +{ + if (!vfd_is_open) + vfd_init(); + + return 0; +} |