Source code for the Trusted Boot Module.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
tbm-mcu/include/flash.h

45 lines
1.7 KiB

#pragma once
#include <stdint.h>
#include <stdlib.h>
struct flash_dev;
struct flash_ops {
void (* release)(struct flash_dev *dev);
size_t (* get_jedec_id)(struct flash_dev *dev, char *jedec_id, size_t len);
size_t (* get_size)(struct flash_dev *dev);
size_t (* get_capacity)(struct flash_dev *dev);
size_t (* read)(struct flash_dev *dev, uint32_t addr, void *data, size_t len);
size_t (* write)(struct flash_dev *dev, uint32_t addr, const void *data,
size_t len);
size_t (* copy)(struct flash_dev *dev, uint32_t dst, uint32_t src, size_t len);
int (* is_erased)(struct flash_dev *dev, uint32_t addr);
int (* erase)(struct flash_dev *dev, uint32_t addr);
int (* sync)(struct flash_dev *dev);
};
struct flash_dev {
struct flash_ops *ops;
void *priv;
uint8_t log2_block_size;
};
int default_flash_is_zero(struct flash_dev *dev, uint32_t addr);
int default_flash_is_one(struct flash_dev *dev, uint32_t addr);
size_t default_flash_copy(struct flash_dev *dev, uint32_t dst, uint32_t src,
size_t len);
struct flash_dev *flash_probe(void);
void flash_release(struct flash_dev *dev);
size_t flash_get_jedec_id(struct flash_dev *dev, char *jedec_id, size_t len);
size_t flash_get_size(struct flash_dev *dev);
size_t flash_get_capacity(struct flash_dev *dev);
size_t flash_read(struct flash_dev *dev, uint32_t addr, void *data, size_t len);
size_t flash_write(struct flash_dev *dev, uint32_t addr, const void *data,
size_t len);
size_t flash_write0(struct flash_dev *dev, uint32_t addr, size_t len);
size_t flash_copy(struct flash_dev *dev, uint32_t dst, uint32_t src, size_t len);
int flash_is_erased(struct flash_dev *dev, uint32_t addr, size_t len);
int flash_erase(struct flash_dev *dev, uint32_t addr, size_t len);
int flash_sync(struct flash_dev *dev);