Imported Upstream version 3.0
[platform/upstream/gnu-efi.git] / inc / efiser.h
1 #ifndef _EFI_SER_H
2 #define _EFI_SER_H
3
4 /*++
5
6 Copyright (c) 1998  Intel Corporation
7
8 Module Name:
9
10     efiser.h
11
12 Abstract:
13
14     EFI serial protocol
15
16 Revision History
17
18 --*/
19
20 //
21 // Serial protocol
22 //
23
24 #define SERIAL_IO_PROTOCOL \
25     { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} }
26
27 INTERFACE_DECL(_SERIAL_IO_INTERFACE);
28
29 typedef enum {
30     DefaultParity,      
31     NoParity,           
32     EvenParity,
33     OddParity,
34     MarkParity,
35     SpaceParity
36 } EFI_PARITY_TYPE;
37
38 typedef enum {
39     DefaultStopBits,        
40     OneStopBit,         // 1 stop bit
41     OneFiveStopBits,    // 1.5 stop bits
42     TwoStopBits         // 2 stop bits
43 } EFI_STOP_BITS_TYPE;
44
45 #define EFI_SERIAL_CLEAR_TO_SEND                   0x0010  // RO
46 #define EFI_SERIAL_DATA_SET_READY                  0x0020  // RO
47 #define EFI_SERIAL_RING_INDICATE                   0x0040  // RO
48 #define EFI_SERIAL_CARRIER_DETECT                  0x0080  // RO
49 #define EFI_SERIAL_REQUEST_TO_SEND                 0x0002  // WO
50 #define EFI_SERIAL_DATA_TERMINAL_READY             0x0001  // WO
51 #define EFI_SERIAL_INPUT_BUFFER_EMPTY              0x0100  // RO
52 #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY             0x0200  // RO
53 #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE        0x1000  // RW
54 #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE        0x2000  // RW
55 #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE    0x4000  // RW
56
57 typedef
58 EFI_STATUS
59 (EFIAPI *EFI_SERIAL_RESET) (
60     IN struct _SERIAL_IO_INTERFACE  *This
61     );
62
63 typedef
64 EFI_STATUS
65 (EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) (
66     IN struct _SERIAL_IO_INTERFACE  *This,
67     IN UINT64                       BaudRate,
68     IN UINT32                       ReceiveFifoDepth,
69     IN UINT32                       Timeout,
70     IN EFI_PARITY_TYPE              Parity,
71     IN UINT8                        DataBits,
72     IN EFI_STOP_BITS_TYPE           StopBits
73     );
74
75 typedef
76 EFI_STATUS
77 (EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) (
78     IN struct _SERIAL_IO_INTERFACE  *This,
79     IN UINT32                       Control
80     );
81
82 typedef
83 EFI_STATUS
84 (EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) (
85     IN struct _SERIAL_IO_INTERFACE  *This,
86     OUT UINT32                      *Control
87     );
88
89 typedef
90 EFI_STATUS
91 (EFIAPI *EFI_SERIAL_WRITE) (
92     IN struct _SERIAL_IO_INTERFACE  *This,
93     IN OUT UINTN                    *BufferSize,
94     IN VOID                         *Buffer
95     );
96
97 typedef
98 EFI_STATUS
99 (EFIAPI *EFI_SERIAL_READ) (
100     IN struct _SERIAL_IO_INTERFACE  *This,
101     IN OUT UINTN                    *BufferSize,
102     OUT VOID                        *Buffer
103     );
104
105 typedef struct {
106     UINT32                  ControlMask;
107
108     // current Attributes
109     UINT32                  Timeout;
110     UINT64                  BaudRate;
111     UINT32                  ReceiveFifoDepth;
112     UINT32                  DataBits;
113     UINT32                  Parity;
114     UINT32                  StopBits;
115 } SERIAL_IO_MODE;
116
117 #define SERIAL_IO_INTERFACE_REVISION    0x00010000
118
119 typedef struct _SERIAL_IO_INTERFACE {
120     UINT32                       Revision;
121     EFI_SERIAL_RESET             Reset;
122     EFI_SERIAL_SET_ATTRIBUTES    SetAttributes;
123     EFI_SERIAL_SET_CONTROL_BITS  SetControl;
124     EFI_SERIAL_GET_CONTROL_BITS  GetControl;
125     EFI_SERIAL_WRITE             Write;
126     EFI_SERIAL_READ              Read;
127
128     SERIAL_IO_MODE               *Mode;
129 } SERIAL_IO_INTERFACE;
130
131 #endif
132