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

📄 ramdisk.h

📁 如何制作ramdisk的一个好资料
💻 H
字号:
/**************************************************************
;*                                                            *
;*         INSTUTITE FOR INFORMATION INDUSTRY                 *
;*                 FAT16 HEADER -- RAMDISK                    *
;*                    APRIL 30, 1998                          *
;*                                                            *
;*************************************************************/
#ifndef _RAMDISK_H
#define _RAMDISK_H


/**************************************************************
	C++ SUPPORT
**************************************************************/
#ifdef	__cplusplus
extern	"C"	{
#endif

//  #include "../../driver/FileSys/include/FileSys.h"//Sean


/**************************************************************
;*                                                            *
;*		Gloabal Definitions			      *
;*                                                            *
;*************************************************************/


/* for debugging */
//#define RAMDISK_DEBUG
//#define RAMDISK_INIT_DEBUG

/*******************************************************************
 Fixed block size or variable block size

 If variable block size is used, the data block and the directory
 block can have different size. Compression is also supported. The
 prices are that the speed will be slower and the space wasted on
 fragmentation will be bigger.

 If fixed block size is used, the data block and the directory block
 must have same size. Compression is not supported. Faster speed and
 no external fragmentation are the adventages of this option.
 *******************************************************************/ 
#define RAMDISK_USE_VARIABLE_SIZE_BLOCK


#ifdef RAMDISK_USE_VARIABLE_SIZE_BLOCK
	/* Individual file compression supporting */
	/* Comment out this line if file compression is not needed */
//	#define RAMDISK_COMPRESS_USE_ZLIB
#endif


/* RAMDisk statistic logging */
//#define RAMDISK_STAT_LOG


/* Current directory mechanism enabling */
/* Comment out the following line if current directory is not needed */
#define CURRENT_DIR_ENABLE



/*-----------------[ File Routine Related ]------------------*/
#define MAX_PATH_LENGTH		(256)
//#define RD_FNAME_LEN		(51)

/**** modified by chilong ****/
#define RD_FNAME_LEN		(50)
/**** modified by chilong ****/

//#define MAX_OPEN_FILE		(100)
//#define RESERVED_FILE_HANDLE	(3)
//#define NEW_BLOCK_SIZE		(1024)
#define SECTOR_SIZE		(512)

/* Copy from pda_cfg.h *//* thhuang */
/**************************************************************
 init ramdisk size
*************************************************************/
#define PDA_RAM_DISK_SIZE 1500
/* Copy from pda_cfg.h */

/*-----------------[ Piece Routine Related ]------------------*/
// chilong 8/17/2001: RD_PLT_ENTRY_NUM * RD_PIECE_SIZE = RAMDISK SIZE
#define RD_PLT_ENTRY_NUM	(14)	// the number of entries in the PLT
					// the maximum size of the RAMDisk can
//#define RD_PLT_ENTRY_NUM	(190)	// the number of entries in the PLT
					// the maximum size of the RAMDisk can
					//   be modified by changing this definition
#ifdef RAMDISK_USE_VARIABLE_SIZE_BLOCK
	// variable block size
// 1st choice
//	#define RD_PIECE_SIZE		33216	// size of a piece
//	#define RD_BLOCK_SIZE		2048
//	#define DIR_BLOCK_SIZE		2048	// (DIR_BLOCK_SIZE / 64) entries

// 2nd choice
//	#define RD_PIECE_SIZE		32824	// size of a piece
//	#define RD_BLOCK_SIZE		16384
//	#define DIR_BLOCK_SIZE		16384	// (DIR_BLOCK_SIZE / 64) entries

// 3rd choice (normal choice)
/* marked by chilong 9/25/2001 
	#define RD_PIECE_SIZE		32992	// size of a piece
						// chilong: 8 * (4096 + 24(block header) + 4(block tail)) = 32992
	#define RD_BLOCK_SIZE		4096
	#define DIR_BLOCK_SIZE		4096	// (DIR_BLOCK_SIZE / 64) entries
   marked by chilong 9/25/2001 */

/**** modified by chilong 9/25/2001 ****/

	#define RD_PIECE_SIZE		66048	// size of a piece
						// chilong: 32 * (4096 + 24(block header) + 2*4(block tail)) = 132096
	#define RD_BLOCK_SIZE		4096
	#define DIR_BLOCK_SIZE		4096	// (DIR_BLOCK_SIZE / 64) entries
	
	// !!Note: 1st, 2nd, 4th, 5th pieces' size should be changed due to the change of B_TAIL
/**** modified by chilong 9/25/2001 ****/
   
// 4th choice (used in ramdisk with bigger size)
//	#define RD_PIECE_SIZE		98976	// size of a piece
						// chilong: 24 * (4096 + 24(block header) + 4(block tail)) = 98976
//	#define RD_BLOCK_SIZE		4096
//	#define DIR_BLOCK_SIZE		4096	// (DIR_BLOCK_SIZE / 64) entries
	
// 5th choice (used in ramdisk with bigger size)
//	#define RD_PIECE_SIZE		197952	// size of a piece
						// chilong: 48 * (4096 + 24(block header) + 4(block tail)) = 197952
//	#define RD_BLOCK_SIZE		4096
//	#define DIR_BLOCK_SIZE		4096	// (DIR_BLOCK_SIZE / 64) entries

// 6th choice (used in ramdisk with bigger size)
//	#define RD_PIECE_SIZE		3167232	// size of a piece
						// chilong: 768 * (4096 + 24(block header) + 4(block tail)) = 3167232
//	#define RD_BLOCK_SIZE		4096
//	#define DIR_BLOCK_SIZE		4096	// (DIR_BLOCK_SIZE / 64) entries

	// these two block sizes can be different
#else
	// fixed block size
	#define RD_BLOCKS_PER_PIECE	16	// number of blocks per piece
	#define RD_BLOCK_SIZE		2048	// size of a block
	#define DIR_BLOCK_SIZE		2048	// (DIR_BLOCK_SIZE / 64) entries
						// these two block sizes must be the same
#endif

/*--------------------[ DISK RELATED CONSTANTS ] -------------------*/
#define DIR_ENTRY_SIZE		(96)
#define SIGN1_LEN		(20)	// length of signature1

/*----------------[ Root Directory Related ]-----------------*/
/* Values of the first byte with special meaning */
#define DELETED_ENTRY	(0xe5)  /* file/directory is deleted */
#define FREE_ENTRY	(0x00)	/* entry was never in use */

/* Time, Date, and attribute */

// File permission
/*
#define O_APPEND	(0x01)	// Write from the end of the file
#define O_CREATE	(0x02)  // If file not exist, create it
#define O_CREAT		(0x02)  // If file not exist, create it
#define O_RDONLY	(0x04)  // The file is Read Only, DOS 

⌨️ 快捷键说明

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