Finishing fsmc driver

This commit is contained in:
Zhao_Jiasheng
2021-05-29 13:24:05 +08:00
parent 8b2d6082d1
commit 221bd363c9
18 changed files with 237 additions and 674 deletions

View File

@@ -37,6 +37,10 @@ menu "Kernel feature"
help
Alignment size for CPU architecture data access
config MEM_EXTERN_SRAM
bool "Using extern memory"
default n
config MM_PAGE_SIZE
int "Config memory page size"
default 4096

View File

@@ -85,7 +85,7 @@ void FreeBlockMemGather(void *data_block);
#endif
void InitBoardMemory(void *begin_addr, void *end_addr);
#ifdef DATA_IN_ExtSRAM
#ifdef MEM_EXTERN_SRAM
void ExtSramInitBoardMemory(void *start_phy_address, void *end_phy_address, uint8 extsram_idx);
#endif
void *x_malloc(x_size_t nbytes);

View File

@@ -22,8 +22,6 @@
#include <xiuos.h>
#include <string.h>
#define DATA_IN_ExtSRAM
#define MEM_STATS
/* Covert pointer to other structure */
@@ -167,7 +165,7 @@ static struct ByteMemory ByteManager;
static struct ByteMemory UserByteManager;
#endif
#ifdef DATA_IN_ExtSRAM
#ifdef MEM_EXTERN_SRAM
static struct ByteMemory ExtByteManager[EXTSRAM_MAX_NUM] = {0};
#endif
/**
@@ -393,7 +391,7 @@ static void* BigMemMalloc(struct DynamicBuddyMemory *dynamic_buddy, x_size_t siz
/* failure allocation */
if(result == NONE) {
#ifndef DATA_IN_ExtSRAM
#ifndef MEM_EXTERN_SRAM
KPrintf("%s: allocation failed, size %d.\n", __func__,allocsize);
#endif
return result;
@@ -600,7 +598,7 @@ static void *SmallMemMalloc(struct ByteMemory *byte_memory, x_size_t size)
/* the static memory block is exhausted, now turn to dynamic buddy memory for allocation. */
result = byte_memory->dynamic_buddy_manager.done->malloc(&byte_memory->dynamic_buddy_manager, size, DYNAMIC_BLOCK_NO_EXTMEM_MASK);
#ifdef DATA_IN_ExtSRAM
#ifdef MEM_EXTERN_SRAM
if(NONE == result) {
for(i = 0; i < EXTSRAM_MAX_NUM; i++) {
if(NONE != ExtByteManager[i].done) {
@@ -637,7 +635,7 @@ void *x_malloc(x_size_t size)
/* parameter detection */
#ifdef DATA_IN_ExtSRAM
#ifdef MEM_EXTERN_SRAM
/* parameter detection */
if(size == 0 ){
return NONE;
@@ -671,7 +669,7 @@ void *x_malloc(x_size_t size)
if(ret != NONE)
CHECK(ByteManager.dynamic_buddy_manager.done->JudgeLegal(&ByteManager.dynamic_buddy_manager, ret - SIZEOF_DYNAMICALLOCNODE_MEM));
try_extmem:
#ifdef DATA_IN_ExtSRAM
#ifdef MEM_EXTERN_SRAM
if(NONE == ret) {
for(i = 0; i < EXTSRAM_MAX_NUM; i++) {
if(NONE != ExtByteManager[i].done) {
@@ -798,7 +796,7 @@ void x_free(void *pointer)
} else
#endif
{
#ifdef DATA_IN_ExtSRAM
#ifdef MEM_EXTERN_SRAM
/* judge the pointer is not malloced from extern memory*/
if(0 == (node->flag & 0xFF0000)) {
ByteManager.dynamic_buddy_manager.done->release(&ByteManager,pointer);
@@ -816,7 +814,7 @@ void x_free(void *pointer)
CriticalAreaUnLock(lock);
}
#ifdef DATA_IN_ExtSRAM
#ifdef MEM_EXTERN_SRAM
/**
* This function initializes the dynamic buddy memory of extern sram.
*