[OpenBIOS] r259 - in openbios-devel: arch/ppc/qemu drivers
svn at openbios.org
svn at openbios.org
Mon Nov 24 13:41:36 CET 2008
Author: stepan
Date: 2008-11-24 13:41:36 +0100 (Mon, 24 Nov 2008)
New Revision: 259
Removed:
openbios-devel/drivers/adb.fs
Modified:
openbios-devel/arch/ppc/qemu/init.c
openbios-devel/arch/ppc/qemu/qemu.fs
openbios-devel/drivers/adb.c
openbios-devel/drivers/adb.h
openbios-devel/drivers/build.xml
openbios-devel/drivers/cuda.c
openbios-devel/drivers/cuda.h
Log:
ADB/CUDA fixes
Modified: openbios-devel/arch/ppc/qemu/init.c
===================================================================
--- openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/arch/ppc/qemu/init.c 2008-11-24 12:41:36 UTC (rev 259)
@@ -31,7 +31,6 @@
extern void unexpected_excep( int vector );
extern void ob_ide_init( void );
extern void ob_pci_init( void );
-extern void ob_adb_init( void );
extern void setup_timers( void );
void
@@ -113,9 +112,6 @@
#ifdef CONFIG_DRIVER_IDE
ob_ide_init();
#endif
-#ifdef CONFIG_DRIVER_ADB
- ob_adb_init();
-#endif
node_methods_init();
Modified: openbios-devel/arch/ppc/qemu/qemu.fs
===================================================================
--- openbios-devel/arch/ppc/qemu/qemu.fs 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/arch/ppc/qemu/qemu.fs 2008-11-24 12:41:36 UTC (rev 259)
@@ -35,12 +35,12 @@
\ preopen device nodes (and store the ihandles under /chosen)
:noname
- " rtc" " /pci/isa/rtc" preopen
+ " rtc" " rtc" preopen
" memory" " /memory" preopen
" mmu" " /cpu at 0" preopen
\ " stdout" " /packages/terminal-emulator" preopen
- " stdout" " /pci/pci6666,6666" preopen
- " stdin" " /pci/via-cuda/adb" preopen
+ " stdout" " screen" preopen
+ " stdin" " adb-keyboard" preopen
; SYSTEM-initializer
@@ -93,8 +93,8 @@
\ 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
+ " adb-keyboard" " input-device" $setenv
+ " screen" " output-device" $setenv
then
;
Modified: openbios-devel/drivers/adb.c
===================================================================
--- openbios-devel/drivers/adb.c 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/drivers/adb.c 2008-11-24 12:41:36 UTC (rev 259)
@@ -27,8 +27,10 @@
#include "adb.h"
#include "kbd.h"
#include "cuda.h"
+#include "libc/byteorder.h"
+#include "libc/vsprintf.h"
-#define DEBUG_ADB 1
+//#define DEBUG_ADB 1
#ifdef DEBUG_ADB
#define ADB_DPRINTF(fmt, args...) \
@@ -37,8 +39,29 @@
#define ADB_DPRINTF(fmt, args...) do { } while (0)
#endif
-DECLARE_NODE( adb, INSTALL_OPEN, 0, "/pci/via-cuda/adb" );
+static void adb_read(void);
+DECLARE_UNNAMED_NODE( keyboard, INSTALL_OPEN, sizeof(int));
+
+static void
+keyboard_open(int *idx)
+{
+ RET(-1);
+}
+
+static void
+keyboard_close(int *idx)
+{
+}
+
+static void keyboard_read(void);
+
+NODE_METHODS( keyboard ) = {
+ { "open", keyboard_open },
+ { "close", keyboard_close },
+ { "read", keyboard_read },
+};
+
/* ADB US keyboard translation map
* XXX: for now, only shift modifier is defined
*/
@@ -424,14 +447,9 @@
int next_key;
};
+static adb_kbd_t *my_adb_kbd = NULL;
+static adb_dev_t *my_adb_dev = NULL;
-
-
-
-static adb_kbd_t *my_adb_kbd;
-adb_dev_t *my_adb_dev;
-//={ NULL, NULL, 2, 1, (unsigned int)0x80816000 };
-
static int adb_kbd_read (void *private)
{
uint8_t buffer[ADB_BUF_SIZE];
@@ -441,7 +459,6 @@
int ret;
kbd = (void *)dev->state;
- //ADB_DPRINTF("enter\n");
/* Get saved state */
ret = -1;
for (key = -1; key == -1; ) {
@@ -449,9 +466,8 @@
key = kbd->next_key;
kbd->next_key = -1;
} else {
- if (adb_reg_get(dev, 0, buffer) != 2) {
- goto out;
- }
+ if (adb_reg_get(dev, 0, buffer) != 2)
+ break;
kbd->next_key = buffer[1] == 0xFF ? -1 : buffer[1];
key = buffer[0];
}
@@ -459,45 +475,102 @@
ADB_DPRINTF("Translated %d (%02x) into %d (%02x)\n",
key, key, ret, ret);
}
- out:
return ret;
}
-void *adb_kbd_new (void *private)
+void *adb_kbd_new (char *path, void *private)
{
- adb_kbd_t *kbd=my_adb_kbd;
+ char buf[64];
+ int props[1];
+ phandle_t ph, aliases;
+ adb_kbd_t *kbd;
+ adb_dev_t *dev = private;
+ kbd = (adb_kbd_t*)malloc(sizeof(adb_kbd_t));
+ if (kbd != NULL) {
+ memset(kbd, 0, sizeof(adb_kbd_t));
+ kbd_set_keymap(&kbd->kbd, sizeof(ADB_kbd_us) / sizeof(keymap_t),
+ ADB_kbd_us);
+ kbd->next_key = -1;
+ dev->state = (int32_t)kbd;
+ my_adb_dev = dev;
+ }
- memset(kbd, 0, sizeof(adb_kbd_t));
- kbd_set_keymap(&kbd->kbd, sizeof(ADB_kbd_us) / sizeof(keymap_t), ADB_kbd_us);
- kbd->next_key = -1;
-
- //my_adb_dev.state=(unsigned int)my_adb_kbd;
- my_adb_dev=private;
- return NULL;
+ sprintf(buf, "%s/keyboard", path);
+ REGISTER_NAMED_NODE( keyboard, buf);
+
+ ph = find_dev(buf);
+
+ set_property(ph, "device_type", "keyboard", 9);
+ props[0] = __cpu_to_be32(dev->addr);
+ set_property(ph, "reg", &props, sizeof(props));
+
+ aliases = find_dev("/aliases");
+ set_property(aliases, "adb-keyboard", buf, strlen(buf) + 1);
+
+ return kbd;
}
/* ( addr len -- actual ) */
-void adb_read(void)
+static void keyboard_read(void)
{
char *addr;
- int len, key;
+ int len, key, i;
len=POP();
addr=(char *)POP();
- if(len!=1) printk("adb_read: %x %x\n", (unsigned int)addr , len);
-
- key=adb_kbd_read(my_adb_dev);
- //key=-1;
- if (key!=-1) {
- *addr=(char)key;
- PUSH(1);
- } else
- PUSH(0);
+ for (i = 0; i < len; i++) {
+ key = adb_kbd_read(my_adb_dev);
+ if (key == -1 || key == -2)
+ break;
+ *addr++ = (char)key;
+ }
+ PUSH(i);
}
+DECLARE_UNNAMED_NODE( mouse, INSTALL_OPEN, sizeof(int));
+static void
+mouse_open(int *idx)
+{
+ RET(-1);
+}
+
+static void
+mouse_close(int *idx)
+{
+}
+
+static void mouse_read(void);
+
+NODE_METHODS( mouse ) = {
+ { "open", mouse_open },
+ { "close", mouse_close },
+};
+
+void *adb_mouse_new (char *path, void *private)
+{
+ char buf[64];
+ int props[1];
+ phandle_t ph, aliases;
+ adb_dev_t *dev = private;
+
+ sprintf(buf, "%s/mouse", path);
+ REGISTER_NAMED_NODE( mouse, buf);
+
+ ph = find_dev(buf);
+
+ set_property(ph, "device_type", "mouse", 6);
+ props[0] = __cpu_to_be32(dev->addr);
+ set_property(ph, "reg", &props, sizeof(props));
+ set_int_property(ph, "#buttons", 3);
+
+ aliases = find_dev("/aliases");
+ set_property(aliases, "adb-mouse", buf, strlen(buf) + 1);
+}
+
+
int adb_cmd (adb_dev_t *dev, uint8_t cmd, uint8_t reg,
uint8_t *buf, int len)
{
@@ -561,18 +634,3 @@
return len;
}
-
-
-NODE_METHODS( adb ) = {
- { "read", adb_read },
-};
-
-int ob_adb_init(void)
-{
- printk("Initializing ADB driver\n");
- cuda_init(0x80800000 + 0x16000);
- REGISTER_NODE( adb );
- //adb_kbd_new();
- return 0;
-}
-
Deleted: openbios-devel/drivers/adb.fs
===================================================================
--- openbios-devel/drivers/adb.fs 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/drivers/adb.fs 2008-11-24 12:41:36 UTC (rev 259)
@@ -1,33 +0,0 @@
-[IFDEF] CONFIG_DRIVER_ADB
-
-dev /pci
-\ simple pci bus node
-new-device
-" via-cuda" device-name
-" via-cuda" encode-string " device_type" property
-" cuda" encode-string " compatible" property
-
-external
-: open ( ." opening CUDA" cr ) true ;
-: close ;
-: decode-unit 0 decode-unit-pci-bus ;
-: encode-unit encode-unit-pci ;
-finish-device
-
-dev /pci/via-cuda
-
-new-device
-" adb" device-name
-" adb" encode-string " device_type" property
-0 encode-int " #size-cells" property
-1 encode-int " #address-cells" property
-
-external
-: open ( ." opening ADB" cr ) true ;
-: close ;
-finish-device
-
-device-end
-
-[THEN]
-
Modified: openbios-devel/drivers/adb.h
===================================================================
--- openbios-devel/drivers/adb.h 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/drivers/adb.h 2008-11-24 12:41:36 UTC (rev 259)
@@ -71,7 +71,7 @@
adb_bus_t *adb_bus_new (void *host,
int (*req)(void *host, const uint8_t *snd_buf,
int len, uint8_t *rcv_buf));
-int adb_bus_init (adb_bus_t *bus);
+int adb_bus_init (char *path, adb_bus_t *bus);
static inline int adb_reset (adb_bus_t *bus)
{
@@ -99,7 +99,7 @@
return adb_cmd(dev, ADB_LISTEN, reg, buf, len);
}
-void *adb_kbd_new (void *private);
+void *adb_kbd_new (char *path, void *private);
#endif /* !defined(__OHW_ADB_H__) */
Modified: openbios-devel/drivers/build.xml
===================================================================
--- openbios-devel/drivers/build.xml 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/drivers/build.xml 2008-11-24 12:41:36 UTC (rev 259)
@@ -6,7 +6,7 @@
<object source="timer.c" condition="DRIVER_IDE"/>
<object source="kbd.c" condition="DRIVER_ADB"/>
<object source="adb.c" condition="DRIVER_ADB"/>
- <object source="cuda.c" condition="DRIVER_ADB"/>
+ <object source="cuda.c" condition="DRIVER_PCI"/>
<object source="floppy.c" condition="DRIVER_FLOPPY"/>
<object source="iommu.c" condition="DRIVER_SBUS"/>
<object source="sbus.c" condition="DRIVER_SBUS"/>
@@ -20,7 +20,6 @@
<dictionary name="openbios" target="forth">
<object source="pci.fs" condition="DRIVER_PCI"/>
<object source="ide.fs" condition="DRIVER_IDE"/>
- <object source="adb.fs" condition="DRIVER_ADB"/>
<object source="sbus.fs" condition="DRIVER_SBUS"/>
<object source="esp.fs" condition="DRIVER_ESP"/>
</dictionary>
Modified: openbios-devel/drivers/cuda.c
===================================================================
--- openbios-devel/drivers/cuda.c 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/drivers/cuda.c 2008-11-24 12:41:36 UTC (rev 259)
@@ -1,10 +1,13 @@
#include "openbios/config.h"
#include "openbios/bindings.h"
+#include "libc/byteorder.h"
+#include "libc/vsprintf.h"
+
#include "adb.h"
#include "cuda.h"
-#define DEBUG_CUDA
+//#define DEBUG_CUDA
#ifdef DEBUG_CUDA
#define CUDA_DPRINTF(fmt, args...) \
do { printk("CUDA - %s: " fmt, __func__ , ##args); } while (0)
@@ -13,6 +16,9 @@
#endif
#define ADB_DPRINTF CUDA_DPRINTF
+#define IO_CUDA_OFFSET 0x00016000
+#define IO_CUDA_SIZE 0x00002000
+
/* VIA registers - spaced 0x200 bytes apart */
#define RS 0x200 /* skip between registers */
#define B 0 /* B-side data */
@@ -145,27 +151,158 @@
}
-cuda_t *cuda_init (uint32_t base)
+DECLARE_UNNAMED_NODE(ob_cuda, INSTALL_OPEN, sizeof(int));
+
+static void
+ob_cuda_initialize (int *idx)
{
+ extern phandle_t pic_handle;
+ phandle_t ph=get_cur_dev();
+ int props[2];
+
+ push_str("via-cuda");
+ fword("device-type");
+
+ set_int_property(ph, "#address-cells", 1);
+ set_int_property(ph, "#size-cells", 0);
+
+ set_property(ph, "compatible", "cuda", 5);
+
+ props[0] = __cpu_to_be32(IO_CUDA_OFFSET);
+ props[1] = __cpu_to_be32(IO_CUDA_SIZE);
+
+ set_property(ph, "reg", &props, sizeof(props));
+ set_int_property(ph, "interrupt-parent", pic_handle);
+ // HEATHROW
+ set_int_property(ph, "interrupts", 0x12);
+}
+
+static void
+ob_cuda_open(int *idx)
+{
+ RET(-1);
+}
+
+static void
+ob_cuda_close(int *idx)
+{
+}
+
+static void
+ob_cuda_decode_unit(void *private)
+{
+ PUSH(0);
+ fword("decode-unit-pci-bus");
+}
+
+static void
+ob_cuda_encode_unit(void *private)
+{
+ fword("encode-unit-pci");
+}
+
+NODE_METHODS(ob_cuda) = {
+ { NULL, ob_cuda_initialize },
+ { "open", ob_cuda_open },
+ { "close", ob_cuda_close },
+ { "decode-unit", ob_cuda_decode_unit },
+ { "encode-unit", ob_cuda_encode_unit },
+};
+
+DECLARE_UNNAMED_NODE(rtc, INSTALL_OPEN, sizeof(int));
+
+static void
+rtc_open(int *idx)
+{
+ RET(-1);
+}
+
+NODE_METHODS(rtc) = {
+ { "open", rtc_open },
+};
+
+static void
+rtc_init(char *path)
+{
+ phandle_t ph, aliases;
+ char buf[64];
+
+ sprintf(buf, "%s/rtc", path);
+ REGISTER_NAMED_NODE(rtc, buf);
+
+ ph = find_dev(buf);
+ set_property(ph, "device_type", "rtc", 4);
+ set_property(ph, "compatible", "rtc", 4);
+
+ aliases = find_dev("/aliases");
+ set_property(aliases, "rtc", buf, strlen(buf) + 1);
+
+}
+
+cuda_t *cuda_init (char *path, uint32_t base)
+{
cuda_t *cuda;
+ char buf[64];
- //CUDA_DPRINTF(" base=%08x\n", base);
+ base += IO_CUDA_OFFSET;
+ CUDA_DPRINTF(" base=%08x\n", base);
cuda = malloc(sizeof(cuda_t));
if (cuda == NULL)
return NULL;
+
+ sprintf(buf, "%s/via-cuda", path);
+ REGISTER_NAMED_NODE(ob_cuda, buf);
+
cuda->base = base;
cuda_writeb(cuda, B, cuda_readb(cuda, B) | TREQ | TIP);
+#ifdef CONFIG_DRIVER_ADB
cuda->adb_bus = adb_bus_new(cuda, &cuda_adb_req);
if (cuda->adb_bus == NULL) {
free(cuda);
return NULL;
}
- adb_bus_init(cuda->adb_bus);
+ adb_bus_init(buf, cuda->adb_bus);
+#endif
+ rtc_init(buf);
+
return cuda;
}
+#ifdef CONFIG_DRIVER_ADB
+DECLARE_UNNAMED_NODE( adb, INSTALL_OPEN, sizeof(int));
+
+static void
+adb_initialize (int *idx)
+{
+ phandle_t ph=get_cur_dev();
+
+ push_str("adb");
+ fword("device-type");
+
+ set_property(ph, "compatible", "adb", 4);
+ set_int_property(ph, "#address-cells", 1);
+ set_int_property(ph, "#size-cells", 0);
+}
+
+static void
+adb_open(int *idx)
+{
+ RET(-1);
+}
+
+static void
+adb_close(int *idx)
+{
+}
+
+NODE_METHODS( adb ) = {
+ { NULL, adb_initialize },
+ { "open", adb_open },
+ { "close", adb_close },
+};
+
adb_bus_t *adb_bus_new (void *host,
int (*req)(void *host, const uint8_t *snd_buf,
int len, uint8_t *rcv_buf))
@@ -184,8 +321,9 @@
/* Check and relocate all ADB devices as suggested in
* * ADB_manager Apple documentation
* */
-int adb_bus_init (adb_bus_t *bus)
+int adb_bus_init (char *path, adb_bus_t *bus)
{
+ char buf[64];
uint8_t buffer[ADB_BUF_SIZE];
uint8_t adb_addresses[16] =
{ 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, 0, };
@@ -194,6 +332,8 @@
int reloc = 0, next_free = 7;
int keep;
+ sprintf(buf, "%s/adb", path);
+ REGISTER_NAMED_NODE( adb, buf);
/* Reset the bus */
// ADB_DPRINTF("\n");
adb_reset(bus);
@@ -258,11 +398,11 @@
break;
case ADB_KEYBD:
ADB_DPRINTF("Found one keyboard on address %d\n", address);
- adb_kbd_new(*cur);
+ adb_kbd_new(buf, *cur);
break;
case ADB_MOUSE:
ADB_DPRINTF("Found one mouse on address %d\n", address);
- //chardev_register(CHARDEV_MOUSE, &adb_mouse_ops, *cur);
+ adb_mouse_new(buf, *cur);
break;
case ADB_ABS:
ADB_DPRINTF("Found one absolute positioning device\n");
@@ -294,4 +434,4 @@
return 0;
}
-
+#endif
Modified: openbios-devel/drivers/cuda.h
===================================================================
--- openbios-devel/drivers/cuda.h 2008-11-24 12:38:23 UTC (rev 258)
+++ openbios-devel/drivers/cuda.h 2008-11-24 12:41:36 UTC (rev 259)
@@ -15,6 +15,6 @@
};
-cuda_t *cuda_init (uint32_t base);
+cuda_t *cuda_init (char *path, uint32_t base);
More information about the OpenBIOS
mailing list