• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 constexpr int SECTOR_SIZE = 512;
19 
20 struct __attribute__((packed)) MbrPartitionEntry {
21   std::uint8_t status;
22   std::uint8_t begin_chs[3];
23   std::uint8_t partition_type;
24   std::uint8_t end_chs[3];
25   std::uint32_t first_lba;
26   std::uint32_t num_sectors;
27 };
28 
29 struct __attribute__((packed)) MasterBootRecord {
30   std::uint8_t bootstrap_code[446];
31   MbrPartitionEntry partitions[4];
32   std::uint8_t boot_signature[2];
33 };
34 
35 static_assert(sizeof(MasterBootRecord) == SECTOR_SIZE);
36