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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4d02595 was fcc6224, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

boot,arm32: Make arm32 bootstrap code BeagleBoard-xM aware.

  • Property mode set to 100644
File size: 3.6 KB
RevLine 
[6b781c0]1/*
[4872160]2 * Copyright (c) 2007 Michal Kebrt
3 * Copyright (c) 2009 Vineeth Pillai
[1590e23]4 * Copyright (c) 2010 Jiri Svoboda
[6b781c0]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 */
[4872160]34/** @file
35 * @brief bootloader output logic
36 */
[6b781c0]37
[4872160]38#include <typedefs.h>
39#include <arch/main.h>
40#include <putchar.h>
41#include <str.h>
42
[fcc6224]43#ifdef MACHINE_beagleboardxm
44
45/** Send a byte to the amdm37x serial console.
46 *
47 * @param byte Byte to send.
48 */
49static void scons_sendb_bbxm(uint8_t byte)
50{
51 volatile uint32_t *thr =
52 (volatile uint32_t *)BBXM_SCONS_THR;
53 volatile uint32_t *ssr =
54 (volatile uint32_t *)BBXM_SCONS_SSR;
55
56 /* Wait until transmitter is empty. */
57 while ((*ssr & BBXM_THR_FULL) == 1) ;
58
59 /* Transmit byte. */
60 *thr = (uint32_t) byte;
61}
62
63#endif
64
[1590e23]65#ifdef MACHINE_gta02
66
67/** Send a byte to the gta02 serial console.
68 *
69 * @param byte Byte to send.
70 */
71static void scons_sendb_gta02(uint8_t byte)
72{
73 volatile uint32_t *utrstat;
74 volatile uint32_t *utxh;
75
76 utrstat = (volatile uint32_t *) GTA02_SCONS_UTRSTAT;
77 utxh = (volatile uint32_t *) GTA02_SCONS_UTXH;
78
79 /* Wait until transmitter is empty. */
[f1fc83a]80 while ((*utrstat & S3C24XX_UTXH_TX_EMPTY) == 0)
[1590e23]81 ;
82
83 /* Transmit byte. */
84 *utxh = (uint32_t) byte;
85}
86
87#endif
88
89#ifdef MACHINE_testarm
90
91/** Send a byte to the GXemul testarm serial console.
92 *
93 * @param byte Byte to send.
94 */
95static void scons_sendb_testarm(uint8_t byte)
96{
97 *((volatile uint8_t *) TESTARM_SCONS_ADDR) = byte;
98}
99
100#endif
101
102#ifdef MACHINE_integratorcp
103
104/** Send a byte to the IntegratorCP serial console.
105 *
106 * @param byte Byte to send.
107 */
108static void scons_sendb_icp(uint8_t byte)
109{
110 *((volatile uint8_t *) ICP_SCONS_ADDR) = byte;
111}
112
113#endif
114
115/** Send a byte to the serial console.
116 *
117 * @param byte Byte to send.
118 */
119static void scons_sendb(uint8_t byte)
120{
[fcc6224]121#ifdef MACHINE_beagleboardxm
122 scons_sendb_bbxm(byte);
123#endif
[1590e23]124#ifdef MACHINE_gta02
125 scons_sendb_gta02(byte);
126#endif
127#ifdef MACHINE_testarm
128 scons_sendb_testarm(byte);
129#endif
130#ifdef MACHINE_integratorcp
[12b0d51]131 scons_sendb_icp(byte);
[1590e23]132#endif
133}
134
135/** Display a character
136 *
137 * @param ch Character to display
138 */
[4872160]139void putchar(const wchar_t ch)
140{
141 if (ch == '\n')
[1590e23]142 scons_sendb('\r');
143
[4872160]144 if (ascii_check(ch))
[1590e23]145 scons_sendb((uint8_t) ch);
[4872160]146 else
[1590e23]147 scons_sendb(U_SPECIAL);
[4872160]148}
[6b781c0]149
150/** @}
151 */
Note: See TracBrowser for help on using the repository browser.