1 ;------------------------------------------------------------------------------
3 ; Serial port debug support macros
5 ; Copyright (c) 2008 - 2009, Intel Corporation
6 ; All rights reserved. This program and the accompanying materials
7 ; are licensed and made available under the terms and conditions of the BSD License
8 ; which accompanies this distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 ;------------------------------------------------------------------------------
16 ;//---------------------------------------------
17 ;// UART Register Offsets
18 ;//---------------------------------------------
19 %define BAUD_LOW_OFFSET 0x00
20 %define BAUD_HIGH_OFFSET 0x01
21 %define IER_OFFSET 0x01
22 %define LCR_SHADOW_OFFSET 0x01
23 %define FCR_SHADOW_OFFSET 0x02
24 %define IR_CONTROL_OFFSET 0x02
25 %define FCR_OFFSET 0x02
26 %define EIR_OFFSET 0x02
27 %define BSR_OFFSET 0x03
28 %define LCR_OFFSET 0x03
29 %define MCR_OFFSET 0x04
30 %define LSR_OFFSET 0x05
31 %define MSR_OFFSET 0x06
33 ;//---------------------------------------------
34 ;// UART Register Bit Defines
35 ;//---------------------------------------------
36 %define LSR_TXRDY 0x20
40 ; UINT16 gComBase = 0x3f8;
41 ; UINTN gBps = 115200;
45 ; UINT8 gBreakSet = 0;
47 %define DEFAULT_COM_BASE 0x3f8
48 %define DEFAULT_BPS 115200
49 %define DEFAULT_DATA 8
50 %define DEFAULT_STOP 1
51 %define DEFAULT_PARITY 0
52 %define DEFAULT_BREAK_SET 0
54 %define SERIAL_DEFAULT_LCR ( \
55 (DEFAULT_BREAK_SET << 6) | \
56 (DEFAULT_PARITY << 3) | \
57 (DEFAULT_STOP << 2) | \
61 %define SERIAL_PORT_IO_BASE_ADDRESS DEFAULT_COM_BASE
63 %macro inFromSerialPort 1
64 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
68 %macro waitForSerialTxReady 0
71 inFromSerialPort LSR_OFFSET
77 %macro outToSerialPort 2
78 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
83 %macro debugShowCharacter 1
88 %macro debugShowHexDigit 1
90 debugShowCharacter BYTE ('0' + (%1))
92 debugShowCharacter BYTE ('a' + ((%1) - 0xa))
97 debugShowCharacter `\r`
98 debugShowCharacter `\n`
101 %macro debugShowPostCode 1
102 debugShowHexDigit (((%1) >> 4) & 0xf)
103 debugShowHexDigit ((%1) & 0xf)
109 %macro debugInitialize 0
111 real16InitDebugReturn:
116 ; Set communications format
118 outToSerialPort LCR_OFFSET, ((DLAB << 7) | SERIAL_DEFAULT_LCR)
121 ; Configure baud rate
123 outToSerialPort BAUD_HIGH_OFFSET, ((115200 / DEFAULT_BPS) >> 8)
124 outToSerialPort BAUD_LOW_OFFSET, ((115200 / DEFAULT_BPS) & 0xff)
127 ; Switch back to bank 0
129 outToSerialPort LCR_OFFSET, SERIAL_DEFAULT_LCR
131 jmp real16InitDebugReturn