Added DebugAgentTimerLib. Cleaned up .h files and other code.
[mirror_edk2.git] / Omap35xxPkg / Library / GdbSerialLib / GdbSerialLib.c
CommitLineData
a3f98646 1/** @file
2 Basic serial IO abstaction for GDB
3
4 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
5
6 All rights reserved. This program and the accompanying materials
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
24RETURN_STATUS
25EFIAPI
26GdbSerialLibConstructor (
43263288 27 VOID
a3f98646 28 )
29{
30 return RETURN_SUCCESS;
31}
32
33RETURN_STATUS
34EFIAPI
35GdbSerialInit (
36 IN UINT64 BaudRate,
37 IN UINT8 Parity,
38 IN UINT8 DataBits,
39 IN UINT8 StopBits
40 )
41{
42 return RETURN_SUCCESS;
43}
44
45BOOLEAN
46EFIAPI
47GdbIsCharAvailable (
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
60CHAR8
61EFIAPI
62GdbGetChar (
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
76VOID
77EFIAPI
78GdbPutChar (
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
89VOID
90GdbPutString (
91 IN CHAR8 *String
92 )
93{
94 while (*String != '\0') {
95 GdbPutChar (*String);
96 String++;
97 }
98}
99
100
101
102