mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2025-04-21 12:27:27 +03:00
add-kernel-init.patch
Huge patch boils down massive kernel image parsing and boot action to a modest sequence of code that actually boots the kernel. Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
@@ -27,7 +27,7 @@ int delay(int time)
|
||||
for(i=0;i<time;i++);
|
||||
return 0;
|
||||
}
|
||||
int set_GPB()
|
||||
int set_GPB(void)
|
||||
{
|
||||
GPBCON = 0x5;
|
||||
GPBDW = 0xffff;
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
|
||||
int orange_on(int times);
|
||||
int blue_on(int times);
|
||||
int blink_led();
|
||||
int blink_led(void);
|
||||
|
||||
#endif /* __BLINK_LED_H */
|
||||
|
||||
@@ -32,17 +32,16 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
.text :
|
||||
{
|
||||
src/start.o (.text)
|
||||
src/lowlevel_init.o(.text)
|
||||
src/start_kboot.o (.text .rodata)
|
||||
*(.text .rodata)
|
||||
src/start.o (.text .rodata* .data)
|
||||
src/lowlevel_init.o(.text .rodata* .data)
|
||||
src/start_kboot.o (.text .rodata* .data)
|
||||
src/serial.o (.text .rodata* .data)
|
||||
src/blink_led.o (.text .rodata* .data)
|
||||
* (.rodata* .data)
|
||||
}
|
||||
|
||||
. = ALIGN(4);
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
}
|
||||
.everything_else : { *(.text) }
|
||||
|
||||
. = ALIGN(4);
|
||||
.got :
|
||||
@@ -50,7 +49,7 @@ SECTIONS
|
||||
*(.got)
|
||||
}
|
||||
|
||||
. = ALIGN(4);
|
||||
. = 0x32000000 ;
|
||||
__bss_start = .;
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ int vsprintf(char *buf, const char *fmt, va_list args);
|
||||
int puts(const char *string);
|
||||
void printhex(unsigned char v);
|
||||
void print32(unsigned int u);
|
||||
void hexdump(unsigned char *start, int len);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long addr)
|
||||
{
|
||||
unsigned short *ptr16 = (unsigned short *)buf;
|
||||
unsigned int i, page_num;
|
||||
unsigned char ecc[64];
|
||||
unsigned short *p16 = (unsigned short *)ecc;
|
||||
|
||||
nand_clear_RnB();
|
||||
|
||||
@@ -104,9 +106,11 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long addr)
|
||||
NFCMD = NAND_CMD_READSTART;
|
||||
nand_wait();
|
||||
|
||||
for (i = 0; i < NAND_PAGE_SIZE/2; i++) {
|
||||
*ptr16 = NFDATA16;
|
||||
ptr16++;
|
||||
for (i = 0; i < NAND_PAGE_SIZE/2; i++)
|
||||
*ptr16++ = NFDATA16;
|
||||
|
||||
for (i = 0; i < 64 / 2; i++) {
|
||||
*p16++ = NFDATA16;
|
||||
}
|
||||
|
||||
return NAND_PAGE_SIZE;
|
||||
@@ -129,26 +133,20 @@ int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)
|
||||
;
|
||||
|
||||
for (i = start_addr; i < (start_addr + size);) {
|
||||
#ifdef DEBUG
|
||||
serial_putc(2, 'i');
|
||||
serial_putc(2, '0');
|
||||
serial_putc(2, 'x');
|
||||
print32((unsigned int)i);
|
||||
serial_putc(2, ' ');
|
||||
#endif
|
||||
if (i % NAND_BLOCK_SIZE == 0) {
|
||||
if ((i & (NAND_BLOCK_SIZE - 1)) == 0) {
|
||||
if (is_bad_block(i) ||
|
||||
is_bad_block(i + NAND_PAGE_SIZE)) {
|
||||
#ifdef DEBUG
|
||||
serial_putc(2, '?');
|
||||
#endif
|
||||
serial_putc(2, '!');
|
||||
serial_putc(2, '0');
|
||||
serial_putc(2, 'x');
|
||||
print32((unsigned int)i);
|
||||
serial_putc(2, ' ');
|
||||
|
||||
i += NAND_BLOCK_SIZE;
|
||||
size += NAND_BLOCK_SIZE;
|
||||
if (bad_count++ == 4) {
|
||||
#ifdef DEBUG
|
||||
serial_putc(2, '+');
|
||||
serial_putc(2, '\n');
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
serial_putc(2, '\n');
|
||||
@@ -157,18 +155,8 @@ int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)
|
||||
}
|
||||
|
||||
j = nand_read_page_ll(buf, i);
|
||||
#ifdef DEBUG
|
||||
serial_putc(2, 'j');
|
||||
serial_putc(2, '0');
|
||||
serial_putc(2, 'x');
|
||||
print32((unsigned int)j);
|
||||
serial_putc(2, ' ');
|
||||
#endif
|
||||
i += j;
|
||||
buf += j;
|
||||
#if DEBUG
|
||||
serial_putc(2, '\n');
|
||||
#endif
|
||||
}
|
||||
|
||||
/* chip Disable */
|
||||
|
||||
@@ -109,6 +109,23 @@ void print32(unsigned int u)
|
||||
printhex(u);
|
||||
}
|
||||
|
||||
void hexdump(unsigned char *start, int len)
|
||||
{
|
||||
int n;
|
||||
|
||||
while (len > 0) {
|
||||
print32((int)start);
|
||||
serial_putc(DEBUG_CONSOLE_UART, ':');
|
||||
serial_putc(DEBUG_CONSOLE_UART, ' ');
|
||||
for (n = 0; n < 16; n++) {
|
||||
printhex(*start++);
|
||||
serial_putc(DEBUG_CONSOLE_UART, ' ');
|
||||
}
|
||||
serial_putc(DEBUG_CONSOLE_UART, '\n');
|
||||
len -= 16;
|
||||
}
|
||||
}
|
||||
|
||||
int printk(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -35,7 +35,8 @@ extern void bootloader_second_phase(void);
|
||||
|
||||
void start_kboot(void)
|
||||
{
|
||||
void (*phase2)(void) = bootloader_second_phase + TEXT_BASE;
|
||||
void (*phase2)(void) = (void (*)(void))((int)bootloader_second_phase +
|
||||
TEXT_BASE);
|
||||
|
||||
port_init();
|
||||
serial_init(0x11, UART2);
|
||||
@@ -43,18 +44,15 @@ void start_kboot(void)
|
||||
puts("Openmoko KBOOT "stringify2(BUILD_HOST)" "
|
||||
stringify2(BUILD_VERSION)" "
|
||||
stringify2(BUILD_DATE)"\n");
|
||||
|
||||
/*
|
||||
* pull the whole U-Boot image into SDRAM
|
||||
* pull the whole bootloader image into SDRAM
|
||||
*/
|
||||
|
||||
if (nand_read_ll((unsigned char *)TEXT_BASE, 0, 256 * 1024) < 0)
|
||||
if (nand_read_ll((unsigned char *)TEXT_BASE, 0, 24 * 1024) < 0)
|
||||
while(1)
|
||||
blink_led();
|
||||
|
||||
/*
|
||||
* jump to bootloader_second_phase() running from DRAM copy
|
||||
*/
|
||||
|
||||
(phase2)();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user