1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #include "types.h" 19 20 #ifndef __BLOCK_IO_PROTOCOL_H__ 21 #define __BLOCK_IO_PROTOCOL_H__ 22 23 typedef struct EfiBlockIoMedia EfiBlockIoMedia; 24 typedef struct EfiBlockIoProtocol EfiBlockIoProtocol; 25 26 struct EfiBlockIoProtocol { 27 uint64_t revision; 28 EfiBlockIoMedia* media; 29 EfiStatus (*reset)(EfiBlockIoProtocol* self, bool extended_verification); 30 EfiStatus (*read_blocks)(EfiBlockIoProtocol* self, uint32_t media_id, uint64_t lba, 31 size_t buffer_size, void* buffer); 32 EfiStatus (*write_blocks)(EfiBlockIoProtocol* self, uint32_t media_id, uint64_t lba, 33 size_t buffer_size, void* buffer); 34 EfiStatus (*flush_blocks)(EfiBlockIoProtocol* self); 35 }; 36 37 struct EfiBlockIoMedia { 38 // present in rev1 39 uint32_t media_id; 40 bool removable_media; 41 bool media_present; 42 bool logical_partition; 43 bool read_only; 44 bool write_caching; 45 uint32_t block_size; 46 uint32_t io_align; 47 uint64_t last_block; 48 49 // present in rev2 50 uint64_t lowest_aligned_lba; 51 uint32_t logical_blocks_per_physical_block; 52 53 // present in rev3 54 uint32_t optimal_transfer_length_granularity; 55 }; 56 57 #endif //__BLOCK_IO_PROTOCOL_H__ 58