]>
Commit | Line | Data |
---|---|---|
a3f98646 | 1 | /** @file |
2 | Basic serial IO abstaction for GDB | |
3 | ||
3d70643b | 4 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> |
a3f98646 | 5 | |
3d70643b | 6 | This program and the accompanying materials |
a3f98646 | 7 | are licensed and made available under the terms and conditions of the BSD License |
8 | which accompanies this distribution. The full text of the license may be found at | |
9 | http://opensource.org/licenses/bsd-license.php | |
10 | ||
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
13 | ||
14 | **/ | |
15 | ||
16 | #include <Uefi.h> | |
17 | #include <Library/GdbSerialLib.h> | |
18 | #include <Library/PcdLib.h> | |
19 | #include <Library/IoLib.h> | |
20 | #include <Library/DebugLib.h> | |
21 | #include <Library/OmapLib.h> | |
22 | #include <Omap3530/Omap3530.h> | |
23 | ||
24 | RETURN_STATUS | |
25 | EFIAPI | |
26 | GdbSerialLibConstructor ( | |
43263288 | 27 | VOID |
a3f98646 | 28 | ) |
29 | { | |
30 | return RETURN_SUCCESS; | |
31 | } | |
32 | ||
33 | RETURN_STATUS | |
34 | EFIAPI | |
35 | GdbSerialInit ( | |
36 | IN UINT64 BaudRate, | |
37 | IN UINT8 Parity, | |
38 | IN UINT8 DataBits, | |
39 | IN UINT8 StopBits | |
40 | ) | |
41 | { | |
42 | return RETURN_SUCCESS; | |
43 | } | |
44 | ||
45 | BOOLEAN | |
46 | EFIAPI | |
47 | GdbIsCharAvailable ( | |
48 | VOID | |
49 | ) | |
50 | { | |
43263288 | 51 | UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG; |
a3f98646 | 52 | |
53 | if ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_NOT_EMPTY) { | |
54 | return TRUE; | |
55 | } else { | |
56 | return FALSE; | |
57 | } | |
58 | } | |
59 | ||
60 | CHAR8 | |
61 | EFIAPI | |
62 | GdbGetChar ( | |
63 | VOID | |
64 | ) | |
65 | { | |
43263288 | 66 | UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG; |
67 | UINT32 RBR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_RBR_REG; | |
a3f98646 | 68 | CHAR8 Char; |
69 | ||
70 | while ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_EMPTY); | |
71 | Char = MmioRead8(RBR); | |
72 | ||
73 | return Char; | |
74 | } | |
75 | ||
76 | VOID | |
77 | EFIAPI | |
78 | GdbPutChar ( | |
79 | IN CHAR8 Char | |
80 | ) | |
81 | { | |
43263288 | 82 | UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG; |
83 | UINT32 THR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_THR_REG; | |
a3f98646 | 84 | |
85 | while ((MmioRead8(LSR) & UART_LSR_TX_FIFO_E_MASK) == UART_LSR_TX_FIFO_E_NOT_EMPTY); | |
86 | MmioWrite8(THR, Char); | |
87 | } | |
88 | ||
89 | VOID | |
90 | GdbPutString ( | |
91 | IN CHAR8 *String | |
92 | ) | |
93 | { | |
94 | while (*String != '\0') { | |
95 | GdbPutChar (*String); | |
96 | String++; | |
97 | } | |
98 | } | |
99 | ||
100 | ||
101 | ||
102 |