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"
31 #include "hollywood.h"
33 #define MINIMUM_MINI_VERSION 0x00010001
38 static void dsp_reset(void)
40 write16(0x0c00500a, read16(0x0c00500a) & ~0x01f8);
41 write16(0x0c00500a, read16(0x0c00500a) | 0x0010);
42 write16(0x0c005036, 0);
45 static char ascii(char s) {
46 if(s < 0x20) return '.';
47 if(s > 0x7E) return '.';
51 void hexdump(void *d, int len) {
55 for (off=0; off<len; off += 16) {
58 if((i+off)>=len) printf(" ");
59 else printf("%02x ",data[off+i]);
63 if((i+off)>=len) printf(" ");
64 else printf("%c",ascii(data[off+i]));
71 printf("reading OTP...\n");
73 printf("read OTP!\n");
75 hexdump(&otp, sizeof(otp));
77 printf("reading SEEPROM...\n");
79 printf("read SEEPROM!\n");
81 hexdump(&seeprom, sizeof(seeprom));
91 irq_bw_enable(BW_PI_IRQ_RESET);
92 irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic
94 irq_hw_enable(IRQ_OHCI0);
96 //irq_hw_enable(IRQ_OHCI1);
106 VIDEO_SetFrameBuffer(get_xfb());
109 u32 version = ipc_getvers();
110 u16 mini_version_major = version >> 16 & 0xFFFF;
111 u16 mini_version_minor = version & 0xFFFF;
112 printf("Mini version: %d.%0d\n", mini_version_major, mini_version_minor);
114 if (version < MINIMUM_MINI_VERSION) {
115 printf("Sorry, this version of MINI (armboot.bin)\n"
116 "is too old, please update to at least %d.%0d.\n",
117 (MINIMUM_MINI_VERSION >> 16), (MINIMUM_MINI_VERSION & 0xFFFF));
119 ; // better ideas welcome!
123 usb_init(OHCI0_REG_BASE);
126 usb_init(OHCI1_REG_BASE);
128 /* load HID keyboard driver */
131 /* wait for usb keyboard plugged in */
132 if(!usb_hidkb_inuse()) {
133 print_str("plug in an usb keyboard", 23);
135 while(!usb_hidkb_inuse());
137 #define FONT_WIDTH 13
138 #define FONT_HEIGHT 15
139 #define STDOUT_BORDER_LEFT 20
140 #define STDOUT_BORDER_RIGHT 650
141 #define STDOUT_BORDER_TOP 20
142 #define STDOUT_BORDER_BOTTOM 550
144 /* you are welcome to make this nice :) */
146 u16 i, j, y=STDOUT_BORDER_TOP, x=STDOUT_BORDER_LEFT;
151 memset(str, '\0', 7);
153 k = usb_hidkb_getChars();
154 old_x = x; /* save actual x and y position for printing after the loop */
156 for(i=0; k->keys[i]>0; i++) {
157 unsigned char key = usb_hidkb_get_char_from_keycode(k->keys[i],
158 (k->mod & MOD_lshift) || (k->mod & MOD_rshift));
159 /* no key or key not relevant? next, please. */
163 /* RETURN pressed? */
165 x = STDOUT_BORDER_LEFT;
168 } else if (key == '\t') {
169 x += (TABSIZE*FONT_WIDTH);
171 /* BACKSPACE pressed? */
172 } else if (key == '\r') {
175 /* now we have only printable characters left */
182 /* line full? break! */
183 if(x > (STDOUT_BORDER_RIGHT-FONT_WIDTH)) {
184 x = STDOUT_BORDER_LEFT;
187 /* screen full? start again at top */
188 if(y > (STDOUT_BORDER_BOTTOM-FONT_HEIGHT)) {
189 y = STDOUT_BORDER_TOP;
192 if(j > 0) { /* when there was any printable stuff, show it */
193 print_str_noscroll(old_x, old_y, str);
194 printf("y: %d\n", y);
200 printf("===============================\n");
204 printf("bye, world!\n");