📄 fsmqueue.h
字号:
/*****************************************************************************
FILE NAME: FsmQueue.h
DESCRIPTION:
Copyright (c) 2002, VIA Technologies, Inc.
*****************************************************************************/
#ifndef FSM_QUEUE_H
#define FSM_QUEUE_H
/*******************************************
*
* Operation Command.
*
*******************************************/
#define CMD_CREATE 0x01
#define CMD_MKDIR 0x02
#define CMD_MODIFY 0x03
#define CMD_APPEND 0x04
#define CMD_TRUNCATE 0x05
#define CMD_DELETE 0x06
#define CMD_RMDIR 0x07
#define CMD_RENAME 0x08
/*******************************************
*
* Queue Item Type.
*
*******************************************/
#define QUEUE_DATA_ITEM 0x01
#define QUEUE_FILE_DIR 0x02
/*******************************************
*
* WAIT flag
*
*******************************************/
#if (OS_TYPE == OS_NUCLEUS)
#define WAIT_FOREVER NU_SUSPEND
#define WAIT_TRY NU_NO_SUSPEND
#else
#define WAIT_FOREVER INFINITE
#define WAIT_TRY 0
#endif
/*******************************************
*
* the number of sectors
* that an queue item takes up in flash.
*
*******************************************/
#define ACCUM_START_VALUE 2
#define ACCUM_CNT_CREATE 1
#define ACCUM_CNT_MKDIR 2
#define ACCUM_CNT_DELETE 0
#define ACCUM_CNT_RMDIR 0
#define ACCUM_CNT_RENAME 1
#define ACCUM_CNT_MODIFY 0
#define ACCUM_CNT_TRUNCATE 1
#define ACCUM_CNT_APPEND(offset, len, size) \
(1 + ((offset) + (len) + (size) - 1) / (size) - ((offset) + (size) - 1) / (size))
/* ^--- this 1 is used for directory entry extension. */
#define ACCUM_CNT_MODIFY_RESERVED(offset, len, size) \
(((offset) + (len) + (size) - 1) / (size) - (offset) / (size))
/*******************************************
*
* The following structure is used for
* Write Task and Write Queue.
*
*******************************************/
typedef /*PACKED*/ union
{
/* file descriptor */
uint32 fd;
/*PACKED*/ struct
{
/* data item type */
uint16 ItemType;
/* data item id */
uint16 ItemId;
} Item;
} FsmItemFdT;
typedef /*PACKED*/ struct _FSM_QUEUE_ITEM
{
/* Points to next queue item structure. */
struct _FSM_QUEUE_ITEM * NextP;
/* Type of queue item.
* Its value is QUEUE_DATA_ITEM if type s data item.
* Its value is QUEUE_FILE_DIR if type s file or directory.
*/
uint8 type;
/* operation command.
* It may be the following value:
* CMD_CREATE : Create a file or a data item
* CMD_MKDIR : Make a directory
* CMD_MODIFY : Modify a file or a data item
* CMD_APPEND : Append a file or a data item
* CMD_TRUNCATE : Truncate a file
* CMD_DELETE : Delete a file or a data item
* CMD_RMDIR : Remove a directory
* CMD_RENAME : Rename a file or a directory
*/
uint8 cmd;
/* Reserve for future use */
uint16 rsv;
FsmItemFdT ItemFd;
/* the number of offset bytes
* from the beginning of file contents or data item contents
* to current operation position.
*/
uint32 offset;
/* Byte size of data object. */
uint32 length;
HBSEM SemEvent;
/* This field is not used at present. */
/* uint32 FirstLsn; */
} FsmQueueItemT;
/*******************************************
*
* The following APIs are used for
* Data File System and Write Task.
*
*******************************************/
/* Get the number of sectors that items in queue take up in flash. */
uint32 GetAccumSize(uint32 * CntP);
/* This function allocates all resource for the queue,
* and initializes the queue.
*/
uint32 QueueCreate(void);
/* This function frees any resource allocated by the queue code. */
uint32 QueueDestroy(void);
/* This function inserts a queue item whose type is file or dir
* into the queue. This function allocates memory for queue
* item structure and data object.
*/
uint32 QueueAddFileDir(uint8 cmd, uint32 fd, uint32 offset, uint8 * DataP, uint32 length);
/* This function inserts a queue item whose type is data item
* into the queue. This function allocates memory for queue
* item structure and data object.
*/
uint32 QueueAddDataItem(uint8 cmd, uint16 ItemType, uint16 ItemId, uint32 offset, uint8 * DataP, uint32 length);
/* Gets address of the first queue item. */
uint32 QueuePeek(FsmQueueItemT ** QueueItemPP);
/* Delete the first item of the queue. */
uint32 QueueDel(void);
/* This function reads data from the queue according to
* these input parameters.
*/
uint32 QueueReadData(uint8 type, uint32 fd, uint32 offset, uint8 * DataP, uint32 length, uint32 * read_size);
uint32 QueueReadFile(
uint32 fd,
uint32 offset,
uint8 * DataP,
uint32 length,
uint32 * read_size
);
uint32 QueueReadDataItem(
uint16 ItemType,
uint16 ItemId,
uint32 offset,
uint8 * DataP,
uint32 length,
uint32 * read_size
);
/* This function waits the queue empty. */
uint32 WaitQueueEmpty(uint32 timeout);
/* This function waits these queue items empty whose memeber 'fd'
* value is equal to input parameter 'fd' value.
*/
uint32 WaitFdEmpty(uint32 fd, uint32 timeout);
/* This function waits these queue items empty whose memeber
* 'ItemType' and 'ItemId' value are equal to input parameter
* 'ItemType' and 'ItemId' value.
*/
uint32 WaitTypeIdEmpty(uint16 ItemType, uint16 ItemId, uint32 timeout);
/*
* This function gets the current length of data item.
*/
uint32 QueueGetDataItemLength(uint16 ItemType, uint16 ItemId, uint32 * LengthP);
#endif /* FSM_QUEUE_H */
/*****************************************************************************
* $Log: FsmQueue.h $
* Revision 1.3 2004/03/17 12:57:33 zgy
* Revision 1.24 2004/03/16 15:54:40 jjs
* Revision 1.23 2004/02/26 12:14:53 jjs
* Updated the new sectors number required by Append command.
* Revision 1.22 2004/02/20 17:37:50 jjs
* Added a macro to calculate the reserved space for modification operation.
* Revision 1.21 2003/11/05 10:20:47 zgy
* Revision 1.20 2003/10/24 14:09:19 zgy
* append func: QueueGetDataItemLength.
* Revision 1.19 2003/10/22 13:48:39 jjs
* Revision 1.18 2003/10/22 12:09:59 jjs
* Revision 1.17 2003/10/16 10:58:54 jjs
* Revision 1.16 2003/10/10 13:20:57 zgy
* Revision 1.15 2003/10/09 13:19:36 zgy
* add function WaitTypeIdEmpty
* Revision 1.14 2003/10/09 10:04:14 zgy
* Revision 1.13 2003/10/08 11:50:08 jjs
* Revision 1.12 2003/09/27 14:44:35 zgy
* Modify QueueAddDataItem Input parameter
* Revision 1.11 2003/09/27 14:22:14 zgy
* Add queue api function: QueueAdd.
* Modify QueueAddDataItem function.
* Revision 1.10 2003/09/20 18:00:50 jjs
* Revision 1.9 2003/09/18 14:50:32 zgy
* Revision 1.8 2003/09/18 11:16:28 zgy
* Revision 1.7 2003/09/15 16:19:19 zgy
* Revision 1.6 2003/09/15 13:02:26 zgy
* Revision 1.5 2003/09/14 16:57:28 jjs
* Revision 1.4 2003/09/12 15:19:26 zgy
* Revision 1.3 2003/09/12 15:10:30 jjs
* Revision 1.2 2003/09/09 16:34:00 zgy
* Revision 1.1 2003/09/09 15:06:58 zgy
* Initial revision
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -