| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved. | 2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved. |
| 3 * | 3 * |
| 4 * See file CREDITS for list of people who contributed to this | 4 * See file CREDITS for list of people who contributed to this |
| 5 * project. | 5 * project. |
| 6 * | 6 * |
| 7 * This program is free software; you can redistribute it and/or | 7 * This program is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU General Public License as | 8 * modify it under the terms of the GNU General Public License as |
| 9 * published by the Free Software Foundation; either version 2 of | 9 * published by the Free Software Foundation; either version 2 of |
| 10 * the License, or (at your option) any later version. | 10 * the License, or (at your option) any later version. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return write_block_raw(context); | 52 return write_block_raw(context); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static void | 55 static void |
| 56 usage(void) | 56 usage(void) |
| 57 { | 57 { |
| 58 printf("Usage: cbootimage [options] configfile imagename\n"); | 58 printf("Usage: cbootimage [options] configfile imagename\n"); |
| 59 printf(" options:\n"); | 59 printf(" options:\n"); |
| 60 printf(" -h, --help, -? Display this message.\n"); | 60 printf(" -h, --help, -? Display this message.\n"); |
| 61 printf(" -d, --debug Output debugging information.\n"); | 61 printf(" -d, --debug Output debugging information.\n"); |
| 62 printf(" -gbct Generate the new bct file.\n"); |
| 62 printf(" configfile File with configuration information\n"); | 63 printf(" configfile File with configuration information\n"); |
| 63 printf(" imagename Output image name\n"); | 64 printf(" imagename Output image name\n"); |
| 64 } | 65 } |
| 65 | 66 |
| 66 static int | 67 static int |
| 67 process_command_line(int argc, char *argv[], build_image_context *context) | 68 process_command_line(int argc, char *argv[], build_image_context *context) |
| 68 { | 69 { |
| 69 int arg = 1; | 70 int arg = 1; |
| 70 | 71 |
| 72 context->generate_bct = 0; |
| 73 |
| 71 while (arg < argc) { | 74 while (arg < argc) { |
| 72 /* Process the next argument. */ | 75 /* Process the next argument. */ |
| 73 if (!strcmp(argv[arg], "-h") || | 76 if (!strcmp(argv[arg], "-h") || |
| 74 !strcmp(argv[arg], "--help") || | 77 !strcmp(argv[arg], "--help") || |
| 75 !strcmp(argv[arg], "-?")) { | 78 !strcmp(argv[arg], "-?")) { |
| 76 help_only = 1; | 79 help_only = 1; |
| 77 usage(); | 80 usage(); |
| 78 return 0; | 81 return 0; |
| 79 } else if (!strcmp(argv[arg], "-d") || | 82 } else if (!strcmp(argv[arg], "-d") || |
| 80 !strcmp(argv[arg], "--debug")) { | 83 !strcmp(argv[arg], "--debug")) { |
| 81 enable_debug = 1; | 84 enable_debug = 1; |
| 82 arg++; | 85 arg++; |
| 86 } else if (!strcmp(argv[arg], "-gbct")) { |
| 87 context->generate_bct = 1; |
| 88 arg++; |
| 83 } else if (argv[arg][0] == '-') { | 89 } else if (argv[arg][0] == '-') { |
| 84 printf("Illegal option %s\n", argv[arg]); | 90 printf("Illegal option %s\n", argv[arg]); |
| 85 usage(); | 91 usage(); |
| 86 return -EINVAL; | 92 return -EINVAL; |
| 87 } | 93 } |
| 88 else | 94 else |
| 89 break; /* Finished with options */ | 95 break; /* Finished with options */ |
| 90 } | 96 } |
| 91 | 97 |
| 92 /* Handle file specification errors. */ | 98 /* Handle file specification errors. */ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 "w+"); | 167 "w+"); |
| 162 if (context.raw_file == NULL) { | 168 if (context.raw_file == NULL) { |
| 163 printf("Error opening raw file %s.\n", | 169 printf("Error opening raw file %s.\n", |
| 164 context.image_filename); | 170 context.image_filename); |
| 165 goto fail; | 171 goto fail; |
| 166 } | 172 } |
| 167 | 173 |
| 168 /* Parse & process the contents of the config file. */ | 174 /* Parse & process the contents of the config file. */ |
| 169 process_config_file(&context); | 175 process_config_file(&context); |
| 170 | 176 |
| 177 /* Generate the new bct file */ |
| 178 if (context.generate_bct != 0) { |
| 179 /* Signing the bct. */ |
| 180 e = sign_bct(&context, context.bct); |
| 181 if (e != 0) |
| 182 printf("Signing BCT failed, error: %d.\n", e); |
| 183 |
| 184 fwrite(context.bct, 1, sizeof(nvboot_config_table), |
| 185 context.raw_file); |
| 186 printf("New BCT file %s has been successfully generated!\n", |
| 187 context.image_filename); |
| 188 goto fail; |
| 189 } |
| 190 |
| 171 /* Update the bct file */ | 191 /* Update the bct file */ |
| 172 /* Update the add on file */ | 192 /* Update the add on file */ |
| 173 e = update_addon_item(&context); | 193 e = update_addon_item(&context); |
| 174 if ( e!= 0) { | 194 if ( e!= 0) { |
| 175 printf("Write addon item failed, error: %d.\n", e); | 195 printf("Write addon item failed, error: %d.\n", e); |
| 176 goto fail; | 196 goto fail; |
| 177 } | 197 } |
| 178 /* Peform final signing & encryption of bct. */ | 198 /* Peform final signing & encryption of bct. */ |
| 179 e = sign_bct(&context, context.bct); | 199 e = sign_bct(&context, context.bct); |
| 180 if (e != 0) { | 200 if (e != 0) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 192 fail: | 212 fail: |
| 193 /* Close the file(s). */ | 213 /* Close the file(s). */ |
| 194 if (context.raw_file) | 214 if (context.raw_file) |
| 195 fclose(context.raw_file); | 215 fclose(context.raw_file); |
| 196 | 216 |
| 197 /* Clean up memory. */ | 217 /* Clean up memory. */ |
| 198 cleanup_context(&context); | 218 cleanup_context(&context); |
| 199 | 219 |
| 200 return e; | 220 return e; |
| 201 } | 221 } |
| OLD | NEW |