2 Debug Communication Library definitions.
4 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
5 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.
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.
15 #ifndef __DEBUG_COMMUNICATION_LIB_H__
16 #define __DEBUG_COMMUNICATION_LIB_H__
18 typedef VOID
* DEBUG_PORT_HANDLE
;
21 Caller provided function to be invoked at the end of DebugPortInitialize().
23 Refer to the description for DebugPortInitialize() for more details.
25 @param[in] Context The first input argument of DebugPortInitialize().
26 @param[in] DebugPortHandle Debug port handle created by Debug Communication Library.
31 (EFIAPI
* DEBUG_PORT_CONTINUE
)(
33 IN DEBUG_PORT_HANDLE DebugPortHandle
37 Initialize the debug port.
39 This function will initialize debug port to get it ready for data transmition. If
40 certain Debug Communication Library instance has to save some private data in the
41 stack, this function must work on the mode that doesn't return to the caller, then
42 the caller needs to wrap up all rest of logic after DebugPortInitialize() into one
43 function and pass it into DebugPortInitialize(). DebugPortInitialize() is
44 responsible to invoke the passing-in function at the end of DebugPortInitialize().
46 If the parameter Function is not NULL, Debug Communication Library instance will
47 invoke it by passing in the Context to be the first parameter. Debug Communication
48 Library instance could create one debug port handle to be the second parameter
49 passing into the Function. Debug Communication Library instance also could pass
50 NULL to be the second parameter if it doesn't create the debug port handle.
52 If the parameter Function is NULL, and Context is not NULL. At this time, Context
53 is the debug port handle created by the previous Debug Communication Library
55 a) If the instance can understand and continue use the private data of the previous
56 instance, it could return the same handle as passed in (as Context parameter).
57 b) If the instance does not understand, or does not want to continue use the
58 private data of the previous instance, it could ignore the input Context parameter
59 and create the new handle to be returned.
61 If Function() is NULL and Context is NULL, Debug Communication Library could create a
62 new handle and return it. NULL is also a valid handle to be returned.
64 @param[in] Context Context needed by callback function; it was optional.
65 @param[in] Function Continue function called by Debug Communication library;
68 @return The debug port handle created by Debug Communication Library if Function
76 IN DEBUG_PORT_CONTINUE Function
81 Read data from debug device and save the datas in buffer.
83 Reads NumberOfBytes data bytes from a debug device into the buffer
84 specified by Buffer. The number of bytes actually read is returned.
85 If the return value is less than NumberOfBytes, then the rest operation failed.
86 If NumberOfBytes is zero, then return 0.
88 @param Handle Debug port handle.
89 @param Buffer Pointer to the data buffer to store the data read from the debug device.
90 @param NumberOfBytes Number of bytes which will be read.
91 @param Timeout Timeout value for reading from debug device. It unit is Microsecond.
93 @retval 0 Read data failed, no data is to be read.
94 @retval >0 Actual number of bytes read from debug device.
100 IN DEBUG_PORT_HANDLE Handle
,
102 IN UINTN NumberOfBytes
,
108 Write data from buffer to debug device.
110 Writes NumberOfBytes data bytes from Buffer to the debug device.
111 The number of bytes actually written to the debug device is returned.
112 If the return value is less than NumberOfBytes, then the write operation failed.
113 If NumberOfBytes is zero, then return 0.
115 @param Handle Debug port handle.
116 @param Buffer Pointer to the data buffer to be written.
117 @param NumberOfBytes Number of bytes to written to the debug device.
119 @retval 0 NumberOfBytes is 0.
120 @retval >0 The number of bytes written to the debug device.
121 If this value is less than NumberOfBytes, then the read operation failed.
126 DebugPortWriteBuffer (
127 IN DEBUG_PORT_HANDLE Handle
,
129 IN UINTN NumberOfBytes
133 Polls a debug device to see if there is any data waiting to be read.
135 Polls a debug device to see if there is any data waiting to be read.
136 If there is data waiting to be read from the debug device, then TRUE is returned.
137 If there is no data waiting to be read from the debug device, then FALSE is returned.
139 @param Handle Debug port handle.
141 @retval TRUE Data is waiting to be read from the debug device.
142 @retval FALSE There is no data waiting to be read from the serial device.
147 DebugPortPollBuffer (
148 IN DEBUG_PORT_HANDLE Handle