Root/
| Source at commit 2dc2fb278cf17368265e066d025c2584d640f1a7 created 11 years 11 days ago. By Werner Almesberger, tornado/fw/tornado.c: update signal processing from sim/alg.c | |
|---|---|
| 1 | /* |
| 2 | * fw/reset.c - Reset protocol |
| 3 | * |
| 4 | * Written 2012 by Werner Almesberger |
| 5 | * Copyright 2012 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #include <stdbool.h> |
| 15 | #include <stdint.h> |
| 16 | #include <string.h> |
| 17 | |
| 18 | #include <avr/io.h> |
| 19 | #include <avr/pgmspace.h> |
| 20 | |
| 21 | #include "proto.h" |
| 22 | #include "dispatch.h" |
| 23 | #include "secret.h" |
| 24 | |
| 25 | |
| 26 | /* |
| 27 | * For now, we use the unlock secret for reset as well. The reasoning is as |
| 28 | * follows: |
| 29 | * |
| 30 | * - both secrets are transmitted in the clear and can therefore only be |
| 31 | * used in a trusted environment, |
| 32 | * - both secrets are used mainly during development and not needed for regular |
| 33 | * operation, |
| 34 | * - RESET is normally followed immediately by FIRMWARE, so a listener could |
| 35 | * intercept the secret(s) either way. |
| 36 | */ |
| 37 | |
| 38 | |
| 39 | static bool reset_first(uint8_t limit, const uint8_t *payload) |
| 40 | { |
| 41 | if (memcmp_P(payload, maint_secret, PAYLOAD)) |
| 42 | return 0; |
| 43 | WDTCSR = 1 << WDE; |
| 44 | return 1; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | struct handler reset_handler = { |
| 49 | .type = RESET, |
| 50 | .first = reset_first, |
| 51 | }; |
| 52 | |
Branches:
master
tornado-v1
