[OpenBIOS] r201 - openbios-devel/arch/sparc64
svn at openbios.org
svn at openbios.org
Tue Jul 15 17:04:02 CEST 2008
Author: blueswirl
Date: 2008-07-15 17:04:02 +0200 (Tue, 15 Jul 2008)
New Revision: 201
Modified:
openbios-devel/arch/sparc64/boot.h
openbios-devel/arch/sparc64/console.c
openbios-devel/arch/sparc64/init.fs
openbios-devel/arch/sparc64/openbios.c
Log:
Make serial console usable
Modified: openbios-devel/arch/sparc64/boot.h
===================================================================
--- openbios-devel/arch/sparc64/boot.h 2008-07-15 14:59:53 UTC (rev 200)
+++ openbios-devel/arch/sparc64/boot.h 2008-07-15 15:04:02 UTC (rev 201)
@@ -21,3 +21,4 @@
extern uint64_t cmdline_size;
extern char boot_device;
extern struct sys_info sys_info;
+void ob_su_init(uint64_t base, uint64_t offset, int intr);
Modified: openbios-devel/arch/sparc64/console.c
===================================================================
--- openbios-devel/arch/sparc64/console.c 2008-07-15 14:59:53 UTC (rev 200)
+++ openbios-devel/arch/sparc64/console.c 2008-07-15 15:04:02 UTC (rev 201)
@@ -6,17 +6,32 @@
*/
#include "openbios/config.h"
+#include "openbios/bindings.h"
#include "openbios/kernel.h"
#include "openbios.h"
#include "video_subr.h"
+#include "libc/vsprintf.h"
+#include "sys_info.h"
+#include "boot.h"
-#ifdef CONFIG_DEBUG_CONSOLE
+#define REGISTER_NAMED_NODE( name, path ) do { \
+ bind_new_node( name##_flags_, name##_size_, \
+ path, name##_m, sizeof(name##_m)/sizeof(method_t)); \
+ } while(0)
+#define REGISTER_NODE_METHODS( name, path ) do { \
+ const char *paths[1]; \
+ \
+ paths[0] = path; \
+ bind_node( name##_flags_, name##_size_, \
+ paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
+ } while(0)
+
/* ******************************************************************
* serial console functions
* ****************************************************************** */
-#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+#define SER_SIZE 8
#define RBR(x) x==2?0x2f8:0x3f8
#define THR(x) x==2?0x2f8:0x3f8
@@ -85,6 +100,9 @@
}
}
+#ifdef CONFIG_DEBUG_CONSOLE
+#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+
static void serial_cls(void);
static void serial_putchar(int c);
@@ -414,5 +432,147 @@
#endif
}
+#endif // CONFIG_DEBUG_CONSOLE
-#endif // CONFIG_DEBUG_CONSOLE
+/* ( addr len -- actual ) */
+static void
+su_read(unsigned long *address)
+{
+ char *addr;
+ int len;
+
+ len = POP();
+ addr = (char *)POP();
+
+ if (len != 1)
+ printk("su_read: bad len, addr %lx len %x\n", (unsigned long)addr, len);
+
+ if (uart_charav(*address)) {
+ *addr = (char)uart_getchar(*address);
+ PUSH(1);
+ } else {
+ PUSH(0);
+ }
+}
+
+/* ( addr len -- actual ) */
+static void
+su_read_keyboard(void)
+{
+ unsigned char *addr;
+ int len;
+
+ len = POP();
+ addr = (unsigned char *)POP();
+
+ if (len != 1)
+ printk("su_read: bad len, addr %lx len %x\n", (unsigned long)addr, len);
+
+ if (keyboard_dataready()) {
+ *addr = keyboard_readdata();
+ PUSH(1);
+ } else {
+ PUSH(0);
+ }
+}
+
+/* ( addr len -- actual ) */
+static void
+su_write(unsigned long *address)
+{
+ unsigned char *addr;
+ int i, len;
+
+ len = POP();
+ addr = (unsigned char *)POP();
+
+ for (i = 0; i < len; i++) {
+ uart_putchar(*address, addr[i]);
+ }
+ PUSH(len);
+}
+
+static void
+su_close(void)
+{
+}
+
+static void
+su_open(unsigned long *address)
+{
+ int len;
+ phandle_t ph;
+ unsigned long *prop;
+ char *args;
+
+ fword("my-self");
+ fword("ihandle>phandle");
+ ph = (phandle_t)POP();
+ prop = (unsigned long *)get_property(ph, "address", &len);
+ *address = *prop;
+ fword("my-args");
+ args = pop_fstr_copy();
+
+ RET ( -1 );
+}
+
+DECLARE_UNNAMED_NODE(su, INSTALL_OPEN, sizeof(unsigned long));
+
+NODE_METHODS(su) = {
+ { "open", su_open },
+ { "close", su_close },
+ { "read", su_read },
+ { "write", su_write },
+};
+
+DECLARE_UNNAMED_NODE(su_keyboard, INSTALL_OPEN, sizeof(unsigned long));
+
+NODE_METHODS(su_keyboard) = {
+ { "open", su_open },
+ { "close", su_close },
+ { "read", su_read_keyboard },
+};
+
+void
+ob_su_init(uint64_t base, uint64_t offset, int intr)
+{
+ push_str("/pci/isa");
+ fword("find-device");
+ fword("new-device");
+
+ push_str("su");
+ fword("device-name");
+
+ push_str("serial");
+ fword("device-type");
+
+ PUSH((base + offset) >> 32);
+ fword("encode-int");
+ PUSH((base + offset) & 0xffffffff);
+ fword("encode-int");
+ fword("encode+");
+ PUSH(SER_SIZE);
+ fword("encode-int");
+ fword("encode+");
+ push_str("reg");
+ fword("property");
+
+ fword("finish-device");
+
+ REGISTER_NODE_METHODS(su, "/pci/isa/su");
+
+ push_str("/chosen");
+ fword("find-device");
+
+ push_str("/pci/isa/su");
+ fword("open-dev");
+ fword("encode-int");
+ push_str("stdin");
+ fword("property");
+
+ push_str("/pci/isa/su");
+ fword("open-dev");
+ fword("encode-int");
+ push_str("stdout");
+ fword("property");
+}
Modified: openbios-devel/arch/sparc64/init.fs
===================================================================
--- openbios-devel/arch/sparc64/init.fs 2008-07-15 14:59:53 UTC (rev 200)
+++ openbios-devel/arch/sparc64/init.fs 2008-07-15 15:04:02 UTC (rev 201)
@@ -33,8 +33,6 @@
:noname
" memory" " /memory" preopen
" mmu" " /cpus/@0" preopen
- " stdout" " /builtin/console" preopen
- " stdin" " /builtin/console" preopen
; SYSTEM-initializer
Modified: openbios-devel/arch/sparc64/openbios.c
===================================================================
--- openbios-devel/arch/sparc64/openbios.c 2008-07-15 14:59:53 UTC (rev 200)
+++ openbios-devel/arch/sparc64/openbios.c 2008-07-15 15:04:02 UTC (rev 201)
@@ -345,8 +345,10 @@
#endif
nvram_init();
- device_end();
+ ob_su_init(0x1fe02000000ULL, 0x3f8ULL, 0);
+ device_end();
+
bind_func("platform-boot", boot );
}
More information about the OpenBIOS
mailing list