Ejemplo n.º 1
0
int _main(unsigned zero, unsigned type, unsigned tags)
{    
    const char *cmdline = 0;
    int n;
    
    arm11_clock_init();

        /* must do this before board_init() so that we
        ** use the partition table in the tags if it 
        ** already exists 
        */
    if((zero == 0) && (type != 0) && tags_okay(tags)) {
        linux_type = type;
        linux_tags = tags;

        cmdline = tags_get_cmdline((void*) linux_tags);
        
        tags_import_partitions((void*) linux_tags);
        revision = tags_get_revision((void*) linux_tags);
        if(revision == 1) {
            console_set_colors(0x03E0, 0xFFFF);
        }
        if(revision == 2) {
            console_set_colors(0x49B2, 0xFFFF);
        }

            /* we're running as a second-stage, so wait for interrupt */
        boot_from_flash = 0;
    } else {
        linux_type = board_machtype();
        linux_tags = 0;
    }

    board_init();
    keypad_init();
    
    console_init();
    dprintf_set_putc(uart_putc);    

    if(linux_tags == 0) {
            /* generate atags containing partitions 
             * from the bootloader, etc 
             */
        linux_tags = ADDR_TAGS;
        create_atags(linux_tags, 0, 0, 0);
    }
    
    if (cmdline) {
        char *sn = strstr(cmdline, SERIALNO_STR);
        if (sn) {
            char *s = serialno;
            sn += SERIALNO_LEN;
            while (*sn && (*sn != ' ') && ((s - serialno) < 31)) {
                *s++ = *sn++;
            }
            *s++ = 0;
        }
    }

    cprintf("\n\nUSB FastBoot:  V%s\n", get_fastboot_version());
    cprintf("Machine ID:    %d v%d\n", linux_type, revision);
    cprintf("Build Date:    "__DATE__", "__TIME__"\n\n");

    cprintf("Serial Number: %s\n\n", serialno[0] ? serialno : "UNKNOWN");

    flash_dump_ptn();

    flash_init();

        /* scan the keyboard a bit */
    for(n = 0; n < 50; n++) {
        boot_poll();
    }

    if (boot_from_flash) {
        cprintf("\n ** BOOTING LINUX FROM FLASH **\n");
        boot_linux_from_flash();
    }

    usbloader_init();
    
    for(;;) {
        usb_poll();
    }
    return 0;
}
/*
 * USB boot routine
 *
 * Desc: usb boot.
 * Retn: 0 for success, -1 for error.
 */
int usb_boot(unsigned zero, unsigned type, unsigned tags)
{
#ifdef DEBUG
	serial_puts_info("Usb_boot:  In function of usb_boot ...\n");
#endif
	/* see all of files in android-1.5r2/bootable/bootloader/legacy/usbloader */
	unsigned long ram_size;
	unsigned long addr;

	/* must do this before board_init() so that we
        ** use the partition table in the tags if it 
        ** already exists 
        */
	linux_type = board_machtype();
	linux_tags = 0;
#ifdef DEBUG	
	serial_puts_info("Usb_boot:  Board init ...\n");
#endif
	board_init();
	ram_size = initdram(0);
/*test*/
    if (ram_size > EMC_LOW_SDRAM_SPACE_SIZE)
                ram_size = EMC_LOW_SDRAM_SPACE_SIZE;
/*test*/
	addr = CFG_SDRAM_BASE + ram_size;

	/* We can reserve some RAM "on top" here. */
	/* round down to next 4 kB limit. */
	addr &= ~(4096 - 1);
#ifdef DEBUG
	serial_puts_info("Usb_boot:  Lcd_setmem ...\n");
#endif
	addr = lcd_setmem(addr);
	fb_base = addr;
#ifdef DEBUG
	serial_puts_info("Usb_boot:  Drv_lcd_init ...\n");
#endif
	drv_lcd_init();
	lcd_console_init();
	
#if 0
	memset(print_buf, 0, PRINT_BUF_MAX);
	strcpy(print_buf, "123456:USB FastBoot:bbb");
	lcd_puts(print_buf);
	memset(print_buf, 0, PRINT_BUF_MAX);
	cprintf(print_buf, ":ABC%dEFG:a\rabc",3);
	lcd_puts(print_buf);
#endif

#if 1
	memset(print_buf, '\0', PRINT_BUF_MAX);
	cprintf(print_buf, "USB FastBoot:  V %s\n", get_fastboot_version());
	lcd_puts(print_buf);

	memset(print_buf, '\0', PRINT_BUF_MAX);
	cprintf(print_buf, "Machine ID:    %d v %d\n", linux_type, revision);
	lcd_puts(print_buf);
	
	memset(print_buf, '\0', PRINT_BUF_MAX);
	cprintf(print_buf, "Build Date:    "__DATE__", "__TIME__"\n");
	lcd_puts(print_buf);

	memset(print_buf, '\0', PRINT_BUF_MAX);
	cprintf(print_buf, "Serial Number: %s\n", "UNKNOWN");
	lcd_puts(print_buf);
#endif

#if 1
	serial_puts_msg("\nUSB FastBoot: V ");
	serial_puts_msg(get_fastboot_version());
	serial_puts_msg(" \n");

	serial_puts_msg("Machine ID: ");
	dump_uint(linux_type);
	serial_puts_msg("  v ");
	dump_uint(revision);
	serial_puts_msg(" \n");

	serial_puts_msg("Build Date: ");
	serial_puts_msg(__DATE__);
	serial_puts_msg("  ");
	serial_puts_msg(__TIME__);
	serial_puts_msg("\n");
	
	serial_puts_msg("Serial Number: ");
	if (serialno[0])
		serial_puts_msg(serialno);
	else
		serial_puts_msg("UNKNOWN\n");
#endif
	flash_dump_ptn();
	usbloader_init();
	for(;;) {
		usb_poll();
	}
	
	return 0;
}