📄 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:
*
*
*
*
****************************************************************************/
#ifndef __PCDISK__
#define __PCDISK__ 1
#define NU_NO_ERROR_CHECKING 1
#include <stddef.h>
#ifdef PLUS
#ifndef NUCLEUS
#include "plus\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 */
#define COUNT short int /* 16 BIT unsigned */
#define BOOL int /* native int */
#define INT int /* native int */
#define VOID void /* void */
#define UTINY unsigned char /* 8 BIT unsigned */
#define UTEXT unsigned char /* 8 BIT signed */
#define TEXT char /* char */
#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 ================ */
/* On non intel environments use ther following */
#define INTEL 0
#if (INTEL)
#define FAR far
#else
#define FAR
#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
/* ============= 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)
/* Set the following to one if you wish to allocate ram disk memory from
a PLUS memory pool. This affects code in nufp.c and ramdisk.c. This should
be set to 1 for 32 bit systems where it is possible to use allocate > 64K
to a memory pool. If you wish to allocate a RAM Disk larger than 48K on
an Intel real-mode based Nucleus PLUS port, then you should set this
manifest to 0. In that case, the pool will be created by using a DOS
malloc call.
*/
#define RAMDISK_FROMPOOL 1 /* Plus only */
#if (RAMDISK_FROMPOOL)
/* Nucleus PLUS: If allocating the ram disk from a partition pool we
allocated 12 pages (48K). This is because 8086 real mode ports under plus
may only allocate 64K at a time for a pool. For 32 bit ports this
restriction does not exist. */
#define NUM_RAMDISK_PAGES 40 /* WAS 12 (Must be at least 1) */
#else
#define NUM_RAMDISK_PAGES 40 /* WAS 16 (Must be at least 1) */
#endif
#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 =======*/
/* 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;}
/* 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;
/* Fine grained multitask support */
#define LOCK_METHOD 2
#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 */
UCOUNT driveno; /* Driveno. Set when open succeeds */
UCOUNT maxfindex; /* Last element in the fat */
BLOCKT fatblock; /* First block in fat */
UCOUNT secproot; /* blocks in root dir */
BOOL fat_is_dirty;
BOOL use_fatbuf;
FATSWAP fat_swap_structure; /* Fat swap structure if swapping */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -