xref: /haiku/headers/private/kernel/platform/efi/protocol/serial-io.h (revision 1a3518cf757c2da8006753f83962da5935bbc82b)
1 // Copyright 2016-2019 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include <efi/types.h>
8 #include <efi/boot-services.h>
9 #include <efi/runtime-services.h>
10 
11 #define EFI_SERIAL_IO_PROTOCOL_GUID \
12     {0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD}}
13 
14 extern efi_guid SerialIoProtocol;
15 
16 #define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000
17 
18 typedef struct efi_serial_io_protocol efi_serial_io_protocol;
19 
20 typedef struct {
21     uint32_t ControlMask;
22 
23     // current Attributes
24     uint32_t Timeout;
25     uint64_t BaudRate;
26     uint32_t ReceiveFifoDepth;
27     uint32_t DataBits;
28     uint32_t Parity;
29     uint32_t StopBits;
30 } efi_serial_io_mode;
31 
32 typedef enum {
33     DefaultParity,
34     NoParity,
35     EvenParity,
36     OddParity,
37     MarkParity,
38     SpaceParity
39 } efi_parity_type;
40 
41 typedef enum {
42     DefaultStopBits,
43     OneStopBit,
44     OneFiveStopBits,
45     TwoStopBits
46 } efi_stop_bits_type;
47 
48 
49 typedef struct efi_serial_io_protocol {
50     uint32_t Revision;
51 
52     efi_status (*Reset)(efi_serial_io_protocol* self) EFIAPI;
53     efi_status (*SetAttributes)(efi_serial_io_protocol* self,
54                                 uint64_t BaudRate, uint32_t ReceiveFifoDepth,
55                                 uint32_t Timeout, efi_parity_type Parity,
56                                 uint8_t DataBits, efi_stop_bits_type StopBits) EFIAPI;
57     efi_status (*SetControl)(efi_serial_io_protocol* self,
58                              uint32_t Control) EFIAPI;
59     efi_status (*GetControl)(efi_serial_io_protocol* self,
60                              uint32_t* Control) EFIAPI;
61     efi_status (*Write)(efi_serial_io_protocol* self,
62                         size_t* BufferSize, void* Buffer) EFIAPI;
63     efi_status (*Read)(efi_serial_io_protocol* self,
64                        size_t* BufferSize, void* Buffer) EFIAPI;
65 
66     efi_serial_io_mode* Mode;
67 } efi_serial_io_protocol;
68