From: Bernhard Urban Date: Tue, 29 Sep 2009 10:20:29 +0000 (+0200) Subject: preps for marcans bt hax X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=ppcskel.git;a=commitdiff_plain;h=cd7b54f43059cd737e3482d19951edb6c326d171 preps for marcans bt hax --- diff --git a/main.c b/main.c index 67d6d88..d1c895f 100644 --- a/main.c +++ b/main.c @@ -27,6 +27,7 @@ Copyright (C) 2009 John Kelley #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()) { diff --git a/usb/Makefile b/usb/Makefile index 8dee0bc..efdf445 100644 --- a/usb/Makefile +++ b/usb/Makefile @@ -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 diff --git a/usb/core/core.c b/usb/core/core.c index a6c84fb..4ab945c 100644 --- a/usb/core/core.c +++ b/usb/core/core.c @@ -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; diff --git a/usb/core/core.h b/usb/core/core.h index 98ab7ea..75eefc3 100644 --- a/usb/core/core.h +++ b/usb/core/core.h @@ -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; }; diff --git a/usb/core/usb.c b/usb/core/usb.c index 45ceba2..c98681b 100644 --- a/usb/core/usb.c +++ b/usb/core/usb.c @@ -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 index 0000000..433182f --- /dev/null +++ b/usb/drivers/bt.c @@ -0,0 +1,83 @@ +/* + ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader. + bluetooth driver + +Copyright (C) 2009 Bernhard Urban +Copyright (C) 2009 Sebastian Falbesoner + +# 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 index 0000000..50ef867 --- /dev/null +++ b/usb/drivers/bt.h @@ -0,0 +1,23 @@ +/* + ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader. + bluetooth driver + +Copyright (C) 2009 Bernhard Urban +Copyright (C) 2009 Sebastian Falbesoner + +# 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 */ + diff --git a/usb/drivers/class/hid.c b/usb/drivers/class/hid.c index 933b592..1204d1b 100644 --- a/usb/drivers/class/hid.c +++ b/usb/drivers/class/hid.c @@ -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); }