1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2008, Intel Corporation
4 ; All rights reserved. This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 ; Serial port support macros
20 ;------------------------------------------------------------------------------
24 ;//---------------------------------------------
25 ;// UART Register Offsets
26 ;//---------------------------------------------
27 %define BAUD_LOW_OFFSET 0x00
28 %define BAUD_HIGH_OFFSET 0x01
29 %define IER_OFFSET 0x01
30 %define LCR_SHADOW_OFFSET 0x01
31 %define FCR_SHADOW_OFFSET 0x02
32 %define IR_CONTROL_OFFSET 0x02
33 %define FCR_OFFSET 0x02
34 %define EIR_OFFSET 0x02
35 %define BSR_OFFSET 0x03
36 %define LCR_OFFSET 0x03
37 %define MCR_OFFSET 0x04
38 %define LSR_OFFSET 0x05
39 %define MSR_OFFSET 0x06
41 ;//---------------------------------------------
42 ;// UART Register Bit Defines
43 ;//---------------------------------------------
44 %define LSR_TXRDY 0x20
48 ; UINT16 gComBase = 0x3f8;
49 ; UINTN gBps = 115200;
53 ; UINT8 gBreakSet = 0;
55 %define DEFAULT_COM_BASE 0x3f8
56 %define DEFAULT_BPS 115200
57 %define DEFAULT_DATA 8
58 %define DEFAULT_STOP 1
59 %define DEFAULT_PARITY 0
60 %define DEFAULT_BREAK_SET 0
62 %define SERIAL_DEFAULT_LCR ( \
63 (DEFAULT_BREAK_SET << 6) | \
64 (DEFAULT_PARITY << 3) | \
65 (DEFAULT_STOP << 2) | \
69 %define SERIAL_PORT_IO_BASE_ADDRESS DEFAULT_COM_BASE
71 %macro inFromSerialPort 1
72 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
76 %macro waitForSerialTxReady 0
79 inFromSerialPort LSR_OFFSET
85 %macro outToSerialPort 2
86 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
91 %macro writeToSerialPort 1
98 ; Set communications format
100 outToSerialPort LCR_OFFSET, ((DLAB << 7) | SERIAL_DEFAULT_LCR)
103 ; Configure baud rate
105 outToSerialPort BAUD_HIGH_OFFSET, ((115200 / DEFAULT_BPS) >> 8)
106 outToSerialPort BAUD_LOW_OFFSET, ((115200 / DEFAULT_BPS) & 0xff)
109 ; Switch back to bank 0
111 outToSerialPort LCR_OFFSET, SERIAL_DEFAULT_LCR
113 jmp real16SerialPortInitReturn