From patchwork Sat Aug 27 12:54:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 111874 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 19BC2B702E for ; Sat, 27 Aug 2011 22:54:25 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BB8D928084; Sat, 27 Aug 2011 14:54:23 +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 mMflJFOAzEDi; Sat, 27 Aug 2011 14:54:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A8A7828085; Sat, 27 Aug 2011 14:54:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BDBC828085 for ; Sat, 27 Aug 2011 14:54:18 +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 SnHUNEcPXr+e for ; Sat, 27 Aug 2011 14:54: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 mail-pz0-f41.google.com (mail-pz0-f41.google.com [209.85.210.41]) by theia.denx.de (Postfix) with ESMTPS id 1D2BA28084 for ; Sat, 27 Aug 2011 14:54:15 +0200 (CEST) Received: by pzk4 with SMTP id 4so8587617pzk.28 for ; Sat, 27 Aug 2011 05:54:13 -0700 (PDT) Received: by 10.142.14.8 with SMTP id 8mr1141506wfn.189.1314449653384; Sat, 27 Aug 2011 05:54:13 -0700 (PDT) Received: from localhost.localdomain (d122-104-32-184.sbr6.nsw.optusnet.com.au. [122.104.32.184]) by mx.google.com with ESMTPS id i1sm6970286pbe.1.2011.08.27.05.54.10 (version=SSLv3 cipher=OTHER); Sat, 27 Aug 2011 05:54:12 -0700 (PDT) From: Graeme Russ To: u-boot@lists.denx.de Date: Sat, 27 Aug 2011 22:54:05 +1000 Message-Id: <1314449645-16900-1-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.5.2.317.g391b14 Subject: [U-Boot] [RFC][PATCH] Pre-console buffer 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 cropped up as an aside to another thread so I thought I would give it a go. It's pretty rough-and-ready but it does the trick :) --- arch/x86/cpu/cpu.c | 2 + arch/x86/include/asm/global_data.h | 14 +++++---- common/console.c | 56 ++++++++++++++++++++++++++++-------- include/configs/eNET.h | 5 ++- 4 files changed, 58 insertions(+), 19 deletions(-) -- 1.7.5.2.317.g391b14 diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index cac12c0..602fb51 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -90,6 +90,8 @@ int x86_cpu_init_f(void) const u32 em_rst = ~X86_CR0_EM; const u32 mp_ne_set = X86_CR0_MP | X86_CR0_NE; + printf("Example pre-console printf()\n"); + /* initialize FPU, reset EM, set MP and NE */ asm ("fninit\n" \ "movl %%cr0, %%eax\n" \ diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h index 2902e61..4ebc5bd 100644 --- a/arch/x86/include/asm/global_data.h +++ b/arch/x86/include/asm/global_data.h @@ -44,6 +44,7 @@ typedef struct global_data { unsigned long env_addr; /* Address of Environment struct */ unsigned long cpu_clk; /* CPU clock in Hz! */ unsigned long bus_clk; + unsigned long con_buf_idx; /* Console buffer index */ unsigned long relocaddr; /* Start address of U-Boot in RAM */ unsigned long start_addr_sp; /* start_addr_stackpointer */ phys_size_t ram_size; /* RAM size */ @@ -65,13 +66,14 @@ extern gd_t *gd; #define GD_ENV_ADDR 5 #define GD_CPU_CLK 6 #define GD_BUS_CLK 7 -#define GD_RELOC_ADDR 8 -#define GD_START_ADDR_SP 9 -#define GD_RAM_SIZE 10 -#define GD_RESET_STATUS 11 -#define GD_JT 12 +#define GD_CON_BUF_IDX 8 +#define GD_RELOC_ADDR 9 +#define GD_START_ADDR_SP 10 +#define GD_RAM_SIZE 11 +#define GD_RESET_STATUS 12 +#define GD_JT 13 -#define GD_SIZE 13 +#define GD_SIZE 14 /* * Global Data Flags diff --git a/common/console.c b/common/console.c index acc4df3..1fa862d 100644 --- a/common/console.c +++ b/common/console.c @@ -323,6 +323,28 @@ 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; + + buffer[gd->con_buf_idx] = 0x00; + puts(buffer); +} + void putc(const char c) { #ifdef CONFIG_SILENT_CONSOLE @@ -334,13 +356,16 @@ void putc(const char c) if (gd->flags & GD_FLG_DISABLE_CONSOLE) return; #endif - - if (gd->flags & GD_FLG_DEVINIT) { - /* Send to the standard output */ - fputc(stdout, c); + if (gd->flags & GD_FLG_HAVE_CONSOLE) { + if (gd->flags & GD_FLG_DEVINIT) { + /* Send to the standard output */ + fputc(stdout, c); + } else { + /* Send directly to the handler */ + serial_putc(c); + } } else { - /* Send directly to the handler */ - serial_putc(c); + pre_console_putc(c); } } @@ -355,13 +380,16 @@ void puts(const char *s) if (gd->flags & GD_FLG_DISABLE_CONSOLE) return; #endif - - if (gd->flags & GD_FLG_DEVINIT) { - /* Send to the standard output */ - fputs(stdout, s); + if (gd->flags & GD_FLG_HAVE_CONSOLE) { + if (gd->flags & GD_FLG_DEVINIT) { + /* Send to the standard output */ + fputs(stdout, s); + } else { + /* Send directly to the handler */ + serial_puts(s); + } } else { - /* Send directly to the handler */ - serial_puts(s); + pre_console_puts(s); } } @@ -529,6 +557,10 @@ int console_init_f(void) gd->flags |= GD_FLG_SILENT; #endif + printf("console initialised - dumping buffer\n"); + print_pre_console_buffer(); + printf("buffer dumped\n"); + return 0; } diff --git a/include/configs/eNET.h b/include/configs/eNET.h index 548d52c..4fb971f 100644 --- a/include/configs/eNET.h +++ b/include/configs/eNET.h @@ -164,8 +164,11 @@ #define CONFIG_SYS_STACK_SIZE (32 * 1024) #define CONFIG_SYS_CAR_ADDR 0x19200000 #define CONFIG_SYS_CAR_SIZE (16 * 1024) +#define CONFIG_SYS_TMP_CON_BUF_SZ (1 * 1024) #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_CAR_ADDR + \ - CONFIG_SYS_CAR_SIZE) + CONFIG_SYS_CAR_SIZE - \ + CONFIG_SYS_TMP_CON_BUF_SZ) +#define CONFIG_SYS_TMP_CON_BUF_ADDR CONFIG_SYS_INIT_SP_ADDR + 1 #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE #define CONFIG_SYS_MONITOR_LEN (256 * 1024) #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SECT_SIZE + \