slot.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Kaspar Schleiser <kaspar@schleiser.de>
3  * 2018 Inria
4  * 2018 Freie Universität Berlin
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
25 #ifndef RIOTBOOT_SLOT_H
26 #define RIOTBOOT_SLOT_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <stddef.h>
33 
34 #include "riotboot/hdr.h"
35 
41 int riotboot_slot_current(void);
42 
48 int riotboot_slot_other(void);
49 
57 uint32_t riotboot_slot_get_image_startaddr(unsigned slot);
58 
64 void riotboot_slot_jump(unsigned slot);
65 
73 const riotboot_hdr_t *riotboot_slot_get_hdr(unsigned slot);
74 
82 static inline int riotboot_slot_validate(unsigned slot)
83 {
85 }
86 
93 static inline void riotboot_slot_print_hdr(unsigned slot)
94 {
96 }
97 
101 size_t riotboot_slot_offset(unsigned slot);
102 
107 void riotboot_slot_dump_addrs(void);
108 
116 static inline size_t riotboot_slot_size(unsigned slot)
117 {
118  switch(slot) {
119  case 0:
120  return SLOT0_LEN;
121 #if NUM_SLOTS==2
122  case 1:
123  return SLOT1_LEN;
124 #endif
125  default:
126  return 0;
127  }
128 }
129 
133 extern const unsigned riotboot_slot_numof;
134 
138 extern const riotboot_hdr_t * const riotboot_slots[];
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* RIOTBOOT_SLOT_H */
riotboot_slot_other
int riotboot_slot_other(void)
Get currently not running image slot.
riotboot_slots
const riotboot_hdr_t *const riotboot_slots[]
Storage for header pointers of the configured slots.
riotboot_slot_numof
const unsigned riotboot_slot_numof
Number of configured firmware slots (incl.
riotboot_slot_get_hdr
const riotboot_hdr_t * riotboot_slot_get_hdr(unsigned slot)
Get header from a given flash slot.
riotboot_slot_current
int riotboot_slot_current(void)
Get currently running image slot.
riotboot_hdr_validate
int riotboot_hdr_validate(const riotboot_hdr_t *riotboot_hdr)
Validate image header.
hdr.h
RIOT "partition" header and tools.
riotboot_hdr_print
void riotboot_hdr_print(const riotboot_hdr_t *riotboot_hdr)
Print formatted riotboot_hdr_t to STDIO.
riotboot_slot_dump_addrs
void riotboot_slot_dump_addrs(void)
Dump the addresses of all configured slots.
riotboot_slot_size
static size_t riotboot_slot_size(unsigned slot)
Get the size of a slot.
Definition: slot.h:116
riotboot_slot_get_image_startaddr
uint32_t riotboot_slot_get_image_startaddr(unsigned slot)
Get jump-to address of image slot.
riotboot_slot_print_hdr
static void riotboot_slot_print_hdr(unsigned slot)
Print formatted slot header to STDIO.
Definition: slot.h:93
riotboot_slot_jump
void riotboot_slot_jump(unsigned slot)
Boot into image in slot slot.
riotboot_hdr_t
Structure to store image header - All members are little endian.
Definition: hdr.h:51
riotboot_slot_offset
size_t riotboot_slot_offset(unsigned slot)
Get the offset (in flash, in bytes) for a given slot.
riotboot_slot_validate
static int riotboot_slot_validate(unsigned slot)
Validate slot.
Definition: slot.h:82