]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmRealViewEbPkg/Library/GdbSerialLib/GdbSerialLib.c
2 Basic serial IO abstaction for GDB
4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
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
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.
17 #include <Library/GdbSerialLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/IoLib.h>
21 #include <ArmEb/ArmEb.h>
25 GdbSerialLibConstructor (
29 return GdbSerialInit (115200, 0, 8, 1);
41 if ((Parity
!= 0) || (DataBits
!= 8) || (StopBits
!= 1)) {
42 return RETURN_UNSUPPORTED
;
45 if (BaudRate
!= 115200) {
46 // Could add support for different Baud rates....
47 return RETURN_UNSUPPORTED
;
50 UINT32 Base
= PcdGet32 (PcdGdbUartBase
);
52 // initialize baud rate generator to 115200 based on EB clock REFCLK24MHZ
53 MmioWrite32 (Base
+ UARTIBRD
, UART_115200_IDIV
);
54 MmioWrite32 (Base
+ UARTFBRD
, UART_115200_FDIV
);
56 // no parity, 1 stop, no fifo, 8 data bits
57 MmioWrite32 (Base
+ UARTLCR_H
, 0x60);
59 // clear any pending errors
60 MmioWrite32 (Base
+ UARTECR
, 0);
62 // enable tx, rx, and uart overall
63 MmioWrite32 (Base
+ UARTCR
, 0x301);
65 return RETURN_SUCCESS
;
74 UINT32 FR
= PcdGet32 (PcdGdbUartBase
) + UARTFR
;
76 if ((MmioRead32 (FR
) & UART_RX_EMPTY_FLAG_MASK
) == 0) {
89 UINT32 FR
= PcdGet32 (PcdGdbUartBase
) + UARTFR
;
90 UINT32 DR
= PcdGet32 (PcdGdbUartBase
) + UARTDR
;
92 while ((MmioRead32 (FR
) & UART_RX_EMPTY_FLAG_MASK
) == 0);
93 return MmioRead8 (DR
);
102 UINT32 FR
= PcdGet32 (PcdGdbUartBase
) + UARTFR
;
103 UINT32 DR
= PcdGet32 (PcdGdbUartBase
) + UARTDR
;
105 while ((MmioRead32 (FR
) & UART_TX_EMPTY_FLAG_MASK
) != 0);
106 MmioWrite8 (DR
, Char
);
115 while (*String
!= '\0') {
116 GdbPutChar (*String
);