diff options
author | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-09-03 18:56:40 -0400 |
---|---|---|
committer | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-10-19 02:55:52 -0400 |
commit | 32742e6158657f19ad31653705bef56d983508e7 (patch) | |
tree | 05a13b990dac551c18e1fd468ca1383b86f40e0c | |
parent | 59bdc4be0b819173a8f840fc11ccb82d6f2ca64b (diff) |
wimax/i2400m: decide properly if using signed vs non-signed firmware loading
The i2400m based devices can boot two main types of firmware images:
signed and non-signed. Signed images have signature data included that
must match that of a certificate stored in the device.
Currently the code is making the decission on what type of firmware
load (signed vs non-signed) is going to be loaded based on a hardcoded
decission in __i2400m_ack_verify(), based on the barker the device
sent upon boot.
This is not flexible enough as future hardware will emit more barkers;
thus the bit has to be set in a place where there is better knowledge
of what is going on. This will be done in follow-up commits -- however
this patch paves the way for it.
So the querying of the mode is packed into i2400m_boot_is_signed();
the main changes are just using i2400m_boot_is_signed() to determine
the method to follow and setting i2400m->sboot in
i2400m_is_boot_barker(). The modifications in i2400m_dnload_init() and
i2400m_dnload_finalize() are just reorganizing the order of the if
blocks and thus look larger than they really are.
Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
-rw-r--r-- | drivers/net/wimax/i2400m/fw.c | 35 | ||||
-rw-r--r-- | include/linux/wimax/i2400m.h | 10 |
2 files changed, 21 insertions, 24 deletions
diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c index 92d4d605dc2d..c962a8d8df7e 100644 --- a/drivers/net/wimax/i2400m/fw.c +++ b/drivers/net/wimax/i2400m/fw.c | |||
@@ -509,6 +509,17 @@ error_send: | |||
509 | 509 | ||
510 | 510 | ||
511 | /* | 511 | /* |
512 | * Indicate if the device emitted a reboot barker that indicates | ||
513 | * "signed boot" | ||
514 | */ | ||
515 | static | ||
516 | unsigned i2400m_boot_is_signed(struct i2400m *i2400m) | ||
517 | { | ||
518 | return likely(i2400m->sboot); | ||
519 | } | ||
520 | |||
521 | |||
522 | /* | ||
512 | * Do the final steps of uploading firmware | 523 | * Do the final steps of uploading firmware |
513 | * | 524 | * |
514 | * Depending on the boot mode (signed vs non-signed), different | 525 | * Depending on the boot mode (signed vs non-signed), different |
@@ -529,7 +540,7 @@ int i2400m_dnload_finalize(struct i2400m *i2400m, | |||
529 | 540 | ||
530 | d_fnstart(3, dev, "offset %zu\n", offset); | 541 | d_fnstart(3, dev, "offset %zu\n", offset); |
531 | cmd = (void *) bcf + offset; | 542 | cmd = (void *) bcf + offset; |
532 | if (i2400m->sboot == 0) { | 543 | if (i2400m_boot_is_signed(i2400m) == 0) { |
533 | struct i2400m_bootrom_header jump_ack; | 544 | struct i2400m_bootrom_header jump_ack; |
534 | d_printf(1, dev, "unsecure boot, jumping to 0x%08x\n", | 545 | d_printf(1, dev, "unsecure boot, jumping to 0x%08x\n", |
535 | le32_to_cpu(cmd->target_addr)); | 546 | le32_to_cpu(cmd->target_addr)); |
@@ -846,28 +857,24 @@ int i2400m_dnload_init(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf) | |||
846 | { | 857 | { |
847 | int result; | 858 | int result; |
848 | struct device *dev = i2400m_dev(i2400m); | 859 | struct device *dev = i2400m_dev(i2400m); |
849 | u32 module_id = le32_to_cpu(bcf->module_id); | ||
850 | 860 | ||
851 | if (i2400m->sboot == 0 | 861 | if (i2400m_boot_is_signed(i2400m)) { |
852 | && (module_id & I2400M_BCF_MOD_ID_POKES) == 0) { | 862 | d_printf(1, dev, "signed boot\n"); |
853 | /* non-signed boot process without pokes */ | 863 | result = i2400m_dnload_init_signed(i2400m, bcf); |
854 | result = i2400m_dnload_init_nonsigned(i2400m); | ||
855 | if (result == -ERESTARTSYS) | 864 | if (result == -ERESTARTSYS) |
856 | return result; | 865 | return result; |
857 | if (result < 0) | 866 | if (result < 0) |
858 | dev_err(dev, "fw %s: non-signed download " | 867 | dev_err(dev, "firmware %s: signed boot download " |
859 | "initialization failed: %d\n", | 868 | "initialization failed: %d\n", |
860 | i2400m->fw_name, result); | 869 | i2400m->fw_name, result); |
861 | } else if (i2400m->sboot == 0 | 870 | } else { |
862 | && (module_id & I2400M_BCF_MOD_ID_POKES)) { | 871 | /* non-signed boot process without pokes */ |
863 | /* non-signed boot process with pokes, nothing to do */ | 872 | d_printf(1, dev, "non-signed boot\n"); |
864 | result = 0; | 873 | result = i2400m_dnload_init_nonsigned(i2400m); |
865 | } else { /* signed boot process */ | ||
866 | result = i2400m_dnload_init_signed(i2400m, bcf); | ||
867 | if (result == -ERESTARTSYS) | 874 | if (result == -ERESTARTSYS) |
868 | return result; | 875 | return result; |
869 | if (result < 0) | 876 | if (result < 0) |
870 | dev_err(dev, "fw %s: signed boot download " | 877 | dev_err(dev, "firmware %s: non-signed download " |
871 | "initialization failed: %d\n", | 878 | "initialization failed: %d\n", |
872 | i2400m->fw_name, result); | 879 | i2400m->fw_name, result); |
873 | } | 880 | } |
diff --git a/include/linux/wimax/i2400m.h b/include/linux/wimax/i2400m.h index 433693ef2bb0..d6e2a3595682 100644 --- a/include/linux/wimax/i2400m.h +++ b/include/linux/wimax/i2400m.h | |||
@@ -168,16 +168,6 @@ enum i2400m_brh { | |||
168 | }; | 168 | }; |
169 | 169 | ||
170 | 170 | ||
171 | /* Constants for bcf->module_id */ | ||
172 | enum i2400m_bcf_mod_id { | ||
173 | /* Firmware file carries its own pokes -- pokes are a set of | ||
174 | * magical values that have to be written in certain memory | ||
175 | * addresses to get the device up and ready for firmware | ||
176 | * download when it is in non-signed boot mode. */ | ||
177 | I2400M_BCF_MOD_ID_POKES = 0x000000001, | ||
178 | }; | ||
179 | |||
180 | |||
181 | /** | 171 | /** |
182 | * i2400m_bootrom_header - Header for a boot-mode command | 172 | * i2400m_bootrom_header - Header for a boot-mode command |
183 | * | 173 | * |