61 if (!force_recreate) {
70 perror(
"fopen flash");
75 memset(sector, 0xFF,
sizeof(sector));
79 fwrite(sector,
sizeof(sector), 1, flash_dev->
flash_file);
91 *chip_id = (uintptr_t)flash_dev;
141 if (fseek (flash_dev->
flash_file, chip_offset, SEEK_SET) != 0) {
168 if (fseek (flash_dev->
flash_file, chip_offset, SEEK_SET) != 0) {
173 s = fwrite (data, 1, len, flash_dev->
flash_file);
191 if (fseek (flash_dev->
flash_file, chip_offset, SEEK_SET) != 0) {
196 s = fread (data, 1, len, flash_dev->
flash_file);
#define PIOS_SEMAPHORE_TIMEOUT_MAX
static int32_t PIOS_Flash_Posix_EndTransaction(uintptr_t chip_id)
static int32_t PIOS_Flash_Posix_EraseSector(uintptr_t chip_id, uint32_t chip_sector, uint32_t chip_offset)
struct pios_semaphore * transaction_lock
static int32_t PIOS_Flash_Posix_WriteData(uintptr_t chip_id, uint32_t chip_offset, const uint8_t *data, uint16_t len)
enum flash_posix_magic magic
const struct pios_flash_driver pios_posix_flash_driver
void * PIOS_malloc(size_t size)
const struct pios_flash_posix_cfg * cfg
uint8_t data[XFER_BYTES_PER_PACKET]
static struct flyingpicmd_cfg_fa cfg
static int32_t PIOS_Flash_Posix_StartTransaction(uintptr_t chip_id)
struct pios_semaphore * PIOS_Semaphore_Create(void)
Creates a binary semaphore.
void PIOS_Flash_Posix_SetFName(const char *name)
bool PIOS_Semaphore_Give(struct pios_semaphore *sema)
Gives binary semaphore.
void PIOS_Flash_Posix_Destroy(uintptr_t chip_id)
void PIOS_free(void *buf)
static const char * PIOS_Flash_Posix_GetFName()
static const char * pios_flash_file_name
bool PIOS_Semaphore_Take(struct pios_semaphore *sema, uint32_t timeout_ms)
Takes binary semaphore.
int32_t PIOS_Flash_Posix_Init(uintptr_t *chip_id, const struct pios_flash_posix_cfg *cfg, bool force_recreate)
static struct flash_posix_dev * PIOS_Flash_Posix_Alloc(void)
static int32_t PIOS_Flash_Posix_ReadData(uintptr_t chip_id, uint32_t chip_offset, uint8_t *data, uint16_t len)
int32_t(* start_transaction)(uintptr_t chip_id)