]>
Commit | Line | Data |
---|---|---|
2ef2b01e A |
1 | /** @file |
2 | Basic serial IO abstaction for GDB | |
3 | ||
1ebd6c11 | 4 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> |
2ef2b01e | 5 | |
1ebd6c11 | 6 | This program and the accompanying materials |
2ef2b01e A |
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 ( | |
27 | IN EFI_HANDLE ImageHandle, | |
28 | IN EFI_SYSTEM_TABLE *SystemTable | |
29 | ) | |
30 | { | |
31 | return RETURN_SUCCESS; | |
32 | } | |
33 | ||
34 | RETURN_STATUS | |
35 | EFIAPI | |
36 | GdbSerialInit ( | |
37 | IN UINT64 BaudRate, | |
38 | IN UINT8 Parity, | |
39 | IN UINT8 DataBits, | |
40 | IN UINT8 StopBits | |
41 | ) | |
42 | { | |
43 | return RETURN_SUCCESS; | |
44 | } | |
45 | ||
46 | BOOLEAN | |
47 | EFIAPI | |
48 | GdbIsCharAvailable ( | |
49 | VOID | |
50 | ) | |
51 | { | |
7e353851 | 52 | UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG; |
2ef2b01e A |
53 | |
54 | if ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_NOT_EMPTY) { | |
55 | return TRUE; | |
56 | } else { | |
57 | return FALSE; | |
58 | } | |
59 | } | |
60 | ||
61 | CHAR8 | |
62 | EFIAPI | |
63 | GdbGetChar ( | |
64 | VOID | |
65 | ) | |
66 | { | |
7e353851 | 67 | UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG; |
68 | UINT32 RBR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_RBR_REG; | |
2ef2b01e A |
69 | CHAR8 Char; |
70 | ||
71 | while ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_EMPTY); | |
72 | Char = MmioRead8(RBR); | |
73 | ||
74 | return Char; | |
75 | } | |
76 | ||
77 | VOID | |
78 | EFIAPI | |
79 | GdbPutChar ( | |
80 | IN CHAR8 Char | |
81 | ) | |
82 | { | |
7e353851 | 83 | UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG; |
84 | UINT32 THR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_THR_REG; | |
2ef2b01e A |
85 | |
86 | while ((MmioRead8(LSR) & UART_LSR_TX_FIFO_E_MASK) == UART_LSR_TX_FIFO_E_NOT_EMPTY); | |
87 | MmioWrite8(THR, Char); | |
88 | } | |
89 | ||
90 | VOID | |
91 | GdbPutString ( | |
92 | IN CHAR8 *String | |
93 | ) | |
94 | { | |
95 | while (*String != '\0') { | |
96 | GdbPutChar (*String); | |
97 | String++; | |
98 | } | |
99 | } | |
100 | ||
101 | ||
102 | ||
103 |