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