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

📄 pcdisk.h

📁 ertfs文件系统里面既有完整ucos程序
💻 H
📖 第 1 页 / 共 3 页
字号:
/*****************************************************************************
*Filename: PCDISK.H - Defines & structures for ms-dos utilities
*                     
*
* EBS - RTFS (Real Time File Manager)
*
* Copyright Peter Van Oudenaren , 1993
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*
*
*
* Description: 
*   
*
*
*
****************************************************************************/

#ifndef __PCDISK__
#define __PCDISK__ 1

#if (defined(ERTFS_SA))
#define INCLUDE_ERTFS 1
#include "portkern.h"
#include "portio.h"          /* OS specific */
#include "portterm.h"        /* OS specific */
#include "rtfsapi.h"

#else

/*
 * if not built 'Stand-Alone' and you defined INCLUDE_RTIP, load
 * xnconf.h to set the desired value for INCLUDE_RTIP and others.
 */              
#if defined(INCLUDE_RTIP)
/* load RTIP configuration settings */
#include "xnconf.h"
#endif

#if (INCLUDE_RTIP)
#include "rtip.h"
#if (INCLUDE_ERTFS)
#include "rtfsapi.h"
#endif
#else   // INCLUDE_RTIP
#include "ebs.h"
#include "os.h"          /* OS specific */
#if (INCLUDE_ERTFS)
#include "rtfsapi.h"
#endif
#endif  // INCLUDE_RTIP

#endif // ERTFS_SA

#include "pcconf.h"
#if (INCLUDE_ERTFS)
typedef unsigned long int BLOCKT;   /* 32 BIT unsigned */
#define BLOCKEQ0 0L

/* Include kernel specific definitions */
#if (USE_ATA)
#include <ide_drv.h>
#endif

#if (USE_FLOPPY)
#include <fl_drver.h>
#endif

#if (FAT32)
typedef unsigned long  CLUSTERTYPE;
#else
typedef unsigned short CLUSTERTYPE;
#endif

/* Device types (floppy or ide) */
#define DEV_FLOPPY                  1
#define DEV_PCMCIA_ATA              2
#define DEV_PCMCIA_SRAM             3
#define DEV_TRUE_IDE_ATA            4
#define DEV_RAMDISK                 5
#define DEV_ROMDISK                 6


// 10-24-2000 added LBA formatting. Submit to main tree

/* Structure used to reserve arrays of blocks in the BSS */
typedef struct block_alloc {
        byte    core[512];
        } BLOCK_ALLOC;

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

#if (VFAT)
#define FIRST_NAMESEG 0x40
#define NAMESEG_ORDER 0x3F
#endif

    /* Structure used to track cached fat blocks */
typedef struct fatswap
{
    word  n_to_swap;  /* Next to swap. For implementing round robin */
        /* These two counters track cache usage as we fill it. Eventually the 
           FAT fills and we go into swapping mode at steady state */
    word  n_blocks_used;  /* How many blocks in the cache have we used */
    word  n_blocks_total; /* How many blocks are available in the cache */
    BOOLEAN block_0_is_valid; /*  If TRUE then data_map[0] contains the offset
                                  of the first block of the FAT */
#if (FAT_BUFFER_SIZE > 63)
	/* This should work on systems with 32 bit integers and segments 
       but we'll leave it as an option for now */
    byte   pdirty[FAT_BUFFER_SIZE/8];
    byte   data_map[FAT_BUFFER_SIZE*4];
#else
    byte   pdirty[32];   /* BIT-map of blocks needing flushing */
    byte   data_map[256];   /* 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 */
#endif
    PFBYTE data_array;   /* Block buffer area */
} FATSWAP;


    /* Structure to contain block 0 image from the disk */
typedef struct ddrive {
        BOOLEAN  mount_valid;       /* True if valid volume and 
                                       BLOCK 0, fat buffer, block pool 
                                       etc are valid */
        dword volume_serialno;      /* Volume serial number block 0 */
        byte  volume_label[14];     /* Volume entry from block 0 */
        word  bytespcluster;        /*  */
        dword byte_into_cl_mask;    /* And this with file pointer to get the
                                       byte offset into the cluster */
        word    fasize;             /* Nibbles per fat entry. (2 or 4) */
        BLOCKT  rootblock;          /* First block of root dir */
        BLOCKT  firstclblock;       /* First block of cluster area */
        word    driveno;            /* Driveno. Set when open succeeds */
        CLUSTERTYPE maxfindex;      /* Last element in the fat - FAT32*/
        BLOCKT  fatblock;           /* First block in fat */
        word    secproot;           /* blocks in root dir */
        BOOLEAN fat_is_dirty;
        FATSWAP fat_swap_structure; /* Fat swap structure if swapping */
        dword   bootaddr;
        char    oemname[9];
        word    bytspsector;        /* Must be 512 for this implementation */
        byte    secpalloc;          /* Sectors per cluster */
        word    log2_secpalloc;     /* Log of sectors per cluster */
        word    secreserved;        /* Reserved sectors before the FAT */
        byte    numfats;            /* Number of FATS on the disk */
        word    numroot;            /* Maximum # of root dir entries */
        BLOCKT  numsecs;            /* Total # sectors on the disk */
        byte    mediadesc;          /* Media descriptor byte */
        CLUSTERTYPE secpfat;        /* Size of each fat */
        word    secptrk;            /* sectors per track */
        word    numhead;            /* number of heads */
        BLOCKT  numhide;            /* # hidden sectors */
        CLUSTERTYPE  free_contig_base;   /* Guess of where file data would most */
        CLUSTERTYPE  free_contig_pointer;/* Efficiently stored */  
#if (FAT32)
        long    known_free_clusters;/* If non-zero pc_free may use this value - FAT32 */
        word    infosec;
#else
        word    known_free_clusters;/* If non-zero pc_free may use this value */
#endif
    

// NEWNEW
// These arent new but they are moved to this section because they play a larger
// role. These values are loaded by the routine pc_read_partition_table(). And
// used by formatting and read/write routines.


        BLOCKT partition_base;      /* Start of the partition */
        dword  partition_size;      /* Size of the partition  */
        int    partition_type;      /* Partition type */
        int    begin_user_area;     /* Beyond this is initialized at
                                       run time and must not be written
                                       by ertfs */

/* user init is required for the following elements required */
        IOADDRESS register_file_address;
        int       interrupt_number;      // note -1 is polled for IDE

/* Flags - These must be set by the pc_ertfs_init */
#define DRIVE_FLAGS_PARTITIONED     0x0002  /* Partitioned device  */
#define DRIVE_FLAGS_PCMCIA          0x0004  /* Pcmcia device */
#define DRIVE_FLAGS_PCMCIA_ATA		0x0008
/* Flags - These must be set by the warmstrt IOCTL call to the driver */
#define DRIVE_FLAGS_VALID           0x0001  /* Flags have been set */
#define DRIVE_FLAGS_REMOVABLE       0x0040  /* Device is removable */
#define DRIVE_FLAGS_INSERTED        0x0080  /* Device drivers use to 
                                               remember states */
/* VALID is set by the device driver as a result of a successful call to 
   the device ioctl call DEVCTL_WARMSTART. If the driver does not set this 
   flag then it i assumed that the driver probe or init sequence failed
*/
        word drive_flags;
        int partition_number;
        int lock_unit;
        int pcmcia_slot_number;
        int pcmcia_controller_number;
        byte pcmcia_cfg_opt_value;

        int controller_number;
        int logical_unit_number;

        /* These two routines are attached to device driver specific routines */
        BOOLEAN (*dev_table_drive_io)(int driveno, dword sector, void KS_FAR *buffer, word count, BOOLEAN readin);
        int (*dev_table_perform_device_ioctl)(int driveno, int opcode, PFVOID arg);
/* end user init required */
        } DDRIVE;

    /* Dos Directory Entry Memory Image of Disk Entry */
#define INOPBLOCK 16                /* 16 of these fit in a block */
typedef struct dosinode {
        byte    fname[8];
        byte    fext[3];
        byte    fattribute;      /* File attributes */
#if (FAT32)
        byte    resarea[8];
        word    fclusterhi; /* This is where FAT32 stores file location */
#else
        byte    resarea[10];
#endif
        word  ftime;              /* time & date lastmodified */
        word  fdate;
        word  fcluster;        /* Cluster for data file */
        dword   fsize;            /* File size */
        } DOSINODE;



#if (VFAT)

/* LFNINODE - This is an image of lfn extended names in a subdirectory */
/* Note: lfn file names are null terminated unicode 00, the lfninode is
   padded mod 13 with ffff */
typedef struct lfninode {
                              /* The first LNF has 0x40 + N left */
        byte    lfnorder;     /* 0x45, 0x04, 0x03, 0x02, 0x01 they are stored in
                               reverse order */
        byte    lfname1[10];
//      UNICODE lfname1[5];
        byte    lfnattribute; /* always 0x0F */
        byte    lfnres;       /* reserved */
        byte    lfncksum;   /* All lfninode in one dirent have the same chksum */
        byte    lfname2[12];
//      UNICODE lfname2[6];
        word    lfncluster; /* always 0x0000 */
        byte    lfname3[4];
//      UNICODE lfname3[2];
        } LFNINODE;             

/* Trag lfn segments. segblock[0] is the block that contains beginning of the
   file name. segindex is the segment in that block where the beginning is
   stored. If the lfn spans > 1 block the next block # is in segblock[2] */
typedef struct segdesc {
    int nsegs;      /* # segs in the lfn */
    int segindex;
    byte ncksum;    /* checksum of the associated DOSINODE */
    BLOCKT segblock[2];
    } SEGDESC;

#endif


    /* Internal representation of DOS entry */
    /* The first 8 fields !MUST! be identical to the DOSINODE structure.
       The code will be changed later so finode contains a DOSINODE (bug) */
typedef struct finode {
        byte   fname[8];
        byte   fext[3];
        byte   fattribute;       /* File attributes */
#if (FAT32)
        byte    resarea[8];
        word    fclusterhi; /* This is where FAT32 stores file location */
#else
        word    resarea[10];
#endif
        word  ftime;              /* time & date lastmodified */
        word  fdate;
        word  fcluster;        /* Cluster for data file */
        dword   fsize;            /* File size */

        dword   alloced_size;      /* Size rounded up to the hearest cluster 
                                       (only maintained for files */
        int   opencount;
/* If the finode is an open file the following flags control the sharing.
   they are maintained by po__open                                    */
#ifdef OF_WRITE
/* The watcom Windows include files define OF_WRITE too */
#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 */
        int   openflags;          /* For Files. Track how files have it open */
        DDRIVE  *my_drive;
        BLOCKT  my_block;
        int   my_index;
        struct finode *pnext;      
        struct finode *pprev;

⌨️ 快捷键说明

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