|
|
|
@ -5,9 +5,9 @@ |
|
|
|
|
#include <flash.h> |
|
|
|
|
#include <macros.h> |
|
|
|
|
|
|
|
|
|
int default_flash_is_erased(struct flash_dev *dev, uint32_t addr) |
|
|
|
|
static int default_flash_is_val(struct flash_dev *dev, uint32_t addr, char val) |
|
|
|
|
{ |
|
|
|
|
uint8_t data[32]; |
|
|
|
|
char data[32]; |
|
|
|
|
size_t i, nbytes, len = 1 << dev->log2_block_size; |
|
|
|
|
|
|
|
|
|
addr <<= dev->log2_block_size; |
|
|
|
@ -19,7 +19,7 @@ int default_flash_is_erased(struct flash_dev *dev, uint32_t addr) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(data); ++i) { |
|
|
|
|
if (data[i] != 0xff) |
|
|
|
|
if (data[i] != val) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -30,6 +30,16 @@ int default_flash_is_erased(struct flash_dev *dev, uint32_t addr) |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int default_flash_is_zero(struct flash_dev *dev, uint32_t addr) |
|
|
|
|
{ |
|
|
|
|
return default_flash_is_val(dev, addr, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int default_flash_is_one(struct flash_dev *dev, uint32_t addr) |
|
|
|
|
{ |
|
|
|
|
return default_flash_is_val(dev, addr, 0xff); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
size_t default_flash_copy(struct flash_dev *dev, uint32_t dst, uint32_t src, |
|
|
|
|
size_t len) |
|
|
|
|
{ |
|
|
|
|