summaryrefslogtreecommitdiff
path: root/tests/vboot_kernel_tests.c
diff options
context:
space:
mode:
authorNam T. Nguyen <namnguyen@chromium.org>2014-10-24 13:20:39 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-13 18:29:09 +0000
commit6ee52d9a929d00e871e7316240b54f381146fbc6 (patch)
treeca403414469d9364d144a67e63f8f439874802e3 /tests/vboot_kernel_tests.c
parent43e0a9ed6c0b332631442fcf581e7456d62e4532 (diff)
downloadvboot-6ee52d9a929d00e871e7316240b54f381146fbc6.tar.gz
vboot: cgpt: Support writing GPT structs to NOR flash
This CL allows the GPT headers and partition entry arrays to be stored in a NOR flash device. Instead of treating both the NOR and NAND devices as one (in a sandwich way), this CL writes and reads the GPT structs independently of the actual device that houses the partitions. Therefore, the first usable LBA of the partitions will be at 0, and the last usable LBA is at the end of the NAND. +------------------------+ | NOR houses GPT structs | +------------------------+ | 0 | Index into v v +------------------------+ | NAND houses partitions | +------------------------+ Note that the "my_lba", "alternate_lba", "entries_lba" in the GPT headers are no longer meaningful. Consumers of cgptlib will have to set "stored_on_device" to either GPT_STORED_ON_DEVICE or GPT_STORED_OFF_DEVICE, and "gpt_drive_sectors" to the number of 512-byte sectors available to store GPT structs. The NOR read and write operations are done by "flashrom". BUG=chromium:425677 BRANCH=none TEST=unittest TEST=build with DEBUG, cgpt create/add/show on a stumpy-moblab Change-Id: I083b3c94da3b0bb3da1a7b10c6969774080a2afd Reviewed-on: https://chromium-review.googlesource.com/226800 Reviewed-by: Nam Nguyen <namnguyen@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
Diffstat (limited to 'tests/vboot_kernel_tests.c')
-rw-r--r--tests/vboot_kernel_tests.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c
index 0c26d212..05035f28 100644
--- a/tests/vboot_kernel_tests.c
+++ b/tests/vboot_kernel_tests.c
@@ -289,7 +289,7 @@ static void ReadWriteGptTest(void)
GptHeader *h;
g.sector_bytes = MOCK_SECTOR_SIZE;
- g.drive_sectors = MOCK_SECTOR_COUNT;
+ g.drive_sectors = g.gpt_drive_sectors = MOCK_SECTOR_COUNT;
g.valid_headers = g.valid_entries = MASK_BOTH;
ResetMocks();
@@ -315,10 +315,10 @@ static void ReadWriteGptTest(void)
Memset(mock_gpt_primary, '\0', sizeof(*mock_gpt_primary));
TEST_EQ(AllocAndReadGptData(handle, &g), 0,
"AllocAndRead primary invalid");
- TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors), 1,
- "Primary header is invalid");
- TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors), 0,
- "Secondary header is valid");
+ TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 1, "Primary header is invalid");
+ TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 0, "Secondary header is valid");
TEST_CALLS("VbExDiskRead(h, 1, 1)\n"
"VbExDiskRead(h, 1023, 1)\n"
"VbExDiskRead(h, 991, 32)\n");
@@ -332,10 +332,10 @@ static void ReadWriteGptTest(void)
Memset(mock_gpt_secondary, '\0', sizeof(*mock_gpt_secondary));
TEST_EQ(AllocAndReadGptData(handle, &g), 0,
"AllocAndRead secondary invalid");
- TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors), 0,
- "Primary header is valid");
- TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors), 1,
- "Secondary header is invalid");
+ TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 0, "Primary header is valid");
+ TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 1, "Secondary header is invalid");
TEST_CALLS("VbExDiskRead(h, 1, 1)\n"
"VbExDiskRead(h, 2, 32)\n"
"VbExDiskRead(h, 1023, 1)\n");
@@ -350,10 +350,10 @@ static void ReadWriteGptTest(void)
Memset(mock_gpt_secondary, '\0', sizeof(*mock_gpt_secondary));
TEST_EQ(AllocAndReadGptData(handle, &g), 1,
"AllocAndRead primary and secondary invalid");
- TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors), 1,
- "Primary header is invalid");
- TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors), 1,
- "Secondary header is invalid");
+ TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 1, "Primary header is invalid");
+ TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 1, "Secondary header is invalid");
TEST_CALLS("VbExDiskRead(h, 1, 1)\n"
"VbExDiskRead(h, 1023, 1)\n");
WriteAndFreeGptData(handle, &g);
@@ -379,8 +379,8 @@ static void ReadWriteGptTest(void)
"VbExDiskRead(h, 991, 32)\n"
"VbExDiskWrite(h, 1, 1)\n"
"VbExDiskWrite(h, 2, 32)\n");
- TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors), 0,
- "Fix Primary GPT: Primary header is valid");
+ TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 0, "Fix Primary GPT: Primary header is valid");
/*
* Invalidate secondary GPT header and check that it can be
@@ -403,8 +403,8 @@ static void ReadWriteGptTest(void)
"VbExDiskRead(h, 1023, 1)\n"
"VbExDiskWrite(h, 1023, 1)\n"
"VbExDiskWrite(h, 991, 32)\n");
- TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors), 0,
- "Fix Secondary GPT: Secondary header is valid");
+ TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.drive_sectors,
+ GPT_STORED_ON_DEVICE), 0, "Fix Secondary GPT: Secondary header is valid");
/* Data which is changed is written */
ResetMocks();