Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: utility/load_kernel_test.c

Issue 6610019: Reapply patch from http://codereview.chromium.org/6594092/ (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « firmware/lib/vboot_kernel.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* Routines for verifying a file's signature. Useful in testing the core 6 /* Routines for verifying a file's signature. Useful in testing the core
7 * RSA verification implementation. 7 * RSA verification implementation.
8 */ 8 */
9 9
10 #include <inttypes.h> /* For PRIu64 macro */ 10 #include <inttypes.h> /* For PRIu64 macro */
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <string.h> 13 #include <string.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <unistd.h> 15 #include <unistd.h>
16 16
17 #include "load_kernel_fw.h" 17 #include "load_kernel_fw.h"
18 #include "boot_device.h" 18 #include "boot_device.h"
19 #include "host_common.h" 19 #include "host_common.h"
20 #include "rollback_index.h" 20 #include "rollback_index.h"
21 #include "utility.h" 21 #include "utility.h"
22 #include "vboot_kernel.h" 22 #include "vboot_kernel.h"
23 23
24 #define LBA_BYTES 512 24 #define LBA_BYTES 512
25 #define KERNEL_BUFFER_SIZE 0xA00000 25 #define KERNEL_BUFFER_SIZE 0xA00000
26 26
27 /* Global variables for stub functions */ 27 /* Global variables for stub functions */
28 static LoadKernelParams lkp; 28 static LoadKernelParams lkp;
29 static VbNvContext vnc;
29 static FILE *image_file = NULL; 30 static FILE *image_file = NULL;
30 31
31 32
32 /* Boot device stub implementations to read from the image file */ 33 /* Boot device stub implementations to read from the image file */
33 int BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, void *buffer) { 34 int BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, void *buffer) {
34 printf("Read(%" PRIu64 ", %" PRIu64 ")\n", lba_start, lba_count); 35 printf("Read(%" PRIu64 ", %" PRIu64 ")\n", lba_start, lba_count);
35 36
36 if (lba_start > lkp.ending_lba || 37 if (lba_start > lkp.ending_lba ||
37 lba_start + lba_count - 1 > lkp.ending_lba) { 38 lba_start + lba_count - 1 > lkp.ending_lba) {
38 fprintf(stderr, "Read overrun: %" PRIu64 " + %" PRIu64 " > %" PRIu64 "\n", 39 fprintf(stderr, "Read overrun: %" PRIu64 " + %" PRIu64 " > %" PRIu64 "\n",
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 int main(int argc, char* argv[]) { 77 int main(int argc, char* argv[]) {
77 78
78 const char* image_name; 79 const char* image_name;
79 int rv, c, argsleft; 80 int rv, c, argsleft;
80 int errorcnt = 0; 81 int errorcnt = 0;
81 char *e = 0; 82 char *e = 0;
82 83
83 Memset(&lkp, 0, sizeof(LoadKernelParams)); 84 Memset(&lkp, 0, sizeof(LoadKernelParams));
84 lkp.bytes_per_lba = LBA_BYTES; 85 lkp.bytes_per_lba = LBA_BYTES;
85 lkp.boot_flags = BOOT_FLAG_RECOVERY; 86 lkp.boot_flags = BOOT_FLAG_RECOVERY;
87 Memset(&vnc, 0, sizeof(VbNvContext));
88 lkp.nv_context = &vnc;
86 89
87 /* Parse options */ 90 /* Parse options */
88 opterr = 0; 91 opterr = 0;
89 while ((c=getopt(argc, argv, ":b:")) != -1) 92 while ((c=getopt(argc, argv, ":b:")) != -1)
90 { 93 {
91 switch (c) 94 switch (c)
92 { 95 {
93 case 'b': 96 case 'b':
94 lkp.boot_flags = strtoull(optarg, &e, 0); 97 lkp.boot_flags = strtoull(optarg, &e, 0);
95 if (!*optarg || (e && *e)) 98 if (!*optarg || (e && *e))
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 lkp.partition_guid[12], 204 lkp.partition_guid[12],
202 lkp.partition_guid[13], 205 lkp.partition_guid[13],
203 lkp.partition_guid[14], 206 lkp.partition_guid[14],
204 lkp.partition_guid[15]); 207 lkp.partition_guid[15]);
205 } 208 }
206 209
207 fclose(image_file); 210 fclose(image_file);
208 Free(lkp.kernel_buffer); 211 Free(lkp.kernel_buffer);
209 return rv != LOAD_KERNEL_SUCCESS; 212 return rv != LOAD_KERNEL_SUCCESS;
210 } 213 }
OLDNEW
« no previous file with comments | « firmware/lib/vboot_kernel.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698