From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19762 invoked by alias); 24 Dec 2008 14:24:08 -0000 Received: (qmail 19750 invoked by uid 22791); 24 Dec 2008 14:24:07 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_50 X-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_50 X-Spam-Check-By: sourceware.org Received: from mail01.solnet.ch (HELO mail01.solnet.ch) (212.101.4.135) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 24 Dec 2008 14:23:27 +0000 X-Virus-Scanned: by SolNet-Check at mail01.solnet.ch Received: from mail01.solnet.ch ([127.0.0.1]) by localhost (mail01.solnet.ch [127.0.0.1]) (SolNet-Check, port 10024) with LMTP id wBtkFWbUOIq6 for ; Wed, 24 Dec 2008 14:23:24 +0000 (UTC) Received: from beta.intefo.ch (static-212-101-18-64.adsl.solnet.ch [212.101.18.64]) by mail01.solnet.ch (Postfix) with ESMTP id 114F250DEB for ; Wed, 24 Dec 2008 14:23:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at beta.intefo.ch Received: from beta.intefo.ch ([127.0.0.1]) by localhost (beta.intefo.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Of9NZBw9MFo8 for ; Wed, 24 Dec 2008 15:23:23 +0100 (CET) Received: from [192.168.1.20] (simon.intefo.ch [192.168.1.20]) by beta.intefo.ch (Postfix) with ESMTP id 89CC17700DC for ; Wed, 24 Dec 2008 15:23:23 +0100 (CET) Message-ID: <495245DF.4060708@intefo.ch> Date: Wed, 24 Dec 2008 14:24:00 -0000 From: Simon Kallweit User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: eCos Patches List Subject: diagnostic output to custom handler Content-Type: multipart/mixed; boundary="------------040106030309070303080203" X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2008-12/txt/msg00056.txt.bz2 This is a multi-part message in MIME format. --------------040106030309070303080203 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 316 This patch adds the possibility to override the diag_write_char function at run-time, allowing diagnostic output to be redirected to a custom handler. I need this functionality as I want the diagnostic output to be written into a ring buffer in flash. I think this function may be useful to others too?!? Simon --------------040106030309070303080203 Content-Type: text/x-diff; name="diag_custom_output.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diag_custom_output.patch" Content-length: 3156 diff -r b190c02bd4f7 packages/infra/current/ChangeLog --- a/packages/infra/current/ChangeLog Tue Dec 23 09:32:09 2008 +0100 +++ b/packages/infra/current/ChangeLog Wed Dec 24 15:20:51 2008 +0100 @@ -1,3 +1,9 @@ +2008-12-24 Simon Kallweit + + * include/diag.h: + * src/diag.cxx: Implemented a further indirection for + diag_write_char to allow diagnostic output to a custom handler. + 2008-10-02 Jonathan Larmour * src/gccsupport.cxx (fwrite, fputc): New functions since GCC can diff -r b190c02bd4f7 packages/infra/current/include/diag.h --- a/packages/infra/current/include/diag.h Tue Dec 23 09:32:09 2008 +0100 +++ b/packages/infra/current/include/diag.h Wed Dec 24 15:20:51 2008 +0100 @@ -64,6 +64,8 @@ externC void diag_init(void); /* Initialize, call before any others*/ +externC void diag_set_write_char(void (*write_char)(char c)); + externC void diag_write_char(char c); /* Write single char to output */ externC void diag_write_string(const char *psz); /* Write zero terminated string */ diff -r b190c02bd4f7 packages/infra/current/src/diag.cxx --- a/packages/infra/current/src/diag.cxx Tue Dec 23 09:32:09 2008 +0100 +++ b/packages/infra/current/src/diag.cxx Wed Dec 24 15:20:51 2008 +0100 @@ -90,39 +90,53 @@ CYGBLD_ATTRIB_INIT_AFTER(CYG_INIT_HAL); /*----------------------------------------------------------------------*/ -/* Write single char to output */ - -externC void diag_write_char(char c) -{ - /* Translate LF into CRLF */ - - if( c == '\n' ) - { - HAL_DIAG_WRITE_CHAR('\r'); - } - - HAL_DIAG_WRITE_CHAR(c); -} - -// Default wrapper function used by diag_printf -static void -_diag_write_char(char c, void **param) -{ - diag_write_char(c); -} - -/*----------------------------------------------------------------------*/ /* Initialize. Call to pull in diag initializing constructor */ externC void diag_init(void) { } +// Default wrapper function used by diag_write_char +static void +_diag_write_char(char c) +{ + HAL_DIAG_WRITE_CHAR(c); +} + +static void (*_write_char)(char c) = _diag_write_char; + +externC void diag_set_write_char(void (*write_char)(char c)) +{ + _write_char = write_char; +} + +/*----------------------------------------------------------------------*/ +/* Write single char to output */ + +externC void diag_write_char(char c) +{ + /* Translate LF into CRLF */ + + if( c == '\n' ) + { + _write_char('\r'); + } + + _write_char(c); +} + +// Default wrapper function used by diag_printf +static void +_diag_putc(char c, void **param) +{ + diag_write_char(c); +} + // // This routine is used to send characters during 'printf()' functions. // It can be replaced by providing a replacement via diag_init_putc(). // -static void (*_putc)(char c, void **param) = _diag_write_char; +static void (*_putc)(char c, void **param) = _diag_putc; void diag_init_putc(void (*putc)(char c, void **param)) --------------040106030309070303080203--