2 BootMii - a Free Software replacement for the Nintendo/BroadOn bootloader.
5 Copyright (C) 2008, 2009 Haxx Enterprises <bushing@gmail.com>
6 Copyright (C) 2009 Andre Heider "dhewg" <dhewg@wiibrew.org>
7 Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
8 Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com>
9 Copyright (C) 2009 John Kelley <wiidev@kelley.ca>
11 # This code is licensed to you under the terms of the GNU GPL, version 2;
12 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
15 #include "bootmii_ppc.h"
24 #include "video_low.h"
28 #include "usb/core/core.h"
29 #include "usb/drivers/class/hid.h"
30 #include "usb/drivers/bt.h"
32 #include "hollywood.h"
34 #define MINIMUM_MINI_VERSION 0x00010001
39 static void dsp_reset(void)
41 write16(0x0c00500a, read16(0x0c00500a) & ~0x01f8);
42 write16(0x0c00500a, read16(0x0c00500a) | 0x0010);
43 write16(0x0c005036, 0);
46 static char ascii(char s) {
47 if(s < 0x20) return '.';
48 if(s > 0x7E) return '.';
52 void hexdump(void *d, int len) {
56 for (off=0; off<len; off += 16) {
59 if((i+off)>=len) printf(" ");
60 else printf("%02x ",data[off+i]);
64 if((i+off)>=len) printf(" ");
65 else printf("%c",ascii(data[off+i]));
72 printf("reading OTP...\n");
74 printf("read OTP!\n");
76 hexdump(&otp, sizeof(otp));
78 printf("reading SEEPROM...\n");
80 printf("read SEEPROM!\n");
82 hexdump(&seeprom, sizeof(seeprom));
92 irq_bw_enable(BW_PI_IRQ_RESET);
93 irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic
95 irq_hw_enable(IRQ_OHCI0);
97 irq_hw_enable(IRQ_OHCI1);
107 VIDEO_SetFrameBuffer(get_xfb());
110 u32 version = ipc_getvers();
111 u16 mini_version_major = version >> 16 & 0xFFFF;
112 u16 mini_version_minor = version & 0xFFFF;
113 printf("Mini version: %d.%0d\n", mini_version_major, mini_version_minor);
115 if (version < MINIMUM_MINI_VERSION) {
116 printf("Sorry, this version of MINI (armboot.bin)\n"
117 "is too old, please update to at least %d.%0d.\n",
118 (MINIMUM_MINI_VERSION >> 16), (MINIMUM_MINI_VERSION & 0xFFFF));
120 ; // better ideas welcome!
124 usb_init(OHCI0_REG_BASE);
127 usb_init(OHCI1_REG_BASE);
129 /* load HID keyboard driver */
132 /* load BT-USB driver */
136 /* wait for usb keyboard plugged in */
137 if(!usb_hidkb_inuse()) {
138 print_str("plug in an usb keyboard", 23);
140 while(!usb_hidkb_inuse());
142 print_str("hello keyboard :)", 17);
144 #define FONT_WIDTH 13
145 #define FONT_HEIGHT 15
146 #define STDOUT_BORDER_LEFT 20
147 #define STDOUT_BORDER_RIGHT 650
148 #define STDOUT_BORDER_TOP 20
149 #define STDOUT_BORDER_BOTTOM 550
151 /* you are welcome to make this nice :) */
153 u16 i, j, ret=0, y=STDOUT_BORDER_TOP, x=STDOUT_BORDER_LEFT;
155 struct kbrep *k, *old=NULL;
157 while(usb_hidkb_inuse()) {
158 memset(str, '\0', 7);
159 k = usb_hidkb_getChars();
161 old_x = x; /* save actual x and y position for printing after the loop */
163 for(i=0; k->keys[i]>0; i++) {
165 /* dropping char's if necessary */
167 for(j=0; j < 6; j++) {
168 if(old->keys[j] == k->keys[i]) {
180 unsigned char key = usb_hidkb_get_char_from_keycode(k->keys[i],
181 (k->mod & MOD_lshift) || (k->mod & MOD_rshift));
182 /* no key or key not relevant? next, please. */
186 /* RETURN pressed? */
188 x = STDOUT_BORDER_LEFT;
192 } else if (key == '\t') {
193 x += (TABSIZE*FONT_WIDTH);
196 /* BACKSPACE pressed? */
197 } else if (key == '\r') {
200 /* now we have only printable characters left */
207 /* line full? break! */
208 if(x > (STDOUT_BORDER_RIGHT-FONT_WIDTH)) {
209 x = STDOUT_BORDER_LEFT;
212 /* screen full? start again at top */
213 if(y > (STDOUT_BORDER_BOTTOM-FONT_HEIGHT)) {
214 y = STDOUT_BORDER_TOP;
221 if(j > 0) { /* when there was any printable stuff, show it */
222 print_str_noscroll(old_x, old_y, str);
230 printf("===============================\n");
234 printf("bye, world!\n");