diff --git a/arch/sparc32/openbios.c b/arch/sparc32/openbios.c
index c1b4e47..d5a4cb0 100644
--- a/arch/sparc32/openbios.c
+++ b/arch/sparc32/openbios.c
@@ -57,6 +57,9 @@ arch_init( void )
#endif
#ifdef CONFIG_DRIVER_ESP
ob_esp_init();
+#endif
+#ifdef CONFIG_DRIVER_OBIO
+ ob_obio_init(0x71000000);
#endif
device_end();
bind_func("platform-boot", boot );
diff --git a/arch/sparc32/romvec.c b/arch/sparc32/romvec.c
index 611d935..678ea5a 100644
--- a/arch/sparc32/romvec.c
+++ b/arch/sparc32/romvec.c
@@ -76,7 +76,7 @@ static int obp_nextnode(int node)
PUSH(node);
fword("peer");
peer = POP();
- DPRINTF("obp_nextnode(%x) = %x\n", node, peer);
+ DPRINTF("obp_nextnode(0x%x) = 0x%x\n", node, peer);
return peer;
}
@@ -88,7 +88,7 @@ static int obp_child(int node)
PUSH(node);
fword("child");
child = POP();
- DPRINTF("obp_child(%x) = %x\n", node, child);
+ DPRINTF("obp_child(0x%x) = 0x%x\n", node, child);
return child;
}
@@ -103,9 +103,7 @@ static int obp_proplen(int node, char *name)
notfound = POP();
if (notfound) {
- DPRINTF("obp_proplen(%x, %s) (not found)\n", node, name);
- (void) POP();
- (void) POP();
+ DPRINTF("obp_proplen(0x%x, %s) (not found)\n", node, name);
return -1;
} else {
@@ -113,7 +111,7 @@ static int obp_proplen(int node, char *name)
len = POP();
(void) POP();
- DPRINTF("obp_proplen(%x, %s) = %d\n", node, name, len);
+ DPRINTF("obp_proplen(0x%x, %s) = %d\n", node, name, len);
return len;
}
@@ -138,9 +136,7 @@ static int obp_getprop(int node, char *name, char *value)
notfound = POP();
}
if (notfound) {
- DPRINTF("obp_getprop(%x, %s) (not found)\n", node, name);
- (void) POP();
- (void) POP();
+ DPRINTF("obp_getprop(0x%x, %s) (not found)\n", node, name);
return -1;
} else {
@@ -151,7 +147,7 @@ static int obp_getprop(int node, char *name, char *value)
str = (char *) POP();
memcpy(value, str, len);
- DPRINTF("obp_getprop(%x, %s) = %s\n", node, name, str);
+ DPRINTF("obp_getprop(0x%x, %s) = %s\n", node, name, str);
return len;
}
@@ -162,14 +158,13 @@ static int obp_setprop(__attribute__((unused)) int node,
__attribute__((unused)) char *value,
__attribute__((unused)) int len)
{
- DPRINTF("obp_setprop(%x, %s) = %s (%d)\n", node, name, value, len);
+ DPRINTF("obp_setprop(0x%x, %s) = %s (%d)\n", node, name, value, len);
return -1;
}
static const char *obp_nextprop(int node, char *name)
{
- char *ret;
int found;
if (!name || *name == '\0') {
@@ -183,11 +178,11 @@ static const char *obp_nextprop(int node, char *name)
fword("next-property");
found = POP();
if (!found) {
- DPRINTF("obp_nextprop(%x, %s) (not found)\n", node, name);
+ DPRINTF("obp_nextprop(0x%x, %s) (not found)\n", node, name);
(void) POP();
(void) POP();
- return NULL;
+ return "";
} else {
int len;
char *str;
@@ -195,7 +190,7 @@ static const char *obp_nextprop(int node, char *name)
len = POP();
str = (char *) POP();
- DPRINTF("obp_nextprop(%x, %s) = %s\n", node, name, str);
+ DPRINTF("obp_nextprop(0x%x, %s) = %s\n", node, name, str);
return str;
}
@@ -271,7 +266,7 @@ static int obp_rdblkdev(int dev_desc, int num_blks, int offset, char *buf)
ret = obp_devread(dev_desc, buf, num_blks * bs) / bs;
- DPRINTF("obp_rdblkdev(fd %x, num_blks %d, offset %d (hi %d lo %d), buf 0x%x) = %d\n", dev_desc, num_blks, offset, hi, lo, (int)buf, ret);
+ DPRINTF("obp_rdblkdev(fd 0x%x, num_blks %d, offset %d (hi %d lo %d), buf 0x%x) = %d\n", dev_desc, num_blks, offset, hi, lo, (int)buf, ret);
return ret;
}
@@ -283,7 +278,7 @@ static char *obp_dumb_mmap(char *va, __attribute__((unused)) int which_io,
unsigned int off;
unsigned int mva;
- DPRINTF("obp_dumb_mmap: virta %x, which_io %d, paddr %x, sz %d\n", va, which_io, pa, size);
+ DPRINTF("obp_dumb_mmap: virta 0x%x, which_io %d, paddr 0x%x, sz %d\n", va, which_io, pa, size);
off = pa & (PAGE_SIZE-1);
npages = (off + size + (PAGE_SIZE-1)) / PAGE_SIZE;
pa &= ~(PAGE_SIZE-1);
@@ -301,7 +296,7 @@ static char *obp_dumb_mmap(char *va, __attribute__((unused)) int which_io,
static void obp_dumb_munmap(__attribute__((unused)) char *va,
__attribute__((unused)) unsigned int size)
{
- DPRINTF("obp_dumb_munmap: virta %x, sz %d\n", va, size);
+ DPRINTF("obp_dumb_munmap: virta 0x%x, sz %d\n", va, size);
}
static int obp_devread(int dev_desc, char *buf, int nbytes)
@@ -371,7 +366,7 @@ static int obp_cpustart(unsigned int whichcpu, int ctxtbl_ptr,
//int cpu, found;
struct linux_prom_registers *smp_ctable = (void *)ctxtbl_ptr;
- DPRINTF("obp_cpustart: cpu %d, ctxptr %x, ctx %d, pc %x\n", whichcpu,
+ DPRINTF("obp_cpustart: cpu %d, ctxptr 0x%x, ctx %d, pc 0x%x\n", whichcpu,
smp_ctable->phys_addr, thiscontext, prog_counter);
#if 0
found = obp_getprop(whichcpu, "mid", (char *)&cpu);
@@ -435,7 +430,7 @@ init_openprom(unsigned long memsize, const char *cmdline, char boot_device)
prop_mem_reg[2] = memsize;
prop_mem_avail[0] = 0;
prop_mem_avail[1] = 0;
- prop_mem_avail[2] = va2pa((unsigned long)&_data);
+ prop_mem_avail[2] = va2pa((unsigned long)&_data) - 1;
prop_vmem_avail[0] = 0;
prop_vmem_avail[1] = 0;
prop_vmem_avail[2] = (unsigned long)&_start - 1;
@@ -506,6 +501,14 @@ init_openprom(unsigned long memsize, const char *cmdline, char boot_device)
romvec0.pv_v2bootargs.bootargs = &cmdline;
romvec0.pv_v2bootargs.fd_stdin = &obp_fd_stdin;
romvec0.pv_v2bootargs.fd_stdout = &obp_fd_stdout;
+
+ push_str("/builtin/console");
+ fword("open-dev");
+ obp_fd_stdin = POP();
+ push_str("/builtin/console");
+ fword("open-dev");
+ obp_fd_stdout = POP();
+
obp_stdin = PROMDEV_TTYA;
obp_stdout = PROMDEV_TTYA;
diff --git a/arch/sparc32/tree.fs b/arch/sparc32/tree.fs
index 252e7b4..cfed64b 100644
--- a/arch/sparc32/tree.fs
+++ b/arch/sparc32/tree.fs
@@ -96,7 +96,7 @@ new-device
" SUNW,tcx" device-name
" display" device-type
h# 1d encode-int " vbporch" property
- h# 90 encode-int " hbporch" property
+ h# a0 encode-int " hbporch" property
h# 06 encode-int " vsync" property
h# 88 encode-int " hsync" property
h# 03 encode-int " vfporch" property
@@ -111,7 +111,7 @@ new-device
5 encode-int 0 encode-int encode+ " intr" property
5 encode-int " interrupts" property
2 encode-int h# 00800000 encode-int encode+ h# 00100000 encode-int encode+
- 2 encode-int encode+ h# 02000000 encode-int encode+ h# 00000001 encode-int encode+
+ 2 encode-int encode+ h# 02000000 encode-int encode+ h# 00000001 encode-int encode+
2 encode-int encode+ h# 04000000 encode-int encode+ h# 00800000 encode-int encode+
2 encode-int encode+ h# 06000000 encode-int encode+ h# 00800000 encode-int encode+
2 encode-int encode+ h# 0a000000 encode-int encode+ h# 00000001 encode-int encode+
@@ -235,8 +235,8 @@ new-device
h# 0 encode-int h# 00000000 encode-int encode+ h# 00000008 encode-int encode+ " reg" property
1 encode-int " slave" property
h# 2c encode-int 0 encode-int encode+ " intr" property
- 1 encode-int " keyboard" property
- 1 encode-int " mouse" property
+ -1 encode-int " keyboard" property
+ -1 encode-int " mouse" property
finish-device
" /obio" find-device
diff --git a/config/examples/cross-sparc32_config.xml b/config/examples/cross-sparc32_config.xml
index c524ae0..7d617e4 100644
--- a/config/examples/cross-sparc32_config.xml
+++ b/config/examples/cross-sparc32_config.xml
@@ -67,6 +67,7 @@
+
diff --git a/config/examples/sparc32_config.xml b/config/examples/sparc32_config.xml
index dedfc38..3d91777 100644
--- a/config/examples/sparc32_config.xml
+++ b/config/examples/sparc32_config.xml
@@ -67,6 +67,7 @@
+
diff --git a/drivers/build.xml b/drivers/build.xml
index ce8deee..a7f4fb3 100644
--- a/drivers/build.xml
+++ b/drivers/build.xml
@@ -11,6 +11,7 @@
+
diff --git a/drivers/esp.c b/drivers/esp.c
index fc5fd26..df22e94 100644
--- a/drivers/esp.c
+++ b/drivers/esp.c
@@ -363,6 +363,14 @@ ob_esp_initialize(__attribute__((unused)) esp_private_t **esp)
fword("encode+");
push_str("reg");
fword("property");
+
+ PUSH(0x24);
+ fword("encode-int");
+ PUSH(0);
+ fword("encode-int");
+ fword("encode+");
+ push_str("intr");
+ fword("property");
}
static void
diff --git a/drivers/obio.c b/drivers/obio.c
new file mode 100644
index 0000000..90dfd58
--- /dev/null
+++ b/drivers/obio.c
@@ -0,0 +1,85 @@
+/*
+ * OpenBIOS Sparc OBIO driver
+ *
+ * (C) 2004 Stefan Reinauer
+ * (C) 2005 Ed Schouten
+ *
+ * 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 "openbios/config.h"
+#include "openbios/bindings.h"
+#include "openbios/kernel.h"
+#include "libc/byteorder.h"
+#include "libc/vsprintf.h"
+
+#include "openbios/drivers.h"
+
+static void
+ob_zs_init(unsigned long slavio_base)
+{
+ unsigned long zs_addr;
+
+ zs_addr = (unsigned long)map_io(slavio_base + 0x0, 8);
+ push_str("/obio/zs@0,0");
+ fword("find-device");
+
+ PUSH(zs_addr);
+ fword("encode-int");
+ PUSH(sizeof(zs_addr));
+ fword("encode-int");
+ fword("encode+");
+ push_str("address");
+ fword("property");
+
+ zs_addr = (unsigned long)map_io(slavio_base + 0x00100000, 8);
+ push_str("/obio/zs@0,100000");
+ fword("find-device");
+
+ PUSH(zs_addr);
+ fword("encode-int");
+ PUSH(sizeof(zs_addr));
+ fword("encode-int");
+ fword("encode+");
+ push_str("address");
+ fword("property");
+}
+
+static void
+ob_obio_open(int *idx)
+{
+ int ret=1;
+ RET ( -ret );
+}
+
+static void
+ob_obio_close(int *idx)
+{
+ selfword("close-deblocker");
+}
+
+static void
+ob_obio_initialize(int *idx)
+{
+}
+
+
+NODE_METHODS(ob_obio_node) = {
+ { NULL, ob_obio_initialize },
+ { "open", ob_obio_open },
+ { "close", ob_obio_close },
+};
+
+
+int ob_obio_init(unsigned long slavio_base)
+{
+
+ //printk("Initializing OBIO devices...\n");
+
+ ob_zs_init(slavio_base);
+
+ return 0;
+}
diff --git a/include/openbios/drivers.h b/include/openbios/drivers.h
index f34385e..96788ff 100644
--- a/include/openbios/drivers.h
+++ b/include/openbios/drivers.h
@@ -23,4 +23,7 @@ int ob_ide_init(void);
#ifdef CONFIG_DRIVER_ESP
int ob_esp_init(void);
#endif
+#ifdef CONFIG_DRIVER_OBIO
+int ob_obio_init(unsigned long slavio_base);
+#endif