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

📄 pcdisk.h

📁 nucleus file NUCLEUS的文件系统源代码
💻 H
📖 第 1 页 / 共 4 页
字号:
   Nucleus FILE users. (see pc_users.c)  */
typedef int CONTEXT_HANDLE_TYPE;

/* See the porting manual and pc_locks.c for a description of this constant */
/* Fine grained multitask support */
#define LOCK_METHOD             2
#endif  /* Num users > 1 */

#if (LOCK_METHOD == 2)
/* Natural type for an event handle (see pc_locks.c)  */
typedef int WAIT_HANDLE_TYPE;

/* This is how many event handles we will allocate at startup. */
#define NHANDLES                ((NDRIVES*3) + NFINODES))

/* Lock object: We keep track of opencount and exclusive internally.
   wait_handle is a handle to an event channel that is provided by
   the executive or os environment. via pc_alloc_lock(). When we need
   to trigger an event on the channel we call pc_wake_lock(wait_handle)
   when we need to block we call pc_wait_lock(wait_handle)
*/
typedef struct lockobj
{
    WAIT_HANDLE_TYPE    wait_handle;
    INT16               opencount;
    INT                 exclusive;
} LOCKOBJ;

/* Special macros providing fine grained re-entrancy */
#define PC_DRIVE_ENTER(X, Y)    pc_drive_enter((X), (Y));
#define PC_DRIVE_EXIT(X)        pc_drive_exit((X));
#define PC_INODE_ENTER(X,Y)     pc_inode_enter((X), (Y));
#define PC_INODE_EXIT(X)        pc_inode_exit((X));
#define PC_FAT_ENTER(X)         pc_fat_enter((X));
#define PC_FAT_EXIT(X)          pc_fat_exit((X));
#define PC_DRIVE_IO_ENTER(X)    pc_drive_io_enter((X));
#define PC_DRIVE_IO_EXIT(X)     pc_drive_io_exit((X));
#else
/* LOCK_METHOD 1 or 0 */
#define PC_DRIVE_ENTER(X, Y)
#define PC_DRIVE_EXIT(X)
#define PC_INODE_ENTER(X, Y)
#define PC_INODE_EXIT(X)
#define PC_FAT_ENTER(X)
#define PC_FAT_EXIT(X)
#define PC_DRIVE_IO_ENTER(X)
#define PC_DRIVE_IO_EXIT(X)
#endif /*  (LOCK_METHOD == 2) */

/* Changing to '/' and "//" should give unix style path separators. This
   is not tested but it should work */
#define BACKSLASH '\\'
#define STRBACKSLASH "\\"

#define PCDELETE (UINT8) 0xE5       /* MS-DOS file deleted char */

#define ARDONLY     0x01        /* Read only fil attributes */
#define AHIDDEN     0x02        /* Hidden fil attributes */
#define ASYSTEM     0x04        /* System fil attributes */
#define AVOLUME     0x08        /* Volume Lable fil attributes */
#define ADIRENT     0x10        /* Dirrectory fil attributes */
#define ARCHIVE     0x20        /* Archives fil attributes */
#define ANORMAL     0x00        /* Normal fil attributes */


/* Structure used to track cached fat blocks */
typedef struct fatswap
{
    UINT32      n_to_swap;          /* Next to swap. For implementing round robin */
    UINT32      base_block;         /* base_block of FAT sector index in data_map */
    /*  These two counters track cache usage as we fill it. Eventually the
        FAT fills and we go into swapping mode at steady state */
    UINT16      n_blocks_used;      /* How many blocks in the cache have we used */
    UINT16      n_blocks_total;     /* How many blocks are available in the cache */

    UINT8       *pdirty;            /* BIT-map of blocks needing flushing */
    INT         block_0_is_valid;   /* If YES then data_map[0] contains the offset
                                       of the first block of the FAT */
    INT         data_map_size;      /* data_map table size */
    UINT16      *data_map;          /* Table that maps block numbers in the fat to
                                       block offsets in our data array. zero means
                                       the block is not mapped. Except.. data_map[0]
                                       contains block zero of the FAT which
                                       is at location 0 in the data array */
    UINT8 FAR   *data_array;        /* Block buffer area on Intel systems always FAR */

} FATSWAP;


/* Structure to contain block 0 image from the disk */
typedef struct ddrive
{
    UINT32      fs_type;            /* FAT_FILE_SYSTEM */
    INT16       opencount;          /* Drive open count */
    UINT16      bytespcluster;      /* Bytes per cluster */
    UINT32      byte_into_cl_mask;  /* And this with file pointer to get the
                                       byte offset into the cluster */
    UINT16      fasize;             /* Nibbles per fat entry. (2 or 4) */
    UINT32      rootblock;          /* First block of root dir */
    UINT32      firstclblock;       /* First block of cluster area */
    UINT16      driveno;            /* Driveno. Set when open succeeds */
    UINT32      maxfindex;          /* Last element in the fat */
    UINT16      secproot;           /* blocks in root dir */
    INT         fat_is_dirty;       /* FAT update flag */
    INT         use_fatbuf;         /* Use FAT buffer flag */
    FATSWAP     fat_swap_structure; /* Fat swap structure if swapping */
    UINT16      log2_secpalloc;     /* Log of sectors per cluster */
    UINT32      maxfsize_cluster;   /* Maximum file cluster size */
    UINT16      valid_fsinfo;       /* fsinfo valid  flag */
          /******** BPB  ***********/
    INT8        oemname[8];         /* 0x03 OEM name */
    UINT16      bytspsector;        /* 0x0b Must be 512 for this implementation */
    UINT8       secpalloc;          /* 0x0d Sectors per cluster */
    UINT16      fatblock;           /* 0x0e Reserved sectors before the FAT */
    UINT8       numfats;            /* 0x10 Number of FATS on the disk */
    UINT16      numroot;            /* 0x11 Maximum # of root dir entries */
    UINT32      numsecs;            /* 0x13 Total # sectors on the disk */
    UINT8       mediadesc;          /* 0x15 Media descriptor byte */
    UINT32      secpfat;            /* 0x16 Size of each fat */
    UINT16      secptrk;            /* 0x18 sectors per track */
    UINT16      numhead;            /* 0x1a number of heads */
    UINT32      numhide;            /* 0x1c # hidden sectors */
    UINT32      bignumsecs;         /* 0x20 Sectors per FAT32 */
 /* FAT16/12 */
    UINT8       phys_num;           /* 0x24 physical drive number */
    UINT8       xtbootsig;          /* 0x26 extend boot recored signature */
    UINT32      volid;              /* 0x27 or 0x43 (FAT32) volume serial number */
    UINT8       vollabel[11];       /* 0x2b or 0x47 (FAT32) volueme_label */
 /* FAT32 */
    UINT32      bigsecpfat;         /* 0x24 Size of each FAT on the FAT32 */
    UINT16      fat_flag;           /* 0x28 FAT flag */
    UINT16      file_version;       /* 0x2a file system version */
    UINT32      rootdirstartcl;     /* 0x2c root cluster */
    UINT16      fsinfo;             /* 0x30 fsinfo block */
    UINT16      bpb_backup;         /* 0x32 BPB backup */
 /* FAT32 FSINFO */
    UINT32      free_clusters_count; /* If non-zero pc_free may use this value */
    UINT32      free_contig_pointer; /* Efficiently stored */

} DDRIVE;


/* Dos Directory Entry Memory Image of Disk Entry */
#define INOPBLOCK       16          /* 16 of these fit in a block */
typedef struct dosinode
{
    UINT8       fname[8];           /* 00-07h   File name */
    UINT8       fext[3];            /* 08-0Ah   File extension */
    UINT8       fattribute;         /*    0Bh   File attributes */
    UINT8       reserve;            /*    0Ch   Reserved */
    UINT8       fcrcmsec;           /*    0Dh   File create centesimal mili second */
    UINT16      fcrtime;            /* 0E-0Fh   File create time */
    UINT16      fcrdate;            /* 10-11h   File create date */
    UINT16      faccdate;           /* 12-13h   Access date */
    UINT16      fclusterhigh;       /* 14-15h   High cluster for data file */
    UINT16      fuptime;            /* 16-17h   File update time */
    UINT16      fupdate;            /* 18-19h   File update */
    UINT16      fclusterlow;        /* 1A-1Bh   Low cluster for data file */
    UINT32      fsize;              /* 1C-1Fh   File size */

} DOSINODE;


/* Block buffer */
typedef struct blkbuff
{
    struct      blkbuff *pnext;     /* Next block buffer pointer */
    UINT32      lru;                /* Last recently used stuff */
    INT16       locked;             /* Reserve */
    DDRIVE      *pdrive;            /* Drive block 0 image */
    UINT32      blockno;            /* I/O block number */
    INT16       use_count;          /* use count */
    INT         io_pending;         /* I/O pending flag */
    UINT8       data[512];          /* I/O data buffer */

} BLKBUFF;


/* Long file name information */
typedef struct lnaminfo
{
    BLKBUFF     *lnamblk1;          /* Long file name block buffer 1    */
    BLKBUFF     *lnamblk2;          /* Long file name block buffer 2    */
    BLKBUFF     *lnamblk3;          /* Long file name block buffer 3    */
    INT16       lnam_index;         /* Long file name start index       */
    INT16       lnament;            /* Number of long file name entries */
    UINT8       lnamchk;            /* Check value of short file name   */

} LNAMINFO;


/* Long file name Directory Entry Memory Image of Disk Entry */
typedef struct lnament
{
    UINT8       ent_num;            /*    00h   Long filename entry number  */
    UINT8       str1[10];           /* 01-0Ah   File name                   */
    UINT8       attrib;             /*    0Bh   File attributes, always 0Fh */
    UINT8       reserve;            /*    0Ch   Reserved                    */
    UINT8       snamchk;            /*    0Dh   Short file name check       */
    UINT8       str2[12];           /* 0E-19h   File name                   */
    UINT8       fatent[2];          /* 1A-1Bh   File entry number, always 00*/
    UINT8       str3[4];            /* 1C-1Fh   File name                   */

} LNAMENT;


/* Internal representation of DOS entry */
typedef struct finode
{
    UINT8       fname[8];           /* File name */
    UINT8       fext[3];            /* File extension */
    UINT8       fattribute;         /* File attributes */
    UINT8       reserve;            /* Reserved */
    UINT8       fcrcmsec;           /* File create centesimal mili second */
    UINT16      fcrtime;            /* File create time */
    UINT16      fcrdate;            /* File create date */
    UINT16      faccdate;           /* Access date */
    UINT16      fuptime;            /* File update time */
    UINT16      fupdate;            /* File update */
    UINT32      fcluster;           /* Cluster for data file */
    UINT32      fsize;              /* File size */
    UINT32      alloced_size;       /* Size rounded up to the hearest cluster
                       (only maintained for files */
    INT16   opencount;

/* If the finode is an open file the following flags control the sharing.
   they are maintained by NU_Open                                      */
#ifdef OF_WRITE
#undef OF_WRITE
#endif
#define OF_WRITE            0x01    /* File is open for write by someone */
#define OF_WRITEEXCLUSIVE   0x02    /* File is open for write by someone
                                       they wish exclusive write access */
#define OF_EXCLUSIVE        0x04    /* File is open with exclusive access not
                                       sharing write or read */
    INT16       openflags;          /* For Files. Track how files have it open */
    DDRIVE      *my_drive;          /* Block 0 image from this disk */
    UINT32      my_block;           /* Number of this file directory entry block */
    INT16       my_index;           /* Directory entry index */
#if (LOCK_METHOD == 2)
    LOCKOBJ     lock_object;        /* for locking during critical sections */
#endif
    struct finode *pnext;           /* Next DOS entry pointer */
    struct finode *pprev;           /* Prevenience DOS entry pointer */
    UINT16      abs_length;         /* Absolute path length */

⌨️ 快捷键说明

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