Replace references to extern console_buffer with a function call
PATCH 1/1 Replace references to extern console_buffer with a function call
--- board/amcc/canyonlands/bootstrap.c | 2 +- board/amcc/katmai/cmd_katmai.c | 2 +- board/amcc/sequoia/cmd_sequoia.c | 2 +- board/amcc/yucca/cmd_yucca.c | 2 +- board/eltec/bab7xx/misc.c | 2 +- board/eltec/elppc/misc.c | 2 +- board/eltec/mhpc/mhpc.c | 4 +--- board/hymod/input.c | 7 ++++--- common/cmd_bedbug.c | 3 ++- common/cmd_dcr.c | 2 +- common/cmd_i2c.c | 2 +- common/cmd_mem.c | 2 +- common/cmd_nvedit.c | 2 +- common/cmd_pci.c | 2 +- common/console.c | 7 +++++++ common/hush.c | 2 +- common/main.c | 8 +++----- include/common.h | 1 + lib_arm/board.c | 2 +- lib_ppc/board.c | 2 +- 20 files changed, 32 insertions(+), 26 deletions(-)
board/amcc/canyonlands/bootstrap.c +1 -1
@@ -84,7 +84,7 @@ static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) {u8 *buf, b_nand;int x, y, nbytes, selcfg; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();if (argc <2 ) {printf ("Usage:\n%s\n" , cmdtp->usage);
board/amcc/katmai/cmd_katmai.c +1 -1
@@ -35,7 +35,7 @@ static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])uchar chip;ulong data;int nbytes; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();char sysClock[4 ];char cpuClock[4 ];
board/amcc/sequoia/cmd_sequoia.c +1 -1
@@ -125,7 +125,7 @@ static int do_bootstrap(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) {u8 *buf, bNAND;int x, y, nbytes, selcfg; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();if (argc <2 ) {printf ("Usage:\n%s\n" , cmdtp->usage);
board/amcc/yucca/cmd_yucca.c +1 -1
@@ -53,7 +53,7 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,uchar chip;ulong data;int nbytes; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();char sysClock[4 ];char cpuClock[4 ];
board/eltec/bab7xx/misc.c +1 -1
@@ -31,7 +31,6 @@#include "srom.h" /* imports */ -extern char console_buffer[CFG_CBSIZE ];extern int l2_cache_enable (int l2control);extern void *nvram_read (void *dest,const short src,size_t count);extern void nvram_write (short dest,const void *src,size_t count);
@@ -63,6 +62,7 @@ int misc_init_r (void)char buf[256 ];char hex[23 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,10 ,11 ,12 ,13 ,14 ,15 }; +char *console_buffer =console_buffer_addr ();pci_dev_t bdf;char sromSYM[] = {
board/eltec/elppc/misc.c +1 -1
@@ -29,7 +29,6 @@#include "srom.h" /* imports */ -extern char console_buffer[CFG_CBSIZE ];extern int l2_cache_enable (int l2control);extern int eepro100_write_eeprom (struct eth_device *dev,int location,int addr_len,unsigned short data);
@@ -74,6 +73,7 @@ int misc_init_r (void)char hex[23 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,10 ,11 ,12 ,13 ,14 ,15 }; +char *console_buffer =console_buffer_addr ();/* Clock setting for MPC107 i2c */ mpc107_i2c_init (MPC107_EUMB_ADDR ,0x2b );
board/eltec/mhpc/mhpc.c +1 -3
@@ -35,9 +35,6 @@#include "mpc8xx.h" #include <video_fb.h> -/* imports from common/main.c */ -extern char console_buffer[CFG_CBSIZE ]; -extern void eeprom_init (void );extern int eeprom_read (unsigned dev_addr,unsigned offset,unsigned char *buffer,unsigned cnt);
@@ -157,6 +154,7 @@ int misc_init_r (void)char hex[23 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,10 ,11 ,12 ,13 ,14 ,15 }; +char *console_buffer =console_buffer_addr ();int i;/* check revision data */
board/hymod/input.c +4 -3
@@ -23,12 +23,11 @@#include <common.h> -/* imports from common/main.c */ -extern char console_buffer[CFG_CBSIZE ]; -int hymod_get_serno (const char *prompt) { +char *console_buffer =console_buffer_addr (); +for (;;) {int n, serno;char *p;
@@ -58,6 +57,8 @@ hymod_get_serno (const char *prompt)int hymod_get_ethaddr (void ) { +char *console_buffer =console_buffer_addr (); +for (;;) {int n;
common/cmd_bedbug.c +2 -1
@@ -19,7 +19,6 @@ DECLARE_GLOBAL_DATA_PTR; extern void show_regs __P ((struct pt_regs *)); extern int run_command __P ((const char *, int)); -extern char console_buffer[];ulong dis_last_addr =0 ;/* Last address disassembled */ ulong dis_last_len =20 ;/* Default disassembler length */
@@ -125,6 +124,7 @@ int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])unsigned long instr;/* Machine code for text */ char prompt[15 ];/* Prompt string for user input */ int asm_err;/* Error code from the assembler */ +char *console_buffer =console_buffer_addr ();/* -------------------------------------------------- */ int rcode =0 ;
@@ -219,6 +219,7 @@ void bedbug_main_loop (unsigned long addr, struct pt_regs *regs)int rc =0 ;/* Result from run_command */ char prompt_str[20 ];/* Prompt string */ static char lastcommand[CFG_CBSIZE ] = {0 };/* previous command */ +char *console_buffer =console_buffer_addr ();/* -------------------------------------------------- */ if (bug_ctx.clear)
common/cmd_dcr.c +1 -1
@@ -70,7 +70,7 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])/* DCR's value */ int nbytes; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();/* Validate arguments */ if (argc <2 ) {
common/cmd_i2c.c +1 -1
@@ -418,7 +418,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])int size =1 ;int nbytes;int j; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();if (argc !=3 ) {printf ("Usage:\n%s\n" , cmdtp->usage);
common/cmd_mem.c +1 -1
@@ -1012,7 +1012,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) {ulong addr, i;int nbytes, size; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();if (argc !=2 ) {printf ("Usage:\n%s\n" , cmdtp->usage);
common/cmd_nvedit.c +1 -1
@@ -416,7 +416,7 @@ int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_CMD_ASKENV )int do_askenv (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -extern char console_buffer[CFG_CBSIZE ]; +char *console_buffer =console_buffer_addr ();char message[CFG_CBSIZE ];int size =CFG_CBSIZE -1 ;int len;
common/cmd_pci.c +1 -1
@@ -405,7 +405,7 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag {ulong i;int nbytes; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();uint val4;ushort val2;u_char val1;
common/console.c +7 -0
@@ -33,6 +33,8 @@ DECLARE_GLOBAL_DATA_PTR;int console_changed =0 ;#endif +static char console_buffer[CFG_CBSIZE ];/* console I/O buffer */ +#ifdef CFG_CONSOLE_IS_IN_ENV /* * if overwrite_console returns 1, the stdin, stderr and stdout
@@ -286,6 +288,11 @@ void clear_ctrlc (void) ctrlc_was_pressed =0 ; } +char *console_buffer_addr (void ) +{ +return console_buffer; +} +#ifdef CONFIG_MODEM_SUPPORT_DEBUG char screen[1024 ];char *cursor = screen;
common/hush.c +1 -1
@@ -1019,7 +1019,7 @@ static void get_user_input(struct in_str *i)fflush (stdout); i->p = the_command;#else -extern char console_buffer[CFG_CBSIZE ]; +char *console_buffer =console_buffer_addr ();int n;static char the_command[CFG_CBSIZE ];
common/main.c +3 -5
@@ -65,8 +65,6 @@ static int abortboot(int);#undef DEBUG_PARSER -char console_buffer[CFG_CBSIZE ];/* console I/O buffer */ -static char *delete_char (char *buffer,char *p,int *colp,int *np,int plen);static char erase_seq[] ="\b \b" ;/* erase sequence */ static char tab_seq[] =" " ;/* used to expand TABs */
@@ -445,7 +443,7 @@ void main_loop (void) flag =0 ;/* assume no special flags for now */ if (len >0 ) -strcpy (lastcommand, console_buffer); +strcpy (lastcommand,console_buffer_addr ());else if (len ==0 ) flag |=CMD_FLAG_REPEAT ;#ifdef CONFIG_BOOT_RETRY_TIME
@@ -928,7 +926,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len)*/ int readline (const char *const prompt) { -return readline_into_buffer (prompt, console_buffer); +return readline_into_buffer (prompt,console_buffer_addr ()); }
@@ -1036,7 +1034,7 @@ int readline_into_buffer (const char *const prompt, char * buffer)#ifdef CONFIG_AUTO_COMPLETE /* if auto completion triggered just continue */ *p ='\0' ; -if (cmd_auto_complete (prompt, console_buffer, &n, &col)) { +if (cmd_auto_complete (prompt,console_buffer_addr (), &n, &col)) { p = p_buf + n;/* reset */ continue ; }
include/common.h +1 -0
@@ -628,6 +628,7 @@ int ctrlc (void);int had_ctrlc (void );/* have we had a Control-C since last clear? */ void clear_ctrlc (void );/* clear the Control-C condition */ int disable_ctrlc (int );/* 1 to disable, 0 to enable Control-C detect */ +char *console_buffer_addr (void );/* * STDIO based functions (can always be used)
lib_arm/board.c +1 -1
@@ -506,7 +506,7 @@ int mdm_init (void)char env_str[16 ];char *init_str;int i; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();extern void enable_putc (void );extern int hwflow_onoff (int );
lib_ppc/board.c +1 -1
@@ -1238,7 +1238,7 @@ int mdm_init (void)char env_str[16 ];char *init_str;int i; -extern char console_buffer[]; +char *console_buffer =console_buffer_addr ();extern void enable_putc (void );extern int hwflow_onoff (int );
Signature · 1 line
1.5.4.3
PATCH 1/1 Replace references to extern console_buffer with a function call
Dear Peter Tyser,
what is the purpose of this patch? As far as I can see we gain nothing, but we lose on memory footpint. I guess there is some problem you're trying to fix, but you did not mention it?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The use of COBOL cripples the mind; its teaching should, therefore,
be regarded as a criminal offence.
-- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5PATCH 1/1 Replace references to extern console_buffer with a function call
Quoted 3 lines
what is the purpose of this patch? As far as I can see we gain nothing, but we lose on memory footpint. I guess there is some problem you're trying to fix, but you did not mention it?
I've added a basic "debug serial console" which relies on this patch. The debug console is a simple command prompt which allows the user to issue commands before relocating to SDRAM. We've found this feature very useful for operations such as initially programming SPD data, debugging hardware issues (SDRAM/I2C). I'll submit the debug console patches shortly.
I'm not sure if the debug console will be accepted to mainline, but I think this patch alone is an improvement over the current implementation of using a global string and multiple external console_buffer references. I've always thought global variables should be avoided if there is a reasonable alternative
Best,
Peter
PATCH 1/1 Replace references to extern console_buffer with a function call
Dear Peter Tyser,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 3 lines
what is the purpose of this patch? As far as I can see we gain nothing, but we lose on memory footpint. I guess there is some problem you're trying to fix, but you did not mention it?
I've added a basic "debug serial console" which relies on this patch. The debug console is a simple command prompt which allows the user to issue commands before relocating to SDRAM. We've found this feature very useful for operations such as initially programming SPD data, debugging hardware issues (SDRAM/I2C). I'll submit the debug console patches shortly.
OK, I think what you're trying to do.
Quoted 2 lines
I'm not sure if the debug console will be accepted to mainline, but I think this patch alone is an improvement over the current implementation
Frankly, I don't think so - it just makes the code bigger for no good use to 99.9% of the users.
Quoted 3 lines
of using a global string and multiple external
console_bufferreferences. I've always thought global variables should be avoided if there is a reasonable alternative
But this is a boot loader, and size matters.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Lady Nancy Astor:
"Winston, if you were my husband, I'd put poison in your coffee."
Winston Churchill:
"Nancy, if you were my wife, I'd drink it."PATCH 1/1 Replace references to extern console_buffer with a function call
Quoted 5 lines
Quoted 1 line
I'm not sure if the debug console will be accepted to mainline, but
I
Quoted 1 line
think this patch alone is an improvement over the current
implementation
Quoted 8 lines
Frankly, I don't think so - it just makes the code bigger for no good use to 99.9% of the users.
Quoted 3 lines
of using a global string and multiple external
console_bufferreferences. I've always thought global variables should be avoided if there is a reasonable alternativeBut this is a boot loader, and size matters.
I had assumed gcc/ld would be smart enough to optimize the function call away, seeing as there is no conditional code in it. I just tested, and the size was increased by 48 bytes for the MPC8548CDS reference board after applying the patch. Inlining the console_buffer_addr() didn't get rid of the 48 bytes of bloat.
I guess this patch's fate will be the same as "[RFC] Add support for early serial debug console"...
Thanks,
Peter
PATCH 1/1 Replace references to extern console_buffer with a function call
Dear Peter Tyser,
Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 2 lines
But this is a boot loader, and size matters.
I had assumed gcc/ld would be smart enough to optimize the function call away, seeing as there is no conditional code in it. I just tested, and the size was increased by 48 bytes for the MPC8548CDS reference board after applying the patch. Inlining the
console_buffer_addr()didn't get rid of the 48 bytes of bloat.I guess this patch's fate will be the same as "[RFC] Add support for early serial debug console"...
Indeed, as this is the only application where the patch is needed.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Fascinating, a totally parochial attitude. -- Spock, "Metamorphosis", stardate 3219.8