blob: c60820dfccced78a4e8bd5e32191c3c9cec74680 [file] [log] [blame]
Haojian Zhuang91f56462016-07-28 14:19:36 +08001/*
Govindraj Raja998b1e22023-09-21 18:04:00 -05002 * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
Haojian Zhuang91f56462016-07-28 14:19:36 +08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Haojian Zhuang91f56462016-07-28 14:19:36 +08005 */
6
7#include <assert.h>
Manish Pandey9b384b32021-11-12 12:59:09 +00008#include <inttypes.h>
Antonio Nino Diaz00086e32018-08-16 16:46:06 +01009#include <stdio.h>
Haojian Zhuang91f56462016-07-28 14:19:36 +080010#include <string.h>
11
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <common/debug.h>
Rohit Nerc15dcd72022-05-06 07:58:21 +000013#include <common/tf_crc32.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000014#include <drivers/io/io_storage.h>
Sughosh Ganu47b642e2021-11-10 13:00:30 +053015#include <drivers/partition/efi.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000016#include <drivers/partition/partition.h>
17#include <drivers/partition/gpt.h>
18#include <drivers/partition/mbr.h>
19#include <plat/common/platform.h>
20
Haojian Zhuang42a746d2019-09-14 18:01:16 +080021static uint8_t mbr_sector[PLAT_PARTITION_BLOCK_SIZE];
Florian La Roche231c2442019-01-27 14:30:12 +010022static partition_entry_list_t list;
Haojian Zhuang91f56462016-07-28 14:19:36 +080023
24#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
25static void dump_entries(int num)
26{
27 char name[EFI_NAMELEN];
28 int i, j, len;
29
30 VERBOSE("Partition table with %d entries:\n", num);
31 for (i = 0; i < num; i++) {
Antonio Nino Diaz00086e32018-08-16 16:46:06 +010032 len = snprintf(name, EFI_NAMELEN, "%s", list.list[i].name);
Haojian Zhuang91f56462016-07-28 14:19:36 +080033 for (j = 0; j < EFI_NAMELEN - len - 1; j++) {
34 name[len + j] = ' ';
35 }
36 name[EFI_NAMELEN - 1] = '\0';
Manish Pandey9b384b32021-11-12 12:59:09 +000037 VERBOSE("%d: %s %" PRIx64 "-%" PRIx64 "\n", i + 1, name, list.list[i].start,
Haojian Zhuang91f56462016-07-28 14:19:36 +080038 list.list[i].start + list.list[i].length - 4);
39 }
40}
41#else
42#define dump_entries(num) ((void)num)
43#endif
44
45/*
46 * Load the first sector that carries MBR header.
47 * The MBR boot signature should be always valid whether it's MBR or GPT.
48 */
49static int load_mbr_header(uintptr_t image_handle, mbr_entry_t *mbr_entry)
50{
51 size_t bytes_read;
Haojian Zhuang91f56462016-07-28 14:19:36 +080052 int result;
Govindraj Raja998b1e22023-09-21 18:04:00 -050053 mbr_entry_t *tmp;
Haojian Zhuang91f56462016-07-28 14:19:36 +080054
55 assert(mbr_entry != NULL);
56 /* MBR partition table is in LBA0. */
57 result = io_seek(image_handle, IO_SEEK_SET, MBR_OFFSET);
58 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -050059 VERBOSE("Failed to seek (%i)\n", result);
Haojian Zhuang91f56462016-07-28 14:19:36 +080060 return result;
61 }
62 result = io_read(image_handle, (uintptr_t)&mbr_sector,
Haojian Zhuang42a746d2019-09-14 18:01:16 +080063 PLAT_PARTITION_BLOCK_SIZE, &bytes_read);
Govindraj Raja998b1e22023-09-21 18:04:00 -050064 if ((result != 0) || (bytes_read != PLAT_PARTITION_BLOCK_SIZE)) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -050065 VERBOSE("Failed to read data (%i)\n", result);
Haojian Zhuang91f56462016-07-28 14:19:36 +080066 return result;
67 }
68
69 /* Check MBR boot signature. */
Haojian Zhuang42a746d2019-09-14 18:01:16 +080070 if ((mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 2] != MBR_SIGNATURE_FIRST) ||
71 (mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 1] != MBR_SIGNATURE_SECOND)) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -050072 VERBOSE("MBR boot signature failure\n");
Haojian Zhuang91f56462016-07-28 14:19:36 +080073 return -ENOENT;
74 }
Govindraj Raja998b1e22023-09-21 18:04:00 -050075
76 tmp = (mbr_entry_t *)(&mbr_sector[MBR_PRIMARY_ENTRY_OFFSET]);
77
78 if (tmp->first_lba != 1) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -050079 VERBOSE("MBR header may have an invalid first LBA\n");
Govindraj Raja998b1e22023-09-21 18:04:00 -050080 return -EINVAL;
81 }
82
83 if ((tmp->sector_nums == 0) || (tmp->sector_nums == UINT32_MAX)) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -050084 VERBOSE("MBR header entry has an invalid number of sectors\n");
Govindraj Raja998b1e22023-09-21 18:04:00 -050085 return -EINVAL;
86 }
87
88 memcpy(mbr_entry, tmp, sizeof(mbr_entry_t));
Haojian Zhuang91f56462016-07-28 14:19:36 +080089 return 0;
90}
91
92/*
Rohit Nerc15dcd72022-05-06 07:58:21 +000093 * Load GPT header and check the GPT signature and header CRC.
Paul Beesley1fbc97b2019-01-11 18:26:51 +000094 * If partition numbers could be found, check & update it.
Haojian Zhuang91f56462016-07-28 14:19:36 +080095 */
Govindraj Raja998b1e22023-09-21 18:04:00 -050096static int load_gpt_header(uintptr_t image_handle, size_t header_offset,
97 unsigned long long *part_lba)
Haojian Zhuang91f56462016-07-28 14:19:36 +080098{
99 gpt_header_t header;
100 size_t bytes_read;
101 int result;
Rohit Nerc15dcd72022-05-06 07:58:21 +0000102 uint32_t header_crc, calc_crc;
Haojian Zhuang91f56462016-07-28 14:19:36 +0800103
Govindraj Raja998b1e22023-09-21 18:04:00 -0500104 result = io_seek(image_handle, IO_SEEK_SET, header_offset);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800105 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500106 VERBOSE("Failed to seek into the GPT image at offset (%zu)\n",
107 header_offset);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800108 return result;
109 }
110 result = io_read(image_handle, (uintptr_t)&header,
111 sizeof(gpt_header_t), &bytes_read);
112 if ((result != 0) || (sizeof(gpt_header_t) != bytes_read)) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500113 VERBOSE("GPT header read error(%i) or read mismatch occurred,"
114 "expected(%zu) and actual(%zu)\n", result,
115 sizeof(gpt_header_t), bytes_read);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800116 return result;
117 }
118 if (memcmp(header.signature, GPT_SIGNATURE,
Govindraj Raja232a11f2023-10-03 16:39:32 -0500119 sizeof(header.signature)) != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500120 VERBOSE("GPT header signature failure\n");
Haojian Zhuang91f56462016-07-28 14:19:36 +0800121 return -EINVAL;
122 }
123
Rohit Nerc15dcd72022-05-06 07:58:21 +0000124 /*
125 * UEFI Spec 2.8 March 2019 Page 119: HeaderCRC32 value is
126 * computed by setting this field to 0, and computing the
127 * 32-bit CRC for HeaderSize bytes.
128 */
129 header_crc = header.header_crc;
130 header.header_crc = 0U;
131
Govindraj Raja998b1e22023-09-21 18:04:00 -0500132 calc_crc = tf_crc32(0U, (uint8_t *)&header, sizeof(gpt_header_t));
Rohit Nerc15dcd72022-05-06 07:58:21 +0000133 if (header_crc != calc_crc) {
134 ERROR("Invalid GPT Header CRC: Expected 0x%x but got 0x%x.\n",
135 header_crc, calc_crc);
136 return -EINVAL;
137 }
138
139 header.header_crc = header_crc;
140
Haojian Zhuang91f56462016-07-28 14:19:36 +0800141 /* partition numbers can't exceed PLAT_PARTITION_MAX_ENTRIES */
142 list.entry_count = header.list_num;
143 if (list.entry_count > PLAT_PARTITION_MAX_ENTRIES) {
144 list.entry_count = PLAT_PARTITION_MAX_ENTRIES;
145 }
Govindraj Raja998b1e22023-09-21 18:04:00 -0500146
147 *part_lba = header.part_lba;
Haojian Zhuang91f56462016-07-28 14:19:36 +0800148 return 0;
149}
150
Govindraj Raja232a11f2023-10-03 16:39:32 -0500151/*
152 * Load a single MBR entry based on details from MBR header.
153 */
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800154static int load_mbr_entry(uintptr_t image_handle, mbr_entry_t *mbr_entry,
Govindraj Raja998b1e22023-09-21 18:04:00 -0500155 int part_number)
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800156{
157 size_t bytes_read;
158 uintptr_t offset;
159 int result;
160
161 assert(mbr_entry != NULL);
162 /* MBR partition table is in LBA0. */
163 result = io_seek(image_handle, IO_SEEK_SET, MBR_OFFSET);
164 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500165 VERBOSE("Failed to seek (%i)\n", result);
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800166 return result;
167 }
168 result = io_read(image_handle, (uintptr_t)&mbr_sector,
Haojian Zhuang42a746d2019-09-14 18:01:16 +0800169 PLAT_PARTITION_BLOCK_SIZE, &bytes_read);
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800170 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500171 VERBOSE("Failed to read data (%i)\n", result);
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800172 return result;
173 }
174
175 /* Check MBR boot signature. */
Haojian Zhuang42a746d2019-09-14 18:01:16 +0800176 if ((mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 2] != MBR_SIGNATURE_FIRST) ||
177 (mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 1] != MBR_SIGNATURE_SECOND)) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500178 VERBOSE("MBR Entry boot signature failure\n");
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800179 return -ENOENT;
180 }
181 offset = (uintptr_t)&mbr_sector +
182 MBR_PRIMARY_ENTRY_OFFSET +
183 MBR_PRIMARY_ENTRY_SIZE * part_number;
184 memcpy(mbr_entry, (void *)offset, sizeof(mbr_entry_t));
185
186 return 0;
187}
188
Govindraj Raja232a11f2023-10-03 16:39:32 -0500189/*
190 * Load MBR entries based on max number of partition entries.
191 */
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800192static int load_mbr_entries(uintptr_t image_handle)
193{
194 mbr_entry_t mbr_entry;
195 int i;
196
197 list.entry_count = MBR_PRIMARY_ENTRY_NUMBER;
198
199 for (i = 0; i < list.entry_count; i++) {
200 load_mbr_entry(image_handle, &mbr_entry, i);
201 list.list[i].start = mbr_entry.first_lba * 512;
202 list.list[i].length = mbr_entry.sector_nums * 512;
203 list.list[i].name[0] = mbr_entry.type;
204 }
205
206 return 0;
207}
208
Govindraj Raja232a11f2023-10-03 16:39:32 -0500209/*
210 * Try to read and load a single GPT entry.
211 */
Haojian Zhuang91f56462016-07-28 14:19:36 +0800212static int load_gpt_entry(uintptr_t image_handle, gpt_entry_t *entry)
213{
Govindraj Raja232a11f2023-10-03 16:39:32 -0500214 size_t bytes_read = 0U;
Haojian Zhuang91f56462016-07-28 14:19:36 +0800215 int result;
216
217 assert(entry != NULL);
218 result = io_read(image_handle, (uintptr_t)entry, sizeof(gpt_entry_t),
Govindraj Raja232a11f2023-10-03 16:39:32 -0500219 &bytes_read);
220 if ((result != 0) || (sizeof(gpt_entry_t) != bytes_read)) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500221 VERBOSE("GPT Entry read error(%i) or read mismatch occurred,"
222 "expected(%zu) and actual(%zu)\n", result,
223 sizeof(gpt_entry_t), bytes_read);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800224 return -EINVAL;
Govindraj Raja232a11f2023-10-03 16:39:32 -0500225 }
226
Haojian Zhuang91f56462016-07-28 14:19:36 +0800227 return result;
228}
229
Govindraj Raja232a11f2023-10-03 16:39:32 -0500230/*
231 * Retrieve each entry in the partition table, parse the data from each
232 * entry and store them in the list of partition table entries.
233 */
234static int load_partition_gpt(uintptr_t image_handle,
235 unsigned long long part_lba)
Haojian Zhuang91f56462016-07-28 14:19:36 +0800236{
Govindraj Raja232a11f2023-10-03 16:39:32 -0500237 const signed long long gpt_entry_offset = LBA(part_lba);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800238 gpt_entry_t entry;
239 int result, i;
240
Govindraj Raja232a11f2023-10-03 16:39:32 -0500241 result = io_seek(image_handle, IO_SEEK_SET, gpt_entry_offset);
242 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500243 VERBOSE("Failed to seek (%i), Failed loading GPT partition"
244 "table entries\n", result);
Govindraj Raja232a11f2023-10-03 16:39:32 -0500245 return result;
246 }
247
Haojian Zhuang91f56462016-07-28 14:19:36 +0800248 for (i = 0; i < list.entry_count; i++) {
249 result = load_gpt_entry(image_handle, &entry);
Govindraj Raja232a11f2023-10-03 16:39:32 -0500250 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500251 VERBOSE("Failed to load gpt entry data(%i) error is (%i)\n",
252 i, result);
Govindraj Raja232a11f2023-10-03 16:39:32 -0500253 return result;
254 }
255
Haojian Zhuang91f56462016-07-28 14:19:36 +0800256 result = parse_gpt_entry(&entry, &list.list[i]);
257 if (result != 0) {
258 break;
259 }
260 }
261 if (i == 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500262 VERBOSE("No Valid GPT Entries found\n");
Haojian Zhuang91f56462016-07-28 14:19:36 +0800263 return -EINVAL;
264 }
265 /*
266 * Only records the valid partition number that is loaded from
267 * partition table.
268 */
269 list.entry_count = i;
270 dump_entries(list.entry_count);
271
272 return 0;
273}
274
Govindraj Raja232a11f2023-10-03 16:39:32 -0500275/*
276 * Try retrieving and parsing the backup-GPT header and backup GPT entries.
277 * Last 33 blocks contains the backup-GPT entries and header.
278 */
279static int load_backup_gpt(unsigned int image_id, unsigned int sector_nums)
280{
281 int result;
282 unsigned long long part_lba = 0;
283 size_t gpt_header_offset;
284 uintptr_t dev_handle, image_spec, image_handle;
285 io_block_spec_t *block_spec;
286 int part_num_entries;
287
288 result = plat_get_image_source(image_id, &dev_handle, &image_spec);
289 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500290 VERBOSE("Failed to obtain reference to image id=%u (%i)\n",
291 image_id, result);
Govindraj Raja232a11f2023-10-03 16:39:32 -0500292 return result;
293 }
294
295 block_spec = (io_block_spec_t *)image_spec;
296 /*
297 * We need to read 32 blocks of GPT entries and one block of GPT header
298 * try mapping only last 33 last blocks from the image to read the
299 * Backup-GPT header and its entries.
300 */
301 part_num_entries = (PLAT_PARTITION_MAX_ENTRIES / 4);
302 /* Move the offset base to LBA-33 */
303 block_spec->offset += LBA(sector_nums - part_num_entries);
304 /*
305 * Set length as LBA-33, 32 blocks of backup-GPT entries and one
306 * block of backup-GPT header.
307 */
308 block_spec->length = LBA(part_num_entries + 1);
309
310 result = io_open(dev_handle, image_spec, &image_handle);
311 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500312 VERBOSE("Failed to access image id (%i)\n", result);
Govindraj Raja232a11f2023-10-03 16:39:32 -0500313 return result;
314 }
315
316 INFO("Trying to retrieve back-up GPT header\n");
317 /* Last block is backup-GPT header, after the end of GPT entries */
318 gpt_header_offset = LBA(part_num_entries);
319 result = load_gpt_header(image_handle, gpt_header_offset, &part_lba);
320 if ((result != 0) || (part_lba == 0)) {
321 ERROR("Failed to retrieve Backup GPT header,"
322 "Partition maybe corrupted\n");
323 goto out;
324 }
325
326 /*
327 * Note we mapped last 33 blocks(LBA-33), first block here starts with
328 * entries while last block was header.
329 */
330 result = load_partition_gpt(image_handle, 0);
331
332out:
333 io_close(image_handle);
334 return result;
335}
336
337/*
338 * Load a GPT partition, Try retrieving and parsing the primary GPT header,
339 * if its corrupted try loading backup GPT header and then retrieve list
340 * of partition table entries found from the GPT.
341 */
342static int load_primary_gpt(uintptr_t image_handle, unsigned int first_lba)
343{
344 int result;
345 unsigned long long part_lba;
346 size_t gpt_header_offset;
347
348 /* Try to load Primary GPT header from LBA1 */
349 gpt_header_offset = LBA(first_lba);
350 result = load_gpt_header(image_handle, gpt_header_offset, &part_lba);
351 if ((result != 0) || (part_lba == 0)) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500352 VERBOSE("Failed to retrieve Primary GPT header,"
353 "trying to retrieve back-up GPT header\n");
Govindraj Raja232a11f2023-10-03 16:39:32 -0500354 return result;
355 }
356
357 return load_partition_gpt(image_handle, part_lba);
358}
359
360/*
361 * Load the partition table info based on the image id provided.
362 */
Haojian Zhuang91f56462016-07-28 14:19:36 +0800363int load_partition_table(unsigned int image_id)
364{
365 uintptr_t dev_handle, image_handle, image_spec = 0;
366 mbr_entry_t mbr_entry;
367 int result;
368
369 result = plat_get_image_source(image_id, &dev_handle, &image_spec);
370 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500371 VERBOSE("Failed to obtain reference to image id=%u (%i)\n",
372 image_id, result);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800373 return result;
374 }
375
376 result = io_open(dev_handle, image_spec, &image_handle);
377 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500378 VERBOSE("Failed to access image id=%u (%i)\n", image_id, result);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800379 return result;
380 }
381
382 result = load_mbr_header(image_handle, &mbr_entry);
383 if (result != 0) {
Govindraj Raja1341a3f2023-10-12 17:31:41 -0500384 VERBOSE("Failed to access image id=%u (%i)\n", image_id, result);
Govindraj Raja232a11f2023-10-03 16:39:32 -0500385 goto out;
Haojian Zhuang91f56462016-07-28 14:19:36 +0800386 }
387 if (mbr_entry.type == PARTITION_TYPE_GPT) {
Govindraj Raja232a11f2023-10-03 16:39:32 -0500388 result = load_primary_gpt(image_handle, mbr_entry.first_lba);
Govindraj Raja998b1e22023-09-21 18:04:00 -0500389 if (result != 0) {
Govindraj Raja232a11f2023-10-03 16:39:32 -0500390 io_close(image_handle);
391 return load_backup_gpt(BKUP_GPT_IMAGE_ID,
392 mbr_entry.sector_nums);
Govindraj Raja998b1e22023-09-21 18:04:00 -0500393 }
Haojian Zhuang91f56462016-07-28 14:19:36 +0800394 } else {
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800395 result = load_mbr_entries(image_handle);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800396 }
Loh Tien Hock8defbae2019-02-11 10:56:28 +0800397
Govindraj Raja232a11f2023-10-03 16:39:32 -0500398out:
Haojian Zhuang91f56462016-07-28 14:19:36 +0800399 io_close(image_handle);
400 return result;
401}
402
Govindraj Raja232a11f2023-10-03 16:39:32 -0500403/*
404 * Try retrieving a partition table entry based on the name of the partition.
405 */
Haojian Zhuang91f56462016-07-28 14:19:36 +0800406const partition_entry_t *get_partition_entry(const char *name)
407{
408 int i;
409
410 for (i = 0; i < list.entry_count; i++) {
411 if (strcmp(name, list.list[i].name) == 0) {
412 return &list.list[i];
413 }
414 }
415 return NULL;
416}
417
Govindraj Raja232a11f2023-10-03 16:39:32 -0500418/*
419 * Try retrieving a partition table entry based on the GUID.
420 */
Lionel Debievea88ca2e2022-02-24 18:56:28 +0100421const partition_entry_t *get_partition_entry_by_type(const uuid_t *type_uuid)
422{
423 int i;
424
425 for (i = 0; i < list.entry_count; i++) {
426 if (guidcmp(type_uuid, &list.list[i].type_guid) == 0) {
427 return &list.list[i];
428 }
429 }
430
431 return NULL;
432}
433
Govindraj Raja232a11f2023-10-03 16:39:32 -0500434/*
435 * Try retrieving a partition table entry based on the UUID.
436 */
Sughosh Ganu47b642e2021-11-10 13:00:30 +0530437const partition_entry_t *get_partition_entry_by_uuid(const uuid_t *part_uuid)
438{
439 int i;
440
441 for (i = 0; i < list.entry_count; i++) {
442 if (guidcmp(part_uuid, &list.list[i].part_guid) == 0) {
443 return &list.list[i];
444 }
445 }
446
447 return NULL;
448}
449
Govindraj Raja232a11f2023-10-03 16:39:32 -0500450/*
451 * Return entry to the list of partition table entries.
452 */
Haojian Zhuang91f56462016-07-28 14:19:36 +0800453const partition_entry_list_t *get_partition_entry_list(void)
454{
455 return &list;
456}
457
Govindraj Raja232a11f2023-10-03 16:39:32 -0500458/*
459 * Try loading partition table info for the given image ID.
460 */
Haojian Zhuang91f56462016-07-28 14:19:36 +0800461void partition_init(unsigned int image_id)
462{
Govindraj Raja20431cf2023-10-12 16:41:07 -0500463 int ret;
464
465 ret = load_partition_table(image_id);
466 if (ret != 0) {
467 ERROR("Failed to parse partition with image id = %u\n",
468 image_id);
469 }
470}
471
472/*
473 * Load a GPT based image.
474 */
475int gpt_partition_init(void)
476{
477 return load_partition_table(GPT_IMAGE_ID);
Haojian Zhuang91f56462016-07-28 14:19:36 +0800478}