| 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_CGPTLIB_H_ | 6 #ifndef VBOOT_REFERENCE_CGPTLIB_H_ |
| 7 #define VBOOT_REFERENCE_CGPTLIB_H_ | 7 #define VBOOT_REFERENCE_CGPTLIB_H_ |
| 8 | 8 |
| 9 #include "gpt.h" | 9 #include "gpt.h" |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 * header (size: 16 KB) */ | 79 * header (size: 16 KB) */ |
| 80 uint32_t sector_bytes; /* Size of a LBA sector, in bytes */ | 80 uint32_t sector_bytes; /* Size of a LBA sector, in bytes */ |
| 81 uint64_t drive_sectors; /* Size of drive in LBA sectors, in sectors */ | 81 uint64_t drive_sectors; /* Size of drive in LBA sectors, in sectors */ |
| 82 | 82 |
| 83 /* Outputs */ | 83 /* Outputs */ |
| 84 uint8_t modified; /* Which inputs have been modified? | 84 uint8_t modified; /* Which inputs have been modified? |
| 85 * 0x01 = header1 | 85 * 0x01 = header1 |
| 86 * 0x02 = header2 | 86 * 0x02 = header2 |
| 87 * 0x04 = table1 | 87 * 0x04 = table1 |
| 88 * 0x08 = table2 */ | 88 * 0x08 = table2 */ |
| 89 | |
| 90 /* Internal state */ | |
| 91 int current_kernel; /* the current chromeos kernel index in partition table. | 89 int current_kernel; /* the current chromeos kernel index in partition table. |
| 92 * -1 means not found on drive. */ | 90 * -1 means not found on drive. */ |
| 93 } GptData; | 91 } GptData; |
| 94 | 92 |
| 95 int GptInit(GptData *gpt); | 93 int GptInit(GptData *gpt); |
| 96 /* Initializes the GPT data structure's internal state. The following fields | 94 /* Initializes the GPT data structure's internal state. The following fields |
| 97 * must be filled before calling this function: | 95 * must be filled before calling this function: |
| 98 * | 96 * |
| 99 * primary_header | 97 * primary_header |
| 100 * secondary_header | 98 * secondary_header |
| (...skipping 11 matching lines...) Expand all Loading... |
| 112 * GPT_ERROR_INVALID_ENTRIES, both partition table entries are invalid, enters | 110 * GPT_ERROR_INVALID_ENTRIES, both partition table entries are invalid, enters |
| 113 * recovery mode, | 111 * recovery mode, |
| 114 * GPT_ERROR_INVALID_SECTOR_SIZE, size of a sector is not supported, | 112 * GPT_ERROR_INVALID_SECTOR_SIZE, size of a sector is not supported, |
| 115 * GPT_ERROR_INVALID_SECTOR_NUMBER, number of sectors in drive is invalid (too | 113 * GPT_ERROR_INVALID_SECTOR_NUMBER, number of sectors in drive is invalid (too |
| 116 * small) */ | 114 * small) */ |
| 117 | 115 |
| 118 int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size); | 116 int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size); |
| 119 /* Provides the location of the next kernel partition, in order of decreasing | 117 /* Provides the location of the next kernel partition, in order of decreasing |
| 120 * priority. On return the start_sector parameter contains the LBA sector | 118 * priority. On return the start_sector parameter contains the LBA sector |
| 121 * for the start of the kernel partition, and the size parameter contains the | 119 * for the start of the kernel partition, and the size parameter contains the |
| 122 * size of the kernel partition in LBA sectors. | 120 * size of the kernel partition in LBA sectors. gpt.current_kernel contains |
| 121 * the partition index of the current chromeos kernel partition. |
| 123 * | 122 * |
| 124 * Returns GPT_SUCCESS if successful, else | 123 * Returns GPT_SUCCESS if successful, else |
| 125 * GPT_ERROR_NO_VALID_KERNEL, no avaliable kernel, enters recovery mode */ | 124 * GPT_ERROR_NO_VALID_KERNEL, no avaliable kernel, enters recovery mode */ |
| 126 | 125 |
| 127 int GptUpdateKernelEntry(GptData *gpt, uint32_t update_type); | 126 int GptUpdateKernelEntry(GptData *gpt, uint32_t update_type); |
| 128 /* Updates the kernel entry with the specified index, using the specified type | 127 /* Updates the kernel entry with the specified index, using the specified type |
| 129 * of update (GPT_UPDATE_ENTRY_*). | 128 * of update (GPT_UPDATE_ENTRY_*). |
| 130 * | 129 * |
| 131 * On return the modified field may be set, if the GPT data has been modified | 130 * On return the modified field may be set, if the GPT data has been modified |
| 132 * and should be written to disk. | 131 * and should be written to disk. |
| 133 * | 132 * |
| 134 * Returns GPT_SUCCESS if successful, else | 133 * Returns GPT_SUCCESS if successful, else |
| 135 * GPT_ERROR_INVALID_UPDATE_TYPE, invalid 'update_type' is given. | 134 * GPT_ERROR_INVALID_UPDATE_TYPE, invalid 'update_type' is given. |
| 136 */ | 135 */ |
| 137 | 136 |
| 138 #endif /* VBOOT_REFERENCE_CGPTLIB_H_ */ | 137 #endif /* VBOOT_REFERENCE_CGPTLIB_H_ */ |
| OLD | NEW |