📄 pcdisk.h
字号:
/*****************************************************************************
*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:
*
* L. Brooks changed definition of BOOL from #define to typedef for
* compatibility with Nucleus C++. (12/01/96)
*
* Added support for TI DSP's (03/97).
*
* Added support for porting x86 structures represented by UTINY buffers
* to target architecture structures and vise-versa.
*
****************************************************************************/
#ifndef __PCDISK__
#define __PCDISK__ 1
#include <stddef.h>
#ifdef PLUS
#ifndef NUCLEUS
#include "nucleus.h"
#endif
#endif
/* Pseudo types to eliminate confusion about the sizes of native types */
#define ULONG unsigned long int /* 32 BIT unsigned */
#define LONG long int /* 32 BIT signed */
#define UCOUNT unsigned short int /* 16 BIT unsigned, 32 BIT for TIDSP */
#define COUNT short int /* 16 BIT unsigned, 32 BIT for TIDSP */
#ifndef _nucpp_h_
typedef unsigned char BOOL; /* 32 BIT for TIDSP */
#endif
#define INT int /* native int, 32 BIT for TIDSP */
#define VOID void /* void */
#define UTINY unsigned char /* 8 BIT unsigned, 32 BIT for TIDSP */
#define UTEXT unsigned char /* 8 BIT signed, 32 BIT for TIDSP */
#define TEXT char /* char, 32 BIT for TIDSP */
#define BLOCKT unsigned long int /* 32 BIT unsigned */
#define PCFD int /* file desc */
#define FAIL 0 /* OS exit error status */
#define YES 1
#define NO 0
#define IMPORT extern
#define GLOBAL /* extern */
#define LOCAL static
#define BLOCKEQ0 0L
/* =========== User tunable section ================ */
/* =========== Memory model code ================ */
/* define one of the following constants.
mcj: added INTEL_PROTECTED to so that NEAR and FAR get defined out for the protected x86 port
*/
#define MOT_ORDER_32 1
#define INTEL 0
#define INTEL_PROTECTED 0
#define TI_DSP 0
#if (INTEL)
#define NEAR
#define FAR far
#else
#if (TI_DSP)
#define NEAR
#define FAR
#else
#define NEAR
#define FAR
#endif
#endif
/* ============ Device drivers =============== */
/* ============= ATI DRIVERS =============== */
/* Set the following line to 1 if you purchased the IDE driver */
#define EBS_IDE 0
/* Set the following line to 1 if you purchased the FLOPPY driver */
#define EBS_FLOPPY 0
/* Set the following line to 1 if you purchased the RAMDISK driver */
#define RAMDISK 1
#define RAMDISK_FROMPOOL 1
/* ============= RAMDISK =============== */
/* For the demonstration port we create a 50K ram disk. If you purchased
ATI's RAM Disk Driver, you can change the following definitions to
any size you desire (with the exceptions as listed below).
Note on Intel the RAM Disk is always in the far heap. So you may create
a large ram disk even in small model. Note the ram disk driver will
allocate this much core when it is first mounted.
If you don't need a ramdisk eliminate it from devtable.c
NOTE: Remove the ram disk entries from IN_DATA.C if no RAM Disk is required.
*/
#if (PLUS)
#define NUM_RAMDISK_PAGES 12 /* WAS 12 (Must be at least 1) */
#else
#define NUM_RAMDISK_PAGES 16 /* (Must be at least 1) */
#endif /* PLUS */
#define RAMDISK_PAGE_SIZE 8 /* 8 blocks ='s 4 k (dont exceed 32) */
#define NRAMDISKBLOCKS (NUM_RAMDISK_PAGES * RAMDISK_PAGE_SIZE)
/* ======== MULTI TASKING SUPPORT =============== */
/* Maximum # of tasks that may use the file system. */
#define NUM_USERS 10
/* ========= OTHER CONSTANTS =========================== */
/* Set this to total number of drives to support. This value (4) supports
(A,B,C,D). If you are going to use the RAM Disk in addition to these
four drives, set NDRIVES to 5. */
#define NDRIVES 4
/* Blocks in the buffer pool. Uses 532 bytes per block.
impacts performance during directory traversals 20 to 30 is optimal */
#define NBLKBUFFS 20
/* Maximum Number of open Files */
#define NUSERFILES 30
/* Directory Object Needs. Conservative guess is One CWD per user per drive +
One per file + one per User for directory traversal */
#define NFINODES (NUM_USERS*NDRIVES + NUM_USERS + NUSERFILES)
#define NDROBJS (NUM_USERS*NDRIVES + NUM_USERS + NUSERFILES)
#define EMAXPATH 148 /* Maximum path length Change if you like */
/* NOTE: See the end of this file for more tunable constants which pertain
to the Nucleus environment, specifically allocating memory. */
/*=============== END TUNABLE CONSTANTS ==========================*/
/*=============== MULTI TASKING DATA STRUCTURES and MACROS =======*/
/* Fine grained multitask support */
#define LOCK_METHOD 2
#if (LOCK_METHOD == 2)
/* These macros are API call prolog and epilogs. In multitasking mode
they lock/unlock the RTFS semaphore and check if the user is registered
via pc_rtfs_become_user() respectively. In single tasking mode they do nothing */
#define PC_FS_ENTER() UCOUNT process_flags = pc_fs_enter();
#define PC_FS_EXIT() pc_fs_exit(process_flags);
#define CHECK_USER(X, Y) if (!NU_Check_File_User()) \
{ pc_fs_exit(process_flags); \
return((X) Y);}
#define VOID_CHECK_USER() if (!NU_Check_File_User()) \
{ pc_fs_exit(process_flags); \
return;}
#else
/* These macros are API call prolog and epilogs. In multitasking mode
they lock/unlock the RTFS semaphore and check if the user is registered
via pc_rtfs_become_user() respectively. In single tasking mode they do nothing */
#define PC_FS_ENTER() ;
#define PC_FS_EXIT() ;
#define CHECK_USER(X, Y) ;
#define VOID_CHECK_USER() ;
#endif
/* This is the type of a unique number that is associated with each task. It
could be a process ID as in unix or a task control block address or
index in a real time exec. It is used to validate tasks as registered
Nucleus FILE users. (see pc_users.c) */
typedef int CONTEXT_HANDLE_TYPE;
#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;
COUNT opencount;
BOOL 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));
#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 (UTINY) 0xE5 /* MS-DOS file deleted char */
#define ARDONLY 0x1 /* MS-DOS File attributes */
#define AHIDDEN 0x2
#define ASYSTEM 0x4
#define AVOLUME 0x8
#define ADIRENT 0x10
#define ARCHIVE 0x20
#define ANORMAL 0x00
/* Structure used to track cached fat blocks */
typedef struct fatswap
{
UCOUNT 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 */
UCOUNT n_blocks_used; /* How many blocks in the cache have we used */
UCOUNT n_blocks_total; /* How many blocks are available in the cache */
UTINY pdirty[32]; /* BIT-map of blocks needing flushing */
BOOL block_0_is_valid; /* If YES then data_map[0] contains the offset
of the first block of the FAT */
UTINY data_map[255]; /* 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 */
UTINY FAR *data_array; /* Block buffer area on Intel systems always
FAR */
} FATSWAP;
/* Structure to contain block 0 image from the disk */
typedef struct ddrive {
COUNT opencount;
UCOUNT bytespcluster;
ULONG byte_into_cl_mask; /* And this with file pointer to get the
byte offset into the cluster */
UCOUNT fasize; /* Nibbles per fat entry. (2 or 4) */
BLOCKT rootblock; /* First block of root dir */
BLOCKT firstclblock; /* First block of cluster area */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -