forked from xuos/xiuos
Merge branch 'fix_bug' of https://git.trustie.net/huangyuqing/xiuos into fix_bug
This commit is contained in:
commit
59f6f8d89c
|
@ -54,7 +54,6 @@ Modification:
|
||||||
extern x_base cpu2_boot_flag;
|
extern x_base cpu2_boot_flag;
|
||||||
extern void entry(void);
|
extern void entry(void);
|
||||||
extern void SecondaryCpuCStart(void);
|
extern void SecondaryCpuCStart(void);
|
||||||
extern void ShutdownCpu(void);
|
|
||||||
extern int IoConfigInit(void);
|
extern int IoConfigInit(void);
|
||||||
extern int HwSpiInit(void);
|
extern int HwSpiInit(void);
|
||||||
extern int HwI2cInit(void);
|
extern int HwI2cInit(void);
|
||||||
|
@ -187,25 +186,3 @@ void HwCpuReset(void)
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),
|
||||||
reboot, HwCpuReset, reset machine );
|
reboot, HwCpuReset, reset machine );
|
||||||
static void (*pre_shutdown_action)(void *);
|
|
||||||
static void *pre_shutdown_action_arg;
|
|
||||||
|
|
||||||
void SetPreShutdownAction(void (*func)(void *), void *arg)
|
|
||||||
{
|
|
||||||
pre_shutdown_action = func;
|
|
||||||
pre_shutdown_action_arg = arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CmdShutdown()
|
|
||||||
{
|
|
||||||
#ifdef FS_VFS
|
|
||||||
SyncOpenedFiles();
|
|
||||||
#endif
|
|
||||||
if (pre_shutdown_action != NULL)
|
|
||||||
pre_shutdown_action(pre_shutdown_action_arg);
|
|
||||||
|
|
||||||
ShutdownCpu();
|
|
||||||
}
|
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),
|
|
||||||
shutdown,CmdShutdown,shutdown machine);
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ extern void ShowMemory(void);
|
||||||
extern long ShowSem(void);
|
extern long ShowSem(void);
|
||||||
extern long ShowEvent(void);
|
extern long ShowEvent(void);
|
||||||
extern long ShowMutex(void);
|
extern long ShowMutex(void);
|
||||||
//extern long ShowMemPool(void);
|
//extern long ShowGatherMem(void);
|
||||||
extern long ShowMsgQueue(void);
|
extern long ShowMsgQueue(void);
|
||||||
//extern long showdevice(void);
|
//extern long showdevice(void);
|
||||||
extern long ShowTimer(void);
|
extern long ShowTimer(void);
|
||||||
|
@ -75,7 +75,7 @@ uintptr_t KsPrintInfo(uint32_t knum,uintptr_t *param, uint8_t num )
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
//ShowMemPool();
|
//ShowGatherMem();
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
#ifdef KERNEL_MESSAGEQUEUE
|
#ifdef KERNEL_MESSAGEQUEUE
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <xiuos.h>
|
#include <xiuos.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern long ShowMemPool(void);
|
extern long ShowGatherMem(void);
|
||||||
extern void ShowMemory(void);
|
extern void ShowMemory(void);
|
||||||
extern void ShowBuddy(void);
|
extern void ShowBuddy(void);
|
||||||
/**************************single gatherblock test sample***********************************/
|
/**************************single gatherblock test sample***********************************/
|
||||||
|
@ -93,7 +93,7 @@ int SingleGatherblockTest(char * parameter)
|
||||||
if(0 == strncmp("static", parameter, strlen("static"))){
|
if(0 == strncmp("static", parameter, strlen("static"))){
|
||||||
KPrintf("test static create gatherblock.\n");
|
KPrintf("test static create gatherblock.\n");
|
||||||
InitMemGather(&gm, "mp_s", &mempool[0], sizeof(mempool), 80);
|
InitMemGather(&gm, "mp_s", &mempool[0], sizeof(mempool), 80);
|
||||||
ShowMemPool();
|
ShowGatherMem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 == strncmp("dynamic", parameter, strlen("dynamic"))){
|
if(0 == strncmp("dynamic", parameter, strlen("dynamic"))){
|
||||||
|
@ -105,7 +105,7 @@ int SingleGatherblockTest(char * parameter)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowMemPool();
|
ShowGatherMem();
|
||||||
}
|
}
|
||||||
/* create task1, alloc memory blocks */
|
/* create task1, alloc memory blocks */
|
||||||
tid1 = KTaskCreate("task1", Task1GmAlloc, parameter,
|
tid1 = KTaskCreate("task1", Task1GmAlloc, parameter,
|
||||||
|
@ -204,7 +204,7 @@ int MultipleGatherblockTest(void)
|
||||||
KPrintf("create m_gm_d2 failed.");
|
KPrintf("create m_gm_d2 failed.");
|
||||||
CHECK(0);
|
CHECK(0);
|
||||||
}
|
}
|
||||||
ShowMemPool();
|
ShowGatherMem();
|
||||||
|
|
||||||
/* create task1, alloc memory blocks */
|
/* create task1, alloc memory blocks */
|
||||||
m_tid1 = KTaskCreate("task1_m", Task1AllocEntry, NONE,
|
m_tid1 = KTaskCreate("task1_m", Task1AllocEntry, NONE,
|
||||||
|
@ -443,7 +443,7 @@ int RandomAllocFreeTest(void *parameter)
|
||||||
if(0 == strncmp("static", parameter, strlen("static"))){
|
if(0 == strncmp("static", parameter, strlen("static"))){
|
||||||
KPrintf("test static create gatherblock-%s.\n",parameter);
|
KPrintf("test static create gatherblock-%s.\n",parameter);
|
||||||
InitMemGather(&random_static_gm, "ran_mp_s", &dynamic_mempool[0], sizeof(dynamic_mempool), 80);
|
InitMemGather(&random_static_gm, "ran_mp_s", &dynamic_mempool[0], sizeof(dynamic_mempool), 80);
|
||||||
ShowMemPool();
|
ShowGatherMem();
|
||||||
}else{
|
}else{
|
||||||
KPrintf("test dynamic create gatherblock.\n");
|
KPrintf("test dynamic create gatherblock.\n");
|
||||||
random_dynamic_gm = CreateMemGather("ran_mp_d",40,80);
|
random_dynamic_gm = CreateMemGather("ran_mp_d",40,80);
|
||||||
|
@ -451,7 +451,7 @@ int RandomAllocFreeTest(void *parameter)
|
||||||
KPrintf("%s: allocate failure.\n",__func__);
|
KPrintf("%s: allocate failure.\n",__func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ShowMemPool();
|
ShowGatherMem();
|
||||||
}
|
}
|
||||||
/* create task1, alloc memory blocks */
|
/* create task1, alloc memory blocks */
|
||||||
random_tid1 = KTaskCreate("r_task1", RandomTask1GmAlloc, parameter,
|
random_tid1 = KTaskCreate("r_task1", RandomTask1GmAlloc, parameter,
|
||||||
|
|
|
@ -88,21 +88,25 @@ int TestMain(int argc, char*argv[])
|
||||||
break;
|
break;
|
||||||
case MEM:
|
case MEM:
|
||||||
#ifdef KERNEL_TEST_MEM
|
#ifdef KERNEL_TEST_MEM
|
||||||
|
if (argc > 2)
|
||||||
TestMem(argc-2,&argv[2]);
|
TestMem(argc-2,&argv[2]);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case TIMER:
|
case TIMER:
|
||||||
#ifdef KERNEL_TEST_TIMER
|
#ifdef KERNEL_TEST_TIMER
|
||||||
|
if (argc > 2)
|
||||||
TestTmr(argc-2,&argv[2]);
|
TestTmr(argc-2,&argv[2]);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case GATHERBLOCK:
|
case GATHERBLOCK:
|
||||||
#ifdef KERNEL_TEST_MEM
|
#ifdef KERNEL_TEST_MEM
|
||||||
|
if (argc > 2)
|
||||||
TestGatherblock(&argv[2]);
|
TestGatherblock(&argv[2]);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case SCHED:
|
case SCHED:
|
||||||
#ifdef KERNEL_TEST_SCHED
|
#ifdef KERNEL_TEST_SCHED
|
||||||
|
if (argc > 2)
|
||||||
TestTaskReadyAndSched(argc-2, &argv[2]);
|
TestTaskReadyAndSched(argc-2, &argv[2]);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -112,6 +116,7 @@ int TestMain(int argc, char*argv[])
|
||||||
#endif
|
#endif
|
||||||
case REALTIME:
|
case REALTIME:
|
||||||
#ifdef KERNEL_TEST_REALTIME
|
#ifdef KERNEL_TEST_REALTIME
|
||||||
|
if (argc > 2)
|
||||||
TestRealtime(argc-2, &argv[2]);
|
TestRealtime(argc-2, &argv[2]);
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct DynamicAllocNode
|
||||||
*/
|
*/
|
||||||
struct DynamicFreeNode
|
struct DynamicFreeNode
|
||||||
{
|
{
|
||||||
uint32 size; /* the size of dynamicAllocNode */
|
x_size_t size; /* the size of dynamicAllocNode */
|
||||||
uint32 prev_adj_size; /* the size of the previous adjacent node, (dynamic alloc node or dynamic free node */
|
uint32 prev_adj_size; /* the size of the previous adjacent node, (dynamic alloc node or dynamic free node */
|
||||||
|
|
||||||
struct DynamicFreeNode *next;
|
struct DynamicFreeNode *next;
|
||||||
|
@ -341,7 +341,7 @@ static void* BigMemMalloc(struct DynamicBuddyMemory *dynamic_buddy, x_size_t siz
|
||||||
};
|
};
|
||||||
|
|
||||||
/* get the best-fit freeNode */
|
/* get the best-fit freeNode */
|
||||||
if (node) {
|
if (node && (node->size > allocsize)) {
|
||||||
struct DynamicFreeNode *remainder;
|
struct DynamicFreeNode *remainder;
|
||||||
struct DynamicFreeNode *next;
|
struct DynamicFreeNode *next;
|
||||||
x_size_t remaining;
|
x_size_t remaining;
|
||||||
|
|
Loading…
Reference in New Issue