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

📄 zfstruct.h

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 H
字号:
/*
 * File       : zfstruct.h
 * Description: This file contains the structures required by the ZiLOG File System
 * Author     : Mahadev K C
 * Created on : 30-APR-2003
 *
 * Copyright 2002 ZiLOG Inc.  ALL RIGHTS RESERVED.
 *
 * This file contains unpublished confidential and proprietary information
 * of ZiLOG, Inc.
 * NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
 * IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
 * This is not a license and no use of any kind of this work is authorized
 * in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
 * sole discretion 
 */

#ifndef _ZFSSTRUCT_H_
#define _ZFSSTRUCT_H_

//include header files
#include "zfstypes.h"
#include "zfsdef.h"
#include "zfscfg.h"

#define SEC_DATA_BIT_OFFSET		(0x08)
#define SEC_NXT_SEC_NUM_OFFSET	(0x05)
// ZFS structures
// sector header
typedef struct {
	ZFS_SEC_TYPE_t	sec_type ;	/* ZFS_SEC_TYPE_TB/ZFS_SEC_TYPE_AB/ZFS_SEC_TYPE_FIT/ZFS_SEC_TYPE_DATA/ZFS_SEC_TYPE_NEW_AB */
	UINT8			status ;	/* allocated/dirty/free */
	ZFS_SEC_ID_t	sec_num ;	/* sector number incase of flash, sector address in case of RAM */
	ZFS_SEC_ID_t	nxtsecnum ;	/* sector number incase of flash, sector address in case of RAM */
	UINT16			sec_data_bit ; /* if each bit is set to zERO, then we wrote 32 bits in the sector. */
	UINT8			nxt_sec_data_bit ; /* 0th bit is set to ZERO if nxt_sec_num is written properly */
} ZFS_SEC_HDR_t, *PZFS_SEC_HDR_t ;


#define BLK_TB_GC_START_OFFSET	( sizeof( ZFS_SEC_HDR_t) + 7 )
#define BLK_TB_GC_END_OFFSET		( sizeof( ZFS_SEC_HDR_t) + 8 )
#define BLK_AB_GC_START_OFFSET	( sizeof( ZFS_SEC_HDR_t) + 9 )
#define BLK_AB_GC_END_OFFSET		( sizeof( ZFS_SEC_HDR_t) + 10 )

// block header
typedef struct {
	ZFS_SEC_HDR_t 	sec_hdr ; 
	UINT8			zfs_magic_num; 	// magic number that identifies the block as ZFS block
	UINT8			blk_num ;		/* blk number */
	UINT8			gc_frmblk ;		/* blk number of the block to transfer data to TB. Valid only if bygcstart bit is set and bygcend is reset */
	UINT8			gc_toblk ;		/* blk number of the block to transfer data to TB. Valid only if bygcstart bit is set and bygcend is reset */
	UINT8			byfmt_start ;	/* format started */
	UINT8			byfmt_end ;		/* format completed */
	UINT8			tb_gc_start ;		/* TB gc started - this bit is set in the TB. */
	UINT8			tb_gc_end ;		/* gc completed - This bit is valid in the TB */
	UINT8			ab_gc_start ;		/* gc started - This bit is valid only in the AB*/
	UINT8			ab_gc_end ;		/* gc completed - This bit is valid only in the AB.*/
} ZFS_BLK_HDR_t, *PZFS_BLK_HDR_t ;


// file informatin table
typedef struct {
	ZFS_SEC_HDR_t 	sec_hdr ; /* contains sectype as FAT/DATA, status as allocated/dirty/free/not saved */
	UINT16			sec_data_bit ; /* if each bit is set to zERO, then we wrote 32 bytes in the sector. */
	UINT8			free_fir ; /* data bit for free fir slot in the sector */
} ZFS_FIT_HDR_t, *PZFS_FIT_HDR_t ;

// data sector header
typedef struct {
	ZFS_SEC_HDR_t	sec_hdr ;
} ZFS_DATA_SEC_HDR_t ;

// file information record
typedef struct {
	UINT8				fir_type_status ;	/* DIR/FILE, BINARY/ASCII, FREE/ALLOCATED, DIRTY, NOT SAVED */
	ZFS_SEC_ID_t		sec_datanum ;	/* sector number of data sector/new FIT if it is directory */
	ZFS_CHECKSUM_t		filecs ;		/* check sum */
	INT8				fir_name[ ZFS_MAX_FILE_NAME_SIZE ] ;	/* File/directory name */
	UINT32				size ; 			/* size  */
	UINT32				tom ;			/* time of modification */
	UINT8				tom_century ; /* Century. This will be a part of time. */
	UINT8				reserved[2];
} ZFS_FIR_t, *PZFS_FIR_t ;


// block info structure
typedef struct {
	ZFS_BLK_HDR_t blk_hdr ;
	UINT8*	blk_start_addr ;
	UINT	free_sec_count ;
	UINT	dirty_sec_count ;
	UINT8	*next_free_sec_addr ;
	
} ZFS_BLK_INFO_t, *PZFS_BLK_INFO_t ;

#include "dirnode.h"

// volume info structure
typedef struct {
	PZFS_CONFIG_t	pcfg ;			/* volume configuration data */
	ZFS_BLK_INFO_t	*blk_info ;		/* block info */
	UINT8			*pvol_sat ;		/* SAT start address for the volume */
	ZFS_SEC_ID_t	root_sec_num ;	/* root sectors number / address */
	PZFS_DIR_LIST_t	proot_node ; /* root directory list */
	UINT			free_sec_count ;		/* global free sec count for the volume */
	UINT			dirty_sec_count ;	/* global dirty sector count for the volume */
	UINT			ttl_num_secs; 		/* total number of sectors except those in the transfer block */
	UINT8			new_format_flag ;
	UINT8			is_valid ; /* Whether this volume is valid or not. */
} ZFS_VOL_INFO_t, *PZFS_VOL_INFO_t ;

// current working directory info */
typedef struct {
	ZFS_THD_HANDLE_t	thd_handle ;	/* thread handle for which cwd is stored */
	UINT8				file_count ;	/* number of files opened in current thread */
//	UINT8				cwd[ ZFS_MAX_CWD_PATH_LEN ] ;
	PZFS_DIR_LIST_t		pcwd_node ;		/* node for the current working directory */
	PZFS_VOL_INFO_t		pvol_info ;		/* pointer to the volume info table */
	ZFS_STATUS_t		err_num ;		/* error number if any latest operation on FS from the thread */
} ZFS_CWD_INFO_t, *PZFS_CWD_INFO_t ;





// open record structure
typedef struct {
	UINT8			status ;
	INT8			name[ ZFS_MAX_FILE_NAME_SIZE + 1 ] ;
	UINT8			mode ;				/* mode - READ, WRITE, READ | WRITE, APPEND */
	UINT8			attr ;				/* attributes - ASCII/BINARY */
	UINT32			offset ;			/* current seek pointer in the opened file. */
	UINT32			bytes_written ;		/* current number of bytes written to the file in case of WRITE mode. 
										   This is used to write the FIR for corresponding length of the file. */
	UINT32			size ;				/* file size */
	ZFS_SEC_ID_t	first_secnum ;		/* first sector number */
	ZFS_SEC_ID_t	cur_secnum ;		/* current sector number */
	ZFS_SEC_ID_t	last_secnum ;		/* last sector number */
	ZFS_CHECKSUM_t filecs ;
	PZFS_FIR_t		pfir_file ;
	PZFS_DIR_LIST_t	pdir_node ;
	PZFS_CWD_INFO_t	pcwd_info ;		/* current working directory info */
	PZFS_VOL_INFO_t	pvol ;				/* pointer to the volume info, to which this file belongs */
} ZFS_OPEN_REC_t, *PZFS_OPEN_REC_t  ;



/////////////////////////////////////////////////////
// different structure sizes
/////////////////////////////////////////////////////

typedef struct {
	UINT8 CB[ ZFS_BLK_INFO_STR_SIZE ] ;
} ZFS_BLK_INFO_CB_t ;

typedef struct {
	UINT8 CB[ ZFS_VOL_INFO_STR_SIZE ] ;
} ZFS_VOL_INFO_CB_t ;

typedef struct {
	UINT8 CB[ ZFS_OPEN_REC_STR_SIZE ] ;
} ZFS_OPEN_REC_CB_t ;

typedef struct {
	UINT8 CB[ ZFS_DIR_LIST_STR_SIZE ] ;
} ZFS_DIR_LIST_CB_t ;


/////////////////////////////////////////////////////



// macros
#define ZFS_SEC_DATA_SIZE				( ZFS_SEC_SIZE - sizeof( ZFS_SEC_HDR_t) )

// extern variables
extern UINT8 g_zfs_init ;
// macros
#define IsZFSInited()		( g_zfs_init )

//Function: IsAbsPath
//Description: This function will check the path and returns the root node of the volume if found else
// returns NULL.
UINT8 IsAbsPath( IN INT8 * path, OUT PZFS_VOL_INFO_t *pvol, OUT UINT *off, OUT PZFS_DIR_LIST_t *dir_node ) ;

#endif //_ZFSSTRUCT_H_


⌨️ 快捷键说明

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