[PATCH 2/4] qi-add-steppingstone-section-for-putc.patch
Andy Green
andy at openmoko.com
Thu Oct 30 08:59:58 CET 2008
We need putc even when we are operating entirely from steppingstone.
Arrange that the board-specific putc code is in a section that goes into
steppingstone, and adapt the utils.c putc() so that it no longer needs to
indirect through the board_api struct that is in main memory.
Signed-off-by: Andy Green <andy at openmoko.com>
---
include/qi.h | 2 ++
src/cpu/s3c2442/gta02.c | 2 +-
src/cpu/s3c2442/qi.lds | 16 ++++++++++------
src/cpu/s3c2442/start_qi.c | 1 +
src/cpu/s3c6410/gta03.c | 2 +-
src/cpu/s3c6410/qi.lds | 16 +++++++++-------
src/cpu/s3c6410/start_qi.c | 3 ++-
src/utils.c | 26 +++++++++++++++-----------
8 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/include/qi.h b/include/qi.h
index b9970a4..90d16cf 100644
--- a/include/qi.h
+++ b/include/qi.h
@@ -108,5 +108,7 @@ int nand_read_ll(unsigned char *buf, unsigned long start512, int blocks512);
extern void memory_test(void * start, unsigned int length);
+void set_putc_func(void (*p)(char));
+
#endif
diff --git a/src/cpu/s3c2442/gta02.c b/src/cpu/s3c2442/gta02.c
index 3f33957..23acefa 100644
--- a/src/cpu/s3c2442/gta02.c
+++ b/src/cpu/s3c2442/gta02.c
@@ -341,7 +341,7 @@ const struct board_variant const * get_board_variant_gta02(void)
return &board_variants[gta02_get_pcb_revision() & 1];
}
-static void putc_gta02(char c)
+static __attribute__ (( section (".steppingstone") )) void putc_gta02(char c)
{
serial_putc_s3c24xx(GTA02_DEBUG_UART, c);
}
diff --git a/src/cpu/s3c2442/qi.lds b/src/cpu/s3c2442/qi.lds
index 09da8bb..c23b447 100644
--- a/src/cpu/s3c2442/qi.lds
+++ b/src/cpu/s3c2442/qi.lds
@@ -37,12 +37,16 @@ SECTIONS
. = ALIGN(4);
.text :
{
- src/cpu/s3c2442/start.o (.text .rodata* .data)
- src/cpu/s3c2442/lowlevel_init.o (.text .rodata* .data)
- src/cpu/s3c2442/start_qi.o (.text .rodata* .data)
- src/blink_led.o (.text .rodata* .data)
- src/cpu/s3c2442/nand_read.o (.text .rodata* .data)
- src/cpu/s3c2442/serial-s3c24xx.o (.text .rodata* .data)
+ src/cpu/s3c2442/start.o (.text .rodata* .data .bss)
+ src/cpu/s3c2442/lowlevel_init.o (.text .rodata* .data .bss)
+ src/cpu/s3c2442/start_qi.o (.text .rodata* .data .bss)
+/* src/blink_led.o (.text .rodata* .data .bss) */
+ src/cpu/s3c2442/nand_read.o (.text .rodata* .data .bss)
+ src/cpu/s3c2442/serial-s3c24xx.o (.text .rodata* .data .bss)
+ src/memory-test.o (.text .rodata* .data .bss)
+ src/utils.o (.text .rodata* .data .bss)
+ src/ctype.o (.text .rodata* .data .bss)
+ * (.steppingstone)
}
. = ALIGN(4);
diff --git a/src/cpu/s3c2442/start_qi.c b/src/cpu/s3c2442/start_qi.c
index 38a95ba..8364a2d 100644
--- a/src/cpu/s3c2442/start_qi.c
+++ b/src/cpu/s3c2442/start_qi.c
@@ -98,6 +98,7 @@ void start_qi(void)
}
this_board->port_init();
+ set_putc_func(this_board->putc);
/* stick some hello messages on debug console */
diff --git a/src/cpu/s3c6410/gta03.c b/src/cpu/s3c6410/gta03.c
index a6766d8..e925740 100644
--- a/src/cpu/s3c6410/gta03.c
+++ b/src/cpu/s3c6410/gta03.c
@@ -166,7 +166,7 @@ int is_this_board_gta03(void)
return 1;
}
-static void putc_gta03(char c)
+static __attribute__ (( section (".steppingstone") )) void putc_gta03(char c)
{
serial_putc_s3c64xx(GTA03_DEBUG_UART, c);
}
diff --git a/src/cpu/s3c6410/qi.lds b/src/cpu/s3c6410/qi.lds
index d148c86..7a89334 100644
--- a/src/cpu/s3c6410/qi.lds
+++ b/src/cpu/s3c6410/qi.lds
@@ -42,13 +42,15 @@ SECTIONS
__steppingstone :
AT (0)
{
- src/cpu/s3c6410/start.o (.text .rodata* .data)
- src/cpu/s3c6410/start_qi.o (.text .rodata* .data)
- src/cpu/s3c6410/serial-s3c64xx.o (.text .rodata* .data)
- src/cpu/s3c6410/gta03.o (.text .rodata* .data)
- src/cpu/s3c6410/hs_mmc.o (.text .rodata* .data)
- src/utils.o (.text .rodata* .data)
- src/ctype.o (.text .rodata* .data)
+ src/cpu/s3c6410/start.o (.text .rodata* .data .bss)
+ src/cpu/s3c6410/start_qi.o (.text .rodata* .data .bss)
+ src/cpu/s3c6410/serial-s3c64xx.o (.text .rodata* .data .bss)
+ src/cpu/s3c6410/gta03.o (.text .rodata* .data .bss)
+ src/cpu/s3c6410/hs_mmc.o (.text .rodata* .data .bss)
+ src/utils.o (.text .rodata* .data .bss)
+ src/memory-test.o (.text .rodata* .data .bss)
+ src/ctype.o (.text .rodata* .data .bss)
+ * (.steppingstone)
}
. = ALIGN(4);
diff --git a/src/cpu/s3c6410/start_qi.c b/src/cpu/s3c6410/start_qi.c
index a12a512..ac94b66 100644
--- a/src/cpu/s3c6410/start_qi.c
+++ b/src/cpu/s3c6410/start_qi.c
@@ -79,6 +79,7 @@ void start_qi(void)
/* okay, do the critical port and serial init for our board */
this_board->port_init();
+ set_putc_func(this_board->putc);
/* stick some hello messages on debug console */
@@ -97,7 +98,7 @@ void start_qi(void)
if (!is_jtag) {
/*
- * We got the first 4KBytes of the bootloader pulled into the
+ * We got the first 8KBytes of the bootloader pulled into the
* steppingstone SRAM for free. Now we pull the whole bootloader
* image into SDRAM.
*
diff --git a/src/utils.c b/src/utils.c
index ffca1f5..fc1e668 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -23,10 +23,14 @@
#include <qi.h>
#include <string.h>
-static u8 malloc_pool[100 * 1024];
-void * malloc_pointer = &malloc_pool[0];
+static void (*putc_func)(char) = NULL;
+void set_putc_func(void (*p)(char))
+{
+ putc_func = p;
+}
+
size_t strlen(const char *s)
{
size_t n = 0;
@@ -88,7 +92,7 @@ char *strchr(const char *s, int c)
int puts(const char *string)
{
while (*string)
- this_board->putc(*string++);
+ (putc_func)(*string++);
return 1;
}
@@ -97,9 +101,9 @@ int puts(const char *string)
void printnybble(unsigned char n)
{
if (n < 10)
- this_board->putc('0' + n);
+ (putc_func)('0' + n);
else
- this_board->putc('a' + n - 10);
+ (putc_func)('a' + n - 10);
}
void print8(unsigned char n)
@@ -122,13 +126,13 @@ void hexdump(unsigned char *start, int len)
while (len > 0) {
print32((int)start);
- this_board->putc(':');
- this_board->putc(' ');
+ (putc_func)(':');
+ (putc_func)(' ');
for (n = 0; n < 16; n++) {
print8(*start++);
- this_board->putc(' ');
+ (putc_func)(' ');
}
- this_board->putc('\n');
+ (putc_func)('\n');
len -= 16;
}
}
@@ -152,7 +156,7 @@ void printdec(int n)
int div = 0;
if (n < 0) {
- this_board->putc('-');
+ (putc_func)('-');
n = -n;
}
@@ -163,7 +167,7 @@ void printdec(int n)
n -= d[div];
}
if (r || flag || (d[div] == 1)) {
- this_board->putc('0' + r);
+ (putc_func)('0' + r);
flag = 1;
}
div++;
More information about the openmoko-kernel
mailing list