diff options
author | Nam T. Nguyen <namnguyen@chromium.org> | 2014-08-22 15:01:38 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-28 01:17:48 +0000 |
commit | a2d72f70c18905aba25eb0971f6f601dd1fa5a60 (patch) | |
tree | 42f9be2f6fb2d9bd5fd54a7d4b31d5c0c378e381 /cgpt/cgpt_create.c | |
parent | f510973497a430c1bb41d9b7e996d02fb7f7179e (diff) | |
download | vboot-a2d72f70c18905aba25eb0971f6f601dd1fa5a60.tar.gz |
vboot: cgpt: Refer to partition entries by entries_lba.
This CL accesses the partition entry array through its header's
entries_lba value.
Previously, we assume the primary entry array lies on third sector, and
the secondary array lies (1 + 32) sectors from disk end. This assumption
was fine, even Wikipedia assumed the same.
But in order for us to support writing boot code to the third sector (as
required by some Freescale board), the primary entry array must be moved
to another location. Therefore, we must use "entries_lba" to locate the
arrays from now on.
BRANCH=none
BUG=chromium:406432
TEST=unittest
TEST=`cgpt create -p` and then `cgpt show`. Make sure the table
header and entries are properly moved.
Change-Id: Ia9008b0bb204f290b1f6240df562ce7d3a9bbff2
Reviewed-on: https://chromium-review.googlesource.com/213861
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
Diffstat (limited to 'cgpt/cgpt_create.c')
-rw-r--r-- | cgpt/cgpt_create.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/cgpt/cgpt_create.c b/cgpt/cgpt_create.c index 9f60b3a1..c9134da6 100644 --- a/cgpt/cgpt_create.c +++ b/cgpt/cgpt_create.c @@ -29,15 +29,16 @@ static int GptCreate(struct drive *drive, CgptCreateParams *params) { memcpy(h->signature, GPT_HEADER_SIGNATURE, GPT_HEADER_SIGNATURE_SIZE); h->revision = GPT_HEADER_REVISION; h->size = sizeof(GptHeader); - h->my_lba = 1; - h->alternate_lba = drive->gpt.drive_sectors - 1; - h->first_usable_lba = 1 + 1 + GPT_ENTRIES_SECTORS; - h->last_usable_lba = drive->gpt.drive_sectors - 1 - GPT_ENTRIES_SECTORS - 1; + h->my_lba = GPT_PMBR_SECTOR; /* The second sector on drive. */ + h->alternate_lba = drive->gpt.drive_sectors - GPT_HEADER_SECTOR; + h->entries_lba = h->my_lba + GPT_HEADER_SECTOR + params->padding; + h->first_usable_lba = h->entries_lba + GPT_ENTRIES_SECTORS; + h->last_usable_lba = (drive->gpt.drive_sectors - GPT_HEADER_SECTOR - + GPT_ENTRIES_SECTORS - 1); if (CGPT_OK != GenerateGuid(&h->disk_uuid)) { Error("Unable to generate new GUID.\n"); return -1; } - h->entries_lba = 2; h->number_of_entries = 128; h->size_of_entry = sizeof(GptEntry); |