HyperDbg Debugger
Loading...
Searching...
No Matches
uartp.h File Reference

Go to the source code of this file.

Macros

#define SET_FLAGS(_x, _f)   ((_x) |= (_f))
 
#define CLEAR_FLAGS(_x, _f)   ((_x) &= ~(_f))
 
#define CLEAR_OTHER_FLAGS(_x, _f)   ((_x) &= (_f))
 
#define CHECK_FLAG(_x, _f)   ((_x) & (_f))
 
#define READ_PORT_UCHAR   UartHardwareAccess.ReadPort8
 
#define WRITE_PORT_UCHAR   UartHardwareAccess.WritePort8
 
#define READ_PORT_USHORT   UartHardwareAccess.ReadPort16
 
#define WRITE_PORT_USHORT   UartHardwareAccess.WritePort16
 
#define READ_PORT_ULONG   UartHardwareAccess.ReadPort32
 
#define WRITE_PORT_ULONG   UartHardwareAccess.WritePort32
 
#define READ_REGISTER_UCHAR   UartHardwareAccess.ReadRegister8
 
#define WRITE_REGISTER_UCHAR   UartHardwareAccess.WriteRegister8
 
#define READ_REGISTER_USHORT   UartHardwareAccess.ReadRegister16
 
#define WRITE_REGISTER_USHORT   UartHardwareAccess.WriteRegister16
 
#define READ_REGISTER_ULONG   UartHardwareAccess.ReadRegister32
 
#define WRITE_REGISTER_ULONG   UartHardwareAccess.WriteRegister32
 
#define READ_REGISTER_ULONG64   UartHardwareAccess.ReadRegister64
 
#define WRITE_REGISTER_ULONG64   UartHardwareAccess.WriteRegister64
 

Typedefs

typedef enum _ACPI_GENERIC_ACCESS_SIZE ACPI_GENERIC_ACCESS_SIZE
 
typedef enum _ACPI_GENERIC_ACCESS_SIZEPACPI_GENERIC_ACCESS_SIZE
 

Enumerations

enum  _ACPI_GENERIC_ACCESS_SIZE {
  AcpiGenericAccessSizeLegacy = 0 , AcpiGenericAccessSizeByte , AcpiGenericAccessSizeWord , AcpiGenericAccessSizeDWord ,
  AcpiGenericAccessSizeQWord
}
 

Functions

BOOLEAN UartpSetAccess (_Inout_ PCPPORT Port, const BOOLEAN MemoryMapped, const UCHAR AccessSize, const UCHAR BitWidth)
 

Variables

UART_HARDWARE_ACCESS UartHardwareAccess
 

Macro Definition Documentation

◆ CHECK_FLAG

#define CHECK_FLAG ( _x,
_f )   ((_x) & (_f))

◆ CLEAR_FLAGS

#define CLEAR_FLAGS ( _x,
_f )   ((_x) &= ~(_f))

◆ CLEAR_OTHER_FLAGS

#define CLEAR_OTHER_FLAGS ( _x,
_f )   ((_x) &= (_f))

◆ READ_PORT_UCHAR

#define READ_PORT_UCHAR   UartHardwareAccess.ReadPort8

◆ READ_PORT_ULONG

#define READ_PORT_ULONG   UartHardwareAccess.ReadPort32

◆ READ_PORT_USHORT

#define READ_PORT_USHORT   UartHardwareAccess.ReadPort16

◆ READ_REGISTER_UCHAR

#define READ_REGISTER_UCHAR   UartHardwareAccess.ReadRegister8

◆ READ_REGISTER_ULONG

#define READ_REGISTER_ULONG   UartHardwareAccess.ReadRegister32

◆ READ_REGISTER_ULONG64

#define READ_REGISTER_ULONG64   UartHardwareAccess.ReadRegister64

◆ READ_REGISTER_USHORT

#define READ_REGISTER_USHORT   UartHardwareAccess.ReadRegister16

◆ SET_FLAGS

#define SET_FLAGS ( _x,
_f )   ((_x) |= (_f))

◆ WRITE_PORT_UCHAR

#define WRITE_PORT_UCHAR   UartHardwareAccess.WritePort8

◆ WRITE_PORT_ULONG

#define WRITE_PORT_ULONG   UartHardwareAccess.WritePort32

◆ WRITE_PORT_USHORT

#define WRITE_PORT_USHORT   UartHardwareAccess.WritePort16

◆ WRITE_REGISTER_UCHAR

#define WRITE_REGISTER_UCHAR   UartHardwareAccess.WriteRegister8

◆ WRITE_REGISTER_ULONG

#define WRITE_REGISTER_ULONG   UartHardwareAccess.WriteRegister32

◆ WRITE_REGISTER_ULONG64

#define WRITE_REGISTER_ULONG64   UartHardwareAccess.WriteRegister64

◆ WRITE_REGISTER_USHORT

#define WRITE_REGISTER_USHORT   UartHardwareAccess.WriteRegister16

Typedef Documentation

◆ ACPI_GENERIC_ACCESS_SIZE

◆ PACPI_GENERIC_ACCESS_SIZE

Enumeration Type Documentation

◆ _ACPI_GENERIC_ACCESS_SIZE

Enumerator
AcpiGenericAccessSizeLegacy 
AcpiGenericAccessSizeByte 
AcpiGenericAccessSizeWord 
AcpiGenericAccessSizeDWord 
AcpiGenericAccessSizeQWord 
49{
enum _ACPI_GENERIC_ACCESS_SIZE ACPI_GENERIC_ACCESS_SIZE
@ AcpiGenericAccessSizeByte
Definition uartp.h:51
@ AcpiGenericAccessSizeLegacy
Definition uartp.h:50
@ AcpiGenericAccessSizeWord
Definition uartp.h:52
@ AcpiGenericAccessSizeQWord
Definition uartp.h:54
@ AcpiGenericAccessSizeDWord
Definition uartp.h:53

Function Documentation

◆ UartpSetAccess()

BOOLEAN UartpSetAccess ( _Inout_ PCPPORT Port,
const BOOLEAN MemoryMapped,
const UCHAR AccessSize,
const UCHAR BitWidth )
255{
256 UCHAR MinRegisterWidth;
257 BOOLEAN PowerOfTwo;
258 UART_HARDWARE_READ_INDEXED_UCHAR ReadFunction;
259 UART_HARDWARE_WRITE_INDEXED_UCHAR WriteFunction;
260
261 MinRegisterWidth = 8;
262
263 //
264 // Select the appropriate port access routines depending upon whether this
265 // serial port is mapped into memory or I/O space.
266 //
267
268 if (MemoryMapped == FALSE)
269 {
270 switch ((ACPI_GENERIC_ACCESS_SIZE)AccessSize)
271 {
272#if defined(_X86_) || defined(_AMD64_)
273
275 __fallthrough;
276
278 WriteFunction = WritePortWithIndex8;
279 ReadFunction = ReadPortWithIndex8;
280 break;
281
283 WriteFunction = WritePortWithIndex16;
284 ReadFunction = ReadPortWithIndex16;
285 MinRegisterWidth = 16;
286 break;
287
289 WriteFunction = WritePortWithIndex32;
290 ReadFunction = ReadPortWithIndex32;
291 MinRegisterWidth = 32;
292 break;
293
294 //
295 // The quad word access size isn't supported for port based I/O.
296 //
297
298#endif
299
300 default:
301 return FALSE;
302 }
303 }
304 else
305 {
306 switch ((ACPI_GENERIC_ACCESS_SIZE)AccessSize)
307 {
309 __fallthrough;
310
312 WriteFunction = WriteRegisterWithIndex8;
313 ReadFunction = ReadRegisterWithIndex8;
314 break;
315
317 WriteFunction = WriteRegisterWithIndex16;
318 ReadFunction = ReadRegisterWithIndex16;
319 MinRegisterWidth = 16;
320 break;
321
323 WriteFunction = WriteRegisterWithIndex32;
324 ReadFunction = ReadRegisterWithIndex32;
325 MinRegisterWidth = 32;
326 break;
327
328#if defined(_WIN64)
329
331 WriteFunction = WriteRegisterWithIndex64;
332 ReadFunction = ReadRegisterWithIndex64;
333 MinRegisterWidth = 64;
334 break;
335
336#endif
337
338 default:
339 return FALSE;
340 }
341 }
342
343 //
344 // Validate BitWidth parameter.
345 //
346
347 PowerOfTwo = ((BitWidth & (BitWidth - 1)) == 0);
348 if ((PowerOfTwo == FALSE) ||
349 (BitWidth < MinRegisterWidth) ||
350 (BitWidth > MAX_REGISTER_WIDTH))
351 {
352 return FALSE;
353 }
354
355 Port->ByteWidth = BitWidth / 8;
356 Port->Write = WriteFunction;
357 Port->Read = ReadFunction;
358 return TRUE;
359}
UCHAR BOOLEAN
Definition BasicTypes.h:39
unsigned char UCHAR
Definition BasicTypes.h:35
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
#define MAX_REGISTER_WIDTH
Definition uartio.c:32

Variable Documentation

◆ UartHardwareAccess

UART_HARDWARE_ACCESS UartHardwareAccess
extern
112 {
113
114#if defined(_X86_)
115
116 ReadPort8,
117 WritePort8,
118 ReadPort16,
119 WritePort16,
120 ReadPort32,
121 WritePort32,
122
123#elif defined(_AMD64_)
124
131
132#else
133
134 NULL,
135 NULL,
136 NULL,
137 NULL,
138 NULL,
139 NULL,
140
141#endif
142
143#if defined(_X86_)
144
145 ReadRegister8,
146 WriteRegister8,
147 ReadRegister16,
148 WriteRegister16,
149 ReadRegister32,
150 WriteRegister32,
151
152#else
153
160
161#endif
162
163#if defined(_WIN64)
164
167
168#else
169
170 NULL,
171 NULL
172
173#endif
174
175};
NULL()
Definition test-case-generator.py:530
#define WRITE_REGISTER_UCHAR
Definition uartp.h:38
#define READ_PORT_ULONG
Definition uartp.h:35
#define WRITE_REGISTER_USHORT
Definition uartp.h:40
#define WRITE_REGISTER_ULONG
Definition uartp.h:42
#define READ_PORT_USHORT
Definition uartp.h:33
#define READ_REGISTER_USHORT
Definition uartp.h:39
#define WRITE_PORT_ULONG
Definition uartp.h:36
#define WRITE_PORT_USHORT
Definition uartp.h:34
#define READ_REGISTER_ULONG64
Definition uartp.h:43
#define READ_REGISTER_UCHAR
Definition uartp.h:37
#define WRITE_PORT_UCHAR
Definition uartp.h:32
#define READ_REGISTER_ULONG
Definition uartp.h:41
#define READ_PORT_UCHAR
Definition uartp.h:31
#define WRITE_REGISTER_ULONG64
Definition uartp.h:44