source: mainline/boot/arch/arm32/src/putchar.c@ d2707fc

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d2707fc was f1fc83a, checked in by Jiri Svoboda <jiri@…>, 15 years ago

Add s3c24xx_uart driver to kernel for serial console output.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 2007 Michal Kebrt
3 * Copyright (c) 2009 Vineeth Pillai
4 * Copyright (c) 2010 Jiri Svoboda
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/** @addtogroup arm32boot
32 * @{
33 */
34/** @file
35 * @brief bootloader output logic
36 */
37
38#include <typedefs.h>
39#include <arch/main.h>
40#include <putchar.h>
41#include <str.h>
42
43#ifdef MACHINE_gta02
44
45/** Send a byte to the gta02 serial console.
46 *
47 * @param byte Byte to send.
48 */
49static void scons_sendb_gta02(uint8_t byte)
50{
51 volatile uint32_t *utrstat;
52 volatile uint32_t *utxh;
53
54 utrstat = (volatile uint32_t *) GTA02_SCONS_UTRSTAT;
55 utxh = (volatile uint32_t *) GTA02_SCONS_UTXH;
56
57 /* Wait until transmitter is empty. */
58 while ((*utrstat & S3C24XX_UTXH_TX_EMPTY) == 0)
59 ;
60
61 /* Transmit byte. */
62 *utxh = (uint32_t) byte;
63}
64
65#endif
66
67#ifdef MACHINE_testarm
68
69/** Send a byte to the GXemul testarm serial console.
70 *
71 * @param byte Byte to send.
72 */
73static void scons_sendb_testarm(uint8_t byte)
74{
75 *((volatile uint8_t *) TESTARM_SCONS_ADDR) = byte;
76}
77
78#endif
79
80#ifdef MACHINE_integratorcp
81
82/** Send a byte to the IntegratorCP serial console.
83 *
84 * @param byte Byte to send.
85 */
86static void scons_sendb_icp(uint8_t byte)
87{
88 *((volatile uint8_t *) ICP_SCONS_ADDR) = byte;
89}
90
91#endif
92
93/** Send a byte to the serial console.
94 *
95 * @param byte Byte to send.
96 */
97static void scons_sendb(uint8_t byte)
98{
99#ifdef MACHINE_gta02
100 scons_sendb_gta02(byte);
101#endif
102#ifdef MACHINE_testarm
103 scons_sendb_testarm(byte);
104#endif
105#ifdef MACHINE_integratorcp
106 scons_sendb_icp(byte);
107#endif
108}
109
110/** Display a character
111 *
112 * @param ch Character to display
113 */
114void putchar(const wchar_t ch)
115{
116 if (ch == '\n')
117 scons_sendb('\r');
118
119 if (ascii_check(ch))
120 scons_sendb((uint8_t) ch);
121 else
122 scons_sendb(U_SPECIAL);
123}
124
125/** @}
126 */
Note: See TracBrowser for help on using the repository browser.