RDFU  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
ComPort.c
Go to the documentation of this file.
1 
11 #include "EfiScannerHeaders.h"
12 
13 /*
14  Com1, IRQ 4, address: 3F8
15  Com2, IRQ 3, address: 2F8
16  Com3, IRQ 4, address: 3E8
17  Com4, IRQ 3, address: 2E8
18 */
19 
20 #define LSR_OFFSET 0x05
21 #define LSR_RXDA 0x01
22 #define LSR_TXRDY 0x20
23 
24 #define COM_PORT_ADDRESS1 0x3f8
25 #define COM_PORT_ADDRESS2 0x2f8
26 #define COM_PORT_ADDRESS3 0x3e8
27 #define COM_PORT_ADDRESS4 0x2e8
28 
29 
31 
32 
44 VOID ComInitialize(ULONG ComPortAddr)
45 {
46  if (ComPortAddr)
47  ComPort = ComPortAddr;
48 }
49 
50 
51 
62 {
63  // wait for tx ready
64  while ((ASMReadPortByte(ComPort + LSR_OFFSET) & LSR_TXRDY) == 0);
66 }
67 
68 
78 VOID ComPutString(CHAR8 *String)
79 {
80  while (String[0] != 0)
81  {
82  ComPutChar((UCHAR)String[0]);
83  String++;
84  }
85 }
86 
87 
88 
90 {
91 
92  UINT8 Data;
93  CHAR8 Char;
94  do
95  {
97  } while ((Data & LSR_RXDA) == 0);
98 
99  Char = ASMReadPortByte(ComPort);
100  return Char;
101 }
102 
103 
104 
105