OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 #ifndef VBOOT_REFERENCE_CGPT_INTERNAL_H_ | 6 #ifndef VBOOT_REFERENCE_CGPT_INTERNAL_H_ |
7 #define VBOOT_REFERENCE_CGPT_INTERNAL_H_ | 7 #define VBOOT_REFERENCE_CGPT_INTERNAL_H_ |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include "cgpt.h" | 10 #include "cgpt.h" |
11 | 11 |
12 /* Internal use only. | |
13 * Don't use them unless you know what you are doing. */ | |
14 int CheckParameters(GptData *gpt); | 12 int CheckParameters(GptData *gpt); |
15 uint32_t CheckHeaderSignature(GptData *gpt); | 13 uint32_t CheckHeaderSignature(GptData *gpt); |
16 uint32_t CheckRevision(GptData *gpt); | 14 uint32_t CheckRevision(GptData *gpt); |
17 uint32_t CheckSize(GptData *gpt); | 15 uint32_t CheckSize(GptData *gpt); |
18 uint32_t CheckReservedFields(GptData *gpt); | 16 uint32_t CheckReservedFields(GptData *gpt); |
19 uint32_t CheckMyLba(GptData *gpt); | 17 uint32_t CheckMyLba(GptData *gpt); |
20 uint32_t CheckSizeOfPartitionEntry(GptData *gpt); | 18 uint32_t CheckSizeOfPartitionEntry(GptData *gpt); |
21 uint32_t CheckNumberOfEntries(GptData *gpt); | 19 uint32_t CheckNumberOfEntries(GptData *gpt); |
22 uint32_t CheckEntriesLba(GptData *gpt); | 20 uint32_t CheckEntriesLba(GptData *gpt); |
23 uint32_t CheckValidUsableLbas(GptData *gpt); | 21 uint32_t CheckValidUsableLbas(GptData *gpt); |
24 uint32_t CheckHeaderCrc(GptData *gpt); | 22 uint32_t CheckHeaderCrc(GptData *gpt); |
25 uint32_t CheckEntriesCrc(GptData *gpt); | 23 uint32_t CheckEntriesCrc(GptData *gpt); |
26 uint32_t CheckValidEntries(GptData *gpt); | 24 uint32_t CheckValidEntries(GptData *gpt); |
27 int OverlappedEntries(GptEntry *entries, uint32_t number_of_entries); | 25 int OverlappedEntries(GptEntry *entries, uint32_t number_of_entries); |
28 uint32_t CheckOverlappedPartition(GptData *gpt); | 26 uint32_t CheckOverlappedPartition(GptData *gpt); |
29 uint8_t RepairEntries(GptData *gpt, const uint32_t valid_entries); | 27 uint8_t RepairEntries(GptData *gpt, const uint32_t valid_entries); |
30 uint8_t RepairHeader(GptData *gpt, const uint32_t valid_headers); | 28 uint8_t RepairHeader(GptData *gpt, const uint32_t valid_headers); |
31 typedef struct { | 29 typedef struct { |
32 uint64_t starting; | 30 uint64_t starting; |
33 uint64_t ending; | 31 uint64_t ending; |
34 } pair_t; | 32 } pair_t; |
35 | 33 |
| 34 GptEntry *GetEntry(GptData *gpt, int secondary, int entry_index); |
| 35 void SetPriority(GptData *gpt, int secondary, int entry_index, int priority); |
| 36 int GetPriority(GptData *gpt, int secondary, int entry_index); |
| 37 void SetBad(GptData *gpt, int secondary, int entry_index, int bad); |
| 38 int GetBad(GptData *gpt, int secondary, int entry_index); |
| 39 void SetTries(GptData *gpt, int secondary, int entry_index, int tries); |
| 40 int GetTries(GptData *gpt, int secondary, int entry_index); |
| 41 void SetSuccess(GptData *gpt, int secondary, int entry_index, int success); |
| 42 int GetSuccess(GptData *gpt, int secondary, int entry_index); |
| 43 |
| 44 /* If gpt->current_kernel is this value, means either: |
| 45 * 1. an initial value before scanning GPT entries, |
| 46 * 2. after scanning, no any valid kernel is found. |
| 47 */ |
| 48 #define CGPT_KERNEL_ENTRY_NOT_FOUND (-1) |
| 49 |
| 50 /* Bit definitions and masks for GPT attributes. |
| 51 * |
| 52 * 63 -- do not automounting |
| 53 * 62 -- hidden |
| 54 * 60 -- read-only |
| 55 * : |
| 56 * 57 -- bad kernel entry |
| 57 * 56 -- success |
| 58 * 55,52 -- tries |
| 59 * 51,48 -- priority |
| 60 * 0 -- system partition |
| 61 */ |
| 62 #define CGPT_ATTRIBUTE_BAD_OFFSET 57 |
| 63 #define CGPT_ATTRIBUTE_MAX_BAD (1ULL) |
| 64 #define CGPT_ATTRIBUTE_BAD_MASK (CGPT_ATTRIBUTE_MAX_BAD << \ |
| 65 CGPT_ATTRIBUTE_BAD_OFFSET) |
| 66 |
| 67 #define CGPT_ATTRIBUTE_SUCCESS_OFFSET 56 |
| 68 #define CGPT_ATTRIBUTE_MAX_SUCCESS (1ULL) |
| 69 #define CGPT_ATTRIBUTE_SUCCESS_MASK (CGPT_ATTRIBUTE_MAX_SUCCESS << \ |
| 70 CGPT_ATTRIBUTE_SUCCESS_OFFSET) |
| 71 |
| 72 #define CGPT_ATTRIBUTE_TRIES_OFFSET 52 |
| 73 #define CGPT_ATTRIBUTE_MAX_TRIES (15ULL) |
| 74 #define CGPT_ATTRIBUTE_TRIES_MASK (CGPT_ATTRIBUTE_MAX_TRIES << \ |
| 75 CGPT_ATTRIBUTE_TRIES_OFFSET) |
| 76 |
| 77 #define CGPT_ATTRIBUTE_PRIORITY_OFFSET 48 |
| 78 #define CGPT_ATTRIBUTE_MAX_PRIORITY (15ULL) |
| 79 #define CGPT_ATTRIBUTE_PRIORITY_MASK (CGPT_ATTRIBUTE_MAX_PRIORITY << \ |
| 80 CGPT_ATTRIBUTE_PRIORITY_OFFSET) |
| 81 |
36 #endif /* VBOOT_REFERENCE_CGPT_INTERNAL_H_ */ | 82 #endif /* VBOOT_REFERENCE_CGPT_INTERNAL_H_ */ |
OLD | NEW |