projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add CPU_CORE_NAME and CPU_NAME macros for debugging purposes.
[bertos.git]
/
bertos
/
cpu
/
arm
/
drv
/
flash_lpc2.c
diff --git
a/bertos/cpu/arm/drv/flash_lpc2.c
b/bertos/cpu/arm/drv/flash_lpc2.c
index 99cf91e89a4ccb66beba63233d7348e29405cbf8..a78ade27c8bfe111e560d10a4a165071d3cc37c4 100644
(file)
--- a/
bertos/cpu/arm/drv/flash_lpc2.c
+++ b/
bertos/cpu/arm/drv/flash_lpc2.c
@@
-94,7
+94,8
@@
struct FlashHardware
#define FLASH_PAGE_CNT FLASH_MEM_SIZE / FLASH_PAGE_SIZE_BYTES
#define FLASH_PAGE_CNT FLASH_MEM_SIZE / FLASH_PAGE_SIZE_BYTES
-ALLOC_BITARRAY(page_dirty, FLASH_PAGE_CNT);
+BITARRAY_ALLOC(page_dirty, FLASH_PAGE_CNT);
+static BitArray lpc2_bitx;
uint8_t erase_group[] = {
uint8_t erase_group[] = {
@@
-178,10
+179,7
@@
static uint32_t addr_to_sector(size_t addr)
static size_t lpc2_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size)
{
static size_t lpc2_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size)
{
- ASSERT(offset == 0);
- ASSERT(size == blk->blk_size);
-
- memcpy(buf, (void *)(idx * blk->blk_size), size);
+ memcpy(buf, (void *)(idx * blk->blk_size + offset), size);
return size;
}
return size;
}
@@
-216,7
+214,7
@@
static size_t lpc2_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const
goto flash_error;
if ((fls->blk.priv.flags & KB_WRITE_ONCE) &&
goto flash_error;
if ((fls->blk.priv.flags & KB_WRITE_ONCE) &&
- bitarray_
blockFull(idx_sector, erase_group[sector], page_dirty, FLASH_PAGE_CNT
))
+ bitarray_
isRangeFull(&lpc2_bitx, idx_sector, erase_group[sector]
))
{
kputs("blocchi pieni\n");
ASSERT(0);
{
kputs("blocchi pieni\n");
ASSERT(0);
@@
-225,7
+223,7
@@
static size_t lpc2_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const
bool erase = false;
if ((fls->blk.priv.flags & KB_WRITE_ONCE) &&
bool erase = false;
if ((fls->blk.priv.flags & KB_WRITE_ONCE) &&
- bitarray_
blockEmpty(idx_sector, erase_group[sector], page_dirty, FLASH_PAGE_CNT
))
+ bitarray_
isRangeEmpty(&lpc2_bitx, idx_sector, erase_group[sector]
))
erase = true;
if (!(fls->blk.priv.flags & KB_WRITE_ONCE))
erase = true;
if (!(fls->blk.priv.flags & KB_WRITE_ONCE))
@@
-252,13
+250,13
@@
static size_t lpc2_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const
if (fls->blk.priv.flags & KB_WRITE_ONCE)
{
if (fls->blk.priv.flags & KB_WRITE_ONCE)
{
- if (bitarray_
check(idx, page_dirty, FLASH_PAGE_CNT
))
+ if (bitarray_
test(&lpc2_bitx, idx
))
{
ASSERT(0);
goto flash_error;
}
else
{
ASSERT(0);
goto flash_error;
}
else
- bitarray_set(
idx, page_dirty, FLASH_PAGE_CNT
);
+ bitarray_set(
&lpc2_bitx, idx
);
}
cmd.cmd = COPY_RAM_TO_FLASH;
}
cmd.cmd = COPY_RAM_TO_FLASH;
@@
-340,6
+338,8
@@
static void common_init(Flash *fls)
fls->blk.blk_size = FLASH_PAGE_SIZE_BYTES;
fls->blk.blk_cnt = FLASH_MEM_SIZE / FLASH_PAGE_SIZE_BYTES;
fls->blk.blk_size = FLASH_PAGE_SIZE_BYTES;
fls->blk.blk_cnt = FLASH_MEM_SIZE / FLASH_PAGE_SIZE_BYTES;
+
+ bitarray_init(&lpc2_bitx, FLASH_PAGE_CNT, page_dirty, sizeof(page_dirty));
}
void flash_hw_init(Flash *fls, int flags)
}
void flash_hw_init(Flash *fls, int flags)