dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
loadable_extension.h
Go to the documentation of this file.
1 
9 /*
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18  * for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, see <http://www.gnu.org/licenses/>
22  *
23  * Additional note on redistribution: The copyright and license notices above
24  * must be maintained in each individual source file that is a derivative work
25  * of this source file; otherwise redistribution is prohibited.
26  */
27 
28 #ifndef _LOADABLE_EXTENSION_H
29 #define _LOADABLE_EXTENSION_H
30 
31 #include <stdint.h>
32 
33 /* 48 byte header-- containing a high degree of redundancy/verification
34  * for sanity. Payload immediately follows.
35  */
37 #define LOADABLE_EXTENSION_MAGIC 0x58655264 /* 'dReX' little endian */
38 #define LOADABLE_EXTENSION_UNPROGRAMMED 0xffffffff
39  uint32_t magic;
40  uint32_t length;
42  uint32_t reserved[2];
44 #define LOADABLE_REQUIRE_VERSION_INVALID 0x00000000
45 #define LOADABLE_REQUIRE_VERSION_WIRED 0x00000001
46  uint32_t require_version;
48  uint32_t ram_seg_len;
49  uint32_t ram_seg_copylen;
50  uint32_t ram_seg_copyoff;
53  uint32_t ram_seg_gotlen;
58  uint32_t entry_offset;
59  uint32_t header_crc;
60  uint32_t payload_crc;
61 };
62 
63 #define DECLARE_LOADABLE_EXTENSION(ent_func) \
64 extern char _sidata; \
65 extern char _eidata; \
66  \
67 extern char _copylen; \
68 extern char _gotlen; \
69 extern char _ramlen; \
70  \
71 const struct loadable_extension lext __attribute__((section (".extension_header"))) = { \
72  .magic = LOADABLE_EXTENSION_MAGIC, \
73  .length = (uint32_t) &_eidata, \
74  .require_version = LOADABLE_REQUIRE_VERSION_WIRED, \
75  .entry_offset = (uint32_t) ent_func, \
76  .ram_seg_copyoff = (uint32_t) &_sidata, \
77  /* These next & opers are lies, because they're lengths, not offsets */ \
78  .ram_seg_len = (uint32_t) &_ramlen, \
79  .ram_seg_copylen = (uint32_t) &_copylen, \
80  .ram_seg_gotlen = (uint32_t) &_gotlen, \
81 }
82 
83 #endif
84