Index: src/platform/vboot_reference/vkernel/kernel_image.c |
diff --git a/src/platform/vboot_reference/vkernel/kernel_image.c b/src/platform/vboot_reference/vkernel/kernel_image.c |
index 61e5408a7f76299a49b78cb9358a689d5a92681f..f78f0f4624e5b6e64f280a4d49799093951e10ce 100644 |
--- a/src/platform/vboot_reference/vkernel/kernel_image.c |
+++ b/src/platform/vboot_reference/vkernel/kernel_image.c |
@@ -599,15 +599,9 @@ int AddKernelSignature(KernelImage* image, |
return 1; |
} |
-void PrintKernelEntry(kernel_entry* entry) { |
- debug("Boot Priority = %d\n", entry->boot_priority); |
- debug("Boot Tries Remaining = %d\n", entry->boot_tries_remaining); |
- debug("Boot Success Flag = %d\n", entry->boot_success_flag); |
-} |
- |
-// Return the smallest integral multiple of [alignment] that is equal to or |
-// greater than [val]. Used to determine the number of |
-// pages/sectors/blocks/whatever needed to contain [val] items/bytes/etc. |
+/* Return the smallest integral multiple of [alignment] that is equal to or |
+ * greater than [val]. Used to determine the number of |
+ * pages/sectors/blocks/whatever needed to contain [val] items/bytes/etc. */ |
static uint64_t roundup(uint64_t val, uint64_t alignment) { |
uint64_t rem = val % alignment; |
if ( rem ) |
@@ -615,21 +609,21 @@ static uint64_t roundup(uint64_t val, uint64_t alignment) { |
return val; |
} |
-// Match regexp /\b--\b/ to delimit the start of the kernel commandline. If we |
-// don't find one, we'll use the whole thing. |
+/* Match regexp /\b--\b/ to delimit the start of the kernel commandline. If we |
+ * don't find one, we'll use the whole thing. */ |
static unsigned int find_cmdline_start(char *input, unsigned int max_len) { |
int start = 0; |
int i; |
for(i = 0; i < max_len-1 && input[i]; i++) { |
- if (input[i] == '-' && input[i+1] == '-') { // found a "--" |
- if ((i == 0 || input[i-1] == ' ') && // nothing before it |
- (i+2 >= max_len || input[i+2] == ' ')) { // nothing after it |
- start = i+2; // note: hope there's a trailing '\0' |
+ if (input[i] == '-' && input[i+1] == '-') { /* found a "--" */ |
+ if ((i == 0 || input[i-1] == ' ') && /* nothing before it */ |
+ (i+2 >= max_len || input[i+2] == ' ')) { /* nothing after it */ |
+ start = i+2; /* note: hope there's a trailing '\0' */ |
break; |
} |
} |
} |
- while(input[start] == ' ') // skip leading spaces |
+ while(input[start] == ' ') /* skip leading spaces */ |
start++; |
return start; |
@@ -659,7 +653,7 @@ uint8_t* GenerateKernelBlob(const char* kernel_file, |
uint32_t cmdline_addr; |
uint64_t i; |
- // Read the input files. |
+ /* Read the input files. */ |
kernel_buf = BufferFromFile(kernel_file, &kernel_size); |
if (!kernel_buf) |
goto done0; |
@@ -667,13 +661,13 @@ uint8_t* GenerateKernelBlob(const char* kernel_file, |
config_buf = BufferFromFile(config_file, &config_size); |
if (!config_buf) |
goto done1; |
- if (config_size >= CROS_CONFIG_SIZE) { // need room for trailing '\0' |
+ if (config_size >= CROS_CONFIG_SIZE) { /* need room for trailing '\0' */ |
error("config file %s is too large (>= %d bytes)\n", |
config_file, CROS_CONFIG_SIZE); |
goto done1; |
} |
- // Replace any newlines with spaces in the config file. |
+ /* Replace any newlines with spaces in the config file. */ |
for (i=0; i < config_size; i++) |
if (config_buf[i] == '\n') |
config_buf[i] = ' '; |
@@ -682,15 +676,15 @@ uint8_t* GenerateKernelBlob(const char* kernel_file, |
if (!bootloader_buf) |
goto done2; |
- // The first part of vmlinuz is a header, followed by a real-mode boot stub. |
- // We only want the 32-bit part. |
+ /* The first part of vmlinuz is a header, followed by a real-mode boot stub. |
+ * We only want the 32-bit part. */ |
if (kernel_size) { |
lh = (struct linux_kernel_header *)kernel_buf; |
kernel32_start = (lh->setup_sects+1) << 9; |
kernel32_size = kernel_size - kernel32_start; |
} |
- // Allocate and zero the blob we need. |
+ /* Allocate and zero the blob we need. */ |
blob_size = roundup(kernel32_size, CROS_ALIGN) + |
CROS_CONFIG_SIZE + |
CROS_PARAMS_SIZE + |
@@ -703,42 +697,43 @@ uint8_t* GenerateKernelBlob(const char* kernel_file, |
Memset(blob, 0, blob_size); |
now = 0; |
- // Copy the 32-bit kernel. |
+ /* Copy the 32-bit kernel. */ |
if (kernel32_size) |
Memcpy(blob + now, kernel_buf + kernel32_start, kernel32_size); |
now += roundup(now + kernel32_size, CROS_ALIGN); |
- // Find the load address of the commandline. We'll need it later. |
+ /* Find the load address of the commandline. We'll need it later. */ |
cmdline_addr = CROS_32BIT_ENTRY_ADDR + now |
+ find_cmdline_start((char *)config_buf, config_size); |
- // Copy the config. |
+ /* Copy the config. */ |
if (config_size) |
Memcpy(blob + now, config_buf, config_size); |
now += CROS_CONFIG_SIZE; |
- // The zeropage data is next. Overlay the linux_kernel_header onto it, and |
- // tweak a few fields. |
+ /* The zeropage data is next. Overlay the linux_kernel_header onto it, and |
+ * tweak a few fields. */ |
params = (struct linux_kernel_params *)(blob + now); |
if (kernel_size) |
Memcpy(&(params->setup_sects), &(lh->setup_sects), |
sizeof(*lh) - offsetof(struct linux_kernel_header, setup_sects)); |
params->boot_flag = 0; |
- params->ramdisk_image = 0; // we don't support initrd |
+ params->ramdisk_image = 0; /* we don't support initrd */ |
params->ramdisk_size = 0; |
params->type_of_loader = 0xff; |
params->cmd_line_ptr = cmdline_addr; |
now += CROS_PARAMS_SIZE; |
- // Finally, append the bootloader. Remember where it will load in memory, too. |
+ /* Finally, append the bootloader. Remember where it will load in memory, too. |
+ */ |
bootloader_mem_start = CROS_32BIT_ENTRY_ADDR + now; |
bootloader_mem_size = roundup(bootloader_size, CROS_ALIGN); |
if (bootloader_size) |
Memcpy(blob + now, bootloader_buf, bootloader_size); |
now += bootloader_mem_size; |
- // Pass back some info. |
+ /* Pass back some info. */ |
if (ret_blob_len) |
*ret_blob_len = blob_size; |
if (ret_bootloader_offset) |
@@ -746,7 +741,7 @@ uint8_t* GenerateKernelBlob(const char* kernel_file, |
if (ret_bootloader_size) |
*ret_bootloader_size = bootloader_mem_size; |
- // Clean up and return the blob. |
+ /* Clean up and return the blob. */ |
done3: |
Free(bootloader_buf); |
done2: |