]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c
EmbeddedPkg/Metronome.c: Fix delay computed by WaitForTick() function.
[mirror_edk2.git] / EmbeddedPkg / Library / TemplateSerialPortLib / TemplateSerialPortLib.c
1 /** @file
2 Serial I/O Port library functions with no library constructor/destructor
3
4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5 Copyright (c) 2012, ARM Ltd. All rights reserved.
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include <Base.h>
18
19
20 #include <Library/SerialPortLib.h>
21 #include <Library/SerialPortExtLib.h>
22
23 /**
24
25 Programmed hardware of Serial port.
26
27 @return Always return EFI_UNSUPPORTED.
28
29 **/
30 RETURN_STATUS
31 EFIAPI
32 SerialPortInitialize (
33 VOID
34 )
35 {
36 return RETURN_UNSUPPORTED;
37 }
38
39 /**
40 Set the serial device control bits.
41
42 @return Always return EFI_UNSUPPORTED.
43
44 **/
45 RETURN_STATUS
46 EFIAPI
47 SerialPortSetControl (
48 IN UINT32 Control
49 )
50 {
51 return RETURN_UNSUPPORTED;
52 }
53
54 /**
55 Get the serial device control bits.
56
57 @param Control Control signals read from the serial device.
58
59 @retval EFI_SUCCESS The control bits were read from the serial device.
60 @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
61
62 **/
63 RETURN_STATUS
64 EFIAPI
65 SerialPortGetControl (
66 OUT UINT32 *Control
67 )
68 {
69 if (SerialPortPoll ()) {
70 // If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY
71 *Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
72 } else {
73 *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
74 }
75 return EFI_SUCCESS;
76 }
77
78 /**
79 Set the serial device attributes.
80
81 @return Always return EFI_UNSUPPORTED.
82
83 **/
84 RETURN_STATUS
85 EFIAPI
86 SerialPortSetAttributes (
87 IN OUT UINT64 *BaudRate,
88 IN OUT UINT32 *ReceiveFifoDepth,
89 IN OUT UINT32 *Timeout,
90 IN OUT EFI_PARITY_TYPE *Parity,
91 IN OUT UINT8 *DataBits,
92 IN OUT EFI_STOP_BITS_TYPE *StopBits
93 )
94 {
95 return RETURN_UNSUPPORTED;
96 }
97
98 /**
99 Write data to serial device.
100
101 @param Buffer Point of data buffer which need to be written.
102 @param NumberOfBytes Number of output bytes which are cached in Buffer.
103
104 @retval 0 Write data failed.
105 @retval !0 Actual number of bytes written to serial device.
106
107 **/
108 UINTN
109 EFIAPI
110 SerialPortWrite (
111 IN UINT8 *Buffer,
112 IN UINTN NumberOfBytes
113 )
114 {
115 return 0;
116 }
117
118
119 /**
120 Read data from serial device and save the data in buffer.
121
122 @param Buffer Point of data buffer which need to be written.
123 @param NumberOfBytes Number of output bytes which are cached in Buffer.
124
125 @retval 0 Read data failed.
126 @retval !0 Actual number of bytes read from serial device.
127
128 **/
129 UINTN
130 EFIAPI
131 SerialPortRead (
132 OUT UINT8 *Buffer,
133 IN UINTN NumberOfBytes
134 )
135 {
136 return 0;
137 }
138
139
140
141 /**
142 Poll the serial device to see if there is any data waiting.
143
144 If there is data waiting to be read from the serial port, then return
145 TRUE. If there is no data waiting to be read from the serial port, then
146 return FALSE.
147
148 @retval TRUE Data is waiting to be read.
149 @retval FALSE There is no data waiting to be read.
150
151 **/
152 BOOLEAN
153 EFIAPI
154 SerialPortPoll (
155 VOID
156 )
157 {
158 return 0;
159 }
160