1 // Copyright 2016 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_BLOCK_IO_PROTOCOL_GUID \ 12 {0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} 13 14 extern efi_guid BlockIoProtocol; 15 16 #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001 17 #define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031 18 19 typedef struct efi_block_io_media efi_block_io_media; 20 typedef struct efi_block_io_protocol efi_block_io_protocol; 21 22 struct efi_block_io_protocol { 23 uint64_t Revision; 24 efi_block_io_media* Media; 25 efi_status (*Reset)(efi_block_io_protocol* self, 26 bool ExtendedVerification) EFIAPI; 27 efi_status (*ReadBlocks)(efi_block_io_protocol* self, 28 uint32_t MediaId, uint64_t LBA, 29 size_t BufferSize, void* Buffer) EFIAPI; 30 efi_status (*WriteBlocks)(efi_block_io_protocol* self, 31 uint32_t MediaId, uint64_t LBA, 32 size_t BufferSize, const void* Buffer) EFIAPI; 33 efi_status (*FlushBlocks)(efi_block_io_protocol* self); 34 35 36 }; 37 38 struct efi_block_io_media { 39 // present in rev1 40 uint32_t MediaId; 41 bool RemovableMedia; 42 bool MediaPresent; 43 bool LogicalPartition; 44 bool ReadOnly; 45 bool WriteCaching; 46 uint8_t pad1[3]; 47 uint32_t BlockSize; 48 uint32_t IoAlign; 49 uint8_t pad2[4]; 50 uint64_t LastBlock; 51 52 // present in rev2 53 uint64_t LowestAlignedLba; 54 uint32_t LogicalBlocksPerPhysicalBlock; 55 56 // present in rev3 57 uint32_t OptimalTransferLengthGranularity; 58 }; 59