255{
256 UCHAR MinRegisterWidth;
258 UART_HARDWARE_READ_INDEXED_UCHAR ReadFunction;
259 UART_HARDWARE_WRITE_INDEXED_UCHAR WriteFunction;
260
261 MinRegisterWidth = 8;
262
263
264
265
266
267
268 if (MemoryMapped ==
FALSE)
269 {
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
296
297
298#endif
299
300 default:
302 }
303 }
304 else
305 {
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:
340 }
341 }
342
343
344
345
346
347 PowerOfTwo = ((BitWidth & (BitWidth - 1)) == 0);
348 if ((PowerOfTwo ==
FALSE) ||
349 (BitWidth < MinRegisterWidth) ||
351 {
353 }
354
355 Port->ByteWidth = BitWidth / 8;
356 Port->Write = WriteFunction;
357 Port->Read = ReadFunction;
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
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