Loading...
Searching...
No Matches
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
11#pragma once
12
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <stddef.h>
32
33#include "riotboot/hdr.h"
34
41
48
56uint32_t riotboot_slot_get_image_startaddr(unsigned slot);
57
63void riotboot_slot_jump(unsigned slot);
64
73
80{
81 int slot = riotboot_slot_current();
82 if (slot < 0) {
83 return NULL;
84 }
85 return riotboot_slot_get_hdr(slot);
86}
87
95static inline int riotboot_slot_validate(unsigned slot)
96{
98}
99
106static inline void riotboot_slot_print_hdr(unsigned slot)
107{
109}
110
114size_t riotboot_slot_offset(unsigned slot);
115
121
129static inline size_t riotboot_slot_size(unsigned slot)
130{
131 switch (slot) {
132#if NUM_SLOTS >= 1
133 case 0:
134 return SLOT0_LEN;
135#endif
136#if NUM_SLOTS == 2
137 case 1:
138 return SLOT1_LEN;
139#endif
140 default:
141 return 0;
142 }
143}
144
148extern const unsigned riotboot_slot_numof;
149
153extern const riotboot_hdr_t *const riotboot_slots[];
154
155#ifdef __cplusplus
156}
157#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.
uint32_t riotboot_slot_get_image_startaddr(unsigned slot)
Get jump-to address of image slot.
static const riotboot_hdr_t * riotboot_slot_get_current_hdr(void)
Get header from currently running image slot.
Definition slot.h:79
static void riotboot_slot_print_hdr(unsigned slot)
Print formatted slot header to STDIO.
Definition slot.h:106
static size_t riotboot_slot_size(unsigned slot)
Get the size of a slot.
Definition slot.h:129
void riotboot_slot_jump(unsigned slot)
Boot into image in slot slot.
static int riotboot_slot_validate(unsigned slot)
Validate slot.
Definition slot.h:95
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.
const riotboot_hdr_t * riotboot_slot_get_hdr(unsigned slot)
Get header from a given flash slot.
int riotboot_slot_current(void)
Get currently running image slot.
Structure to store image header - All members are little endian.
Definition hdr.h:50