blob: dcc518244a4297cacc1b224ba602673ad43ca263 [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @file
2 Basic serial IO abstaction for GDB
3
4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5
6 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 (
27 VOID
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{
51 UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
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{
66 UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
67 UINT32 RBR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_RBR_REG;
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{
82 UINT32 LSR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_LSR_REG;
83 UINT32 THR = UartBase(PcdGet32(PcdOmap35xxConsoleUart)) + UART_THR_REG;
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