X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=main.c;h=d1c895faf19755ff5622f384fc97b375852fdc2d;hb=refs%2Fheads%2Fbt;hp=c75712b16c569ba6bec2987d87471b307f0d8e94;hpb=d07b8474abba58f2f6894b6f04b9375abce02375;p=ppcskel.git diff --git a/main.c b/main.c index c75712b..d1c895f 100644 --- a/main.c +++ b/main.c @@ -24,7 +24,12 @@ Copyright (C) 2009 John Kelley #include "video_low.h" #include "input.h" #include "console.h" -#include "ohci.h" +#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" #define MINIMUM_MINI_VERSION 0x00010001 @@ -83,8 +88,13 @@ int main(void) exception_init(); dsp_reset(); - // clear interrupt mask - write32(0x0c003004, 0); + irq_initialize(); + irq_bw_enable(BW_PI_IRQ_RESET); + irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic + /* external ohci */ + irq_hw_enable(IRQ_OHCI0); + /* internal ohci */ + irq_hw_enable(IRQ_OHCI1); ipc_initialize(); ipc_slowping(); @@ -92,7 +102,6 @@ int main(void) gecko_init(); input_init(); init_fb(vmode); - ohci_init(); VIDEO_Init(vmode); VIDEO_SetFrameBuffer(get_xfb()); @@ -111,31 +120,119 @@ int main(void) ; // better ideas welcome! } - print_str_noscroll(112, 112, "ohai, world!\n"); + /* external ohci */ + usb_init(OHCI0_REG_BASE); - testOTP(); + /* internal ohci */ + usb_init(OHCI1_REG_BASE); - printf("bye, world!\n"); + /* load HID keyboard driver */ + usb_hidkb_init(); + + /* load BT-USB driver */ + usb_bt_init(); - // enable OHCI0 interrupt on hollywood-pic -#define HW_PPCIRQFLAG (0x0d800030) -#define HW_PPCIRQMASK (0x0d800034) - write32(HW_PPCIRQFLAG, ~0); - write32(HW_PPCIRQMASK, 1<<5); - // enable RESET and PIC (#14) interrupts on processor interface - write32(0x0c003004, (1<<1) | (1<<14)); -#define _CPU_ISR_Enable() \ - { register u32 _val = 0; \ - __asm__ __volatile__ ( \ - "mfmsr %0\n" \ - "ori %0,%0,0x8000\n" \ - "mtmsr %0" \ - : "=&r" ((_val)) : "0" ((_val)) \ - ); \ +wait_kb: + /* wait for usb keyboard plugged in */ + if(!usb_hidkb_inuse()) { + print_str("plug in an usb keyboard", 23); } - _CPU_ISR_Enable() + while(!usb_hidkb_inuse()); + + print_str("hello keyboard :)", 17); + +#define FONT_WIDTH 13 +#define FONT_HEIGHT 15 +#define STDOUT_BORDER_LEFT 20 +#define STDOUT_BORDER_RIGHT 650 +#define STDOUT_BORDER_TOP 20 +#define STDOUT_BORDER_BOTTOM 550 +#define TABSIZE 4 + /* you are welcome to make this nice :) */ + char str[7]; + u16 i, j, ret=0, y=STDOUT_BORDER_TOP, x=STDOUT_BORDER_LEFT; + u16 old_x, old_y; + struct kbrep *k, *old=NULL; + + while(usb_hidkb_inuse()) { + memset(str, '\0', 7); + k = usb_hidkb_getChars(); + j=0; + old_x = x; /* save actual x and y position for printing after the loop */ + old_y = y; + for(i=0; k->keys[i]>0; i++) { + + /* dropping char's if necessary */ + if(old) { + for(j=0; j < 6; j++) { + if(old->keys[j] == k->keys[i]) { + ret = 1; + break; + } + } + } + if(ret) { + ret = 0; + continue; + } + j = 0; + + unsigned char key = usb_hidkb_get_char_from_keycode(k->keys[i], + (k->mod & MOD_lshift) || (k->mod & MOD_rshift)); + /* no key or key not relevant? next, please. */ + if (key == 0) + continue; + + /* RETURN pressed? */ + if (key == '\n') { + x = STDOUT_BORDER_LEFT; + y += FONT_HEIGHT; + printf("\n"); + /* TAB pressed? */ + } else if (key == '\t') { + x += (TABSIZE*FONT_WIDTH); + printf("\t"); + + /* BACKSPACE pressed? */ + } else if (key == '\r') { + /* TODO */ + + /* now we have only printable characters left */ + } else { + x += FONT_WIDTH; + str[j] = key; + j++; + } + + /* line full? break! */ + if(x > (STDOUT_BORDER_RIGHT-FONT_WIDTH)) { + x = STDOUT_BORDER_LEFT; + y += FONT_HEIGHT; + } + /* screen full? start again at top */ + if(y > (STDOUT_BORDER_BOTTOM-FONT_HEIGHT)) { + y = STDOUT_BORDER_TOP; + } + } + if(old) { + free(old); + } + old = k; + if(j > 0) { /* when there was any printable stuff, show it */ + print_str_noscroll(old_x, old_y, str); + printf("%s", str); + } + } + + goto wait_kb; - while(1) {} +#if 0 + printf("===============================\n"); + + SHA1TestCases(); + + printf("bye, world!\n"); +#endif return 0; }