1 //==========================================================================
3 // io/serial/common/haldiag.c
5 // Serial I/O interface module using HAL I/O routines
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
44 // Contributors: gthomas
46 // Purpose: HAL/diag serial driver
49 //####DESCRIPTIONEND####
51 //==========================================================================
53 #include <pkgconf/io.h>
54 #include <pkgconf/io_serial.h>
55 #ifdef CYGPKG_IO_SERIAL_HALDIAG
56 #include <cyg/io/io.h>
57 #include <cyg/io/devtab.h>
58 #include <cyg/io/serial.h>
59 #include <cyg/infra/diag.h>
60 #include <cyg/hal/hal_diag.h>
62 static bool haldiag_init(struct cyg_devtab_entry *tab);
63 static bool haldiag_putc(serial_channel *chan, unsigned char c);
64 static unsigned char haldiag_getc(serial_channel *chan);
65 static Cyg_ErrNo haldiag_set_config(serial_channel *chan, cyg_uint32 key,
66 const void *xbuf, cyg_uint32 *len);
68 static SERIAL_FUNS(haldiag_funs,
72 0, // start xmit - not used
73 0 // stop xmit - not used
77 static SERIAL_CHANNEL(haldiag_channel0,
80 CYG_SERIAL_BAUD_DEFAULT,
81 CYG_SERIAL_STOP_DEFAULT,
82 CYG_SERIAL_PARITY_DEFAULT,
83 CYG_SERIAL_WORD_LENGTH_DEFAULT,
84 CYG_SERIAL_FLAGS_DEFAULT
86 DEVTAB_ENTRY(haldiag_io0,
88 0, // Does not depend on a lower level interface
91 0, // No initialization/lookup needed
95 haldiag_config_port(serial_channel *chan)
100 haldiag_init(struct cyg_devtab_entry *tab)
102 serial_channel *chan = (serial_channel *)tab->priv;
103 #ifdef CYGDBG_IO_INIT
104 diag_printf("HAL/diag SERIAL init\n");
106 haldiag_config_port(chan);
110 // Return 'true' if character is sent to device
112 haldiag_putc(serial_channel *chan, unsigned char c)
114 HAL_DIAG_WRITE_CHAR(c);
119 haldiag_getc(serial_channel *chan)
122 HAL_DIAG_READ_CHAR(c);
123 return (unsigned char)c;
127 haldiag_set_config(serial_channel *chan, cyg_uint32 key, const void *xbuf,
131 case CYG_IO_SET_CONFIG_SERIAL_INFO:
132 diag_printf("%s\n", __FUNCTION__);
138 #endif // CYGPKG_IO_SERIAL_HALDIAG