]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/SerialPortLib.h
60d32122976b7ce8fc15af91bc235b5da8fc9c2e
[mirror_edk2.git] / MdePkg / Include / Library / SerialPortLib.h
1 /** @file
2 This library class provides common serial I/O port functions.
3
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __SERIAL_PORT_LIB__
16 #define __SERIAL_PORT_LIB__
17
18 /**
19 Initialize the serial device hardware.
20
21 If no initialization is required, then return RETURN_SUCCESS.
22 If the serial device was successfully initialized, then return RETURN_SUCCESS.
23 If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
24
25 @retval RETURN_SUCCESS The serial device was initialized.
26 @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
27
28 **/
29 RETURN_STATUS
30 EFIAPI
31 SerialPortInitialize (
32 VOID
33 );
34
35 /**
36 Write data from buffer to serial device.
37
38 Writes NumberOfBytes data bytes from Buffer to the serial device.
39 The number of bytes actually written to the serial device is returned.
40 If the return value is less than NumberOfBytes, then the write operation failed.
41 If Buffer is NULL, then ASSERT().
42 If NumberOfBytes is zero, then return 0.
43
44 @param Buffer Pointer to the data buffer to be written.
45 @param NumberOfBytes Number of bytes to written to the serial device.
46
47 @retval 0 NumberOfBytes is 0.
48 @retval >0 The number of bytes written to the serial device.
49 If this value is less than NumberOfBytes, then the read operation failed.
50
51 **/
52 UINTN
53 EFIAPI
54 SerialPortWrite (
55 IN UINT8 *Buffer,
56 IN UINTN NumberOfBytes
57 );
58
59
60 /**
61 Read data from serial device and save the datas in buffer.
62
63 Reads NumberOfBytes data bytes from a serial device into the buffer
64 specified by Buffer. The number of bytes actually read is returned.
65 If the return value is less than NumberOfBytes, then the rest operation failed.
66 If Buffer is NULL, then ASSERT().
67 If NumberOfBytes is zero, then return 0.
68
69 @param Buffer Pointer to the data buffer to store the data read from the serial device.
70 @param NumberOfBytes Number of bytes which will be read.
71
72 @retval 0 Read data failed, no data is to be read.
73 @retval >0 Actual number of bytes read from serial device.
74
75 **/
76 UINTN
77 EFIAPI
78 SerialPortRead (
79 OUT UINT8 *Buffer,
80 IN UINTN NumberOfBytes
81 );
82
83 /**
84 Polls a serial device to see if there is any data waiting to be read.
85
86 Polls a serial device to see if there is any data waiting to be read.
87 If there is data waiting to be read from the serial device, then TRUE is returned.
88 If there is no data waiting to be read from the serial device, then FALSE is returned.
89
90 @retval TRUE Data is waiting to be read from the serial device.
91 @retval FALSE There is no data waiting to be read from the serial device.
92
93 **/
94 BOOLEAN
95 EFIAPI
96 SerialPortPoll (
97 VOID
98 );
99
100 #endif