⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbmtask.c

📁 norflash的文件系统。 用于中低端手机开发的参考
💻 C
字号:
/*****************************************************************************
 
  FILE NAME: dbmtask.c

  DESCRIPTION:

    This file contains the Data Base Manager (DBM) task routines. 
    The DBM maintains data base(s) in non-volatile memory so that the
    data can survive across a power down. 

  PROCEDURES IN THIS SOURCE FILE:

    Global Procedures
    -------------------
    DbmTask

 Copyright (c) 1998 - 2002 LSI Logic. All rights reserved. LSI Confidential information.
 Copyright (c) 2002, VIA Technologies, Inc.
*****************************************************************************/

#include "dbmapi.h"
#include "dbmdefs.h"
#include "dbmerrs.h"
#include "exeapi.h"
#include "monapi.h"
#include "sysdefs.h"

/*****************************************************************************
*  Declare local variables 
*****************************************************************************/


/*****************************************************************************
*  Declare function prototypes for local routines in this file
*****************************************************************************/

/* VIA glie */
extern bool NamLock;
/* end VIA */


/*****************************************************************************
 
  FUNCTION NAME: DbmTask                       

  DESCRIPTION:

    This routine is the DBM main task. It sets up an Exe wait for message 
    then reads a message from the DBM mailbox when this task is scheduled.
    The message ID is checked and the appropriate function is called.
    This task can handle two data bases stored in two different non-volatile
    memories.

  PARAMETERS:

    None
    
  RETURNED VALUES:

    None

*****************************************************************************/

void DbmTask(uint32 argc, void *argv)
{
   ExeEventWaitT  Status;
   bool           MsgStatus;
   uint32         MsgId;
   uint32         MsgSize;
   void          *MsgDataP;

   DbmInitFlash();

   while(TRUE)
   {
      /* Wait event on mail */
      Status = ExeEventWait(EXE_DBM_ID, (bool)EXE_SIGNAL_FALSE, 
                            EXE_MESSAGE_TRUE, EXE_TIMEOUT_FALSE); 
      
      /* Check if message in mailbox  */
      if (Status & EXE_MESSAGE_TYPE)
      {
         /* Set up a while loop to process ALL msgs in DBM mailbox */
         while (ExeMsgCheck(EXE_DBM_ID, DBM_MAILBOX))
         {
            /* Read command message */
            MsgStatus = ExeMsgRead(EXE_DBM_ID, DBM_MAILBOX, &MsgId, 
                                   &MsgDataP, &MsgSize);

            /* If message received process it */
            if (MsgStatus)
            {
               /* Process command mail message */
               switch(MsgId)
               {
                  case DBM_CLEAR_MSG:
                     DbmClearFlashDbMsg(MsgDataP);
                     break;
         
                  case DBM_READ_MSG:
                     DbmReadFlashDbMsg(MsgDataP);
                     break;            
   
                  case DBM_WRITE_MSG:
                     DbmWriteFlashDbMsg(MsgDataP);
                     break;
   
                  case DBM_CACHE_MSG:
                     DbmCacheFlashDbMsg(MsgDataP);
                     break;
   
                  case DBM_FLUSH_MSG:
                     DbmFlushFlashDbMsg(MsgDataP);
                     break;
   
                  case DBM_READ_BLK_MSG:
                     DbmBlkReadFlashDbMsg(MsgDataP);
                     break;
   
				  case DBM_WRITE_BLK_MSG:
                     DbmBlkWriteFlashDbMsg(MsgDataP);
                     break;
   
				  case DBM_NAM_LOCK_MSG:
                     DbmNAMlockUnlockDbMsg(MsgDataP);
                     break;

                  default:
                     MonFault(MON_DBM_FAULT_UNIT, DBM_MSG_ID_ERR, MsgId, MON_CONTINUE); 
                     break;
               }
   
               /* Deallocate memory from command message */
               if (MsgDataP != NULL)
                  ExeMsgBufferFree(MsgDataP);
            }
         }
      }
   }
}

/*****************************************************************************
* $Log: dbmtask.c $
* Revision 1.1  2003/11/07 18:55:31  xuhua
* Initial revision
* Revision 1.1  2003/10/21 16:02:00  hanxiao99
* Initial revision
* Revision 1.1  2003/10/08 14:40:50  hanxiao99
* Initial revision
* Revision 1.1  2003/09/03 14:52:39  hanxiao99
* Initial revision
* Revision 1.1  2003/07/31 05:21:14  javese
* Initial revision
* Revision 1.4  2003/01/27 17:19:26  vtc
* delete some comment statement.  ---  Jingsong Jin
* Revision 1.3  2002/11/23 02:17:04  wavis
* Remove FMM semaphores.
* Revision 1.2  2002/10/23 10:39:40  Bing
* Check in for Greg
* Revision 1.1  2002/10/03 17:32:48  fpeng
* Initial revision
* Revision 1.6  2002/05/29 08:51:37  mshaver
* Added VIA Technologies copyright.
* Revision 1.5  2002/04/10 15:38:40  mshaver
* Added code at DBM initialization to wait for a start up signal from
* MON. This is needed because without it DBM will be sent
* messages from HWD to start reading calibration data from flash
* during intialization. If the flash filesystem option is enabled then
* DBM can only read data once the flash filesystem software has 
* initialized to allow DBM to get the FMM semaphore. The 
* initialization of FMM is done from MON.
* Revision 1.4  2002/02/06 12:51:09  mshaver
* Added code to handle the NAM lock message, DBM_NAM_LOCK_MSG
* Revision 1.3  2001/11/13 12:57:09  mshaver
* Merge in revision 1.2.1.2 which updated DBM task to read all
* messages in mail queue before suspending.
* Revision 1.2.1.2  2001/11/01 16:23:32  mshaver
* Updated DBM task to read ALL messages in mail queue before
* suspending.
* Revision 1.2.1.1  2001/10/06 07:55:51  mshaver
* Duplicate revision
* Revision 1.2  2001/10/06 07:55:51  mshaver
* Merge in revision 1.1.1.2
* Revision 1.1.1.2  2001/10/04 11:26:37  mshaver
* Conditionally include fmmapi.h if SYS_OPTION_FILESYSTEM
* is defined. Surround all DBM flash operations with calls
* to FMMSemTake() and FMMSemGive() if
* SYS_OPTION_FILESYSTEM is defined. These calls to use 
* semaphores to control access to the flash will guard against
* concurrent accesses to the flash by FMM.
* Revision 1.1.1.1  2000/10/06 13:40:19  mshaver
* Duplicate revision
* Revision 1.1  2000/10/06 13:40:19  mshaver
* Initial revision
* Revision 1.1  2000/10/06 18:26:49Z  mshaver
* Initial revision
* Revision 1.6  2000/07/21 17:29:18Z  mshaver
* Since the RF data base no longer resides in flash, the need to 
* call eeprom routines based on the data base ID is gone. Now, just
* one set of routines are used for both the CP and RF data bases.
* Revision 1.5  2000/06/07 15:10:48Z  mshaver
* Added support for the dbm block read/write commands
* DBM_READ_BLK_MSG and DBM_WRITE_BLK_MSG.
* Also, eliminated the used of the flag DbmFlashEnable as it is always
* set true and is not needed.
* Revision 1.4  2000/01/29 02:19:27Z  etarolli
* Updated flash and eeprom DB code so they are similar
* Revision 1.3  2000/01/19 20:27:10Z  mshaver
* Fold changes into the baseline
* Revision 1.2.1.2  1999/12/22 21:16:39Z  mshaver
* Added layer which determines, based on the data base id, whether
* the eeprom or flash layer will service the message request.
* Revision 1.2.1.1  1999/12/02 18:31:55Z  mshaver
* Duplicate revision
* Revision 1.2  1999/12/02 18:31:55Z  cdma
* Updated comments for CBP3.0
*****************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -