Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 1 | /* |
Brian Swetland | ddf61a2 | 2009-01-29 20:46:14 -0800 | [diff] [blame] | 2 | * Copyright (c) 2009, Google Inc. |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 3 | * All rights reserved. |
Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame^] | 4 | * Copyright (c) 2009, The Linux Foundation. All rights reserved. |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * * Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in |
| 13 | * the documentation and/or other materials provided with the |
| 14 | * distribution. |
| 15 | * * Neither the name of Google, Inc. nor the names of its contributors |
| 16 | * may be used to endorse or promote products derived from this |
| 17 | * software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 23 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 26 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 27 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | * SUCH DAMAGE. |
| 31 | */ |
| 32 | |
| 33 | #include <debug.h> |
| 34 | #include <printf.h> |
| 35 | #include <arch/arm/dcc.h> |
Dima Zavin | 6e274c2 | 2009-01-28 17:28:41 -0800 | [diff] [blame] | 36 | #include <dev/fbcon.h> |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 37 | #include <dev/uart.h> |
| 38 | |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 39 | void _dputc(char c) |
| 40 | { |
Brian Swetland | ddf61a2 | 2009-01-29 20:46:14 -0800 | [diff] [blame] | 41 | #if WITH_DEBUG_DCC |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 42 | if (c == '\n') { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 43 | while (dcc_putc('\r') < 0) ; |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 44 | } |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 45 | while (dcc_putc(c) < 0) ; |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 46 | #endif |
Brian Swetland | ddf61a2 | 2009-01-29 20:46:14 -0800 | [diff] [blame] | 47 | #if WITH_DEBUG_UART |
| 48 | uart_putc(0, c); |
| 49 | #endif |
| 50 | #if WITH_DEBUG_FBCON && WITH_DEV_FBCON |
Dima Zavin | 6e274c2 | 2009-01-28 17:28:41 -0800 | [diff] [blame] | 51 | fbcon_putc(c); |
| 52 | #endif |
Ajay Dudani | 168f6cb | 2009-12-07 19:04:02 -0800 | [diff] [blame] | 53 | #if WITH_DEBUG_JTAG |
| 54 | jtag_dputc(c); |
| 55 | #endif |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 56 | } |
| 57 | |
Travis Geiselbrecht | dbc2c68 | 2009-06-28 12:18:39 -0700 | [diff] [blame] | 58 | int dgetc(char *c, bool wait) |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 59 | { |
Brian Swetland | c82fda9 | 2009-01-02 01:53:42 -0800 | [diff] [blame] | 60 | int n; |
Brian Swetland | ddf61a2 | 2009-01-29 20:46:14 -0800 | [diff] [blame] | 61 | #if WITH_DEBUG_DCC |
Brian Swetland | c82fda9 | 2009-01-02 01:53:42 -0800 | [diff] [blame] | 62 | n = dcc_getc(); |
Brian Swetland | ddf61a2 | 2009-01-29 20:46:14 -0800 | [diff] [blame] | 63 | #elif WITH_DEBUG_UART |
| 64 | n = uart_getc(0, 0); |
Brian Swetland | c82fda9 | 2009-01-02 01:53:42 -0800 | [diff] [blame] | 65 | #else |
Brian Swetland | ddf61a2 | 2009-01-29 20:46:14 -0800 | [diff] [blame] | 66 | n = -1; |
Brian Swetland | c82fda9 | 2009-01-02 01:53:42 -0800 | [diff] [blame] | 67 | #endif |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 68 | if (n < 0) { |
| 69 | return -1; |
| 70 | } else { |
| 71 | *c = n; |
| 72 | return 0; |
| 73 | } |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | void platform_halt(void) |
| 77 | { |
| 78 | dprintf(INFO, "HALT: spinning forever...\n"); |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 79 | for (;;) ; |
Brian Swetland | 2500aa1 | 2009-01-01 04:33:55 -0800 | [diff] [blame] | 80 | } |