📄 init.c
字号:
/*****************************************************************************
FILE NAME: init.c
DESCRIPTION:
FSM initialization module.
Copyright (c) 2002, VIA Technologies, Inc.
*****************************************************************************/
#include "fsmdefs.h"
#include "FsmFs.h"
#include "fsmapi.h"
#include "fsmflash.h"
#include "ostype.h"
#include "fsmdev.h"
#define DFS1_VOLUME_NAME "vt"
#define DFS1_SECTOR_SIZE 128
extern uint32 FsmVfsStartup(void);
extern uint32 FsmVfsExit(void);
extern uint32 FsmDfsStartup(void);
extern uint32 FsmDfsExit(void);
extern uint32 FsmDataItemInit(FsmDevObjHdrT * DevObjP);
extern uint32 FsmDataItemExit(void);
extern FsmFsDrvT FsmDfsDrv;
extern volatile uint8 FsmStarting;
#if (OS_TYPE == OS_WINDOWS)
extern FsmFlashDevT TestDev;
#else
extern FsmFlashDevT FlashDev;
/*added device here to support more volumes. */
#endif
uint32 CreateFlashDevObjs()
{
HMSEM hMtxSem;
FsmFlashDevT * FlashDevP;
#if (OS_TYPE == OS_WINDOWS)
FlashDevP = &TestDev;
#else
FlashDevP = &FlashDev;
#endif
hMtxSem = FsmCreateMtxSem(1);
if(hMtxSem == NULL)
{
return ERR_SYSTEM;
}
FlashDevP->DevWriteLock = hMtxSem;
hMtxSem = FsmCreateMtxSem(1);
if(hMtxSem == NULL)
{
hMtxSem = FlashDevP->DevWriteLock;
FsmDeleteMtxSem(hMtxSem);
return ERR_SYSTEM;
}
FlashDevP->DevEraseLock = hMtxSem;
return ERR_NONE;
}
uint32 DestroyFlashDevObjs()
{
FsmFlashDevT * FlashDevP;
#if (OS_TYPE == OS_WINDOWS)
FlashDevP = &TestDev;
#else
FlashDevP = &FlashDev;
#endif
FsmDeleteMtxSem(FlashDevP->DevWriteLock);
FsmDeleteMtxSem(FlashDevP->DevEraseLock);
return ERR_NONE;
}
uint32 FsmSystemInit(void * start, uint32 size)
{
FsmFlashDevT * FlashDevP;
#if (OS_TYPE == OS_WINDOWS)
FlashDevP = &TestDev;
#else
FlashDevP = &FlashDev;
#endif
FsmStarting = TRUE;
FsmMemorySet(start, 0, size);
if(FsmMemInit(start, size) != ERR_NONE)
{
goto Fsm_sys_init_eixt;
/* return ERR_SYSTEM; */
}
/*
* The startup function of file system
* can be called in FsmInit function of
* that file system, if it is the case,
* we needn't to call this function here.
*/
if(FsmDfsStartup() != ERR_NONE)
{
FsmMemExit();
goto Fsm_sys_init_eixt;
/* return ERR_SYSTEM; */
}
if(FsmVfsStartup() != ERR_NONE)
{
FsmDfsExit();
FsmMemExit();
goto Fsm_sys_init_eixt;
/* return ERR_SYSTEM; */
}
if(CreateFlashDevObjs() != ERR_NONE)
{
MonPrintf("\nCreateFlashDevObjs() failure!");
FsmVfsExit();
FsmDfsExit();
FsmMemExit();
goto Fsm_sys_init_eixt;
/* return ERR_SYSTEM; */
}
if(FsmMount(&FsmDfsDrv, &(FlashDevP->DevObjHdr), DFS1_VOLUME_NAME, DFS1_SECTOR_SIZE) != 0)
{
MonPrintf("\nFailed on calling FsmMount()");
DestroyFlashDevObjs();
FsmVfsExit();
FsmDfsExit();
FsmMemExit();
goto Fsm_sys_init_eixt;
/* return ERR_SYSTEM; */
}
/*
* More devices can be mounted here to support multiple volumes.
*/
/* Data item manager initialize */
if(FsmDataItemInit(&(FlashDevP->DevObjHdr)) != ERR_NONE)
{
FsmUnMount(DFS1_VOLUME_NAME);
DestroyFlashDevObjs();
FsmVfsExit();
FsmDfsExit();
FsmMemExit();
goto Fsm_sys_init_eixt;
/* return ERR_SYSTEM; */
}
FsmStarting = FALSE;
return ERR_NONE;
Fsm_sys_init_eixt:
FsmStarting = FALSE;
return ERR_SYSTEM;
}
uint32 FsmSystemExit()
{
FsmDataItemExit();
FsmUnMount(DFS1_VOLUME_NAME);
DestroyFlashDevObjs();
FsmVfsExit();
FsmDfsExit();
FsmMemExit();
return ERR_NONE;
}
/*****************************************************************************
* $Log: init.c $
* Revision 1.4 2004/03/18 09:17:49 zgy
* change volume name.
* Revision 1.3 2004/03/17 12:58:22 zgy
* Revision 1.13 2004/03/16 15:57:48 jjs
* Revision 1.12 2004/03/11 15:05:04 jjs
* Revision 1.11 2003/11/05 10:51:44 zgy
* Revision 1.10 2003/10/26 11:10:41 jjs
* Revision 1.9 2003/10/21 16:28:05 wsm
* Revision 1.8 2003/10/21 11:51:12 jjs
* Added support for Nucleus OS.
* Revision 1.7 2003/10/16 11:36:50 jjs
* Revision 1.6 2003/10/08 18:15:59 jjs
* Revision 1.5 2003/10/08 12:44:54 jjs
* Revision 1.4 2003/09/16 11:30:55 wsm
* Revision 1.3 2003/09/14 16:56:46 jjs
* Revision 1.2 2003/09/12 18:06:27 jjs
* Revision 1.1 2003/09/09 15:07:53 jjs
* Initial revision
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -