]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/ResetVector/SerialDebug.asm
Add initial version of Open Virtual Machine Firmware (OVMF) platform.
[mirror_edk2.git] / OvmfPkg / ResetVector / SerialDebug.asm
1 ;------------------------------------------------------------------------------
2 ;
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
8 ;
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.
11 ;
12 ; Module Name:
13 ;
14 ; SerialDebug.asm
15 ;
16 ; Abstract:
17 ;
18 ; Serial port support macros
19 ;
20 ;------------------------------------------------------------------------------
21
22 BITS 16
23
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
40
41 ;//---------------------------------------------
42 ;// UART Register Bit Defines
43 ;//---------------------------------------------
44 %define LSR_TXRDY 0x20
45 %define LSR_RXDA 0x01
46 %define DLAB 0x01
47
48 ; UINT16 gComBase = 0x3f8;
49 ; UINTN gBps = 115200;
50 ; UINT8 gData = 8;
51 ; UINT8 gStop = 1;
52 ; UINT8 gParity = 0;
53 ; UINT8 gBreakSet = 0;
54
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
61
62 %define SERIAL_DEFAULT_LCR ( \
63 (DEFAULT_BREAK_SET << 6) | \
64 (DEFAULT_PARITY << 3) | \
65 (DEFAULT_STOP << 2) | \
66 (DEFAULT_DATA - 5) \
67 )
68
69 %define SERIAL_PORT_IO_BASE_ADDRESS DEFAULT_COM_BASE
70
71 %macro inFromSerialPort 1
72 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
73 in al, dx
74 %endmacro
75
76 %macro waitForSerialTxReady 0
77
78 %%waitingForTx:
79 inFromSerialPort LSR_OFFSET
80 test al, LSR_TXRDY
81 jz %%waitingForTx
82
83 %endmacro
84
85 %macro outToSerialPort 2
86 mov dx, (SERIAL_PORT_IO_BASE_ADDRESS + %1)
87 mov al, %2
88 out dx, al
89 %endmacro
90
91 %macro writeToSerialPort 1
92 waitForSerialTxReady
93 outToSerialPort 0, %1
94 %endmacro
95
96 real16InitSerialPort:
97 ;
98 ; Set communications format
99 ;
100 outToSerialPort LCR_OFFSET, ((DLAB << 7) | SERIAL_DEFAULT_LCR)
101
102 ;
103 ; Configure baud rate
104 ;
105 outToSerialPort BAUD_HIGH_OFFSET, ((115200 / DEFAULT_BPS) >> 8)
106 outToSerialPort BAUD_LOW_OFFSET, ((115200 / DEFAULT_BPS) & 0xff)
107
108 ;
109 ; Switch back to bank 0
110 ;
111 outToSerialPort LCR_OFFSET, SERIAL_DEFAULT_LCR
112
113 jmp real16SerialPortInitReturn
114