From patchwork Mon Aug 29 17:21:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 112119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 54128B6F8E for ; Tue, 30 Aug 2011 03:22:23 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 879D628116; Mon, 29 Aug 2011 19:22:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Cugbusl9UrSD; Mon, 29 Aug 2011 19:22:20 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D1E92810A; Mon, 29 Aug 2011 19:22:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BA1FE2810A for ; Mon, 29 Aug 2011 19:22:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4CTxjE4nI5NT for ; Mon, 29 Aug 2011 19:22:17 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.67]) by theia.denx.de (Postfix) with ESMTPS id AF4A328108 for ; Mon, 29 Aug 2011 19:22:15 +0200 (CEST) Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id p7THMCnX012281; Mon, 29 Aug 2011 10:22:12 -0700 Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by hpaq6.eem.corp.google.com with ESMTP id p7THM2Fu003119; Mon, 29 Aug 2011 10:22:03 -0700 Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id 2959F140BF9; Mon, 29 Aug 2011 10:22:02 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 29 Aug 2011 10:21:57 -0700 Message-Id: <1314638517-20178-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 X-System-Of-Record: true Subject: [U-Boot] [RFC PATCH] Pre-console buffer for ARM X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch is for Graeme to take a look at. I found that have_console is not a flag yet. Also a few tidy-ups to handle buffer overflow and to avoid printing a 'dumping buffer' message when nothing was outputted. Also I tried to simplify the maths for the location of the pre-console buffer. IMO this should be done in board.c though. Signed-off-by: Simon Glass --- arch/arm/include/asm/global_data.h | 1 + common/console.c | 36 ++++++++++++++++++++++++++++++++++++ include/configs/tegra2-common.h | 8 ++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h index 4fc51fd..8b028cc 100644 --- a/arch/arm/include/asm/global_data.h +++ b/arch/arm/include/asm/global_data.h @@ -71,6 +71,7 @@ typedef struct global_data { unsigned long start_addr_sp; /* start_addr_stackpointer */ unsigned long reloc_off; #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) + unsigned long con_buf_idx; /* Console buffer index */ unsigned long tlb_addr; #endif void **jt; /* jump table */ diff --git a/common/console.c b/common/console.c index 8c650e0..2a7d2c8 100644 --- a/common/console.c +++ b/common/console.c @@ -323,6 +323,36 @@ int tstc(void) return serial_tstc(); } +void pre_console_putc(const char c) +{ + char *buffer = (char *)CONFIG_SYS_TMP_CON_BUF_ADDR; + + if (gd->con_buf_idx < CONFIG_SYS_TMP_CON_BUF_SZ) + buffer[gd->con_buf_idx++] = c; +} + +void pre_console_puts(const char *s) +{ + while (*s) + pre_console_putc(*s++); +} + +void print_pre_console_buffer(void) +{ + char *buffer = (char *)CONFIG_SYS_TMP_CON_BUF_ADDR; + int index = gd->con_buf_idx; + + if (index) { + printf("console initialised - dumping pre-console buffer:\n"); + index = min(index, CONFIG_SYS_TMP_CON_BUF_SZ - 1); + buffer[index] = '\0'; + puts(buffer); + if (gd->con_buf_idx == CONFIG_SYS_TMP_CON_BUF_SZ) + puts("... (buffer overflowed)\n"); + printf("buffer dumped\n"); + } +} + void putc(const char c) { #ifdef CONFIG_SILENT_CONSOLE @@ -341,6 +371,8 @@ void putc(const char c) } else { /* Send directly to the handler */ serial_putc(c); + } else { + pre_console_putc(c); } } @@ -362,6 +394,8 @@ void puts(const char *s) } else { /* Send directly to the handler */ serial_puts(s); + } else { + pre_console_puts(s); } } @@ -529,6 +563,8 @@ int console_init_f(void) gd->flags |= GD_FLG_SILENT; #endif + print_pre_console_buffer(); + return 0; } diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h index 73e0f05..a42cce1 100644 --- a/include/configs/tegra2-common.h +++ b/include/configs/tegra2-common.h @@ -156,8 +156,12 @@ #define CONFIG_SYS_INIT_RAM_ADDR CONFIG_STACKBASE #define CONFIG_SYS_INIT_RAM_SIZE CONFIG_SYS_MALLOC_LEN -#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \ - CONFIG_SYS_INIT_RAM_SIZE - \ +#define CONFIG_SYS_TMP_CON_BUF_SZ (1 * 1024) +#define CONFIG_SYS_INIT_RAM_TOP (CONFIG_SYS_INIT_RAM_ADDR + \ + CONFIG_SYS_INIT_RAM_SIZE) +#define CONFIG_SYS_TMP_CON_BUF_ADDR (CONFIG_SYS_INIT_RAM_TOP - \ + CONFIG_SYS_TMP_CON_BUF_SZ) +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TMP_CON_BUF_ADDR - \ GENERATED_GBL_DATA_SIZE) #define CONFIG_TEGRA2_GPIO