Ran all .c and .h files through "indent"

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@329 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2001-11-18 14:01:12 +00:00
parent 684a2cb93d
commit b6d423a1b3
73 changed files with 8037 additions and 8177 deletions

View File

@ -1,14 +1,14 @@
#if defined(_MSC_VER)
#define asm __asm
#if _MSC_VER >= 700
#pragma warning(disable:4103)
#endif
#pragma pack(1)
#elif defined(_QC) || defined(__WATCOM__)
#pragma pack(1)
#elif defined(__ZTC__)
#pragma ZTC align 1
#elif defined(__TURBOC__) && (__TURBOC__ > 0x202)
#pragma option -a-
#define asm __asm
#if _MSC_VER >= 700
#pragma warning(disable:4103)
#endif
#pragma pack(1)
#elif defined(_QC) || defined(__WATCOM__)
#pragma pack(1)
#elif defined(__ZTC__)
#pragma ZTC align 1
#elif defined(__TURBOC__) && (__TURBOC__ > 0x202)
#pragma option -a-
#endif

View File

@ -32,13 +32,13 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *buffer_hRcsId = "$Id$";
static BYTE *buffer_hRcsId =
"$Id$";
#endif
#endif
#define BUFFERSIZE 512
struct buffer
{
struct buffer {
WORD b_dummy; /* dummy self pointing word to keep MFT from crashing */
struct buffer
FAR *b_next; /* form linked list for LRU */
@ -53,12 +53,10 @@ struct buffer
UWORD b_offset; /* span between copies */
#endif
#if 0 /*TE*/
union
{
union {
struct dpb FAR *_b_dpbp; /* pointer to DPB */
LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */
}
_b;
} _b;
#endif
BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */
};
@ -79,4 +77,3 @@ struct buffer
* Rev 1.0 20 Apr 2001 17:30:00 Bart Oldeman
* Initial revision.
*/

View File

@ -28,30 +28,25 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *Cds_hRcsId = "$Id$";
static BYTE *Cds_hRcsId =
"$Id$";
#endif
#endif
#define MAX_CDSPATH 67
struct cds
{
struct cds {
BYTE cdsCurrentPath[MAX_CDSPATH];
UWORD cdsFlags;
struct dpb FAR *cdsDpb;
union
{
BYTE FAR *
_cdsRedirRec;
struct
{
union {
BYTE FAR *_cdsRedirRec;
struct {
UWORD _cdsStrtClst;
UWORD _cdsParam;
}
_cdsRedir;
}
_cdsUnion;
} _cdsRedir;
} _cdsUnion;
UWORD cdsStoreUData;
@ -67,11 +62,9 @@ struct cds
#define cdsRedirRec _cdsUnion._cdsRedirRec
#define cdsParam _cdsUnion._cdsRedir._cdsParam
typedef struct _cdstbl
{
typedef struct _cdstbl {
struct cds cds_table[26];
}
cdstbl;
} cdstbl;
/* Bits for cdsFlags */
#define CDSNETWDRV 0x8000

View File

@ -32,13 +32,12 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *clock_hRcsId = "$Id$";
static BYTE *clock_hRcsId =
"$Id$";
#endif
#endif
struct ClockRecord
{
struct ClockRecord {
UWORD clkDays; /* days since Jan 1, 1980. */
UBYTE clkMinutes; /* residual minutes. */
UBYTE clkHours; /* residual hours. */

View File

@ -32,7 +32,8 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *date_hRcsId = "$Id$";
static BYTE *date_hRcsId =
"$Id$";
#endif
#endif

View File

@ -30,13 +30,13 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *clock_hRcsId = "$Id$";
static BYTE *clock_hRcsId =
"$Id$";
#endif
#endif
/* Internal drive parameter block */
struct dpb
{
struct dpb {
BYTE dpb_unit; /* unit for error reporting */
BYTE dpb_subunit; /* the sub-unit for driver */
UWORD dpb_secsize; /* sector size */
@ -61,18 +61,16 @@ struct dpb
UWORD dpb_nfreeclst; /* number of free clusters */
/* -1 if not known */
#else
union
{
struct
{
union {
struct {
UWORD dpb_nfreeclst_lo;
UWORD dpb_nfreeclst_hi;
} dpb_nfreeclst_st;
ULONG _dpb_xnfreeclst; /* number of free clusters */
/* -1 if not known */
} dpb_nfreeclst_un;
#define dpb_nfreeclst dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_lo
#define dpb_xnfreeclst dpb_nfreeclst_un._dpb_xnfreeclst
#define dpb_nfreeclst dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_lo
#define dpb_xnfreeclst dpb_nfreeclst_un._dpb_xnfreeclst
UWORD dpb_xflags; /* extended flags, see bpb */
UWORD dpb_xfsinfosec; /* FS info sector number, */

View File

@ -29,11 +29,11 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *device_hRcsId = "$Id$";
static BYTE *device_hRcsId =
"$Id$";
#endif
#endif
/*
* Status Word Bits
*/
@ -122,8 +122,7 @@ static BYTE *device_hRcsId = "$Id$";
/* Device header */
struct dhdr
{
struct dhdr {
struct dhdr
FAR *dh_next;
UWORD dh_attr;
@ -155,8 +154,7 @@ struct dhdr
#define BPB_SIZEOF 31 /* size of the standard BPB */
typedef struct
{
typedef struct {
UWORD bpb_nbyte; /* Bytes per Sector */
UBYTE bpb_nsector; /* Sectors per Allocation Unit */
UWORD bpb_nreserved; /* # Reserved Sectors */
@ -184,8 +182,7 @@ typedef struct
UWORD bpb_xbackupsec; /* backup boot sector number */
/* 0xFFFF if unknown */
#endif
}
bpb;
} bpb;
#define N_RETRY 5 /* number of retries permitted */
#define SEC_SIZE 512 /* size of sector in bytes */
@ -193,15 +190,15 @@ bpb;
#define LBA_READ 0x4200
#define LBA_WRITE 0x4300
struct _bios_LBA_address_packet /* Used to access a hard disk via LBA */
struct _bios_LBA_address_packet
/* Used to access a hard disk via LBA */
/* Added by Brian E. Reifsnyder */
{
unsigned char packet_size; /* size of this packet...set to 16 */
unsigned char reserved_1; /* set to 0...unused */
unsigned char number_of_blocks; /* 0 < number_of_blocks < 128 */
unsigned char reserved_2; /* set to 0...unused */
UBYTE far * buffer_address; /* addr of transfer buffer */
UBYTE far *buffer_address; /* addr of transfer buffer */
unsigned long block_address; /* LBA address */
unsigned long block_address_high; /* high bytes of LBA addr...unused */
};
@ -213,8 +210,7 @@ struct CHS {
};
/* DOS 4.0-7.0 drive data table (see RBIL at INT2F,AX=0803) */
typedef struct ddtstruct
{
typedef struct ddtstruct {
struct ddtstruct FAR *ddt_next;
/* pointer to next table (offset FFFFh if last table) */
UBYTE ddt_driveno; /* physical unit number (for INT 13) */
@ -225,30 +221,28 @@ typedef struct ddtstruct
bit 7: unsupportable disk (all accesses will return Not Ready) */
UWORD ddt_FileOC; /* Count of Open files on Drv */
UBYTE ddt_type; /* device type */
UWORD ddt_descflags;/* bit flags describing drive */
UWORD ddt_descflags; /* bit flags describing drive */
UWORD ddt_ncyl; /* number of cylinders
(for partition only, if hard disk) */
bpb ddt_defbpb; /* BPB for default (highest) capacity supported */
UBYTE ddt_reserved[6]; /* (part of BPB above) */
UBYTE ddt_ltrack; /* last track accessed */
union
{
union {
ULONG ddt_lasttime; /* removable media: time of last access
in clock ticks (FFFFFFFFh if never) */
struct
{
struct {
UWORD ddt_part; /* partition (FFFFh = primary, 0001h = extended)
always 0001h for DOS 5+ */
UWORD ddt_abscyl; /* absolute cylinder number of partition's
start on physical drive
(FFFFh if primary partition in DOS 4.x)*/
(FFFFh if primary partition in DOS 4.x) */
} ddt_hd;
} ddt_fh;
UBYTE ddt_volume[12]; /* ASCIIZ volume label or "NO NAME " if none
(apparently taken from extended boot record
rather than root directory) */
ULONG ddt_serialno; /* serial number */
UBYTE ddt_fstype[9]; /* ASCIIZ filesystem type ("FAT12 " or "FAT16 ")*/
UBYTE ddt_fstype[9]; /* ASCIIZ filesystem type ("FAT12 " or "FAT16 ") */
ULONG ddt_offset; /* relative partition offset */
BITS ddt_LBASupported:1; /* set, if INT13 extensions enabled */
BITS ddt_WriteVerifySupported:1;
@ -268,8 +262,7 @@ typedef struct ddtstruct
/* typedef struct ddtstruct ddt;*/
struct gblkio
{
struct gblkio {
UBYTE gbio_spcfunbit;
UBYTE gbio_devtype;
UWORD gbio_devattrib;
@ -294,11 +287,10 @@ struct gblkrw /* for read / write track */
UWORD gbrw_cyl;
UWORD gbrw_sector;
UWORD gbrw_nsecs;
UBYTE FAR * gbrw_buffer;
UBYTE FAR *gbrw_buffer;
};
struct Gioc_media
{
struct Gioc_media {
WORD ioc_level;
ULONG ioc_serialno;
BYTE ioc_volume[11];
@ -315,8 +307,7 @@ struct Gioc_media
#define BT_BPB 11
#define BT_SIZEOF 36
typedef struct
{
typedef struct {
BYTE bt_jump[3]; /* Boot Jump opcodes */
BYTE bt_oem[8]; /* OEM Name */
bpb bt_bpb; /* BPB for this media/device */
@ -330,12 +321,10 @@ typedef struct
ULONG bt_serialno;
BYTE bt_volume[11];
BYTE bt_fstype[8];
}
boot;
} boot;
/* File system information structure */
struct fsinfo
{
struct fsinfo {
UDWORD fi_signature; /* must be 0x61417272 */
DWORD fi_nfreeclst; /* number of free clusters, -1 if unknown */
DWORD fi_cluster; /* most recently allocated cluster, -1 if unknown */
@ -344,61 +333,42 @@ struct fsinfo
typedef boot super; /* Alias for boot structure */
typedef struct
{
typedef struct {
UBYTE r_length; /* Request Header length */
UBYTE r_unit; /* Unit Code */
UBYTE r_command; /* Command Code */
WORD r_status; /* Status */
BYTE r_reserved[8]; /* DOS Reserved Area */
union
{
struct
{
union {
struct {
UBYTE _r_nunits; /* number of units */
BYTE FAR *_r_endaddr; /* Ending Address */
bpb *FAR * _r_bpbptr; /* ptr to BPB array */
UBYTE _r_firstunit;
}
_r_init;
struct
{
} _r_init;
struct {
BYTE _r_meddesc; /* MEDIA Descriptor */
BYTE _r_retcode; /* Return Code */
BYTE FAR
* _r_vid; /* volume id */
}
_r_media;
struct
{
BYTE FAR * _r_vid; /* volume id */
} _r_media;
struct {
BYTE _r_meddesc; /* MEDIA Descriptor */
boot FAR
* _r_fat; /* boot sector pointer */
bpb FAR
* _r_bpbpt; /* ptr to BPB table */
}
_r_bpb;
struct
{
boot FAR * _r_fat; /* boot sector pointer */
bpb FAR * _r_bpbpt; /* ptr to BPB table */
} _r_bpb;
struct {
BYTE _r_meddesc; /* MEDIA Descriptor */
BYTE FAR
* _r_trans; /* Transfer Address */
BYTE FAR * _r_trans; /* Transfer Address */
UWORD _r_count; /* Byte/Sector Count */
UWORD _r_start; /* Starting Sector No. */
BYTE FAR
* _r_vid; /* Pointer to volume id */
BYTE FAR * _r_vid; /* Pointer to volume id */
LONG _r_huge; /* for > 32Mb drives */
}
_r_rw;
struct
{
} _r_rw;
struct {
BYTE _r_ndbyte; /* Byte Read From Device */
}
_r_nd;
}
_r_x;
}
request;
} _r_nd;
} _r_x;
} request;
#define HUGECOUNT 0xffff
#define MAXSHORT 0xffffl

View File

@ -30,13 +30,12 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *dirmatch_hRcsId = "$Id$";
static BYTE *dirmatch_hRcsId =
"$Id$";
#endif
#endif
typedef struct
{
typedef struct {
BYTE dm_drive;
BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE];
BYTE dm_attr_srch;
@ -48,8 +47,7 @@ typedef struct
UWORD reserved;
#endif
struct
{
struct {
BITS /* directory has been modified */
f_dmod:1;
BITS /* directory is the root */
@ -60,16 +58,14 @@ typedef struct
f_ddir:1;
BITS /* filler to avoid a bad bug (feature?) in */
f_filler:12; /* TC 2.01 */
}
dm_flags; /* file flags */
} dm_flags; /* file flags */
BYTE dm_attr_fnd; /* found file attribute */
time dm_time; /* file time */
date dm_date; /* file date */
LONG dm_size; /* file size */
BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */
}
dmatch;
} dmatch;
/*
* Log: dirmatch.h,v

View File

@ -30,15 +30,14 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *dosnames_hRcsId = "$Id$";
static BYTE *dosnames_hRcsId =
"$Id$";
#endif
#endif
#define PARSE_MAX 64
struct dosnames
{
struct dosnames {
UBYTE dn_drive; /* the drive that was parsed */
UBYTE dn_network[PARSE_MAX]; /* specified network */
UBYTE dn_path[PARSE_MAX]; /* the path */

View File

@ -30,11 +30,11 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *error_hRcsId = "$Id$";
static BYTE *error_hRcsId =
"$Id$";
#endif
#endif
/* Internal system error returns */
#define SUCCESS 0 /* Function was successful */
#define DE_INVLDFUNC -1 /* Invalid function number */

View File

@ -30,13 +30,12 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *exe_hRcsId = "$Id$";
static BYTE *exe_hRcsId =
"$Id$";
#endif
#endif
typedef struct
{
typedef struct {
UWORD exSignature;
UWORD exExtraBytes;
UWORD exPages;
@ -51,8 +50,7 @@ typedef struct
UWORD exInitCS;
UWORD exRelocTable;
UWORD exOverlay;
}
exe_header;
} exe_header;
#define MAGIC 0x5a4d

View File

@ -30,11 +30,11 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *fat_hRcsId = "$Id$";
static BYTE *fat_hRcsId =
"$Id$";
#endif
#endif
/* FAT file system attribute bits */
#define D_NORMAL 0 /* normal */
#define D_RDONLY 0x01 /* read-only file */
@ -79,8 +79,7 @@ static BYTE *fat_hRcsId = "$Id$";
/* dpb_size == 0 for FAT32, hence doing -1 here */
/* FAT file system directory entry */
struct dirent
{
struct dirent {
UBYTE dir_name[FNAME_SIZE]; /* Filename */
UBYTE dir_ext[FEXT_SIZE]; /* Filename extension */
UBYTE dir_attrib; /* File Attribute */
@ -97,8 +96,7 @@ struct dirent
ULONG dir_size; /* File size in bytes */
};
struct lfn_entry
{
struct lfn_entry {
UBYTE lfn_id;
UNICODE lfn_name0_4[5];
UBYTE lfn_attrib;
@ -142,8 +140,7 @@ struct lfn_entry
#define DIRENT_SIZE 32
struct lfn_inode
{
struct lfn_inode {
UNICODE name[256];
struct dirent l_dir;
@ -151,7 +148,7 @@ struct lfn_inode
ULONG l_diroff; /* offset of the dir entry */
};
typedef struct lfn_inode FAR * lfn_inode_ptr;
typedef struct lfn_inode FAR *lfn_inode_ptr;
/*
* Log: fat.h,v

View File

@ -30,11 +30,11 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *fcb_hRcsId = "$Id$";
static BYTE *fcb_hRcsId =
"$Id$";
#endif
#endif
/* fcb convience defines */
/* block device info */
#define FID_CHARDEV 0x80 /* 1 defines character device */
@ -77,8 +77,7 @@ static BYTE *fcb_hRcsId = "$Id$";
#define FCB_WRITE 1
/* File Control Block (FCB) */
typedef struct
{
typedef struct {
BYTE fcb_drive; /* Drive number 0=default, 1=A, etc */
BYTE fcb_fname[FNAME_SIZE]; /* File name */
BYTE fcb_fext[FEXT_SIZE]; /* File name Extension */
@ -99,21 +98,17 @@ typedef struct
/* end reserved */
UBYTE fcb_curec; /* Current block number of */
ULONG fcb_rndm; /* Current relative record number */
}
fcb;
} fcb;
/* FAT extended fcb */
typedef struct
{
typedef struct {
UBYTE xfcb_flag; /* 0xff indicates Extended FCB */
BYTE xfcb_resvrd[5]; /* Reserved */
UBYTE xfcb_attrib; /* Attribute */
fcb xfcb_fcb;
}
xfcb;
} xfcb;
typedef struct
{
typedef struct {
UBYTE renDriveID; /* drive no. */
BYTE renOldName[8]; /* Old Filename */
BYTE renOldExtent[3]; /* Old File Extension */
@ -121,8 +116,7 @@ typedef struct
BYTE renNewName[8]; /* New Filename */
BYTE renNewExtent[3]; /* New FileExtension */
BYTE renReserved2[9];
}
rfcb;
} rfcb;
/*
* Log: fcb.h,v

View File

@ -30,11 +30,11 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *file_hRcsId = "$Id$";
static BYTE *file_hRcsId =
"$Id$";
#endif
#endif
/* 0 = CON, standard input, can be redirected */
/* 1 = CON, standard output, can be redirected */
/* 2 = CON, standard error */

View File

@ -30,25 +30,22 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *fnode_hRcsId = "$Id$";
static BYTE *fnode_hRcsId =
"$Id$";
#endif
#endif
struct f_node
{
struct f_node {
UWORD f_count; /* number of uses of this file */
COUNT f_mode; /* read, write, read-write, etc */
struct
{
struct {
BITS f_dmod:1; /* directory has been modified */
BITS f_droot:1; /* directory is the root */
BITS f_dnew:1; /* fnode is new and needs fill */
BITS f_ddir:1; /* fnode is assigned to dir */
BITS f_ddate:1; /* date set using setdate */
}
f_flags; /* file flags */
} f_flags; /* file flags */
struct dirent f_dir; /* this file's dir entry image */
@ -67,8 +64,7 @@ struct f_node
};
#if 0
struct lfn_inode
{
struct lfn_inode {
UNICODE name[255];
struct dirent l_dir; /* this file's dir entry image */
@ -76,12 +72,12 @@ struct lfn_inode
ULONG l_diroff; /* offset of the dir entry */
CLUSTER l_dirstart; /* the starting cluster of dir */
/* when dir is not root */
};
};
typedef struct lfn_inode FAR * lfn_inode_ptr;
typedef struct lfn_inode FAR *lfn_inode_ptr;
#endif
typedef struct f_node * f_node_ptr;
typedef struct f_node *f_node_ptr;
/*
* Log: fnode.h,v

View File

@ -30,21 +30,19 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *kbd_hRcsId = "$Id$";
static BYTE *kbd_hRcsId =
"$Id$";
#endif
#endif
#define KBD_MAXLENGTH 256
/* Keyboard buffer */
typedef struct
{
typedef struct {
UBYTE kb_size; /* size of buffer in bytes */
UBYTE kb_count; /* number of bytes returned */
BYTE kb_buf[KBD_MAXLENGTH]; /* the buffer itself */
}
keyboard;
} keyboard;
/*
* Log: kbd.h,v

View File

@ -23,5 +23,5 @@ typedef struct _KernelConfig {
signed char SkipConfigSeconds;
unsigned char ForceLBA;
unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */
} KernelConfig;
} KernelConfig;
extern struct _KernelConfig FAR LowKernelConfig;

View File

@ -30,7 +30,8 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *mcb_hRcsId = "$Id$";
static BYTE *mcb_hRcsId =
"$Id$";
#endif
#endif
@ -56,15 +57,13 @@ static BYTE *mcb_hRcsId = "$Id$";
typedef UWORD seg;
typedef UWORD offset;
typedef struct
{
typedef struct {
BYTE m_type; /* mcb type - chain or end */
UWORD m_psp; /* owner id via psp segment */
UWORD m_size; /* size of segment in paragraphs */
BYTE m_fill[3];
BYTE m_name[8]; /* owner name limited to 8 bytes */
}
mcb;
} mcb;
/*
* Log: mcb.h,v

View File

@ -59,30 +59,22 @@
#define REM_PRINTREDIR 0x1125
#define REM_EXTOC 0x112e
struct rgds
{
struct rgds {
UWORD r_spc;
UWORD r_navc;
UWORD r_bps;
UWORD r_nc;
};
struct remote_fileattrib
{
struct remote_fileattrib {
UWORD rfa_file; /* File Attributes */
union
{
union {
ULONG rfa_filesize; /* file size */
struct
{
struct {
UWORD rfa_filesize_lo; /* DI Low */
UWORD rfa_filesize_hi; /* BX High */
}
_split_rfa_fz;
}
rfa_fz_union;
} _split_rfa_fz;
} rfa_fz_union;
UWORD rfa_time;
UWORD rfa_date;
};

View File

@ -281,7 +281,6 @@
access to often used and mandatoryly present tables. */
#define NLS_REORDER_POINTERS
/*
* How the kernel and NLSFUNC communicate with each other
*/
@ -336,8 +335,7 @@
/*
* This is the data in the exact order returned by DOS-65-01
*/
struct nlsExtCntryInfo
{
struct nlsExtCntryInfo {
UBYTE subfct; /* always 1 */
WORD size; /* size of this structure
without this WORD itself */
@ -393,7 +391,6 @@ struct nlsPointer { /* Information of DOS-65-0X is addressed
0xA0, 0xA1,& 0xA2 */
};
struct nlsPackage { /* the contents of one chain item of the
list of NLS packages */
struct nlsPackage FAR *nxt; /* next item in chain */
@ -433,11 +430,9 @@ nlsChBuf(256);
struct nlsFnamTerm {
WORD size; /* size of this structure */
BYTE dummy1;
char firstCh,
lastCh; /* first, last permittable character */
char firstCh, lastCh; /* first, last permittable character */
BYTE dummy2;
char firstExcl,
lastExcl; /* first, last excluded character */
char firstExcl, lastExcl; /* first, last excluded character */
BYTE dummy3;
BYTE numSep; /* number of file name separators */
char separators[1]; /* grows dynamically */
@ -543,7 +538,7 @@ struct nlsCSys_numEntries { /* helper structure for "number of entries" */
/* Actually, this structure is never really used */
struct nlsCSys_fileHeader { /* S0: primary structure */
unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1];
/* decrement by 1 to cut off \0 from IDString -- ska*/
/* decrement by 1 to cut off \0 from IDString -- ska */
};
struct nlsCSys_completeFileHeader { /* as S0, but full 128 bytes */
@ -551,6 +546,5 @@ struct nlsCSys_completeFileHeader { /* as S0, but full 128 bytes */
unsigned char csys_padbytes[128 - (sizeof(CSYS_FD_IDSTRING) - 1)];
};
/* standard alignment */
#include <algndflt.h>

View File

@ -51,27 +51,23 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *pcb_hRcsId = "$Id$";
static BYTE *pcb_hRcsId =
"$Id$";
#endif
#endif
/* Force one-byte alignment for all the internal structures, see above */
#include <algnbyte.h>
/* */
/* interrupt handler structure definition */
/* */
typedef union
{
typedef union {
UWORD x; /* access mode for ax, bx, etc. */
struct
{
struct {
UBYTE l; /* access mode for al, bl, etc. */
UBYTE h; /* access mode for ah, bh, etc. */
}
b;
}
xreg;
} b;
} xreg;
/* The structure assumes that:
1) An interrupt was invoked, &
@ -79,22 +75,11 @@ xreg;
Furthermore, the PUSH$ALL macro must push ES first and AX last.
-- 2000/03/22 ska*/
/* maps MS-DOS unique stacking order */
typedef struct _iregss
{
xreg a,
b,
c,
d;
UWORD si,
di,
bp,
ds,
es;
UWORD ip,
cs,
flags;
}
iregs;
typedef struct _iregss {
xreg a, b, c, d;
UWORD si, di, bp, ds, es;
UWORD ip, cs, flags;
} iregs;
/* Registers directly passed to syscall;
must be the same order as iregs!
@ -104,16 +89,12 @@ iregs;
UWORD si, UWORD di, UWORD bp, UWORD ds, UWORD es, \
UWORD ip, UWORD cs, UWORD flags
/* Process control block for task switching */
typedef struct
{
typedef struct {
UWORD pc_ss;
UWORD pc_sp;
iregs pc_regs;
}
pcb;
} pcb;
/* Note: The following figure is not made by myself and I assume that
the order of "ES" through "AX" are misinterpreted?! -- 2000/03/22 ska*/

View File

@ -30,7 +30,8 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static char *portab_hRcsId = "$Id$";
static char *portab_hRcsId =
"$Id$";
#endif
#endif
@ -57,84 +58,71 @@ static char *portab_hRcsId = "$Id$";
/* */
/****************************************************************/
/* commandline overflow - removing -DI86 TE*/
/* commandline overflow - removing -DI86 TE */
#if defined(__TURBOC__)
#define I86
#define CDECL cdecl
void __int__(int);
#define I86
#define CDECL cdecl
void __int__(int);
#elif defined (_MSC_VER)
#define I86
#define CDECL _cdecl
#define __int__(intno) asm int intno;
#define I86
#define CDECL _cdecl
#define __int__(intno) asm int intno;
#if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE*/
#define I386
#endif
#if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE */
#define I386
#endif
#elif defined(__WATCOMC__) /* don't know a better way */
#define I86
#define __int__(intno) asm int intno;
#define asm __asm
#define far __far
#define CDECL __cdecl
#define I86
#define __int__(intno) asm int intno;
#define asm __asm
#define far __far
#define CDECL __cdecl
#if _M_IX86 >= 300
#define I386
#endif
#if _M_IX86 >= 300
#define I386
#endif
#elif defined (_MYMC68K_COMILER_)
#define MC68K
#define MC68K
#else
anyone knows a _portable_ way to create nice errors??
at least this causes the compiler not to compile :-)
anyone knows a _portable_ way to create nice errors ? ?
at least this causes the compiler not to compile : -)
#endif
/* functions, that are shared between C and ASM _must_
have a certain calling standard. These are declared
as 'ASMCFUNC', and is (and will be ?-) cdecl */
#define ASMCFUNC cdecl
#ifdef MC68K
#define far /* No far type */
#define interrupt /* No interrupt type */
#define VOID void
#define FAR /* linear architecture */
#define NEAR /* " " */
#define INRPT interrupt
#define CONST
#define REG register
#define API int /* linear architecture */
#define NONNATIVE
#define PARASIZE 4096 /* "paragraph" size */
#endif
#ifdef I86
#define VOID void
#define FAR far /* segment architecture */
#define NEAR near /* " " */
#define INRPT interrupt
#define CONST const
#define REG register
#define API int far pascal /* segment architecture */
#define NATIVE
#define PARASIZE 16 /* "paragraph" size */
#endif
/* */
/* Boolean type & definitions of TRUE and FALSE boolean values */
/* */
@ -188,7 +176,6 @@ typedef unsigned short UNICODE;
#define STATIC /* local calls inside module */
#ifdef UNIX
typedef char FAR *ADDRESS;
#else
@ -223,13 +210,13 @@ typedef signed long LONG;
*/
#if defined(__TURBOC__)
#define UNREFERENCED_PARAMETER(x) if (x);
#define UNREFERENCED_PARAMETER(x) if (x);
#else
#define UNREFERENCED_PARAMETER(x) x;
#define UNREFERENCED_PARAMETER(x) x;
#endif
#ifdef I86 /* commandline overflow - removing /DPROTO TE*/
#define PROTO
#ifdef I86 /* commandline overflow - removing /DPROTO TE */
#define PROTO
#endif
/*

View File

@ -30,7 +30,8 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *process_hRcsId = "$Id$";
static BYTE *process_hRcsId =
"$Id$";
#endif
#endif
@ -40,36 +41,27 @@ static BYTE *process_hRcsId = "$Id$";
#define P_NOWAIT 1 /* both concurrent -- not implemented */
#define P_OVERLAY 2 /* child replaces parent, parent no longer exists */
typedef struct
{
union
{
struct
{
typedef struct {
union {
struct {
UWORD load_seg;
UWORD reloc;
}
_load;
struct
{
} _load;
struct {
UWORD env_seg;
CommandTail FAR *cmd_line;
fcb FAR *fcb_1;
fcb FAR *fcb_2;
BYTE FAR *stack;
BYTE FAR *start_addr;
}
_exec;
}
ldata;
}
exec_blk;
} _exec;
} ldata;
} exec_blk;
#define exec ldata._exec
#define load ldata._load
typedef struct
{
typedef struct {
UWORD ps_exit; /* 00 CP/M-like exit poimt */
UWORD ps_size; /* 02 memory size in paragraphs */
BYTE ps_fill1; /* 04 single char fill */
@ -77,7 +69,7 @@ typedef struct
/* CP/M-like entry point */
UBYTE ps_farcall; /* 05 far call opcode */
VOID(FAR * ps_reentry) (); /* 06 re-entry point */
VOID(interrupt FAR * ps_isv22) (),/* 0a terminate address */
VOID(interrupt FAR * ps_isv22) (), /* 0a terminate address */
(interrupt FAR * ps_isv23) (), /* 0e break address */
(interrupt FAR * ps_isv24) (); /* 12 critical error address */
UWORD ps_parent; /* 16 parent psp segment */
@ -91,37 +83,23 @@ typedef struct
BYTE ps_fill2[16];
UBYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */
BYTE ps_fill3[9];
union
{
struct
{
fcb
_ps_fcb1; /* first command line argument */
}
_u1;
struct
{
BYTE
fill4[16];
fcb
_ps_fcb2; /* second command line argument */
}
_u2;
struct
{
union {
struct {
fcb _ps_fcb1; /* first command line argument */
} _u1;
struct {
BYTE fill4[16];
fcb _ps_fcb2; /* second command line argument */
} _u2;
struct {
BYTE fill5[36];
struct
{
struct {
BYTE _ps_cmd_count;
BYTE _ps_cmd[127]; /* command tail */
}
_u4;
}
_u3;
}
_u;
}
psp;
} _u4;
} _u3;
} _u;
} psp;
#define ps_fcb1 _u._u1._ps_fcb1
#define ps_fcb2 _u._u2._ps_fcb2

View File

@ -29,16 +29,15 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *sft_hRcsId = "$Id$";
static BYTE *sft_hRcsId =
"$Id$";
#endif
#endif
#define SFTMAX 128
/* Handle Definition entry */
typedef struct
{
typedef struct {
WORD sft_count; /* 00 - reference count */
WORD sft_mode; /* 02 - open mode - see below */
BYTE sft_attrib; /* 04 - file attribute - dir style */
@ -46,24 +45,17 @@ typedef struct
union /* 05 */
{
WORD _sft_flags;
struct
{
struct {
BYTE _sft_flags_lo;
BYTE _sft_flags_hi;
}
_split_sft_flags;
}
sft_flags_union;
} _split_sft_flags;
} sft_flags_union;
union /* 07 */
{
struct dpb FAR *
_sft_dcb; /* The device control block */
struct dhdr FAR *
_sft_dev; /* device driver for char dev */
}
sft_dcb_or_dev;
struct dpb FAR *_sft_dcb; /* The device control block */
struct dhdr FAR *_sft_dev; /* device driver for char dev */
} sft_dcb_or_dev;
WORD sft_stclust; /* 0b - Starting cluster */
time sft_time; /* 0d - File time */
date sft_date; /* 0f - File date */
@ -74,36 +66,30 @@ typedef struct
WORD sft_dirdlust; /* 1d - Sector containing cluster */
BYTE sft_diridx; /* 1f - directory index */
BYTE sft_name[11]; /* 20 - dir style file name */
BYTE FAR *
sft_bshare; /* 2b - backward link of file sharing sft */
BYTE FAR *sft_bshare; /* 2b - backward link of file sharing sft */
WORD sft_mach; /* 2f - machine number - network apps */
WORD sft_psp; /* 31 - owner psp */
WORD sft_shroff; /* 33 - Sharing offset */
WORD sft_status; /* 35 - this sft status */
BYTE FAR * sft_ifsptr; /* 37 - pointer to IFS driver for file, 0000000h if native DOS */
}
sft;
BYTE FAR *sft_ifsptr; /* 37 - pointer to IFS driver for file, 0000000h if native DOS */
} sft;
/* SFT Table header definition */
typedef struct _sftheader
{
typedef struct _sftheader {
struct _sfttbl FAR * /* link to next table in list */
sftt_next;
WORD sftt_count; /* # of handle definition */
/* entries, this table */
}
sftheader;
} sftheader;
/* System File Definition List */
typedef struct _sfttbl
{
typedef struct _sfttbl {
struct _sfttbl FAR * /* link to next table in list */
sftt_next;
WORD sftt_count; /* # of handle definition */
/* entries, this table */
sft sftt_table[SFTMAX]; /* The array of sft for block */
}
sfttbl;
} sfttbl;
/* defines for sft use */
#define SFT_MASK 0x0060 /* splits device data */
@ -153,7 +139,6 @@ sfttbl;
#define sft_flags_hi sft_flags_union._split_sft_flags._sft_flags_hi
#define sft_flags_lo sft_flags_union._split_sft_flags._sft_flags_lo
/*
* Log: sft.h,v
*

View File

@ -30,21 +30,19 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *tail_hRcsId = "$Id$";
static BYTE *tail_hRcsId =
"$Id$";
#endif
#endif
#ifndef LINESIZE
#define LINESIZE 127
#endif
typedef struct
{
typedef struct {
UBYTE ctCount; /* number of bytes returned */
BYTE ctBuffer[LINESIZE]; /* the buffer itself */
}
CommandTail;
} CommandTail;
/*
* Log: tail.h,v

View File

@ -34,7 +34,8 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *time_hRcsId = "$Id$";
static BYTE *time_hRcsId =
"$Id$";
#endif
#endif
@ -87,4 +88,3 @@ typedef UWORD time;
* Rev 1.0 02 Jul 1995 10:39:56 patv
* Initial revision.
*/

View File

@ -28,7 +28,8 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *date_hRcsId = "$Id$";
static BYTE *date_hRcsId =
"$Id$";
#endif
#endif
@ -45,5 +46,5 @@ static BYTE *date_hRcsId = "$Id$";
#define REVISION_SEQ 25
#define BUILD "2025"
#define SUB_BUILD "b"
#define KERNEL_VERSION_STRING "1.1.25b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/
#define KERNEL_BUILD_STRING "2025b" /*#BUILD SUB_BUILD*/
#define KERNEL_VERSION_STRING "1.1.25b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */
#define KERNEL_BUILD_STRING "2025b" /*#BUILD SUB_BUILD */

View File

@ -8,18 +8,17 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *XStructs_hRcsId = "$Id$";
static BYTE *XStructs_hRcsId =
"$Id$";
#endif
#endif
struct xdpbdata
{
struct xdpbdata {
UWORD xdd_dpbsize;
struct dpb xdd_dpb;
};
struct xfreespace
{
struct xfreespace {
UWORD xfs_datasize; /* size of this structure */
union {
UWORD requested; /* requested structure version */
@ -36,8 +35,7 @@ struct xfreespace
UBYTE xfs_reserved[8];
};
struct xdpbforformat
{
struct xdpbforformat {
UWORD xdff_datasize; /* size of this structure */
union {
UWORD requested; /* requested structure version */

View File

@ -32,7 +32,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *blockioRcsId = "$Id$";
static BYTE *blockioRcsId =
"$Id$";
#endif
/************************************************************************/
@ -42,7 +43,6 @@ static BYTE *blockioRcsId = "$Id$";
/************************************************************************/
/* #define DISPLAY_GETBLOCK */
/* */
/* Initialize the buffer structure */
/* */
@ -75,7 +75,7 @@ VOID FAR reloc_call_init_buffers(void)
*/
/* Extract the block number from a buffer structure. */
#if 0 /*TE*/
ULONG getblkno(struct buffer FAR * bp)
ULONG getblkno(struct buffer FAR * bp)
{
if (bp->b_blkno == 0xffffu)
return bp->b_huge_blkno;
@ -89,7 +89,7 @@ ULONG getblkno(struct buffer FAR * bp)
/* Set the block number of a buffer structure. (The caller should */
/* set the unit number before calling this function.) */
#if 0 /*TE*/
VOID setblkno(struct buffer FAR * bp, ULONG blkno)
VOID setblkno(struct buffer FAR * bp, ULONG blkno)
{
if (blkno >= 0xffffu)
{
@ -126,8 +126,7 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno)
*/
BOOL searchblock(ULONG blkno, COUNT dsk,
struct buffer FAR ** pBuffp)
BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR ** pBuffp)
{
int fat_count = 0;
struct buffer FAR *bp;
@ -135,17 +134,14 @@ BOOL searchblock(ULONG blkno, COUNT dsk,
struct buffer FAR *lastNonFat = NULL;
struct buffer FAR *uncacheBuf = NULL;
#ifdef DISPLAY_GETBLOCK
printf("[searchblock %d, blk %ld, buf ", dsk, blkno);
#endif
/* Search through buffers to see if the required block */
/* is already in a buffer */
for (bp = firstbuf; bp != NULL;lbp = bp, bp = bp->b_next)
for (bp = firstbuf; bp != NULL; lbp = bp, bp = bp->b_next)
{
if ((getblkno(bp) == blkno) &&
(bp->b_flag & BFR_VALID) && (bp->b_unit == dsk))
@ -167,7 +163,6 @@ BOOL searchblock(ULONG blkno, COUNT dsk,
if (bp->b_flag & BFR_UNCACHE)
uncacheBuf = bp;
if (bp->b_flag & BFR_FAT)
fat_count++;
else
@ -185,7 +180,7 @@ BOOL searchblock(ULONG blkno, COUNT dsk,
}
else
{
if (lbp ->b_flag & BFR_FAT && fat_count < 3 && lastNonFat)
if (lbp->b_flag & BFR_FAT && fat_count < 3 && lastNonFat)
{
lbp = lastNonFat;
}
@ -199,8 +194,6 @@ BOOL searchblock(ULONG blkno, COUNT dsk,
printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp));
#endif
if (lbp != firstbuf) /* move to front */
{
for (bp = firstbuf; bp->b_next != lbp; bp = bp->b_next)
@ -233,7 +226,6 @@ BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk)
return FALSE;
}
void dumpBufferCache(void)
{
struct buffer FAR *bp;
@ -242,16 +234,15 @@ void dumpBufferCache(void)
/* Search through buffers to see if the required block */
/* is already in a buffer */
for (bp = firstbuf; bp != NULL;bp = bp->b_next)
for (bp = firstbuf; bp != NULL; bp = bp->b_next)
{
printf("%8lx %02x ",getblkno(bp),bp->b_flag);
printf("%8lx %02x ", getblkno(bp), bp->b_flag);
if (++printed % 6 == 0)
printf("\n");
}
printf("\n");
}
/* */
/* Return the address of a buffer structure containing the */
/* requested block. */
@ -265,8 +256,6 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
{
struct buffer FAR *bp;
/* Search through buffers to see if the required block */
/* is already in a buffer */
@ -278,7 +267,6 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
/* The block we need is not in a buffer, we must make a buffer */
/* available, and fill it with the desired block */
/* take the buffer that lbp points to and flush it, then read new block. */
if (!flush1(bp))
return NULL;
@ -302,7 +290,7 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
exactly the same as getblock(), but the data will be completely
overwritten. so there is no need to read from disk first
*/
struct buffer FAR * getblockOver(ULONG blkno, COUNT dsk)
struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk)
{
struct buffer FAR *bp;
@ -331,6 +319,7 @@ struct buffer FAR * getblockOver(ULONG blkno, COUNT dsk)
return NULL;
}
}
/* */
/* Mark all buffers for a disk as not valid */
/* */
@ -380,8 +369,7 @@ BOOL flush1(struct buffer FAR * bp)
if ((bp->b_flag & BFR_VALID) && (bp->b_flag & BFR_DIRTY))
{
result = dskxfer(bp->b_unit, getblkno(bp),
(VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */
result = dskxfer(bp->b_unit, getblkno(bp), (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */
if (bp->b_flag & BFR_FAT)
{
int i = bp->b_copies;
@ -390,8 +378,7 @@ BOOL flush1(struct buffer FAR * bp)
while (--i > 0)
{
blkno += bp->b_offset;
result = dskxfer(bp->b_unit, blkno,
(VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */
result = dskxfer(bp->b_unit, blkno, (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */
}
}
}
@ -428,7 +415,6 @@ BOOL flush(void)
return (ok);
}
/************************************************************************/
/* */
/* Device Driver Interface Functions */
@ -439,15 +425,15 @@ BOOL flush(void)
/* */
/* Changed to UWORD 9/4/00 BER */
UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode)
UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks,
COUNT mode)
/* End of change */
{
/* REG struct dpb *dpbp = &blk_devices[dsk]; */
REG struct dpb FAR *dpbp = CDSp->cds_table[dsk].cdsDpb;
if ((UCOUNT)dsk >= lastdrive )
if ((UCOUNT) dsk >= lastdrive)
{
return 0x0201; /* illegal command */
}
@ -461,7 +447,8 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod
if (KeyboardShiftState() & 0x01)
{
printf("dskxfer:%s %x - %lx %u\n", mode == DSKWRITE ? "write" : "read", dsk, blkno, numblocks);
printf("dskxfer:%s %x - %lx %u\n", mode == DSKWRITE ? "write" : "read",
dsk, blkno, numblocks);
if ((KeyboardShiftState() & 0x03) == 3)
dumpBufferCache();
}
@ -472,14 +459,23 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod
IoReqHdr.r_length = sizeof(request);
IoReqHdr.r_unit = dpbp->dpb_subunit;
switch(mode)
switch (mode)
{
case DSKWRITE : if (verify_ena) { IoReqHdr.r_command = C_OUTVFY; break; }
case DSKWRITE:
if (verify_ena)
{
IoReqHdr.r_command = C_OUTVFY;
break;
}
/* else fall through */
case DSKWRITEINT26: IoReqHdr.r_command = C_OUTPUT; break;
case DSKWRITEINT26:
IoReqHdr.r_command = C_OUTPUT;
break;
case DSKREADINT25:
case DSKREAD : IoReqHdr.r_command = C_INPUT; break;
case DSKREAD:
IoReqHdr.r_command = C_INPUT;
break;
default:
return 0x0100; /* illegal command */
}
@ -513,9 +509,6 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod
return (IoReqHdr.r_status);
*/
/* Skip the abort, retry, fail code...it needs fixed...BER */
/* End of change */

View File

@ -33,7 +33,8 @@
extern void ASMCFUNC spawn_int23(void);
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
#define CB_FLG *(UBYTE FAR*)MK_FP(0x40, 0x71)
@ -81,4 +82,3 @@ void handle_break(void)
* Steffen contributed.
*
*/

View File

@ -31,7 +31,8 @@
#include "portab.h"
#ifdef VERSION_STRINGS
static BYTE *charioRcsId = "$Id$";
static BYTE *charioRcsId =
"$Id$";
#endif
#include "globals.h"
@ -67,16 +68,18 @@ struct dhdr FAR *finddev(UWORD attr_mask)
VOID _cso(COUNT c)
{
if (syscon->dh_attr & ATTR_FASTCON) {
#if defined(__TURBOC__)
if (syscon->dh_attr & ATTR_FASTCON)
{
#if defined(__TURBOC__)
_AL = c;
__int__(0x29);
#else
asm {
#else
asm
{
mov al, byte ptr c;
int 0x29;
}
#endif
#endif
return;
}
CharReqHdr.r_length = sizeof(request);
@ -95,7 +98,7 @@ VOID cso(COUNT c)
con_hold();
if (PrinterEcho)
DosWrite(STDPRN, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal);
DosWrite(STDPRN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal);
switch (c)
{
@ -106,20 +109,24 @@ VOID cso(COUNT c)
case BELL:
break;
case BS:
if (scr_pos > 0) scr_pos--;
if (scr_pos > 0)
scr_pos--;
break;
case HT:
do _cso(' '); while ((++scr_pos) & 7);
do
_cso(' ');
while ((++scr_pos) & 7);
break;
default:
scr_pos++;
}
if (c != HT) _cso(c);
if (c != HT)
_cso(c);
}
VOID sto(COUNT c)
{
DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal);
DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal);
}
VOID mod_cso(REG UCOUNT c)
@ -173,7 +180,7 @@ COUNT con_read(void)
CharReqHdr.r_length = sizeof(request);
CharReqHdr.r_command = C_INPUT;
CharReqHdr.r_count = 1;
CharReqHdr.r_trans = (BYTE FAR *)&c;
CharReqHdr.r_trans = (BYTE FAR *) & c;
CharReqHdr.r_status = 0;
execrh((request FAR *) & CharReqHdr, syscon);
if (CharReqHdr.r_status & S_ERROR)
@ -186,7 +193,7 @@ COUNT con_read(void)
VOID con_hold(void)
{
UBYTE c = ndread();
if(c == CTL_S)
if (c == CTL_S)
{
con_read();
Do_DosIdle_loop();
@ -210,8 +217,9 @@ UCOUNT _sti(BOOL check_break)
Do_DosIdle_loop();
if (check_break)
con_hold();
while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal, TRUE)
!= 1) ;
while (GenericRead
(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal,
TRUE) != 1) ;
return c;
}
@ -285,10 +293,8 @@ static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp)
/* return number of characters before EOF if there is one, else just the total */
UCOUNT sti_0a(keyboard FAR * kp)
{
REG UWORD c,
cu_pos = scr_pos;
UWORD
virt_pos = scr_pos;
REG UWORD c, cu_pos = scr_pos;
UWORD virt_pos = scr_pos;
UWORD init_count = 0; /* kp->kb_count; */
BOOL eof = FALSE;
#ifndef NOSPCL
@ -483,4 +489,3 @@ UCOUNT sti(keyboard * kp)
* Initial revision.
*
*/

View File

@ -33,13 +33,14 @@
#include "dyndata.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
#ifdef DEBUG
#define DebugPrintf(x) printf x
#define DebugPrintf(x) printf x
#else
#define DebugPrintf(x)
#define DebugPrintf(x)
#endif
#ifdef KDB
@ -63,38 +64,32 @@ extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes
extern UBYTE DOSFAR lastdrive, DOSFAR nblkdev, DOSFAR mem_access_mode,
DOSFAR uppermem_link;
extern struct dhdr
DOSTEXTFAR blk_dev, /* Block device (Disk) driver */
DOSTEXTFAR blk_dev, /* Block device (Disk) driver */
DOSFAR nul_dev;
extern struct buffer FAR * DOSFAR firstbuf; /* head of buffers linked list */
extern struct buffer FAR *DOSFAR firstbuf; /* head of buffers linked list */
extern struct dpb FAR * DOSFAR DPBp;
extern struct dpb FAR *DOSFAR DPBp;
/* First drive Parameter Block */
extern cdstbl FAR * DOSFAR CDSp;
extern cdstbl FAR *DOSFAR CDSp;
/* Current Directory Structure */
extern sfttbl FAR * DOSFAR sfthead;
extern sfttbl FAR *DOSFAR sfthead;
/* System File Table head */
extern sfttbl FAR * DOSFAR FCBp;
extern sfttbl FAR *DOSFAR FCBp;
extern BYTE DOSFAR VgaSet,
DOSFAR _HMATextAvailable, /* first byte of available CODE area */
extern BYTE DOSFAR VgaSet, DOSFAR _HMATextAvailable, /* first byte of available CODE area */
FAR _HMATextStart[], /* first byte of HMAable CODE area */
FAR _HMATextEnd[],
DOSFAR break_ena, /* break enabled flag */
FAR _HMATextEnd[], DOSFAR break_ena, /* break enabled flag */
DOSFAR os_major, /* major version number */
DOSFAR os_minor, /* minor version number */
DOSFAR switchar,
DOSFAR _InitTextStart, /* first available byte of ram */
DOSFAR switchar, DOSFAR _InitTextStart, /* first available byte of ram */
DOSFAR ReturnAnyDosVersionExpected;
extern UWORD DOSFAR ram_top, /* How much ram in Kbytes */
DOSFAR UMB_top,
DOSFAR umb_start,
DOSFAR uppermem_root,
DOSFAR LoL_nbuffers;
struct config Config
=
{
DOSFAR UMB_top,
DOSFAR umb_start, DOSFAR uppermem_root, DOSFAR LoL_nbuffers;
struct config Config = {
NUMBUFF,
NFILES,
NFCBS,
@ -105,14 +100,13 @@ struct config Config
NSTACKS,
128
/* COUNTRY= is initialized within DoConfig() */
,0 /* country ID */
,0 /* codepage */
,"" /* filename */
,0 /* amount required memory */
,0 /* pointer to loaded data */
,0 /* strategy for command.com is low by default */
}
;
, 0 /* country ID */
, 0 /* codepage */
, "" /* filename */
, 0 /* amount required memory */
, 0 /* pointer to loaded data */
, 0 /* strategy for command.com is low by default */
};
/* MSC places uninitialized data into COMDEF records,
that end up in DATA segment. this can't be tolerated
in INIT code.
@ -124,16 +118,14 @@ BYTE FAR *lpTop = 0;
BYTE FAR *lpOldTop = 0;
STATIC COUNT nCfgLine = 0;
STATIC COUNT nPass = 0;
COUNT UmbState = 0;
STATIC BYTE szLine[256] = {0};
STATIC BYTE szBuf[256] = {0};
COUNT UmbState = 0;
STATIC BYTE szLine[256] = { 0 };
STATIC BYTE szBuf[256] = { 0 };
BYTE singleStep = FALSE; /* F8 processing */
BYTE SkipAllConfig = FALSE; /* F5 processing */
BYTE askThisSingleCommand = FALSE; /* ?device= device?= */
INIT VOID zumcb_init(UCOUNT seg, UWORD size);
INIT VOID mumcb_init(UCOUNT seg, UWORD size);
@ -162,7 +154,7 @@ INIT struct dhdr FAR *linkdev(struct dhdr FAR * dhp);
INIT UWORD initdev(struct dhdr FAR * dhp, BYTE FAR * cmdTail);
INIT int SkipLine(char *pLine);
INIT char *stristr(char *s1, char *s2);
INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s);
INIT COUNT strcasecmp(REG BYTE * d, REG BYTE * s);
extern void HMAconfig(int finalize);
VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */
@ -176,15 +168,13 @@ INIT STATIC VOID FAR *AlignParagraph(VOID FAR * lpPtr);
INIT struct table *LookUp(struct table *p, BYTE * token);
struct table
{
struct table {
BYTE *entry;
BYTE pass;
VOID(*func) (BYTE * pLine);
};
STATIC struct table commands[] =
{
STATIC struct table commands[] = {
{"BREAK", 1, CfgBreak},
{"BUFFERS", 1, Config_Buffers},
{"COMMAND", 1, InitPgm},
@ -223,15 +213,16 @@ BYTE HMAState = 0;
#define HMA_DONE 2 /* Moved kernel to HMA */
#define HMA_LOW 3 /* Definitely LOW */
void FAR * ConfigAlloc(COUNT bytes)
void FAR *ConfigAlloc(COUNT bytes)
{
VOID FAR *p;
p = HMAalloc(bytes);
if (p == NULL) p = KernelAlloc(bytes);
if (p == NULL)
p = KernelAlloc(bytes);
/* printf("ConfigAlloc %d at %p\n", bytes, p);*/
/* printf("ConfigAlloc %d at %p\n", bytes, p); */
return p;
}
@ -259,8 +250,6 @@ INIT void PreConfig(void)
/* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */
/* DebugPrintf(("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch));*/
/* buffers = (struct buffer FAR *)
KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */
#ifdef DEBUG
@ -272,43 +261,41 @@ INIT void PreConfig(void)
KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/
f_nodes = (f_node_ptr)
DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node));
DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node));
f_nodes_cnt = Config.cfgFiles;
/* sfthead = (sfttbl FAR *)&basesft; */
/* FCBp = (sfttbl FAR *)&FcbSft; */
/* FCBp = (sfttbl FAR *)
KernelAlloc(sizeof(sftheader)
+ Config.cfgFiles * sizeof(sft));*/
+ Config.cfgFiles * sizeof(sft)); */
lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f);
lpBase = AlignParagraph((BYTE FAR *) DynLast() + 0x0f);
config_init_buffers( Config.cfgBuffers);
config_init_buffers(Config.cfgBuffers);
sfthead->sftt_next = (sfttbl FAR *)
KernelAlloc(sizeof(sftheader)
+ (Config.cfgFiles-5) * sizeof(sft));
KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft));
sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1;
sfthead->sftt_next->sftt_count = Config.cfgFiles-5;
sfthead->sftt_next->sftt_count = Config.cfgFiles - 5;
CDSp = (cdstbl FAR *)
KernelAlloc(0x58 * lastdrive);
CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive);
DPBp = (struct dpb FAR *)
KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb));
KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb));
#ifdef DEBUG
printf("Preliminary:\n f_node 0x%x",f_nodes);
printf("Preliminary:\n f_node 0x%x", f_nodes);
/* printf(" FCB table 0x%p\n",FCBp);*/
printf(" sft table 0x%p\n",sfthead->sftt_next);
printf(" CDS table 0x%p\n",CDSp);
printf(" DPB table 0x%p\n",DPBp);
printf(" sft table 0x%p\n", sfthead->sftt_next);
printf(" CDS table 0x%p\n", CDSp);
printf(" DPB table 0x%p\n", DPBp);
#endif
/* Done. Now initialize the MCB structure */
/* This next line is 8086 and 80x86 real mode specific */
#ifdef DEBUG
printf("Preliminary allocation completed: top at 0x%p\n",lpBase);
printf("Preliminary allocation completed: top at 0x%p\n", lpBase);
#endif
#ifdef KDB
@ -319,7 +306,7 @@ INIT void PreConfig(void)
#endif
/* We expect ram_top as Kbytes, so convert to paragraphs */
mcb_init(first_mcb, ram_top*64 - first_mcb - 1);
mcb_init(first_mcb, ram_top * 64 - first_mcb - 1);
nPass = 1;
}
@ -329,24 +316,22 @@ INIT void PostConfig(void)
{
/* close all (device) files */
/* Set pass number */
nPass = 2;
/* compute lastdrive ... */
lastdrive = Config.cfgLastdrive;
if (lastdrive < nblkdev )
lastdrive = nblkdev ;
if (lastdrive < nblkdev)
lastdrive = nblkdev;
/* initialize NEAR allocated things */
/* Initialize the file table */
DynFree(f_nodes);
f_nodes = (f_node_ptr)
DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node));
DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node));
f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */
/* Initialize the base memory pointers from last time. */
/*
if the kernel could be moved to HMA, everything behind the dynamic
@ -355,10 +340,9 @@ INIT void PostConfig(void)
and allocation starts after the kernel.
*/
lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f);
DebugPrintf(("starting FAR allocations at %p\n",lpBase));
lpBase = AlignParagraph((BYTE FAR *) DynLast() + 0x0f);
DebugPrintf(("starting FAR allocations at %p\n", lpBase));
/* Begin by initializing our system buffers */
/* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */
@ -366,83 +350,83 @@ INIT void PostConfig(void)
/* printf("DMA scratchpad allocated at 0x%p\n", dma_scratch); */
#endif
config_init_buffers(Config.cfgBuffers);
/* sfthead = (sfttbl FAR *)&basesft; */
/* FCBp = (sfttbl FAR *)&FcbSft; */
/* FCBp = (sfttbl FAR *)
KernelAlloc(sizeof(sftheader)
+ Config.cfgFiles * sizeof(sft));*/
+ Config.cfgFiles * sizeof(sft)); */
sfthead->sftt_next = (sfttbl FAR *)
KernelAlloc(sizeof(sftheader)
+ (Config.cfgFiles-5) * sizeof(sft));
KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft));
sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1;
sfthead->sftt_next->sftt_count = Config.cfgFiles-5;
sfthead->sftt_next->sftt_count = Config.cfgFiles - 5;
CDSp = (cdstbl FAR *)
KernelAlloc(0x58 * lastdrive);
CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive);
DPBp = (struct dpb FAR *)
KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb));
KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb));
#ifdef DEBUG
printf("Final: \n f_node 0x%x\n",f_nodes);
printf("Final: \n f_node 0x%x\n", f_nodes);
/* printf(" FCB table 0x%p\n",FCBp);*/
printf(" sft table 0x%p\n",sfthead->sftt_next);
printf(" CDS table 0x%p\n",CDSp);
printf(" DPB table 0x%p\n",DPBp);
printf(" sft table 0x%p\n", sfthead->sftt_next);
printf(" CDS table 0x%p\n", CDSp);
printf(" DPB table 0x%p\n", DPBp);
#endif
if (Config.cfgStacks)
{
VOID FAR *stackBase = KernelAlloc(Config.cfgStacks * Config.cfgStackSize);
VOID FAR *stackBase =
KernelAlloc(Config.cfgStacks * Config.cfgStackSize);
init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize);
DebugPrintf(("Stacks allocated at %p\n",stackBase));
DebugPrintf(("Stacks allocated at %p\n", stackBase));
}
DebugPrintf(("Allocation completed: top at 0x%p\n",lpBase));
DebugPrintf(("Allocation completed: top at 0x%p\n", lpBase));
}
/* This code must be executed after device drivers has been loaded */
INIT VOID configDone(VOID)
{
if ( HMAState != HMA_DONE )
if (HMAState != HMA_DONE)
{
lpBase = AlignParagraph(lpBase);
DebugPrintf(("HMA not available, moving text to %x\n",FP_SEG(lpBase)));
DebugPrintf(("HMA not available, moving text to %x\n",
FP_SEG(lpBase)));
MoveKernel(FP_SEG(lpBase));
lpBase = AlignParagraph((BYTE FAR *)lpBase + HMAFree + 0x0f);
lpBase = AlignParagraph((BYTE FAR *) lpBase + HMAFree + 0x0f);
DebugPrintf(("kernel is low, start alloc at %p",lpBase));
DebugPrintf(("kernel is low, start alloc at %p", lpBase));
/* final buffer processing, now upwards */
HMAState = HMA_LOW;
config_init_buffers( Config.cfgBuffers);
config_init_buffers(Config.cfgBuffers);
}
if (lastdrive < nblkdev) {
if (lastdrive < nblkdev)
{
DebugPrintf(("lastdrive %c too small upping it to: %c\n", lastdrive + 'A', nblkdev + 'A' -1));
DebugPrintf(("lastdrive %c too small upping it to: %c\n",
lastdrive + 'A', nblkdev + 'A' - 1));
lastdrive = nblkdev;
CDSp = (cdstbl FAR *)
KernelAlloc(0x58 * lastdrive);
CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive);
}
first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4);
/* We expect ram_top as Kbytes, so convert to paragraphs */
mcb_init(first_mcb, ram_top*64 - first_mcb - 1);
mcb_init(first_mcb, ram_top * 64 - first_mcb - 1);
if(UmbState == 1)
if (UmbState == 1)
{
mumcb_init(ram_top*64 - 1, umb_start - 64*ram_top);
mumcb_init(ram_top * 64 - 1, umb_start - 64 * ram_top);
/* Check if any devices were loaded in umb */
if(umb_start != FP_SEG(upBase) ){
if (umb_start != FP_SEG(upBase))
{
/* make last block normal with SC for the devices */
UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4);
@ -450,7 +434,7 @@ INIT VOID configDone(VOID)
mumcb_init(uppermem_root, umr_new - uppermem_root - 1);
uppermem_root = umr_new;
zumcb_init(uppermem_root, (umb_start + UMB_top ) - uppermem_root - 1);
zumcb_init(uppermem_root, (umb_start + UMB_top) - uppermem_root - 1);
upBase += 16;
}
@ -472,24 +456,24 @@ INIT VOID configDone(VOID)
umbz_root = uppermem_root;
if(UMB_get_largest(&umb_seg, &umb_size)){
if (UMB_get_largest(&umb_seg, &umb_size))
{
mcb_init(umbz_root, (umb_start + UMB_top ) - uppermem_root - 1);
mcb_init(umbz_root, (umb_start + UMB_top) - uppermem_root - 1);
/* change UMB 'Z' to 'M' */
((mcb FAR *)MK_FP(umbz_root,0))->m_type = 'M';
((mcb FAR *) MK_FP(umbz_root, 0))->m_type = 'M';
/* move to end */
umbz_root += ((mcb FAR *)MK_FP(umbz_root,0))->m_size + 1;
umbz_root += ((mcb FAR *) MK_FP(umbz_root, 0))->m_size + 1;
/* create link mcb */
mumcb_init(umbz_root, umb_seg - umbz_root - 1);
/* should the UMB driver return
adjacent memory in several pieces */
if (umb_seg - umbz_root - 1 == 0)
((mcb FAR *)MK_FP(umbz_root,0))->m_psp = FREE_PSP;
((mcb FAR *) MK_FP(umbz_root, 0))->m_psp = FREE_PSP;
/* create new 'Z' mcb */
zumcb_init(umb_seg, umb_size - 1);
@ -497,12 +481,11 @@ INIT VOID configDone(VOID)
}
}
DebugPrintf(("UMB Allocation completed: top at 0x%p\n",upBase));
DebugPrintf(("UMB Allocation completed: top at 0x%p\n", upBase));
/* The standard handles should be reopened here, because
we may have loaded new console or printer drivers in CONFIG.SYS */
}
INIT VOID DoConfig(VOID)
@ -528,7 +511,6 @@ INIT VOID DoConfig(VOID)
DebugPrintf(("Reading CONFIG.SYS...\n"));
}
/* Have one -- initialize. */
nCfgLine = 0;
bEof = 0;
@ -538,7 +520,7 @@ INIT VOID DoConfig(VOID)
/* do the table lookup and execute the handler for that */
/* function. */
for (;!bEof;nCfgLine++)
for (; !bEof; nCfgLine++)
{
struct table *pEntry;
@ -557,15 +539,14 @@ INIT VOID DoConfig(VOID)
/* immediately convert to upper case */
*pLine = toupper(*pLine);
if (pLine >= szLine + sizeof(szLine)-3)
if (pLine >= szLine + sizeof(szLine) - 3)
{
CfgFailure(pLine);
printf("error - line overflow line %d \n",nCfgLine);
printf("error - line overflow line %d \n", nCfgLine);
break;
}
if (*pLine == '\n' ||
*pLine == EOF ) /* end of line */
if (*pLine == '\n' || *pLine == EOF) /* end of line */
break;
if (*pLine == '\r') /* ignore */
@ -577,7 +558,6 @@ INIT VOID DoConfig(VOID)
*pLine = 0;
pLine = szLine;
/* Skip leading white space and get verb. */
pLine = scan(pLine, szBuf);
@ -591,7 +571,7 @@ INIT VOID DoConfig(VOID)
if (pEntry->pass >= 0 && pEntry->pass != nPass)
continue;
if ( SkipLine(pLineStart)) /* F5/F8 processing */
if (SkipLine(pLineStart)) /* F5/F8 processing */
continue;
pLine = skipwh(pLine);
@ -599,18 +579,18 @@ INIT VOID DoConfig(VOID)
if ('=' != *pLine)
CfgFailure(pLine);
else /* YES. DO IT */
(*(pEntry->func)) (skipwh(pLine+1));
(*(pEntry->func)) (skipwh(pLine + 1));
/* might have been the UMB driver */
if(UmbState == 2){
if (UmbState == 2)
{
UCOUNT umb_seg, umb_size;
if(UMB_get_largest(&umb_seg, &umb_size)){
if (UMB_get_largest(&umb_seg, &umb_size))
{
UmbState = 1;
upBase = MK_FP(umb_seg , 0);
upBase = MK_FP(umb_seg, 0);
UMB_top = umb_size;
umb_start = umb_seg;
@ -654,8 +634,9 @@ INIT struct table *LookUp(struct table *p, BYTE * token)
ULONG GetBiosTime(VOID)
{
return *(ULONG FAR *)(MK_FP(0x40,0x6c));
return *(ULONG FAR *) (MK_FP(0x40, 0x6c));
}
UWORD GetBiosKey(int timeout)
{
iregs r;
@ -665,12 +646,12 @@ UWORD GetBiosKey(int timeout)
for (;;)
{
r.a.x = 0x0100; /* are there keys available ? */
init_call_intr(0x16,&r);
init_call_intr(0x16, &r);
if ((r.flags & 0x40) == 0) /* yes - fetch and return */
{
r.a.x = 0x0000;
init_call_intr(0x16,&r);
init_call_intr(0x16, &r);
return r.a.x;
}
@ -678,7 +659,7 @@ UWORD GetBiosKey(int timeout)
if (timeout < 0)
continue;
if (GetBiosTime() - startTime >= timeout*18)
if (GetBiosTime() - startTime >= timeout * 18)
break;
}
return 0xffff;
@ -712,14 +693,12 @@ INIT BOOL SkipLine(char *pLine)
singleStep = TRUE;
}
printf("\r%79s\r",""); /* clear line */
printf("\r%79s\r", ""); /* clear line */
if (SkipAllConfig)
printf("Skipping CONFIG.SYS/AUTOEXEC.BAT\n");
}
if (SkipAllConfig)
return TRUE;
@ -732,7 +711,7 @@ INIT BOOL SkipLine(char *pLine)
{
key = GetBiosKey(-1);
switch(toupper(key & 0x00ff))
switch (toupper(key & 0x00ff))
{
case 'N':
case 'n':
@ -794,7 +773,8 @@ INIT void Config_Buffers(BYTE * pLine)
return;
/* Got the value, assign either default or new value */
Config.cfgBuffers = (nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers));
Config.cfgBuffers =
(nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers));
}
INIT STATIC VOID sysScreenMode(BYTE * pLine)
@ -818,7 +798,8 @@ INIT STATIC VOID sysScreenMode(BYTE * pLine)
_BL = 0;
__int__(0x10);
#else
asm {
asm
{
mov al, byte ptr nMode;
mov ah, 0x11;
mov bl, 0;
@ -829,8 +810,7 @@ INIT STATIC VOID sysScreenMode(BYTE * pLine)
INIT STATIC VOID sysVersion(BYTE * pLine)
{
COUNT major,
minor;
COUNT major, minor;
char *p;
p = pLine;
@ -880,7 +860,7 @@ INIT STATIC VOID CfgLastdrive(BYTE * pLine)
return;
}
drv -= 'A';
drv++; /* Make real number*/
drv++; /* Make real number */
Config.cfgLastdrive = max(Config.cfgLastdrive, drv);
}
@ -888,7 +868,6 @@ INIT STATIC VOID CfgLastdrive(BYTE * pLine)
UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way.
*/
INIT STATIC VOID Dosmem(BYTE * pLine)
{
BYTE *pTmp;
@ -903,10 +882,18 @@ INIT STATIC VOID Dosmem(BYTE * pLine)
printf("DOS called with %s\n", szBuf);
for (pTmp = szBuf ; ; )
for (pTmp = szBuf;;)
{
if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; }
if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAState = HMA_REQ; pTmp += 4; }
if (fmemcmp(pTmp, "UMB", 3) == 0)
{
UMBwanted = TRUE;
pTmp += 3;
}
if (fmemcmp(pTmp, "HIGH", 4) == 0)
{
HMAState = HMA_REQ;
pTmp += 4;
}
/* if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/
pTmp = skipwh(pTmp);
@ -915,14 +902,15 @@ INIT STATIC VOID Dosmem(BYTE * pLine)
pTmp++;
}
if(UmbState == 0){
if (UmbState == 0)
{
uppermem_link = 0;
uppermem_root = 0;
UmbState = UMBwanted ? 2 : 0;
}
/* Check if HMA is available straight away */
if (HMAState == HMA_REQ && MoveKernelToHMA()){
if (HMAState == HMA_REQ && MoveKernelToHMA())
{
HMAState = HMA_DONE;
}
}
@ -1046,7 +1034,6 @@ INIT STATIC VOID InitPgmHigh(BYTE * pLine)
Config.cfgP_0_startmode = 0x80;
}
INIT STATIC VOID InitPgm(BYTE * pLine)
{
/* Get the string argument that represents the new init pgm */
@ -1074,7 +1061,7 @@ INIT STATIC VOID Numlock(BYTE * pLine)
extern VOID ASMCFUNC keycheck();
/* Format: NUMLOCK = (ON | OFF) */
BYTE FAR *keyflags = (BYTE FAR *)MK_FP(0x40,0x17);
BYTE FAR *keyflags = (BYTE FAR *) MK_FP(0x40, 0x17);
GetStringArg(pLine, szBuf);
@ -1085,7 +1072,7 @@ INIT STATIC VOID Numlock(BYTE * pLine)
INIT STATIC VOID DeviceHigh(BYTE * pLine)
{
if(UmbState == 1)
if (UmbState == 1)
{
if (LoadDevice(pLine, UMB_top, TRUE) == DE_NOMEM)
{
@ -1112,7 +1099,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
struct dhdr FAR *next_dhp;
BOOL result;
if(mode)
if (mode)
dhp = AlignParagraph(upBase);
else
dhp = AlignParagraph(lpBase);
@ -1125,11 +1112,9 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
eb.load.reloc = eb.load.load_seg = FP_SEG(dhp);
#ifdef DEBUG
printf("Loading device driver %s at segment %04x\n",
szBuf, FP_SEG(dhp));
printf("Loading device driver %s at segment %04x\n", szBuf, FP_SEG(dhp));
#endif
if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS)
{
CfgFailure(pLine);
@ -1145,10 +1130,9 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
/* add \r\n to the command line */
strcat(szBuf, "\r\n");
for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff &&
(result=init_device(dhp, szBuf, mode, top))==SUCCESS
; dhp = next_dhp)
for (next_dhp = NULL; FP_OFF(next_dhp) != 0xffff &&
(result = init_device(dhp, szBuf, mode, top)) == SUCCESS;
dhp = next_dhp)
{
next_dhp = dhp->dh_next;
if (FP_SEG(next_dhp) == 0xffff)
@ -1156,7 +1140,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(next_dhp));
#ifdef DEBUG
else if (FP_OFF(next_dhp) != 0xffff) /* end of internal chain */
printf("multisegmented device driver found, next %p\n",next_dhp);
printf("multisegmented device driver found, next %p\n", next_dhp);
/* give warning message */
#endif
/* Link in device driver and save nul_dev pointer to next */
@ -1169,7 +1153,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
/* final HMA processing: */
/* final buffer processing, now upwards */
HMAState = HMA_DONE;
config_init_buffers( Config.cfgBuffers);
config_init_buffers(Config.cfgBuffers);
}
return result;
@ -1204,7 +1188,7 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes)
else
lpBase += nBytes;
fmemset( lpAllocated, 0, nBytes);
fmemset(lpAllocated, 0, nBytes);
return lpAllocated;
}
@ -1229,7 +1213,7 @@ INIT void FAR *AlignParagraph(VOID FAR * lpPtr)
/* First, convert the segmented pointer to linear address */
uSegVal = FP_SEG(lpPtr);
uSegVal += (FP_OFF(lpPtr)+0xf) >> 4;
uSegVal += (FP_OFF(lpPtr) + 0xf) >> 4;
if (FP_OFF(lpPtr) > 0xfff0)
uSegVal += 0x1000; /* handle overflow */
@ -1239,30 +1223,27 @@ INIT void FAR *AlignParagraph(VOID FAR * lpPtr)
}
#endif
INIT BYTE *
skipwh(BYTE * s)
INIT BYTE *skipwh(BYTE * s)
{
while (*s && (*s == 0x0d || *s == 0x0a || *s == ' ' || *s == '\t'))
++s;
return s;
}
INIT BYTE *
scan(BYTE * s, BYTE * d)
INIT BYTE *scan(BYTE * s, BYTE * d)
{
askThisSingleCommand = FALSE;
s = skipwh(s);
if (*s == ';') {
if (*s == ';')
{
/* semicolon is a synonym for rem */
*d++ = *s++;
}
else while (*s &&
else
while (*s &&
!(*s == 0x0d
|| *s == 0x0a
|| *s == ' '
|| *s == '\t'
|| *s == '='))
|| *s == 0x0a || *s == ' ' || *s == '\t' || *s == '='))
{
if (*s == '?')
{
@ -1343,12 +1324,11 @@ INIT COUNT toupper(COUNT c)
/* The following code is 8086 dependant */
#if 1 /* ifdef KERNEL */
INIT VOID
mcb_init(UCOUNT seg, UWORD size)
INIT VOID mcb_init(UCOUNT seg, UWORD size)
{
COUNT i;
mcb FAR * mcbp = MK_FP(seg,0);
mcb FAR *mcbp = MK_FP(seg, 0);
mcbp->m_type = MCB_LAST;
mcbp->m_psp = FREE_PSP;
@ -1364,11 +1344,10 @@ INIT VOID
mem_access_mode = FIRST_FIT;
}
INIT VOID
zumcb_init(UCOUNT seg, UWORD size)
INIT VOID zumcb_init(UCOUNT seg, UWORD size)
{
COUNT i;
mcb FAR * mcbp = MK_FP(seg,0);
mcb FAR *mcbp = MK_FP(seg, 0);
mcbp->m_type = MCB_LAST;
mcbp->m_psp = FREE_PSP;
@ -1378,11 +1357,10 @@ INIT VOID
}
INIT VOID
mumcb_init(UCOUNT seg, UWORD size)
INIT VOID mumcb_init(UCOUNT seg, UWORD size)
{
COUNT i;
mcb FAR * mcbp = MK_FP(seg,0);
mcb FAR *mcbp = MK_FP(seg, 0);
static char name[8] = "SC\0\0\0\0\0\0";
@ -1394,8 +1372,7 @@ INIT VOID
}
#endif
INIT VOID
strcat(REG BYTE * d, REG BYTE * s)
INIT VOID strcat(REG BYTE * d, REG BYTE * s)
{
while (*d != 0)
++d;
@ -1407,14 +1384,14 @@ char *stristr(char *s1, char *s2)
{
int loop;
for ( ; *s1 ; s1++)
for ( loop = 0; ; loop++)
for (; *s1; s1++)
for (loop = 0;; loop++)
{
if (s2[loop] == 0) /* found end of string 2 -> success */
{
return s1; /* position where s2 was found */
}
if (toupper(s1[loop]) != toupper(s2[loop]) )
if (toupper(s1[loop]) != toupper(s2[loop]))
break;
}
@ -1422,7 +1399,7 @@ char *stristr(char *s1, char *s2)
}
/* compare two ASCII strings ignoring case */
INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s)
INIT COUNT strcasecmp(REG BYTE * d, REG BYTE * s)
{
while (*s != '\0' && *d != '\0')
{
@ -1443,7 +1420,6 @@ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s)
that saves some relocation problems
*/
VOID config_init_buffers(COUNT anzBuffers)
{
REG WORD i;
@ -1458,10 +1434,10 @@ VOID config_init_buffers(COUNT anzBuffers)
fillhma = FALSE;
}
anzBuffers = max(anzBuffers,6);
anzBuffers = max(anzBuffers, 6);
if (anzBuffers > 99)
{
printf("BUFFERS=%u not supported, reducing to 99\n",anzBuffers);
printf("BUFFERS=%u not supported, reducing to 99\n", anzBuffers);
anzBuffers = 99;
}
LoL_nbuffers = anzBuffers;
@ -1469,17 +1445,18 @@ VOID config_init_buffers(COUNT anzBuffers)
lpTop = lpOldTop;
if (HMAState == HMA_NONE || HMAState == HMA_REQ)
lpTop = lpBase = lpTop - anzBuffers * (sizeof (struct buffer) + 0xf);
lpTop = lpBase = lpTop - anzBuffers * (sizeof(struct buffer) + 0xf);
firstbuf = ConfigAlloc(sizeof (struct buffer));
firstbuf = ConfigAlloc(sizeof(struct buffer));
pbuffer = firstbuf;
DebugPrintf(("init_buffers at"));
for (i = 0; ; ++i)
for (i = 0;; ++i)
{
if (FP_SEG(pbuffer) == 0xffff) HMAcount++;
if (FP_SEG(pbuffer) == 0xffff)
HMAcount++;
pbuffer->b_dummy = FP_OFF(pbuffer);
pbuffer->b_unit = 0;
@ -1489,7 +1466,7 @@ VOID config_init_buffers(COUNT anzBuffers)
pbuffer->b_offset = 0;
pbuffer->b_next = NULL;
DebugPrintf((" (%d,%p)",i, pbuffer));
DebugPrintf((" (%d,%p)", i, pbuffer));
/* now, we can have quite some buffers in HMA
-- up to 37 for KE38616.
@ -1499,18 +1476,18 @@ VOID config_init_buffers(COUNT anzBuffers)
if (i < (anzBuffers - 1))
{
pbuffer->b_next = HMAalloc(sizeof (struct buffer));
pbuffer->b_next = HMAalloc(sizeof(struct buffer));
if (pbuffer->b_next == NULL)
{
/* if more buffer requested then fit into HMA, allocate
some from low memory as rewuested
*/
pbuffer->b_next = ConfigAlloc(sizeof (struct buffer));
pbuffer->b_next = ConfigAlloc(sizeof(struct buffer));
}
}
else if (fillhma)
pbuffer->b_next = HMAalloc(sizeof (struct buffer));
pbuffer->b_next = HMAalloc(sizeof(struct buffer));
if (pbuffer->b_next == NULL)
break;
@ -1522,7 +1499,7 @@ VOID config_init_buffers(COUNT anzBuffers)
if (HMAcount)
printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n",
HMAcount, HMAcount*sizeof (struct buffer));
HMAcount, HMAcount * sizeof(struct buffer));
if (HMAState == HMA_NONE || HMAState == HMA_REQ)
lpBase = tmplpBase;
@ -1536,7 +1513,6 @@ VOID config_init_buffers(COUNT anzBuffers)
they expect. be careful with it!
*/
INIT VOID SetAnyDos(BYTE * pLine)
{
UNREFERENCED_PARAMETER(pLine);
@ -1622,4 +1598,3 @@ INIT VOID SetAnyDos(BYTE * pLine)
* Rev 1.0 19 Feb 1996 3:22:16 patv
* Added NLS, int2f and config.sys processing
*/

View File

@ -27,7 +27,6 @@
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#ifdef DEBUG
/* Enable debugging of NLS part */

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,8 @@
#include "portab.h"
#ifdef VERSION_STRINGS
static BYTE *dosnamesRcsId = "$Id$";
static BYTE *dosnamesRcsId =
"$Id$";
#endif
#include "globals.h"
@ -79,16 +80,10 @@ VOID SpacePad(BYTE * szString, COUNT nChars)
COUNT ParseDosName(BYTE * lpszFileName,
COUNT * pnDrive,
BYTE * pszDir,
BYTE * pszFile,
BYTE * pszExt,
BOOL bAllowWildcards)
BYTE * pszFile, BYTE * pszExt, BOOL bAllowWildcards)
{
COUNT nDirCnt,
nFileCnt,
nExtCnt;
BYTE *lpszLclDir,
*lpszLclFile,
*lpszLclExt;
COUNT nDirCnt, nFileCnt, nExtCnt;
BYTE *lpszLclDir, *lpszLclFile, *lpszLclExt;
/* Initialize the users data fields */
if (pszDir)
@ -118,12 +113,13 @@ COUNT ParseDosName(BYTE * lpszFileName,
}
nDirCnt = FP_OFF(lpszLclFile) - FP_OFF(lpszLclDir);
/* Fix lengths to maximums allowed by MS-DOS. */
if (nDirCnt > PARSE_MAX-1)
nDirCnt = PARSE_MAX-1;
if (nDirCnt > PARSE_MAX - 1)
nDirCnt = PARSE_MAX - 1;
/* Parse out the file name portion. */
lpszFileName = lpszLclFile;
while (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName))
while (bAllowWildcards ? WildChar(*lpszFileName) :
NameChar(*lpszFileName))
{
++nFileCnt;
++lpszFileName;
@ -143,15 +139,14 @@ COUNT ParseDosName(BYTE * lpszFileName,
pszDir[nDirCnt] = '\0';
}
if (pszFile)
memcpy(pszFile, "????????", FNAME_SIZE+1);
memcpy(pszFile, "????????", FNAME_SIZE + 1);
if (pszExt)
memcpy(pszExt, "???", FEXT_SIZE+1);
memcpy(pszExt, "???", FEXT_SIZE + 1);
return SUCCESS;
}
else
return DE_FILENOTFND;
/* Now we have pointers set to the directory portion and the */
/* file portion. Now determine the existance of an extension. */
lpszLclExt = lpszFileName;
@ -160,12 +155,14 @@ COUNT ParseDosName(BYTE * lpszFileName,
lpszLclExt = ++lpszFileName;
while (*lpszFileName)
{
if (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName))
if (bAllowWildcards ? WildChar(*lpszFileName) :
NameChar(*lpszFileName))
{
++nExtCnt;
++lpszFileName;
}
else{
else
{
return DE_FILENOTFND;
}
}
@ -199,14 +196,10 @@ COUNT ParseDosName(BYTE * lpszFileName,
#if 0
/* not necessary anymore because of truename */
COUNT ParseDosPath(BYTE * lpszFileName,
COUNT * pnDrive,
BYTE * pszDir,
BYTE * pszCurPath)
COUNT * pnDrive, BYTE * pszDir, BYTE * pszCurPath)
{
COUNT nDirCnt,
nPathCnt;
BYTE *lpszLclDir,
*pszBase = pszDir;
COUNT nDirCnt, nPathCnt;
BYTE *lpszLclDir, *pszBase = pszDir;
/* Initialize the users data fields */
*pszDir = '\0';
@ -237,10 +230,10 @@ COUNT ParseDosPath(BYTE * lpszFileName,
lpszLclDir = lpszFileName;
if (!PathSep(*lpszLclDir))
{
fstrncpy(pszDir, pszCurPath, PARSE_MAX - 1); /*TE*/
nPathCnt = fstrlen(pszCurPath);
if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX - 1) /*TE*/
pszDir[nPathCnt++] = '\\';
fstrncpy(pszDir, pszCurPath, PARSE_MAX - 1);
/*TE*/ nPathCnt = fstrlen(pszCurPath);
if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX - 1)
/*TE*/ pszDir[nPathCnt++] = '\\';
if (nPathCnt > PARSE_MAX)
nPathCnt = PARSE_MAX;
pszDir += nPathCnt;
@ -248,16 +241,15 @@ COUNT ParseDosPath(BYTE * lpszFileName,
/* Now see how long a directory component we have. */
while (NameChar(*lpszFileName)
|| PathSep(*lpszFileName)
|| '.' == *lpszFileName)
|| PathSep(*lpszFileName) || '.' == *lpszFileName)
{
++nDirCnt;
++lpszFileName;
}
/* Fix lengths to maximums allowed by MS-DOS. */
if ((nDirCnt + nPathCnt) > PARSE_MAX - 1) /*TE*/
nDirCnt = PARSE_MAX - 1 - nPathCnt;
if ((nDirCnt + nPathCnt) > PARSE_MAX - 1)
/*TE*/ nDirCnt = PARSE_MAX - 1 - nPathCnt;
/* Finally copy whatever the user wants extracted to the user's */
/* buffers. */
@ -289,11 +281,8 @@ COUNT ParseDosPath(BYTE * lpszFileName,
VOID DosTrimPath(BYTE * lpszPathNamep)
{
BYTE *lpszLast,
*lpszNext,
*lpszRoot = NULL;
COUNT nChars,
flDotDot;
BYTE *lpszLast, *lpszNext, *lpszRoot = NULL;
COUNT nChars, flDotDot;
/* First, convert all '/' to '\'. Look for root as we scan */
if (*lpszPathNamep == '\\')
@ -302,14 +291,13 @@ VOID DosTrimPath(BYTE * lpszPathNamep)
{
if (*lpszNext == '/')
*lpszNext = '\\';
if (!lpszRoot &&
*lpszNext == ':' && *(lpszNext + 1) == '\\')
if (!lpszRoot && *lpszNext == ':' && *(lpszNext + 1) == '\\')
lpszRoot = lpszNext + 1;
}
/* NAMEMAX + 2, must include C: TE*/
/* NAMEMAX + 2, must include C: TE */
for (lpszLast = lpszNext = lpszPathNamep, nChars = 0;
*lpszNext != '\0' && nChars < NAMEMAX+2;)
*lpszNext != '\0' && nChars < NAMEMAX + 2;)
{
/* Initialize flag for loop. */
flDotDot = FALSE;
@ -325,8 +313,7 @@ VOID DosTrimPath(BYTE * lpszPathNamep)
/* as appropriate. */
else if (*(lpszNext + 1) == '.')
{
if (*(lpszNext + 2) == '.'
&& !(*(lpszNext + 3)))
if (*(lpszNext + 2) == '.' && !(*(lpszNext + 3)))
{
/* At the end, just truncate */
/* and exit. */
@ -337,8 +324,7 @@ VOID DosTrimPath(BYTE * lpszPathNamep)
return;
}
if (*(lpszNext + 2) == '.'
&& *(lpszNext + 3) == '\\')
if (*(lpszNext + 2) == '.' && *(lpszNext + 3) == '\\')
{
fstrncpy(lpszLast, lpszNext + 3, NAMEMAX);
/* bump back to the last */
@ -351,8 +337,7 @@ VOID DosTrimPath(BYTE * lpszPathNamep)
{
--lpszLast;
}
while (lpszLast != lpszPathNamep
&& *lpszLast != '\\');
while (lpszLast != lpszPathNamep && *lpszLast != '\\');
flDotDot = TRUE;
}
/* Note: we skip strange stuff that */
@ -460,4 +445,3 @@ VOID DosTrimPath(BYTE * lpszPathNamep)
* Initial revision.
*
*/

View File

@ -29,20 +29,18 @@
#include "dyndata.h"
#ifdef VERSION_STRINGS
static BYTE *dskRcsId = "$Id$";
static BYTE *dskRcsId =
"$Id$";
#endif
#if defined(DEBUG)
#define DebugPrintf(x) printf x
#define DebugPrintf(x) printf x
#else
#define DebugPrintf(x)
#define DebugPrintf(x)
#endif
/* #define STATIC */
#ifdef PROTO
BOOL ASMCFUNC fl_reset(WORD);
COUNT ASMCFUNC fl_readdasd(WORD);
@ -57,11 +55,12 @@ COUNT ASMCFUNC fl_setdisktype(WORD, WORD);
COUNT ASMCFUNC fl_setmediatype(WORD, WORD, WORD);
VOID ASMCFUNC fl_readkey(VOID);
extern COUNT ASMCFUNC fl_lba_ReadWrite (BYTE drive, WORD mode,
struct _bios_LBA_address_packet FAR *dap_p);
extern COUNT ASMCFUNC fl_lba_ReadWrite(BYTE drive, WORD mode,
struct _bios_LBA_address_packet FAR
* dap_p);
int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer,
ULONG LBA_address,unsigned total, UWORD *transferred);
int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
ULONG LBA_address, unsigned total, UWORD * transferred);
#else
BOOL fl_reset();
COUNT fl_readdasd();
@ -82,8 +81,6 @@ extern BYTE FAR nblk_rel;
extern int FAR ASMCFUNC Get_nblk_rel(void);
#define LBA_READ 0x4200
#define LBA_WRITE 0x4300
UWORD LBA_WRITE_VERIFY = 0x4302;
@ -98,14 +95,12 @@ UWORD LBA_WRITE_VERIFY = 0x4302;
*/
UBYTE DiskTransferBuffer[1 * SEC_SIZE];
static struct Access_info
{
static struct Access_info {
BYTE AI_spec;
BYTE AI_Flag;
};
struct FS_info
{
struct FS_info {
ULONG serialno;
BYTE volume[11];
BYTE fstype[8];
@ -114,7 +109,10 @@ struct FS_info
extern struct DynS Dyn;
/*TE - array access functions */
ddt *getddt(int dev) { return &(((ddt*)Dyn.Buffer)[dev]);}
ddt *getddt(int dev)
{
return &(((ddt *) Dyn.Buffer)[dev]);
}
#define N_PART 4 /* number of partitions per
table partition */
@ -123,39 +121,33 @@ COUNT nUnits; /* number of returned units */
#define PARTOFF 0x1be
#ifdef PROTO
WORD
_dsk_init (rqptr rq, ddt *pddt),
mediachk (rqptr rq, ddt *pddt),
bldbpb (rqptr rq, ddt *pddt),
blockio (rqptr rq, ddt *pddt),
IoctlQueblk(rqptr rq, ddt *pddt),
Genblkdev (rqptr rq, ddt *pddt),
Getlogdev (rqptr rq, ddt *pddt),
Setlogdev (rqptr rq, ddt *pddt),
blk_Open (rqptr rq, ddt *pddt),
blk_Close (rqptr rq, ddt *pddt),
blk_Media (rqptr rq, ddt *pddt),
blk_noerr (rqptr rq, ddt *pddt),
blk_nondr (rqptr rq, ddt *pddt),
blk_error (rqptr rq, ddt *pddt);
_dsk_init(rqptr rq, ddt * pddt),
mediachk(rqptr rq, ddt * pddt),
bldbpb(rqptr rq, ddt * pddt),
blockio(rqptr rq, ddt * pddt),
IoctlQueblk(rqptr rq, ddt * pddt),
Genblkdev(rqptr rq, ddt * pddt),
Getlogdev(rqptr rq, ddt * pddt),
Setlogdev(rqptr rq, ddt * pddt),
blk_Open(rqptr rq, ddt * pddt),
blk_Close(rqptr rq, ddt * pddt),
blk_Media(rqptr rq, ddt * pddt),
blk_noerr(rqptr rq, ddt * pddt),
blk_nondr(rqptr rq, ddt * pddt), blk_error(rqptr rq, ddt * pddt);
WORD dskerr(COUNT);
#else
WORD _dsk_init(),
mediachk(),
bldbpb(),
blockio(),
IoctlQueblk(),
Genblkdev(),
Getlogdev(),
Setlogdev(),
blk_Open(),
blk_Close(),
blk_Media(),
blk_noerr(),
blk_nondr(),
blk_error();
mediachk(),
bldbpb(),
blockio(),
IoctlQueblk(),
Genblkdev(),
Getlogdev(),
Setlogdev(),
blk_Open(),
blk_Close(), blk_Media(), blk_noerr(), blk_nondr(), blk_error();
WORD dskerr();
#endif
@ -164,7 +156,7 @@ WORD dskerr();
/* */
#ifdef PROTO
static WORD(*dispatch[NENTRY]) (rqptr rq, ddt *pddt) =
static WORD(*dispatch[NENTRY]) (rqptr rq, ddt * pddt) =
#else
static WORD(*dispatch[NENTRY]) () =
#endif
@ -197,20 +189,12 @@ static WORD(*dispatch[NENTRY]) () =
IoctlQueblk /* Ioctl Query */
};
#define hd(x) ((x) & DF_FIXED)
/* ----------------------------------------------------------------------- */
/* F U N C T I O N S --------------------------------------------------- */
/* ----------------------------------------------------------------------- */
COUNT FAR ASMCFUNC blk_driver(rqptr rp)
{
if (rp->r_unit >= nUnits && rp->r_command != C_INIT)
@ -224,7 +208,7 @@ COUNT FAR ASMCFUNC blk_driver(rqptr rp)
}
/* disk init is done in diskinit.c, so this should never be called */
WORD _dsk_init(rqptr rp, ddt *pddt)
WORD _dsk_init(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(rp);
UNREFERENCED_PARAMETER(pddt);
@ -232,7 +216,7 @@ WORD _dsk_init(rqptr rp, ddt *pddt)
return S_DONE; /* to keep the compiler happy */
}
STATIC WORD play_dj(ddt*pddt)
STATIC WORD play_dj(ddt * pddt)
{
/* play the DJ ... */
if ((pddt->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == DF_MULTLOG)
@ -251,8 +235,8 @@ STATIC WORD play_dj(ddt*pddt)
printf("Error in the DJ mechanism!\n"); /* should not happen! */
return M_CHANGED;
}
printf("Remove diskette in drive %c:\n", 'A'+pddt2->ddt_logdriveno);
printf("Insert diskette in drive %c:\n", 'A'+pddt->ddt_logdriveno);
printf("Remove diskette in drive %c:\n", 'A' + pddt2->ddt_logdriveno);
printf("Insert diskette in drive %c:\n", 'A' + pddt->ddt_logdriveno);
printf("Press the any key to continue ... \n");
fl_readkey();
pddt2->ddt_descflags &= ~DF_CURLOG;
@ -262,7 +246,7 @@ STATIC WORD play_dj(ddt*pddt)
return M_NOT_CHANGED;
}
STATIC WORD diskchange(ddt *pddt)
STATIC WORD diskchange(ddt * pddt)
{
COUNT result;
@ -286,7 +270,7 @@ STATIC WORD diskchange(ddt *pddt)
return tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED;
}
WORD mediachk(rqptr rp, ddt *pddt)
WORD mediachk(rqptr rp, ddt * pddt)
{
/* check floppy status */
if (pddt->ddt_descflags & DF_REFORMAT)
@ -309,34 +293,34 @@ WORD mediachk(rqptr rp, ddt *pddt)
/*
* Read Write Sector Zero or Hard Drive Dos Bpb
*/
STATIC WORD RWzero(ddt *pddt, UWORD mode)
STATIC WORD RWzero(ddt * pddt, UWORD mode)
{
UWORD done;
return LBA_Transfer(pddt, mode,
(UBYTE FAR *)&DiskTransferBuffer,
pddt->ddt_offset,1,&done);
(UBYTE FAR *) & DiskTransferBuffer,
pddt->ddt_offset, 1, &done);
}
/*
0 if not set, 1 = a, 2 = b, etc, assume set.
page 424 MS Programmer's Ref.
*/
static WORD Getlogdev(rqptr rp, ddt *pddt)
static WORD Getlogdev(rqptr rp, ddt * pddt)
{
BYTE x = rp->r_unit;
UNREFERENCED_PARAMETER(pddt);
x++;
if( x > Get_nblk_rel() )
if (x > Get_nblk_rel())
return failure(E_UNIT);
rp->r_unit = x;
return S_DONE;
}
static WORD Setlogdev(rqptr rp, ddt *pddt)
static WORD Setlogdev(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(rp);
UNREFERENCED_PARAMETER(pddt);
@ -344,7 +328,7 @@ static WORD Setlogdev(rqptr rp, ddt *pddt)
return S_DONE;
}
static WORD blk_Open(rqptr rp, ddt *pddt)
static WORD blk_Open(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(rp);
@ -352,7 +336,7 @@ static WORD blk_Open(rqptr rp, ddt *pddt)
return S_DONE;
}
static WORD blk_Close(rqptr rp, ddt *pddt)
static WORD blk_Close(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(rp);
@ -360,29 +344,29 @@ static WORD blk_Close(rqptr rp, ddt *pddt)
return S_DONE;
}
static WORD blk_nondr(rqptr rp, ddt *pddt)
static WORD blk_nondr(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(rp);
UNREFERENCED_PARAMETER(pddt);
return S_BUSY|S_DONE;
return S_BUSY | S_DONE;
}
static WORD blk_Media(rqptr rp, ddt *pddt)
static WORD blk_Media(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(rp);
if (hd( pddt->ddt_descflags))
return S_BUSY|S_DONE; /* Hard Drive */
if (hd(pddt->ddt_descflags))
return S_BUSY | S_DONE; /* Hard Drive */
else
return S_DONE; /* Floppy */
}
static WORD getbpb(ddt *pddt)
static WORD getbpb(ddt * pddt)
{
ULONG count;
bpb *pbpbarray = &pddt->ddt_bpb;
WORD head,/*track,*/sector,ret;
WORD head, /*track, */ sector, ret;
pddt->ddt_descflags |= DF_NOACCESS; /* set drive to not accessible and changed */
if (diskchange(pddt) != M_NOT_CHANGED)
@ -392,10 +376,12 @@ static WORD getbpb(ddt *pddt)
if (ret != 0)
return (dskerr(ret));
getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), &pbpbarray->bpb_nbyte);
getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]),
&pbpbarray->bpb_nbyte);
if (DiskTransferBuffer[0x1fe]!=0x55 || DiskTransferBuffer[0x1ff]!=0xaa ||
pbpbarray->bpb_nbyte != 512) {
if (DiskTransferBuffer[0x1fe] != 0x55
|| DiskTransferBuffer[0x1ff] != 0xaa || pbpbarray->bpb_nbyte != 512)
{
/* copy default bpb to be sure that there is no bogus data */
memcpy(pbpbarray, &pddt->ddt_defbpb, sizeof(bpb));
return S_DONE;
@ -408,7 +394,7 @@ static WORD getbpb(ddt *pddt)
fmemcpy(pbpbarray, &DiskTransferBuffer[BT_BPB], sizeof(bpb));
#ifdef WITHFAT32
/*??*/
/*?? */
/* 2b is fat16 volume label. if memcmp, then offset 0x36.
if (fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT16",5) == 0 ||
fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT12",5) == 0) {
@ -421,24 +407,27 @@ static WORD getbpb(ddt *pddt)
if (pbpbarray->bpb_nfsect != 0)
{
/* FAT16/FAT12 boot sector */
getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pddt->ddt_serialno);
memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x2B], 11);
memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x36], 8);
} else {
getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])),
&pddt->ddt_serialno);
memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11);
memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8);
}
else
{
/* FAT32 boot sector */
getlong(&((((BYTE *) & DiskTransferBuffer[0x43])[0])), &pddt->ddt_serialno);
memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x47], 11);
memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x52], 8);
getlong(&((((BYTE *) & DiskTransferBuffer[0x43])[0])),
&pddt->ddt_serialno);
memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x47], 11);
memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x52], 8);
pbpbarray->bpb_ndirent = 512;
}
#else
getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pddt->ddt_serialno);
memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x2B], 11);
memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x36], 8);
getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])),
&pddt->ddt_serialno);
memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11);
memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8);
#endif
#ifdef DSK_DEBUG
printf("BPB_NBYTE = %04x\n", pbpbarray->bpb_nbyte);
printf("BPB_NSECTOR = %02x\n", pbpbarray->bpb_nsector);
@ -452,8 +441,7 @@ static WORD getbpb(ddt *pddt)
count =
pbpbarray->bpb_nsize == 0 ?
pbpbarray->bpb_huge :
pbpbarray->bpb_nsize;
pbpbarray->bpb_huge : pbpbarray->bpb_nsize;
head = pbpbarray->bpb_nheads;
sector = pbpbarray->bpb_nsecs;
@ -476,8 +464,7 @@ static WORD getbpb(ddt *pddt)
return 0;
}
STATIC WORD bldbpb(rqptr rp, ddt *pddt)
STATIC WORD bldbpb(rqptr rp, ddt * pddt)
{
WORD result;
@ -488,12 +475,12 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt)
return S_DONE;
}
static WORD IoctlQueblk(rqptr rp, ddt *pddt)
static WORD IoctlQueblk(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(pddt);
switch(rp->r_count){
switch (rp->r_count)
{
case 0x0846:
case 0x0847:
case 0x0860:
@ -507,36 +494,37 @@ static WORD IoctlQueblk(rqptr rp, ddt *pddt)
}
COUNT Genblockio(ddt *pddt, UWORD mode, WORD head, WORD track, WORD sector,
WORD count, VOID FAR *buffer)
COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track,
WORD sector, WORD count, VOID FAR * buffer)
{
UWORD transferred;
/* apparently sector is ZERO, not ONE based !!! */
return LBA_Transfer(pddt, mode, buffer,
((ULONG)track * pddt->ddt_bpb.bpb_nheads + head) *
(ULONG)pddt->ddt_bpb.bpb_nsecs +
pddt->ddt_offset + sector,
count, &transferred);
((ULONG) track * pddt->ddt_bpb.bpb_nheads + head) *
(ULONG) pddt->ddt_bpb.bpb_nsecs +
pddt->ddt_offset + sector, count, &transferred);
}
STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
{
int ret;
bpb *pbpb;
#ifdef WITHFAT32
int extended = 0;
if ((rp->r_count >> 8) == 0x48) extended = 1;
if ((rp->r_count >> 8) == 0x48)
extended = 1;
else
#endif
if ((rp->r_count >> 8) != 8)
return failure(E_CMD);
switch(rp->r_count & 0xff){
switch (rp->r_count & 0xff)
{
case 0x40: /* set device parameters */
{
struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans;
struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans;
pddt->ddt_type = gblp->gbio_devtype;
pddt->ddt_descflags &= ~3;
@ -544,18 +532,21 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
| (DF_DPCHANGED | DF_REFORMAT);
pddt->ddt_ncyl = gblp->gbio_ncyl;
/* use default dpb or current bpb? */
pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb;
pbpb =
(gblp->gbio_spcfunbit & 0x01) ==
0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb;
#ifdef WITHFAT32
if (!extended) fmemcpy(pbpb, &gblp->gbio_bpb, BPB_SIZEOF);
if (!extended)
fmemcpy(pbpb, &gblp->gbio_bpb, BPB_SIZEOF);
else
#endif
fmemcpy(pbpb, &gblp->gbio_bpb, sizeof(gblp->gbio_bpb));
/*pbpb->bpb_nsector = gblp->gbio_nsecs;*/
/*pbpb->bpb_nsector = gblp->gbio_nsecs; */
break;
}
case 0x41: /* write track */
{
struct gblkrw FAR * rw = (struct gblkrw FAR *) rp->r_trans;
struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans;
ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl,
rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer);
if (ret != 0)
@ -564,9 +555,11 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
break;
case 0x42: /* format/verify track */
{
struct gblkfv FAR * fv = (struct gblkfv FAR *) rp->r_trans;
struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans;
COUNT tracks;
struct thst {UBYTE track, head, sector, type;} *addrfield, afentry;
struct thst {
UBYTE track, head, sector, type;
} *addrfield, afentry;
if (hd(pddt->ddt_descflags))
{
@ -588,7 +581,8 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
fv->gbfv_spcfunbit = 2;
return dskerr(ret);
}
else if (ret == 0x80) {
else if (ret == 0x80)
{
fv->gbfv_spcfunbit = 3; /* no disk in drive */
return dskerr(ret);
}
@ -597,13 +591,16 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
{
COUNT type = 0;
if ((fv->gbfv_spcfunbit & 1) &&
(ret = fl_read(pddt->ddt_driveno,0,0,1,1,DiskTransferBuffer)) != 0)
(ret =
fl_read(pddt->ddt_driveno, 0, 0, 1, 1,
DiskTransferBuffer)) != 0)
{
fv->gbfv_spcfunbit = 3; /* no disk in drive */
return dskerr(ret);
}
if (pddt->ddt_ncyl == 40 &&
(pddt->ddt_bpb.bpb_nsecs == 9 || pddt->ddt_bpb.bpb_nsecs == 8))
(pddt->ddt_bpb.bpb_nsecs == 9
|| pddt->ddt_bpb.bpb_nsecs == 8))
{
if (pddt->ddt_type == 0)
type = 1; /* 320/360K disk in 360K drive */
@ -614,8 +611,7 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
pddt->ddt_bpb.bpb_nsecs == 15)
type = 3; /* 1.2M disk in 1.2M drive */
else if ((pddt->ddt_type == 2 || pddt->ddt_type == 7) &&
pddt->ddt_ncyl == 80 && pddt->ddt_bpb.bpb_nsecs == 15
)
pddt->ddt_ncyl == 80 && pddt->ddt_bpb.bpb_nsecs == 15)
type = 4; /* 720kb disk in 1.44M or 720kb drive */
if (type == 0)
@ -627,25 +623,27 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
fl_setdisktype(pddt->ddt_driveno, type);
}
}
if (fv->gbfv_spcfunbit & 1) return S_DONE;
if (fv->gbfv_spcfunbit & 1)
return S_DONE;
afentry.type = 2; /* 512 byte sectors */
afentry.track = fv->gbfv_cyl;
afentry.head = fv->gbfv_head;
for (tracks = fv->gbfv_spcfunbit & 2 ? fv->gbfv_ntracks : 1; tracks > 0;
tracks--)
for (tracks = fv->gbfv_spcfunbit & 2 ? fv->gbfv_ntracks : 1;
tracks > 0; tracks--)
{
addrfield = (struct thst *)DiskTransferBuffer;
if (afentry.track > pddt->ddt_ncyl)
return failure(E_FAILURE);
for (afentry.sector = 1; afentry.sector <= pddt->ddt_bpb.bpb_nsecs;
afentry.sector++)
for (afentry.sector = 1;
afentry.sector <= pddt->ddt_bpb.bpb_nsecs; afentry.sector++)
memcpy(addrfield++, &afentry, sizeof(afentry));
ret = Genblockio(pddt, LBA_FORMAT, afentry.head, afentry.track, 0,
ret =
Genblockio(pddt, LBA_FORMAT, afentry.head, afentry.track, 0,
pddt->ddt_bpb.bpb_nsecs, DiskTransferBuffer);
if (ret != 0)
return dskerr(ret);
@ -662,7 +660,7 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
case 0x62: /* verify track */
{
struct gblkfv FAR * fv = (struct gblkfv FAR *) rp->r_trans;
struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans;
ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0,
(fv->gbfv_spcfunbit ?
@ -675,14 +673,14 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
break;
case 0x46: /* set volume serial number */
{
struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans;
struct FS_info FAR * fs;
struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans;
struct FS_info FAR *fs;
ret = getbpb(pddt);
if (ret != 0)
return (ret);
fs = (struct FS_info FAR *) &DiskTransferBuffer
fs = (struct FS_info FAR *)&DiskTransferBuffer
[(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x27 : 0x43)];
fs->serialno = gioc->ioc_serialno;
pddt->ddt_serialno = fs->serialno;
@ -694,14 +692,14 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
break;
case 0x47: /* set access flag */
{
struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans;
struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans;
pddt->ddt_descflags &= ~DF_NOACCESS;
pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS);
}
break;
case 0x60: /* get device parameters */
{
struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans;
struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans;
gblp->gbio_devtype = pddt->ddt_type;
gblp->gbio_devattrib = pddt->ddt_descflags & 3;
@ -709,18 +707,21 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
gblp->gbio_media = (pddt->ddt_type == 1) && (pddt->ddt_ncyl == 40);
gblp->gbio_ncyl = pddt->ddt_ncyl;
/* use default dpb or current bpb? */
pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb;
pbpb =
(gblp->gbio_spcfunbit & 0x01) ==
0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb;
#ifdef WITHFAT32
if (!extended) fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF);
if (!extended)
fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF);
else
#endif
fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb));
/*gblp->gbio_nsecs = pbpb->bpb_nsector;*/
/*gblp->gbio_nsecs = pbpb->bpb_nsector; */
break;
}
case 0x61: /* read track */
{
struct gblkrw FAR * rw = (struct gblkrw FAR *) rp->r_trans;
struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans;
ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl,
rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer);
if (ret != 0)
@ -729,20 +730,20 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
break;
case 0x66: /* get volume serial number */
{
struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans;
struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans;
ret = getbpb(pddt);
if (ret != 0)
return (ret);
gioc->ioc_serialno = pddt->ddt_serialno;
fmemcpy(gioc->ioc_volume, pddt->ddt_volume,11);
fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype,8);
fmemcpy(gioc->ioc_volume, pddt->ddt_volume, 11);
fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype, 8);
}
break;
case 0x67: /* get access flag */
{
struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans;
struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans;
ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */
}
break;
@ -752,7 +753,7 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt)
return S_DONE;
}
WORD blockio(rqptr rp, ddt *pddt)
WORD blockio(rqptr rp, ddt * pddt)
{
ULONG start, size;
WORD ret;
@ -760,11 +761,17 @@ WORD blockio(rqptr rp, ddt *pddt)
int action;
bpb *pbpb;
switch (rp->r_command){
case C_INPUT: action = LBA_READ; break;
case C_OUTPUT:action = LBA_WRITE; break;
case C_OUTVFY:action = LBA_WRITE_VERIFY; break;
switch (rp->r_command)
{
case C_INPUT:
action = LBA_READ;
break;
case C_OUTPUT:
action = LBA_WRITE;
break;
case C_OUTVFY:
action = LBA_WRITE_VERIFY;
break;
default:
return failure(E_FAILURE);
}
@ -777,8 +784,7 @@ WORD blockio(rqptr rp, ddt *pddt)
pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb;
size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge);
if (start >= size ||
start + rp->r_count > size)
if (start >= size || start + rp->r_count > size)
{
return 0x0408;
}
@ -786,7 +792,7 @@ WORD blockio(rqptr rp, ddt *pddt)
ret = LBA_Transfer(pddt, action,
rp->r_trans,
start, rp->r_count,(UWORD*)&rp->r_count);
start, rp->r_count, (UWORD *) & rp->r_count);
if (ret != 0)
{
@ -795,7 +801,7 @@ WORD blockio(rqptr rp, ddt *pddt)
return S_DONE;
}
STATIC WORD blk_error(rqptr rp, ddt *pddt)
STATIC WORD blk_error(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(pddt);
@ -803,8 +809,7 @@ STATIC WORD blk_error(rqptr rp, ddt *pddt)
return failure(E_FAILURE); /* general failure */
}
STATIC WORD blk_noerr(rqptr rp, ddt *pddt)
STATIC WORD blk_noerr(rqptr rp, ddt * pddt)
{
UNREFERENCED_PARAMETER(rp);
UNREFERENCED_PARAMETER(pddt);
@ -845,19 +850,16 @@ STATIC WORD dskerr(COUNT code)
}
}
/*
translate LBA sectors into CHS addressing
*/
void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt *pddt)
void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt)
{
/* we need the defbpb values since those are taken from the
BIOS, not from some random boot sector, except when
we're dealing with a floppy */
bpb *pbpb = hd(pddt->ddt_descflags) ?
&pddt->ddt_defbpb :
&pddt->ddt_bpb;
bpb *pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb;
chs->Sector = LBA_address % pbpb->bpb_nsecs + 1;
@ -867,12 +869,10 @@ void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt *pddt)
chs->Cylinder = LBA_address / pbpb->bpb_nheads;
}
/* Test for 64K boundary crossing and return count small */
/* enough not to exceed the threshold. */
STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count)
STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count)
{
UWORD utemp = (((UWORD) FP_SEG(buffer) << 4) + FP_OFF(buffer));
@ -888,8 +888,6 @@ STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count)
return count;
}
/*
int LBA_Transfer(
ddt *pddt, physical characteristics of drive
@ -918,11 +916,12 @@ STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count)
*/
int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer,
ULONG LBA_address,unsigned totaltodo, UWORD *transferred)
int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
ULONG LBA_address, unsigned totaltodo,
UWORD * transferred)
{
static struct _bios_LBA_address_packet dap = {
16,0,0,0,0,0,0
16, 0, 0, 0, 0, 0, 0
};
unsigned count;
@ -948,16 +947,14 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer,
}
*/
for ( ;totaltodo != 0; )
for (; totaltodo != 0;)
{
count = totaltodo;
count = min(count, 0x7f);
/* avoid overflowing 64K DMA boundary */
count = DMA_max_transfer(buffer,count);
count = DMA_max_transfer(buffer, count);
if (FP_SEG(buffer) >= 0xa000 || count == 0)
{
@ -966,16 +963,15 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer,
if ((mode & 0xff00) == (LBA_WRITE & 0xff00))
{
fmemcpy(DiskTransferBuffer,buffer,512);
fmemcpy(DiskTransferBuffer, buffer, 512);
}
}
else {
else
{
transfer_address = buffer;
}
for ( num_retries = 0; num_retries < N_RETRY; num_retries++)
for (num_retries = 0; num_retries < N_RETRY; num_retries++)
{
if (pddt->ddt_LBASupported && mode != LBA_FORMAT)
{
@ -986,21 +982,23 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer,
dap.block_address_high = 0; /* clear high part */
dap.block_address = LBA_address; /* clear high part */
/* Load the registers and call the interrupt. */
if (pddt->ddt_WriteVerifySupported || mode != LBA_WRITE_VERIFY)
{
error_code = fl_lba_ReadWrite(pddt->ddt_driveno,mode, &dap);
error_code = fl_lba_ReadWrite(pddt->ddt_driveno, mode, &dap);
}
else {
else
{
/* verify requested, but not supported */
error_code = fl_lba_ReadWrite(pddt->ddt_driveno,LBA_WRITE, &dap);
error_code =
fl_lba_ReadWrite(pddt->ddt_driveno, LBA_WRITE, &dap);
if (error_code == 0)
{
error_code = fl_lba_ReadWrite(pddt->ddt_driveno,LBA_VERIFY, &dap);
error_code =
fl_lba_ReadWrite(pddt->ddt_driveno, LBA_VERIFY, &dap);
}
}
}
@ -1018,24 +1016,28 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer,
if (chs.Cylinder > 1023)
{
printf("LBA-Transfer error : cylinder %u > 1023\n", chs.Cylinder);
printf("LBA-Transfer error : cylinder %u > 1023\n",
chs.Cylinder);
return 1;
}
error_code = (mode == LBA_READ ? fl_read :
mode == LBA_VERIFY ? fl_verify :
mode == LBA_FORMAT ? fl_format : fl_write)(
pddt->ddt_driveno,
chs.Head, (UWORD)chs.Cylinder, chs.Sector,
count, transfer_address);
mode ==
LBA_FORMAT ? fl_format : fl_write) (pddt->
ddt_driveno,
chs.Head,
(UWORD) chs.
Cylinder,
chs.Sector,
count,
transfer_address);
if (error_code == 0 &&
mode == LBA_WRITE_VERIFY)
if (error_code == 0 && mode == LBA_WRITE_VERIFY)
{
error_code = fl_verify(
pddt->ddt_driveno,
chs.Head, (UWORD)chs.Cylinder, chs.Sector,
count, transfer_address);
error_code = fl_verify(pddt->ddt_driveno,
chs.Head, (UWORD) chs.Cylinder,
chs.Sector, count, transfer_address);
}
}
if (error_code == 0)
@ -1054,17 +1056,17 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer,
if (transfer_address == DiskTransferBuffer &&
(mode & 0xff00) == (LBA_READ & 0xff00))
{
fmemcpy(buffer,DiskTransferBuffer,512);
fmemcpy(buffer, DiskTransferBuffer, 512);
}
*transferred += count;
LBA_address += count;
totaltodo -= count;
buffer = add_far(buffer,count*512);
buffer = add_far(buffer, count * 512);
}
return(error_code);
return (error_code);
}
/*

View File

@ -10,4 +10,4 @@
#include "init-mod.h"
#include "dyndata.h"
struct DynS Dyn = {0};
struct DynS Dyn = { 0 };

View File

@ -16,4 +16,4 @@ void DynFree(void *ptr);
struct DynS {
unsigned Allocated;
char Buffer[1];
};
};

View File

@ -4,7 +4,6 @@
this serves requests from the INIT modules to
allocate dynamic data.
kernel layout:
00000H 000FFH 00100H PSP PSP
00100H 004E1H 003E2H _TEXT CODE
@ -28,7 +27,6 @@ additionally:
122E0H 12AA5H 007C6H ID ID
12AA6H 12CBFH 0021AH IB IB
purpose is to move the HMA_TEXT = resident kernel
around, so that below it - after BSS, there is data
addressable near by the kernel, to hold some arrays
@ -42,23 +40,20 @@ additionally:
#include "dyndata.h"
#if defined(DEBUG)
#define DebugPrintf(x) printf x
#define DebugPrintf(x) printf x
#else
#define DebugPrintf(x)
#define DebugPrintf(x)
#endif
/*extern struct DynS FAR Dyn;*/
#ifndef __TURBOC__
#include "init-dat.h"
extern struct DynS DOSFAR Dyn;
#include "init-dat.h"
extern struct DynS DOSFAR Dyn;
#else
extern struct DynS FAR Dyn;
extern struct DynS FAR Dyn;
#endif
void far *DynAlloc(char *what, unsigned num, unsigned size)
{
void far *now;
@ -67,14 +62,15 @@ void far *DynAlloc(char *what, unsigned num, unsigned size)
UNREFERENCED_PARAMETER(what);
#endif
if ((ULONG)total + Dyn.Allocated > 0xffff)
if ((ULONG) total + Dyn.Allocated > 0xffff)
{
printf("PANIC:Dyn %lu\n", (ULONG)total + Dyn.Allocated);
for (;;);
printf("PANIC:Dyn %lu\n", (ULONG) total + Dyn.Allocated);
for (;;) ;
}
DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n",
what, num, size, total, Dyn.Allocated,Dyn.Allocated+total));
what, num, size, total, Dyn.Allocated,
Dyn.Allocated + total));
now = (void far *)&Dyn.Buffer[Dyn.Allocated];
fmemset(now, 0, total);
@ -91,7 +87,8 @@ void DynFree(void *ptr)
void FAR *DynLast()
{
DebugPrintf(("dynamic data end at %p\n",(void FAR *)(Dyn.Buffer+Dyn.Allocated)));
DebugPrintf(("dynamic data end at %p\n",
(void FAR *)(Dyn.Buffer + Dyn.Allocated)));
return Dyn.Buffer+Dyn.Allocated;
return Dyn.Buffer + Dyn.Allocated;
}

View File

@ -29,7 +29,8 @@
#include "portab.h"
#ifdef VERSION_STRINGS
static BYTE *errorRcsId = "$Id$";
static BYTE *errorRcsId =
"$Id$";
#endif
#include "globals.h"
@ -39,19 +40,11 @@ static BYTE *errorRcsId = "$Id$";
VOID dump(void)
{
printf("Register Dump [AH = %02x CS:IP = %04x:%04x]\n",
error_regs.AH,
error_regs.CS,
error_regs.IP);
error_regs.AH, error_regs.CS, error_regs.IP);
printf("AX:%04x BX:%04x CX:%04x DX:%04x\n",
error_regs.AX,
error_regs.BX,
error_regs.CX,
error_regs.DX);
error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX);
printf("SI:%04x DI:%04x DS:%04x ES:%04x\n",
error_regs.SI,
error_regs.DI,
error_regs.DS,
error_regs.ES);
error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES);
}
#endif
@ -82,21 +75,15 @@ VOID fatal(BYTE * err_msg)
/* Abort, retry or fail for character devices */
COUNT char_error(request * rq, struct dhdr FAR * lpDevice)
{
return CriticalError(
EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE,
0,
rq->r_status & S_MASK,
lpDevice);
return CriticalError(EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE,
0, rq->r_status & S_MASK, lpDevice);
}
/* Abort, retry or fail for block devices */
COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice)
{
return CriticalError(
EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE,
nDrive,
rq->r_status & S_MASK,
lpDevice);
return CriticalError(EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE,
nDrive, rq->r_status & S_MASK, lpDevice);
}
/*
@ -139,4 +126,3 @@ COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice)
* Rev 1.0 02 Jul 1995 8:06:14 patv
* Initial revision.
*/

View File

@ -31,7 +31,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *fatdirRcsId = "$Id$";
static BYTE *fatdirRcsId =
"$Id$";
#endif
/* Description.
@ -45,7 +46,8 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart)
fnp->f_flags.f_droot = FALSE;
fnp->f_flags.f_ddir = TRUE;
fnp->f_flags.f_dnew = TRUE;
fnp->f_diroff = fnp->f_offset = fnp->f_cluster_offset = fnp->f_highwater = 0l;
fnp->f_diroff = fnp->f_offset = fnp->f_cluster_offset =
fnp->f_highwater = 0l;
/* root directory */
if (dirstart == 0)
@ -76,17 +78,18 @@ f_node_ptr dir_open(BYTE * dirname)
BYTE *pszPath = dirname + 2;
/* Allocate an fnode if possible - error return (0) if not. */
if ((fnp = get_f_node()) == (f_node_ptr)0)
if ((fnp = get_f_node()) == (f_node_ptr) 0)
{
return (f_node_ptr)0;
return (f_node_ptr) 0;
}
/* Force the fnode into read-write mode */
fnp->f_mode = RDWR;
/* determine what drive we are using... */
if (ParseDosName(dirname, &drive, (BYTE *) 0, (BYTE *) 0, (BYTE *) 0, FALSE)
!= SUCCESS)
if (ParseDosName
(dirname, &drive, (BYTE *) 0, (BYTE *) 0, (BYTE *) 0,
FALSE) != SUCCESS)
{
release_f_node(fnp);
return NULL;
@ -104,7 +107,8 @@ f_node_ptr dir_open(BYTE * dirname)
{
drive = default_drive;
}
if (drive >= lastdrive) {
if (drive >= lastdrive)
{
release_f_node(fnp);
return NULL;
}
@ -139,7 +143,7 @@ f_node_ptr dir_open(BYTE * dirname)
if (media_check(fnp->f_dpb) < 0)
{
release_f_node(fnp);
return (f_node_ptr)0;
return (f_node_ptr) 0;
}
/* Walk the directory tree to find the starting cluster */
@ -161,7 +165,7 @@ f_node_ptr dir_open(BYTE * dirname)
/* comparison... */
/* first the file name with trailing spaces... */
memset(TempBuffer, ' ', FNAME_SIZE+FEXT_SIZE);
memset(TempBuffer, ' ', FNAME_SIZE + FEXT_SIZE);
for (i = 0; i < FNAME_SIZE; i++)
{
@ -191,9 +195,12 @@ f_node_ptr dir_open(BYTE * dirname)
while (dir_read(fnp) == 1)
{
if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED)
if (fnp->f_dir.dir_name[0] != '\0'
&& fnp->f_dir.dir_name[0] != DELETED)
{
if (fcmp(TempBuffer, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE))
if (fcmp
(TempBuffer, (BYTE *) fnp->f_dir.dir_name,
FNAME_SIZE + FEXT_SIZE))
{
i = TRUE;
break;
@ -205,7 +212,7 @@ f_node_ptr dir_open(BYTE * dirname)
{
release_f_node(fnp);
return (f_node_ptr)0;
return (f_node_ptr) 0;
}
else
{
@ -250,7 +257,7 @@ COUNT dir_read(REG f_node_ptr fnp)
if (fnp->f_flags.f_droot)
{
if (new_diroff >= DIRENT_SIZE * (ULONG)fnp->f_dpb->dpb_dirents)
if (new_diroff >= DIRENT_SIZE * (ULONG) fnp->f_dpb->dpb_dirents)
return DE_SEEK;
bp = getblock((ULONG) (new_diroff / secsize
@ -294,7 +301,8 @@ COUNT dir_read(REG f_node_ptr fnp)
bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_VALID;
getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)new_diroff) % fnp->f_dpb->dpb_secsize],
getdirent((BYTE FAR *) & bp->
b_buffer[((UWORD) new_diroff) % fnp->f_dpb->dpb_secsize],
(struct dirent FAR *)&fnp->f_dir);
/* Update the fnode's directory info */
@ -328,8 +336,7 @@ BOOL dir_write(REG f_node_ptr fnp)
/* simple. */
if (fnp->f_flags.f_droot)
{
bp = getblock(
(ULONG) ((UWORD)fnp->f_diroff / secsize
bp = getblock((ULONG) ((UWORD) fnp->f_diroff / secsize
+ fnp->f_dpb->dpb_dirstrt),
fnp->f_dpb->dpb_unit);
#ifdef DISPLAY_GETBLOCK
@ -387,7 +394,8 @@ BOOL dir_write(REG f_node_ptr fnp)
if (fnp->f_flags.f_dnew && fnp->f_dir.dir_attrib != D_LFN)
fmemset(&fnp->f_dir.dir_case, 0, 8);
putdirent((struct dirent FAR *)&fnp->f_dir,
(VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]);
(VOID FAR *) & bp->b_buffer[(UWORD) fnp->f_diroff %
fnp->f_dpb->dpb_secsize]);
bp->b_flag &= ~(BFR_DATA | BFR_FAT);
bp->b_flag |= BFR_DIR | BFR_DIRTY | BFR_VALID;
@ -417,7 +425,7 @@ VOID dir_close(REG f_node_ptr fnp)
}
#ifndef IPL
COUNT dos_findfirst(UCOUNT attr, BYTE *name)
COUNT dos_findfirst(UCOUNT attr, BYTE * name)
{
REG f_node_ptr fnp;
REG dmatch *dmp = (dmatch *) TempBuffer;
@ -425,8 +433,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name)
COUNT nDrive;
BYTE *p;
BYTE local_name[FNAME_SIZE + 1],
local_ext[FEXT_SIZE + 1];
BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1];
/* printf("ff %Fs\n", name);*/
@ -438,7 +445,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name)
/* current directory, do a seek and read, then close the fnode. */
/* Parse out the drive, file name and file extension. */
i = ParseDosName(name, &nDrive, &szDirName[2], local_name, local_ext, TRUE);
i = ParseDosName(name, &nDrive, &szDirName[2], local_name, local_ext,
TRUE);
if (i != SUCCESS)
return i;
/*
@ -490,7 +498,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name)
/* Now initialize the dirmatch structure. */
nDrive=get_verify_drive(name);
nDrive = get_verify_drive(name);
if (nDrive < 0)
return nDrive;
dmp->dm_drive = nDrive;
@ -531,6 +539,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name)
return dos_findnext();
}
}
/*
BUGFIX TE 06/28/01
@ -547,7 +556,7 @@ COUNT dos_findnext(void)
BOOL found = FALSE;
/* Allocate an fnode if possible - error return (0) if not. */
if ((fnp = get_f_node()) == (f_node_ptr)0)
if ((fnp = get_f_node()) == (f_node_ptr) 0)
{
return DE_NFILES;
}
@ -572,7 +581,7 @@ COUNT dos_findnext(void)
/* seek first. */
if (dmp->dm_entry > 0)
{
fnp->f_diroff = (ULONG)(dmp->dm_entry - 1) * DIRENT_SIZE;
fnp->f_diroff = (ULONG) (dmp->dm_entry - 1) * DIRENT_SIZE;
fnp->f_flags.f_dnew = FALSE;
}
else
@ -586,9 +595,11 @@ COUNT dos_findnext(void)
{
++dmp->dm_entry;
if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED
&& (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID )
&& (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID)
{
if (fcmp_wild((BYTE FAR *)dmp->dm_name_pat, (BYTE FAR *)fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE))
if (fcmp_wild
((BYTE FAR *) dmp->dm_name_pat, (BYTE FAR *) fnp->f_dir.dir_name,
FNAME_SIZE + FEXT_SIZE))
{
/*
MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16.
@ -599,7 +610,8 @@ COUNT dos_findnext(void)
/* Test the attribute as the final step */
if (!(fnp->f_dir.dir_attrib & D_VOLID) &&
((~dmp->dm_attr_srch & fnp->f_dir.dir_attrib & (D_DIR | D_SYSTEM | D_HIDDEN)) == 0))
((~dmp->dm_attr_srch & fnp->f_dir.
dir_attrib & (D_DIR | D_SYSTEM | D_HIDDEN)) == 0))
{
found = TRUE;
break;
@ -632,7 +644,7 @@ COUNT dos_findnext(void)
so we have to work from the last blank backward
*/
void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName)
void ConvertName83ToNameSZ(BYTE FAR * destSZ, BYTE FAR * srcFCBName)
{
int loop;
int noExtension = FALSE;
@ -642,25 +654,21 @@ void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName)
noExtension = TRUE;
}
fmemcpy(destSZ,srcFCBName,FNAME_SIZE);
fmemcpy(destSZ, srcFCBName, FNAME_SIZE);
srcFCBName += FNAME_SIZE;
for (loop = FNAME_SIZE; --loop >= 0; )
for (loop = FNAME_SIZE; --loop >= 0;)
{
if (destSZ[loop] != ' ')
break;
}
destSZ += loop + 1;
if (!noExtension) /* not for ".", ".." */
{
for (loop = FEXT_SIZE; --loop >= 0; )
for (loop = FEXT_SIZE; --loop >= 0;)
{
if (srcFCBName[loop] != ' ')
break;
@ -668,8 +676,8 @@ void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName)
if (loop >= 0)
{
*destSZ++ = '.';
fmemcpy(destSZ,srcFCBName,loop+1);
destSZ += loop+1;
fmemcpy(destSZ, srcFCBName, loop + 1);
destSZ += loop + 1;
}
}
*destSZ = '\0';
@ -679,7 +687,7 @@ void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName)
returns the asciiSZ length of a 8.3 filename
*/
int FileName83Length(BYTE *filename83)
int FileName83Length(BYTE * filename83)
{
BYTE buff[13];
@ -777,4 +785,3 @@ int FileName83Length(BYTE *filename83)
* Rev 1.0 02 Jul 1995 8:04:34 patv
* Initial revision.
*/

View File

@ -59,18 +59,16 @@ BOOL first_fat(f_node_ptr);
COUNT map_cluster(f_node_ptr, COUNT);
STATIC VOID shrink_file(f_node_ptr fnp);
ULONG clus2phys(CLUSTER cl_no, struct dpb FAR *dpbp)
ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp)
{
CLUSTER data =
#ifdef WITHFAT32
ISFAT32(dpbp) ?
dpbp->dpb_xdata :
ISFAT32(dpbp) ? dpbp->dpb_xdata :
#endif
dpbp->dpb_data;
return ((ULONG)(cl_no - 2) << dpbp->dpb_shftcnt) + data;
return ((ULONG) (cl_no - 2) << dpbp->dpb_shftcnt) + data;
}
/************************************************************************/
/* */
/* Internal file handlers - open, create, read, write, close, etc. */
@ -160,7 +158,7 @@ COUNT dos_close(COUNT fd)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
return DE_INVLDHNDL;
if (fnp->f_flags.f_dmod)
@ -184,8 +182,7 @@ COUNT dos_close(COUNT fd)
/* */
/* split a path into it's component directory and file name */
/* */
f_node_ptr
split_path(BYTE * path, BYTE * fname, BYTE * fext)
f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext)
{
REG f_node_ptr fnp;
COUNT nDrive;
@ -194,7 +191,7 @@ f_node_ptr
/* Start off by parsing out the components. */
if (ParseDosName(path, &nDrive, &szDirName[2], fname, fext, FALSE)
!= SUCCESS)
return (f_node_ptr)0;
return (f_node_ptr) 0;
if (nDrive < 0)
nDrive = default_drive;
@ -205,8 +202,9 @@ f_node_ptr
SpacePad(fname, FNAME_SIZE);
SpacePad(fext, FEXT_SIZE);
if (nDrive >= lastdrive) {
return (f_node_ptr)0;
if (nDrive >= lastdrive)
{
return (f_node_ptr) 0;
}
cdsp = &CDSp->cds_table[nDrive];
@ -229,10 +227,11 @@ f_node_ptr
*/
#ifdef DEBUG
if (cdsp->cdsFlags & CDSNETWDRV) {
if (cdsp->cdsFlags & CDSNETWDRV)
{
printf("split path called for redirected file: `%s.%s'\n",
fname, fext);
return (f_node_ptr)0;
return (f_node_ptr) 0;
}
#endif
@ -242,10 +241,10 @@ f_node_ptr
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit... */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
{
dir_close(fnp);
return (f_node_ptr)0;
return (f_node_ptr) 0;
}
/* Convert the name into an absolute name for comparison... */
@ -267,8 +266,8 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext)
if (fnp->f_dir.dir_name[0] == DELETED)
continue;
if (fcmp(fname, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE)
&& fcmp(fext, (BYTE *)fnp->f_dir.dir_ext, FEXT_SIZE)
if (fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE)
&& fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE)
&& ((fnp->f_dir.dir_attrib & D_VOLID) == 0))
{
found = TRUE;
@ -293,9 +292,11 @@ COUNT remove_lfn_entries(f_node_ptr fnp)
ULONG original_diroff = fnp->f_diroff;
COUNT rc;
while (TRUE) {
if(fnp->f_diroff == 0) break;
fnp->f_diroff -= 2*DIRENT_SIZE;
while (TRUE)
{
if (fnp->f_diroff == 0)
break;
fnp->f_diroff -= 2 * DIRENT_SIZE;
/* it cannot / should not get below 0 because of '.' and '..' */
if ((rc = dir_read(fnp)) < 0)
return rc;
@ -310,6 +311,7 @@ COUNT remove_lfn_entries(f_node_ptr fnp)
return rc;
return SUCCESS;
}
/* /// Added - Ron Cemer */
/* If more than one f_node has a file open, and a write
occurs, this function must be called to propagate the
@ -319,26 +321,33 @@ COUNT remove_lfn_entries(f_node_ptr fnp)
reasons, since DOS without SHARE does not share changes
between two or more open instances of the same file
unless these instances were generated by dup() or dup2(). */
STATIC void merge_file_changes(f_node_ptr fnp, int collect) {
STATIC void merge_file_changes(f_node_ptr fnp, int collect)
{
f_node_ptr fnp2;
int i;
if (!IsShareInstalled()) return;
for (i = 0; i < f_nodes_cnt; i++) {
fnp2 = (f_node_ptr)&f_nodes[i];
if ( (fnp != (f_node_ptr)0)
if (!IsShareInstalled())
return;
for (i = 0; i < f_nodes_cnt; i++)
{
fnp2 = (f_node_ptr) & f_nodes[i];
if ((fnp != (f_node_ptr) 0)
&& (fnp != fnp2)
&& (fnp->f_count > 0)
&& (is_same_file(fnp, fnp2)) ) {
if (collect) {
&& (fnp->f_count > 0) && (is_same_file(fnp, fnp2)))
{
if (collect)
{
/* We're collecting file changes from any other
f_node which refers to this file. */
if (fnp2->f_mode != RDONLY) {
if (fnp2->f_mode != RDONLY)
{
fnp2->f_dir.dir_size = fnp2->f_highwater;
copy_file_changes(fnp2, fnp);
break;
}
} else {
}
else
{
/* We just made changes to this file, so we are
distributing these changes to the other f_nodes
which refer to this file. */
@ -351,16 +360,17 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect) {
}
/* /// Added - Ron Cemer */
STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) {
STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2)
{
return
(fnp1->f_dpb->dpb_unit == fnp2->f_dpb->dpb_unit)
&& (fnp1->f_dpb->dpb_subunit == fnp2->f_dpb->dpb_subunit)
&& (fcmp
((BYTE *)fnp1->f_dir.dir_name,
(BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE))
((BYTE *) fnp1->f_dir.dir_name,
(BYTE *) fnp2->f_dir.dir_name, FNAME_SIZE))
&& (fcmp
((BYTE *)fnp1->f_dir.dir_ext,
(BYTE *)fnp2->f_dir.dir_ext, FEXT_SIZE))
((BYTE *) fnp1->f_dir.dir_ext,
(BYTE *) fnp2->f_dir.dir_ext, FEXT_SIZE))
&& ((fnp1->f_dir.dir_attrib & D_VOLID) == 0)
&& ((fnp2->f_dir.dir_attrib & D_VOLID) == 0)
&& (fnp1->f_diroff == fnp2->f_diroff)
@ -369,7 +379,8 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) {
}
/* /// Added - Ron Cemer */
STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) {
STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst)
{
dst->f_highwater = src->f_highwater;
dst->f_dir.dir_start = src->f_dir.dir_start;
#ifdef WITHFAT32
@ -489,7 +500,7 @@ STATIC COUNT delete_dir_entry(f_node_ptr fnp)
/* Ok, so we can delete. Start out by */
/* clobbering all FAT entries for this file */
/* (or, in English, truncate the FAT). */
if ((rc=remove_lfn_entries(fnp)) < 0)
if ((rc = remove_lfn_entries(fnp)) < 0)
return rc;
wipe_out(fnp);
@ -571,7 +582,7 @@ COUNT dos_rmdir(BYTE * path)
/* directories may have attributes, too. at least my WinNT disk
has many 'archive' directories
we still don't allow RDONLY directories to be deleted TE*/
we still don't allow RDONLY directories to be deleted TE */
/* if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE|D_SYSTEM))
{
@ -604,7 +615,8 @@ COUNT dos_rmdir(BYTE * path)
{
if (fnp1->f_dir.dir_name[0] == '\0')
break;
if (fnp1->f_dir.dir_name[0] == DELETED || fnp1->f_dir.dir_attrib == D_LFN)
if (fnp1->f_dir.dir_name[0] == DELETED
|| fnp1->f_dir.dir_attrib == D_LFN)
continue;
else
{
@ -693,7 +705,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2)
}
}
if ((ret=remove_lfn_entries(fnp1)) < 0)
if ((ret = remove_lfn_entries(fnp1)) < 0)
return ret;
/* put the fnode's name into the directory. */
@ -731,7 +743,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2)
/* */
/* wipe out all FAT entries starting from st for create, delete, etc. */
/* */
STATIC VOID wipe_out_clusters(struct dpb FAR *dpbp, CLUSTER st)
STATIC VOID wipe_out_clusters(struct dpb FAR * dpbp, CLUSTER st)
{
REG CLUSTER next;
@ -754,20 +766,20 @@ STATIC VOID wipe_out_clusters(struct dpb FAR *dpbp, CLUSTER st)
#ifdef WITHFAT32
if (ISFAT32(dpbp))
{
if ((dpbp->dpb_xcluster == UNKNCLUSTER)
|| (dpbp->dpb_xcluster > st))
if ((dpbp->dpb_xcluster == UNKNCLUSTER) || (dpbp->dpb_xcluster > st))
dpbp->dpb_xcluster = st;
} else
}
else
#endif
if ((dpbp->dpb_cluster == UNKNCLUSTER)
|| (dpbp->dpb_cluster > st))
if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st))
dpbp->dpb_cluster = st;
/* and just follow the linked list */
st = next;
}
#ifdef WITHFAT32
if (ISFAT32(dpbp)) write_fsinfo(dpbp);
if (ISFAT32(dpbp))
write_fsinfo(dpbp);
#endif
}
@ -799,9 +811,7 @@ STATIC BOOL find_free(f_node_ptr fnp)
date dos_getdate()
{
#ifndef NOTIME
BYTE WeekDay,
Month,
MonthDay;
BYTE WeekDay, Month, MonthDay;
COUNT Year;
date Date;
@ -809,8 +819,7 @@ date dos_getdate()
/* on start-up or the CMOS clock */
DosGetDate((BYTE FAR *) & WeekDay,
(BYTE FAR *) & Month,
(BYTE FAR *) & MonthDay,
(COUNT FAR *) & Year);
(BYTE FAR *) & MonthDay, (COUNT FAR *) & Year);
Date = DT_ENCODE(Month, MonthDay, Year - EPOCH_YEAR);
return Date;
@ -827,18 +836,14 @@ date dos_getdate()
time dos_gettime()
{
#ifndef NOTIME
BYTE Hour,
Minute,
Second,
Hundredth;
BYTE Hour, Minute, Second, Hundredth;
/* First - get the system time set by either the user */
/* on start-up or the CMOS clock */
DosGetTime((BYTE FAR *) & Hour,
(BYTE FAR *) & Minute,
(BYTE FAR *) & Second,
(BYTE FAR *) & Hundredth);
return TM_ENCODE(Hour, Minute, Second/2);
(BYTE FAR *) & Second, (BYTE FAR *) & Hundredth);
return TM_ENCODE(Hour, Minute, Second / 2);
#else
return 0;
#endif
@ -858,7 +863,7 @@ COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
return DE_INVLDHNDL;
/* Get the date and time from the fnode and return */
@ -882,7 +887,7 @@ COUNT dos_setftime(COUNT fd, date dp, time tp)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
return DE_INVLDHNDL;
/* Set the date and time from the fnode and return */
@ -908,7 +913,7 @@ LONG dos_getcufsize(COUNT fd)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
return -1l;
/* Return the file size */
@ -929,7 +934,7 @@ LONG dos_getfsize(COUNT fd)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
return -1l;
/* Return the file size */
@ -950,7 +955,7 @@ BOOL dos_setfsize(COUNT fd, LONG size)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
return FALSE;
/* Change the file size */
@ -984,7 +989,8 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp)
if (dpbp->dpb_xcluster != UNKNCLUSTER)
idx = dpbp->dpb_xcluster;
size = dpbp->dpb_xsize;
} else
}
else
#endif
if (dpbp->dpb_cluster != UNKNCLUSTER)
idx = dpbp->dpb_cluster;
@ -1061,7 +1067,7 @@ COUNT dos_mkdir(BYTE * dir)
can create an unlimited amount of same dirs. this space
is lost forever
*/
if (strlen(dir) > PARSE_MAX+2) /* dir is already output of "truename" */
if (strlen(dir) > PARSE_MAX + 2) /* dir is already output of "truename" */
{
dir_close(fnp);
return DE_PATHNOTFND;
@ -1101,7 +1107,6 @@ COUNT dos_mkdir(BYTE * dir)
return ret;
}
/* get an empty cluster, so that we make it into a */
/* directory. */
/* TE this has to be done (and failed) BEFORE the dir entry */
@ -1116,7 +1121,6 @@ COUNT dos_mkdir(BYTE * dir)
return DE_HNDLDSKFULL;
}
/* put the fnode's name into the directory. */
memcpy(fnp->f_dir.dir_name, szFileName, FNAME_SIZE);
memcpy(fnp->f_dir.dir_ext, szFileExt, FEXT_SIZE);
@ -1137,7 +1141,6 @@ COUNT dos_mkdir(BYTE * dir)
fnp->f_highwater = 0l;
fnp->f_offset = 0l;
/* Mark the cluster in the FAT as used */
fnp->f_cluster = free_fat;
setdstart(fnp->f_dir, free_fat);
@ -1147,8 +1150,7 @@ COUNT dos_mkdir(BYTE * dir)
/* Craft the new directory. Note that if we're in a new */
/* directory just under the root, ".." pointer is 0. */
/* as we are overwriting it completely, don't read first */
bp = getblockOver(clus2phys(free_fat, dpbp),
dpbp->dpb_unit);
bp = getblockOver(clus2phys(free_fat, dpbp), dpbp->dpb_unit);
#ifdef DISPLAY_GETBLOCK
printf("FAT (dos_mkdir)\n");
#endif
@ -1173,17 +1175,19 @@ COUNT dos_mkdir(BYTE * dir)
/* create the ".." entry */
memcpy(DirEntBuffer.dir_name, ".. ", FNAME_SIZE);
#ifdef WITHFAT32
if (ISFAT32(dpbp) && parent == dpbp->dpb_xrootclst) {
if (ISFAT32(dpbp) && parent == dpbp->dpb_xrootclst)
{
parent = 0;
}
#endif
setdstart(DirEntBuffer, parent);
/* and put it out */
putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]);
putdirent((struct dirent FAR *)&DirEntBuffer,
(BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]);
/* fill the rest of the block with zeros */
fmemset( & bp->b_buffer[2 * DIRENT_SIZE],0, BUFFERSIZE - 2 * DIRENT_SIZE);
fmemset(&bp->b_buffer[2 * DIRENT_SIZE], 0, BUFFERSIZE - 2 * DIRENT_SIZE);
/* Mark the block to be written out */
bp->b_flag |= BFR_DIRTY | BFR_VALID;
@ -1270,7 +1274,8 @@ STATIC COUNT extend_dir(f_node_ptr fnp)
#ifdef DISPLAY_GETBLOCK
printf("DIR (extend_dir)\n");
#endif
if (bp == NULL) {
if (bp == NULL)
{
dir_close(fnp);
return DE_BLKINVLD;
}
@ -1351,7 +1356,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode)
#endif
/* The variable clssize will be used later. */
clssize = (ULONG)fnp->f_dpb->dpb_secsize << fnp->f_dpb->dpb_shftcnt;
clssize = (ULONG) fnp->f_dpb->dpb_secsize << fnp->f_dpb->dpb_shftcnt;
/* If someone did a seek, but no writes have occured, we will */
/* need to initialize the fnode. */
@ -1461,7 +1466,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode)
the same should be done for writes as well
the time to compile the complete kernel (on some P200) is
reduced from 67 to 56 seconds - in an otherwise identical configuration.
@ -1487,7 +1491,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode)
*/
/* Read block from disk */
UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
{
@ -1513,7 +1516,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
{
*err = DE_INVLDHNDL;
return 0;
@ -1556,8 +1559,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
{
/* Do an EOF test and return whatever was transferred */
/* but only for regular files. */
if (!(fnp->f_flags.f_ddir)
&& (fnp->f_offset >= fnp->f_highwater))
if (!(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_highwater))
{
*err = SUCCESS;
return ret_cnt;
@ -1605,16 +1607,16 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
/* see comments above */
if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */
fnp->f_boff == 0 ) /* complete sectors only */
fnp->f_boff == 0) /* complete sectors only */
{
static ULONG startoffset;
UCOUNT sectors_to_read,sectors_wanted;
UCOUNT sectors_to_read, sectors_wanted;
startoffset = fnp->f_offset;
/* avoid EOF problems */
sectors_wanted = ((UCOUNT) min(fnp->f_highwater - fnp->f_offset, to_xfer)) /
sectors_wanted =
((UCOUNT) min(fnp->f_highwater - fnp->f_offset, to_xfer)) /
secsize;
if (sectors_wanted < 2)
@ -1624,21 +1626,22 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
sectors_to_read = min(sectors_to_read, sectors_wanted);
fnp->f_offset += sectors_to_read*secsize;
fnp->f_offset += sectors_to_read * secsize;
while (sectors_to_read < sectors_wanted)
{
if (map_cluster(fnp, XFR_READ) != SUCCESS)
break;
if (clus2phys(fnp->f_cluster, fnp->f_dpb) != currentblock + sectors_to_read)
if (clus2phys(fnp->f_cluster, fnp->f_dpb) !=
currentblock + sectors_to_read)
break;
sectors_to_read += fnp->f_dpb->dpb_clsmask + 1;
sectors_to_read = min(sectors_to_read, sectors_wanted);
fnp->f_offset = startoffset + sectors_to_read*secsize;
fnp->f_offset = startoffset + sectors_to_read * secsize;
}
@ -1659,28 +1662,21 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
return ret_cnt;
}
goto update_pointers;
}
/* normal read: just the old, buffer = sector based read */
normal_read:
normal_read:
#ifdef DSK_DEBUG
printf("read %d links; dir offset %ld, cluster %lx\n",
fnp->f_count,
fnp->f_diroff,
fnp->f_cluster);
fnp->f_count, fnp->f_diroff, fnp->f_cluster);
#endif
/* Get the block we need from cache */
bp = getblock(currentblock /*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector*/,
fnp->f_dpb->dpb_unit);
bp = getblock(currentblock
/*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector */
, fnp->f_dpb->dpb_unit);
#ifdef DISPLAY_GETBLOCK
printf("DATA (readblock)\n");
@ -1699,7 +1695,7 @@ normal_read:
if (fnp->f_flags.f_ddir)
xfr_cnt = min(to_xfer, secsize - fnp->f_boff);
else
xfr_cnt = (UWORD)min(min(to_xfer, secsize - fnp->f_boff),
xfr_cnt = (UWORD) min(min(to_xfer, secsize - fnp->f_boff),
fnp->f_highwater - fnp->f_offset);
fmemcpy(buffer, &bp->b_buffer[fnp->f_boff], xfr_cnt);
@ -1708,16 +1704,15 @@ normal_read:
probably not reused later
*/
if (xfr_cnt == sizeof(bp->b_buffer) ||
fnp->f_offset + xfr_cnt == fnp->f_highwater )
fnp->f_offset + xfr_cnt == fnp->f_highwater)
{
bp->b_flag |= BFR_UNCACHE;
}
/* update pointers and counters */
fnp->f_offset += xfr_cnt;
update_pointers:
update_pointers:
ret_cnt += xfr_cnt;
to_xfer -= xfr_cnt;
buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt);
@ -1750,43 +1745,42 @@ STATIC COUNT dos_extend(f_node_ptr fnp)
count = fnp->f_offset - fnp->f_highwater;
fnp->f_offset = fnp->f_highwater;
while (count > 0)
{
#endif
{
if (map_cluster(fnp, XFR_WRITE) != SUCCESS)
return DE_HNDLDSKFULL;
#ifdef WRITEZEROS
/* Compute the block within the cluster and the offset */
/* within the block. */
fnp->f_sector =
(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_boff = fnp->f_offset & (secsize - 1);
#ifdef DSK_DEBUG
printf("write %d links; dir offset %ld, cluster %d\n",
fnp->f_count,
fnp->f_diroff,
fnp->f_cluster);
fnp->f_count, fnp->f_diroff, fnp->f_cluster);
#endif
xfr_cnt = count < (ULONG)secsize - fnp->f_boff ?
(UWORD) count :
secsize - fnp->f_boff;
xfr_cnt = count < (ULONG) secsize - fnp->f_boff ?
(UWORD) count : secsize - fnp->f_boff;
/* get a buffer to store the block in */
if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) {
bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
fnp->f_dpb->dpb_unit);
if ((fnp->f_boff == 0) && (xfr_cnt == secsize))
{
bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) +
fnp->f_sector, fnp->f_dpb->dpb_unit);
} else {
}
else
{
bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
fnp->f_dpb->dpb_unit);
}
if (bp == NULL) {
if (bp == NULL)
{
return DE_BLKINVLD;
}
/* set a block to zero */
fmemset((BYTE FAR *) & bp->b_buffer[fnp->f_boff], 0, xfr_cnt);
bp->b_flag |= BFR_DIRTY | BFR_VALID;
@ -1799,14 +1793,11 @@ STATIC COUNT dos_extend(f_node_ptr fnp)
/* update pointers and counters */
count -= xfr_cnt;
fnp->f_offset += xfr_cnt;
fnp->f_dir.dir_size = fnp->f_offset;
#endif
fnp->f_highwater = fnp->f_offset;
fnp->f_dir.dir_size = fnp->f_highwater;
merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */
}
#else
fnp->f_highwater = fnp->f_offset;
merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */
#endif
return SUCCESS;
}
@ -1835,7 +1826,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
{
*err = DE_INVLDHNDL;
return 0;
@ -1948,15 +1939,12 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
/* Compute the block within the cluster and the offset */
/* within the block. */
fnp->f_sector =
(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
fnp->f_boff = fnp->f_offset & (secsize - 1);
#ifdef DSK_DEBUG
printf("write %d links; dir offset %ld, cluster %d\n",
fnp->f_count,
fnp->f_diroff,
fnp->f_cluster);
fnp->f_count, fnp->f_diroff, fnp->f_cluster);
#endif
/* /// Moved xfr_cnt calculation from below so we can
@ -1980,20 +1968,23 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
piping and redirection in FreeCOM, as well as many other
potential problems.
- Ron Cemer */
if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) {
bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
fnp->f_dpb->dpb_unit);
if ((fnp->f_boff == 0) && (xfr_cnt == secsize))
{
bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) +
fnp->f_sector, fnp->f_dpb->dpb_unit);
} else {
bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
fnp->f_dpb->dpb_unit);
}
if (bp == NULL) {
else
{
bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) +
fnp->f_sector, fnp->f_dpb->dpb_unit);
}
if (bp == NULL)
{
*err = DE_BLKINVLD;
return ret_cnt;
}
/* transfer a block */
/* Transfer size as either a full block size, or the */
/* requested transfer size, whichever is smaller. */
@ -2012,7 +2003,6 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
bp->b_flag |= BFR_UNCACHE;
}
/* update pointers and counters */
ret_cnt += xfr_cnt;
to_xfer -= xfr_cnt;
@ -2043,7 +2033,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin)
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr)0 || fnp->f_count <= 0)
if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0)
return (LONG) DE_INVLDHNDL;
/* now do the actual lseek adjustment to the file poitner */
@ -2069,7 +2059,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin)
}
/* returns the number of unused clusters */
CLUSTER dos_free(struct dpb FAR *dpbp)
CLUSTER dos_free(struct dpb FAR * dpbp)
{
/* There's an unwritten rule here. All fs */
/* cluster start at 2 and run to max_cluster+2 */
@ -2095,7 +2085,8 @@ CLUSTER dos_free(struct dpb FAR *dpbp)
++cnt;
}
#ifdef WITHFAT32
if (ISFAT32(dpbp)) {
if (ISFAT32(dpbp))
{
dpbp->dpb_xnfreeclst = cnt;
write_fsinfo(dpbp);
return cnt;
@ -2105,10 +2096,8 @@ CLUSTER dos_free(struct dpb FAR *dpbp)
return cnt;
}
#ifndef IPL
COUNT dos_cd(struct cds FAR * cdsp, BYTE *PathName)
COUNT dos_cd(struct cds FAR * cdsp, BYTE * PathName)
{
f_node_ptr fnp;
@ -2143,7 +2132,7 @@ f_node_ptr get_f_node(void)
return &f_nodes[i];
}
}
return (f_node_ptr)0;
return (f_node_ptr) 0;
}
VOID release_f_node(f_node_ptr fnp)
@ -2171,7 +2160,7 @@ COUNT dos_getfattr(BYTE * name)
return DE_FILENOTFND;
/* note: an invalid fd is indicated by a 0 return */
if ((fnp = xlt_fd(fd)) == (f_node_ptr)0)
if ((fnp = xlt_fd(fd)) == (f_node_ptr) 0)
return DE_TOOMANY;
/* If the fd was invalid because it was out of range or the */
@ -2199,7 +2188,7 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp)
return DE_FILENOTFND;
/* note: an invalid fd is indicated by a 0 return */
if ((fnp = xlt_fd(fd)) == (f_node_ptr)0)
if ((fnp = xlt_fd(fd)) == (f_node_ptr) 0)
return DE_TOOMANY;
/* If the fd was invalid because it was out of range or the */
@ -2230,9 +2219,9 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp)
#endif
#ifdef WITHFAT32
VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp, BOOL extended)
VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended)
#else
VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp)
VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp)
#endif
{
ULONG size;
@ -2244,16 +2233,13 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp)
dpbp->dpb_fatstrt = bpbp->bpb_nreserved;
dpbp->dpb_fats = bpbp->bpb_nfat;
dpbp->dpb_dirents = bpbp->bpb_ndirent;
size = bpbp->bpb_nsize == 0 ?
bpbp->bpb_huge :
(ULONG) bpbp->bpb_nsize;
size = bpbp->bpb_nsize == 0 ? bpbp->bpb_huge : (ULONG) bpbp->bpb_nsize;
dpbp->dpb_fatsize = bpbp->bpb_nfsect;
dpbp->dpb_dirstrt = dpbp->dpb_fatstrt
+ dpbp->dpb_fats * dpbp->dpb_fatsize;
dpbp->dpb_data = dpbp->dpb_dirstrt
+ ((DIRENT_SIZE * (ULONG)dpbp->dpb_dirents
+ (dpbp->dpb_secsize - 1))
/ dpbp->dpb_secsize);
+ ((DIRENT_SIZE * (ULONG) dpbp->dpb_dirents
+ (dpbp->dpb_secsize - 1)) / dpbp->dpb_secsize);
/* Michal Meller <maceman@priv4,onet.pl> patch to jimtabor */
dpbp->dpb_size = ((size - dpbp->dpb_data)
/ ((ULONG) bpbp->bpb_nsector) + 1);
@ -2285,9 +2271,10 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp)
dpbp->dpb_dirents = 0;
dpbp->dpb_dirstrt = 0xffff;
dpbp->dpb_size = 0;
dpbp->dpb_xdata = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize;
dpbp->dpb_xsize = ((size - dpbp->dpb_xdata)
/ ((ULONG) bpbp->bpb_nsector) + 1);
dpbp->dpb_xdata =
dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize;
dpbp->dpb_xsize =
((size - dpbp->dpb_xdata) / ((ULONG) bpbp->bpb_nsector) + 1);
dpbp->dpb_xrootclst = bpbp->bpb_xrootclst;
read_fsinfo(dpbp);
}
@ -2310,7 +2297,8 @@ COUNT media_check(REG struct dpb FAR * dpbp)
MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb;
MediaReqHdr.r_status = 0;
execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device);
if (!(MediaReqHdr.r_status & S_ERROR) && (MediaReqHdr.r_status & S_DONE))
if (!(MediaReqHdr.r_status & S_ERROR)
&& (MediaReqHdr.r_status & S_DONE))
break;
else
{
@ -2357,12 +2345,14 @@ COUNT media_check(REG struct dpb FAR * dpbp)
MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb;
MediaReqHdr.r_status = 0;
execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device);
if (!(MediaReqHdr.r_status & S_ERROR) && (MediaReqHdr.r_status & S_DONE))
if (!(MediaReqHdr.r_status & S_ERROR)
&& (MediaReqHdr.r_status & S_DONE))
break;
else
{
loop2:
switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device))
switch (block_error
(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device))
{
case ABORT:
case FAIL:
@ -2391,13 +2381,13 @@ COUNT media_check(REG struct dpb FAR * dpbp)
/* translate the fd into an f_node pointer */
f_node_ptr xlt_fd(COUNT fd)
{
return fd >= f_nodes_cnt ? (f_node_ptr)0 : &f_nodes[fd];
return fd >= f_nodes_cnt ? (f_node_ptr) 0 : &f_nodes[fd];
}
/* translate the f_node pointer into an fd */
COUNT xlt_fnp(f_node_ptr fnp)
{
return (COUNT)(fnp - f_nodes);
return (COUNT) (fnp - f_nodes);
}
#if 0
@ -2411,7 +2401,6 @@ struct dhdr FAR *select_unit(COUNT drive)
}
#endif
/* TE
if the current filesize in FAT is larger then the dir_size
it's truncated here.
@ -2431,12 +2420,13 @@ STATIC VOID shrink_file(f_node_ptr fnp)
{
ULONG lastoffset = fnp->f_offset; /* has to be saved */
CLUSTER next,st;
CLUSTER next, st;
struct dpb FAR *dpbp = fnp->f_dpb;
fnp->f_offset = fnp->f_highwater; /* end of file */
if (fnp->f_offset) fnp->f_offset--; /* last existing cluster */
if (fnp->f_offset)
fnp->f_offset--; /* last existing cluster */
if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */
goto done;
@ -2453,7 +2443,6 @@ STATIC VOID shrink_file(f_node_ptr fnp)
/* last cluster is encountered. */
/* zap the FAT pointed to */
if (fnp->f_highwater == 0)
{
setdstart(fnp->f_dir, FREE);
@ -2461,7 +2450,7 @@ STATIC VOID shrink_file(f_node_ptr fnp)
}
else
{
link_fat(dpbp, st,LONG_LAST_CLUSTER);
link_fat(dpbp, st, LONG_LAST_CLUSTER);
}
wipe_out_clusters(dpbp, next);
@ -2617,4 +2606,3 @@ done:
* Rev 1.0 02 Jul 1995 8:04:46 patv
* Initial revision.
*/

View File

@ -30,7 +30,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
#ifdef PROTO
@ -56,14 +57,13 @@ CLUSTER next_cl32();
/************************************************************************/
#ifndef ISFAT32
int ISFAT32(struct dpb FAR *dpbp)
int ISFAT32(struct dpb FAR * dpbp)
{
return _ISFAT32(dpbp);
}
#endif
struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp)
struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR * dpbp)
{
ULONG sector;
struct buffer FAR *bp;
@ -75,16 +75,17 @@ struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp)
#ifdef WITHFAT32
else if (ISFAT32(dpbp))
{
sector = (ULONG)cluster * SIZEOF_CLST32;
sector = (ULONG) cluster *SIZEOF_CLST32;
}
#endif
else
{
sector = (ULONG)cluster * SIZEOF_CLST16;
sector = (ULONG) cluster *SIZEOF_CLST16;
}
sector = sector / dpbp->dpb_secsize + dpbp->dpb_fatstrt;
#ifdef WITHFAT32
if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) {
if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING))
{
/* we must modify the active fat,
it's number is in the 0-3 bits of dpb_xflags */
sector += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_xfatsize;
@ -112,7 +113,7 @@ struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp)
}
#ifdef WITHFAT32
void read_fsinfo(struct dpb FAR *dpbp)
void read_fsinfo(struct dpb FAR * dpbp)
{
struct buffer FAR *bp;
struct fsinfo FAR *fip;
@ -121,12 +122,12 @@ void read_fsinfo(struct dpb FAR *dpbp)
bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT | BFR_DIRTY);
bp->b_flag |= BFR_VALID;
fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4];
fip = (struct fsinfo FAR *)&bp->b_buffer[0x1e4];
dpbp->dpb_xnfreeclst = fip->fi_nfreeclst;
dpbp->dpb_xcluster = fip->fi_cluster;
}
void write_fsinfo(struct dpb FAR *dpbp)
void write_fsinfo(struct dpb FAR * dpbp)
{
struct buffer FAR *bp;
struct fsinfo FAR *fip;
@ -135,7 +136,7 @@ void write_fsinfo(struct dpb FAR *dpbp)
bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT);
bp->b_flag |= BFR_VALID | BFR_DIRTY;
fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4];
fip = (struct fsinfo FAR *)&bp->b_buffer[0x1e4];
fip->fi_nfreeclst = dpbp->dpb_xnfreeclst;
fip->fi_cluster = dpbp->dpb_xcluster;
}
@ -157,7 +158,8 @@ void write_fsinfo(struct dpb FAR *dpbp)
/* 12 bytes are compressed to 9 bytes */
/* */
UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2)
UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1,
REG CLUSTER Cluster2)
{
UCOUNT res;
@ -172,7 +174,6 @@ UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2)
else
return DE_BLKINVLD;
/* update the free space count */
if (res == SUCCESS && Cluster2 == FREE)
@ -184,7 +185,8 @@ UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2)
/* cluster */
++dpbp->dpb_xnfreeclst;
write_fsinfo(dpbp);
} else
}
else
#endif
if (dpbp->dpb_nfreeclst != UNKNCLSTFREE)
++dpbp->dpb_nfreeclst;
@ -195,7 +197,7 @@ UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2)
/* update the free space count for returned */
/* cluster */
/* ++dpbp->dpb_nfreeclst;
}*/
} */
/* update the free space count for removed */
/* cluster */
@ -210,7 +212,8 @@ UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2)
}
#ifdef WITHFAT32
UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1,
CLUSTER Cluster2)
{
UCOUNT idx;
struct buffer FAR *bp;
@ -223,7 +226,7 @@ UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
/* form an index so that we can read the block as a */
/* byte array */
idx = (UWORD)((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize);
idx = (UWORD) ((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize);
/* Finally, put the word into the buffer and mark the */
/* buffer as dirty. */
@ -237,7 +240,8 @@ UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
#endif
UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1,
CLUSTER Cluster2)
{
UCOUNT idx;
struct buffer FAR *bp;
@ -250,7 +254,7 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
/* form an index so that we can read the block as a */
/* byte array */
idx = (UWORD)(( Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize);
idx = (UWORD) ((Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize);
/* Finally, put the word into the buffer and mark the */
/* buffer as dirty. */
@ -262,22 +266,21 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
return SUCCESS;
}
UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1,
CLUSTER Cluster2)
{
REG UBYTE FAR *fbp0,
FAR * fbp1;
REG UBYTE FAR *fbp0, FAR * fbp1;
UCOUNT idx;
struct buffer FAR *bp,
FAR * bp1;
struct buffer FAR *bp, FAR * bp1;
/* Get the block that this cluster is in */
bp = getFATblock(Cluster1 , dpbp);
bp = getFATblock(Cluster1, dpbp);
if (bp == NULL)
return DE_BLKINVLD;
/* form an index so that we can read the block as a */
/* byte array */
idx = (UCOUNT)(((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize;
idx = (UCOUNT) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize;
/* Test to see if the cluster straddles the block. If */
/* it does, get the next block and use both to form the */
@ -285,7 +288,7 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
/* block. */
if (idx >= dpbp->dpb_secsize - 1)
{
bp1 = getFATblock(Cluster1 + 1,dpbp);
bp1 = getFATblock(Cluster1 + 1, dpbp);
if (bp1 == 0)
return DE_BLKINVLD;
@ -315,12 +318,14 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2)
/* Given the disk parameters, and a cluster number, this function
looks at the FAT, and returns the next cluster in the clain. */
CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum)
CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum)
{
struct buffer FAR *bp;
#ifdef DEBUG
if (ClusterNum == LONG_LAST_CLUSTER) printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n");
if (ClusterNum == 0) printf("fatal error: trying to do next_cluster(dpbp, 0)!\n");
if (ClusterNum == LONG_LAST_CLUSTER)
printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n");
if (ClusterNum == 0)
printf("fatal error: trying to do next_cluster(dpbp, 0)!\n");
#endif
/* Get the block that this cluster is in */
@ -340,11 +345,13 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum)
/* form an index so that we can read the block as a */
/* byte array */
idx = (UCOUNT)(((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize;
idx =
(UCOUNT) (((ClusterNum << 1) +
ClusterNum) >> 1) % dpbp->dpb_secsize;
clusterbuff.bytes[0] = bp->b_buffer[idx];
clusterbuff.bytes[1] = bp->b_buffer[idx+1]; /* next byte, will be overwritten,
clusterbuff.bytes[1] = bp->b_buffer[idx + 1]; /* next byte, will be overwritten,
if not valid */
/* Test to see if the cluster straddles the block. If it */
@ -353,7 +360,7 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum)
/* block. */
if (idx >= dpbp->dpb_secsize - 1)
{
bp = getFATblock(ClusterNum +1, dpbp);
bp = getFATblock(ClusterNum + 1, dpbp);
if (bp == 0)
return LONG_BAD;
@ -366,7 +373,8 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum)
#ifndef I86 /* the latter assumes byte ordering */
if (ClusterNum & 0x01)
idx = ((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4);
idx =
((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4);
else
idx = clusterbuff.byte[0] | ((clusterbuff.byte[0] & 0x0f) << 8);
#else
@ -401,10 +409,16 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum)
#else
/* this saves 2 WORDS of stack :-) */
res = *(UWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize)]);
res =
*(UWORD FAR *) & (bp->
b_buffer[(UCOUNT)
((ClusterNum * SIZEOF_CLST16) %
dpbp->dpb_secsize)]);
#endif
if (res >= MASK16) return LONG_LAST_CLUSTER;
if (res == BAD16) return LONG_BAD;
if (res >= MASK16)
return LONG_LAST_CLUSTER;
if (res == BAD16)
return LONG_BAD;
return res;
}
@ -413,8 +427,13 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum)
{
UDWORD res;
res = *(UDWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST32) % dpbp->dpb_secsize)]);
if (res > LONG_BAD) return LONG_LAST_CLUSTER;
res =
*(UDWORD FAR *) & (bp->
b_buffer[(UCOUNT)
((ClusterNum * SIZEOF_CLST32) %
dpbp->dpb_secsize)]);
if (res > LONG_BAD)
return LONG_LAST_CLUSTER;
return res;
}
@ -477,6 +496,3 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum)
* Rev 1.0 02 Jul 1995 8:04:56 patv
* Initial revision.
*/

View File

@ -30,7 +30,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
#define FCB_SUCCESS 0
@ -41,7 +42,8 @@ static BYTE *RcsId = "$Id$";
#ifdef PROTO
fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb);
fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive);
fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer,
COUNT * pCurDrive);
void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive);
VOID FcbNextRecord(fcb FAR * lpFcb);
BOOL FcbCalcRec(xfcb FAR * lpXfcb);
@ -56,7 +58,6 @@ BOOL FcbCalcRec();
#define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL)
#define TestFieldSeps(lpFileName) (*(lpFileName) <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL)
static dmatch Dmatch;
VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps,
@ -66,9 +67,9 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps,
/* get the data available from dpb */
*nc = 0xffff; /* pass 0xffff to skip free count */
if (DosGetFree((UBYTE)drive, spc, &navc, bps, nc))
if (DosGetFree((UBYTE) drive, spc, &navc, bps, nc))
/* Point to the media desctriptor for this drive */
*mdp = (BYTE FAR*)&(CDSp->cds_table[drive].cdsDpb->dpb_mdb);
*mdp = (BYTE FAR *) & (CDSp->cds_table[drive].cdsDpb->dpb_mdb);
}
#define PARSE_SEP_STOP 0x01
@ -84,7 +85,7 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps,
WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb)
{
COUNT nIndex;
WORD wRetCodeName,wRetCodeExt;
WORD wRetCodeName, wRetCodeExt;
/* pjv -- ExtFcbToFcb? */
/* Start out with some simple stuff first. Check if we are */
@ -131,24 +132,28 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb)
/* special cases: '.' and '..' */
if (**lpFileName == '.')
{
lpFcb->fcb_fname[0]='.';
lpFcb->fcb_fname[0] = '.';
++*lpFileName;
if (**lpFileName == '.')
{
lpFcb->fcb_fname[1]='.';
lpFcb->fcb_fname[1] = '.';
++*lpFileName;
}
return PARSE_RET_NOWILD;
}
/* Now to format the file name into the string */
*lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName);
*lpFileName =
GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE,
(BOOL *) & wRetCodeName);
/* Do we have an extension? If do, format it else return */
if (**lpFileName == '.')
*lpFileName = GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCodeExt);
*lpFileName =
GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext,
FEXT_SIZE, (BOOL *) & wRetCodeExt);
return (wRetCodeName|wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD;
return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD;
}
BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName)
@ -161,8 +166,7 @@ BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName)
#if 0 /* defined above */
BOOL TestCmnSeps(BYTE FAR * lpFileName)
{
BYTE *pszTest,
*pszCmnSeps = ":<|>+=,";
BYTE *pszTest, *pszCmnSeps = ":<|>+=,";
for (pszTest = pszCmnSeps; *pszTest != '\0'; ++pszTest)
if (*lpFileName == *pszTest)
@ -174,8 +178,7 @@ BOOL TestCmnSeps(BYTE FAR * lpFileName)
#if 0
BOOL TestFieldSeps(BYTE FAR * lpFileName)
{
BYTE *pszTest,
*pszCmnSeps = "/\"[]<>|.";
BYTE *pszTest, *pszCmnSeps = "/\"[]<>|.";
/* Another non-portable construct */
if (*lpFileName <= ' ')
@ -188,7 +191,6 @@ BOOL TestFieldSeps(BYTE FAR * lpFileName)
}
#endif
BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField,
COUNT nFieldSize, BOOL * pbWildCard)
{
@ -196,7 +198,8 @@ BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField,
BYTE cFill = ' ';
*pbWildCard = FALSE;
while (*lpFileName != '\0' && !TestFieldSeps(lpFileName) && nIndex < nFieldSize)
while (*lpFileName != '\0' && !TestFieldSeps(lpFileName)
&& nIndex < nFieldSize)
{
if (*lpFileName == ' ')
break;
@ -232,7 +235,7 @@ static ULONG FcbRec(VOID)
{
UWORD tmp = 128;
return ((ULONG)lpFcb->fcb_cublock * tmp) + lpFcb->fcb_curec;
return ((ULONG) lpFcb->fcb_cublock * tmp) + lpFcb->fcb_curec;
}
BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode)
@ -395,7 +398,8 @@ BOOL FcbCalcRec(xfcb FAR * lpXfcb)
return TRUE;
}
BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode)
BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords,
COUNT * nErrorCode)
{
FcbCalcRec(lpXfcb);
@ -412,7 +416,8 @@ BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode)
return TRUE;
}
BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode)
BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords,
COUNT * nErrorCode)
{
FcbCalcRec(lpXfcb);
@ -430,7 +435,7 @@ BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode)
}
BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode,
BOOL (*FcbFunc)(xfcb FAR *, COUNT *))
BOOL(*FcbFunc) (xfcb FAR *, COUNT *))
{
UWORD uwCurrentBlock;
UBYTE ucCurrentRecord;
@ -443,7 +448,7 @@ BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode,
uwCurrentBlock = lpFcb->fcb_cublock;
ucCurrentRecord = lpFcb->fcb_curec;
(*FcbFunc)(lpXfcb, nErrorCode);
(*FcbFunc) (lpXfcb, nErrorCode);
lpFcb->fcb_cublock = uwCurrentBlock;
lpFcb->fcb_curec = ucCurrentRecord;
@ -476,7 +481,8 @@ BOOL FcbCreate(xfcb FAR * lpXfcb)
lpFcb->fcb_sftno = sft_idx;
lpFcb->fcb_curec = 0;
lpFcb->fcb_recsiz = (dhp ? 0 : 128);
if (!dhp) lpFcb->fcb_drive = FcbDrive;
if (!dhp)
lpFcb->fcb_drive = FcbDrive;
lpFcb->fcb_fsize = 0;
lpFcb->fcb_date = dos_getdate();
lpFcb->fcb_time = dos_gettime();
@ -509,7 +515,7 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer,
void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive)
{
BYTE loc_szBuffer[2+FNAME_SIZE+1+FEXT_SIZE+1]; /* 'A:' + '.' + '\0' */
BYTE loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; /* 'A:' + '.' + '\0' */
BYTE *pszBuffer = loc_szBuffer;
/* Build a traditional DOS file name */
@ -550,7 +556,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb)
lpFcb->fcb_rndm = 0;
lpFcb->fcb_sftno = sft_idx;
dhp = IsDevice(PriPathName);
if (dhp )
if (dhp)
{
lpFcb->fcb_recsiz = 0;
lpFcb->fcb_fsize = 0;
@ -586,7 +592,9 @@ BOOL FcbDelete(xfcb FAR * lpXfcb)
dmatch Dmatch;
dta = (BYTE FAR *) & Dmatch;
if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
if (DosFindFirst
(D_ALL,
SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
{
dta = lpOldDta;
return FALSE;
@ -625,7 +633,9 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
dmatch Dmatch;
dta = (BYTE FAR *) & Dmatch;
if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
if (DosFindFirst
(D_ALL,
SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS)
{
dta = lpOldDta;
return FALSE;
@ -634,8 +644,7 @@ BOOL FcbRename(xfcb FAR * lpXfcb)
do
{
fcb LocalFcb;
BYTE *pToName,
*pszFrom;
BYTE *pToName, *pszFrom;
BYTE FAR *pFromPattern;
COUNT nIndex;
@ -718,7 +727,7 @@ BOOL FcbClose(xfcb FAR * lpXfcb)
lpFcb = ExtFcbToFcb(lpXfcb);
/* An already closed FCB can be closed again without error */
if (lpFcb->fcb_sftno == (BYTE)0xff)
if (lpFcb->fcb_sftno == (BYTE) 0xff)
return TRUE;
/* Get the SFT block that contains the SFT */
@ -730,8 +739,9 @@ BOOL FcbClose(xfcb FAR * lpXfcb)
if (!(s->sft_flags & SFT_FSHARED))
dos_setfsize(s->sft_status, lpFcb->fcb_fsize);
DosSetFtimeSft(lpFcb->fcb_sftno, lpFcb->fcb_date, lpFcb->fcb_time);
if (DosCloseSft(lpFcb->fcb_sftno) == SUCCESS) {
lpFcb->fcb_sftno = (BYTE)0xff;
if (DosCloseSft(lpFcb->fcb_sftno) == SUCCESS)
{
lpFcb->fcb_sftno = (BYTE) 0xff;
return TRUE;
}
return FALSE;
@ -743,7 +753,7 @@ VOID FcbCloseAll()
COUNT idx = 0;
sft FAR *sftp;
for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) -1; idx++)
for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) - 1; idx++)
if ((sftp->sft_mode & SFT_MFCB) && sftp->sft_psp == cu_psp)
DosCloseSft(idx);
}
@ -779,7 +789,7 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb)
*lpDir++ = FcbDrive;
fmemcpy(lpDir, &SearchDir, sizeof(struct dirent));
lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster;
lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster;
lpFcb->fcb_strtclst = Dmatch.dm_entry;
/*
@ -787,7 +797,7 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb)
The First byte is the current directory count and the second seems
to be the attribute byte.
*/
lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date.*/
lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date. */
#if 0
lpFcb->fcb_cublock = Dmatch.dm_entry;
lpFcb->fcb_cublock *= 0x100;
@ -841,7 +851,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb)
*lpDir++ = FcbDrive;
fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent));
lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster;
lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster;
lpFcb->fcb_strtclst = Dmatch.dm_entry;
lpFcb->fcb_sftno = Dmatch.dm_drive;
@ -917,5 +927,3 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb)
* Rev 1.0 02 Jul 1995 8:06:06 patv
* Initial revision.
*/

View File

@ -29,11 +29,11 @@
#ifdef VERSION_STRINGS
#ifdef MAIN
static BYTE *Globals_hRcsId = "$Id$";
static BYTE *Globals_hRcsId =
"$Id$";
#endif
#endif
#include "device.h"
#include "mcb.h"
#include "pcb.h"
@ -127,8 +127,6 @@ static BYTE *Globals_hRcsId = "$Id$";
#define DSKWRITEINT26 3
#define DSKREADINT25 4
/* FAT cluster special flags */
#define FREE 0x000
@ -162,20 +160,16 @@ FAR clk_dev, /* Clock device driver */
FAR prn_dev, /* Generic printer device driver */
FAR aux_dev, /* Generic aux device driver */
FAR blk_dev; /* Block device (Disk) driver */
extern UWORD
ram_top; /* How much ram in Kbytes */
extern COUNT *
error_tos, /* error stack */
extern UWORD ram_top; /* How much ram in Kbytes */
extern COUNT *error_tos, /* error stack */
disk_api_tos, /* API handler stack - disk fns */
char_api_tos; /* API handler stack - char fns */
extern BYTE
FAR _InitTextStart; /* first available byte of ram */
extern BYTE
FAR _HMATextAvailable, /* first byte of available CODE area */
extern BYTE FAR _InitTextStart; /* first available byte of ram */
extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */
FAR _HMATextStart[], /* first byte of HMAable CODE area */
FAR _HMATextEnd[]; /* and the last byte of it */
extern
BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */
BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */
extern struct ClockRecord
ClkRecord;
@ -183,20 +177,17 @@ extern struct ClockRecord
/* */
/* Global variables */
/* */
GLOBAL BYTE
os_major, /* major version number */
GLOBAL BYTE os_major, /* major version number */
os_minor, /* minor version number */
rev_number /* minor version number */
#ifdef MAIN
= REV_NUMBER,
= REV_NUMBER,
#else
,
#endif
version_flags /* minor version number */
#ifdef MAIN
= 0;
= 0;
#else
;
#endif
@ -204,13 +195,13 @@ GLOBAL BYTE
#ifdef DEBUG
GLOBAL WORD bDumpRegs
#ifdef MAIN
= FALSE;
= FALSE;
#else
;
#endif
GLOBAL WORD bDumpRdWrParms
#ifdef MAIN
= FALSE;
= FALSE;
#else
;
#endif
@ -230,18 +221,18 @@ GLOBAL BYTE copyright[] =
GLOBAL BYTE os_release[]
#ifdef MAIN
#if 0
= "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n"
= "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n"
#endif
= "FreeDOS kernel version " KERNEL_VERSION_STRING \
= "FreeDOS kernel version " KERNEL_VERSION_STRING
" (Build " KERNEL_BUILD_STRING ") [" __DATE__ " " __TIME__ "]\n"
#if 0
"For technical information and description of the DOS-C operating system\n\
"For technical information and description of the DOS-C operating system\n\
consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\
Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\
\n"
#endif
#endif
;
;
/* Globally referenced variables - WARNING: ORDER IS DEFINED IN */
/* KERNAL.ASM AND MUST NOT BE CHANGED. DO NOT CHANGE ORDER BECAUSE THEY */
@ -251,87 +242,63 @@ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\
extern UWORD NetBios;
extern BYTE *net_name;
extern BYTE net_set_count;
extern BYTE NetDelay,
NetRetry;
extern BYTE NetDelay, NetRetry;
extern UWORD
first_mcb, /* Start of user memory */
UMB_top,
umb_start,
uppermem_root; /* Start of umb chain ? */
extern UWORD first_mcb, /* Start of user memory */
UMB_top, umb_start, uppermem_root; /* Start of umb chain ? */
extern struct dpb
FAR *DPBp; /* First drive Parameter Block */
extern sfttbl
FAR * sfthead; /* System File Table head */
extern sfttbl FAR * sfthead; /* System File Table head */
extern struct dhdr
FAR *clock, /* CLOCK$ device */
FAR * syscon; /* console device */
extern WORD
maxbksize; /* Number of Drives in system */
extern WORD maxbksize; /* Number of Drives in system */
extern struct buffer
FAR *firstbuf; /* head of buffers linked list */
extern cdstbl
FAR * CDSp; /* Current Directory Structure */
extern cdstbl FAR * CDSp; /* Current Directory Structure */
extern
struct cds FAR *current_ldt;
extern LONG current_filepos; /* current file position */
extern sfttbl
FAR * FCBp; /* FCB table pointer */
extern WORD
nprotfcb; /* number of protected fcbs */
extern UBYTE
nblkdev, /* number of block devices */
extern sfttbl FAR * FCBp; /* FCB table pointer */
extern WORD nprotfcb; /* number of protected fcbs */
extern UBYTE nblkdev, /* number of block devices */
lastdrive, /* value of last drive */
uppermem_link, /* UMB Link flag */
PrinterEcho; /* Printer Echo Flag */
extern UWORD
LoL_nbuffers; /* Number of buffers */
extern UWORD LoL_nbuffers; /* Number of buffers */
extern struct dhdr
nul_dev;
extern UBYTE
mem_access_mode; /* memory allocation scheme */
extern BYTE
ErrorMode, /* Critical error flag */
extern UBYTE mem_access_mode; /* memory allocation scheme */
extern BYTE ErrorMode, /* Critical error flag */
InDOS, /* In DOS critical section */
OpenMode, /* File Open Attributes */
SAttr, /* Attrib Mask for Dir Search */
dosidle_flag,
Server_Call,
CritErrLocus,
CritErrAction,
CritErrClass,
VgaSet,
njoined; /* number of joined devices */
dosidle_flag, Server_Call, CritErrLocus, CritErrAction, CritErrClass, VgaSet, njoined; /* number of joined devices */
extern UWORD Int21AX;
extern COUNT CritErrCode;
extern BYTE FAR * CritErrDev;
extern BYTE FAR *CritErrDev;
extern struct dirent
SearchDir;
extern struct
{
extern struct {
COUNT nDrive;
BYTE szName[FNAME_SIZE + 1];
BYTE szExt[FEXT_SIZE + 1];
}
FcbSearchBuffer;
} FcbSearchBuffer;
extern struct /* Path name parsing buffer */
{
BYTE _PriPathName[128];
}
_PriPathBuffer;
} _PriPathBuffer;
extern struct
{
extern struct {
BYTE _fname[FNAME_SIZE];
BYTE _fext[FEXT_SIZE+1]; /* space for 0 */
}
szNames;
BYTE _fext[FEXT_SIZE + 1]; /* space for 0 */
} szNames;
#define PriPathName _PriPathBuffer._PriPathName
#define szDirName TempCDS.cdsCurrentPath
@ -341,19 +308,15 @@ szNames;
extern struct /* Alternate path name parsing buffer */
{
BYTE _SecPathName[128];
}
_SecPathBuffer;
} _SecPathBuffer;
#define SecPathName _SecPathBuffer._SecPathName
extern UWORD
wAttr;
extern UWORD wAttr;
extern BYTE
default_drive; /* default drive for dos */
extern BYTE default_drive; /* default drive for dos */
extern BYTE
TempBuffer[], /* Temporary general purpose buffer */
extern BYTE TempBuffer[], /* Temporary general purpose buffer */
FAR internal_data[], /* sda areas */
FAR swap_always[], /* " " */
FAR swap_indos[], /* " " */
@ -361,46 +324,36 @@ extern BYTE
break_flg, /* true if break was detected */
break_ena, /* break enabled flag */
FAR * dta; /* Disk transfer area (kludge) */
extern seg
cu_psp; /* current psp segment */
extern iregs
FAR * user_r; /* User registers for int 21h call */
extern seg cu_psp; /* current psp segment */
extern iregs FAR * user_r; /* User registers for int 21h call */
extern struct dirent /* Temporary directory entry */
DirEntBuffer;
extern request /* I/O Request packets */
CharReqHdr,
IoReqHdr,
MediaReqHdr;
CharReqHdr, IoReqHdr, MediaReqHdr;
extern fcb
FAR * lpFcb; /* Pointer to users fcb */
extern fcb FAR * lpFcb; /* Pointer to users fcb */
extern sft
FAR * lpCurSft;
extern sft FAR * lpCurSft;
extern BYTE
verify_ena, /* verify enabled flag */
extern BYTE verify_ena, /* verify enabled flag */
switchar, /* switch char */
return_mode, /* Process termination rets */
return_code; /* " " " */
extern BYTE
BootDrive, /* Drive we came up from */
extern BYTE BootDrive, /* Drive we came up from */
scr_pos; /* screen position for bs, ht, etc */
/*extern WORD
NumFloppies; !!*/ /* How many floppies we have */
NumFloppies; !!*//* How many floppies we have */
extern keyboard
kb_buf;
extern keyboard kb_buf;
extern struct cds
TempCDS;
/* start of uncontrolled variables */
GLOBAL seg
RootPsp; /* Root process -- do not abort */
GLOBAL seg RootPsp; /* Root process -- do not abort */
/* don't know what it should do, but its no longer in use TE
GLOBAL struct f_node
@ -410,8 +363,7 @@ GLOBAL struct f_node
#ifdef DEBUG
GLOBAL iregs error_regs; /* registers for dump */
GLOBAL WORD
dump_regs; /* dump registers of bad call */
GLOBAL WORD dump_regs; /* dump registers of bad call */
#endif
@ -421,7 +373,7 @@ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */
/*!! GLOBAL iregs
FAR * ustackp, /* user stack */
/*!! FAR * kstackp; */ /* kernel stack */
/*!! FAR * kstackp; *//* kernel stack */
/* */
/* Function prototypes - automatically generated */
@ -430,15 +382,12 @@ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */
/* Process related functions - not under automatic generation. */
/* Typically, these are in ".asm" files. */
VOID
FAR ASMCFUNC cpm_entry(VOID)
VOID FAR ASMCFUNC cpm_entry(VOID)
/*INRPT FAR handle_break(VOID) */ ;
VOID
enable(VOID),
disable(VOID);
VOID enable(VOID), disable(VOID);
COUNT
ASMCFUNC CriticalError(
COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice);
ASMCFUNC CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError,
struct dhdr FAR * lpDevice);
#ifdef PROTO
VOID FAR ASMCFUNC CharMapSrvc(VOID);
@ -519,7 +468,6 @@ void ASMCFUNC spawn_int23(void); /* procsupt.asm */
int control_break(void); /* break.c */
void handle_break(void); /* break.c */
GLOBAL BYTE ReturnAnyDosVersionExpected;
GLOBAL COUNT UnusedRetVal; /* put unused errors here (to save stack space) */

View File

@ -1,31 +1,27 @@
/* Included by initialisation functions */
#if _MSC_VER != 0
extern __segment DosDataSeg;/* serves for all references to the DOS DATA segment
extern __segment DosDataSeg; /* serves for all references to the DOS DATA segment
necessary for MSC+our funny linking model
*/
extern __segment DosTextSeg;
extern __segment DosTextSeg;
#define DOSFAR __based(DosDataSeg)
#define DOSTEXTFAR __based(DosTextSeg)
#define DOSFAR __based(DosDataSeg)
#define DOSTEXTFAR __based(DosTextSeg)
#elif defined(__TURBOC__)
#define DOSFAR FAR
#define DOSTEXTFAR FAR
#define DOSFAR FAR
#define DOSTEXTFAR FAR
#elif defined(__WATCOMC__)
#define DOSFAR FAR
#define DOSTEXTFAR FAR
#define DOSFAR FAR
#define DOSTEXTFAR FAR
#else
#pragma error("unknown compiler - please adjust")
this should simply not compile !!
#pragma error("unknown compiler - please adjust")
this should simply not compile ! !
#endif
extern BYTE DOSFAR version_flags; /* minor version number */

View File

@ -24,7 +24,6 @@
#include "KConfig.h"
extern struct _KernelConfig InitKernelConfig;
/*
* The null macro `INIT' can be used to allow the reader to differentiate
* between functions defined in `INIT_TEXT' and those defined in `_TEXT'.
@ -58,7 +57,7 @@ COUNT ASMCFUNC strlen(REG BYTE * s);
/*inithma.c*/
extern BYTE DosLoadedInHMA;
extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len);
extern fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len);
#define setvec(n, isr) (void)(*(VOID (FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr))
@ -75,11 +74,8 @@ extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len);
#define MAX_HARD_DRIVE 8
#define NDEV 26 /* up to Z: */
/* Start of configuration variables */
struct config
{
struct config {
BYTE cfgBuffers;
/* number of buffers in the system */
UBYTE cfgFiles;
@ -101,7 +97,7 @@ struct config
/* COUNTRY=
In Pass #1 these information is collected and in PostConfig()
the NLS package is loaded into memory.
-- 2000/06/11 ska*/
-- 2000/06/11 ska */
WORD cfgCSYS_cntry;
/* country ID to be loaded */
WORD cfgCSYS_cp;
@ -134,7 +130,7 @@ INIT VOID mcb_init(UCOUNT seg, UWORD size);
INIT VOID strcat(REG BYTE * d, REG BYTE * s);
INIT BYTE FAR *KernelAlloc(WORD nBytes);
INIT COUNT ASMCFUNC Umb_Test(void);
INIT COUNT ASMCFUNC UMB_get_largest(UCOUNT *seg, UCOUNT *size);
INIT COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size);
INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString);
/* diskinit.c */
@ -152,19 +148,20 @@ UWORD init_oem(void);
/* intr.asm */
void ASMCFUNC init_call_intr(int nr, iregs *rp);
void ASMCFUNC init_call_intr(int nr, iregs * rp);
UCOUNT ASMCFUNC read(int fd, void *buf, UCOUNT count);
int ASMCFUNC open(const char *pathname, int flags);
int ASMCFUNC close(int fd);
int ASMCFUNC dup2(int oldfd, int newfd);
int ASMCFUNC allocmem(UWORD size, seg *segp);
int ASMCFUNC allocmem(UWORD size, seg * segp);
INIT VOID ASMCFUNC init_PSPInit(seg psp_seg);
INIT VOID ASMCFUNC init_PSPSet(seg psp_seg);
INIT COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
INIT VOID ASMCFUNC keycheck(VOID);
/* irqstack.asm */
VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize);
VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks,
WORD stackSize);
/* inthndlr.c */
VOID far ASMCFUNC int21_entry(iregs UserRegs);
@ -187,11 +184,12 @@ VOID FAR ASMCFUNC int2f_handler(void);
/* main.c */
INIT VOID ASMCFUNC FreeDOSmain(void);
INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top);
INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine,
COUNT mode, COUNT top);
INIT VOID init_fatal(BYTE * err_msg);
/* prf.c */
WORD init_printf(CONST BYTE * fmt,...);
WORD init_printf(CONST BYTE * fmt, ...);
WORD init_sprintf(BYTE * buff, CONST BYTE * fmt, ...);
void MoveKernel(unsigned NewKernelSegment);
@ -203,5 +201,5 @@ extern unsigned CurrentKernelSegment;
ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */
ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */
ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */
ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2,UWORD *rem); /* DIVide ULong by UShort */
ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */
#endif

File diff suppressed because it is too large Load Diff

View File

@ -63,60 +63,54 @@
parameter is forced.
*/
#include "portab.h"
#include "init-mod.h"
#include "init-dat.h"
extern BYTE
FAR _HMATextAvailable, /* first byte of available CODE area */
extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */
FAR _HMATextStart[], /* first byte of HMAable CODE area */
FAR _HMATextEnd[]; /* and the last byte of it */
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */
BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */
BYTE DosLoadedInHMA = FALSE; /* set to TRUE if loaded HIGH */
BYTE HMAclaimed = FALSE; /* set to TRUE if claimed from HIMEM */
WORD HMAFree = 0; /* first byte in HMA not yet used */
extern BYTE FAR * DOSTEXTFAR ASMCFUNC XMSDriverAddress;
extern BYTE FAR *DOSTEXTFAR ASMCFUNC XMSDriverAddress;
extern FAR ASMCFUNC _EnableA20(VOID);
extern FAR ASMCFUNC _DisableA20(VOID);
extern void FAR *ASMCFUNC DetectXMSDriver(VOID);
extern int ASMCFUNC init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx);
extern int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax,
UWORD dx);
#ifdef DEBUG
#ifdef __TURBOC__
#define int3() __int__(3);
#else
void int3()
{ __asm int 3;
}
#endif
#ifdef __TURBOC__
#define int3() __int__(3);
#else
#define int3()
void int3()
{
__asm int 3;
}
#endif
#else
#define int3()
#endif
#ifdef DEBUG
#define HMAInitPrintf(x) printf x
#define HMAInitPrintf(x) printf x
#else
#define HMAInitPrintf(x)
#define HMAInitPrintf(x)
#endif
void MoveKernel(unsigned NewKernelSegment);
#ifdef DEBUG
VOID hdump(BYTE FAR *p)
VOID hdump(BYTE FAR * p)
{
int loop;
HMAInitPrintf(("%p", p));
@ -127,25 +121,22 @@ VOID hdump(BYTE FAR *p)
printf("\n");
}
#else
#define hdump(ptr)
#define hdump(ptr)
#endif
#define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17)))
/* of course, this should go to ASMSUPT */
fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len)
fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len)
{
for ( ; len ; s1++,s2++,--len)
for (; len; s1++, s2++, --len)
{
if (*s1 - *s2)
return *s1-*s2;
return *s1 - *s2;
}
return 0;
}
/*
this tests, if the HMA area can be enabled.
if so, it simply leaves it on
@ -156,22 +147,21 @@ int EnableHMA(VOID)
_EnableA20();
if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) == 0)
if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) == 0)
{
printf("HMA can't be enabled\n");
return FALSE;
}
_DisableA20();
if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) != 0)
if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) != 0)
{
printf("HMA can't be disabled - no problem for us\n");
}
_EnableA20();
if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) == 0)
if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) == 0)
{
printf("HMA can't be enabled second time\n");
return FALSE;
@ -183,9 +173,6 @@ int EnableHMA(VOID)
}
/*
move the kernel up to high memory
this is very unportable
@ -196,7 +183,6 @@ int EnableHMA(VOID)
#define HMAOFFSET 0x20
#define HMASEGMENT 0xffff
int MoveKernelToHMA()
{
@ -214,7 +200,8 @@ int MoveKernelToHMA()
*/
if (KeyboardShiftState() & 0x0f)
{
printf("Keyboard state is %0x, NOT moving to HMA\n",KeyboardShiftState());
printf("Keyboard state is %0x, NOT moving to HMA\n",
KeyboardShiftState());
return FALSE;
}
#endif
@ -231,7 +218,8 @@ int MoveKernelToHMA()
/* allocate HMA through XMS driver */
if (HMAclaimed == 0 &&
(HMAclaimed = init_call_XMScall( XMSDriverAddress, 0x0100, 0xffff)) == 0)
(HMAclaimed =
init_call_XMScall(XMSDriverAddress, 0x0100, 0xffff)) == 0)
{
printf("Can't reserve HMA area ??\n");
@ -240,7 +228,6 @@ int MoveKernelToHMA()
MoveKernel(0xffff);
{
/* E) up to now, nothing really bad was done.
but now, we reuse the HMA area. bad things will happen
@ -249,7 +236,6 @@ int MoveKernelToHMA()
cause INT 3 on all accesses to this area
*/
DosLoadedInHMA = TRUE;
}
@ -260,7 +246,6 @@ int MoveKernelToHMA()
}
/* not necessary anymore : BO */
/*
now protect against HIMEM/FDXMS/... by simulating a VDISK
@ -271,7 +256,7 @@ int MoveKernelToHMA()
*/
#if 0
void InstallVDISK(VOID)
{
{
static struct { /* Boot-Sektor of a RAM-Disk */
UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */
char Name[5];
@ -280,30 +265,31 @@ void InstallVDISK(VOID)
BYTE dummy3[6];
WORD Sektoren;
BYTE dummy4;
} VDISK_BOOT_SEKTOR =
} VDISK_BOOT_SEKTOR = {
{
{ 0xcf, ' ', ' '},
{ 'V', 'D', 'I', 'S', 'K'},
{ ' ', ' ', ' '},
512,
{ 'F', 'D', 'O', 'S', ' ', ' '},
128, /* 128*512 = 64K */
' '
};
0xcf, ' ', ' '},
{
'V', 'D', 'I', 'S', 'K'},
{
' ', ' ', ' '}, 512,
{
'F', 'D', 'O', 'S', ' ', ' '}, 128, /* 128*512 = 64K */
' '};
if (!DosLoadedInHMA) return;
if (HMAclaimed) return;
if (!DosLoadedInHMA)
return;
if (HMAclaimed)
return;
fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SEKTOR,
sizeof(VDISK_BOOT_SEKTOR));
fmemcpy(MK_FP(0xffff,0x0010), &VDISK_BOOT_SEKTOR, sizeof(VDISK_BOOT_SEKTOR));
setvec(0x19, MK_FP(0xffff, 0x0010)); /* let INT 19 point to VDISK */
setvec(0x19, MK_FP(0xffff,0x0010)); /* let INT 19 point to VDISK */
*(WORD FAR *)MK_FP(0xffff,0x002e) = 1024+64;
}
*(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64;
}
#endif
/*
this should be called, after each device driver
has been loaded with FALSE
@ -334,9 +320,11 @@ VOID FAR *HMAalloc(COUNT bytesToAllocate)
{
VOID FAR *HMAptr;
if (!DosLoadedInHMA) return NULL;
if (!DosLoadedInHMA)
return NULL;
if (HMAFree >= 0xfff0 - bytesToAllocate) return NULL;
if (HMAFree >= 0xfff0 - bytesToAllocate)
return NULL;
HMAptr = MK_FP(0xffff, HMAFree);
@ -345,13 +333,11 @@ VOID FAR *HMAalloc(COUNT bytesToAllocate)
/*printf("HMA allocated %d byte at %x\n", bytesToAllocate, HMAptr); */
fmemset( HMAptr,0, bytesToAllocate);
fmemset(HMAptr, 0, bytesToAllocate);
return HMAptr;
}
unsigned CurrentKernelSegment = 0;
void MoveKernel(unsigned NewKernelSegment)
@ -367,9 +353,9 @@ void MoveKernel(unsigned NewKernelSegment)
if (CurrentKernelSegment == 0xffff)
return;
HMASource = MK_FP(CurrentKernelSegment,(FP_OFF(_HMATextStart) & 0xfff0));
HMADest = MK_FP(NewKernelSegment,0x0000);
HMASource =
MK_FP(CurrentKernelSegment, (FP_OFF(_HMATextStart) & 0xfff0));
HMADest = MK_FP(NewKernelSegment, 0x0000);
len = (FP_OFF(_HMATextEnd) | 0x000f) - (FP_OFF(_HMATextStart) & 0xfff0);
@ -386,20 +372,23 @@ void MoveKernel(unsigned NewKernelSegment)
if (NewKernelSegment < CurrentKernelSegment ||
NewKernelSegment == 0xffff)
{
unsigned i; UBYTE FAR *s,FAR *d;
unsigned i;
UBYTE FAR *s, FAR * d;
for (i = 0, s = HMASource,d = HMADest; i < len; i++)
for (i = 0, s = HMASource, d = HMADest; i < len; i++)
d[i] = s[i];
}
else {
else
{
/* might overlap */
unsigned i; UBYTE FAR *s,FAR *d;
unsigned i;
UBYTE FAR *s, FAR * d;
for (i = len, s = HMASource,d = HMADest; i != 0; i--)
for (i = len, s = HMASource, d = HMADest; i != 0; i--)
d[i] = s[i];
}
HMAFree = FP_OFF(HMADest)+len; /* first free byte after HMA_TEXT */
HMAFree = FP_OFF(HMADest) + len; /* first free byte after HMA_TEXT */
{
/* D) but it only makes sense, if we can relocate
@ -430,7 +419,7 @@ void MoveKernel(unsigned NewKernelSegment)
DOSTEXTFAR _HMARelocationTableStart[],
DOSTEXTFAR _HMARelocationTableEnd[];
struct RelocationTable FAR *rp, rtemp ;
struct RelocationTable FAR *rp, rtemp;
/* verify, that all entries are valid */
@ -441,13 +430,16 @@ void MoveKernel(unsigned NewKernelSegment)
rp->callNear != 0xe8 || /* call NEAR */
0)
{
printf("illegal relocation entry # %d\n",(FP_OFF(rp) - FP_OFF(_HMARelocationTableStart))/sizeof(struct RelocationTable));
printf("illegal relocation entry # %d\n",
(FP_OFF(rp) -
FP_OFF(_HMARelocationTableStart)) /
sizeof(struct RelocationTable));
int3();
goto errorReturn;
}
}
/* OK, all valid, go to relocate*/
/* OK, all valid, go to relocate */
for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++)
{
@ -461,7 +453,7 @@ void MoveKernel(unsigned NewKernelSegment)
rel->jmpSegment = NewKernelSegment;
rel->jmpOffset = rtemp.jmpOffset;
rel->callNear = rtemp.callNear;
rel->callOffset = rtemp.callOffset+5; /* near calls are relative */
rel->callOffset = rtemp.callOffset + 5; /* near calls are relative */
}
else
rp->jmpSegment = NewKernelSegment;
@ -477,16 +469,15 @@ void MoveKernel(unsigned NewKernelSegment)
UWORD jmpSegment;
};
extern struct initRelocationTable
_HMAinitRelocationTableStart[],
_HMAinitRelocationTableEnd[];
_HMAinitRelocationTableStart[], _HMAinitRelocationTableEnd[];
struct initRelocationTable *rp;
/* verify, that all entries are valid */
for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++)
for (rp = _HMAinitRelocationTableStart;
rp < _HMAinitRelocationTableEnd; rp++)
{
if (
rp->callNear != 0xe8 || /* call NEAR */
if (rp->callNear != 0xe8 || /* call NEAR */
rp->jmpFar != 0xea || /* jmp FAR */
rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */
0)
@ -497,9 +488,10 @@ void MoveKernel(unsigned NewKernelSegment)
}
}
/* OK, all valid, go to relocate*/
/* OK, all valid, go to relocate */
for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++)
for (rp = _HMAinitRelocationTableStart;
rp < _HMAinitRelocationTableEnd; rp++)
{
rp->jmpSegment = NewKernelSegment;
}
@ -509,7 +501,7 @@ void MoveKernel(unsigned NewKernelSegment)
return;
errorReturn:
for (;;);
for (;;) ;
}
/*

View File

@ -31,7 +31,8 @@
#include "init-mod.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
UWORD init_oem(void)
@ -42,7 +43,7 @@ UWORD init_oem(void)
asm
{
int 0x12;
mov top_k,ax;
mov top_k, ax;
}
#else
__int__(0x12);
@ -94,4 +95,3 @@ UWORD init_oem(void)
* Rev 1.0 02 Jul 1995 8:31:54 patv
* Initial revision.
*/

View File

@ -32,7 +32,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
BYTE *RcsId = "$Id$";
BYTE *RcsId =
"$Id$";
#endif
#ifdef TSC
@ -41,7 +42,7 @@ static bTraceNext = FALSE;
#endif
#if 0 /* Very suspicious, passing structure by value??
Deactivated -- 2000/06/16 ska*/
Deactivated -- 2000/06/16 ska */
/* Special entry for far call into the kernel */
#pragma argsused
VOID FAR int21_entry(iregs UserRegs)
@ -51,8 +52,7 @@ VOID FAR int21_entry(iregs UserRegs)
#endif
/* Structures needed for int 25 / int 26 */
struct HugeSectorBlock
{
struct HugeSectorBlock {
ULONG blkno;
WORD nblks;
BYTE FAR *buf;
@ -89,7 +89,6 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp)
break_ena = tmp != 0;
}
/* Get Boot Drive */
case 0x05:
irp->DL = BootDrive;
@ -100,7 +99,7 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp)
irp->BL = os_major;
irp->BH = os_minor;
irp->DL = rev_number;
irp->DH = version_flags; /* bit3:runs in ROM,bit 4: runs in HMA*/
irp->DH = version_flags; /* bit3:runs in ROM,bit 4: runs in HMA */
break;
case 0x03: /* DOS 7 does not set AL */
@ -153,18 +152,16 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp)
}
}
VOID ASMCFUNC int21_service(iregs FAR * r)
{
COUNT rc = 0;
void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often,
that this saves ~100 bytes */
#define CLEAR_CARRY_FLAG() r->FLAGS &= ~FLG_CARRY
#define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY
((psp FAR *)MK_FP(cu_psp, 0))->ps_stack = (BYTE FAR *) r;
((psp FAR *) MK_FP(cu_psp, 0))->ps_stack = (BYTE FAR *) r;
#ifdef DEBUG
if (bDumpRegs)
@ -176,7 +173,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r)
}
#endif
if(r->AH >=0x38 && r->AH <= 0x4F)
if (r->AH >= 0x38 && r->AH <= 0x4F)
CLEAR_CARRY_FLAG();
/* Clear carry by default for these functions */
@ -233,7 +230,8 @@ dispatch:
case 0x03:
{
COUNT scratch;
GenericRead(STDAUX, 1, (BYTE FAR *) & r->AL, (COUNT FAR *) & scratch, TRUE);
GenericRead(STDAUX, 1, (BYTE FAR *) & r->AL,
(COUNT FAR *) & scratch, TRUE);
break;
}
@ -241,14 +239,14 @@ dispatch:
case 0x04:
{
COUNT scratch;
DosWrite(STDAUX, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch);
DosWrite(STDAUX, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) & scratch);
break;
}
/* Print Character */
case 0x05:
{
COUNT scratch;
DosWrite(STDPRN, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch);
DosWrite(STDPRN, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) & scratch);
break;
}
@ -281,11 +279,12 @@ dispatch:
/* Display String */
case 0x09:
{
BYTE FAR * q;
BYTE FAR *q;
q = FP_DS_DX;
while (*q != '$')
++q;
DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, (COUNT FAR *) & UnusedRetVal);
DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX,
(COUNT FAR *) & UnusedRetVal);
}
r->AL = '$';
break;
@ -440,8 +439,7 @@ dispatch:
FatGetDrvData(0,
(UCOUNT FAR *) & r->AX,
(UCOUNT FAR *) & r->CX,
(UCOUNT FAR *) & r->DX,
(BYTE FAR **) & p);
(UCOUNT FAR *) & r->DX, (BYTE FAR **) & p);
r->DS = FP_SEG(p);
r->BX = FP_OFF(p);
}
@ -455,8 +453,7 @@ dispatch:
FatGetDrvData(r->DL,
(UCOUNT FAR *) & r->AX,
(UCOUNT FAR *) & r->CX,
(UCOUNT FAR *) & r->DX,
(BYTE FAR **) & p);
(UCOUNT FAR *) & r->DX, (BYTE FAR **) & p);
r->DS = FP_SEG(p);
r->BX = FP_OFF(p);
}
@ -542,9 +539,7 @@ dispatch:
BYTE FAR *lpFileName;
lpFileName = MK_FP(r->DS, r->SI);
r->AL = FcbParseFname(r->AL,
&lpFileName,
MK_FP(r->ES, r->DI));
r->AL = FcbParseFname(r->AL, &lpFileName, MK_FP(r->ES, r->DI));
r->DS = FP_SEG(lpFileName);
r->SI = FP_OFF(lpFileName);
}
@ -552,8 +547,7 @@ dispatch:
/* Get Date */
case 0x2a:
DosGetDate(
(BYTE FAR *) & (r->AL), /* WeekDay */
DosGetDate((BYTE FAR *) & (r->AL), /* WeekDay */
(BYTE FAR *) & (r->DH), /* Month */
(BYTE FAR *) & (r->DL), /* MonthDay */
(COUNT FAR *) & (r->CX)); /* Year */
@ -561,8 +555,7 @@ dispatch:
/* Set Date */
case 0x2b:
rc = DosSetDate(
r->DH, /* Month */
rc = DosSetDate(r->DH, /* Month */
r->DL, /* MonthDay */
r->CX); /* Year */
r->AL = (rc != SUCCESS ? 0xff : 0);
@ -570,8 +563,7 @@ dispatch:
/* Get Time */
case 0x2c:
DosGetTime(
(BYTE FAR *) & (r->CH), /* Hour */
DosGetTime((BYTE FAR *) & (r->CH), /* Hour */
(BYTE FAR *) & (r->CL), /* Minutes */
(BYTE FAR *) & (r->DH), /* Seconds */
(BYTE FAR *) & (r->DL)); /* Hundredths */
@ -579,8 +571,7 @@ dispatch:
/* Set Date */
case 0x2d:
rc = DosSetTime(
r->CH, /* Hour */
rc = DosSetTime(r->CH, /* Hour */
r->CL, /* Minutes */
r->DH, /* Seconds */
r->DL); /* Hundredths */
@ -617,15 +608,14 @@ dispatch:
*/
UBYTE FAR *retp = MK_FP(r->cs, r->ip);
if ( retp[0] == 0x3d && /* cmp ax, xxyy */
if (retp[0] == 0x3d && /* cmp ax, xxyy */
(retp[3] == 0x75 || retp[3] == 0x74)) /* je/jne error */
{
r->AL = retp[1];
r->AH = retp[2];
}
else if(retp[0] == 0x86 && /* xchg al,ah */
retp[1] == 0xc4 &&
retp[2] == 0x3d && /* cmp ax, xxyy */
else if (retp[0] == 0x86 && /* xchg al,ah */
retp[1] == 0xc4 && retp[2] == 0x3d && /* cmp ax, xxyy */
(retp[5] == 0x75 || retp[5] == 0x74)) /* je/jne error */
{
r->AL = retp[4];
@ -655,8 +645,10 @@ dispatch:
struct dpb FAR *dpb;
UCOUNT drv = r->DL;
if (drv == 0 || r->AH == 0x1f) drv = default_drive;
else drv--;
if (drv == 0 || r->AH == 0x1f)
drv = default_drive;
else
drv--;
if (drv >= lastdrive)
{
@ -666,8 +658,7 @@ dispatch:
}
dpb = CDSp->cds_table[drv].cdsDpb;
if (dpb == 0 ||
CDSp->cds_table[drv].cdsFlags & CDSNETWDRV)
if (dpb == 0 || CDSp->cds_table[drv].cdsFlags & CDSNETWDRV)
{
r->AL = 0xFF;
CritErrCode = 0x0f;
@ -720,12 +711,10 @@ dispatch:
/* Dos Get Disk Free Space */
case 0x36:
DosGetFree(
r->DL,
DosGetFree(r->DL,
(UCOUNT FAR *) & r->AX,
(UCOUNT FAR *) & r->BX,
(UCOUNT FAR *) & r->CX,
(UCOUNT FAR *) & r->DX);
(UCOUNT FAR *) & r->CX, (UCOUNT FAR *) & r->DX);
break;
/* Undocumented Get/Set Switchar */
@ -754,21 +743,24 @@ dispatch:
{
UWORD cntry = r->AL;
if(cntry == 0)
cntry = (UWORD)-1;
else if(cntry == 0xff)
if (cntry == 0)
cntry = (UWORD) - 1;
else if (cntry == 0xff)
cntry = r->BX;
if (0xffff == r->DX) {
if (0xffff == r->DX)
{
/* Set Country Code */
if((rc = DosSetCountry(cntry)) < 0)
if ((rc = DosSetCountry(cntry)) < 0)
goto error_invalid;
} else {
}
else
{
/* Get Country Information */
if((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0)
if ((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0)
goto error_invalid;
/* HACK FIXME */
if(cntry == (UWORD)-1)
if (cntry == (UWORD) - 1)
cntry = 1;
/* END OF HACK */
r->AX = r->BX = cntry;
@ -843,12 +835,14 @@ dispatch:
case 0x42:
{
ULONG lrc;
if ((rc = DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) | r->DX), r->AL, &lrc)) < 0)
if ((rc =
DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) | r->DX),
r->AL, &lrc)) < 0)
goto error_exit;
else
{
r->DX = (lrc >> 16);
r->AX = (UWORD)lrc;
r->AX = (UWORD) lrc;
}
}
break;
@ -913,7 +907,8 @@ dispatch:
/* Allocate memory */
case 0x48:
if ((rc = DosMemAlloc(r->BX, mem_access_mode, &(r->AX), &(r->BX))) < 0)
if ((rc =
DosMemAlloc(r->BX, mem_access_mode, &(r->AX), &(r->BX))) < 0)
{
DosMemLargest(&(r->BX));
goto error_exit;
@ -958,8 +953,7 @@ dispatch:
case 0x4b:
break_flg = FALSE;
if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX))
!= SUCCESS)
if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX)) != SUCCESS)
goto error_exit;
break;
@ -1038,9 +1032,10 @@ dispatch:
case 0x53:
/* DOS 2+ internal - TRANSLATE BIOS PARAMETER BLOCK TO DRIVE PARAM BLOCK */
bpb_to_dpb((bpb FAR *)MK_FP(r->DS, r->SI), (struct dpb FAR *)MK_FP(r->ES, r->BP)
bpb_to_dpb((bpb FAR *) MK_FP(r->DS, r->SI),
(struct dpb FAR *)MK_FP(r->ES, r->BP)
#ifdef WITHFAT32
,(r->CX == 0x4558 && r->DX == 0x4152)
, (r->CX == 0x4558 && r->DX == 0x4152)
#endif
);
break;
@ -1059,7 +1054,8 @@ dispatch:
/* Dos Rename */
case 0x56:
rc = DosRename((BYTE FAR *) FP_DS_DX, (BYTE FAR *) MK_FP(r->ES, r->DI));
rc = DosRename((BYTE FAR *) FP_DS_DX,
(BYTE FAR *) MK_FP(r->ES, r->DI));
if (rc < SUCCESS)
goto error_exit;
else
@ -1072,8 +1068,7 @@ dispatch:
switch (r->AL)
{
case 0x00:
rc = DosGetFtime(
(COUNT) r->BX, /* Handle */
rc = DosGetFtime((COUNT) r->BX, /* Handle */
(date FAR *) & r->DX, /* FileDate */
(time FAR *) & r->CX); /* FileTime */
if (rc < SUCCESS)
@ -1081,8 +1076,7 @@ dispatch:
break;
case 0x01:
rc = DosSetFtime(
(COUNT) r->BX, /* Handle */
rc = DosSetFtime((COUNT) r->BX, /* Handle */
(date) r->DX, /* FileDate */
(time) r->CX); /* FileTime */
if (rc < SUCCESS)
@ -1195,8 +1189,10 @@ dispatch:
case 0x5c:
if ((rc = DosLockUnlock
(r->BX,
(((unsigned long)r->CX)<<16)|(((unsigned long)r->DX)&0xffffL),
(((unsigned long)r->SI)<<16)|(((unsigned long)r->DI)&0xffffL),
(((unsigned long)r->CX) << 16) | (((unsigned long)r->
DX) & 0xffffL),
(((unsigned long)r->SI) << 16) | (((unsigned long)r->
DI) & 0xffffL),
((r->AX & 0xff) != 0))) != 0)
goto error_exit;
CLEAR_CARRY_FLAG();
@ -1256,9 +1252,11 @@ dispatch:
break;
default:
rc = remote_printset(r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX)));
if (rc != SUCCESS) goto error_exit;
r->AX=SUCCESS;
rc = remote_printset(r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)),
r->SI, (MK_FP(r->DS, Int21AX)));
if (rc != SUCCESS)
goto error_exit;
r->AX = SUCCESS;
break;
}
break;
@ -1268,13 +1266,15 @@ dispatch:
switch (r->AL)
{
case 0x07:
if (r->DL < lastdrive) {
if (r->DL < lastdrive)
{
CDSp->cds_table[r->DL].cdsFlags |= 0x100;
}
break;
case 0x08:
if (r->DL < lastdrive) {
if (r->DL < lastdrive)
{
CDSp->cds_table[r->DL].cdsFlags &= ~0x100;
}
break;
@ -1286,10 +1286,11 @@ dispatch:
break;*/
rc = remote_doredirect(r->BX, r->CX, r->DX,
(MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX)));
(MK_FP(r->ES, r->DI)), r->SI,
(MK_FP(r->DS, Int21AX)));
if (rc != SUCCESS)
goto error_exit;
r->AX=SUCCESS;
r->AX = SUCCESS;
break;
}
break;
@ -1297,7 +1298,8 @@ dispatch:
case 0x60: /* TRUENAME */
CLEAR_CARRY_FLAG();
if ((rc = truename(MK_FP(r->DS, r->SI),
adjust_far(MK_FP(r->ES, r->DI)), FALSE)) != SUCCESS)
adjust_far(MK_FP(r->ES, r->DI)),
FALSE)) != SUCCESS)
goto error_exit;
break;
@ -1331,8 +1333,7 @@ dispatch:
/* UNDOCUMENTED: Double byte and korean tables */
case 0x63:
{
static char dbcsTable[4] =
{
static char dbcsTable[4] = {
0, 0, 0, 0
};
r->DS = FP_SEG(&dbcsTable);
@ -1352,7 +1353,8 @@ dispatch:
/* Extended country info */
case 0x65:
switch(r->AL) {
switch (r->AL)
{
case 0x20: /* upcase single character */
r->DL = DosUpChar(r->DL);
break;
@ -1375,9 +1377,9 @@ dispatch:
r->AX = DosYesNo(r->DL);
break;
default:
if ((rc = DosGetData(
r->AL, r->BX, r->DX, r->CX,
MK_FP(r->ES, r->DI))) < 0) {
if ((rc = DosGetData(r->AL, r->BX, r->DX, r->CX,
MK_FP(r->ES, r->DI))) < 0)
{
#ifdef NLS_DEBUG
printf("DosGetData() := %d\n", rc);
#endif
@ -1392,9 +1394,9 @@ dispatch:
CLEAR_CARRY_FLAG();
break;
/* Code Page functions */
case 0x66: {
case 0x66:
{
int rc;
switch (r->AL)
{
@ -1408,7 +1410,7 @@ dispatch:
default:
goto error_invalid;
}
if(rc != SUCCESS)
if (rc != SUCCESS)
goto error_exit;
CLEAR_CARRY_FLAG();
break;
@ -1434,10 +1436,12 @@ dispatch:
if (rc < lastdrive)
{
UWORD saveCX = r->CX;
if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) {
if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV)
{
goto error_invalid;
}
switch(r->AL){
switch (r->AL)
{
case 0x00:
r->AL = 0x0d;
r->CX = 0x0866;
@ -1469,17 +1473,18 @@ dispatch:
COUNT x = 0;
if (r->AL != 0 || r->DH != 0 ||
(r->DL&0x0f) > 0x2 || (r->DL&0xf0) > 0x10)
(r->DL & 0x0f) > 0x2 || (r->DL & 0xf0) > 0x10)
goto error_invalid;
CLEAR_CARRY_FLAG();
if ((rc = DosOpen(MK_FP(r->DS, r->SI),
(r->DL&0x0f) == 0x1 ? r->BL : 0)) < 0)
(r->DL & 0x0f) == 0x1 ? r->BL : 0)) < 0)
{
if (r->DL < 0x10)
goto error_exit;
/* else try to create below */
}
else switch (r->DL & 0x0f)
else
switch (r->DL & 0x0f)
{
case 0x0:
/* fail if file exists */
@ -1500,8 +1505,8 @@ dispatch:
if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX)) < 0)
goto error_exit;
r->CX = x+2;
break_out:
r->CX = x + 2;
break_out:
r->AX = rc;
break;
}
@ -1512,12 +1517,13 @@ break_out:
/* DOS 7.0+ FAT32 extended funcitons */
case 0x73:
{
switch(r->AL)
switch (r->AL)
{
/* Get extended drive parameter block */
case 0x02:
{
struct xdpbdata FAR *xddp = (struct xdpbdata FAR *)MK_FP(r->ES, r->DI);
struct xdpbdata FAR *xddp =
(struct xdpbdata FAR *)MK_FP(r->ES, r->DI);
struct dpb FAR *dpb;
if (r->CX < sizeof(struct xdpbdata))
@ -1527,7 +1533,8 @@ break_out:
}
dpb = GetDriveDPB(r->DL, &rc);
if (rc != SUCCESS) goto error_exit;
if (rc != SUCCESS)
goto error_exit;
flush_buffers(dpb->dpb_unit);
dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */
@ -1555,7 +1562,7 @@ break_out:
goto error_out;
}
CLEAR_CARRY_FLAG();
rc = DosGetExtFree((BYTE FAR *)FP_DS_DX, xfsp);
rc = DosGetExtFree((BYTE FAR *) FP_DS_DX, xfsp);
if (rc != SUCCESS)
goto error_exit;
xfsp->xfs_datasize = sizeof(struct xfreespace);
@ -1574,13 +1581,14 @@ break_out:
goto error_out;
}
dpb = GetDriveDPB(r->DL, &rc);
if (rc != SUCCESS) goto error_exit;
if (rc != SUCCESS)
goto error_exit;
CLEAR_CARRY_FLAG();
xdffp->xdff_datasize = sizeof(struct xdpbforformat);
xdffp->xdff_version.actual = 0;
switch ((UWORD)xdffp->xdff_function)
switch ((UWORD) xdffp->xdff_function)
{
case 0x00:
{
@ -1588,10 +1596,10 @@ break_out:
DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster;
if (ISFAT32(dpb))
{
if ((dpb->dpb_xfsinfosec == 0xffff && (nfreeclst != 0 ||
cluster != 0)) ||
nfreeclst == 1 || nfreeclst > dpb->dpb_xsize ||
cluster == 1 || cluster > dpb->dpb_xsize)
if ((dpb->dpb_xfsinfosec == 0xffff
&& (nfreeclst != 0 || cluster != 0))
|| nfreeclst == 1 || nfreeclst > dpb->dpb_xsize
|| cluster == 1 || cluster > dpb->dpb_xsize)
{
r->AX = -DE_INVLDPARM;
goto error_out;
@ -1621,7 +1629,7 @@ break_out:
}
case 0x02:
{
rebuild_dpb:
rebuild_dpb:
flush_buffers(dpb->dpb_unit);
dpb->dpb_flags = M_CHANGED;
@ -1637,20 +1645,24 @@ rebuild_dpb:
{
struct buffer FAR *bp;
bpb FAR *bpbp;
DWORD newmirroring = xdffp->xdff_f.setmirroring.newmirroring;
DWORD newmirroring =
xdffp->xdff_f.setmirroring.newmirroring;
if (newmirroring != -1 && (ISFAT32(dpb) && (newmirroring & ~(0xf | 0x80))))
if (newmirroring != -1
&& (ISFAT32(dpb)
&& (newmirroring & ~(0xf | 0x80))))
{
r->AX = -DE_INVLDPARM;
goto error_out;
}
xdffp->xdff_f.setmirroring.oldmirroring = (ISFAT32(dpb) ? dpb->dpb_xflags : 0);
xdffp->xdff_f.setmirroring.oldmirroring =
(ISFAT32(dpb) ? dpb->dpb_xflags : 0);
if (newmirroring != -1 && ISFAT32(dpb))
{
bp = getblock(1, dpb->dpb_unit);
bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT);
bp->b_flag |= BFR_VALID | BFR_DIRTY;
bpbp = (bpb FAR *)& bp->b_buffer[BT_BPB];
bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB];
bpbp->bpb_xflags = newmirroring;
}
goto rebuild_dpb;
@ -1660,8 +1672,10 @@ rebuild_dpb:
struct buffer FAR *bp;
bpb FAR *bpbp;
DWORD rootclst = xdffp->xdff_f.setroot.newrootclst;
if (!ISFAT32(dpb) || (rootclst != -1 && (rootclst == 1 ||
rootclst > dpb->dpb_xsize)))
if (!ISFAT32(dpb)
|| (rootclst != -1
&& (rootclst == 1
|| rootclst > dpb->dpb_xsize)))
{
r->AX = -DE_INVLDPARM;
goto error_out;
@ -1703,11 +1717,14 @@ rebuild_dpb:
}
CLEAR_CARRY_FLAG();
if (r->SI == 0) mode = DSKREAD;
else mode = DSKWRITE;
if (r->SI == 0)
mode = DSKREAD;
else
mode = DSKWRITE;
InDOS++;
r->AX=dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf,
r->AX =
dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf,
SectorBlock->nblks, mode);
if (mode == DSKWRITE)
@ -1722,7 +1739,6 @@ rebuild_dpb:
return;
}
r->AX = 0;
r->flags &= ~FLG_CARRY;
--InDOS;
@ -1736,7 +1752,7 @@ rebuild_dpb:
/* FreeDOS LFN helper API functions */
case 0x74:
{
switch(r->AL)
switch (r->AL)
{
/* Allocate LFN inode */
case 0x01:
@ -1759,7 +1775,7 @@ rebuild_dpb:
/* Create LFN entries */
case 0x04:
{
r->AX = lfn_create_entries(r->BX, (lfn_inode_ptr)FP_DS_DX);
r->AX = lfn_create_entries(r->BX, (lfn_inode_ptr) FP_DS_DX);
break;
}
/* Delete LFN entries */
@ -1771,7 +1787,7 @@ rebuild_dpb:
/* Read next LFN */
case 0x06:
{
r->AX = lfn_dir_read(r->BX, (lfn_inode_ptr)FP_DS_DX);
r->AX = lfn_dir_read(r->BX, (lfn_inode_ptr) FP_DS_DX);
break;
}
/* Write SFN pointed by LFN inode */
@ -1799,7 +1815,9 @@ rebuild_dpb:
/* No kernel INT-23 handler required no longer -- 1999/04/15 ska */
/* ctrl-Break handler */
#pragma argsused
VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags)
VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp,
int sp, int bx, int dx, int cx, int ax,
int ip, int cs, int flags)
{
tsr = FALSE;
return_mode = 1;
@ -1813,21 +1831,11 @@ VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int
}
#endif
struct int25regs
{
UWORD es,
ds;
UWORD di,
si,
bp,
sp;
UWORD bx,
dx,
cx,
ax;
UWORD flags,
ip,
cs;
struct int25regs {
UWORD es, ds;
UWORD di, si, bp, sp;
UWORD bx, dx, cx, ax;
UWORD flags, ip, cs;
};
/*
@ -1840,8 +1848,10 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r)
BYTE FAR *buf;
UBYTE drv;
if (mode == 0x26) mode = DSKWRITEINT26;
else mode = DSKREADINT25;
if (mode == 0x26)
mode = DSKWRITEINT26;
else
mode = DSKREADINT25;
drv = r->ax;
@ -1869,16 +1879,15 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r)
if (nblks == 0xFFFF)
{
/*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);*/
/*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); */
blkno = ((struct HugeSectorBlock FAR *)buf)->blkno;
nblks = ((struct HugeSectorBlock FAR *)buf)->nblks;
buf = ((struct HugeSectorBlock FAR *)buf)->buf;
}
InDOS++;
r->ax=dskxfer(drv, blkno, buf, nblks, mode);
r->ax = dskxfer(drv, blkno, buf, nblks, mode);
if (mode == DSKWRITE)
if (r->ax <= 0)
@ -1891,20 +1900,17 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r)
return;
}
r->ax = 0;
r->flags &= ~FLG_CARRY;
--InDOS;
}
/*
VOID int25_handler(struct int25regs FAR * r) { int2526_handler(DSKREAD,r); }
VOID int26_handler(struct int25regs FAR * r) { int2526_handler(DSKWRITE,r); }
*/
#ifdef TSC
static VOID StartTrace(VOID)
{
@ -1926,11 +1932,10 @@ static VOID StartTrace(VOID)
this function is called from an assembler wrapper function
and serves the internal dos calls - int2f/12xx
*/
struct int2f12regs
{
UWORD es,ds;
UWORD di,si,bp,bx,dx,cx,ax;
UWORD ip,cs,flags;
struct int2f12regs {
UWORD es, ds;
UWORD di, si, bp, bx, dx, cx, ax;
UWORD ip, cs, flags;
UWORD callerARG1; /* used if called from INT2F/12 */
};
@ -1941,7 +1946,7 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
if (function > 0x31)
return;
switch(function)
switch (function)
{
case 0x00: /* installation check */
r.ax |= 0x00ff;
@ -1955,20 +1960,19 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
/* code, drive number, error, device header */
r.ax &= 0xff00;
r.ax |= CriticalError(
r.callerARG1 >> 8,
(r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : r.callerARG1 & 0xff,
r.di,
MK_FP(r.bp,r.si));
r.ax |= CriticalError(r.callerARG1 >> 8,
(r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : r.
callerARG1 & 0xff, r.di, MK_FP(r.bp, r.si));
break;
case 0x08: /* decrease SFT reference count */
{
sft FAR *p = MK_FP(r.es,r.di);
sft FAR *p = MK_FP(r.es, r.di);
r.ax = p->sft_count;
if (--p->sft_count == 0) --p->sft_count;
if (--p->sft_count == 0)
--p->sft_count;
}
break;
@ -1997,11 +2001,10 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
case 0x12: /* get length of asciiz string */
r.cx = fstrlen(MK_FP(r.es, r.di))+1;
r.cx = fstrlen(MK_FP(r.es, r.di)) + 1;
break;
case 0x16: /* get address of system file table entry - used by NET.EXE
BX system file table entry number ( such as returned from 2F/1220)
returns
@ -2047,14 +2050,14 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
r.si = FP_OFF(user_r);
break;
case 0x1b: /* #days in February - valid until 2099.*/
case 0x1b: /* #days in February - valid until 2099. */
r.ax = (r.ax & 0xff00) | (r.cx & 3 ? 28 : 29);
break;
case 0x21: /* truename */
truename(MK_FP(r.ds,r.si), MK_FP(r.es,r.di),0);
truename(MK_FP(r.ds, r.si), MK_FP(r.es, r.di), 0);
break;
@ -2062,14 +2065,15 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
{
struct dhdr FAR *dhp;
dhp = IsDevice((BYTE FAR *)DirEntBuffer.dir_name);
dhp = IsDevice((BYTE FAR *) DirEntBuffer.dir_name);
if (dhp)
{
r.bx = (r.bx & 0xff) | (dhp->dh_attr <<8);
r.bx = (r.bx & 0xff) | (dhp->dh_attr << 8);
r.flags &= ~FLG_CARRY;
}
else {
else
{
r.flags |= FLG_CARRY;
}
@ -2079,10 +2083,9 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
case 0x25: /* get length of asciiz string */
r.cx = fstrlen(MK_FP(r.ds, r.si))+1;
r.cx = fstrlen(MK_FP(r.ds, r.si)) + 1;
break;
case 0x2a: /* Set FastOpen but does nothing. */
r.flags &= ~FLG_CARRY;
@ -2091,7 +2094,7 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
case 0x2c: /* added by James Tabor For Zip Drives
Return Null Device Pointer */
/* by UDOS+RBIL: get header of SECOND device driver in device chain,
omitting the NUL device TE*/
omitting the NUL device TE */
r.bx = FP_SEG(nul_dev.dh_next);
r.ax = FP_OFF(nul_dev.dh_next);
@ -2103,7 +2106,8 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r)
break;
default:
printf("unimplemented internal dos function INT2F/12%02x\n",function);
printf("unimplemented internal dos function INT2F/12%02x\n",
function);
r.flags |= FLG_CARRY;
break;

View File

@ -30,7 +30,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
/*
@ -53,7 +54,6 @@ static BYTE *RcsId = "$Id$";
*/
COUNT DosDevIOctl(iregs FAR * r)
{
sft FAR *s;
@ -67,8 +67,6 @@ COUNT DosDevIOctl(iregs FAR * r)
CharReqHdr.r_status = 0;
CharReqHdr.r_count = r->CX;
/* Test that the handle is valid */
switch (r->AL)
{
@ -106,7 +104,7 @@ COUNT DosDevIOctl(iregs FAR * r)
/* JPP - changed to use default drive if drive=0 */
/* JT Fixed it */
CharReqHdr.r_unit = ( r->BL == 0 ? default_drive : r->BL - 1);
CharReqHdr.r_unit = (r->BL == 0 ? default_drive : r->BL - 1);
if (CharReqHdr.r_unit >= lastdrive)
return DE_INVLDDRV;
@ -165,8 +163,8 @@ COUNT DosDevIOctl(iregs FAR * r)
nMode = C_IOCTLOUT;
IoCharCommon:
if ((s->sft_flags & SFT_FDEVICE)
|| ((r->AL == 0x02 ) && (s->sft_dev->dh_attr & SFT_FIOCTL))
|| ((r->AL == 0x03 ) && (s->sft_dev->dh_attr & SFT_FIOCTL))
|| ((r->AL == 0x02) && (s->sft_dev->dh_attr & SFT_FIOCTL))
|| ((r->AL == 0x03) && (s->sft_dev->dh_attr & SFT_FIOCTL))
|| ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL))
|| ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL)))
{
@ -210,22 +208,22 @@ COUNT DosDevIOctl(iregs FAR * r)
case 0x05:
nMode = C_IOCTLOUT;
IoBlockCommon:
if(!dpbp)
if (!dpbp)
{
return DE_INVLDDRV;
}
if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL))
|| ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL))
|| ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL))
|| ((r->AL == 0x0d) && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)))
if (((r->AL == 0x04) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL))
|| ((r->AL == 0x05) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL))
|| ((r->AL == 0x11)
&& !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL))
|| ((r->AL == 0x0d)
&& !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)))
{
return DE_INVLDFUNC;
}
CharReqHdr.r_command = nMode;
execrh((request FAR *) & CharReqHdr,
dpbp->dpb_device);
execrh((request FAR *) & CharReqHdr, dpbp->dpb_device);
if (CharReqHdr.r_status & S_ERROR)
{
@ -268,7 +266,7 @@ COUNT DosDevIOctl(iregs FAR * r)
break;
case 0x08:
if(!dpbp)
if (!dpbp)
{
return DE_INVLDDRV;
}
@ -280,20 +278,20 @@ COUNT DosDevIOctl(iregs FAR * r)
return DE_INVLDFUNC;
case 0x09:
if(CDSp->cds_table[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV)
if (CDSp->cds_table[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV)
{
r->DX = ATTR_REMOTE ;
r->AX = S_DONE|S_BUSY;
r->DX = ATTR_REMOTE;
r->AX = S_DONE | S_BUSY;
}
else
{
if(!dpbp)
if (!dpbp)
{
return DE_INVLDDRV;
}
/* Need to add subst bit 15 */
r->DX = dpbp->dpb_device->dh_attr;
r->AX = S_DONE|S_BUSY;
r->AX = S_DONE | S_BUSY;
}
break;
@ -308,17 +306,15 @@ COUNT DosDevIOctl(iregs FAR * r)
case 0x0f:
nMode = C_SETLDEV;
IoLogCommon:
if(!dpbp)
if (!dpbp)
{
return DE_INVLDDRV;
}
if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))
{
CharReqHdr.r_command = nMode;
execrh((request FAR *) & CharReqHdr,
dpbp->dpb_device);
execrh((request FAR *) & CharReqHdr, dpbp->dpb_device);
if (CharReqHdr.r_status & S_ERROR)
{
@ -391,6 +387,3 @@ COUNT DosDevIOctl(iregs FAR * r)
* Rev 1.0 02 Jul 1995 8:32:04 patv
* Initial revision.
*/

View File

@ -10,7 +10,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *lfnaidRcsId = "$Id$";
static BYTE *lfnaidRcsId =
"$Id$";
#endif
#ifdef WITHLFNAPI
@ -36,7 +37,8 @@ COUNT lfn_allocate_inode(VOID)
{
f_node_ptr fnp = get_f_node();
struct cds FAR *cdsp;
if (fnp == 0) return LHE_NOFREEHNDL;
if (fnp == 0)
return LHE_NOFREEHNDL;
cdsp = &CDSp->cds_table[default_drive];
@ -60,7 +62,8 @@ COUNT lfn_allocate_inode(VOID)
COUNT lfn_free_inode(COUNT handle)
{
f_node_ptr fnp = xlt_fd(handle);
if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL;
if (fnp == 0 || fnp->f_count <= 0)
return LHE_INVLDHNDL;
release_f_node(fnp);
@ -70,7 +73,8 @@ COUNT lfn_free_inode(COUNT handle)
COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff)
{
f_node_ptr fnp = xlt_fd(handle);
if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL;
if (fnp == 0 || fnp->f_count <= 0)
return LHE_INVLDHNDL;
dir_init_fnode(fnp, dirstart);
fnp->f_diroff = diroff;
@ -78,36 +82,43 @@ COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff)
return SUCCESS;
}
BOOL transfer_unicode(UNICODE FAR **dptr, UNICODE FAR **sptr, COUNT count)
BOOL transfer_unicode(UNICODE FAR ** dptr, UNICODE FAR ** sptr,
COUNT count)
{
COUNT j;
BOOL found_zerro = FALSE;
for (j = 0; j < count; j++, (*dptr)++, (*sptr)++)
{
if (found_zerro) **dptr = UNICODE_FILLER;
else **dptr = **sptr;
if (**sptr == 0) found_zerro = TRUE;
if (found_zerro)
**dptr = UNICODE_FILLER;
else
**dptr = **sptr;
if (**sptr == 0)
found_zerro = TRUE;
}
return found_zerro;
}
BOOL lfn_to_unicode(UNICODE FAR **name, struct lfn_entry FAR *lep)
BOOL lfn_to_unicode(UNICODE FAR ** name, struct lfn_entry FAR * lep)
{
UNICODE FAR *ptr;
ptr = lep->lfn_name0_4;
if (!transfer_unicode(name, &ptr, 5)) return FALSE;
if (!transfer_unicode(name, &ptr, 5))
return FALSE;
ptr = lep->lfn_name5_10;
if (!transfer_unicode(name, &ptr, 6)) return FALSE;
if (!transfer_unicode(name, &ptr, 6))
return FALSE;
ptr = lep->lfn_name11_12;
if (!transfer_unicode(name, &ptr, 2)) return FALSE;
if (!transfer_unicode(name, &ptr, 2))
return FALSE;
return TRUE;
}
VOID unicode_to_lfn(UNICODE FAR **name, struct lfn_entry FAR *lep)
VOID unicode_to_lfn(UNICODE FAR ** name, struct lfn_entry FAR * lep)
{
UNICODE FAR *ptr;
@ -127,15 +138,20 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip)
ULONG sfn_diroff;
BOOL name_tail = FALSE;
f_node_ptr fnp = xlt_fd(handle);
if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL;
if (fnp == 0 || fnp->f_count <= 0)
return LHE_INVLDHNDL;
while (TRUE)
{
rc = dir_read(fnp);
if (rc == 0) return SUCCESS;
else if (rc == DE_SEEK) return LHE_SEEK;
else if (rc == DE_BLKINVLD) return LHE_IOERROR;
if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_attrib != D_LFN)
if (rc == 0)
return SUCCESS;
else if (rc == DE_SEEK)
return LHE_SEEK;
else if (rc == DE_BLKINVLD)
return LHE_IOERROR;
if (fnp->f_dir.dir_name[0] != DELETED
&& fnp->f_dir.dir_attrib != D_LFN)
{
fmemcpy(&lip->l_dir, &fnp->f_dir, sizeof(struct dirent));
sfn_diroff = fnp->f_diroff;
@ -147,17 +163,21 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip)
fmemset(lip->name, 0, 256 * sizeof(UNICODE));
while (TRUE)
{
if (fnp->f_diroff == 0) break;
fnp->f_diroff -= 2*DIRENT_SIZE;
if (fnp->f_diroff == 0)
break;
fnp->f_diroff -= 2 * DIRENT_SIZE;
rc = dir_read(fnp);
if (rc == DE_BLKINVLD) return LHE_IOERROR;
if (rc == DE_BLKINVLD)
return LHE_IOERROR;
if (fnp->f_dir.dir_name[0] == DELETED
|| fnp->f_dir.dir_attrib != D_LFN) break;
|| fnp->f_dir.dir_attrib != D_LFN)
break;
name_tail = lfn_to_unicode(&lfn_name, lfn(fnp));
real_id = lfn(fnp)->lfn_id;
if (real_id & 0x40)
{
if ((real_id | 0x40) != id) return LHE_DAMAGEDFS;
if ((real_id | 0x40) != id)
return LHE_DAMAGEDFS;
}
else
{
@ -176,7 +196,8 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip)
COUNT lfn_dir_write(COUNT handle)
{
f_node_ptr fnp = xlt_fd(handle);
if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL;
if (fnp == 0 || fnp->f_count <= 0)
return LHE_INVLDHNDL;
if (!dir_write(fnp))
{
@ -196,10 +217,10 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip)
COUNT entries_needed, free_entries, i, rc;
UNICODE FAR *lfn_name = lip->name;
ULONG sfn_offset;
if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL;
if (fnp == 0 || fnp->f_count <= 0)
return LHE_INVLDHNDL;
entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1)
/ CHARS_IN_LFN_ENTRY + 1; /* We want to create SFN entry too */
entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1) / CHARS_IN_LFN_ENTRY + 1; /* We want to create SFN entry too */
/* Scan the directory from the very begining for the free directory entries */
lfn_setup_inode(handle, fnp->f_dirstart, 0);
@ -213,17 +234,22 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip)
if (free_entries == entries_needed)
break;
}
else free_entries = 0;
else
free_entries = 0;
}
if (rc == DE_BLKINVLD) return LHE_IOERROR;
if (rc == DE_BLKINVLD)
return LHE_IOERROR;
/* We have reached the end of the directory here. */
if (free_entries != entries_needed) free_entries = 0;
if (free_entries != entries_needed)
free_entries = 0;
while (free_entries != entries_needed)
{
rc = dir_read(fnp);
if (rc == 0) free_entries++;
else if (rc == DE_BLKINVLD) return LHE_IOERROR;
if (rc == 0)
free_entries++;
else if (rc == DE_BLKINVLD)
return LHE_IOERROR;
else if (rc == DE_SEEK && extend_dir(fnp) != SUCCESS)
{
lfn_allocate_inode(); /* Another hack. */
@ -238,7 +264,8 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip)
lfn_name = &lip->name[i * CHARS_IN_LFN_ENTRY];
unicode_to_lfn(&lfn_name, lfn(fnp));
fnp->f_dir.dir_attrib = D_LFN;
if (!dir_write(fnp)) return LHE_IOERROR;
if (!dir_write(fnp))
return LHE_IOERROR;
fnp->f_diroff -= DIRENT_SIZE;
}
@ -250,15 +277,17 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip)
COUNT lfn_remove_entries(COUNT handle)
{
f_node_ptr fnp = xlt_fd(handle);
if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL;
if (fnp == 0 || fnp->f_count <= 0)
return LHE_INVLDHNDL;
if(remove_lfn_entries(fnp) < 0) return LHE_IOERROR;
if (remove_lfn_entries(fnp) < 0)
return LHE_IOERROR;
return SUCCESS;
}
/* Calculate checksum for the 8.3 name */
UBYTE lfn_checksum(UBYTE *sfn_name)
UBYTE lfn_checksum(UBYTE * sfn_name)
{
UBYTE sum;
COUNT i;
@ -269,7 +298,7 @@ UBYTE lfn_checksum(UBYTE *sfn_name)
return sum;
}
COUNT ufstrlen(REG UNICODE FAR *s)
COUNT ufstrlen(REG UNICODE FAR * s)
{
REG COUNT cnt = 0;

View File

@ -39,7 +39,6 @@ GLOBAL BYTE copyright[] =
"GNU General Public License as published by the Free Software Foundation;\n"
"either version 2, or (at your option) any later version.\n";
/*
These are the far variables from the DOS data segment that we need here. The
init procedure uses a different default DS data segment, which is discarded
@ -48,45 +47,41 @@ GLOBAL BYTE copyright[] =
-- Bart
*/
extern UBYTE DOSFAR nblkdev,
DOSFAR lastdrive; /* value of last drive */
extern UBYTE DOSFAR nblkdev, DOSFAR lastdrive; /* value of last drive */
GLOBAL BYTE
DOSFAR os_major, /* major version number */
GLOBAL BYTE DOSFAR os_major, /* major version number */
DOSFAR os_minor, /* minor version number */
DOSFAR dosidle_flag,
DOSFAR BootDrive, /* Drive we came up from */
DOSFAR dosidle_flag, DOSFAR BootDrive, /* Drive we came up from */
DOSFAR default_drive; /* default drive for dos */
GLOBAL BYTE DOSFAR os_release[];
/* GLOBAL BYTE DOSFAR copyright[]; */
GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */
extern struct dpb FAR * DOSFAR DPBp; /* First drive Parameter Block */
extern cdstbl FAR * DOSFAR CDSp; /* Current Directory Structure */
extern struct dpb FAR *DOSFAR DPBp; /* First drive Parameter Block */
extern cdstbl FAR *DOSFAR CDSp; /* Current Directory Structure */
extern struct dhdr FAR * DOSFAR clock, /* CLOCK$ device */
extern struct dhdr FAR *DOSFAR clock, /* CLOCK$ device */
FAR * DOSFAR syscon; /* console device */
extern struct dhdr DOSTEXTFAR con_dev, /* console device drive */
DOSTEXTFAR clk_dev, /* Clock device driver */
DOSTEXTFAR blk_dev; /* Block device (Disk) driver */
extern UWORD
DOSFAR ram_top; /* How much ram in Kbytes */
extern iregs FAR * DOSFAR user_r; /* User registers for int 21h call */
extern UWORD DOSFAR ram_top; /* How much ram in Kbytes */
extern iregs FAR *DOSFAR user_r; /* User registers for int 21h call */
extern BYTE FAR _HMATextEnd[];
#ifdef VERSION_STRINGS
static BYTE *mainRcsId = "$Id$";
static BYTE *mainRcsId =
"$Id$";
#endif
struct _KernelConfig InitKernelConfig = {"", 0, 0, 0, 0, 0, 0};
struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0 };
extern WORD days[2][13];
extern BYTE FAR * lpBase;
extern BYTE FAR * lpOldTop;
extern BYTE FAR * lpTop;
extern BYTE FAR * upBase;
extern BYTE FAR *lpBase;
extern BYTE FAR *lpOldTop;
extern BYTE FAR *lpTop;
extern BYTE FAR *upBase;
extern BYTE _ib_start[], _ib_end[], _init_end[];
INIT VOID configDone(VOID);
@ -100,7 +95,7 @@ INIT VOID FsConfig(VOID);
INIT VOID InitPrinters(VOID);
#ifdef _MSC_VER
BYTE _acrtused = 0;
BYTE _acrtused = 0;
#endif
#ifdef _MSC_VER
@ -111,18 +106,16 @@ __segment DosTextSeg = 0;
#endif
INIT VOID ASMCFUNC FreeDOSmain(void)
{
#ifdef _MSC_VER
extern FAR DATASTART;
extern FAR prn_dev;
DosDataSeg = (__segment)&DATASTART;
DosTextSeg = (__segment)&prn_dev;
DosDataSeg = (__segment) & DATASTART;
DosTextSeg = (__segment) & prn_dev;
#endif
fmemcpy(&InitKernelConfig,&LowKernelConfig,sizeof(InitKernelConfig));
fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig));
setvec(0, int0_handler); /* zero divide */
setvec(1, empty_handler); /* single step */
@ -155,8 +148,8 @@ INIT VOID ASMCFUNC FreeDOSmain(void)
void InitializeAllBPBs(VOID)
{
static char filename[] = "A:-@JUNK@-.TMP";
int drive,fileno;
for (drive = 'C'; drive < 'A'+nblkdev; drive++)
int drive, fileno;
for (drive = 'C'; drive < 'A' + nblkdev; drive++)
{
filename[0] = drive;
if ((fileno = open(filename, O_RDONLY)) >= 0)
@ -175,14 +168,14 @@ INIT void init_kernel(void)
ram_top = init_oem();
/* move kernel to high conventional RAM, just below the init code */
lpTop = MK_FP(ram_top * 64 - (FP_OFF(_init_end)+15)/16 -
(FP_OFF(_HMATextEnd)+15)/16, 0);
lpTop = MK_FP(ram_top * 64 - (FP_OFF(_init_end) + 15) / 16 -
(FP_OFF(_HMATextEnd) + 15) / 16, 0);
MoveKernel(FP_SEG(lpTop));
lpOldTop = lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0);
/* Fake int 21h stack frame */
user_r = (iregs FAR *) MK_FP(DOS_PSP,0xD0);
user_r = (iregs FAR *) MK_FP(DOS_PSP, 0xD0);
#ifndef KDB
for (i = 0x20; i <= 0x3f; i++)
@ -288,7 +281,7 @@ INIT VOID FsConfig(VOID)
dpb = DPBp;
/* Initialize the current directory structures */
for (i = 0; i < lastdrive ; i++)
for (i = 0; i < lastdrive; i++)
{
struct cds FAR *pcds_table = &CDSp->cds_table[i];
@ -296,7 +289,7 @@ INIT VOID FsConfig(VOID)
pcds_table->cdsCurrentPath[0] += i;
if (i < nblkdev && (ULONG)dpb != 0xffffffffl)
if (i < nblkdev && (ULONG) dpb != 0xffffffffl)
{
pcds_table->cdsDpb = dpb;
pcds_table->cdsFlags = CDSPHYSDRV;
@ -318,10 +311,9 @@ INIT VOID FsConfig(VOID)
INIT VOID signon()
{
printf("\n%S" ,(void FAR *)os_release);
printf("\n%S", (void FAR *)os_release);
printf("Kernel compatibility %d.%d",
os_major, os_minor );
printf("Kernel compatibility %d.%d", os_major, os_minor);
#if defined(__TURBOC__)
printf(" - TURBOC");
@ -332,7 +324,6 @@ INIT VOID signon()
#else
generate some bullshit error here, as the compiler should be known
#endif
#if defined (I386)
printf(" - 80386 CPU required");
#elif defined (I186)
@ -342,14 +333,13 @@ INIT VOID signon()
#ifdef WITHFAT32
printf(" - FAT32 support");
#endif
printf("\n\n%S",(void FAR *)copyright);
printf("\n\n%S", (void FAR *)copyright);
}
INIT void kernel()
{
#if 0
BYTE FAR *ep,
*sp;
BYTE FAR *ep, *sp;
#endif
exec_blk exb;
CommandTail Cmd;
@ -381,56 +371,51 @@ INIT void kernel()
*((int FAR *)ep) = 0;
ep += sizeof(int);
#else
exb.exec.env_seg = DOS_PSP+8;
exb.exec.env_seg = DOS_PSP + 8;
fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env));
#endif
#endif
RootPsp = ~0;
/* process 0 */
/* Execute command.com /P from the drive we just booted from */
fstrncpy(Cmd.ctBuffer, Config.cfgInitTail,
sizeof(Config.cfgInitTail)-1);
sizeof(Config.cfgInitTail) - 1);
for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++)
if (Cmd.ctBuffer[Cmd.ctCount] == '\r')
break;
/* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */
if (Cmd.ctCount < 127 - 3)
{
extern int singleStep ;
extern int singleStep;
extern int SkipAllConfig;
char *insertString = NULL;
if (singleStep) insertString = " /Y"; /* single step AUTOEXEC */
if (singleStep)
insertString = " /Y"; /* single step AUTOEXEC */
if (SkipAllConfig) insertString = " /D"; /* disable AUTOEXEC */
if (SkipAllConfig)
insertString = " /D"; /* disable AUTOEXEC */
if (insertString)
{
/* insert /D, /Y as first argument */
int cmdEnd,i,slen = strlen(insertString);
int cmdEnd, i, slen = strlen(insertString);
for (cmdEnd = 0;cmdEnd < 127; cmdEnd++)
for (cmdEnd = 0; cmdEnd < 127; cmdEnd++)
{
if (Cmd.ctBuffer[cmdEnd] == ' ' ||
Cmd.ctBuffer[cmdEnd] == '\t' ||
Cmd.ctBuffer[cmdEnd] == '\r')
Cmd.ctBuffer[cmdEnd] == '\t' || Cmd.ctBuffer[cmdEnd] == '\r')
{
for (i = 127 - slen; i >= cmdEnd; i--)
Cmd.ctBuffer[i+slen] = Cmd.ctBuffer[i];
Cmd.ctBuffer[i + slen] = Cmd.ctBuffer[i];
fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString,slen);
fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString, slen);
Cmd.ctCount += slen;
@ -440,8 +425,6 @@ INIT void kernel()
}
}
exb.exec.cmd_line = (CommandTail FAR *) & Cmd;
exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0;
@ -449,13 +432,17 @@ INIT void kernel()
printf("Process 0 starting: %s\n\n", Config.cfgInit);
#endif
while ((rc = init_DosExec(Config.cfgP_0_startmode, &exb, Config.cfgInit)) != SUCCESS)
while ((rc =
init_DosExec(Config.cfgP_0_startmode, &exb,
Config.cfgInit)) != SUCCESS)
{
BYTE *pLine;
printf("\nBad or missing Command Interpreter: %d - %s\n", rc, Cmd.ctBuffer);
printf("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n");
rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer)-1);
Cmd.ctBuffer[rc]='\0';
printf("\nBad or missing Command Interpreter: %d - %s\n", rc,
Cmd.ctBuffer);
printf
("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n");
rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer) - 1);
Cmd.ctBuffer[rc] = '\0';
/* Get the string argument that represents the new init pgm */
pLine = GetStringArg(Cmd.ctBuffer, Config.cfgInit);
@ -467,7 +454,7 @@ INIT void kernel()
/* and add a DOS new line just to be safe */
strcat(Cmd.ctBuffer, "\r\n");
Cmd.ctCount = rc-(pLine-Cmd.ctBuffer);
Cmd.ctCount = rc - (pLine - Cmd.ctBuffer);
#ifdef DEBUG
printf("Process 0 starting: %s\n\n", Config.cfgInit);
@ -484,17 +471,20 @@ static VOID update_dcb(struct dhdr FAR * dhp)
COUNT nunits = dhp->dh_name[0];
struct dpb FAR *dpb;
if (nblkdev==0)
if (nblkdev == 0)
dpb = DPBp;
else {
for (dpb = DPBp; (ULONG)dpb->dpb_next != 0xffffffffl; dpb = dpb->dpb_next)
else
{
for (dpb = DPBp; (ULONG) dpb->dpb_next != 0xffffffffl;
dpb = dpb->dpb_next)
;
dpb = dpb->dpb_next = (struct dpb FAR *)KernelAlloc(nunits*sizeof(struct dpb));
dpb = dpb->dpb_next =
(struct dpb FAR *)KernelAlloc(nunits * sizeof(struct dpb));
}
for(Index = 0; Index < nunits; Index++)
for (Index = 0; Index < nunits; Index++)
{
dpb->dpb_next = dpb+1;
dpb->dpb_next = dpb + 1;
dpb->dpb_unit = nblkdev;
dpb->dpb_subunit = Index;
dpb->dpb_device = dhp;
@ -507,17 +497,17 @@ static VOID update_dcb(struct dhdr FAR * dhp)
++dpb;
++nblkdev;
}
(dpb-1)->dpb_next = (void FAR *)0xFFFFFFFFl;
(dpb - 1)->dpb_next = (void FAR *)0xFFFFFFFFl;
}
/* If cmdLine is NULL, this is an internal driver */
BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_top)
BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode,
COUNT r_top)
{
request rq;
UCOUNT maxmem = ((UCOUNT)r_top << 6) - FP_SEG(dhp);
UCOUNT maxmem = ((UCOUNT) r_top << 6) - FP_SEG(dhp);
if (maxmem >= 0x1000)
maxmem = 0xFFFF;
@ -540,25 +530,27 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_
if (rq.r_status & S_ERROR)
return TRUE;
if(cmdLine){
if (cmdLine)
{
if (mode)
{
/* Don't link in device drivers which do not take up memory */
if (rq.r_endaddr == (BYTE FAR *)dhp)
if (rq.r_endaddr == (BYTE FAR *) dhp)
return TRUE;
else
upBase = rq.r_endaddr;
}
else
{
if (rq.r_endaddr == (BYTE FAR *)dhp)
if (rq.r_endaddr == (BYTE FAR *) dhp)
return TRUE;
else
lpBase = rq.r_endaddr;
}
}
if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) {
if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0))
{
dhp->dh_name[0] = rq.r_nunits;
update_dcb(dhp);
}
@ -571,7 +563,6 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_
return FALSE;
}
INIT static void InitIO(void)
{
/* Initialize driver chain */
@ -599,17 +590,17 @@ VOID init_fatal(BYTE * err_msg)
INIT VOID InitPrinters(VOID)
{
iregs r;
int num_printers,i;
int num_printers, i;
init_call_intr(0x11,&r); /* get equipment list */
init_call_intr(0x11, &r); /* get equipment list */
num_printers = (r.a.x >> 14) & 3; /* bits 15-14 */
for (i = 0;i < num_printers;i++)
for (i = 0; i < num_printers; i++)
{
r.a.x = 0x0100; /* initialize printer */
r.d.x = i;
init_call_intr(0x17,&r);
init_call_intr(0x17, &r);
}
}
@ -705,5 +696,3 @@ INIT VOID InitPrinters(VOID)
* Rev 1.0 02 Jul 1995 8:33:18 patv
* Initial revision.
*/

View File

@ -30,7 +30,8 @@
#include "globals.h"
#ifdef VERSION_STRING
static BYTE *memmgrRcsId = "$Id$";
static BYTE *memmgrRcsId =
"$Id$";
#endif
VOID mcb_init();
@ -40,7 +41,7 @@ VOID show_chain();
/*#define nxtMCBsize(mcb,size) \
MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) */
void FAR *nxtMCBsize(mcb FAR *Mcb, int size)
void FAR *nxtMCBsize(mcb FAR * Mcb, int size)
{
return MK_FP(far2para((VOID FAR *) (Mcb)) + (size) + 1, 0);
}
@ -85,10 +86,10 @@ seg far2para(VOID FAR * p)
seg long2para(ULONG size)
{
UWORD high = size>>16;
if ((UWORD)size > 0xfff0)
UWORD high = size >> 16;
if ((UWORD) size > 0xfff0)
high++;
return (((UWORD)size + 0x0f) >> 4) + (high << 12);
return (((UWORD) size + 0x0f) >> 4) + (high << 12);
}
/*
@ -98,10 +99,11 @@ VOID FAR *add_far(VOID FAR * fp, ULONG off)
{
UWORD off2;
if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + FP_OFF(off);
if (FP_SEG(fp) == 0xffff)
return ((BYTE FAR *) fp) + FP_OFF(off);
off += FP_OFF(fp);
off2 = ((off >> 16) << 12) + ((UWORD)off >> 4);
off2 = ((off >> 16) << 12) + ((UWORD) off >> 4);
return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf);
}
@ -114,7 +116,8 @@ VOID FAR *adjust_far(VOID FAR * fp)
/* and return an adddress adjusted to the nearest paragraph */
/* boundary. */
if (FP_SEG(fp) == 0xffff) return fp;
if (FP_SEG(fp) == 0xffff)
return fp;
return MK_FP(FP_SEG(fp) + (FP_OFF(fp) >> 4), FP_OFF(fp) & 0xf);
}
@ -132,7 +135,8 @@ VOID FAR *adjust_far(VOID FAR * fp)
size is the minimum size of the block to search for,
even if mode == LARGEST.
*/
COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize)
COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para,
UWORD FAR * asize)
{
REG mcb FAR *p;
mcb FAR *foundSeg;
@ -147,7 +151,7 @@ searchAgain:
/*
Hack to the Umb Region direct for now. Save time and program space.
*/
if((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) &&
if ((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) &&
uppermem_link && uppermem_root)
p = para2far(uppermem_root);
@ -212,8 +216,9 @@ searchAgain:
if (!foundSeg || !foundSeg->m_size)
{ /* no block to fullfill the request */
if((mode != LARGEST) && (mode & FIRST_FIT_U) &&
uppermem_link && uppermem_root) {
if ((mode != LARGEST) && (mode & FIRST_FIT_U) &&
uppermem_link && uppermem_root)
{
mode &= ~FIRST_FIT_U;
goto searchAgain;
}
@ -230,7 +235,8 @@ stopIt: /* reached from FIRST_FIT on match */
/* foundSeg := pointer to allocated block
p := pointer to MCB that will form the rest of the block
*/
if ((mode == LAST_FIT)||(mode == LAST_FIT_UO)||(mode == LAST_FIT_U))
if ((mode == LAST_FIT) || (mode == LAST_FIT_UO)
|| (mode == LAST_FIT_U))
{
/* allocate the block from the end of the found block */
p = foundSeg;
@ -283,9 +289,8 @@ COUNT DosMemLargest(UWORD FAR * size)
REG mcb FAR *p;
/* Initialize */
p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link && uppermem_root)
? para2far(uppermem_root)
: para2far(first_mcb);
p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link
&& uppermem_root) ? para2far(uppermem_root) : para2far(first_mcb);
/* Cycle through the whole MCB chain to find the largest unused
area. Join all unused areas together. */
@ -384,8 +389,7 @@ COUNT DosMemFree(UWORD para)
*/
COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize)
{
REG mcb FAR *p,
FAR * q;
REG mcb FAR *p, FAR * q;
REG COUNT i;
/* Initialize */
@ -459,8 +463,8 @@ COUNT DosMemCheck(void)
if (p->m_type != MCB_NORMAL)
{
printf("dos mem corrupt, first_mcb=%04x\n", first_mcb);
hexd("prev " ,pprev,16);
hexd("notMZ",p,16);
hexd("prev ", pprev, 16);
hexd("notMZ", p, 16);
return DE_MCBDESTRY;
}
@ -552,12 +556,10 @@ VOID mcb_print(mcb FAR * mcbp)
fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8);
buff[8] = '\0';
printf("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n",
FP_SEG(mcbp),
FP_OFF(mcbp),
*buff == '\0' ? "*NO-ID*" : buff,
mcbp->m_type, mcbp->m_type > ' ' ? mcbp->m_type : ' ',
mcbp->m_psp,
printf
("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n",
FP_SEG(mcbp), FP_OFF(mcbp), *buff == '\0' ? "*NO-ID*" : buff,
mcbp->m_type, mcbp->m_type > ' ' ? mcbp->m_type : ' ', mcbp->m_psp,
mcbp->m_size);
}
#endif
@ -566,16 +568,16 @@ VOID DosUmbLink(BYTE n)
{
REG mcb FAR *p;
REG mcb FAR *q;
mcb FAR *end_of_conv_mem = para2far(ram_top*64-1);
mcb FAR *end_of_conv_mem = para2far(ram_top * 64 - 1);
if (uppermem_root == 0)
return;
q = p = para2far(first_mcb);
/* like a xor thing! */
if((uppermem_link == 1) && (n == 0))
if ((uppermem_link == 1) && (n == 0))
{
while ( p != end_of_conv_mem )
while (p != end_of_conv_mem)
{
if (mcbFree(p))
joinMCBs(p);
@ -585,22 +587,21 @@ VOID DosUmbLink(BYTE n)
p = nxtMCB(p);
}
if(q->m_type == MCB_NORMAL)
if (q->m_type == MCB_NORMAL)
q->m_type = MCB_LAST;
uppermem_link = n;
}
else
if((uppermem_link == 0) && (n == 1))
else if ((uppermem_link == 0) && (n == 1))
{
while( q->m_type != MCB_LAST)
while (q->m_type != MCB_LAST)
{
if (!mcbValid(q))
goto DUL_exit;
q = nxtMCB(q);
}
if(q->m_type == MCB_LAST)
if (q->m_type == MCB_LAST)
q->m_type = MCB_NORMAL;
uppermem_link = n;
}
@ -625,37 +626,35 @@ extern BYTE _INIT_DATA_START[], _INIT_DATA_END[];
VOID ClaimINITDataSegment()
{
unsigned ilow,ihigh;
VOID FAR * p;
unsigned ilow, ihigh;
VOID FAR *p;
if (INITDataSegmentClaimed)
return;
INITDataSegmentClaimed = 1;
ilow = (unsigned)_INIT_DATA_START;
ilow = (ilow+0x0f) & ~0x000f;
ilow = (ilow + 0x0f) & ~0x000f;
ihigh = (unsigned)_INIT_DATA_END;
ihigh = ((ihigh + 0x0f) & ~0x000f) - 0x20;
if (ilow +0x10 < ihigh)
if (ilow + 0x10 < ihigh)
{
printf("CLAIMING INIT_DATA memory - %u bytes\n",ihigh - ilow);
printf("CLAIMING INIT_DATA memory - %u bytes\n", ihigh - ilow);
}
((mcb *) ilow)->m_type = MCB_NORMAL; /* 'M' */
((mcb *) ilow)->m_psp = FREE_PSP; /* '0' */
((mcb *) ilow)->m_size = (ihigh - ilow - 0x10) >> 4; /* '0' */
((mcb*)ilow)->m_type = MCB_NORMAL; /* 'M' */
((mcb*)ilow)->m_psp = FREE_PSP; /* '0' */
((mcb*)ilow)->m_size = (ihigh-ilow-0x10)>>4; /* '0' */
((mcb *) ihigh)->m_type = MCB_NORMAL; /* 'M' */
((mcb *) ihigh)->m_psp = 0x0008; /* system */
((mcb*)ihigh)->m_type = MCB_NORMAL; /* 'M' */
((mcb*)ihigh)->m_psp = 0x0008; /* system */
p = (void FAR *)(void *)ihigh;
p = (void FAR*)(void*)ihigh;
((mcb *) ihigh)->m_size = first_mcb - 1 - FP_SEG(p) - (FP_OFF(p) >> 4);
((mcb*)ihigh)->m_size = first_mcb -1 - FP_SEG(p) - (FP_OFF(p) >> 4);
p = (void FAR*)(void*)ilow;
p = (void FAR *)(void *)ilow;
first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4);
@ -712,4 +711,3 @@ VOID ClaimINITDataSegment()
* Rev 1.0 02 Jul 1995 8:33:08 patv
* Initial revision.
*/

View File

@ -29,7 +29,8 @@
#include "portab.h"
#ifdef VERSION_STRINGS
static BYTE *miscRcsId = "$Id$";
static BYTE *miscRcsId =
"$Id$";
#endif
#include "globals.h"
@ -119,4 +120,3 @@ VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n)
* Rev 1.0 02 Jul 1995 8:06:28 patv
* Initial revision.
*/

View File

@ -31,7 +31,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
/* see RBIL D-2152 and D-215D06 before attempting
@ -66,4 +67,3 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num)
* *** empty log message ***
*
*/

View File

@ -26,7 +26,8 @@
/****************************************************************/
#ifdef VERSION_STRINGS
static BYTE *mainRcsId = "$Id$";
static BYTE *mainRcsId =
"$Id$";
#endif
#include "portab.h"
@ -39,8 +40,7 @@ static BYTE *mainRcsId = "$Id$";
*/
int SetJFTSize(UWORD nHandles)
{
UWORD block,
maxBlock;
UWORD block, maxBlock;
psp FAR *ppsp = MK_FP(cu_psp, 0);
UBYTE FAR *newtab;
COUNT i;
@ -51,7 +51,8 @@ int SetJFTSize(UWORD nHandles)
return SUCCESS;
}
if ((DosMemAlloc((nHandles + 0xf) >> 4, mem_access_mode, &block, &maxBlock)) < 0)
if ((DosMemAlloc
((nHandles + 0xf) >> 4, mem_access_mode, &block, &maxBlock)) < 0)
return DE_NOMEM;
++block;
@ -74,13 +75,8 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr)
{
/* create filename from current date and time */
char FAR *ptmp = pathname;
BYTE wd,
month,
day;
BYTE h,
m,
s,
hund;
BYTE wd, month, day;
BYTE h, m, s, hund;
WORD sh;
WORD year;
int rc;
@ -98,24 +94,23 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr)
sh = s * 100 + hund;
for ( loop = 0; loop < 0xfff; loop++)
for (loop = 0; loop < 0xfff; loop++)
{
sprintf(name83,"%x%x%x%x%x%03x.%03x",
year & 0xf,month & 0xf, day & 0xf,h & 0xf,m & 0xf, sh&0xfff,
loop & 0xfff);
sprintf(name83, "%x%x%x%x%x%03x.%03x",
year & 0xf, month & 0xf, day & 0xf, h & 0xf, m & 0xf,
sh & 0xfff, loop & 0xfff);
fmemcpy(ptmp, name83, 13);
if ((rc = DosOpen(pathname, 0)) < 0 &&
rc != DE_ACCESS /* subdirectory ?? */
if ((rc = DosOpen(pathname, 0)) < 0 && rc != DE_ACCESS /* subdirectory ?? */
/* todo: sharing collision on
network drive
*/
)
break;
if (rc >= 0) DosClose(rc);
if (rc >= 0)
DosClose(rc);
}
if (rc == DE_FILENOTFND)
@ -125,13 +120,13 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr)
return rc;
}
COUNT get_verify_drive(char FAR *src)
COUNT get_verify_drive(char FAR * src)
{
UBYTE drive;
/* Do we have a drive? */
if (src[1] == ':')
drive = ((src[0]-1) | 0x20) - ('a'-1);
drive = ((src[0] - 1) | 0x20) - ('a' - 1);
else
return default_drive;
if (drive < lastdrive && CDSp->cds_table[drive].cdsFlags & CDSVALID)
@ -194,7 +189,8 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
*/
/* check for a device */
if ((*src != '.') && (*src != '\\') && (*src != '/') && ((dhp = IsDevice(src)) != NULL))
if ((*src != '.') && (*src != '\\') && (*src != '/')
&& ((dhp = IsDevice(src)) != NULL))
{
froot = get_root(src);
@ -204,25 +200,33 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
as long as the name matches.
- Ron Cemer */
buf[2] ='/';
buf[2] = '/';
/* /// Bug: should be only copying up to first space.
- Ron Cemer */
for (d = 0; d < FNAME_SIZE && dhp->dh_name[d] != 0 && dhp->dh_name[d] != ' '; d++)
for (d = 0;
d < FNAME_SIZE && dhp->dh_name[d] != 0 && dhp->dh_name[d] != ' ';
d++)
*bufp++ = dhp->dh_name[d];
/* /// DOS will return C:/NUL.LST if you pass NUL.LST in.
DOS will also return C:/NUL.??? if you pass NUL.* in.
Code added here to support this.
- Ron Cemer */
while ( (*froot != '.') && (*froot != '\0') ) froot++;
if (*froot) froot++;
if (*froot) {
while ((*froot != '.') && (*froot != '\0'))
froot++;
if (*froot)
froot++;
if (*froot)
{
*bufp++ = '.';
for (i = 0; i < FEXT_SIZE; i++) {
if ( (*froot == '\0') || (*froot == '.') )
for (i = 0; i < FEXT_SIZE; i++)
{
if ((*froot == '\0') || (*froot == '.'))
break;
if (*froot == '*') {
for (; i < FEXT_SIZE; i++) *bufp++ = '?';
if (*froot == '*')
{
for (; i < FEXT_SIZE; i++)
*bufp++ = '?';
break;
}
*bufp++ = *froot++;
@ -240,15 +244,20 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
* path to the executable file.
* Jun 11, 2000 - rbc */
/* /// Changed to "while" from "if". - Ron Cemer */
while ( (src[0] == '.') && (src[1] == '\\') ) src += 2;
while ((src[0] == '.') && (src[1] == '\\'))
src += 2;
current_ldt = &CDSp->cds_table[i];
/* Always give the redirector a chance to rewrite the filename */
fstrncpy(bufp - 1, src, sizeof(buf) - (bufp - buf));
if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS) && (dest[0] != '\0')) {
if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS)
&& (dest[0] != '\0'))
{
return SUCCESS;
} else {
}
else
{
bufp[-1] = '\\';
}
if (t == FALSE)
@ -261,7 +270,7 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
if (*src != '\\' && *src != '/') /* append current dir */
{
DosGetCuDir((UBYTE)(i+1), bufp);
DosGetCuDir((UBYTE) (i + 1), bufp);
if (*bufp)
{
while (*bufp)
@ -297,7 +306,7 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
{
char c;
c = *src++;
if(!n)
if (!n)
return DE_PATHNOTFND; /* do this for now */
n--;
switch (c)
@ -327,7 +336,8 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
case '/': /* convert to backslash */
case '\\':
if (bufp[-1] != '\\'){
if (bufp[-1] != '\\')
{
*bufp++ = '\\';
n = 9;
}
@ -352,11 +362,11 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
}
else if (*src == '/' || *src == '\\' || *src == 0)
break;
/* --bufp;*/
/* --bufp; */
else
return DE_PATHNOTFND;
}
else if ( *src == '/' || *src == '\\' || *src == 0)
else if (*src == '/' || *src == '\\' || *src == 0)
{
break;
}
@ -381,95 +391,122 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
/* /// Beginning of new code. - Ron Cemer */
bufp--;
{
char c, *bufend = buf+(sizeof(buf)-1);
char c, *bufend = buf + (sizeof(buf) - 1);
int gotAnyWildcards = 0;
int seglen, copylen, state;
while ( (*src) && (bufp < bufend) ) {
while ((*src) && (bufp < bufend))
{
/* Skip duplicated slashes. */
while ( (*src == '/') || (*src == '\\') ) src++;
if (!(*src)) break;
while ((*src == '/') || (*src == '\\'))
src++;
if (!(*src))
break;
/* Find the end of this segment in the source string. */
for (seglen = 0; ; seglen++) {
for (seglen = 0;; seglen++)
{
c = src[seglen];
if ( (c == '\0') || (c == '/') || (c == '\\') )
if ((c == '\0') || (c == '/') || (c == '\\'))
break;
}
if (seglen > 0) {
if (seglen > 0)
{
/* Ignore all ".\" or "\." path segments. */
if ( (seglen != 1) || (*src != '.') ) {
if ((seglen != 1) || (*src != '.'))
{
/* Apply ".." to the path by removing
last path segment from buf. */
if ( (seglen==2) && (src[0] == '.') && (src[1] == '.') ) {
if (bufp > (buf+rootEndPos)) {
if ((seglen == 2) && (src[0] == '.') && (src[1] == '.'))
{
if (bufp > (buf + rootEndPos))
{
bufp--;
while ( (bufp > (buf+rootEndPos))
&& (*bufp != '/')
&& (*bufp != '\\') )
while ((bufp > (buf + rootEndPos))
&& (*bufp != '/') && (*bufp != '\\'))
bufp--;
} else {
}
else
{
/* .. in root dir illegal */
return DE_PATHNOTFND;
}
} else {
}
else
{
/* New segment. If any wildcards in previous
segment(s), this is an invalid path. */
if (gotAnyWildcards || src[0]=='.') return DE_PATHNOTFND;
if (gotAnyWildcards || src[0] == '.')
return DE_PATHNOTFND;
/* Append current path segment to result. */
*(bufp++) = '\\';
if (bufp >= bufend) break;
if (bufp >= bufend)
break;
copylen = state = 0;
for (i=0; ( (i < seglen) && (bufp < bufend) ); i++) {
for (i = 0; ((i < seglen) && (bufp < bufend)); i++)
{
c = src[i];
gotAnyWildcards |= ( (c == '?') || (c == '*') );
switch (state) {
gotAnyWildcards |= ((c == '?') || (c == '*'));
switch (state)
{
case 0: /* Copying filename (excl. extension) */
if (c == '*') {
while (copylen < FNAME_SIZE) {
if (c == '*')
{
while (copylen < FNAME_SIZE)
{
*(bufp++) = '?';
if (bufp >= bufend) break;
if (bufp >= bufend)
break;
copylen++;
}
copylen = 0;
state = 1; /* Go wait for dot */
break;
}
if (c == '.') {
if (src[i+1] != '.' && i+1 < seglen) *(bufp++) = '.';
if (c == '.')
{
if (src[i + 1] != '.' && i + 1 < seglen)
*(bufp++) = '.';
copylen = 0;
state = 2; /* Copy extension next */
break;
}
*(bufp++) = c;
copylen++;
if (copylen >= FNAME_SIZE) {
if (copylen >= FNAME_SIZE)
{
copylen = 0;
state = 1; /* Go wait for dot */
break;
}
break;
case 1: /* Looking for dot so we can copy exten */
if (src[i] == '.' && src[i+1] != '.' && i+1 < seglen) {
if (src[i] == '.' && src[i + 1] != '.' && i + 1 < seglen)
{
*(bufp++) = '.';
state = 2;
}
break;
case 2: /* Copying extension */
if (c == '*') {
while (copylen < FEXT_SIZE) {
if (c == '*')
{
while (copylen < FEXT_SIZE)
{
*(bufp++) = '?';
if (bufp >= bufend) break;
if (bufp >= bufend)
break;
copylen++;
}
i = seglen; /* Done with segment */
break;
}
if (c == '.') {
if (c == '.')
{
i = seglen; /* Done with segment */
break;
}
*(bufp++) = c;
copylen++;
if (copylen >= FEXT_SIZE) {
if (copylen >= FEXT_SIZE)
{
i = seglen; /* Done with segment */
break;
}
@ -480,7 +517,8 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t)
}
} /* if (seglen > 0) */
src += seglen;
if (*src) src++;
if (*src)
src++;
} /* while ( (*src) && (bufp < bufend) ) */
}
/* /// End of new code. - Ron Cemer */
@ -553,4 +591,3 @@ exit_tn:
* Rev 1.1 22 Jan 1997 13:21:22 patv
* pre-0.92 Svante Frey bug fixes.
*/

View File

@ -39,7 +39,8 @@
#include <nls.h>
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
/*
@ -50,8 +51,10 @@ static BYTE *RcsId = "$Id$";
#ifdef NLS_DEBUG
#define assertDSeqSS() if(_DS != _SS) assertDSneSS();
void assertDSneSS(void)
{ panic("DS unequal to SS");
{
panic("DS unequal to SS");
}
#define log(a) printf a
#define log1(a) printf a
#else
@ -64,23 +67,21 @@ void assertDSneSS(void)
#endif
#endif
struct nlsInfoBlock nlsInfo = {
(char FAR *)0 /* filename to COUNTRY.SYS */
,437 /* system code page */
, 437 /* system code page */
/* Implementation flags */
,0
, 0
#ifdef NLS_MODIFYABLE_DATA
| NLS_CODE_MODIFYABLE_DATA
#endif
#ifdef NLS_REORDER_POINTERS
| NLS_CODE_REORDER_POINTERS
#endif
,&nlsPackageHardcoded /* hardcoded first package */
,&nlsPackageHardcoded /* first item in chain */
, &nlsPackageHardcoded /* hardcoded first package */
, &nlsPackageHardcoded /* first item in chain */
};
/* getTableX return the pointer to the X'th table; X==subfct */
/* subfct 2: normal upcase table; 4: filename upcase table */
#ifdef NLS_REORDER_POINTERS
@ -98,22 +99,21 @@ struct nlsInfoBlock nlsInfo = {
#define getCharTbl4(nls) \
(((struct nlsCharTbl FAR*)getTable4(nls))->tbl - 0x80)
/********************************************************************
***** MUX calling functions ****************************************
********************************************************************/
/*== DS:SI _always_ points to global NLS info structure <-> no
* subfct can use these registers for anything different. ==ska*/
STATIC COUNT muxGo(int subfct, iregs *rp)
STATIC COUNT muxGo(int subfct, iregs * rp)
{
log( ("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%04x:%04x\n", subfct
, rp->DX, rp->BX, rp->ES, rp->DI) );
log(("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%04x:%04x\n",
subfct, rp->DX, rp->BX, rp->ES, rp->DI));
rp->SI = FP_OFF(&nlsInfo);
rp->DS = FP_SEG(&nlsInfo);
rp->AX = 0x1400 | subfct;
intr(0x2f, rp);
log( ("NLS: muxGo(): return value = %d\n", rp->AX) );
log(("NLS: muxGo(): return value = %d\n", rp->AX));
return rp->AX;
}
@ -121,7 +121,8 @@ log( ("NLS: muxGo(): return value = %d\n", rp->AX) );
* Call NLSFUNC to load the NLS package
*/
COUNT muxLoadPkg(UWORD cp, UWORD cntry)
{ iregs r;
{
iregs r;
assertDSeqSS(); /* because "&r" */
@ -130,9 +131,9 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry)
/* 0x14FF == installed */
r.BX = 0; /* make sure the NLSFUNC ID is updated */
if(muxGo(0, &r) != 0x14ff)
if (muxGo(0, &r) != 0x14ff)
return DE_FILENOTFND; /* No NLSFUNC --> no load */
if(r.BX != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */
if (r.BX != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */
return DE_INVLDACC; /* This magic number */
/* OK, the correct NLSFUNC is available --> load pkg */
@ -143,14 +144,14 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry)
return muxGo(NLSFUNC_LOAD_PKG, &r);
}
STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize
, VOID FAR *buf)
{ iregs r;
STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry,
UWORD bufsize, VOID FAR * buf)
{
iregs r;
assertDSeqSS(); /* because "&r" */
log( ("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x\n",
subfct, bp, cp, cntry, bufsize, FP_SEG(buf), FP_OFF(buf)) );
log(("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x\n", subfct, bp, cp, cntry, bufsize, FP_SEG(buf), FP_OFF(buf)));
r.DX = cntry;
r.BX = cp;
@ -170,23 +171,23 @@ log( ("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x
***** Helper functions**********************************************
********************************************************************/
/*
* Search for the NLS package within the chain
* Also resolves the default values (-1) into the currently
* active codepage/country code.
*/
STATIC struct nlsPackage FAR *searchPackage(UWORD cp, UWORD cntry)
{ struct nlsPackage FAR *nls;
{
struct nlsPackage FAR *nls;
if(cp == NLS_DEFAULT)
if (cp == NLS_DEFAULT)
cp = nlsInfo.actPkg->cp;
if(cntry == NLS_DEFAULT)
if (cntry == NLS_DEFAULT)
cntry = nlsInfo.actPkg->cntry;
nls = nlsInfo.chain;
while((nls->cp != cp || nls->cntry != cntry)
&& (nls = nls->nxt) != NULL);
while ((nls->cp != cp || nls->cntry != cntry)
&& (nls = nls->nxt) != NULL) ;
return nls;
}
@ -194,13 +195,14 @@ STATIC struct nlsPackage FAR *searchPackage(UWORD cp, UWORD cntry)
/* For various robustnesses reasons and to simplify the implementation
at other places, locateSubfct() returns NULL (== "not found"),
if nls == NULL on entry. */
STATIC VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct)
{ int cnt;
STATIC VOID FAR *locateSubfct(struct nlsPackage FAR * nls, int subfct)
{
int cnt;
struct nlsPointer FAR *p;
if(nls) for(cnt = nls->numSubfct, p = &nls->nlsPointers[0]
; cnt--; ++p)
if(p->subfct == (UBYTE)subfct)
if (nls)
for (cnt = nls->numSubfct, p = &nls->nlsPointers[0]; cnt--; ++p)
if (p->subfct == (UBYTE) subfct)
return p;
return NULL;
@ -213,16 +215,20 @@ STATIC VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct)
function is guaranteed to return valid pointers, rather than
to let the user (some kernel function) deal with non-existing
tables -- 2000/02/26 ska*/
STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls)
{ struct nlsPointer FAR *poi;
STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR * nls)
{
struct nlsPointer FAR *poi;
if((poi = locateSubfct(nls, subfct)) != NULL)
if ((poi = locateSubfct(nls, subfct)) != NULL)
return poi;
/* Failed --> return the hardcoded table */
switch(subfct) {
case 2: return &nlsUpHardcodedTable;
case 4: return &nlsFnameUpHardcodedTable;
switch (subfct)
{
case 2:
return &nlsUpHardcodedTable;
case 4:
return &nlsFnameUpHardcodedTable;
/* case 5: return &nlsFnameTermHardcodedTable; */
/* case 6: return &nlsCollHardcodedTable; */
}
@ -239,23 +245,22 @@ STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls)
* the code to push bufsize, buf, call cpyBuf() and return its result.
* The parameter were ordered to allow this code optimization.
*/
STATIC COUNT cpyBuf(VOID FAR *dst, UWORD dstlen
, VOID FAR *src, UWORD srclen)
STATIC COUNT cpyBuf(VOID FAR * dst, UWORD dstlen, VOID FAR * src,
UWORD srclen)
{
if(srclen <= dstlen) {
if (srclen <= dstlen)
{
fmemcpy(dst, src, srclen);
return SUCCESS;
}
return DE_INVLDFUNC; /* buffer too small */
}
/*
* This function assumes that 'map' is adjusted such that
* map[0x80] is the uppercase of character 0x80.
*== 128 byte chartables, lower range conform to 7bit-US-ASCII ==ska*/
STATIC VOID upMMem(UBYTE FAR *map, UBYTE FAR * str, unsigned len)
STATIC VOID upMMem(UBYTE FAR * map, UBYTE FAR * str, unsigned len)
{
REG unsigned c;
@ -265,9 +270,10 @@ STATIC VOID upMMem(UBYTE FAR *map, UBYTE FAR * str, unsigned len)
oldStr = str;
oldLen = len;
log( ("NLS: upMMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) );
for(c = 0; c < len; ++c)
printf("%c", str[c] > 32? str[c]: '.');
log(("NLS: upMMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str),
FP_OFF(str)));
for (c = 0; c < len; ++c)
printf("%c", str[c] > 32 ? str[c] : '.');
printf("\"\n");
#endif
if (len)
@ -281,14 +287,13 @@ log( ("NLS: upMMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) );
}
while (--len);
#ifdef NLS_DEBUG
printf("NLS: upMMem(): result=\"");
for(c = 0; c < oldLen; ++c)
printf("%c", oldStr[c] > 32? oldStr[c]: '.');
printf("NLS: upMMem(): result=\"");
for (c = 0; c < oldLen; ++c)
printf("%c", oldStr[c] > 32 ? oldStr[c] : '.');
printf("\"\n");
#endif
}
/********************************************************************
***** Lowlevel interface *******************************************
********************************************************************/
@ -297,12 +302,13 @@ printf("NLS: upMMem(): result=\"");
the direct-access interface.
subfct == NLS_DOS_38 is a value > 0xff in order to not clash
with subfunctions valid to be passed as DOS-65-XX. */
STATIC int nlsGetData(struct nlsPackage FAR *nls, int subfct, UBYTE FAR *buf
, unsigned bufsize)
{ VOID FAR *poi;
STATIC int nlsGetData(struct nlsPackage FAR * nls, int subfct,
UBYTE FAR * buf, unsigned bufsize)
{
VOID FAR *poi;
log( ("NLS: nlsGetData(): subfct=%x, bufsize=%u, cp=%u, cntry=%u\n",
subfct, bufsize, nls->cp, nls->cntry) );
log(("NLS: nlsGetData(): subfct=%x, bufsize=%u, cp=%u, cntry=%u\n",
subfct, bufsize, nls->cp, nls->cntry));
/* Theoretically tables 1 and, if NLS_REORDER_POINTERS is enabled,
2 and 4 could be hard-coded, because their
@ -312,16 +318,16 @@ log( ("NLS: nlsGetData(): subfct=%x, bufsize=%u, cp=%u, cntry=%u\n",
in order to handle all subfunctions.
Also, NLS is often NOT used in any case, so this code is more
size than speed optimized. */
if((poi = locateSubfct(nls, subfct)) != NULL) {
log( ("NLS: nlsGetData(): subfunction found\n") );
switch(subfct) {
if ((poi = locateSubfct(nls, subfct)) != NULL)
{
log(("NLS: nlsGetData(): subfunction found\n"));
switch (subfct)
{
case 1: /* Extended Country Information */
return cpyBuf(buf, bufsize, poi
, ((struct nlsExtCntryInfo FAR*)poi)->size + 3);
return cpyBuf(buf, bufsize, poi,
((struct nlsExtCntryInfo FAR *)poi)->size + 3);
case NLS_DOS_38: /* Normal Country Information */
return cpyBuf(buf, bufsize
, &(((struct nlsExtCntryInfo FAR*)poi)->dateFmt)
, 24); /* standard cinfo has no more 34 _used_ bytes */
return cpyBuf(buf, bufsize, &(((struct nlsExtCntryInfo FAR *)poi)->dateFmt), 24); /* standard cinfo has no more 34 _used_ bytes */
/* don't copy 34, copy only 0x18 instead,
see comment at DosGetCountryInformation TE */
default:
@ -335,7 +341,7 @@ log( ("NLS: nlsGetData(): subfunction found\n") );
NLS pkg --> error. Because the data corresponds to the subfunction
number passed to the API, the failure is the same as that a wrong
API function has been called. */
log( ("NLS: nlsGetData(): Subfunction not found\n") );
log(("NLS: nlsGetData(): Subfunction not found\n"));
return DE_INVLDFUNC;
}
@ -366,9 +372,9 @@ VOID nlsCPchange(UWORD cp)
* appropriate codepage on its own.
*/
STATIC COUNT nlsSetPackage(struct nlsPackage FAR *nls)
STATIC COUNT nlsSetPackage(struct nlsPackage FAR * nls)
{
if(nls->cp != nlsInfo.actPkg->cp) /* Codepage gets changed -->
if (nls->cp != nlsInfo.actPkg->cp) /* Codepage gets changed -->
inform all character drivers thereabout.
If this fails, it would be possible that the old
NLS pkg had been removed from memory by NLSFUNC. */
@ -379,10 +385,11 @@ STATIC COUNT nlsSetPackage(struct nlsPackage FAR *nls)
return SUCCESS;
}
STATIC COUNT DosSetPackage(UWORD cp, UWORD cntry)
{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */
{
struct nlsPackage FAR *nls; /* NLS package to use to return the info from */
/* nls := NLS package of cntry/codepage */
if((nls = searchPackage(cp, cntry)) != NULL)
if ((nls = searchPackage(cp, cntry)) != NULL)
/* OK the NLS pkg is loaded --> activate it */
return nlsSetPackage(nls);
@ -390,33 +397,34 @@ STATIC COUNT DosSetPackage(UWORD cp, UWORD cntry)
return muxLoadPkg(cp, cntry);
}
STATIC void nlsUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len)
STATIC void nlsUpMem(struct nlsPackage FAR * nls, VOID FAR * str, int len)
{
log( ("NLS: nlsUpMem()\n") );
upMMem(getCharTbl2(nls), (UBYTE FAR*)str, len);
log(("NLS: nlsUpMem()\n"));
upMMem(getCharTbl2(nls), (UBYTE FAR *) str, len);
}
STATIC void nlsFUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len)
STATIC void nlsFUpMem(struct nlsPackage FAR * nls, VOID FAR * str, int len)
{
log( ("NLS: nlsFUpMem()\n") );
upMMem(getCharTbl4(nls), (UBYTE FAR*)str, len);
log(("NLS: nlsFUpMem()\n"));
upMMem(getCharTbl4(nls), (UBYTE FAR *) str, len);
}
STATIC VOID xUpMem(struct nlsPackage FAR *nls, VOID FAR * str, unsigned len)
STATIC VOID xUpMem(struct nlsPackage FAR * nls, VOID FAR * str,
unsigned len)
/* upcase a memory area */
{
log( ("NLS: xUpMem(): cp=%u, cntry=%u\n", nls->cp, nls->cntry) );
log(("NLS: xUpMem(): cp=%u, cntry=%u\n", nls->cp, nls->cntry));
if(nls->flags & NLS_FLAG_DIRECT_UPCASE)
if (nls->flags & NLS_FLAG_DIRECT_UPCASE)
nlsUpMem(nls, str, len);
else
muxBufGo(NLSFUNC_UPMEM, 0, nls->cp, nls->cntry, len, str);
}
STATIC int nlsYesNo(struct nlsPackage FAR *nls, unsigned char ch)
STATIC int nlsYesNo(struct nlsPackage FAR * nls, unsigned char ch)
{
assertDSeqSS(); /* because "&ch" */
log( ("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch>32? ch: ' ') );
log(("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch > 32 ? ch : ' '));
xUpMem(nls, &ch, 1); /* Upcase character */
/* Cannot use DosUpChar(), because
@ -425,15 +433,14 @@ log( ("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch>32? ch: ' ') );
function to allow a yesNo() function
catched by external MUX-14 handler, which
does NOT upcase character. */
log( ("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') );
if(ch == nls->yeschar)
log(("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch > 32 ? ch : ' '));
if (ch == nls->yeschar)
return 1;
if(ch == nls->nochar)
if (ch == nls->nochar)
return 0;
return 2;
}
/********************************************************************
***** DOS API ******************************************************
********************************************************************/
@ -441,16 +448,16 @@ log( ("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') );
BYTE DosYesNo(unsigned char ch)
/* returns: 0: ch == "No", 1: ch == "Yes", 2: ch crap */
{
if(nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_YESNO)
if (nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_YESNO)
return nlsYesNo(nlsInfo.actPkg, ch);
else
return muxYesNo(ch);
}
#ifndef DosUpMem
VOID DosUpMem(VOID FAR * str, unsigned len)
{ xUpMem(nlsInfo.actPkg, str, len);
{
xUpMem(nlsInfo.actPkg, str, len);
}
#endif
@ -464,29 +471,30 @@ unsigned char ASMCFUNC DosUpChar(unsigned char ch)
/* upcase a single character */
{
assertDSeqSS(); /* because "&ch" */
log( ("NLS: DosUpChar(): in ch=%u (%c)\n", ch, ch>32? ch: ' ') );
DosUpMem((UBYTE FAR*)&ch, 1);
log( ("NLS: DosUpChar(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') );
log(("NLS: DosUpChar(): in ch=%u (%c)\n", ch, ch > 32 ? ch : ' '));
DosUpMem((UBYTE FAR *) & ch, 1);
log(("NLS: DosUpChar(): upcased ch=%u (%c)\n", ch, ch > 32 ? ch : ' '));
return ch;
}
VOID DosUpString(char FAR *str)
VOID DosUpString(char FAR * str)
/* upcase a string */
{
DosUpMem(str, fstrlen(str));
}
VOID DosUpFMem(VOID FAR *str, unsigned len)
VOID DosUpFMem(VOID FAR * str, unsigned len)
/* upcase a memory area for file names */
{
#ifdef NLS_DEBUG
unsigned c;
log( ("NLS: DosUpFMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) );
for(c = 0; c < len; ++c)
printf("%c", str[c] > 32? str[c]: '.');
log(("NLS: DosUpFMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str),
FP_OFF(str)));
for (c = 0; c < len; ++c)
printf("%c", str[c] > 32 ? str[c] : '.');
printf("\"\n");
#endif
if(nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_FUPCASE)
if (nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_FUPCASE)
nlsFUpMem(nlsInfo.actPkg, str, len);
else
muxUpMem(NLSFUNC_FILE_UPMEM, str, len);
@ -496,11 +504,11 @@ unsigned char DosUpFChar(unsigned char ch)
/* upcase a single character for file names */
{
assertDSeqSS(); /* because "&ch" */
DosUpFMem((UBYTE FAR*)&ch, 1);
DosUpFMem((UBYTE FAR *) & ch, 1);
return ch;
}
VOID DosUpFString(char FAR *str)
VOID DosUpFString(char FAR * str)
/* upcase a string for file names */
{
DosUpFMem(str, fstrlen(str));
@ -514,21 +522,23 @@ VOID DosUpFString(char FAR *str)
* loaded, MUX-14 is invoked; otherwise the pkg's NLS_Fct_buf
* function is invoked.
*/
COUNT DosGetData(int subfct, UWORD cp, UWORD cntry
, UWORD bufsize, VOID FAR * buf)
{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */
COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize,
VOID FAR * buf)
{
struct nlsPackage FAR *nls; /* NLS package to use to return the info from */
log( ("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n",
subfct, cp, cntry, bufsize) );
log(("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n",
subfct, cp, cntry, bufsize));
if(!buf || !bufsize)
if (!buf || !bufsize)
return DE_INVLDDATA;
if(subfct == 0) /* Currently not supported */
if (subfct == 0) /* Currently not supported */
return DE_INVLDFUNC;
/* nls := NLS package of cntry/codepage */
if((nls = searchPackage(cp, cntry)) == NULL
|| (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0) {
if ((nls = searchPackage(cp, cntry)) == NULL
|| (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0)
{
/* If the NLS pkg is not loaded into memory or the
direct-access flag is disabled, the request must
be passed through MUX */
@ -541,7 +551,6 @@ log( ("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n",
return nlsGetData(nls, subfct, buf, bufsize);
}
/*
* Called for DOS-38 get info
*
@ -558,8 +567,9 @@ log( ("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n",
*/
#ifndef DosGetCountryInformation
COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf)
{ return DosGetData(NLS_DOS_38, NLS_DEFAULT, cntry, 0x18, buf);
COUNT DosGetCountryInformation(UWORD cntry, VOID FAR * buf)
{
return DosGetData(NLS_DOS_38, NLS_DEFAULT, cntry, 0x18, buf);
}
#endif
@ -568,15 +578,17 @@ COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf)
*/
#ifndef DosSetCountry
COUNT DosSetCountry(UWORD cntry)
{ return DosSetPackage(NLS_DEFAULT, cntry);
{
return DosSetPackage(NLS_DEFAULT, cntry);
}
#endif
/*
* Called for DOS-66-01 get CP
*/
COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP)
{ *sysCP = nlsInfo.sysCodePage;
COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP)
{
*sysCP = nlsInfo.sysCodePage;
*actCP = nlsInfo.actPkg->cp;
return SUCCESS;
}
@ -587,7 +599,8 @@ COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP)
* to specify it, is lost to me. (2000/02/13 ska)
*/
COUNT DosSetCodepage(UWORD actCP, UWORD sysCP)
{ if(sysCP == NLS_DEFAULT || sysCP == nlsInfo.sysCodePage)
{
if (sysCP == NLS_DEFAULT || sysCP == nlsInfo.sysCodePage)
return DosSetPackage(actCP, NLS_DEFAULT);
return DE_INVLDDATA;
}
@ -608,24 +621,25 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP)
if AL == 0, Carry must be cleared, otherwise set
*/
UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS)
{ struct nlsPackage FAR*nls; /* addressed NLS package */
{
struct nlsPackage FAR *nls; /* addressed NLS package */
UNREFERENCED_PARAMETER (flags);
UNREFERENCED_PARAMETER (cs);
UNREFERENCED_PARAMETER (ip);
UNREFERENCED_PARAMETER (ds);
UNREFERENCED_PARAMETER (es);
UNREFERENCED_PARAMETER (si);
UNREFERENCED_PARAMETER(flags);
UNREFERENCED_PARAMETER(cs);
UNREFERENCED_PARAMETER(ip);
UNREFERENCED_PARAMETER(ds);
UNREFERENCED_PARAMETER(es);
UNREFERENCED_PARAMETER(si);
log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n",
AL, BX, DX) );
log(("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", AL, BX, DX));
if((nls = searchPackage(BX, DX)) == NULL)
if ((nls = searchPackage(BX, DX)) == NULL)
return DE_INVLDFUNC; /* no such package */
log( ("NLS: MUX14(): NLS pkg found\n") );
log(("NLS: MUX14(): NLS pkg found\n"));
switch(AL) {
switch (AL)
{
case NLSFUNC_INSTALL_CHECK:
BX = NLS_FREEDOS_NLSFUNC_ID;
return SUCCESS; /* kernel just simulates default functions */
@ -646,18 +660,19 @@ log( ("NLS: MUX14(): NLS pkg found\n") );
return SUCCESS;
case NLSFUNC_FILE_UPMEM:
#ifdef NLS_DEBUG
{ unsigned j;
{
unsigned j;
BYTE FAR *p;
log( ("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", CX, ES, DI) );
for(j = 0, p = MK_FP(ES, DI); j < CX; ++j)
printf("%c", p[j] > 32? p[j]: '.');
log(("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", CX, ES, DI));
for (j = 0, p = MK_FP(ES, DI); j < CX; ++j)
printf("%c", p[j] > 32 ? p[j] : '.');
printf("\"\n");
}
}
#endif
nlsFUpMem(nls, MK_FP(ES, DI), CX);
return SUCCESS;
}
log( ("NLS: MUX14(): Invalid function %x\n", AL) );
log(("NLS: MUX14(): Invalid function %x\n", AL));
return DE_INVLDFUNC; /* no such function */
}
@ -668,4 +683,3 @@ log( ("NLS: MUX14(): Invalid function %x\n", AL) );
* Initial revision
*
*/

View File

@ -28,14 +28,14 @@
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#include "portab.h"
#include "globals.h"
//#include "pcb.h"
#include <nls.h>
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
#define filename Config.cfgCSYS_fnam
@ -44,50 +44,55 @@ static BYTE *RcsId = "$Id$";
static int err(void)
{
printf("Syntax error in or invalid COUNTRY.SYS: \"%s\"\n"
, filename);
printf("Syntax error in or invalid COUNTRY.SYS: \"%s\"\n", filename);
return 0;
}
#define readStruct(s) readStructure(&(s), sizeof(s), fd)
static int readStructure(void *buf, int size, COUNT fd)
{ if(DosRead(fd, buf, size) == size)
{
if (DosRead(fd, buf, size) == size)
return 1;
return err();
}
/* Evaluate each argument only once */
#define readFct(p,f) readFct_((p), (f), fd)
int readFct_(void *buf, struct csys_function *fct, COUNT fd)
{ if(DosLseek(fd, fct->csys_rpos, 0) >= 0)
{
if (DosLseek(fd, fct->csys_rpos, 0) >= 0)
return readStructure(buf, fct->csys_length, fd);
return err();
}
#define seek(n) rseek((LONG)(n), fd)
static rseek(LONG rpos, COUNT fd)
{ if(DosLseek(fd, rpos, 1) >= 0)
{
if (DosLseek(fd, rpos, 1) >= 0)
return 1;
return err();
}
COUNT csysOpen(void)
{ COUNT fd;
{
COUNT fd;
struct nlsCSys_fileHeader header;
if((fd = DosOpen((BYTE FAR*)filename, 0)) < 0) {
if ((fd = DosOpen((BYTE FAR *) filename, 0)) < 0)
{
printf("Cannot open: \"%s\"\n", filename);
return 1;
}
if(DosRead(fd, &header, sizeof(header)) != sizeof(header);
|| strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0
|| DosLseek(fd, (LONG)sizeof(csys_completeFileHeader), 0)
!= (LONG)sizeof(csys_completeFileHeader)) {
printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n"
, filename, filename);
if (DosRead(fd, &header, sizeof(header)) != sizeof(header);
||strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0
|| DosLseek(fd, (LONG) sizeof(csys_completeFileHeader), 0)
!= (LONG) sizeof(csys_completeFileHeader))
{
printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n", filename,
filename);
DosClose(fd);
return -1;
}
@ -97,15 +102,17 @@ COUNT csysOpen(void)
/* Searches for function definition of table #fctID and
moves it at index idx */
static int chkTable(int idx, int fctID, struct csys_function *fcts
, int numFct)
{ struct csys_function *fct, hfct;
static int chkTable(int idx, int fctID, struct csys_function *fcts,
int numFct)
{
struct csys_function *fct, hfct;
int i;
for(i = 0, fct = fcts; i < numFct; ++i, ++fct)
if(fct->csys_fctID == fctID) {
for (i = 0, fct = fcts; i < numFct; ++i, ++fct)
if (fct->csys_fctID == fctID)
{
/* function found */
if(i == idx) /* already best place */
if (i == idx) /* already best place */
return 1;
/* Swap both places */
memcpy(&hfct, fct, sizeof(hfct));
@ -117,6 +124,7 @@ static int chkTable(int idx, int fctID, struct csys_function *fcts
printf("Mandatory table %u not found.\n", fctID);
return 0;
}
/*
* Description of the algorithm the COUNTRY= information is loaded.
@ -172,7 +180,6 @@ a) The area containing the S3 structures, and
b) probably the last loaded data could be found within the memory already,
so the nlsPackage structure is larger than necessary.
8) But the memory allocation in pass 1 is temporary anyway, because in
the PostConfig() phase, all memory allocations are revoked and created
anew. At this point -- immediately after revoking all memory and
@ -197,7 +204,8 @@ indicates that the FP_OFF(...) is the offset base-relative to the data
offset; which is base-relative to the "nls" pointer.
*/
int csysLoadPackage(COUNT fd)
{ struct csys_numEntries entries;
{
struct csys_numEntries entries;
struct csys_ccDefinition entry;
struct csys_function *fcts;
struct nlsPackage *nls;
@ -205,7 +213,7 @@ int csysLoadPackage(COUNT fd)
int highmark, numFct, i, j;
int totalSize;
#ifndef NLS_MODIFYABLE_DATA
BYTE FAR * p;
BYTE FAR *p;
#endif
#define numE entries.csys_entries
#define bufp(offset) (((BYTE*)nls) + (offset))
@ -213,19 +221,21 @@ int csysLoadPackage(COUNT fd)
/* When this function is called, the position of the file is
at offset 128 (number of country/codepage pairs) */
if(!readStruct(entries))
if (!readStruct(entries))
return 0;
while(numE--) {
if(!readStruct(entry))
while (numE--)
{
if (!readStruct(entry))
return 0;
if(entry.csys_cntry == cntry
&& (cp == NLS_DEFAULT || entry.csys_cp == cp)) {
if (entry.csys_cntry == cntry
&& (cp == NLS_DEFAULT || entry.csys_cp == cp))
{
/* Requested entry found! */
if(!seek(entry.csys_rpos)
|| !readStruct(entries))
if (!seek(entry.csys_rpos) || !readStruct(entries))
return 0;
/* Now reading the function definitions at this position */
if(numE < 5) {
if (numE < 5)
{
printf("Syntax error in COUNTRY.SYS: Too few subfunctions\n");
return 0;
}
@ -235,25 +245,33 @@ int csysLoadPackage(COUNT fd)
numFct = 0; /* number of already loaded fct definition */
totalSize = 0;
{
if(!readStruct(fct))
if (!readStruct(fct))
return 0;
switch(fct.csys_fctID) {
case 0: case 0x20: case 0x21: case 0x22:
case 0xA0: case 0xA1: case 0xA2:
switch (fct.csys_fctID)
{
case 0:
case 0x20:
case 0x21:
case 0x22:
case 0xA0:
case 0xA1:
case 0xA2:
printf("Invalid subfunction %u ignored", fct.csys_fctID);
continue;
case 0x23:
if(fct.csys_length != 2) {
if (fct.csys_length != 2)
{
printf("Pseudo-table 35 length mismatch\n");
continue;
}
}
/* Search if the subfunction is already there */
for(j = 0; j < numFcts && fcts[j].csys_fctID != fct.csys_fctID
; ++j);
if(j != numFct) {
printf("Subfunction %u defined multiple times, ignored\n"
, fct.csys_fctID);
for (j = 0; j < numFcts && fcts[j].csys_fctID != fct.csys_fctID;
++j) ;
if (j != numFct)
{
printf("Subfunction %u defined multiple times, ignored\n",
fct.csys_fctID);
continue;
}
@ -261,7 +279,8 @@ int csysLoadPackage(COUNT fd)
fct.csys_rpos += DosLtell(fd);
totalSize += fct.csys_length;
++numFct;
} while(--numE);
}
while (--numE) ;
/* i is the number of available function definition */
/* check if all mandatory tables are loaded, at the same
@ -271,7 +290,7 @@ int csysLoadPackage(COUNT fd)
/* That's automatically a check that more than 3 definitions
are available */
if(!chkTable(0, 0x23, fcts, numFct) /* pseudo-table 0x23 yes/no */
if (!chkTable(0, 0x23, fcts, numFct) /* pseudo-table 0x23 yes/no */
|| !chkTable(1, 1, fcts, numFct) /* ext cntry info */
|| !chkTable(2, 2, fcts, numFct) /* normal upcase */
|| !chkTable(3, 4, fcts, numFct) /* filename upcase */
@ -286,13 +305,14 @@ int csysLoadPackage(COUNT fd)
already within totalSize as the length of pseudo-table
0x23 has been counted. */
nls = KernelAlloc((data = sizeof(nlsPackage)
+ (numFct - 3) * sizeof(struct nlsPointer)) + totalSize);
+ (numFct - 3) * sizeof(struct nlsPointer)) +
totalSize);
/* data := first byte not used by the control area of
the nlsPackage structure; at this point it is the
offset where table #1 is to be loaded to*/
offset where table #1 is to be loaded to */
/* Install pseudo-table 0x23 */
if(!readFct((BYTE*)&nls->yeschar, fcts))
if (!readFct((BYTE *) & nls->yeschar, fcts))
return 0;
nls->numSubfct = numFct - 1; /* pseudo-table 0x23 */
@ -300,14 +320,15 @@ int csysLoadPackage(COUNT fd)
item */
*bufp(data) = 1; /* table #1 starts with the subfctID
then the data from the file follows */
if(!readFct(bufp(++data), ++fcts))
if (!readFct(bufp(++data), ++fcts))
return 0;
data += fcts->csys_length; /* first byte of local data area */
highmark = data; /* first unused byte */
for(j = 0, poi = nls->nlsPointers; j < numFct - 1; ++j, ++poi) {
for (j = 0, poi = nls->nlsPointers; j < numFct - 1; ++j, ++poi)
{
/* consecutively load all functions */
if(!readFct(bufp(data), ++fcts))
if (!readFct(bufp(data), ++fcts))
return 0;
poi->subfct = fcts->csys_fctID;
/* Now the function data is located at the current top of
@ -318,9 +339,10 @@ int csysLoadPackage(COUNT fd)
/** brute force **/
/* For the standard tables one need to match tables
2 and 4 only. */
for(i = data; i + fcts->csys_length < highmark; ++i) {
if(memcmp(bufp(i), bufp(highmark), fcts->csys_length)
== 0) {
for (i = data; i + fcts->csys_length < highmark; ++i)
{
if (memcmp(bufp(i), bufp(highmark), fcts->csys_length) == 0)
{
/* found! */
/* ==> leave highmark untouch, but modify pointer */
poi->pointer = MK_FP(0, i);
@ -330,9 +352,10 @@ int csysLoadPackage(COUNT fd)
}
}
/* Now try the hardcoded area */
for(p = hcTablesStart; p < hcTablesEnd - fcts->csys_length
; ++p) {
if(fmemcmp(p, bufp(highmark), fcts->csys_length) == 0) {
for (p = hcTablesStart; p < hcTablesEnd - fcts->csys_length; ++p)
{
if (fmemcmp(p, bufp(highmark), fcts->csys_length) == 0)
{
/* found! */
/* ==> leave highmark untouch, but modify pointer */
poi->pointer = p;
@ -354,28 +377,33 @@ int csysLoadPackage(COUNT fd)
}
}
#undef numE
if(cp == NLS_DEFAULT)
if (cp == NLS_DEFAULT)
printf("No definition of country ID %u in file \"%s\"\n",
cntry, filename);
else
printf("No definition of country ID %u for codepage %u in file \"%s\"\n",
printf
("No definition of country ID %u for codepage %u in file \"%s\"\n",
cntry, cp, filename);
return 0;
}
INIT BOOL LoadCountryInfo(char *fnam)
{ COUNT fd;
{
COUNT fd;
int rc;
if(strlen(fnam) < sizeof(filename)) {
if (strlen(fnam) < sizeof(filename))
{
strcpy(filename, fnam);
if((fd = csysOpen()) >= 0) {
if ((fd = csysOpen()) >= 0)
{
rc = csysLoadPackage(fd);
DosClose(fd);
return rc;
}
} else
}
else
printf("Filename too long\n");
return 0;
}
@ -387,4 +415,3 @@ INIT BOOL LoadCountryInfo(char *fnam)
* Add new files and update cvs with patches and changes
*
*/

View File

@ -41,11 +41,11 @@
#define hexd init_hexd
#endif
COUNT ASMCFUNC fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */
COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */
#ifdef VERSION_STRINGS
static BYTE *prfRcsId = "$Id$";
static BYTE *prfRcsId =
"$Id$";
#endif
static BYTE *charp = 0;
@ -70,7 +70,7 @@ VOID cso();
#endif
#ifdef FORSYS
COUNT fstrlen (BYTE FAR * s) /* don't want globals.h, sorry */
COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */
{
int i = 0;
@ -82,33 +82,32 @@ COUNT fstrlen (BYTE FAR * s) /* don't want globals.h, sorry */
#endif
/* special console output routine */
VOID
put_console(COUNT c)
VOID put_console(COUNT c)
{
if (c == '\n')
put_console('\r');
#ifdef FORSYS
write(1,&c,1); /* write character to stdout */
write(1, &c, 1); /* write character to stdout */
#else
#if defined(__TURBOC__)
_AX = 0x0e00 | c;
_BX = 0x0070;
__int__(0x10);
#else
__asm {
__asm
{
mov al, byte ptr c;
mov ah, 0x0e;
mov bx, 0x0070;
int 0x10;
}
#endif /* __TURBO__*/
#endif /* __TURBO__ */
#endif
}
/* special handler to switch between sprintf and printf */
static VOID
handle_char(COUNT c)
static VOID handle_char(COUNT c)
{
if (charp == 0)
put_console(c);
@ -117,8 +116,7 @@ static VOID
}
/* ltob -- convert an long integer to a string in any base (2-16) */
BYTE *
ltob(LONG n, BYTE * s, COUNT base)
BYTE *ltob(LONG n, BYTE * s, COUNT base)
{
ULONG u;
BYTE *p, *q;
@ -129,7 +127,7 @@ BYTE *
if (base == -10) /* signals signed conversion */
{
base = 10;
if (n < 0 )
if (n < 0)
{
u = -n;
*s++ = '-';
@ -141,7 +139,7 @@ BYTE *
{ /* generate digits in reverse order */
static char hexDigits[] = "0123456789abcdef";
*p++ = hexDigits[(UWORD)(u % base)];
*p++ = hexDigits[(UWORD) (u % base)];
}
while ((u /= base) > 0);
@ -155,7 +153,6 @@ BYTE *
return s;
}
#define LEFT 0
#define RIGHT 1
@ -167,7 +164,7 @@ WORD printf(CONST BYTE * fmt, ...)
static char buff[80]; /* adjust if necessary */
charp = buff;
ret = do_printf(fmt, (BYTE **)&fmt + 1);
ret = do_printf(fmt, (BYTE **) & fmt + 1);
handle_char(NULL);
_ES = FP_SEG(buff);
_DX = FP_OFF(buff);
@ -179,20 +176,20 @@ WORD printf(CONST BYTE * fmt, ...)
WORD printf(CONST BYTE * fmt, ...)
{
charp = 0;
return do_printf(fmt, (BYTE **)&fmt + 1);
return do_printf(fmt, (BYTE **) & fmt + 1);
}
#endif
WORD
sprintf(BYTE * buff, CONST BYTE * fmt, ...)
WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...)
{
WORD ret;
charp = buff;
ret = do_printf(fmt, (BYTE **)&fmt + 1);
ret = do_printf(fmt, (BYTE **) & fmt + 1);
handle_char(NULL);
return ret;
}
/*
ULONG FAR retcs(int i)
{
@ -202,16 +199,11 @@ ULONG FAR retcs(int i)
return *(ULONG *)p;
}
*/
COUNT
do_printf(CONST BYTE * fmt, BYTE ** arg)
COUNT do_printf(CONST BYTE * fmt, BYTE ** arg)
{
int base;
BYTE s[11],
FAR *p;
int c,
flag,
size,
fill;
BYTE s[11], FAR * p;
int c, flag, size, fill;
int longarg;
long currentArg;
@ -240,13 +232,13 @@ COUNT
flag = RIGHT;
fill = ' ';
if ( *fmt == '-')
if (*fmt == '-')
{
flag = LEFT;
fmt++;
}
if ( *fmt == '0')
if (*fmt == '0')
{
fill = '0';
fmt++;
@ -257,15 +249,12 @@ COUNT
size = size * 10 + (*fmt++ - '0');
}
if (*fmt == 'l')
{
longarg = TRUE;
fmt++;
}
c = *fmt++;
switch (c)
{
@ -281,10 +270,10 @@ COUNT
UWORD w[2];
static char pointerFormat[] = "%04x:%04x";
w[1] = *((UWORD *) arg);
arg += sizeof(UWORD)/sizeof(BYTE *);
arg += sizeof(UWORD) / sizeof(BYTE *);
w[0] = *((UWORD *) arg);
arg += sizeof(UWORD)/sizeof(BYTE *);
do_printf(pointerFormat,(BYTE**)&w);
arg += sizeof(UWORD) / sizeof(BYTE *);
do_printf(pointerFormat, (BYTE **) & w);
continue;
}
@ -297,7 +286,7 @@ COUNT
/* we assume %Fs here */
case 'S':
p = *((BYTE FAR **) arg);
arg += sizeof(BYTE FAR *)/sizeof(BYTE *);
arg += sizeof(BYTE FAR *) / sizeof(BYTE *);
goto do_outputstring;
case 'i':
@ -321,38 +310,38 @@ COUNT
if (longarg)
{
currentArg = *((LONG *) arg);
arg += sizeof(LONG)/sizeof(BYTE *);
arg += sizeof(LONG) / sizeof(BYTE *);
}
else
{
if (base < 0)
{
currentArg = *((int*) arg);
arg += sizeof(int)/sizeof(BYTE *);
currentArg = *((int *)arg);
arg += sizeof(int) / sizeof(BYTE *);
}
else
{
currentArg = *((unsigned int*) arg);
arg += sizeof(unsigned int)/sizeof(BYTE *);
currentArg = *((unsigned int *)arg);
arg += sizeof(unsigned int) / sizeof(BYTE *);
}
}
ltob(currentArg, s, base);
p = s;
do_outputstring:
do_outputstring:
size -= fstrlen(p);
if (flag == RIGHT )
if (flag == RIGHT)
{
for ( ; size > 0; size--)
for (; size > 0; size--)
handle_char(fill);
}
for (; *p != '\0'; p++)
handle_char(*p);
for ( ; size > 0; size--)
for (; size > 0; size--)
handle_char(fill);
continue;
@ -363,13 +352,12 @@ do_outputstring:
handle_char(c);
break;
}
}
return 0;
}
void hexd(char *title,UBYTE FAR *p,COUNT numBytes)
void hexd(char *title, UBYTE FAR * p, COUNT numBytes)
{
int loop;
printf("%s%04x|", title, FP_SEG(p));
@ -382,8 +370,6 @@ void hexd(char *title,UBYTE FAR *p,COUNT numBytes)
printf("\n");
}
#ifdef TEST
/*
this testprogram verifies that the strings are printed correctly
@ -397,8 +383,10 @@ void hexd(char *title,UBYTE FAR *p,COUNT numBytes)
*/
#include <c:\tc\include\conio.h>
void cso(char c) { putch(c); }
void cso(char c)
{
putch(c);
}
struct {
char *should;
@ -406,65 +394,87 @@ struct {
unsigned lowint;
unsigned highint;
} testarray[] =
} testarray[] = {
{
{ "hello world", "%s %s", (unsigned)"hello",(unsigned)"world"},
{ "hello", "%3s", (unsigned)"hello",0},
{ " hello", "%7s", (unsigned)"hello",0},
{ "hello ", "%-7s", (unsigned)"hello",0},
{ "hello", "%s", (unsigned)"hello",0},
{ "1", "%d", 1, 0},
{ "-1", "%d", -1,0},
{ "65535", "%u", -1,0},
{ "-32768", "%d", 0x8000,0},
{ "32767", "%d", 0x7fff,0},
{ "-32767", "%d", 0x8001,0},
{"8000", "%x", 0x8000, 0},
{" 1", "%4x", 1, 0},
{"0001", "%04x", 1, 0},
{"1 ", "%-4x", 1, 0},
{"1000", "%-04x", 1, 0},
{ "1", "%ld", 1, 0},
{ "-1", "%ld", -1,-1},
{ "65535", "%ld", -1,0},
{ "65535", "%u", -1,0},
{"8000", "%lx", 0x8000, 0},
{"80000000", "%lx", 0,0x8000},
{" 1", "%4lx", 1, 0},
{"0001", "%04lx", 1, 0},
{"1 ", "%-4lx", 1, 0},
{"1000", "%-04lx", 1, 0},
{ "-2147483648", "%ld", 0,0x8000},
{ "2147483648", "%lu", 0,0x8000},
{ "2147483649", "%lu", 1,0x8000},
{ "-2147483647", "%ld", 1,0x8000},
{ "32767", "%ld", 0x7fff,0},
{ "ptr 1234:5678", "ptr %p", 0x5678,0x1234},
0
};
"hello world", "%s %s", (unsigned)"hello", (unsigned)"world"},
{
"hello", "%3s", (unsigned)"hello", 0},
{
" hello", "%7s", (unsigned)"hello", 0},
{
"hello ", "%-7s", (unsigned)"hello", 0},
{
"hello", "%s", (unsigned)"hello", 0},
{
"1", "%d", 1, 0},
{
"-1", "%d", -1, 0},
{
"65535", "%u", -1, 0},
{
"-32768", "%d", 0x8000, 0},
{
"32767", "%d", 0x7fff, 0},
{
"-32767", "%d", 0x8001, 0},
{
"8000", "%x", 0x8000, 0},
{
" 1", "%4x", 1, 0},
{
"0001", "%04x", 1, 0},
{
"1 ", "%-4x", 1, 0},
{
"1000", "%-04x", 1, 0},
{
"1", "%ld", 1, 0},
{
"-1", "%ld", -1, -1},
{
"65535", "%ld", -1, 0},
{
"65535", "%u", -1, 0},
{
"8000", "%lx", 0x8000, 0},
{
"80000000", "%lx", 0, 0x8000},
{
" 1", "%4lx", 1, 0},
{
"0001", "%04lx", 1, 0},
{
"1 ", "%-4lx", 1, 0},
{
"1000", "%-04lx", 1, 0},
{
"-2147483648", "%ld", 0, 0x8000},
{
"2147483648", "%lu", 0, 0x8000},
{
"2147483649", "%lu", 1, 0x8000},
{
"-2147483647", "%ld", 1, 0x8000},
{
"32767", "%ld", 0x7fff, 0},
{
"ptr 1234:5678", "ptr %p", 0x5678, 0x1234}, 0};
test(char *should, char *format, unsigned lowint, unsigned highint)
{
char b[100];
sprintf(b, format, lowint,highint);
sprintf(b, format, lowint, highint);
printf("'%s' = '%s'\n", should, b);
if (strcmp(b,should)) { printf("\nhit the ANYKEY\n"); getch(); }
if (strcmp(b, should))
{
printf("\nhit the ANYKEY\n");
getch();
}
}
main()
{
int i;
@ -472,7 +482,8 @@ main()
for (i = 0; testarray[i].should; i++)
{
test(testarray[i].should,testarray[i].format, testarray[i].lowint, testarray[i].highint);
test(testarray[i].should, testarray[i].format, testarray[i].lowint,
testarray[i].highint);
}
}
#endif
@ -517,4 +528,3 @@ main()
* Rev 1.0 02 Jul 1995 8:05:10 patv
* Initial revision.
*/

View File

@ -28,15 +28,15 @@
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *Proto_hRcsId = "$Id$";
static BYTE *Proto_hRcsId =
"$Id$";
#endif
#endif
/* blockio.c */
ULONG getblkno(struct buffer FAR *);
VOID setblkno(struct buffer FAR *, ULONG);
struct buffer FAR *getblock (ULONG blkno, COUNT dsk);
struct buffer FAR *getblock(ULONG blkno, COUNT dsk);
struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk);
VOID setinvld(REG COUNT dsk);
BOOL flush_buffers(REG COUNT dsk);
@ -45,7 +45,8 @@ BOOL flush(void);
BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk);
BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk);
/* *** Changed on 9/4/00 BER */
UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode);
UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks,
COUNT mode);
/* *** End of change */
/* chario.c */
@ -66,19 +67,20 @@ sft FAR *get_sft(UCOUNT);
/* dosfns.c */
#ifdef WITHFAT32
struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT *rc);
struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT * rc);
#endif
BYTE FAR *get_root(BYTE FAR *);
BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT);
BOOL check_break(void);
UCOUNT GenericReadSft(sft far *sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err,
BOOL force_binary);
COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode);
UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, BYTE FAR * bp,
COUNT FAR * err, BOOL force_binary);
COUNT SftSeek(sft FAR * sftp, LONG new_pos, COUNT mode);
/* COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */
#define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t)
#define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE)
#define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE)
UCOUNT DosWriteSft(sft FAR *sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err);
UCOUNT DosWriteSft(sft FAR * sftp, UCOUNT n, BYTE FAR * bp,
COUNT FAR * err);
#define DosWrite(hndl, n, bp, err) DosWriteSft(get_sft(hndl), n, bp, err)
COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos);
COUNT DosCreat(BYTE FAR * fname, COUNT attrib);
@ -90,8 +92,9 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode);
COUNT DosOpenSft(BYTE * fname, COUNT mode);
COUNT DosClose(COUNT hndl);
COUNT DosCloseSft(WORD sft_idx);
BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * bps, UCOUNT FAR * nc);
COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp);
BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc,
UCOUNT FAR * bps, UCOUNT FAR * nc);
COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp);
COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s);
COUNT DosChangeDir(BYTE FAR * s);
COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name);
@ -102,12 +105,12 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp);
COUNT DosGetFattr(BYTE FAR * name);
COUNT DosSetFattr(BYTE FAR * name, UWORD attrp);
UBYTE DosSelectDrv(UBYTE drv);
COUNT DosDelete(BYTE FAR *path);
COUNT DosDelete(BYTE FAR * path);
COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2);
COUNT DosRenameTrue(BYTE * path1, BYTE * path2);
COUNT DosMkdir(BYTE FAR * dir);
COUNT DosRmdir(BYTE FAR * dir);
struct dhdr FAR * IsDevice(BYTE FAR * FileName);
struct dhdr FAR *IsDevice(BYTE FAR * FileName);
BOOL IsShareInstalled(void);
COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock);
sft FAR *idx_to_sft(COUNT SftIndex);
@ -140,11 +143,11 @@ BOOL dir_write(REG f_node_ptr fnp);
VOID dir_close(REG f_node_ptr fnp);
COUNT dos_findfirst(UCOUNT attr, BYTE * name);
COUNT dos_findnext(void);
void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName);
int FileName83Length(BYTE *filename83);
void ConvertName83ToNameSZ(BYTE FAR * destSZ, BYTE FAR * srcFCBName);
int FileName83Length(BYTE * filename83);
/* fatfs.c */
ULONG clus2phys(CLUSTER cl_no, struct dpb FAR *dpbp);
ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp);
COUNT dos_open(BYTE * path, COUNT flag);
BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n);
BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n);
@ -169,7 +172,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err);
COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count);
COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count);
LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin);
CLUSTER dos_free(struct dpb FAR *dpbp);
CLUSTER dos_free(struct dpb FAR * dpbp);
VOID trim_path(BYTE FAR * s);
@ -180,27 +183,31 @@ VOID release_f_node(f_node_ptr fnp);
VOID dos_setdta(BYTE FAR * newdta);
COUNT dos_getfattr(BYTE * name);
COUNT dos_setfattr(BYTE * name, UWORD attrp);
COUNT media_check(REG struct dpb FAR *dpbp);
COUNT media_check(REG struct dpb FAR * dpbp);
f_node_ptr xlt_fd(COUNT fd);
COUNT xlt_fnp(f_node_ptr fnp);
struct dhdr FAR *select_unit(COUNT drive);
#ifdef WITHFAT32
VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp, BOOL extended);
VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended);
#else
VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp);
VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp);
#endif
/* fattab.c */
void read_fsinfo(struct dpb FAR *dpbp);
void write_fsinfo(struct dpb FAR *dpbp);
UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2);
UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2);
UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2);
UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2);
CLUSTER next_cluster(struct dpb FAR *dpbp, REG CLUSTER ClusterNum);
CLUSTER next_cl32(struct dpb FAR *dpbp, REG CLUSTER ClusterNum);
CLUSTER next_cl16(struct dpb FAR *dpbp, REG CLUSTER ClusterNum);
CLUSTER next_cl12(struct dpb FAR *dpbp, REG CLUSTER ClusterNum);
void read_fsinfo(struct dpb FAR * dpbp);
void write_fsinfo(struct dpb FAR * dpbp);
UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1,
REG CLUSTER Cluster2);
UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1,
CLUSTER Cluster2);
UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1,
CLUSTER Cluster2);
UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1,
CLUSTER Cluster2);
CLUSTER next_cluster(struct dpb FAR * dpbp, REG CLUSTER ClusterNum);
CLUSTER next_cl32(struct dpb FAR * dpbp, REG CLUSTER ClusterNum);
CLUSTER next_cl16(struct dpb FAR * dpbp, REG CLUSTER ClusterNum);
CLUSTER next_cl12(struct dpb FAR * dpbp, REG CLUSTER ClusterNum);
/* fcbfns.c */
VOID DosOutputString(BYTE FAR * s);
@ -209,21 +216,25 @@ int DosCharInput(VOID);
VOID DosDirectConsoleIO(iregs FAR * r);
VOID DosCharOutput(COUNT c);
VOID DosDisplayOutput(COUNT c);
VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, UCOUNT FAR * nc, BYTE FAR ** mdp);
VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps,
UCOUNT FAR * nc, BYTE FAR ** mdp);
WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb);
BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName);
BOOL TestCmnSeps(BYTE FAR * lpFileName);
BOOL TestFieldSeps(BYTE FAR * lpFileName);
BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard);
BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField,
COUNT nFieldSize, BOOL * pbWildCard);
BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode);
BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode);
BOOL FcbGetFileSize(xfcb FAR * lpXfcb);
BOOL FcbSetRandom(xfcb FAR * lpXfcb);
BOOL FcbCalcRec(xfcb FAR * lpXfcb);
BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode);
BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode);
BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords,
COUNT * nErrorCode);
BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords,
COUNT * nErrorCode);
BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode,
BOOL (*FcbFunc)(xfcb FAR *, COUNT *));
BOOL(*FcbFunc) (xfcb FAR *, COUNT *));
BOOL FcbCreate(xfcb FAR * lpXfcb);
void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive);
BOOL FcbOpen(xfcb FAR * lpXfcb);
@ -242,7 +253,8 @@ seg far2para(VOID FAR * p);
seg long2para(ULONG size);
VOID FAR *add_far(VOID FAR * fp, ULONG off);
VOID FAR *adjust_far(VOID FAR * fp);
COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize);
COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para,
UWORD FAR * asize);
COUNT DosMemLargest(UWORD FAR * size);
COUNT DosMemFree(UWORD para);
COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize);
@ -258,7 +270,7 @@ VOID strcpy(REG BYTE * d, REG BYTE * s);
VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n);
VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s);
VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s);
void ASMCFUNC memcpy(REG void * d, REG VOID * s, REG COUNT n);
void ASMCFUNC memcpy(REG void *d, REG VOID * s, REG COUNT n);
void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n);
void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n);
@ -280,27 +292,27 @@ BYTE DosYesNo(unsigned char ch);
VOID DosUpMem(VOID FAR * str, unsigned len);
#endif
unsigned char ASMCFUNC DosUpChar(unsigned char ch);
VOID DosUpString(char FAR *str);
VOID DosUpFMem(VOID FAR *str, unsigned len);
VOID DosUpString(char FAR * str);
VOID DosUpFMem(VOID FAR * str, unsigned len);
unsigned char DosUpFChar(unsigned char ch);
VOID DosUpFString(char FAR *str);
COUNT DosGetData(int subfct, UWORD cp, UWORD cntry
, UWORD bufsize, VOID FAR * buf);
VOID DosUpFString(char FAR * str);
COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize,
VOID FAR * buf);
#ifndef DosGetCountryInformation
COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf);
COUNT DosGetCountryInformation(UWORD cntry, VOID FAR * buf);
#endif
#ifndef DosSetCountry
COUNT DosSetCountry(UWORD cntry);
#endif
COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP);
COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP);
COUNT DosSetCodepage(UWORD actCP, UWORD sysCP);
UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS);
/* prf.c */
VOID put_console(COUNT c);
WORD printf(CONST BYTE * fmt,...);
WORD printf(CONST BYTE * fmt, ...);
WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...);
VOID hexd(char *title,VOID FAR *p,COUNT numBytes);
VOID hexd(char *title, VOID FAR * p, COUNT numBytes);
/* strings.c */
COUNT ASMCFUNC strlen(REG BYTE * s);
@ -318,7 +330,7 @@ void fsncopy(REG BYTE FAR * s, REG BYTE FAR * d, COUNT l);
void ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l);
#define fsncopy(s,d,l) fstrncpy(d,s,l)
BYTE * ASMCFUNC strchr(BYTE * s, BYTE c);
BYTE *ASMCFUNC strchr(BYTE * s, BYTE c);
/* sysclk.c */
WORD FAR ASMCFUNC clk_driver(rqptr rp);
@ -341,18 +353,19 @@ WORD con_driver(rqptr rp);
VOID break_handler(void);
/* systime.c */
VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp);
VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp,
BYTE FAR * hdp);
COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd);
VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp);
VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp,
COUNT FAR * yp);
COUNT DosSetDate(UWORD Month, UWORD DayOfMonth, UWORD Year);
UWORD *is_leap_year_monthdays(UWORD year);
UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth);
/* task.c */
COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname);
COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg,
char far * pathname);
VOID new_psp(psp FAR * p, int psize);
VOID return_user(void);
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
@ -366,8 +379,10 @@ COUNT get_verify_drive(char FAR * src);
COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t);
/* network.c */
COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data);
COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data);
COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s,
UWORD i, VOID FAR * data);
COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s,
UWORD i, VOID FAR * data);
COUNT ASMCFUNC remote_rename(VOID);
COUNT ASMCFUNC remote_delete(VOID);
COUNT ASMCFUNC remote_chdir(VOID);
@ -376,18 +391,18 @@ COUNT ASMCFUNC remote_rmdir(VOID);
COUNT ASMCFUNC remote_close_all(VOID);
COUNT ASMCFUNC remote_process_end(VOID);
COUNT ASMCFUNC remote_flushall(VOID);
COUNT ASMCFUNC remote_findfirst(VOID FAR *s);
COUNT ASMCFUNC remote_findnext(VOID FAR *s);
COUNT ASMCFUNC remote_findfirst(VOID FAR * s);
COUNT ASMCFUNC remote_findnext(VOID FAR * s);
COUNT ASMCFUNC remote_getfattr(VOID);
COUNT ASMCFUNC remote_getfree(VOID FAR *s, VOID *d);
COUNT ASMCFUNC remote_open(sft FAR *s, COUNT mode);
LONG ASMCFUNC remote_lseek(sft FAR *s, LONG new_pos);
UCOUNT ASMCFUNC remote_read(sft FAR *s, UCOUNT n, COUNT * err);
UCOUNT ASMCFUNC remote_write(sft FAR *s, UCOUNT n, COUNT * err);
COUNT ASMCFUNC remote_creat(sft FAR *s, COUNT attr);
COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d);
COUNT ASMCFUNC remote_open(sft FAR * s, COUNT mode);
LONG ASMCFUNC remote_lseek(sft FAR * s, LONG new_pos);
UCOUNT ASMCFUNC remote_read(sft FAR * s, UCOUNT n, COUNT * err);
UCOUNT ASMCFUNC remote_write(sft FAR * s, UCOUNT n, COUNT * err);
COUNT ASMCFUNC remote_creat(sft FAR * s, COUNT attr);
COUNT ASMCFUNC remote_setfattr(COUNT attr);
COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax);
COUNT ASMCFUNC remote_close(sft FAR *s);
COUNT ASMCFUNC remote_close(sft FAR * s);
COUNT ASMCFUNC QRemote_Fn(char FAR * s, char FAR * d);
UWORD get_machine_name(BYTE FAR * netname);
@ -399,7 +414,6 @@ VOID ASMCFUNC exec_user(iregs FAR * irp);
/* detect.c */
unsigned long FAR is_dosemu(void);
/* new by TE */
/*
@ -416,7 +430,7 @@ unsigned long FAR is_dosemu(void);
ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */
ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */
ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */
ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2,UWORD *rem); /* DIVide ULong by UShort */
ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */
#endif
/*

View File

@ -29,7 +29,8 @@
#include "portab.h"
#ifdef VERSION_STRINGS
static BYTE *stringsRcsId = "$Id$";
static BYTE *stringsRcsId =
"$Id$";
#endif
#ifndef I86
@ -187,4 +188,3 @@ BYTE *strchr(BYTE * s, BYTE c)
* Rev 1.0 02 Jul 1995 8:33:46 patv
* Initial revision.
*/

View File

@ -30,7 +30,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
#ifdef PROTO
@ -56,7 +57,6 @@ VOID DayToBcd();
/* */
extern UWORD days[2][13]; /* this is defined by SYSTIME.C */
static struct ClockRecord clk;
/*
@ -82,19 +82,11 @@ static COUNT BcdToByte(COUNT x)
WORD FAR ASMCFUNC clk_driver(rqptr rp)
{
COUNT
c;
COUNT c;
UWORD *pdays;
BYTE bcd_days[4],
bcd_minutes,
bcd_hours,
bcd_seconds;
BYTE bcd_days[4], bcd_minutes, bcd_hours, bcd_seconds;
ULONG Ticks;
UWORD Month,
Day,
Year;
UWORD Month, Day, Year;
switch (rp->r_command)
{
@ -102,10 +94,11 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
/* If AT clock exists, copy AT clock time to system clock */
if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds))
{
DaysSinceEpoch = DaysFromYearMonthDay(
100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]),
DaysSinceEpoch =
DaysFromYearMonthDay(100 * BcdToByte(bcd_days[3]) +
BcdToByte(bcd_days[2]),
BcdToByte(bcd_days[1]),
BcdToByte(bcd_days[0]) );
BcdToByte(bcd_days[0]));
/*
* This is a rather tricky calculation. The number of timer ticks per
@ -126,8 +119,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
case C_INPUT:
{
ULONG remainder,
hs;
ULONG remainder, hs;
if (ReadPCClock(&Ticks))
++DaysSinceEpoch;
clk.clkDays = DaysSinceEpoch;
@ -176,10 +168,10 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
}
#else
{
UWORD q1 = Ticks/19663ul;
UWORD q1 = Ticks / 19663ul;
Ticks -= q1*19663ul;
hs = q1*108000ul;
Ticks -= q1 * 19663ul;
hs = q1 * 108000ul;
}
#endif
@ -196,11 +188,12 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
clk.clkHundredths = remainder % 100ul;
}
fmemcpy(rp->r_trans, &clk, min(sizeof(struct ClockRecord),rp->r_count ));
fmemcpy(rp->r_trans, &clk,
min(sizeof(struct ClockRecord), rp->r_count));
return S_DONE;
case C_OUTPUT:
rp->r_count = min(rp->r_count,sizeof(struct ClockRecord));
rp->r_count = min(rp->r_count, sizeof(struct ClockRecord));
fmemcpy(&clk, rp->r_trans, rp->r_count);
/* Set PC Clock first */
@ -209,8 +202,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
ULONG hs;
hs = 360000ul * clk.clkHours +
6000ul * clk.clkMinutes +
100ul * clk.clkSeconds +
clk.clkHundredths;
100ul * clk.clkSeconds + clk.clkHundredths;
Ticks = 0;
#if 0
if (hs >= 64 * 108000ul)
@ -250,10 +242,10 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
}
#else
{
UWORD q1 = hs/108000ul;
UWORD q1 = hs / 108000ul;
hs -= q1*108000ul;
Ticks = q1*19663ul;
hs -= q1 * 108000ul;
Ticks = q1 * 19663ul;
}
#endif
@ -264,7 +256,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
/* Now set AT clock */
/* Fix year by looping through each year, subtracting */
/* the appropriate number of days for that year. */
for (Year = 1980, c = clk.clkDays; ;)
for (Year = 1980, c = clk.clkDays;;)
{
pdays = is_leap_year_monthdays(Year);
if (c >= pdays[12])
@ -287,7 +279,6 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp)
}
}
DayToBcd((BYTE *) bcd_days, &Month, &Day, &Year);
bcd_minutes = ByteToBcd(clk.clkMinutes);
bcd_hours = ByteToBcd(clk.clkHours);
@ -364,4 +355,3 @@ VOID DayToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr)
* Rev 1.0 02 Jul 1995 8:32:30 patv
* Initial revision.
*/

View File

@ -31,7 +31,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *syspackRcsId = "$Id$";
static BYTE *syspackRcsId =
"$Id$";
#endif
#ifdef NONNATIVE
@ -55,7 +56,8 @@ VOID getbyte(VOID * vp, BYTE * bp)
VOID fgetword(REG VOID FAR * vp, WORD FAR * wp)
{
*wp = (((BYTE FAR *) vp)[0] & 0xff) + ((((BYTE FAR *) vp)[1] & 0xff) << 8);
*wp =
(((BYTE FAR *) vp)[0] & 0xff) + ((((BYTE FAR *) vp)[1] & 0xff) << 8);
}
VOID fgetlong(REG VOID FAR * vp, LONG FAR * lp)

View File

@ -32,17 +32,16 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
UWORD days[2][13] =
{
UWORD days[2][13] = {
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
};
extern request
ClkReqHdr;
extern request ClkReqHdr;
/*
return a pointer to an array with the days for that year
@ -55,19 +54,20 @@ UWORD *is_leap_year_monthdays(UWORD y)
/* this will work until 2200 - long enough for me - and saves 0x1f bytes */
if ((y & 3) || y == 2100) return days[0];
if ((y & 3) || y == 2100)
return days[0];
return days[1];
}
UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth)
{
if (Year < 1980) return 0;
if (Year < 1980)
return 0;
return DayOfMonth - 1
+ is_leap_year_monthdays(Year)[Month - 1]
+ ((Year - 1980) * 365)
+ ((Year - 1980 + 3) / 4);
+ ((Year - 1980) * 365) + ((Year - 1980 + 3) / 4);
}
@ -82,9 +82,8 @@ void ExecuteClockDriverRequest(BYTE command)
execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock);
}
VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp)
VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp,
BYTE FAR * hdp)
{
ExecuteClockDriverRequest(C_INPUT);
@ -99,7 +98,8 @@ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp)
COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd)
{
BYTE Month, DayOfMonth, DayOfWeek; COUNT Year;
BYTE Month, DayOfMonth, DayOfWeek;
COUNT Year;
DosGetDate((BYTE FAR *) & DayOfWeek, (BYTE FAR *) & Month,
(BYTE FAR *) & DayOfMonth, (COUNT FAR *) & Year);
@ -119,21 +119,19 @@ COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd)
}
VOID DosGetDate(wdp, mp, mdp, yp)
BYTE FAR *wdp,
FAR * mp,
FAR * mdp;
BYTE FAR *wdp, FAR * mp, FAR * mdp;
COUNT FAR *yp;
{
UWORD c;
UWORD *pdays;
UWORD Year,Month;
UWORD Year, Month;
ExecuteClockDriverRequest(C_INPUT);
if (ClkReqHdr.r_status & S_ERROR)
return;
for (Year = 1980, c = ClkRecord.clkDays; ;)
for (Year = 1980, c = ClkRecord.clkDays;;)
{
pdays = is_leap_year_monthdays(Year);
if (c >= pdays[12])
@ -154,7 +152,7 @@ COUNT FAR *yp;
}
*mp = Month;
*mdp = c - pdays[Month-1] + 1;
*mdp = c - pdays[Month - 1] + 1;
*yp = Year;
/* Day of week is simple. Take mod 7, add 2 (for Tuesday */
@ -164,20 +162,16 @@ COUNT FAR *yp;
}
COUNT DosSetDate(Month, DayOfMonth, Year)
UWORD Month,
DayOfMonth,
Year;
UWORD Month, DayOfMonth, Year;
{
UWORD *pdays;
pdays = is_leap_year_monthdays(Year);
if (Year < 1980 || Year > 2099
|| Month < 1 || Month > 12
|| DayOfMonth < 1
|| DayOfMonth > pdays[Month] - pdays[Month-1])
|| DayOfMonth < 1 || DayOfMonth > pdays[Month] - pdays[Month - 1])
return DE_INVLDDATA;
DosGetTime((BYTE FAR *) & ClkRecord.clkHours,
(BYTE FAR *) & ClkRecord.clkMinutes,
(BYTE FAR *) & ClkRecord.clkSeconds,

View File

@ -30,7 +30,8 @@
#include "globals.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
static BYTE *RcsId =
"$Id$";
#endif
#define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c))
@ -88,7 +89,8 @@ LONG DosGetFsize(COUNT hndl)
return dos_getfsize(s->sft_status);
}
COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname)
COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg,
char far * pathname)
{
BYTE FAR *pSrc;
BYTE FAR *pDest;
@ -101,14 +103,12 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname)
/* copy parent's environment if exec.env_seg == 0 */
pSrc = exp->exec.env_seg ?
MK_FP(exp->exec.env_seg, 0) :
MK_FP(ppsp->ps_environ, 0);
MK_FP(exp->exec.env_seg, 0) : MK_FP(ppsp->ps_environ, 0);
#if 0
/* Every process requires an environment because of argv[0]
-- 1999/04/21 ska */
*/
if (!pSrc) /* no environment to copy */
*/if (!pSrc) /* no environment to copy */
{
*pChildEnvSeg = 0;
return SUCCESS;
@ -121,13 +121,13 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname)
if (pSrc)
{ /* if no environment is available, one byte is required */
for (nEnvSize = 0; ; nEnvSize++)
for (nEnvSize = 0;; nEnvSize++)
{
/* Test env size and abort if greater than max */
if (nEnvSize >= MAXENV - ENV_KEEPFREE)
return DE_INVLDENV;
if (*(UWORD FAR *)(pSrc+nEnvSize) == 0)
if (*(UWORD FAR *) (pSrc + nEnvSize) == 0)
break;
}
nEnvSize += 2; /* account for trailing \0\0 */
@ -154,10 +154,11 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname)
/* initialize 'extra strings' count */
*((UWORD FAR *) pDest) = 1;
pDest += sizeof(UWORD)/sizeof(BYTE);
pDest += sizeof(UWORD) / sizeof(BYTE);
/* copy complete pathname */
if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS) {
if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS)
{
return RetCode;
}
@ -225,7 +226,7 @@ VOID new_psp(psp FAR * p, int psize)
p->ps_filetab = p->ps_files;
/* clone the file table */
if (p!=q)
if (p != q)
{
REG COUNT i;
@ -250,7 +251,7 @@ VOID new_psp(psp FAR * p, int psize)
RootPsp = FP_SEG(p);
}
STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb,
STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb,
BYTE FAR * fnam)
{
psp FAR *psp;
@ -302,21 +303,25 @@ set_name:
pspmcb->m_name[i] = '\0';
/* return value: AX value to be passed based on FCB values */
return ((psp->ps_fcb1.fcb_drive<lastdrive &&
CDSp->cds_table[psp->ps_fcb1.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) +
((psp->ps_fcb2.fcb_drive<lastdrive &&
CDSp->cds_table[psp->ps_fcb2.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) * 0x100;
return ((psp->ps_fcb1.fcb_drive < lastdrive &&
CDSp->cds_table[psp->ps_fcb1.fcb_drive].
cdsFlags & CDSVALID) ? 0 : 0xff) + ((psp->ps_fcb2.fcb_drive <
lastdrive
&& CDSp->cds_table[psp->
ps_fcb2.
fcb_drive].
cdsFlags & CDSVALID) ? 0 :
0xff) * 0x100;
}
COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
COUNT rc
/* err */
/*,env_size*/;
/*,env_size */ ;
COUNT nread;
UWORD mem;
UWORD env,
asize;
UWORD env, asize;
BYTE FAR *sp;
psp FAR *p;
psp FAR *q = MK_FP(cu_psp, 0);
@ -336,7 +341,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
return rc;
}
/* COMFILES will always be loaded in largest area. is that true TE*/
/* COMFILES will always be loaded in largest area. is that true TE */
/* Now find out how many paragraphs are available */
if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS)
@ -346,19 +351,21 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
}
com_size = asize;
if ( ModeLoadHigh )
if (ModeLoadHigh)
{
DosUmbLink(1); /* link in UMB's */
}
/* Allocate our memory and pass back any errors */
if ((rc = DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem
,(UWORD FAR *) & asize)) < 0)
if ((rc =
DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem,
(UWORD FAR *) & asize)) < 0)
{
if (rc == DE_NOMEM)
{
if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem
,(UWORD FAR *) & asize)) < 0)
if ((rc =
DosMemAlloc(0, LARGEST, (seg FAR *) & mem,
(UWORD FAR *) & asize)) < 0)
{
DosMemFree(env);
return rc;
@ -382,12 +389,11 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
else
mem = exp->load.load_seg;
if ( ModeLoadHigh )
if (ModeLoadHigh)
{
DosUmbLink(UMBstate); /* restore link state */
}
/* Now load the executable */
/* If file not found - error */
/* NOTE - this is fatal because we lost it in transit */
@ -410,11 +416,10 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
MS DOS always only loads the very first 64KB - sizeof(psp) bytes.
-- 1999/04/21 ska */
/* BUG !! in case of LH, memory may be smaller then 64K TE*/
/* BUG !! in case of LH, memory may be smaller then 64K TE */
if (com_size > ((LONG)asize << 4)) /* less memory than the .COM file has */
com_size = (LONG)asize << 4;
if (com_size > ((LONG) asize << 4)) /* less memory than the .COM file has */
com_size = (LONG) asize << 4;
}
do
{
@ -452,7 +457,6 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
in case of LH, this is not necessarily true
*/
*((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0;
/* build the user area on the stack */
@ -463,12 +467,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
irp->CS = mem;
irp->IP = 0x100;
irp->AX = asize; /* fcbcode */
irp->BX =
irp->CX =
irp->DX =
irp->SI =
irp->DI =
irp->BP = 0;
irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0;
irp->FLAGS = 0x200;
if (InDOS)
@ -481,7 +480,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
}
case LOAD:
exp->exec.stack = MK_FP(mem, 0xfffe);
*((UWORD FAR *)exp->exec.stack) = asize;
*((UWORD FAR *) exp->exec.stack) = asize;
exp->exec.start_addr = MK_FP(mem, 0x100);
return SUCCESS;
}
@ -491,8 +490,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
VOID return_user(void)
{
psp FAR *p,
FAR * q;
psp FAR *p, FAR * q;
REG COUNT i;
iregs FAR *irp;
/* long j;*/
@ -519,7 +517,6 @@ VOID return_user(void)
FreeProcessMem(cu_psp);
}
cu_psp = p->ps_parent;
q = MK_FP(cu_psp, 0);
dta = q->ps_dta;
@ -538,19 +535,15 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
COUNT rc;
/*err, */
/*env_size,*/
/*env_size, */
UWORD mem,
env,
asize,
start_seg;
UWORD mem, env, asize, start_seg;
int ModeLoadHigh = mode & 0x80;
UBYTE UMBstate = uppermem_link;
mode &= 0x7f;
/* Clone the environement and create a memory arena */
if (mode != OVERLAY)
{
@ -560,32 +553,30 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
else
mem = exp->load.load_seg;
{
ULONG image_size;
ULONG image_offset;
LONG exe_size;
mcb FAR *mp;
/* compute image offset from the header */
image_offset = (ULONG)header.exHeaderSize * 16;
image_offset = (ULONG) header.exHeaderSize * 16;
/* compute image size by removing the offset from the */
/* number pages scaled to bytes plus the remainder and */
/* the psp */
/* First scale the size */
image_size = (ULONG)header.exPages * 512;
image_size = (ULONG) header.exPages * 512;
/* remove the offset */
image_size -= image_offset;
/* and finally add in the psp size */
if (mode != OVERLAY)
image_size += sizeof(psp); /*TE 03/20/01*/
image_size += sizeof(psp); /*TE 03/20/01 */
if (mode != OVERLAY)
{
if ( ModeLoadHigh )
if (ModeLoadHigh)
{
DosUmbLink(1); /* link in UMB's */
mem_access_mode |= ModeLoadHigh;
@ -600,7 +591,6 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
exe_size = (LONG) long2para(image_size) + header.exMinAlloc;
/* + long2para((LONG) sizeof(psp)); ?? see above
image_size += sizeof(psp) -- 1999/04/21 ska */
if (exe_size > asize && (mem_access_mode & 0x80))
@ -630,10 +620,9 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
and load the image as high as possible into it.
discovered (and after that found in RBIL), when testing NET */
if ((header.exMinAlloc | header.exMaxAlloc ) == 0)
if ((header.exMinAlloc | header.exMaxAlloc) == 0)
exe_size = asize;
/* /// Removed closing curly brace. We should not attempt to allocate
memory if we are overlaying the current process, because the new
process will simply re-use the block we already have allocated.
@ -642,18 +631,19 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
Jun 11, 2000 - rbc
} */
/* Allocate our memory and pass back any errors */
/* We can still get an error on first fit if the above */
/* returned size was a bet fit case */
/* ModeLoadHigh = 80 = try high, then low */
if ((rc = DosMemAlloc((seg) exe_size, mem_access_mode | ModeLoadHigh, (seg FAR *) & mem
,(UWORD FAR *) & asize)) < 0)
if ((rc =
DosMemAlloc((seg) exe_size, mem_access_mode | ModeLoadHigh,
(seg FAR *) & mem, (UWORD FAR *) & asize)) < 0)
{
if (rc == DE_NOMEM)
{
if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem
,(UWORD FAR *) & asize)) < 0)
if ((rc =
DosMemAlloc(0, LARGEST, (seg FAR *) & mem,
(UWORD FAR *) & asize)) < 0)
{
DosMemFree(env);
return rc;
@ -691,13 +681,12 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
asize = exe_size;
/* /// End of additions. Jun 11, 2000 - rbc */
if ( ModeLoadHigh )
if (ModeLoadHigh)
{
mem_access_mode &= ~ModeLoadHigh; /* restore old situation */
DosUmbLink(UMBstate); /* restore link state */
}
if (mode != OVERLAY)
{
/* memory found large enough - continue processing */
@ -760,7 +749,10 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
do
{
nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &UnusedRetVal);
nBytesRead =
DosRead((COUNT) rc,
(COUNT) (exe_size < CHUNK ? exe_size : CHUNK),
(VOID FAR *) sp, &UnusedRetVal);
sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead);
exe_size -= nBytesRead;
}
@ -776,7 +768,9 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
doslseek(rc, (LONG) header.exRelocTable, 0);
for (i = 0; i < header.exRelocItems; i++)
{
if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &UnusedRetVal) != sizeof(reloc))
if (DosRead
(rc, sizeof(reloc), (VOID FAR *) & reloc[0],
&UnusedRetVal) != sizeof(reloc))
{
return DE_INVLDDATA;
}
@ -801,7 +795,6 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
if (mode == OVERLAY)
return SUCCESS;
{
psp FAR *p;
psp FAR *q = MK_FP(cu_psp, 0);
@ -825,7 +818,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
/* build the user area on the stack */
iregs FAR *irp = MK_FP(header.exInitSS + start_seg,
((header.exInitSP - sizeof(iregs)) & 0xffff));
((header.exInitSP -
sizeof(iregs)) & 0xffff));
/* start allocating REGs */
/* Note: must match es & ds memory segment */
@ -833,12 +827,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
irp->CS = header.exInitCS + start_seg;
irp->IP = header.exInitIP;
irp->AX = asize; /* asize = fcbcode */
irp->BX =
irp->CX =
irp->DX =
irp->SI =
irp->DI =
irp->BP = 0;
irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0;
irp->FLAGS = 0x200;
cu_psp = mem;
@ -854,9 +843,11 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
case LOAD:
cu_psp = mem;
exp->exec.stack = MK_FP(header.exInitSS + start_seg, header.exInitSP);
exp->exec.stack =
MK_FP(header.exInitSS + start_seg, header.exInitSP);
*((UWORD FAR *) exp->exec.stack) = asize; /* fcbcode */
exp->exec.start_addr = MK_FP(header.exInitCS + start_seg, header.exInitIP);
exp->exec.start_addr =
MK_FP(header.exInitCS + start_seg, header.exInitIP);
return SUCCESS;
}
}
@ -885,7 +876,6 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
return DE_FILENOTFND;
}
if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &UnusedRetVal)
!= sizeof(exe_header))
{
@ -995,4 +985,3 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
* Rev 1.0 02 Jul 1995 8:34:06 patv
* Initial revision.
*/

View File

@ -8,7 +8,8 @@ int main(int argc, char **argv)
if (argc < 4)
{
fprintf(stderr, "Usage: bin2c <output bin file> <output h file> <array name>\n");
fprintf(stderr,
"Usage: bin2c <output bin file> <output h file> <array name>\n");
return 1;
}

View File

@ -15,12 +15,10 @@
/* This source compiled & tested with Borland C/C++ 3.1 + TC 2.01*/
char VERSION[] = "v1.00";
char PROGRAM[] = "SYS CONFIG";
char KERNEL[] = "KERNEL.SYS";
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -30,8 +28,7 @@ char KERNEL[] = "KERNEL.SYS";
#define FAR far
#include "kconfig.h"
KernelConfig cfg = {0};
KernelConfig cfg = { 0 };
typedef unsigned char byte;
typedef signed char sbyte;
@ -40,14 +37,11 @@ typedef signed short sword;
typedef unsigned long dword;
typedef signed long sdword;
/* These structures need to be byte packed, if your compiler
does not do this by default, add the appropriate command,
such as #pragma pack(1) here, protected with #ifdefs of course.
*/
/* Displays command line syntax */
void showUsage(void)
{
@ -60,10 +54,10 @@ void showUsage(void)
printf(" If no options are given, the current values are shown.\n");
printf(" /help or /? displays this usage information.\n"
" [drive:][path]KERNEL.SYS specifies the kernel file to\n"
" modify, if not given defaults to %s\n",
KERNEL);
" modify, if not given defaults to %s\n", KERNEL);
printf("\n");
printf(" option=value ... specifies one or more options and the values\n"
printf
(" option=value ... specifies one or more options and the values\n"
" to set each to. If an option is given multiple times,\n"
" the value set will be the rightmost one.\n");
printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n"
@ -71,14 +65,11 @@ void showUsage(void)
" GLOBALENABLELBASUPPORT=0|1\n");
}
/* simply reads in current configuration values, exiting program
with an error message and error code unable to, otherwise
cfg & kfile are valid on return.
*/
/* Reads in the current kernel configuration settings,
return 0 on success, nonzero on error. If there was
an actual error the return value is positive, if there
@ -92,23 +83,23 @@ void showUsage(void)
not point to allocated memory on entry, as that memory
will not be used, and will likely not be freed as a result).
*/
int readConfigSettings(int kfile, char *kfilename, KernelConfig *cfg)
int readConfigSettings(int kfile, char *kfilename, KernelConfig * cfg)
{
int ch;
int configBlkFound;
word cfgSize;
/* Seek to start of kernel file */
if (lseek(kfile, 2, SEEK_SET) != 2)
printf("can't seek to offset 2\n"),exit(1);
printf("can't seek to offset 2\n"), exit(1);
if (read(kfile,cfg,sizeof(KernelConfig)) != sizeof(KernelConfig))
printf("can't read %u bytes\n",sizeof(KernelConfig)),exit(1);
if (read(kfile, cfg, sizeof(KernelConfig)) != sizeof(KernelConfig))
printf("can't read %u bytes\n", sizeof(KernelConfig)), exit(1);
if (memcmp(cfg->CONFIG, "CONFIG", 6) != 0)
{
printf("Error: no CONFIG section found in kernel file <%s>\n", kfilename);
printf("Error: no CONFIG section found in kernel file <%s>\n",
kfilename);
printf("Only FreeDOS kernels after 2025 contain a CONFIG section!\n");
exit(1);
}
@ -116,11 +107,10 @@ int readConfigSettings(int kfile, char *kfilename, KernelConfig *cfg)
return 1;
}
/* Writes config values out to file.
Returns 0 on success, nonzero on error.
*/
int writeConfigSettings(int kfile, KernelConfig *cfg)
int writeConfigSettings(int kfile, KernelConfig * cfg)
{
/* Seek to CONFIG section at start of options of kernel file */
@ -135,39 +125,43 @@ int writeConfigSettings(int kfile, KernelConfig *cfg)
return 0;
}
/* Displays kernel configuration information */
void displayConfigSettings(KernelConfig *cfg)
void displayConfigSettings(KernelConfig * cfg)
{
/* print known options and current value - only if available */
if (cfg->ConfigSize >= 1)
{
printf("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n",
printf
("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n",
cfg->DLASortByDriveNo);
}
if (cfg->ConfigSize >= 2)
{
printf("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n",
printf
("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n",
cfg->InitDiskShowDriveAssignment);
}
if (cfg->ConfigSize >= 3)
{
printf("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8 : *2 sec (skip < 0)\n",
printf
("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8 : *2 sec (skip < 0)\n",
cfg->SkipConfigSeconds);
}
if (cfg->ConfigSize >= 4)
{
printf("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n",
printf
("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n",
cfg->ForceLBA);
}
if (cfg->ConfigSize >= 5)
{
printf("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n",
printf
("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n",
cfg->GlobalEnableLBAsupport);
}
@ -178,10 +172,12 @@ void displayConfigSettings(KernelConfig *cfg)
{
printf("Additional options are available, they are not currently\n"
"supported by this tool. The current extra values are (in Hex):\n");
for (i = 0; i < (cfg->configSize-sizeof(ConfigData)); i++)
for (i = 0; i < (cfg->configSize - sizeof(ConfigData)); i++)
{
if ((i%32) == 0) printf("\n");
else if ((i%4) == 0) printf(" ");
if ((i % 32) == 0)
printf("\n");
else if ((i % 4) == 0)
printf(" ");
printf("%02X", (unsigned int)cfg->extra[i]);
}
printf("\n");
@ -190,8 +186,6 @@ void displayConfigSettings(KernelConfig *cfg)
printf("\n");
}
/* Note: The setXXXOption functions will set the config option of
type XXX to the value given. It will display a warning, but
allow probably invalid values to be used (cause I believe in
@ -205,7 +199,8 @@ void displayConfigSettings(KernelConfig *cfg)
/* Sets the given location to an unsigned byte value if different,
displays warning if values exceeds max
*/
void setByteOption(byte *option, char *value, word max, int *updated, char *name)
void setByteOption(byte * option, char *value, word max, int *updated,
char *name)
{
unsigned long optionValue;
@ -217,15 +212,15 @@ void setByteOption(byte *option, char *value, word max, int *updated, char *name
printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n",
name, optionValue);
}
if ((byte)optionValue > max)
if ((byte) optionValue > max)
{
printf("Warning: Option %s: Value <0x%02X> may be invalid!\n",
name, (unsigned int)((byte)optionValue));
name, (unsigned int)((byte) optionValue));
}
/* Don't bother updating if same value */
if ((byte)optionValue != *option)
if ((byte) optionValue != *option)
{
*option = (byte)optionValue;
*option = (byte) optionValue;
*updated = 1;
}
}
@ -233,27 +228,28 @@ void setByteOption(byte *option, char *value, word max, int *updated, char *name
/* Sets the given location to a signed byte value if different,
displays warning if values exceeds max or is less than min
*/
void setSByteOption(sbyte *option, char *value, sword min, sword max, int *updated, char *name)
void setSByteOption(sbyte * option, char *value, sword min, sword max,
int *updated, char *name)
{
signed long optionValue;
/* optionValue = atoi(value); Use strtol instead of atoi/atol as it detects base */
optionValue = strtol(value, NULL, 0);
if ( (optionValue < -128) || (optionValue > 127) )
if ((optionValue < -128) || (optionValue > 127))
{
printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n",
name, optionValue);
}
if ( ((sbyte)optionValue > max) || ((sbyte)optionValue < min) )
if (((sbyte) optionValue > max) || ((sbyte) optionValue < min))
{
printf("Warning: Option %s: Value <0x%02X> may be invalid!\n",
name, (signed int)((byte)optionValue));
name, (signed int)((byte) optionValue));
}
/* Don't bother updating if same value */
if ((sbyte)optionValue != *option)
if ((sbyte) optionValue != *option)
{
*option = (sbyte)optionValue;
*option = (sbyte) optionValue;
*updated = 1;
}
}
@ -262,7 +258,8 @@ void setSByteOption(sbyte *option, char *value, sword min, sword max, int *updat
/* Sets the given location to an unsigned word value if different,
displays warning if values exceeds max
*/
void setWordOption(word *option, char *value, dword max, int *updated, char *name)
void setWordOption(word * option, char *value, dword max, int *updated,
char *name)
{
unsigned long optionValue;
@ -274,15 +271,15 @@ void setWordOption(word *option, char *value, dword max, int *updated, char *nam
printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n",
name, optionValue);
}
if ((word)optionValue > max)
if ((word) optionValue > max)
{
printf("Warning: Option %s: Value <0x%02X> may be invalid!\n",
name, (unsigned int)optionValue);
}
/* Don't bother updating if same value */
if ((word)optionValue != *option)
if ((word) optionValue != *option)
{
*option = (word)optionValue;
*option = (word) optionValue;
*updated = 1;
}
}
@ -290,49 +287,48 @@ void setWordOption(word *option, char *value, dword max, int *updated, char *nam
/* Sets the given location to a signed byte value if different,
displays warning if values exceeds max or is less than min
*/
void setSWordOption(sword *option, char *value, sdword min, sdword max, int *updated, char *name)
void setSWordOption(sword * option, char *value, sdword min, sdword max,
int *updated, char *name)
{
signed long optionValue;
/* optionValue = atol(value); Use strtol instead of atoi/atol as it allows 0xFF and 255 */
optionValue = strtol(value, NULL, 0);
if ( (optionValue < -32768) || (optionValue > 32767) )
if ((optionValue < -32768) || (optionValue > 32767))
{
printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n",
name, optionValue);
}
if ( ((sword)optionValue > max) || ((sword)optionValue < min) )
if (((sword) optionValue > max) || ((sword) optionValue < min))
{
printf("Warning: Option %s: Value <0x%02X> may be invalid!\n",
name, (signed int)optionValue);
}
/* Don't bother updating if same value */
if ((sword)optionValue != *option)
if ((sword) optionValue != *option)
{
*option = (sword)optionValue;
*option = (sword) optionValue;
*updated = 1;
}
}
#endif
/* Main, processes command line options and calls above
functions as required.
*/
int FDKrnConfigMain(int argc,char **argv)
int FDKrnConfigMain(int argc, char **argv)
{
char *kfilename = KERNEL;
int kfile;
int updates = 0; /* flag used to indicate if we need to update kernel */
int argstart,i;
int argstart, i;
char *cptr;
char *argptr;
printf("FreeDOS Kernel Configuration %s\n", VERSION);
/* 1st go through and just process arguments (help/filename/etc) */
for (i = 2; i < argc; i++)
{
@ -341,7 +337,7 @@ int FDKrnConfigMain(int argc,char **argv)
/* is it an argument or an option specifier */
if (argptr[0] == '-' || argptr[0] == '/')
{
switch(argptr[1])
switch (argptr[1])
{
case 'H':
case 'h':
@ -370,18 +366,16 @@ int FDKrnConfigMain(int argc,char **argv)
#endif
/* the first argument may be the kernel name */
if ( (argstart < argc) && (strchr(argptr, '=') == NULL) )
if ((argstart < argc) && (strchr(argptr, '=') == NULL))
{
kfilename = argptr;
argstart++;
}
kfile = open(kfilename, O_RDWR | O_BINARY);
if (kfile < 0)
printf("Error: unable to open kernel file <%s>\n", kfilename),exit(1);
printf("Error: unable to open kernel file <%s>\n", kfilename), exit(1);
/* now that we know the filename (default or given) get config info */
readConfigSettings(kfile, kfilename, &cfg);
@ -390,7 +384,7 @@ int FDKrnConfigMain(int argc,char **argv)
{
argptr = argv[i];
if ((cptr = strchr(argptr,'=')) == NULL)
if ((cptr = strchr(argptr, '=')) == NULL)
goto illegal_arg;
/* split argptr into 2 pieces and make cptr point to 2nd one */
@ -398,34 +392,32 @@ int FDKrnConfigMain(int argc,char **argv)
cptr++;
/* allow 3 valid characters */
if (memicmp(argptr, "DLASORT",3) == 0)
if (memicmp(argptr, "DLASORT", 3) == 0)
{
setByteOption(&(cfg.DLASortByDriveNo),
cptr, 1, &updates, "DLASORT");
setByteOption(&(cfg.DLASortByDriveNo), cptr, 1, &updates, "DLASORT");
}
else if (memicmp(argptr, "SHOWDRIVEASSIGNMENT",3) == 0)
else if (memicmp(argptr, "SHOWDRIVEASSIGNMENT", 3) == 0)
{
setByteOption(&(cfg.InitDiskShowDriveAssignment),
cptr, 1, &updates, "SHOWDRIVEASSIGNMENT");
}
else if (memicmp(argptr, "SKIPCONFIGSECONDS",3) == 0)
else if (memicmp(argptr, "SKIPCONFIGSECONDS", 3) == 0)
{
setSByteOption(&(cfg.SkipConfigSeconds),
cptr, -128, 127, &updates, "SKIPCONFIGSECONDS");
}
else if (memicmp(argptr, "FORCELBA",3) == 0)
else if (memicmp(argptr, "FORCELBA", 3) == 0)
{
setByteOption(&(cfg.ForceLBA),
cptr, 1, &updates, "FORCELBA");
setByteOption(&(cfg.ForceLBA), cptr, 1, &updates, "FORCELBA");
}
else if (memicmp(argptr, "GLOBALENABLELBASUPPORT",3) == 0)
else if (memicmp(argptr, "GLOBALENABLELBASUPPORT", 3) == 0)
{
setByteOption(&(cfg.GlobalEnableLBAsupport),
cptr, 1, &updates, "GLOBALENABLELBASUPPORT");
}
else
{
illegal_arg:
illegal_arg:
printf("Unknown option found <%s>.\nUse %s /help for usage.\n",
argptr, PROGRAM);
exit(1);
@ -444,14 +436,12 @@ illegal_arg:
exit(1);
}
/* display new settings */
printf("\nUpdated Kernel settings.\n");
}
else
printf("\nCurrent Kernel settings.\n");
/* display current settings */
displayConfigSettings(&cfg);
@ -460,4 +450,3 @@ illegal_arg:
return 0;
}

167
sys/sys.c
View File

@ -46,9 +46,9 @@
#include <dos.h>
#include <ctype.h>
#ifdef __TURBOC__
#include <mem.h>
#include <mem.h>
#else
#include <memory.h>
#include <memory.h>
#endif
#include <string.h>
/*#include <dir.h> */
@ -69,16 +69,14 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file);
COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *);
COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *);
#define SEC_SIZE 512
#define COPY_SIZE 32768u
#ifdef _MSC_VER
#pragma pack(1)
#pragma pack(1)
#endif
struct bootsectortype
{
struct bootsectortype {
UBYTE bsJump[3];
char OemName[8];
UWORD bsBytesPerSec;
@ -106,8 +104,7 @@ struct bootsectortype
ULONG sysDataStart; /* first data sector */
};
struct bootsectortype32
{
struct bootsectortype32 {
UBYTE bsJump[3];
char OemName[8];
UWORD bsBytesPerSec;
@ -144,19 +141,17 @@ struct bootsectortype32
UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE];
#define SBOFFSET 11
#define SBSIZE (sizeof(struct bootsectortype) - SBOFFSET)
#define SBSIZE32 (sizeof(struct bootsectortype32) - SBOFFSET)
/* essentially - verify alignment on byte boundaries at compile time */
struct VerifyBootSectorSize
{
struct VerifyBootSectorSize {
char failure1[sizeof(struct bootsectortype) == 78 ? 1 : -1];
char failure2[sizeof(struct bootsectortype) == 78 ? 1 : 0];
};
int FDKrnConfigMain(int argc,char **argv);
int FDKrnConfigMain(int argc, char **argv);
int main(int argc, char **argv)
{
@ -170,9 +165,9 @@ int main(int argc, char **argv)
printf("FreeDOS System Installer " SYS_VERSION "\n\n");
if (argc > 1 && memicmp(argv[1],"CONFIG",6) == 0)
if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0)
{
exit(FDKrnConfigMain(argc,argv));
exit(FDKrnConfigMain(argc, argv));
}
srcPath[0] = '\0';
@ -182,13 +177,13 @@ int main(int argc, char **argv)
if (argc > 2 && argv[2][1] == ':' && argv[2][2] == '\0')
{
drivearg = 2;
strncpy(srcPath, argv[1], MAXPATH-12);
strncpy(srcPath, argv[1], MAXPATH - 12);
/* leave room for COMMAND.COM\0 */
srcPath[MAXPATH-13] = '\0';
srcPath[MAXPATH - 13] = '\0';
/* make sure srcPath + "file" is a valid path */
slen = strlen(srcPath);
if ( (srcPath[slen-1] != ':') &&
((srcPath[slen-1] != '\\') || (srcPath[slen-1] != '/')) )
if ((srcPath[slen - 1] != ':') &&
((srcPath[slen - 1] != '\\') || (srcPath[slen - 1] != '/')))
{
srcPath[slen] = '\\';
slen++;
@ -199,19 +194,23 @@ int main(int argc, char **argv)
if (drivearg == 0)
{
printf("Usage: %s [source] drive: [bootsect [BOTH]]\n", pgm);
printf(" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n");
printf
(" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n");
printf(" drive = A,B,etc.\n");
printf(" bootsect = name of 512-byte boot sector file image for drive:\n");
printf
(" bootsect = name of 512-byte boot sector file image for drive:\n");
printf(" to write to instead of real boot sector\n");
printf(" BOTH : write to both the real boot sector and the image file\n");
printf("%s CONFIG /help\n",pgm);
printf
(" BOTH : write to both the real boot sector and the image file\n");
printf("%s CONFIG /help\n", pgm);
exit(1);
}
drive = toupper(argv[drivearg][0]) - 'A';
if (drive < 0 || drive >= 26)
{
printf( "%s: drive %c must be A:..Z:\n", pgm,*argv[(argc == 3 ? 2 : 1)]);
printf("%s: drive %c must be A:..Z:\n", pgm,
*argv[(argc == 3 ? 2 : 1)]);
exit(1);
}
@ -228,19 +227,19 @@ int main(int argc, char **argv)
}
/* Don't try root if src==dst drive or source path given */
if ( (drive == srcDrive) || (*srcPath && ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2]))) )
if ((drive == srcDrive)
|| (*srcPath
&& ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2]))))
*rootPath = '\0';
else
sprintf(rootPath, "%c:\\", 'A' + srcDrive);
if (!check_space(drive, oldboot))
{
printf("%s: Not enough space to transfer system files\n", pgm);
exit(1);
}
printf("\nCopying KERNEL.SYS...\n");
if (!copy(drive, srcPath, rootPath, "kernel.sys"))
{
@ -255,12 +254,13 @@ int main(int argc, char **argv)
exit(1);
}
if (argc > drivearg+1)
bsFile = argv[drivearg+1];
if (argc > drivearg + 1)
bsFile = argv[drivearg + 1];
printf("\nWriting boot sector...\n");
put_boot(drive, bsFile,
(argc > drivearg+2) && memicmp(argv[drivearg+2], "BOTH", 4) == 0);
(argc > drivearg + 2)
&& memicmp(argv[drivearg + 2], "BOTH", 4) == 0);
printf("\nSystem transferred.\n");
return 0;
@ -283,25 +283,25 @@ VOID dump_sector(unsigned char far * sec)
{
c = oldboot[x * 16 + y];
if (isprint(c))
printf( "%c", c);
printf("%c", c);
else
printf( ".");
printf(".");
}
printf( "\n");
printf("\n");
}
printf( "\n");
printf("\n");
}
#endif
/*
TC absRead not functional on MSDOS 6.2, large disks
MSDOS requires int25, CX=ffff for drives > 32MB
*/
int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned intno)
int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer,
unsigned intno)
{
struct {
unsigned long sectorNumber;
@ -311,18 +311,18 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned
int retval;
union REGS regs;
diskReadPacket.sectorNumber = sector;
diskReadPacket.count = count;
diskReadPacket.address = buffer;
regs.h.al = (BYTE)DosDrive;
regs.h.al = (BYTE) DosDrive;
regs.x.bx = (short)&diskReadPacket;
regs.x.cx = 0xffff;
if (intno != 0x25 && intno != 0x26) return 0xff;
if (intno != 0x25 && intno != 0x26)
return 0xff;
int86(intno,&regs,&regs);
int86(intno, &regs, &regs);
#ifdef WITHFAT32
if (regs.x.cflag)
@ -339,8 +339,7 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned
return regs.x.cflag ? 0xff : 0;
}
VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both)
{
COUNT i, z;
WORD head, track, sector, ret;
@ -356,24 +355,22 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
char drivename[] = "A:\\";
unsigned char x[0x40];
#ifdef DEBUG
printf("Reading old bootsector from drive %c:\n",drive+'A');
printf("Reading old bootsector from drive %c:\n", drive + 'A');
#endif
if (MyAbsReadWrite(drive, 1, 0, oldboot,0x25) != 0)
if (MyAbsReadWrite(drive, 1, 0, oldboot, 0x25) != 0)
{
printf("can't read old boot sector for drive %c:\n", drive +'A');
printf("can't read old boot sector for drive %c:\n", drive + 'A');
exit(1);
}
#ifdef DDEBUG
printf("Old Boot Sector:\n");
dump_sector(oldboot);
#endif
bs = (struct bootsectortype *) & oldboot;
bs = (struct bootsectortype *)&oldboot;
if ((bs->bsFileSysType[4] == '6') && (bs->bsBootSignature == 0x29))
{
fs = 16;
@ -390,23 +387,26 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
*/
regs.h.ah = 0x36; /* get drive free space */
regs.h.dl = drive+1; /* 1 = 'A',... */
int86(0x21,&regs,&regs);
regs.h.dl = drive + 1; /* 1 = 'A',... */
int86(0x21, &regs, &regs);
if (regs.x.ax == 0xffff)
{
printf("can't get free disk space for %c:\n", drive+'A');
printf("can't get free disk space for %c:\n", drive + 'A');
exit(1);
}
if (regs.x.dx <= 0xff6)
{
if (fs != 12) printf("warning : new detection overrides old detection\a\n");
if (fs != 12)
printf("warning : new detection overrides old detection\a\n");
fs = 12;
}
else {
else
{
if (fs != 16) printf("warning : new detection overrides old detection\a\n");
if (fs != 16)
printf("warning : new detection overrides old detection\a\n");
fs = 16;
/* fs = 16/32.
@ -423,14 +423,15 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
regs.x.di = (unsigned)&x;
regs.x.cx = sizeof(x);
int86x(0x21,&regs,&regs,&sregs);
int86x(0x21, &regs, &regs, &sregs);
if (regs.x.cflag) /* error --> no Win98 --> no FAT32 */
{
printf("get extended drive space not supported --> no FAT32\n");
}
else {
if (*(unsigned long *)(x+0x2c) /* total number of clusters */
else
{
if (*(unsigned long *)(x + 0x2c) /* total number of clusters */
> (unsigned)65526l)
{
fs = 32;
@ -438,7 +439,6 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
}
}
if (fs == 16)
{
memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */
@ -469,14 +469,14 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
#endif
memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE);
bs = (struct bootsectortype *) & newboot;
bs = (struct bootsectortype *)&newboot;
memcpy(bs->OemName, "FreeDOS ",8);
memcpy(bs->OemName, "FreeDOS ", 8);
#ifdef WITHFAT32
if (fs == 32)
{
bs32 = (struct bootsectortype32 *) & newboot;
bs32 = (struct bootsectortype32 *)&newboot;
temp = bs32->bsHiddenSecs + bs32->bsResSectors;
bs32->sysFatStart = temp;
@ -485,12 +485,13 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
bs32->sysFatSecMask = bs32->bsBytesPerSec / 4 - 1;
temp = bs32->sysFatSecMask + 1;
for (bs32->sysFatSecShift = 0; temp != 1; bs32->sysFatSecShift++, temp >>= 1);
for (bs32->sysFatSecShift = 0; temp != 1;
bs32->sysFatSecShift++, temp >>= 1) ;
}
#ifdef DEBUG
if (fs == 32)
{
printf( "FAT starts at sector %lx = (%lx + %x)\n", bs32->sysFatStart,
printf("FAT starts at sector %lx = (%lx + %x)\n", bs32->sysFatStart,
bs32->bsHiddenSecs, bs32->bsResSectors);
printf("DATA starts at sector %lx\n", bs32->sysDataStart);
}
@ -502,7 +503,8 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
/* TE thinks : never, see above */
/* temporary HACK for the load segment (0x0060): it is in unused */
/* only needed for older kernels */
*((UWORD *)(bs->unused)) = *((UWORD *)(((struct bootsectortype *)&b_fat16)->unused));
*((UWORD *) (bs->unused)) =
*((UWORD *) (((struct bootsectortype *)&b_fat16)->unused));
/* end of HACK */
/* root directory sectors */
@ -525,7 +527,7 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
printf("Root dir entries = %u\n", bs->bsRootDirEnts);
printf("Root dir sectors = %u\n", bs->sysRootDirSecs);
printf( "FAT starts at sector %lu = (%lu + %u)\n", bs->sysFatStart,
printf("FAT starts at sector %lu = (%lu + %u)\n", bs->sysFatStart,
bs->bsHiddenSecs, bs->bsResSectors);
printf("Root directory starts at sector %lu = (PREVIOUS + %u * %u)\n",
bs->sysRootDirStart, bs->bsFATsecs, bs->bsFATs);
@ -534,7 +536,6 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
#endif
#endif
#ifdef DDEBUG
printf("\nNew Boot Sector:\n");
dump_sector(newboot);
@ -544,12 +545,12 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
{
#ifdef DEBUG
printf("writing new bootsector to drive %c:\n",drive+'A');
printf("writing new bootsector to drive %c:\n", drive + 'A');
#endif
if (MyAbsReadWrite(drive, 1, 0, newboot,0x26) != 0)
if (MyAbsReadWrite(drive, 1, 0, newboot, 0x26) != 0)
{
printf("Can't write new boot sector to drive %c:\n", drive +'A');
printf("Can't write new boot sector to drive %c:\n", drive + 'A');
exit(1);
}
}
@ -563,9 +564,11 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
#endif
/* write newboot to bsFile */
if ((fd = open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0)
if ((fd =
open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,
S_IREAD | S_IWRITE)) < 0)
{
printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno);
printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno);
exit(1);
}
if (write(fd, newboot, SEC_SIZE) != SEC_SIZE)
@ -579,7 +582,6 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both)
}
}
BOOL check_space(COUNT drive, BYTE * BlkBuffer)
{
/* this should check, if on destination is enough space
@ -588,7 +590,6 @@ BOOL check_space(COUNT drive, BYTE * BlkBuffer)
UNREFERENCED_PARAMETER(drive);
UNREFERENCED_PARAMETER(BlkBuffer);
return TRUE;
}
@ -608,7 +609,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file)
if (stat(source, &fstatbuf))
{
printf( "%s: \"%s\" not found\n", pgm, source);
printf("%s: \"%s\" not found\n", pgm, source);
if ((rootPath != NULL) && (*rootPath) /* && (errno == ENOENT) */ )
{
@ -616,7 +617,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file)
printf("%s: Trying \"%s\"\n", pgm, source);
if (stat(source, &fstatbuf))
{
printf( "%s: \"%s\" not found\n", pgm, source);
printf("%s: \"%s\" not found\n", pgm, source);
return FALSE;
}
}
@ -624,20 +625,22 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file)
return FALSE;
}
if ((fdin = open(source, O_RDONLY|O_BINARY)) < 0)
if ((fdin = open(source, O_RDONLY | O_BINARY)) < 0)
{
printf( "%s: failed to open \"%s\"\n", pgm, source);
printf("%s: failed to open \"%s\"\n", pgm, source);
return FALSE;
}
if ((fdout = open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0)
if ((fdout =
open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,
S_IREAD | S_IWRITE)) < 0)
{
printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno);
printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno);
close(fdin);
return FALSE;
}
while ((ret = read(fdin, copybuffer,COPY_SIZE)) > 0)
while ((ret = read(fdin, copybuffer, COPY_SIZE)) > 0)
{
if (write(fdout, copybuffer, ret) != ret)
{
@ -662,17 +665,16 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file)
#ifdef _MSV_VER
{
#include <utime.h>
#include <utime.h>
struct utimbuf utimb;
utimb.actime = /* access time */
utimb.modtime = fstatbuf.st_mtime; /* modification time */
utime(dest,&utimb);
utime(dest, &utimb);
};
#endif
printf("%lu Bytes transferred", copied);
return TRUE;
@ -755,4 +757,3 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file)
* it create a .COM file.
*
*/

View File

@ -17,20 +17,18 @@
#include <string.h>
#ifndef TRUE
#define TRUE (1==1)
#define FALSE (0==1)
#define TRUE (1==1)
#define FALSE (0==1)
#endif
struct {
char *sin,*sout;
} repl[100];
char *sin, *sout;
} repl[100];
int repl_count;
void quit(char *s,...)
void quit(char *s, ...)
{
vprintf(s,(void*)((char *)&s+sizeof(s)));
vprintf(s, (void *)((char *)&s + sizeof(s)));
exit(1);
}
@ -46,7 +44,7 @@ void define_replace(char *sin)
*s = 0;
repl[repl_count].sin = sin;
repl[repl_count].sout = s+1;
repl[repl_count].sout = s + 1;
repl_count++;
}
@ -57,58 +55,59 @@ int main(int argc, char *argv[])
int argloop;
int cont;
int file = 0;
FILE *fd,*fdo;
char *inname=0,*outname= "~patchob.tmp";
FILE *fd, *fdo;
char *inname = 0, *outname = "~patchob.tmp";
int use_temp_file = TRUE;
argc--,argv++;
argc--, argv++;
for (; argc != 0; argc--,argv++)
for (; argc != 0; argc--, argv++)
{
argptr = *argv;
if (*argptr != '-' && *argptr != '-')
{
if (inname == 0) { inname = argptr; continue;}
if (inname == 0)
{
inname = argptr;
continue;
}
define_replace(argptr);
continue;
}
switch (toupper(argptr[1]))
{
case 'O':
outname = argptr+2;
outname = argptr + 2;
use_temp_file = FALSE;
break;
default:
quit("illegal argument <%s>\n",argptr);
quit("illegal argument <%s>\n", argptr);
break;
}
}
if (inname == 0)
quit("Inputfile must be specified\n");
if (repl_count == 0)
quit("no replacements defined");
if ((fd = fopen(inname, "rb")) == NULL) /* open for READ/WRITE */
quit("can't read %s\n", inname);
if ((fd = fopen(inname,"rb")) == NULL) /* open for READ/WRITE */
quit("can't read %s\n",inname);
if ((fdo = fopen(outname, "wb")) == NULL) /* open for READ/WRITE */
quit("can't write %s\n", outname);
if ((fdo = fopen(outname,"wb")) == NULL) /* open for READ/WRITE */
quit("can't write %s\n",outname);
go_records(fd,fdo);
go_records(fd, fdo);
fclose(fd);
fclose(fdo);
if (use_temp_file)
{
unlink(inname);
rename(outname,inname);
rename(outname, inname);
}
return 0;
@ -117,61 +116,51 @@ int main(int argc, char *argv[])
usage()
{
fputs(
"DELSYM V1.0 5'95by tom ehlert, SIG Aachen\n"
fputs("DELSYM V1.0 5'95by tom ehlert, SIG Aachen\n"
" delete symbolic info in object files\n"
"usage:\n"
" DELSYM infile [outfile]\n"
,stderr);
"usage:\n" " DELSYM infile [outfile]\n", stderr);
exit(1);
}
struct record
{
struct record {
unsigned char rectyp;
unsigned datalen;
unsigned char buffer[0x2000];
} Record,Outrecord;
} Record, Outrecord;
go_records(FILE *fdin,FILE *fdo)
go_records(FILE * fdin, FILE * fdo)
{
unsigned char stringlen;
unsigned char *string,*s;
int i,j;
unsigned char *string, *s;
int i, j;
unsigned char chksum;
do {
if (fread(&Record,1,3,fdin) != 3) { /* read type and reclen*/
do
{
if (fread(&Record, 1, 3, fdin) != 3)
{ /* read type and reclen */
/* printf("end of fdin read\n"); */
break;
}
if (Record.datalen > sizeof(Record.buffer))
quit ("record to large : length %u Bytes \n",Record.datalen);
quit("record to large : length %u Bytes \n", Record.datalen);
if (fread(Record.buffer,1,Record.datalen,fdin) != Record.datalen)
if (fread(Record.buffer, 1, Record.datalen, fdin) != Record.datalen)
{
printf("invalid record format\n");
quit ("can't continue\n");
quit("can't continue\n");
}
if (Record.rectyp != 0x96) /* we are only interested in LNAMES */
{
fwrite(&Record,1,3+Record.datalen,fdo);
fwrite(&Record, 1, 3 + Record.datalen, fdo);
continue;
}
Outrecord.rectyp = 0x96;
Outrecord.datalen= 0;
Outrecord.datalen = 0;
for (i = 0; i < Record.datalen-1; )
for (i = 0; i < Record.datalen - 1;)
{
stringlen = Record.buffer[i];
i++;
@ -179,13 +168,11 @@ do {
string = &Record.buffer[i];
i += stringlen;
if (i > Record.datalen)
quit("invalid lnames record");
for (j = 0; j < repl_count; j++)
if (memcmp(string,repl[j].sin,stringlen) == 0
if (memcmp(string, repl[j].sin, stringlen) == 0
&& strlen(repl[j].sin) == stringlen)
{
string = repl[j].sout;
@ -193,12 +180,13 @@ do {
}
Outrecord.buffer[Outrecord.datalen] = stringlen;
Outrecord.datalen++;
memcpy(Outrecord.buffer+Outrecord.datalen,string,stringlen);
memcpy(Outrecord.buffer + Outrecord.datalen, string, stringlen);
Outrecord.datalen += stringlen;
}
chksum = 0;
for (s = (unsigned char *)&Outrecord; s < &Outrecord.buffer[Outrecord.datalen]; s++)
for (s = (unsigned char *)&Outrecord;
s < &Outrecord.buffer[Outrecord.datalen]; s++)
chksum += *s;
Outrecord.buffer[Outrecord.datalen] = ~chksum;
@ -206,10 +194,10 @@ do {
/* printf("^sum = %02x - %02x\n",chksum,~chksum); */
fwrite(&Outrecord, 1, 3 + Outrecord.datalen, fdo);
fwrite(&Outrecord,1,3+Outrecord.datalen,fdo);
}
while (Record.rectyp != 0x00 /*ENDFIL*/);
} while (Record.rectyp != 0x00 /*ENDFIL*/);
printf("\n");
printf("\n");
}

View File

@ -18,23 +18,19 @@
**
*****************************************************************************/
*/
* /
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
typedef unsigned short UWORD;
typedef unsigned long ULONG;
#ifndef _MSC_VER
#define const
#define __cdecl cdecl
#define const
#define __cdecl cdecl
#endif
/* from EXE.H */
typedef struct
{
typedef struct {
UWORD exSignature;
UWORD exExtraBytes;
UWORD exPages;
@ -49,37 +45,40 @@ typedef struct
UWORD exInitCS;
UWORD exRelocTable;
UWORD exOverlay;
}
exe_header;
} exe_header;
#define MAGIC 0x5a4d
struct relocEntry{
struct relocEntry {
UWORD off;
UWORD seg;
UWORD refseg;
};
};
int __cdecl compReloc(const void *p1, const void *p2)
{
struct relocEntry *r1 = (struct relocEntry*)p1;
struct relocEntry *r2 = (struct relocEntry*)p2;
{
struct relocEntry *r1 = (struct relocEntry *)p1;
struct relocEntry *r2 = (struct relocEntry *)p2;
if (r1->refseg > r2->refseg) return 1;
if (r1->refseg < r2->refseg) return -1;
if (r1->refseg > r2->refseg)
return 1;
if (r1->refseg < r2->refseg)
return -1;
if (r1->seg > r2->seg) return 1;
if (r1->seg < r2->seg) return -1;
if (r1->seg > r2->seg)
return 1;
if (r1->seg < r2->seg)
return -1;
if (r1->off > r2->off) return 1;
if (r1->off < r2->off) return -1;
if (r1->off > r2->off)
return 1;
if (r1->off < r2->off)
return -1;
return 0;
}
}
main(int argc,char *argv[])
main(int argc, char *argv[])
{
FILE *fdin;
exe_header header;
@ -88,14 +87,13 @@ main(int argc,char *argv[])
int i;
ULONG image_offset;
if (argc < 2 || (fdin = fopen(argv[1],"rb")) == NULL)
if (argc < 2 || (fdin = fopen(argv[1], "rb")) == NULL)
{
printf("can't open %s\n",argv[1]);
printf("can't open %s\n", argv[1]);
exit(1);
}
if (fread(&header, sizeof(header),1,fdin) != 1 ||
if (fread(&header, sizeof(header), 1, fdin) != 1 ||
header.exSignature != MAGIC)
{
printf("%s is no EXE file\n");
@ -104,13 +102,13 @@ main(int argc,char *argv[])
printf("%u relocation entries found\n", header.exRelocItems);
if (header.exRelocItems > 0x8000/sizeof(*reloc))
if (header.exRelocItems > 0x8000 / sizeof(*reloc))
{
printf("too many relocation entries \n");
exit(1);
}
if ((reloc = malloc(header.exRelocItems*sizeof(*reloc))) == NULL)
if ((reloc = malloc(header.exRelocItems * sizeof(*reloc))) == NULL)
{
printf("can't alloc memory\n");
exit(1);
@ -123,7 +121,7 @@ main(int argc,char *argv[])
}
for (i = 0; i < header.exRelocItems; i++)
if (fread(reloc+i, 4,1,fdin) != 1)
if (fread(reloc + i, 4, 1, fdin) != 1)
{
printf("can't read reloc info\n");
exit(1);
@ -131,9 +129,9 @@ main(int argc,char *argv[])
for (i = 0; i < header.exRelocItems; i++)
{
image_offset = (ULONG)header.exHeaderSize * 16;
image_offset = (ULONG) header.exHeaderSize * 16;
image_offset += ((ULONG)reloc[i].seg << 4) + reloc[i].off;
image_offset += ((ULONG) reloc[i].seg << 4) + reloc[i].off;
if (fseek(fdin, image_offset, 0))
{
@ -141,9 +139,9 @@ main(int argc,char *argv[])
exit(1);
}
if (fread(&reloc[i].refseg, 2,1,fdin) != 1)
if (fread(&reloc[i].refseg, 2, 1, fdin) != 1)
{
printf("can't read rel data for item %d\n",i);
printf("can't read rel data for item %d\n", i);
exit(1);
}
/* printf("%04x:%04x -> %04x\n", reloc[i].seg, reloc[i].off, reloc[i].refseg); */
@ -157,7 +155,8 @@ main(int argc,char *argv[])
{
if (i == 0)
printf("# seg:off references data in -->\n");
printf("%3d %04x:%04x -> %04x\n", i,reloc[i].seg, reloc[i].off, reloc[i].refseg);
printf("%3d %04x:%04x -> %04x\n", i, reloc[i].seg, reloc[i].off,
reloc[i].refseg);
}
}