1 /* 2 * Copyright (C) 2020 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 #pragma once 17 18 #include <cstdint> 19 20 inline constexpr int kSectorSizeShift = 9; 21 inline constexpr int kSectorSize = 1 << kSectorSizeShift; 22 23 struct __attribute__((packed)) MbrPartitionEntry { 24 std::uint8_t status; 25 std::uint8_t begin_chs[3]; 26 std::uint8_t partition_type; 27 std::uint8_t end_chs[3]; 28 std::uint32_t first_lba; 29 std::uint32_t num_sectors; 30 }; 31 32 struct __attribute__((packed)) MasterBootRecord { 33 std::uint8_t bootstrap_code[446]; 34 MbrPartitionEntry partitions[4]; 35 std::uint8_t boot_signature[2]; 36 }; 37 38 static_assert(sizeof(MasterBootRecord) == kSectorSize); 39