]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/SerialPortLib.h
19d6094140c44b6fb7718e95ca049bd5d5057ece
[mirror_edk2.git] / MdePkg / Include / Library / SerialPortLib.h
1 /** @file
2 Serial I/O Port library functions definition.
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 successfuly 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 serail 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
42 If Buffer is NULL, then ASSERT().
43
44 If NumberOfBytes is zero, then return 0.
45
46 @param Buffer Pointer to the data buffer to be written.
47 @param NumberOfBytes Number of bytes to written to the serial device.
48
49 @retval 0 NumberOfBytes is 0.
50 @retval >0 The number of bytes written to the serial device.
51 If this value is less than NumberOfBytes, then the read operation failed.
52
53 **/
54 UINTN
55 EFIAPI
56 SerialPortWrite (
57 IN UINT8 *Buffer,
58 IN UINTN NumberOfBytes
59 );
60
61
62 /**
63 Read data from serial device and save the datas in buffer.
64
65 Reads NumberOfBytes data bytes from a serial device into the buffer
66 specified by Buffer. The number of bytes actually read is returned.
67 If the return value is less than NumberOfBytes, then the rest operation failed.
68
69 If Buffer is NULL, then ASSERT().
70
71 If NumberOfBytes is zero, then return 0.
72
73 @param Buffer Pointer to the data buffer to store the data read from the serial device.
74 @param NumberOfBytes Number of bytes which will be read.
75
76 @retval 0 Read data failed, No data is to be read.
77 @retval !0 Aactual number of bytes read from serial device.
78
79 **/
80 UINTN
81 EFIAPI
82 SerialPortRead (
83 OUT UINT8 *Buffer,
84 IN UINTN NumberOfBytes
85 );
86
87 /**
88 Polls a serial device to see if there is any data waiting to be read.
89
90 Polls aserial device to see if there is any data waiting to be read.
91 If there is data waiting to be read from the serial device, then TRUE is returned.
92 If there is no data waiting to be read from the serial device, then FALSE is returned.
93
94 @retval TRUE Data is waiting to be read from the serial device.
95 @retval FALSE There is no data waiting to be read from the serial device.
96
97 **/
98 BOOLEAN
99 EFIAPI
100 SerialPortPoll (
101 VOID
102 );
103
104 #endif