slot.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2018 Kaspar Schleiser <kaspar@schleiser.de>
3  * SPDX-FileCopyrightText: 2018 Inria
4  * SPDX-FileCopyrightText: 2018 Freie Universität Berlin
5  * SPDX-License-Identifier: LGPL-2.1-only
6  */
7 
8 #pragma once
9 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <stddef.h>
29 
30 #include "riotboot/hdr.h"
31 
38 
45 
53 uint32_t riotboot_slot_get_image_startaddr(unsigned slot);
54 
60 void riotboot_slot_jump(unsigned slot);
61 
69 const riotboot_hdr_t *riotboot_slot_get_hdr(unsigned slot);
70 
77 {
78  int slot = riotboot_slot_current();
79  if (slot < 0) {
80  return NULL;
81  }
82  return riotboot_slot_get_hdr(slot);
83 }
84 
92 static inline int riotboot_slot_validate(unsigned slot)
93 {
95 }
96 
103 static inline void riotboot_slot_print_hdr(unsigned slot)
104 {
106 }
107 
111 size_t riotboot_slot_offset(unsigned slot);
112 
118 
126 static inline size_t riotboot_slot_size(unsigned slot)
127 {
128  switch (slot) {
129 #if NUM_SLOTS >= 1
130  case 0:
131  return SLOT0_LEN;
132 #endif
133 #if NUM_SLOTS == 2
134  case 1:
135  return SLOT1_LEN;
136 #endif
137  default:
138  return 0;
139  }
140 }
141 
145 extern const unsigned riotboot_slot_numof;
146 
150 extern const riotboot_hdr_t *const riotboot_slots[];
151 
152 #ifdef __cplusplus
153 }
154 #endif
RIOT "partition" header and tools.
int riotboot_hdr_validate(const riotboot_hdr_t *riotboot_hdr)
Validate image header.
void riotboot_hdr_print(const riotboot_hdr_t *riotboot_hdr)
Print formatted riotboot_hdr_t to STDIO.
void riotboot_slot_dump_addrs(void)
Dump the addresses of all configured slots.
const riotboot_hdr_t *const riotboot_slots[]
Storage for header pointers of the configured slots.
static const riotboot_hdr_t * riotboot_slot_get_current_hdr(void)
Get header from currently running image slot.
Definition: slot.h:76
uint32_t riotboot_slot_get_image_startaddr(unsigned slot)
Get jump-to address of image slot.
static void riotboot_slot_print_hdr(unsigned slot)
Print formatted slot header to STDIO.
Definition: slot.h:103
static size_t riotboot_slot_size(unsigned slot)
Get the size of a slot.
Definition: slot.h:126
void riotboot_slot_jump(unsigned slot)
Boot into image in slot slot.
const riotboot_hdr_t * riotboot_slot_get_hdr(unsigned slot)
Get header from a given flash slot.
static int riotboot_slot_validate(unsigned slot)
Validate slot.
Definition: slot.h:92
size_t riotboot_slot_offset(unsigned slot)
Get the offset (in flash, in bytes) for a given slot.
const unsigned riotboot_slot_numof
Number of configured firmware slots (incl.
int riotboot_slot_other(void)
Get currently not running image slot.
int riotboot_slot_current(void)
Get currently running image slot.
Structure to store image header - All members are little endian.
Definition: hdr.h:47