1 ;------------------------------------------------------------------------------
3 ; Serial port debug support macros
5 ; Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
6 ; SPDX-License-Identifier: BSD-2-Clause-Patent
8 ;------------------------------------------------------------------------------
10 ;//---------------------------------------------
11 ;// UART Register Offsets
12 ;//---------------------------------------------
13 %define BAUD_LOW_OFFSET 0x00
14 %define BAUD_HIGH_OFFSET 0x01
15 %define IER_OFFSET 0x01
16 %define LCR_SHADOW_OFFSET 0x01
17 %define FCR_SHADOW_OFFSET 0x02
18 %define IR_CONTROL_OFFSET 0x02
19 %define FCR_OFFSET 0x02
20 %define EIR_OFFSET 0x02
21 %define BSR_OFFSET 0x03
22 %define LCR_OFFSET 0x03
23 %define MCR_OFFSET 0x04
24 %define LSR_OFFSET 0x05
25 %define MSR_OFFSET 0x06
27 ;//---------------------------------------------
28 ;// UART Register Bit Defines
29 ;//---------------------------------------------
30 %define LSR_TXRDY 0x20
34 ; UINT16 gComBase = 0x3f8;
35 ; UINTN gBps = 115200;
39 ; UINT8 gBreakSet = 0;
41 %define DEFAULT_COM_BASE 0x3f8
42 %define DEFAULT_BPS 115200
43 %define DEFAULT_DATA 8
44 %define DEFAULT_STOP 1
45 %define DEFAULT_PARITY 0
46 %define DEFAULT_BREAK_SET 0
48 %define SERIAL_DEFAULT_LCR ( \
49 (DEFAULT_BREAK_SET << 6) | \
50 (DEFAULT_PARITY << 3) | \
51 (DEFAULT_STOP << 2) | \
55 %define SERIAL_PORT_IO_BASE_ADDRESS DEFAULT_COM_BASE
57 %macro inFromSerialPort 1
58 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
62 %macro waitForSerialTxReady 0
65 inFromSerialPort LSR_OFFSET
71 %macro outToSerialPort 2
72 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
77 %macro debugShowCharacter 1
82 %macro debugShowHexDigit 1
84 debugShowCharacter BYTE ('0' + (%1))
86 debugShowCharacter BYTE ('a' + ((%1) - 0xa))
91 debugShowCharacter `\r`
92 debugShowCharacter `\n`
95 %macro debugShowPostCode 1
96 debugShowHexDigit (((%1) >> 4) & 0xf)
97 debugShowHexDigit ((%1) & 0xf)
103 %macro debugInitialize 0
105 real16InitDebugReturn:
110 ; Set communications format
112 outToSerialPort LCR_OFFSET, ((DLAB << 7) | SERIAL_DEFAULT_LCR)
115 ; Configure baud rate
117 outToSerialPort BAUD_HIGH_OFFSET, ((115200 / DEFAULT_BPS) >> 8)
118 outToSerialPort BAUD_LOW_OFFSET, ((115200 / DEFAULT_BPS) & 0xff)
121 ; Switch back to bank 0
123 outToSerialPort LCR_OFFSET, SERIAL_DEFAULT_LCR
125 jmp real16InitDebugReturn