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_TERMINAL_DEVICE_TYPE_GUID \ 17 {0x6ad9a60f, 0x5815, 0x4c7c, {0x8A, 0x10, 0x50, 0x53, 0xD2, 0xBF, 0x7A, 0x1B}} 18 19 20 #define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000 21 #define EFI_SERIAL_IO_PROTOCOL_REVISION1p1 0x00010001 22 23 // 24 // Control bits. 25 // 26 #define EFI_SERIAL_CLEAR_TO_SEND 0x0010 27 #define EFI_SERIAL_DATA_SET_READY 0x0020 28 #define EFI_SERIAL_RING_INDICATE 0x0040 29 #define EFI_SERIAL_CARRIER_DETECT 0x0080 30 #define EFI_SERIAL_REQUEST_TO_SEND 0x0002 31 #define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 32 #define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 33 #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 34 #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 35 #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 36 #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 37 38 typedef struct efi_serial_io_protocol efi_serial_io_protocol; 39 40 typedef struct { 41 uint32_t ControlMask; 42 43 // current Attributes 44 uint32_t Timeout; 45 uint64_t BaudRate; 46 uint32_t ReceiveFifoDepth; 47 uint32_t DataBits; 48 uint32_t Parity; 49 uint32_t StopBits; 50 } efi_serial_io_mode; 51 52 typedef enum { 53 DefaultParity, 54 NoParity, 55 EvenParity, 56 OddParity, 57 MarkParity, 58 SpaceParity 59 } efi_parity_type; 60 61 typedef enum { 62 DefaultStopBits, 63 OneStopBit, 64 OneFiveStopBits, 65 TwoStopBits 66 } efi_stop_bits_type; 67 68 69 typedef struct efi_serial_io_protocol { 70 uint32_t Revision; 71 72 efi_status (*Reset)(efi_serial_io_protocol* self) EFIAPI; 73 efi_status (*SetAttributes)(efi_serial_io_protocol* self, 74 uint64_t BaudRate, uint32_t ReceiveFifoDepth, 75 uint32_t Timeout, efi_parity_type Parity, 76 uint8_t DataBits, efi_stop_bits_type StopBits) EFIAPI; 77 efi_status (*SetControl)(efi_serial_io_protocol* self, 78 uint32_t Control) EFIAPI; 79 efi_status (*GetControl)(efi_serial_io_protocol* self, 80 uint32_t* Control) EFIAPI; 81 efi_status (*Write)(efi_serial_io_protocol* self, 82 size_t* BufferSize, void* Buffer) EFIAPI; 83 efi_status (*Read)(efi_serial_io_protocol* self, 84 size_t* BufferSize, void* Buffer) EFIAPI; 85 86 efi_serial_io_mode* Mode; 87 const struct elf_guid* DeviceTypeGuid; // Revision 1.1 88 } efi_serial_io_protocol; 89