]> git.proxmox.com Git - mirror_edk2.git/blob - Omap35xxPkg/Library/GdbSerialLib/GdbSerialLib.c
4e9fa0175bad2b73fdaa7e297dea6c92c2b4bf03
[mirror_edk2.git] / Omap35xxPkg / Library / GdbSerialLib / GdbSerialLib.c
1 /** @file
2 Basic serial IO abstaction for GDB
3
4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <Uefi.h>
11 #include <Library/GdbSerialLib.h>
12 #include <Library/PcdLib.h>
13 #include <Library/IoLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/OmapLib.h>
16 #include <Omap3530/Omap3530.h>
17
18 RETURN_STATUS
19 EFIAPI
20 GdbSerialLibConstructor (
21 VOID
22 )
23 {
24 return RETURN_SUCCESS;
25 }
26
27 RETURN_STATUS
28 EFIAPI
29 GdbSerialInit (
30 IN UINT64 BaudRate,
31 IN UINT8 Parity,
32 IN UINT8 DataBits,
33 IN UINT8 StopBits
34 )
35 {
36 return RETURN_SUCCESS;
37 }
38
39 BOOLEAN
40 EFIAPI
41 GdbIsCharAvailable (
42 VOID
43 )
44 {
45 UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
46
47 if ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_NOT_EMPTY) {
48 return TRUE;
49 } else {
50 return FALSE;
51 }
52 }
53
54 CHAR8
55 EFIAPI
56 GdbGetChar (
57 VOID
58 )
59 {
60 UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
61 UINT32 RBR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_RBR_REG;
62 CHAR8 Char;
63
64 while ((MmioRead8(LSR) & UART_LSR_RX_FIFO_E_MASK) == UART_LSR_RX_FIFO_E_EMPTY);
65 Char = MmioRead8(RBR);
66
67 return Char;
68 }
69
70 VOID
71 EFIAPI
72 GdbPutChar (
73 IN CHAR8 Char
74 )
75 {
76 UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
77 UINT32 THR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_THR_REG;
78
79 while ((MmioRead8(LSR) & UART_LSR_TX_FIFO_E_MASK) == UART_LSR_TX_FIFO_E_NOT_EMPTY);
80 MmioWrite8(THR, Char);
81 }
82
83 VOID
84 GdbPutString (
85 IN CHAR8 *String
86 )
87 {
88 while (*String != '\0') {
89 GdbPutChar (*String);
90 String++;
91 }
92 }
93
94
95
96