summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/arch/ppc/briq/briq.c
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@intel.com>2015-08-28 09:58:54 +0800
committerYang Zhang <yang.z.zhang@intel.com>2015-09-01 12:44:00 +0800
commite44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch)
tree66b09f592c55df2878107a468a91d21506104d3f /qemu/roms/openbios/arch/ppc/briq/briq.c
parent9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (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/briq/briq.c')
-rw-r--r--qemu/roms/openbios/arch/ppc/briq/briq.c194
1 files changed, 194 insertions, 0 deletions
diff --git a/qemu/roms/openbios/arch/ppc/briq/briq.c b/qemu/roms/openbios/arch/ppc/briq/briq.c
new file mode 100644
index 000000000..a8541c370
--- /dev/null
+++ b/qemu/roms/openbios/arch/ppc/briq/briq.c
@@ -0,0 +1,194 @@
+/*
+ * Creation Date: <2004/08/28 18:38:22 greg>
+ * Time-stamp: <2004/08/28 18:38:22 greg>
+ *
+ * <briq.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 "briq/briq.h"
+#include <stdarg.h>
+
+#define UART_BASE 0x3f8
+
+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 = vnsprintf(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 */
+/************************************************************************/
+
+static char nvram[2048];
+
+void
+dump_nvram(void)
+{
+ static char hexdigit[] = "0123456789abcdef";
+ int i;
+ for (i = 0; i < 16*4; i++)
+ {
+ printk ("%c", hexdigit[nvram[i] >> 4]);
+ printk ("%c", hexdigit[nvram[i] % 16]);
+ if (!((i + 1) % 16))
+ {
+ printk ("\n");
+ }
+ else
+ {
+ printk (" ");
+ }
+ }
+}
+
+
+int
+arch_nvram_size( void )
+{
+ return sizeof(nvram);
+}
+
+void
+arch_nvram_put( char *buf )
+{
+ memcpy(nvram, buf, sizeof(nvram));
+ printk("new nvram:\n");
+ dump_nvram();
+}
+
+void
+arch_nvram_get( char *buf )
+{
+ memcpy(buf, nvram, sizeof(nvram));
+ printk("current nvram:\n");
+ dump_nvram();
+}