preps for marcans bt hax
authorBernhard Urban <lewurm@gmx.net>
Tue, 29 Sep 2009 10:20:29 +0000 (12:20 +0200)
committerBernhard Urban <lewurm@gmx.net>
Tue, 29 Sep 2009 10:20:58 +0000 (12:20 +0200)
main.c
usb/Makefile
usb/core/core.c
usb/core/core.h
usb/core/usb.c
usb/drivers/bt.c [new file with mode: 0644]
usb/drivers/bt.h [new file with mode: 0644]
usb/drivers/class/hid.c

diff --git a/main.c b/main.c
index 67d6d88c26a3224b997f44b943af21462bb2cac0..d1c895faf19755ff5622f384fc97b375852fdc2d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -27,6 +27,7 @@ Copyright (C) 2009              John Kelley <wiidev@kelley.ca>
 #include "irq.h"
 #include "usb/core/core.h"
 #include "usb/drivers/class/hid.h"
+#include "usb/drivers/bt.h"
 #include "sha1.h"
 #include "hollywood.h"
 
@@ -93,7 +94,7 @@ int main(void)
        /* external ohci */
        irq_hw_enable(IRQ_OHCI0);
        /* internal ohci */
-       //irq_hw_enable(IRQ_OHCI1);
+       irq_hw_enable(IRQ_OHCI1);
 
        ipc_initialize();
        ipc_slowping();
@@ -123,11 +124,14 @@ int main(void)
        usb_init(OHCI0_REG_BASE);
 
        /* internal ohci */
-       //usb_init(OHCI1_REG_BASE);
+       usb_init(OHCI1_REG_BASE);
 
        /* load HID keyboard driver */
        usb_hidkb_init();
 
+       /* load BT-USB driver */
+       usb_bt_init();
+
 wait_kb:
        /* wait for usb keyboard plugged in */
        if(!usb_hidkb_inuse()) {
index 8dee0bc4031d105a33b2ac613f4122fe1e69ba50..efdf4454199cbfa68f388938bc836734e1e80a18 100644 (file)
@@ -12,4 +12,4 @@ CFLAGS += -D _DU_USB #@ u/c/usb.c
 
 OBJS += usb/host/ohci.o usb/core/core.o usb/core/usb.o \
                usb/lib/list.o \
-               usb/drivers/class/hid.o
+               usb/drivers/class/hid.o usb/drivers/bt.o
index a6c84fb2a7dd13aa3409feb94592fa69071052a1..4ab945cd9accebc263479217ce06897598d04ecb 100644 (file)
@@ -121,7 +121,7 @@ struct usb_device *usb_add_device(u8 lowspeed, u32 reg)
                return (void*) -1;
        }
 
-//#define WTF
+#define WTF
 #ifdef WTF
        volatile u8 wzf = 11;
        if(0 == wzf) {
@@ -420,7 +420,8 @@ u16 usb_submit_irp(struct usb_irp *irp)
                /***************** Status Stage ***********************/
                /* Zero packet for end */
                td = usb_create_transfer_descriptor(irp);
-               td->togl = 1;                                                           /* zero data packet = always DATA1 packet */
+               /* zero data packet = always DATA1 packet */
+               td->togl = 1;
                td->actlen = 0;
                td->buffer = NULL;
 
index 98ab7ea3641581a53f191cd7088123f4ee6d4e6e..75eefc34e3e941c17fe91819fb6617501023d052 100644 (file)
@@ -146,7 +146,7 @@ struct usb_driver {
        void (*probe)(void);
        void (*check)(void);
        void (*remove)(void);
-       void *data;
+       struct usb_device *data;
        struct usb_driver *next;
 };
 
index 45ceba2ea51a4175010c4c774c858227717dec12..c98681ba014d4ca1aa379a934693d54a41614421 100644 (file)
@@ -313,8 +313,6 @@ u8 usb_get_configuration(struct usb_device *dev)
 {
        cleargbuf();
        usb_control_msg(dev, 0x80, GET_CONFIGURATION, 0, 0, 4, gbuf, 0);
-       printf("=============\nafter usb_get_configuration:\n");
-       hexdump((void*) gbuf, 8);
        return gbuf[0];
 }
 
@@ -322,8 +320,6 @@ s8 usb_set_configuration(struct usb_device *dev, u8 configuration)
 {
        cleargbuf();
        usb_control_msg(dev, 0x00, SET_CONFIGURATION, configuration, 0, 0, gbuf, 0);
-       printf("=============\nafter usb_set_configuration:\n");
-       hexdump((void*) gbuf, 8);
        wait_ms(20);
        return 0;
 }
diff --git a/usb/drivers/bt.c b/usb/drivers/bt.c
new file mode 100644 (file)
index 0000000..433182f
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+       ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader.
+       bluetooth driver
+
+Copyright (C) 2009     Bernhard Urban <lewurm@gmx.net>
+Copyright (C) 2009     Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
+
+# This code is licensed to you under the terms of the GNU GPL, version 2;
+# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
+*/
+
+#include "../core/core.h"
+#include "../core/usb.h"
+#include "../usbspec/usb11spec.h"
+#include "../../malloc.h"
+#include "../../string.h"
+
+#include "bt.h"
+
+struct usb_driver btdriv = {
+       .name     = "bt",
+       .probe  = usb_bt_probe,
+       .check  = usb_bt_check,
+       .remove = usb_bt_remove,
+       .data     = NULL
+};
+
+u8 epi_it, epi_bk, epo_bk;
+
+
+void usb_bt_init()
+{
+       usb_register_driver(&btdriv);
+
+       usb_set_configuration(btdriv.data, btdriv.data->conf->bConfigurationValue);
+       printf("get_conf: %d\n", usb_get_configuration(btdriv.data));
+
+       u8 buf[8];
+       memset(buf, 0, 8);
+       usb_control_msg(btdriv.data, 0x01, SET_INTERFACE, 0, 1, 0, buf, 0);
+
+       epi_it = btdriv.data->conf->intf->endp->bEndpointAddress & 0x7F;
+       epi_bk = btdriv.data->conf->intf->endp->next->bEndpointAddress & 0x7F;
+       epo_bk = btdriv.data->conf->intf->endp->next->next->bEndpointAddress & 0x7F;
+
+       btdriv.data->epSize[1] = btdriv.data->conf->intf->endp->wMaxPacketSize;
+       btdriv.data->epSize[2] = btdriv.data->conf->intf->endp->next->wMaxPacketSize;
+       btdriv.data->epSize[3] = btdriv.data->conf->intf->endp->next->next->wMaxPacketSize;
+}
+
+void usb_bt_probe()
+{
+       struct usb_device *dev;
+       struct element *iterator = core.devices->head;
+
+       while(iterator != NULL) {
+               dev = (struct usb_device*) iterator->data;
+               if(dev == NULL) {
+                       continue;
+               }
+
+               if(dev->idVendor == 0x057e && dev->idProduct == 0x0305) {
+                       btdriv.data = dev;
+               }
+
+               iterator=iterator->next;
+       }
+}
+
+void usb_bt_check()
+{
+}
+
+u8 usb_bt_inuse()
+{
+       return btdriv.data ? 1 : 0;
+}
+
+void usb_bt_remove()
+{
+       btdriv.data = NULL;
+}
+
diff --git a/usb/drivers/bt.h b/usb/drivers/bt.h
new file mode 100644 (file)
index 0000000..50ef867
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+       ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader.
+       bluetooth driver
+
+Copyright (C) 2009     Bernhard Urban <lewurm@gmx.net>
+Copyright (C) 2009     Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
+
+# This code is licensed to you under the terms of the GNU GPL, version 2;
+# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
+*/
+
+
+#ifndef __BT_H
+#define __BT_H
+
+void usb_bt_init();
+void usb_bt_probe();
+void usb_bt_check();
+u8 usb_bt_inuse();
+void usb_bt_remove();
+
+#endif /* __BT_H */
+
index 933b592073e938dedb1d09c47207563bf762b38d..1204d1bc13608ce1e9408cf7f8bb8b132b7e1961 100644 (file)
@@ -66,7 +66,7 @@ void usb_hidkb_probe()
                if(dev->conf->intf->bInterfaceClass == HID_CLASSCODE &&
                                dev->conf->intf->bInterfaceSubClass == 1 && /* keyboard support boot protocol? */
                                dev->conf->intf->bInterfaceProtocol == 1) { /* keyboard? */
-                       hidkb.data = (void*) dev;
+                       hidkb.data = dev;
                        usb_hidkb_set_idle(dev, 1);
                }