| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 */ | 34 */ |
| 35 | 35 |
| 36 /* | 36 /* |
| 37 * Support Chrome OS Verify Boot | 37 * Support Chrome OS Verify Boot |
| 38 */ | 38 */ |
| 39 #include <common.h> | 39 #include <common.h> |
| 40 #include <command.h> | 40 #include <command.h> |
| 41 #include <part.h> | 41 #include <part.h> |
| 42 #include <boot_device.h> | 42 #include <boot_device.h> |
| 43 | 43 |
| 44 #define USAGE(ret, cmdtp, fmt, args...) do { \ | 44 #define USAGE(ret, cmdtp, fmt, ...) do { \ |
| 45 » printf(fmt, args); \ | 45 » printf(fmt, ##__VA_ARGS__); \ |
| 46 cmd_usage(cmdtp); \ | 46 cmd_usage(cmdtp); \ |
| 47 return (ret); \ | 47 return (ret); \ |
| 48 } while (0); | 48 } while (0); |
| 49 | 49 |
| 50 block_dev_desc_t *get_bootdev(void); | 50 block_dev_desc_t *get_bootdev(void); |
| 51 int set_bootdev(char *ifname, int dev, int part); | 51 int set_bootdev(char *ifname, int dev, int part); |
| 52 | 52 |
| 53 int do_cros (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); | 53 int do_cros (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| 54 int do_bootdev (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); | 54 int do_bootdev (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| 55 int do_cros_help(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); | 55 int do_cros_help(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 return 0; | 107 return 0; |
| 108 } | 108 } |
| 109 | 109 |
| 110 if (!strcmp(argv[1], "set")) | 110 if (!strcmp(argv[1], "set")) |
| 111 opcode = SET; | 111 opcode = SET; |
| 112 else if (!strcmp(argv[1], "read")) | 112 else if (!strcmp(argv[1], "read")) |
| 113 opcode = READ; | 113 opcode = READ; |
| 114 else if (!strcmp(argv[1], "write")) | 114 else if (!strcmp(argv[1], "write")) |
| 115 opcode = WRITE; | 115 opcode = WRITE; |
| 116 else | 116 else |
| 117 » » USAGE(1, cmdpt, "Unrecognized action: %s\n", argv[1]); | 117 » » USAGE(1, cmdtp, "Unrecognized action: %s\n", argv[1]); |
| 118 | 118 |
| 119 /* apply De Morgan's laws on | 119 /* apply De Morgan's laws on |
| 120 * !((argc == 4 && opcode == SET) || argc == 5) */ | 120 * !((argc == 4 && opcode == SET) || argc == 5) */ |
| 121 if ((argc != 4 || opcode != SET) && argc != 5) | 121 if ((argc != 4 || opcode != SET) && argc != 5) |
| 122 USAGE(1, cmdtp, "Wrong number of arguments\n"); | 122 USAGE(1, cmdtp, "Wrong number of arguments\n"); |
| 123 | 123 |
| 124 if (opcode == SET) { | 124 if (opcode == SET) { |
| 125 dev = (int) simple_strtoul(argv[3], NULL, 16); | 125 dev = (int) simple_strtoul(argv[3], NULL, 16); |
| 126 part = (argc == 5) ? | 126 part = (argc == 5) ? |
| 127 0 : (int) simple_strtoul(argv[4], NULL, 16); | 127 0 : (int) simple_strtoul(argv[4], NULL, 16); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return _do_help(&cmd_cros_sub[0], ARRAY_SIZE(cmd_cros_sub), | 159 return _do_help(&cmd_cros_sub[0], ARRAY_SIZE(cmd_cros_sub), |
| 160 cmdtp, flag, argc, argv); | 160 cmdtp, flag, argc, argv); |
| 161 | 161 |
| 162 c = find_cmd_tbl(argv[1], &cmd_cros_sub[0], ARRAY_SIZE(cmd_cros_sub)); | 162 c = find_cmd_tbl(argv[1], &cmd_cros_sub[0], ARRAY_SIZE(cmd_cros_sub)); |
| 163 if (!c) | 163 if (!c) |
| 164 USAGE(1, cmdtp, "Unrecognized action: %s\n", argv[1]); | 164 USAGE(1, cmdtp, "Unrecognized action: %s\n", argv[1]); |
| 165 | 165 |
| 166 cmd_usage(c); | 166 cmd_usage(c); |
| 167 return 0; | 167 return 0; |
| 168 } | 168 } |
| OLD | NEW |