mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 10:14:55 +00:00
Make LoadKernel() pass back the kernel partition's UniqueGuid.
LoadKernel already returns the partition number for the selected kernel. This change makes it also return the GPT Entry's UniqueGuid, which will eventually be passed to the kernel itself, so the kernel can determine which of several possible devices it has booted from. It doesn't know for certain because the BIOS and the kernel may enumerate the devices in a different order. BUG=chromium-os:4984 Review URL: http://codereview.chromium.org/3056014
This commit is contained in:
@@ -44,6 +44,7 @@ typedef struct LoadKernelParams {
|
||||
* (1...M) */
|
||||
uint64_t bootloader_address; /* Address of bootloader image in RAM */
|
||||
uint64_t bootloader_size; /* Size of bootloader image in bytes */
|
||||
uint8_t partition_guid[16]; /* UniquePartitionGuid for boot partition */
|
||||
} LoadKernelParams;
|
||||
|
||||
int LoadKernel(LoadKernelParams* params);
|
||||
@@ -62,6 +63,7 @@ typedef struct KernelBootloaderOptions {
|
||||
uint64_t original_address; /* Absolute bootloader start adddress,
|
||||
* as returned from LoadKernel() in
|
||||
* LoadKernelParams.bootloader_start */
|
||||
uint8_t partition_guid[16]; /* UniquePartitionGuid for boot partition */
|
||||
} KernelBootloaderOptions;
|
||||
|
||||
|
||||
|
||||
@@ -346,3 +346,9 @@ void SetEntryTries(GptEntry* e, int tries) {
|
||||
e->attrs.fields.gpt_att |= (tries << CGPT_ATTRIBUTE_TRIES_OFFSET) &
|
||||
CGPT_ATTRIBUTE_TRIES_MASK;
|
||||
}
|
||||
|
||||
void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest) {
|
||||
GptEntry* entries = (GptEntry*)gpt->primary_entries;
|
||||
GptEntry* e = entries + gpt->current_kernel;
|
||||
Memcpy(dest, &e->unique, sizeof(Guid));
|
||||
}
|
||||
|
||||
@@ -112,4 +112,7 @@ int IsUnusedEntry(const GptEntry* e);
|
||||
/* Returns 1 if the entry is a Chrome OS kernel partition, else 0. */
|
||||
int IsKernelEntry(const GptEntry* e);
|
||||
|
||||
/* Copies the current kernel partition's UniquePartitionGuid to the dest */
|
||||
void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest);
|
||||
|
||||
#endif /* VBOOT_REFERENCE_CGPTLIB_INTERNAL_H_ */
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
#include "boot_device.h"
|
||||
#include "cgptlib.h"
|
||||
#include "cgptlib_internal.h"
|
||||
#include "load_kernel_fw.h"
|
||||
#include "rollback_index.h"
|
||||
#include "utility.h"
|
||||
#include "vboot_common.h"
|
||||
|
||||
|
||||
#define KBUF_SIZE 65536 /* Bytes to read at start of kernel partition */
|
||||
|
||||
|
||||
@@ -131,7 +131,6 @@ int LoadKernel(LoadKernelParams* params) {
|
||||
|
||||
/* Sanity Checks */
|
||||
if (!params ||
|
||||
!params->header_sign_key_blob ||
|
||||
!params->bytes_per_lba ||
|
||||
!params->ending_lba ||
|
||||
!params->kernel_buffer ||
|
||||
@@ -350,6 +349,7 @@ int LoadKernel(LoadKernelParams* params) {
|
||||
* Adjust here, until cgptlib is fixed. */
|
||||
good_partition = gpt.current_kernel + 1;
|
||||
params->partition_number = gpt.current_kernel + 1;
|
||||
GetCurrentKernelUniqueGuid(&gpt, ¶ms->partition_guid);
|
||||
params->bootloader_address = preamble->bootloader_address;
|
||||
params->bootloader_size = preamble->bootloader_size;
|
||||
/* If we're in developer or recovery mode, there's no rollback
|
||||
|
||||
@@ -1 +1 @@
|
||||
char* VbootVersion = "VBOOv=0249c1a3";
|
||||
char* VbootVersion = "VBOOv=5d5d1959";
|
||||
|
||||
@@ -135,6 +135,25 @@ int main(int argc, char* argv[]) {
|
||||
printf("Partition number: %" PRIu64 "\n", lkp.partition_number);
|
||||
printf("Bootloader address: %" PRIu64 "\n", lkp.bootloader_address);
|
||||
printf("Bootloader size: %" PRIu64 "\n", lkp.bootloader_size);
|
||||
printf("Partition guid: "
|
||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x"
|
||||
"-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
|
||||
lkp.partition_guid[3],
|
||||
lkp.partition_guid[2],
|
||||
lkp.partition_guid[1],
|
||||
lkp.partition_guid[0],
|
||||
lkp.partition_guid[5],
|
||||
lkp.partition_guid[4],
|
||||
lkp.partition_guid[7],
|
||||
lkp.partition_guid[6],
|
||||
lkp.partition_guid[8],
|
||||
lkp.partition_guid[9],
|
||||
lkp.partition_guid[10],
|
||||
lkp.partition_guid[11],
|
||||
lkp.partition_guid[12],
|
||||
lkp.partition_guid[13],
|
||||
lkp.partition_guid[14],
|
||||
lkp.partition_guid[15]);
|
||||
}
|
||||
|
||||
fclose(image_file);
|
||||
|
||||
Reference in New Issue
Block a user