projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
SEC: Add AES implementation.
[bertos.git]
/
bertos
/
cpu
/
cortex-m3
/
drv
/
flash_lm3s.c
diff --git
a/bertos/cpu/cortex-m3/drv/flash_lm3s.c
b/bertos/cpu/cortex-m3/drv/flash_lm3s.c
index dbabc08ae7185b2979794de9b800fb22dff1eb06..7ca0a7cf33b126e3b8577f31e26a3e088a2be6d0 100644
(file)
--- a/
bertos/cpu/cortex-m3/drv/flash_lm3s.c
+++ b/
bertos/cpu/cortex-m3/drv/flash_lm3s.c
@@
-36,8
+36,12
@@
*/
#include "flash_lm3s.h"
*/
#include "flash_lm3s.h"
-#include "cfg/
log
.h"
+#include "cfg/
cfg_emb_flash
.h"
+// Define log settings for cfg/log.h
+#define LOG_LEVEL CONFIG_FLASH_EMB_LOG_LEVEL
+#define LOG_FORMAT CONFIG_FLASH_EMB_LOG_FORMAT
+#include <cfg/log.h>
#include <cfg/macros.h>
#include <io/kblock.h>
#include <cfg/macros.h>
#include <io/kblock.h>
@@
-55,13
+59,13
@@
struct FlashHardware
int status;
};
int status;
};
-static bool flash_wait(struct KBlock *blk)
+static bool flash_wait(struct KBlock *blk
, uint32_t event
)
{
Flash *fls = FLASH_CAST(blk);
ticks_t start = timer_clock();
while (true)
{
{
Flash *fls = FLASH_CAST(blk);
ticks_t start = timer_clock();
while (true)
{
- if (!(FLASH_FMC_R &
FLASH_FMC_ERASE
))
+ if (!(FLASH_FMC_R &
event
))
break;
if (FLASH_FCRIS_R & FLASH_FCRIS_ARIS)
break;
if (FLASH_FCRIS_R & FLASH_FCRIS_ARIS)
@@
-91,7
+95,7
@@
static int lm3s_erasePage(struct KBlock *blk, uint32_t addr)
FLASH_FMA_R = (volatile uint32_t)addr;
FLASH_FMC_R = FLASH_FMC_WRKEY | FLASH_FMC_ERASE;
FLASH_FMA_R = (volatile uint32_t)addr;
FLASH_FMC_R = FLASH_FMC_WRKEY | FLASH_FMC_ERASE;
- return flash_wait(blk);
+ return flash_wait(blk
, FLASH_FMC_ERASE
);
}
static int lm3s_writeWord(struct KBlock *blk, uint32_t addr, uint32_t data)
}
static int lm3s_writeWord(struct KBlock *blk, uint32_t addr, uint32_t data)
@@
-102,7
+106,7
@@
static int lm3s_writeWord(struct KBlock *blk, uint32_t addr, uint32_t data)
FLASH_FMD_R = (volatile uint32_t)data;
FLASH_FMC_R = FLASH_FMC_WRKEY | FLASH_FMC_WRITE;
FLASH_FMD_R = (volatile uint32_t)data;
FLASH_FMC_R = FLASH_FMC_WRKEY | FLASH_FMC_WRITE;
- return flash_wait(blk);
+ return flash_wait(blk
, FLASH_FMC_WRITE
);
}
static size_t lm3s_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size)
}
static size_t lm3s_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size)
@@
-113,6
+117,7
@@
static size_t lm3s_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *b
static size_t lm3s_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const void *_buf, size_t offset, size_t size)
{
static size_t lm3s_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const void *_buf, size_t offset, size_t size)
{
+ (void)offset;
ASSERT(offset == 0);
ASSERT(size == blk->blk_size);
ASSERT(offset == 0);
ASSERT(size == blk->blk_size);
@@
-162,6
+167,8
@@
static const KBlockVTable flash_lm3s_buffered_vt =
.load = kblock_swLoad,
.store = kblock_swStore,
.load = kblock_swLoad,
.store = kblock_swStore,
+ .close = kblock_swClose,
+
.error = lm3s_flash_error,
.clearerr = lm3s_flash_clearerror,
};
.error = lm3s_flash_error,
.clearerr = lm3s_flash_clearerror,
};
@@
-171,20
+178,14
@@
static const KBlockVTable flash_lm3s_unbuffered_vt =
.readDirect = lm3s_flash_readDirect,
.writeDirect = lm3s_flash_writeDirect,
.readDirect = lm3s_flash_readDirect,
.writeDirect = lm3s_flash_writeDirect,
+ .close = kblock_swClose,
+
.error = lm3s_flash_error,
.clearerr = lm3s_flash_clearerror,
};
.error = lm3s_flash_error,
.clearerr = lm3s_flash_clearerror,
};
-/* Flash memory mapping */
-#if CPU_CM3_LM3S1968
- #define EMB_FLASH_SIZE 0x40000 //< 256KiB
- #define EMB_FLASH_PAGE_SIZE 0x400 //< 1KiB
-#else
- #error Unknown CPU
-#endif
-
static struct FlashHardware flash_lm3s_hw;
static struct FlashHardware flash_lm3s_hw;
-static uint8_t flash_buf[
EMB_
FLASH_PAGE_SIZE];
+static uint8_t flash_buf[FLASH_PAGE_SIZE];
static void common_init(Flash *fls)
{
static void common_init(Flash *fls)
{
@@
-195,23
+196,28
@@
static void common_init(Flash *fls)
fls->hw = &flash_lm3s_hw;
fls->hw = &flash_lm3s_hw;
- fls->blk.blk_size =
EMB_
FLASH_PAGE_SIZE;
- fls->blk.blk_cnt =
EMB_FLASH_SIZE / EMB_
FLASH_PAGE_SIZE;
+ fls->blk.blk_size = FLASH_PAGE_SIZE;
+ fls->blk.blk_cnt =
FLASH_SIZE /
FLASH_PAGE_SIZE;
}
}
-void flash_hw_init(Flash *fls)
+void flash_hw_init(Flash *fls
, int flags
)
{
common_init(fls);
fls->blk.priv.vt = &flash_lm3s_buffered_vt;
{
common_init(fls);
fls->blk.priv.vt = &flash_lm3s_buffered_vt;
- fls->blk.priv.flags |= KB_BUFFERED | KB_PARTIAL_WRITE;
+ fls->blk.priv.flags |= KB_BUFFERED | KB_PARTIAL_WRITE
| flags
;
fls->blk.priv.buf = flash_buf;
fls->blk.priv.buf = flash_buf;
+
+ /* Load the first block in the cache */
+ void *flash_start = 0x0;
+ memcpy(fls->blk.priv.buf, flash_start, fls->blk.blk_size);
}
}
-void flash_hw_initUnbuffered(Flash *fls)
+void flash_hw_initUnbuffered(Flash *fls
, int flags
)
{
common_init(fls);
fls->blk.priv.vt = &flash_lm3s_unbuffered_vt;
{
common_init(fls);
fls->blk.priv.vt = &flash_lm3s_unbuffered_vt;
+ fls->blk.priv.flags |= flags;
}
}