xref: /freebsd/stand/efi/include/efiser.h (revision 4c9a0adad18263ec8725d9bfc5f560c6ad1da8bd)
1 #ifndef _EFI_SER_H
2 #define _EFI_SER_H
3 
4 /*++
5 
6 Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
7 This software and associated documentation (if any) is furnished
8 under a license and may only be used or copied in accordance
9 with the terms of the license. Except as permitted by such
10 license, no part of this software or documentation may be
11 reproduced, stored in a retrieval system, or transmitted in any
12 form or by any means without the express written consent of
13 Intel Corporation.
14 
15 Module Name:
16 
17     efiser.h
18 
19 Abstract:
20 
21     EFI serial protocol
22 
23 Revision History
24 
25 --*/
26 
27 //
28 // Serial protocol
29 //
30 
31 #define SERIAL_IO_PROTOCOL \
32     { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} }
33 
34 INTERFACE_DECL(_SERIAL_IO_INTERFACE);
35 
36 typedef enum {
37     DefaultParity,
38     NoParity,
39     EvenParity,
40     OddParity,
41     MarkParity,
42     SpaceParity
43 } EFI_PARITY_TYPE;
44 
45 typedef enum {
46     DefaultStopBits,
47     OneStopBit,         // 1 stop bit
48     OneFiveStopBits,    // 1.5 stop bits
49     TwoStopBits         // 2 stop bits
50 } EFI_STOP_BITS_TYPE;
51 
52 #define EFI_SERIAL_CLEAR_TO_SEND                   0x0010  // RO
53 #define EFI_SERIAL_DATA_SET_READY                  0x0020  // RO
54 #define EFI_SERIAL_RING_INDICATE                   0x0040  // RO
55 #define EFI_SERIAL_CARRIER_DETECT                  0x0080  // RO
56 #define EFI_SERIAL_REQUEST_TO_SEND                 0x0002  // WO
57 #define EFI_SERIAL_DATA_TERMINAL_READY             0x0001  // WO
58 #define EFI_SERIAL_INPUT_BUFFER_EMPTY              0x0100  // RO
59 #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY             0x0200  // RO
60 #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE        0x1000  // RW
61 #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE        0x2000  // RW
62 #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE    0x4000  // RW
63 
64 typedef
65 EFI_STATUS
66 (EFIAPI *EFI_SERIAL_RESET) (
67     IN struct _SERIAL_IO_INTERFACE  *This
68     );
69 
70 typedef
71 EFI_STATUS
72 (EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) (
73     IN struct _SERIAL_IO_INTERFACE  *This,
74     IN UINT64                       BaudRate,
75     IN UINT32                       ReceiveFifoDepth,
76     IN UINT32                       Timeout,
77     IN EFI_PARITY_TYPE              Parity,
78     IN UINT8                        DataBits,
79     IN EFI_STOP_BITS_TYPE           StopBits
80     );
81 
82 typedef
83 EFI_STATUS
84 (EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) (
85     IN struct _SERIAL_IO_INTERFACE  *This,
86     IN UINT32                       Control
87     );
88 
89 typedef
90 EFI_STATUS
91 (EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) (
92     IN struct _SERIAL_IO_INTERFACE  *This,
93     OUT UINT32                      *Control
94     );
95 
96 typedef
97 EFI_STATUS
98 (EFIAPI *EFI_SERIAL_WRITE) (
99     IN struct _SERIAL_IO_INTERFACE  *This,
100     IN OUT UINTN                    *BufferSize,
101     IN VOID                         *Buffer
102     );
103 
104 typedef
105 EFI_STATUS
106 (EFIAPI *EFI_SERIAL_READ) (
107     IN struct _SERIAL_IO_INTERFACE  *This,
108     IN OUT UINTN                    *BufferSize,
109     OUT VOID                        *Buffer
110     );
111 
112 typedef struct {
113     UINT32                  ControlMask;
114 
115     // current Attributes
116     UINT32                  Timeout;
117     UINT64                  BaudRate;
118     UINT32                  ReceiveFifoDepth;
119     UINT32                  DataBits;
120     UINT32                  Parity;
121     UINT32                  StopBits;
122 } SERIAL_IO_MODE;
123 
124 #define SERIAL_IO_INTERFACE_REVISION    0x00010000
125 
126 typedef struct _SERIAL_IO_INTERFACE {
127     UINT32                       Revision;
128     EFI_SERIAL_RESET             Reset;
129     EFI_SERIAL_SET_ATTRIBUTES    SetAttributes;
130     EFI_SERIAL_SET_CONTROL_BITS  SetControl;
131     EFI_SERIAL_GET_CONTROL_BITS  GetControl;
132     EFI_SERIAL_WRITE             Write;
133     EFI_SERIAL_READ              Read;
134 
135     SERIAL_IO_MODE               *Mode;
136 } SERIAL_IO_INTERFACE;
137 
138 #endif
139