libnile
Loading...
Searching...
No Matches
flash_layout.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Adrian "asie" Siekierka
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 *
17 * 2. Altered source versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software.
19 *
20 * 3. This notice may not be removed or altered from any source distribution.
21 */
22
23#ifndef NILE_FLASH_LAYOUT_H_
24#define NILE_FLASH_LAYOUT_H_
25
26#include <wonderful.h>
27
28#define NILE_FLASH_LAYOUT_FPGA_FACTORY_ADDR 0x000000
29#define NILE_FLASH_LAYOUT_IPL1_FACTORY_ADDR 0x008000
30#define NILE_FLASH_LAYOUT_IPL1_RECOVERY_ADDR 0x00C000
31#define NILE_FLASH_LAYOUT_MANIFEST_FACTORY_ADDR 0x00F000
32#define NILE_FLASH_LAYOUT_RECOVERY_FACTORY_ADDR 0x010000
33#define NILE_FLASH_LAYOUT_FACTORY_SIZE 0x040000
34
35#define NILE_FLASH_LAYOUT_FPGA_SIZE 0x008000
36#define NILE_FLASH_LAYOUT_IPL1_ADDR 0x040000
37#define NILE_FLASH_LAYOUT_IPL1_SIZE 0x004000
38#define NILE_FLASH_LAYOUT_MANIFEST_ADDR 0x04F000
39#define NILE_FLASH_LAYOUT_RECOVERY_ADDR 0x050000
40#define NILE_FLASH_LAYOUT_RECOVERY_SIZE 0x030000
41#define NILE_FLASH_LAYOUT_FPGA0_ADDR 0x080000
42#define NILE_FLASH_LAYOUT_FPGA1_ADDR 0x088000
43#define NILE_FLASH_LAYOUT_FPGA2_ADDR 0x090000
44#define NILE_FLASH_LAYOUT_FPGA3_ADDR 0x098000
45
46#ifndef __ASSEMBLER__
47
48#include <stdbool.h>
49#include <stdint.h>
50
51#define NILE_FLASH_MANIFEST_ID 0x5746
52
56typedef struct __attribute__((packed)) {
57 uint16_t id;
58 uint16_t major;
59 uint16_t minor;
60 uint16_t patch;
61 uint8_t reserved[3];
64
68typedef struct __attribute__((packed)) {
70 uint8_t commit_id[20];
71 uint8_t digest[32];
73
74static inline bool nile_flash_layout_read_version(void __far* buffer, size_t size) {
76}
77
78static inline bool nile_flash_layout_read_version_factory(void __far* buffer, size_t size) {
80}
81
82bool nile_flash_layout_version_at_least(uint16_t major, uint16_t minor, uint16_t patch);
83bool nile_flash_layout_version_compatible(uint16_t major, uint16_t minor, uint16_t patch, uint16_t first_incompatible_major);
84
85#endif
86
87#endif /* NILE_FLASH_LAYOUT_H_ */
bool nile_flash_read(void __far *buffer, uint32_t address, uint16_t size)
Read data from SPI flash.
bool nile_flash_layout_version_compatible(uint16_t major, uint16_t minor, uint16_t patch, uint16_t first_incompatible_major)
#define NILE_FLASH_LAYOUT_MANIFEST_ADDR
static bool nile_flash_layout_read_version(void __far *buffer, size_t size)
#define NILE_FLASH_LAYOUT_MANIFEST_FACTORY_ADDR
static bool nile_flash_layout_read_version_factory(void __far *buffer, size_t size)
bool nile_flash_layout_version_at_least(uint16_t major, uint16_t minor, uint16_t patch)
Firmware flash version manifest data structure.
nile_flash_version_t version
Firmware flash version data structure.
uint16_t id
Magic value, should be equal to NILE_FLASH_MANIFEST_ID.
uint16_t major
Major version number.
uint16_t minor
Minor version number.
uint16_t patch
Patch version number.
uint8_t partial_install
0x00 if install successful, non-0x00 if partial