📄 diskio.h
字号:
/* *---------------------------------------------------------------------- * T-Kernel / Standard Extension * * Copyright (C) 2006 by Ken Sakamura. All rights reserved. * T-Kernel / Standard Extension is distributed * under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * * Version: 1.00.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* * diskio.h (file) * * File management * Disk I/O related */#ifndef _FM_DISKIO_H_#define _FM_DISKIO_H_#include "fsinfo.h"#include "ofcb.h"#include "etc.h"#include <extension/sys/segment.h>/* * Map type information * Value set to the mode.info of the map mode specified at mapping * Information to differentiate between the system block and file-specific block, * and between to write (synchronous) and not to write (asynchronous) * when SyncFS. * * MAP_SYNC System blocks of the synchronous writing * MAP_ASYN System blocks of asynchronous writing * Others (OFCB*) File-specific blocks of synchronous writing * * MAP_FMTSK When mapping with the common section task * MAP_FSTSK When mapping with the individual section task independently of OFCB. */typedef OFCB* MapClass;#define MAP_SYNC ( (MapClass)0 )#define MAP_ASYN ( (MapClass)1 )#define MAP_FMTSK ( (MapClass)2 )#define MAP_FSTSK ( (MapClass)3 )#define MAP_SYS(fsinfo) ( ( ((fsinfo)->conMode & (FS_ASYN|FS_RONLY)) != 0 )? \ MAP_ASYN: MAP_SYNC )/* * Default map mode */#define DefaultMapMode /*(MapMode)*/{ \ 0, /* resv */ \ MapRankFM0, /* rank Rank specification */ \ 0, /* real Real/Virtual I/O specification */ \ MapNoClr, /* clear Clear specification */ \ MapSystem|MapRead|MapWrite, /* level Access level specification */ \ 0, /* space Map space specification */ \ INVADR, /* addr Map address specification */ \ 0 /* info Map information */ \ }/* * Map mode when mapping with the common section task (Real IO specification) */#define FmTskMapMode /*(MapMode)*/{ \ 0, /* resv */ \ MapRankFM1, /* rank Rank specification */ \ 1, /* real Real/Virtual I/O specification */ \ MapNoClr, /* clear Clear specification */ \ MapSystem|MapRead|MapWrite, /* level Access level specification */ \ 0, /* space Map space specification */ \ INVADR, /* addr Map address specification */ \ 0 /* info Map information */ \ }/* * Disk information required for mapping */typedef struct DiskMapInfo { ID dskid; /* Disk ID */ DiskInfo dskInfo; /* Disk information */ W pbadj; /* Correction value when computing the physical block number */ signed int diskform:16; /* File system format */ unsigned int big:1; /* TRUE when it is big endian format. */} DiskMapInfo;/* * Interconversion of the disk address */Inline DskAdr LBlkToDAdr( UW lblk ){ DskAdr da; da.offset = 0; da.lblk = lblk; return da;}Inline DskAdr LAdrToDAdr( LogAdr ladr ){ DskAdr da; da.offset = (VP)ladr.offset; da.lblk = ladr.blk; return da;}Inline LogAdr DAdrToLAdr( DskAdr dadr, UW lbsz ){ LogAdr la; la.blk = dadr.lblk + ((UW)dadr.offset / lbsz); la.offset = (UW)dadr.offset % lbsz; return la;}Inline UW DAdrToLBlk( DskAdr dadr, UW lbsz ){ return dadr.lblk + ((UW)dadr.offset / lbsz);}#define fmpLBlkToDAdr(lblk, fsinfo) LBlkToDAdr(lblk)#define fmpLAdrToDAdr(ladr, fsinfo) LAdrToDAdr(ladr)#define fmpDAdrToLAdr(dadr, fsinfo) DAdrToLAdr(dadr, (fsinfo)->sblk)#define fmpDAdrToLBlk(dadr, fsinfo) DAdrToLBlk(dadr, (fsinfo)->sblk)/* * Return value of fmCheckDiskFormat */#define DiskFormVersion(n) ( (UH)(n) )#define DiskFormEndian(n) ( ((UW)(n) >> 16) & 1U )/* Common */IMPORT ER fmCheckDiskFormat( DfSystemHeader *sh );IMPORT ER fmCheckPartitionID( DevName devnm );/* For individual section task */IMPORT VP fmpMapDskAdrS( DskAdrS dadr, W size, MapClass mapc, ID_ERR *mid, FsInfo *fsinfo );IMPORT VP fmpMapDskAdr( DskAdr dadr, W size, MapClass mapc, ID_ERR *mid, FsInfo *fsinfo );IMPORT VP fmpMapLogBlk( UW lblk, MapClass mapc, ID_ERR *mid, FsInfo *fsinfo );IMPORT VP fmpMapLogBlkC( UW lblk, MapClass mapc, MapModeClr clear, ID_ERR *mid, FsInfo *fsinfo );IMPORT VP fmpMapLogBlks( LBlks *lb, MapClass mapc, MapModeClr clear, ID_ERR *mid, FsInfo *fsinfo );IMPORT DfFileID* fmpMapFileID( FID fid, ID_ERR *mid, FsInfo *fsinfo );IMPORT DfFileHeaderBlock* fmpMapFileHeader( FID fid, DskAdr *da, ID_ERR *mid, FsInfo *fsinfo );IMPORT ER fmpSyncFile( MapClass mapc, FsInfo *fsinfo );IMPORT ER fmpCheckDiskError( OFCB *ofcb, FsInfo *fsinfo );IMPORT void fmpResetDiskError( ER err, MapClass mapc, FsInfo *fsinfo );IMPORT ER fmpDefineDiskErrorHandler( BOOL init );#define fmpMapAndClearLogBlk(lblk, mapc, mid, fsinfo) fmpMapLogBlkC(lblk, mapc, MapClr, mid, fsinfo)#define fmpUnmapDisk(mid, flg) ( (void)UnmapDisk(mid, flg) )/* For common section task */IMPORT DfSystemHeader* fmcMapFileSystemHeader( DiskMapInfo *dmInfo, FsInfo *fsinfo, ID_ERR *mid );IMPORT DfFileHeader* fmcMapRootFileHeader( DfSystemHeader *sh, DiskMapInfo *dmInfo, ID_ERR *mid );IMPORT DfShortName* fmcMapRootFileShortName( DfSystemHeader *sh, DiskMapInfo *dmInfo, ID_ERR *mid );#define fmcUnmapDisk(mid, flg) ( UnmapDisk(mid, flg) )#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -