#pragma once #include "arch.h" struct mg_flash { void *start; // Address at which flash starts size_t size; // Flash size size_t secsz; // Sector size size_t align; // Write alignment bool (*read_fn)(void *, void *, size_t); // Read function bool (*write_fn)(void *, const void *, size_t); // Write function bool (*swap_fn)(void); // Swap partitions bool (*init_fn)(struct mg_flash *); // Optional, fills runtime attributes }; extern struct mg_flash *mg_flash; // Reads memory-mapped (XIP) flash. Use as read_fn for such flash bool mg_flash_read_xip(void *addr, void *buf, size_t len);