From 048c87bbac02b5cb53335e1b5d88fd8d6ae3f663 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 Sep 2001 20:39:44 +0000 Subject: [PATCH] FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@305 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.mak | 10 +- config.m | 6 + docs/history.txt | 44 +++++ drivers/floppy.asm | 8 + hdr/algnbyte.h | 13 +- hdr/buffer.h | 13 +- hdr/dcb.h | 47 ++++- hdr/device.h | 63 ++++--- hdr/dirmatch.h | 12 +- hdr/error.h | 16 +- hdr/fat.h | 40 ++++- hdr/fnode.h | 24 ++- hdr/pcb.h | 5 +- hdr/portab.h | 66 +++++-- hdr/process.h | 7 +- hdr/version.h | 8 +- kernel/asmsupt.asm | 5 +- kernel/blockio.c | 12 +- kernel/break.c | 5 +- kernel/chario.c | 18 +- kernel/config.c | 180 +++++++++++-------- kernel/dosfns.c | 138 +++++++++++++-- kernel/dosidle.asm | 12 -- kernel/dsk.c | 259 +++++++++++++++++---------- kernel/dyndata.c | 2 +- kernel/dyndata.h | 2 +- kernel/dyninit.c | 15 +- kernel/entry.asm | 36 ++-- kernel/fatdir.c | 57 +++--- kernel/fatfs.c | 299 ++++++++++++++++++++++---------- kernel/fattab.c | 215 ++++++++++++++++++----- kernel/fcbfns.c | 36 ++-- kernel/globals.h | 104 +++++------ kernel/init-mod.h | 97 +++++------ kernel/initdisk.c | 117 ++++++++----- kernel/inithma.c | 105 ++++------- kernel/initoem.c | 14 +- kernel/int2f.asm | 187 +++++--------------- kernel/inthndlr.c | 413 ++++++++++++++++++++++++++++++++++++++++---- kernel/intr.h | 2 +- kernel/io.asm | 12 ++ kernel/io.inc | 22 +++ kernel/kernel.asm | 23 ++- kernel/main.c | 130 +++++++++++--- kernel/memmgr.c | 9 + kernel/newstuff.c | 7 +- kernel/nls.c | 10 +- kernel/prf.c | 32 +++- kernel/printer.asm | 111 ++++++++++-- kernel/procsupt.asm | 21 +-- kernel/proto.h | 104 +++++++---- kernel/segs.inc | 11 +- kernel/sysclk.c | 13 +- kernel/syspack.c | 5 +- kernel/task.c | 21 ++- sys/sys.mak | 12 +- 56 files changed, 2227 insertions(+), 1028 deletions(-) diff --git a/boot/boot.mak b/boot/boot.mak index 47c515c..c7dc286 100644 --- a/boot/boot.mak +++ b/boot/boot.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.4 2001/09/23 20:39:44 bartoldeman +# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +# # Revision 1.3 2000/05/25 20:56:19 jimtabor # Fixed project history # @@ -49,7 +52,7 @@ !include "..\config.mak" -production: b_fat12.bin b_fat16.bin +production: b_fat12.bin b_fat16.bin b_fat32.bin b_fat12.bin: boot.asm $(NASM) -dISFAT12 boot.asm -ob_fat12.bin @@ -57,8 +60,11 @@ b_fat12.bin: boot.asm b_fat16.bin: boot.asm $(NASM) -dISFAT16 boot.asm -ob_fat16.bin +b_fat32.bin: boot32.asm + $(NASM) boot32.asm -ob_fat32.bin + clobber: clean - $(RM) b_fat12.bin b_fat16.bin status.me + $(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me clean: $(RM) *.lst *.map *.bak *.obj diff --git a/config.m b/config.m index 13f966f..d08787b 100644 --- a/config.m +++ b/config.m @@ -13,6 +13,9 @@ RM=..\utils\rm -f #NASM=nasm # Give extra Turbo C compiler flags here +# such as -DDEBUG : extra DEBUG output +# -DDOSEMU : printf output goes to dosemu log +# -DWITHFAT32 : compile with FAT32 support #ALLCFLAGS=-DDEBUG @@ -59,6 +62,9 @@ RM=..\utils\rm -f # $Id$ # # $Log$ +# Revision 1.8 2001/09/23 20:39:43 bartoldeman +# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +# # Revision 1.7 2001/04/16 14:36:56 bartoldeman # Added ALLCFLAGS for compiler option configuration. # diff --git a/docs/history.txt b/docs/history.txt index 731cd21..edf9fab 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,47 @@ +2001 Sep 24 - Build 2025 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Victor + * More FAT32 fixes ++ Fixes Tom + * Printer handling + * misc INT2F/AH=12 fixes. + * misc clean-ups ++ Fixes Bart + * Added drive B: handling if only one floppy drive available + (look for play_dj() in dsk.c) + * Simplify Victor's FAT32 fixes a bit + * More printer clean-ups +2001 Sep 22 - Build 2025 (test) +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Added Victor + * FAT32 support + * Delete long file names if short file name given ++ Added Jeremy + * modified SYS so it takes optional 2nd parameter (similar to PC DOS) + where if only 1 argument is given, assume to be destination drive, + but if two arguments given, 1st is source (drive and/or path) + and second is destination drive ++ fixes Victor + * some small FCB and dsk.c fixes ++ fixes Tom + * some FAT32 issues + * many compiler portability changes (compiles with Watcom, MSC, ...) + * DosMemChange should set the PSP + * converted INT2F/AH=12 functions to C and added some - enough to + get most of the MS LAN network client working ++ fixes Bart + * some FAT32 issues + * Dos{Open,Creat}Sft drive letter issues + for CDROMs (thanks Jeremy) + * shrink_file should ALWAYS fail for directories, also with + dos_set_fattr (thanks Jeremy) + * only give warnings for slightly suspect partitions at boot + time where CHS does not match LBA. + * re-enabled copyright notice. + * some dsk.c clean-ups to avoid DIR giving the same contents for + a different floppy (get serial number/volume label did reset the + changed state). + * attribute should be 8-bit fix 2001 Aug 19 - Build 2024/h -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + fixes Bart diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 7890dc2..876c77a 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.8 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.7 2001/07/09 22:19:33 bartoldeman ; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings ; @@ -455,3 +458,8 @@ _fl_lba_ReadWrite: pop bp ret + +global _fl_readkey +_fl_readkey: xor ah, ah + int 16h + ret diff --git a/hdr/algnbyte.h b/hdr/algnbyte.h index 23dfd06..55d1c3d 100644 --- a/hdr/algnbyte.h +++ b/hdr/algnbyte.h @@ -1,11 +1,14 @@ #if defined(_MSC_VER) -#define asm __asm -#pragma pack(1) + #define asm __asm + #if _MSC_VER >= 700 + #pragma warning(disable:4103) + #endif + #pragma pack(1) #elif defined(_QC) || defined(__WATCOM__) -#pragma pack(1) + #pragma pack(1) #elif defined(__ZTC__) -#pragma ZTC align 1 + #pragma ZTC align 1 #elif defined(__TURBOC__) && (__TURBOC__ > 0x202) -#pragma option -a- + #pragma option -a- #endif diff --git a/hdr/buffer.h b/hdr/buffer.h index 2d3b665..b7f1ec4 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -38,6 +38,9 @@ static BYTE *buffer_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2001/08/19 12:58:34 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -65,17 +68,19 @@ struct buffer ULONG b_blkno; /* block for this buffer */ /* DOS-C: 0xffff for huge block numbers */ BYTE b_copies; /* number of copies to write */ - UBYTE b_offset_lo; /* span between copies (low) */ +#ifdef WITHFAT32 + ULONG b_offset; /* span between copies */ +#else + UWORD b_offset; /* span between copies */ +#endif #if 0 /*TE*/ union { - struct dpb FAR *_b_dpbp; /* pointer to DPB */ + struct dpb FAR *_b_dpbp; /* pointer to DPB */ LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ } _b; #endif - UBYTE b_offset_hi; /* DOS-C: span between copies (high) */ - UBYTE b_unused; BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ }; diff --git a/hdr/dcb.h b/hdr/dcb.h index 8caa11e..3061a22 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -36,6 +36,9 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -87,7 +90,7 @@ static BYTE *clock_hRcsId = "$Id$"; * Initial revision. */ -/* Internal drive parameter block */ +/* Internal drive parameter block */ struct dpb { BYTE dpb_unit; /* unit for error reporting */ @@ -98,9 +101,18 @@ struct dpb UWORD dpb_fatstrt; /* FAT start sector */ UBYTE dpb_fats; /* # of FAT copies */ UWORD dpb_dirents; /* # of dir entries */ +#ifdef WITHFAT32 + UWORD dpb_wdata; /* start of data area */ + UWORD dpb_wsize; /* # of clusters+1 on media */ + UWORD dpb_wfatsize; /* # of sectors / FAT */ +#else UWORD dpb_data; /* start of data area */ UWORD dpb_size; /* # of clusters+1 on media */ UWORD dpb_fatsize; /* # of sectors / FAT */ +#define dpb_wdata dpb_data +#define dpb_wsize dpb_size +#define dpb_wfatsize dpb_fatsize +#endif UWORD dpb_dirstrt; /* start sec. of root dir */ struct dhdr FAR * /* pointer to device header */ dpb_device; @@ -108,13 +120,36 @@ struct dpb BYTE dpb_flags; /* -1 = force MEDIA CHK */ struct dpb FAR * /* next dpb in chain */ dpb_next; /* -1 = end */ +#ifdef WITHFAT32 + UWORD dpb_wcluster; /* cluster # of first free */ + /* -1 if not known */ + ULONG dpb_nfreeclst; /* number of free clusters */ + /* -1 if not known */ + UWORD dpb_xflags; /* extended flags, see bpb */ + UWORD dpb_xfsinfosec; /* FS info sector number, */ + /* 0xFFFF if unknown */ + UWORD dpb_xbackupsec; /* backup boot sector number */ + /* 0xFFFF if unknown */ + ULONG dpb_data; + ULONG dpb_size; /* # of clusters+1 on media */ + ULONG dpb_fatsize; /* # of sectors / FAT */ + ULONG dpb_xrootclst; /* starting cluster of root dir */ + ULONG dpb_cluster; /* cluster # of first free */ + /* -1 if not known */ +#else UWORD dpb_cluster; /* cluster # of first free */ - /* -1 if not known */ + /* -1 if not known */ +#define dpb_wcluster dpb_cluster UWORD dpb_nfreeclst; /* number of free clusters */ - /* -1 if not known */ - + /* -1 if not known */ +#endif }; -#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ -#define UNKNCLSTFREE 0xffff /* 0xffff = unknown for DOS */ +#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ +#ifdef WITHFAT32 +#define UNKNCLSTFREE 0xffffffffl /* unknown for DOS */ +#else +#define UNKNCLSTFREE 0xffff /* unknown for DOS */ +#endif +#define UNKNCLSTFREE16 0xffff /* unknown for DOS */ diff --git a/hdr/device.h b/hdr/device.h index cd85433..f3f9eaf 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,6 +35,9 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.7 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -229,25 +232,10 @@ struct dhdr /* */ /* Bios Parameter Block structure */ /* */ -/* The following offsets are computed as byte offsets and are based on */ -/* the struct below. The struct itself cannot be used because on some */ -/* compilers, structure alignement may be forced, throwing following */ -/* fields off (e.g. - BYTE, followed by a WORD may have a byte of fill */ -/* inserted in between; the WORD would then be at offset 2, not 1). */ -/* */ -#define BPB_NBYTE 0 -#define BPB_NSECTOR 2 -#define BPB_NRESERVED 3 -#define BPB_NFAT 5 -#define BPB_NDIRENT 6 -#define BPB_NSIZE 8 -#define BPB_MDESC 10 -#define BPB_NFSECT 11 -#define BPB_NSECS 13 -#define BPB_NHEADS 15 -#define BPB_HIDDEN 17 -#define BPB_HUGE 21 -#define BPB_SIZEOF 25 + +#define FAT_NO_MIRRORING 0x80 + +#define BPB_SIZEOF 31 /* size of the standard BPB */ typedef struct { @@ -263,7 +251,21 @@ typedef struct UWORD bpb_nheads; /* Number of heads */ ULONG bpb_hidden; /* Hidden sectors */ ULONG bpb_huge; /* Size in sectors if */ - /* bpb_nsize== 0 */ + /* bpb_nsize == 0 */ +#ifdef WITHFAT32 + ULONG bpb_xnfsect; /* FAT size in sectors if */ + /* bpb_nfsect == 0 */ + UWORD bpb_xflags; /* extended flags */ + /* bit 7: disable mirroring */ + /* bits 6-4: reserved (0) */ + /* bits 3-0: active FAT number */ + UWORD bpb_xfsversion; /* filesystem version */ + ULONG bpb_xrootclst; /* starting cluster of root dir */ + UWORD bpb_xfsinfosec; /* FS info sector number, */ + /* 0xFFFF if unknown */ + UWORD bpb_xbackupsec; /* backup boot sector number */ + /* 0xFFFF if unknown */ +#endif } bpb; @@ -334,6 +336,18 @@ typedef struct ddtstruct BITS ddt_WriteVerifySupported:1; } ddt; +/* description flag bits */ +#define DF_FIXED 0x001 +#define DF_CHANGELINE 0x002 +#define DF_CURBPBLOCK 0x004 +#define DF_SAMESIZE 0x008 +#define DF_MULTLOG 0x010 +#define DF_CURLOG 0x020 +#define DF_DISKCHANGE 0x040 +#define DF_DPCHANGED 0x080 +#define DF_REFORMAT 0x100 +#define DF_NOACCESS 0x200 + /* typedef struct ddtstruct ddt;*/ struct gblkio @@ -383,6 +397,15 @@ typedef struct } boot; +/* File system information structure */ +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 */ + UBYTE fi_reserved[12]; +}; + typedef boot super; /* Alias for boot structure */ typedef struct diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 8d686ed..6956f20 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,6 +36,9 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.5 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -100,7 +103,12 @@ typedef struct BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; BYTE dm_attr_srch; UWORD dm_entry; - UWORD dm_cluster; +#ifdef WITHFAT32 + ULONG dm_dircluster; +#else + UWORD dm_dircluster; + UWORD reserved; +#endif struct { @@ -119,8 +127,6 @@ typedef struct } dm_flags; /* file flags */ - UWORD dm_dirstart; - BYTE dm_attr_fnd; /* found file attribute */ time dm_time; /* file time */ date dm_date; /* file date */ diff --git a/hdr/error.h b/hdr/error.h index 1fcb216..41541c8 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -36,6 +36,9 @@ static BYTE *error_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.5 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -93,7 +96,7 @@ static BYTE *error_hRcsId = "$Id$"; * Initial revision. */ -/* Internal system error returns */ +/* Internal system error returns */ #define SUCCESS 0 /* Function was successful */ #define DE_INVLDFUNC -1 /* Invalid function number */ #define DE_FILENOTFND -2 /* File not found */ @@ -107,22 +110,25 @@ static BYTE *error_hRcsId = "$Id$"; #define DE_INVLDENV -10 /* Invalid enviornement */ #define DE_INVLDFMT -11 /* Invalid format */ #define DE_INVLDACC -12 /* Invalid access */ -#define DE_INVLDDATA -13 /* Inavalid data */ +#define DE_INVLDDATA -13 /* Invalid data */ #define DE_INVLDDRV -15 /* Invalid drive */ #define DE_RMVCUDIR -16 /* Attempt remove current dir */ #define DE_DEVICE -17 /* Not same device */ #define DE_NFILES -18 /* No more files */ #define DE_WRTPRTCT -19 /* No more files */ #define DE_BLKINVLD -20 /* invalid block */ +#define DE_INVLDBUF -24 /* invalid buffer size, ext fnc */ #define DE_SEEK -25 /* error on file seek */ #define DE_HNDLDSKFULL -28 /* handle disk full (?) */ +#define DE_INVLDPARM -0x57 /* invalid parameter */ + #define DE_DEADLOCK -36 #define DE_LOCK -39 #define DE_FILEEXISTS -80 /* File exists */ -/* Critical error flags */ +/* Critical error flags */ #define EFLG_READ 0x00 /* Read error */ #define EFLG_WRITE 0x01 /* Write error */ #define EFLG_RSVRD 0x00 /* Error in rserved area */ @@ -134,8 +140,8 @@ static BYTE *error_hRcsId = "$Id$"; #define EFLG_IGNORE 0x20 /* Handler can ignore */ #define EFLG_CHAR 0x80 /* Error in char or FAT image */ -/* error results returned after asking user */ -/* MS-DOS compatible -- returned by CriticalError */ +/* error results returned after asking user */ +/* MS-DOS compatible -- returned by CriticalError */ #define CONTINUE 0 #define RETRY 1 #define ABORT 2 diff --git a/hdr/fat.h b/hdr/fat.h index b316ad7..7259deb 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.7 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -104,6 +107,8 @@ static BYTE *fat_hRcsId = "$Id$"; /* /// Added D_DEVICE bit. - Ron Cemer */ #define D_DEVICE 0x40 /* device bit */ +#define D_LFN (D_RDONLY | D_HIDDEN | D_SYSTEM | D_VOLID) + /* FAT file name constants */ #define FNAME_SIZE 8 #define FEXT_SIZE 3 @@ -122,11 +127,15 @@ static BYTE *fat_hRcsId = "$Id$"; /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 +#define SIZEOF_CLST32 4 #define FAT_MAGIC 4086 #define FAT_MAGIC16 ((unsigned)65526l) #define FAT_MAGIC32 268435456l -#define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 && ((dpbp)->dpb_size)<=FAT_MAGIC32 ) +/* int ISFAT32(struct dpb FAR *dpbp);*/ +#define ISFAT32(x) _ISFAT32(x) + +#define _ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 && ((dpbp)->dpb_size)<=FAT_MAGIC32 ) #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC && ((dpbp)->dpb_size)<=FAT_MAGIC16 ) #define ISFAT12(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC) @@ -136,11 +145,16 @@ struct dirent UBYTE dir_name[FNAME_SIZE]; /* Filename */ UBYTE dir_ext[FEXT_SIZE]; /* Filename extension */ UBYTE dir_attrib; /* File Attribute */ - BYTE dir_reserved[10]; /* reserved */ + UBYTE dir_case; /* File case */ + UBYTE dir_crtimems; /* Milliseconds */ + UWORD dir_crtime; /* Creation time */ + UWORD dir_crdate; /* Creation date */ + UWORD dir_accdate; /* Last access date */ + UWORD dir_start_high; /* High word of the cluster */ time dir_time; /* Time file created/updated */ - date dir_date; /* Date file created/updated */ + date dir_date; /* Date file created/updated */ UWORD dir_start; /* Starting cluster */ - /* 1st available = 2 */ + /* 1st available = 2 */ ULONG dir_size; /* File size in bytes */ }; @@ -148,6 +162,24 @@ struct dirent /* filesystem sizeof(dirent) - may be different from core */ /* */ +#ifdef WITHFAT32 +#define getdstart(dentry) \ + (((ULONG)dentry.dir_start_high << 16) | dentry.dir_start) +#define setdstart(dentry, value) \ + dentry.dir_start = (UCOUNT)value; \ + dentry.dir_start_high = (UCOUNT)(value >> 16) +#define checkdstart(dentry, value) \ + (dentry.dir_start == (UCOUNT)value && \ + dentry.dir_start_high == (UCOUNT)(value >> 16)) +#else +#define getdstart(dentry) \ + dentry.dir_start +#define setdstart(dentry, value) \ + dentry.dir_start = (UCOUNT)value +#define checkdstart(dentry, value) \ + (dentry.dir_start == (UCOUNT)value) +#endif + #define DIR_NAME 0 #define DIR_EXT FNAME_SIZE #define DIR_ATTRIB FNAME_SIZE+FEXT_SIZE diff --git a/hdr/fnode.h b/hdr/fnode.h index 525c55b..9085ae6 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.8 2001/08/19 12:58:34 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -122,18 +125,33 @@ struct f_node struct dirent f_dir; /* this file's dir entry image */ ULONG f_diroff; /* offset of the dir entry */ - UWORD f_dirstart; /* the starting cluster of dir */ + CLUSTER f_dirstart; /* the starting cluster of dir */ /* when dir is not root */ struct dpb FAR *f_dpb; /* the block device for file */ ULONG f_dsize; /* file size (for directories) */ ULONG f_offset; /* byte offset for next op */ ULONG f_highwater; /* the largest offset ever */ - UWORD f_back; /* the cluster we were at */ + CLUSTER f_back; /* the cluster we were at */ ULONG f_cluster_offset; /* byte offset that the next 3 point to */ - UWORD f_cluster; /* the cluster we are at */ + CLUSTER f_cluster; /* the cluster we are at */ UWORD f_sector; /* the sector in the cluster */ UWORD f_boff; /* the byte in the cluster */ }; +#if 0 +struct lfn_inode + { + UNICODE name[255]; + + struct dirent l_dir; /* this file's dir entry image */ + + 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; +#endif + typedef struct f_node * f_node_ptr; diff --git a/hdr/pcb.h b/hdr/pcb.h index bec11d1..d02c2eb 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -57,6 +57,9 @@ static BYTE *pcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -239,7 +242,7 @@ pcb; * On return, all processor registers are stored into *pr (including * flags). */ -void intr(int intnr, iregs * const pr); +void ASMCFUNC intr(int intnr, iregs * const pr); #endif diff --git a/hdr/portab.h b/hdr/portab.h index 9ddae0b..e4fd11b 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,9 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.9 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -119,6 +122,49 @@ static char *portab_hRcsId = "$Id$"; /* */ /****************************************************************/ + + /* commandline overflow - removing -DI86 TE*/ +#if defined(__TURBOC__) + + #define I86 + #define CDECL cdecl + void __int__(int); + +#elif defined (_MSC_VER) + + #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 + +#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 + + #if _M_IX86 >= 300 + #define I386 + #endif + +#elif defined (_MYMC68K_COMILER_) + + #define MC68K + +#else + 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 */ @@ -198,6 +244,13 @@ typedef int COUNT; typedef unsigned int UCOUNT; typedef unsigned long ULONG; +#ifdef WITHFAT32 +typedef unsigned long CLUSTER; +#else +typedef unsigned short CLUSTER; +#endif +typedef unsigned short UNICODE; + #define STATIC /* local calls inside module */ @@ -240,18 +293,7 @@ typedef signed long LONG; #define UNREFERENCED_PARAMETER(x) x; #endif - -#if defined(__TURBOC__) - #define FDCALL pascal - #define CDECL cdecl -#else - #define FDCALL - #define CDECL -#endif - -#ifdef I86 - /* commandline overflow - removing /DPROTO - TE*/ +#ifdef I86 /* commandline overflow - removing /DPROTO TE*/ #define PROTO #endif diff --git a/hdr/process.h b/hdr/process.h index 70dc6fd..12684fd 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -36,6 +36,9 @@ static BYTE *process_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -128,7 +131,7 @@ typedef struct BYTE ps_fill1; /* single char fill */ /* CP/M-like entry point */ - BYTE ps_farcall; /* far call opcode */ + UBYTE ps_farcall; /* far call opcode */ VOID(FAR * ps_reentry) (); /* re-entry point */ VOID(interrupt FAR * ps_isv22) (), /* terminate address */ (interrupt FAR * ps_isv23) (), /* break address */ @@ -142,7 +145,7 @@ typedef struct VOID FAR *ps_prevpsp; /* previous psp pointer */ BYTE FAR *ps_dta; /* process dta address */ BYTE ps_fill2[16]; - BYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ + UBYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ BYTE ps_fill3[9]; union { diff --git a/hdr/version.h b/hdr/version.h index de27c7e..edc6f08 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -42,6 +42,8 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 24 -#define BUILD 2024 -#define SUB_BUILD "h" +#define REVISION_SEQ 25 +#define BUILD "2025" +#define SUB_BUILD "test" +#define KERNEL_VERSION_STRING "1.1.25" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ +#define KERNEL_BUILD_STRING "2025test" /*#BUILD SUB_BUILD*/ diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 27ebb59..dd18bb8 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -34,6 +34,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.5 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -423,7 +426,7 @@ _fstrncmp: ; and the destination pointer, d les di,[bp+8] - mov cx,[bp+10] + mov cx,[bp+12] jmp short dostrncmp diff --git a/kernel/blockio.c b/kernel/blockio.c index 4ad8945..3c8278f 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.12 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -194,15 +197,13 @@ VOID FAR reloc_call_init_buffers(void) pbuffer->b_flag = 0; pbuffer->b_blkno = 0; pbuffer->b_copies = 0; - pbuffer->b_offset_lo = 0; - pbuffer->b_offset_hi = 0; + pbuffer->b_offset = 0; if (i < (Config.cfgBuffers - 1)) pbuffer->b_next = pbuffer + 1; else pbuffer->b_next = NULL; } firstbuf = &buffers[0]; - lastbuf = &buffers[Config.cfgBuffers - 1]; } */ /* Extract the block number from a buffer structure. */ @@ -496,12 +497,11 @@ BOOL flush1(struct buffer FAR * bp) if (bp->b_flag & BFR_FAT) { int i = bp->b_copies; - LONG blkno = getblkno(bp); - UWORD offset = ((UWORD) bp->b_offset_hi << 8) | bp->b_offset_lo; + ULONG blkno = getblkno(bp); while (--i > 0) { - blkno += offset; + blkno += bp->b_offset; result = dskxfer(bp->b_unit, blkno, (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ } diff --git a/kernel/break.c b/kernel/break.c index 0e2d567..a0c574e 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -30,7 +30,7 @@ #include "portab.h" #include "globals.h" -extern void spawn_int23(void); +extern void ASMCFUNC spawn_int23(void); #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,6 +38,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.6 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * diff --git a/kernel/chario.c b/kernel/chario.c index 53eba67..568fa7f 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.12 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -150,10 +153,6 @@ static VOID kbfill(); struct dhdr FAR *finddev(); #endif -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - /* Return a pointer to the first driver in the chain that * matches the attributes. * not necessary because we have the syscon pointer. @@ -177,8 +176,15 @@ struct dhdr FAR *finddev(UWORD attr_mask) VOID _cso(COUNT c) { if (syscon->dh_attr & ATTR_FASTCON) { - _AL = c; - __int__(0x29); + #if defined(__TURBOC__) + _AL = c; + __int__(0x29); + #else + asm { + mov al, byte ptr c; + int 0x29; + } + #endif return; } CharReqHdr.r_length = sizeof(request); diff --git a/kernel/config.c b/kernel/config.c index 16db066..751c151 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -29,10 +29,10 @@ #include "portab.h" #include "init-mod.h" +#include "init-dat.h" #include "dyndata.h" - /* 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 @@ -41,42 +41,41 @@ -- Bart */ -extern struct buffer FAR * FAR lastbuf;/* tail of ditto */ -extern f_node_ptr FAR f_nodes; /* pointer to the array */ -extern UWORD FAR f_nodes_cnt, /* number of allocated f_nodes */ - FAR first_mcb; /* Start of user memory */ +extern f_node_ptr DOSFAR f_nodes; /* pointer to the array */ +extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes */ + DOSFAR first_mcb; /* Start of user memory */ -extern UBYTE FAR lastdrive, FAR nblkdev, FAR mem_access_mode, - FAR uppermem_link; +extern UBYTE DOSFAR lastdrive, DOSFAR nblkdev, DOSFAR mem_access_mode, + DOSFAR uppermem_link; extern struct dhdr - FAR blk_dev, /* Block device (Disk) driver */ - FAR nul_dev; -extern struct buffer FAR * FAR firstbuf; /* head of buffers linked list */ + DOSTEXTFAR blk_dev, /* Block device (Disk) driver */ + DOSFAR nul_dev; +extern struct buffer FAR * DOSFAR firstbuf; /* head of buffers linked list */ -extern struct dpb FAR * FAR DPBp; +extern struct dpb FAR * DOSFAR DPBp; /* First drive Parameter Block */ -extern cdstbl FAR * FAR CDSp; +extern cdstbl FAR * DOSFAR CDSp; /* Current Directory Structure */ -extern sfttbl FAR * FAR sfthead; +extern sfttbl FAR * DOSFAR sfthead; /* System File Table head */ -extern sfttbl FAR * FAR FCBp; +extern sfttbl FAR * DOSFAR FCBp; -extern BYTE FAR VgaSet, - FAR _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[], - FAR break_ena, /* break enabled flag */ - FAR os_major, /* major version number */ - FAR os_minor, /* minor version number */ - FAR switchar, - FAR _InitTextStart, /* first available byte of ram */ - FAR ReturnAnyDosVersionExpected; + 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 ReturnAnyDosVersionExpected; -extern UWORD FAR ram_top, /* How much ram in Kbytes */ - FAR UMB_top, - FAR umb_start, - FAR uppermem_root, - FAR LoL_nbuffers; +extern UWORD DOSFAR ram_top, /* How much ram in Kbytes */ + DOSFAR UMB_top, + DOSFAR umb_start, + DOSFAR uppermem_root, + DOSFAR LoL_nbuffers; #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -90,6 +89,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.28 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.27 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -276,16 +278,20 @@ struct config Config ,0 /* strategy for command.com is low by default */ } ; - -BYTE FAR *lpBase; -BYTE FAR *upBase; -BYTE FAR *lpTop; -BYTE FAR *lpOldTop; -static COUNT nCfgLine; -static COUNT nPass; - COUNT UmbState; -static BYTE szLine[256]; -static BYTE szBuf[256]; + /* MSC places uninitialized data into COMDEF records, + that end up in DATA segment. this can't be tolerated + in INIT code. + please make sure, that ALL data in INIT is initialized !! + */ +BYTE FAR *lpBase = 0; +BYTE FAR *upBase = 0; +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}; int singleStep = FALSE; int SkipAllConfig = FALSE; @@ -296,18 +302,18 @@ INIT VOID mumcb_init(UCOUNT seg, UWORD size); INIT VOID Config_Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); INIT VOID sysVersion(BYTE * pLine); -INIT VOID Break(BYTE * pLine); +INIT VOID CfgBreak(BYTE * pLine); INIT VOID Device(BYTE * pLine); INIT VOID DeviceHigh(BYTE * pLine); INIT VOID Files(BYTE * pLine); INIT VOID Fcbs(BYTE * pLine); -INIT VOID Lastdrive(BYTE * pLine); +INIT VOID CfgLastdrive(BYTE * pLine); INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode); INIT VOID Dosmem(BYTE * pLine); INIT VOID Country(BYTE * pLine); INIT VOID InitPgm(BYTE * pLine); INIT VOID InitPgmHigh(BYTE * pLine); -INIT VOID Switchar(BYTE * pLine); +INIT VOID CfgSwitchar(BYTE * pLine); INIT VOID CfgFailure(BYTE * pLine); INIT VOID Stacks(BYTE * pLine); INIT VOID SetAnyDos(BYTE * pLine); @@ -323,7 +329,7 @@ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s); extern void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ -INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr); +INIT STATIC VOID FAR *AlignParagraph(VOID FAR * lpPtr); #ifndef I86 #define AlignParagraph(x) (x) #endif @@ -339,9 +345,9 @@ struct table VOID(*func) (BYTE * pLine); }; -static struct table commands[] = +STATIC struct table commands[] = { - {"BREAK", 1, Break}, + {"BREAK", 1, CfgBreak}, {"BUFFERS", 1, Config_Buffers}, {"COMMAND", 1, InitPgm}, {"COUNTRY", 1, Country}, @@ -350,14 +356,14 @@ static struct table commands[] = {"DOS", 1, Dosmem}, {"FCBS", 1, Fcbs}, {"FILES", 1, Files}, - {"LASTDRIVE", 1, Lastdrive}, + {"LASTDRIVE", 1, CfgLastdrive}, {"NUMLOCK", 1, Numlock}, /* rem is never executed by locking out pass */ {"REM", 0, CfgFailure}, {"SHELL", 1, InitPgm}, {"SHELLHIGH", 1, InitPgmHigh}, {"STACKS", 1, Stacks}, - {"SWITCHAR", 1, Switchar}, + {"SWITCHAR", 1, CfgSwitchar}, {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ {"ANYDOS", 1, SetAnyDos}, /* JPP */ @@ -370,9 +376,9 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes); INIT BYTE FAR *KernelAllocDma(WORD); #endif -BYTE *pLineStart; +BYTE *pLineStart = 0; -BYTE HMAState; +BYTE HMAState = 0; #define HMA_NONE 0 /* do nothing */ #define HMA_REQ 1 /* DOS = HIGH detected */ #define HMA_DONE 2 /* Moved kernel to HMA */ @@ -548,7 +554,7 @@ INIT void PostConfig(void) printf(" sft table 0x%p\n",sfthead->sftt_next); printf(" CDS table 0x%p\n",CDSp); printf(" DPB table 0x%p\n",DPBp); -#endif +#endif if (Config.cfgStacks) { VOID FAR *stackBase = KernelAlloc(Config.cfgStacks * Config.cfgStackSize); @@ -707,7 +713,7 @@ INIT VOID DoConfig(VOID) { bEof = TRUE; break; - } + } /* immediately convert to upper case */ *pLine = toupper(*pLine); @@ -946,7 +952,7 @@ INIT void Config_Buffers(BYTE * pLine) Config.cfgBuffers = max(Config.cfgBuffers, nBuffers); } -INIT static VOID sysScreenMode(BYTE * pLine) +INIT STATIC VOID sysScreenMode(BYTE * pLine) { COUNT nMode; @@ -962,12 +968,20 @@ INIT static VOID sysScreenMode(BYTE * pLine) 0x12 (18) 43/50 lines 0x14 (20) 25 lines */ +#if defined(__TURBOC__) _AX = (0x11 << 8) + nMode; _BL = 0; __int__(0x10); +#else + asm { + mov al, byte ptr nMode; + mov ah, 0x11; + int 0x10; + } +#endif } -INIT static VOID sysVersion(BYTE * pLine) +INIT STATIC VOID sysVersion(BYTE * pLine) { COUNT major, minor; @@ -994,7 +1008,7 @@ INIT static VOID sysVersion(BYTE * pLine) os_minor = minor; } -INIT static VOID Files(BYTE * pLine) +INIT STATIC VOID Files(BYTE * pLine) { COUNT nFiles; @@ -1006,7 +1020,7 @@ INIT static VOID Files(BYTE * pLine) Config.cfgFiles = max(Config.cfgFiles, nFiles); } -INIT static VOID Lastdrive(BYTE * pLine) +INIT STATIC VOID CfgLastdrive(BYTE * pLine) { /* Format: LASTDRIVE = letter */ BYTE drv; @@ -1067,7 +1081,7 @@ INIT STATIC VOID Dosmem(BYTE * pLine) } } -INIT static VOID Switchar(BYTE * pLine) +INIT STATIC VOID CfgSwitchar(BYTE * pLine) { /* Format: SWITCHAR = character */ @@ -1075,7 +1089,7 @@ INIT static VOID Switchar(BYTE * pLine) switchar = *szBuf; } -INIT static VOID Fcbs(BYTE * pLine) +INIT STATIC VOID Fcbs(BYTE * pLine) { /* Format: FCBS = totalFcbs [,protectedFcbs] */ COUNT fcbs; @@ -1117,7 +1131,7 @@ INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) return FALSE; } -INIT static VOID Country(BYTE * pLine) +INIT STATIC VOID Country(BYTE * pLine) { /* Format: COUNTRY = countryCode, [codePage], filename */ COUNT ctryCode; @@ -1153,7 +1167,7 @@ INIT static VOID Country(BYTE * pLine) CfgFailure(pLine); } -INIT static VOID Stacks(BYTE * pLine) +INIT STATIC VOID Stacks(BYTE * pLine) { COUNT stacks; @@ -1180,14 +1194,14 @@ INIT static VOID Stacks(BYTE * pLine) } } -INIT static VOID InitPgmHigh(BYTE * pLine) +INIT STATIC VOID InitPgmHigh(BYTE * pLine) { InitPgm(pLine); Config.cfgP_0_startmode = 0x80; } -INIT static VOID InitPgm(BYTE * pLine) +INIT STATIC VOID InitPgm(BYTE * pLine) { /* Get the string argument that represents the new init pgm */ pLine = GetStringArg(pLine, Config.cfgInit); @@ -1202,16 +1216,16 @@ INIT static VOID InitPgm(BYTE * pLine) Config.cfgP_0_startmode = 0; } -INIT static VOID Break(BYTE * pLine) +INIT STATIC VOID CfgBreak(BYTE * pLine) { /* Format: BREAK = (ON | OFF) */ GetStringArg(pLine, szBuf); break_ena = strcasecmp(szBuf, "OFF") ? 1 : 0; } -INIT static VOID Numlock(BYTE * pLine) +INIT STATIC VOID Numlock(BYTE * pLine) { - extern VOID keycheck(); + extern VOID ASMCFUNC keycheck(); /* Format: NUMLOCK = (ON | OFF) */ BYTE FAR *keyflags = (BYTE FAR *)MK_FP(0x40,0x17); @@ -1223,7 +1237,7 @@ INIT static VOID Numlock(BYTE * pLine) keycheck(); } -INIT static VOID DeviceHigh(BYTE * pLine) +INIT STATIC VOID DeviceHigh(BYTE * pLine) { if(UmbState == 1) { @@ -1313,7 +1327,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) return result; } -INIT static VOID CfgFailure(BYTE * pLine) +INIT STATIC VOID CfgFailure(BYTE * pLine) { BYTE *pTmp = pLineStart; @@ -1581,34 +1595,52 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer = firstbuf; + DebugPrintf(("init_buffers at")); + for (i = 0; ; ++i) { if (FP_SEG(pbuffer) == 0xffff) HMAcount++; - lastbuf = pbuffer; - pbuffer->b_dummy = FP_OFF(pbuffer); pbuffer->b_unit = 0; pbuffer->b_flag = 0; pbuffer->b_blkno = 0; pbuffer->b_copies = 0; - pbuffer->b_offset_lo = 0; - pbuffer->b_offset_hi = 0; + pbuffer->b_offset = 0; pbuffer->b_next = NULL; - DebugPrintf(("init_buffers buffer %d at %p\n",i, pbuffer)); - + DebugPrintf((" (%d,%p)",i, pbuffer)); + + /* now, we can have quite some buffers in HMA + -- up to 37 for KE38616. + so we fill the HMA with buffers + */ + if (i < (anzBuffers - 1)) - pbuffer->b_next = ConfigAlloc(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)); + } + } + if (pbuffer->b_next == NULL) break; pbuffer = pbuffer->b_next; } - DebugPrintf(("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", - HMAcount, HMAcount*sizeof (struct buffer))); + DebugPrintf((" done\n")); + + if (HMAcount) + printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", + HMAcount, HMAcount*sizeof (struct buffer)); + if (HMAState == HMA_NONE || HMAState == HMA_REQ) lpBase = tmplpBase; } diff --git a/kernel/dosfns.c b/kernel/dosfns.c index c694fc8..ab068e8 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.26 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.25 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -258,6 +261,31 @@ static int share_lock_unlock /* /// End of additions for SHARE. - Ron Cemer */ +#ifdef WITHFAT32 +struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT *rc) +{ + struct dpb FAR *dpb; + drive = drive == 0 ? default_drive : drive - 1; + + if (drive >= lastdrive) + { + *rc = DE_INVLDDRV; + return 0; + } + + dpb = CDSp->cds_table[drive].cdsDpb; + if (dpb == 0 || + CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + { + *rc = DE_INVLDDRV; + return 0; + } + + *rc = SUCCESS; + return dpb; +} +#endif + static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) { BYTE szLclName[FNAME_SIZE + 1]; @@ -758,7 +786,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) COUNT drive; /* NEVER EVER allow directories to be created */ - if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) + if (attrib & 0xff & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) { return DE_ACCESS; } @@ -772,7 +800,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_psp = cu_psp; sftp->sft_mode = SFT_MRDWR; - sftp->sft_attrib = attrib; + sftp->sft_attrib = attrib & 0xff; sftp->sft_psp = cu_psp; /* check for a device */ @@ -787,12 +815,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) return sft_idx; } - drive = get_verify_drive(fname); - if(drive < 0) { - return drive; - } - - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + if (current_ldt->cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; sftp->sft_mode = attrib; result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); @@ -802,7 +825,12 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) } return result; } - + + drive = get_verify_drive(fname); + if (drive < 0) { + return drive; + } + /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { if ((sftp->sft_shroff = share_open_check @@ -975,12 +1003,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) return sft_idx; } - drive = get_verify_drive(fname); - if (drive < 0) { - return drive; - } - - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + if (current_ldt->cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); if (result == SUCCESS) { @@ -989,6 +1012,12 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) } return result; } + + drive = get_verify_drive(fname); + if (drive < 0) { + return drive; + } + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ /* /// Added for SHARE. - Ron Cemer */ @@ -1116,7 +1145,11 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, { struct dpb FAR *dpbp; struct cds FAR *cdsp; - COUNT rg[4]; + COUNT rg[4]; +#ifdef WITHFAT32 + UCOUNT shift = 0; + ULONG cluster_size, ntotal, nfree; +#endif /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); @@ -1145,8 +1178,28 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, dpbp = CDSp->cds_table[drive].cdsDpb; if (dpbp == NULL || media_check(dpbp) < 0) return; +#ifdef WITHFAT32 + cluster_size = (dpbp->dpb_clsmask + 1) * dpbp->dpb_secsize; + ntotal = dpbp->dpb_size - 1; + if (ISFAT32(dpbp)) while (cluster_size <= 0x7fff) { + cluster_size <<= 1; + ntotal >>= 1; + shift++; + } + /* get the data available from dpb */ + *nc = (UCOUNT)ntotal; + if (ntotal > 0xfffe) + *nc = 0xfffe; + *spc = (dpbp->dpb_clsmask + 1) << shift; + *bps = dpbp->dpb_secsize; - /* get the data vailable from dpb */ + /* now tell fs to give us free cluster */ + /* count */ + nfree = dos_free(dpbp) >> shift; + if (nfree > 0xfffe) nfree = 0xfffe; + *navc = (UCOUNT)nfree; +#else + /* get the data available from dpb */ *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; @@ -1154,8 +1207,59 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, /* now tell fs to give us free cluster */ /* count */ *navc = dos_free(dpbp); +#endif } +#ifdef WITHFAT32 +/* network names like \\SERVER\C aren't supported yet */ +#define IS_SLASH(ch) (ch == '\\' || ch == '/') +COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp) +{ + struct dpb FAR *dpbp; + struct cds FAR *cdsp; + UBYTE drive; + UCOUNT rg[4]; + + if (IS_SLASH(DriveString[0]) || !IS_SLASH(DriveString[2]) + || DriveString[1] != ':') + return DE_INVLDDRV; + drive = DosUpFChar(*DriveString) - 'A'; + if (drive >= lastdrive) return DE_INVLDDRV; + + cdsp = &CDSp->cds_table[drive]; + + if (!(cdsp->cdsFlags & CDSVALID)) + return DE_INVLDDRV; + + if (cdsp->cdsFlags & CDSNETWDRV) + { + int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + + xfsp->xfs_clussize = rg[0]; + xfsp->xfs_totalclusters = rg[1]; + xfsp->xfs_secsize = rg[2]; + xfsp->xfs_freeclusters = rg[3]; + } else { + dpbp = CDSp->cds_table[drive].cdsDpb; + if (dpbp == NULL || media_check(dpbp) < 0) + return DE_INVLDDRV; + xfsp->xfs_secsize = dpbp->dpb_secsize; + xfsp->xfs_totalclusters = dpbp->dpb_size; + xfsp->xfs_freeclusters = dos_free(dpbp); + xfsp->xfs_clussize = dpbp->dpb_clsmask + 1; + } + xfsp->xfs_totalunits = xfsp->xfs_totalclusters; + xfsp->xfs_freeunits = xfsp->xfs_freeclusters; + xfsp->xfs_totalsectors = xfsp->xfs_totalclusters * xfsp->xfs_clussize; + xfsp->xfs_freesectors = xfsp->xfs_freeclusters * xfsp->xfs_clussize; + xfsp->xfs_datasize = sizeof(struct xfreespace); + + fmemset(xfsp->xfs_reserved, 0, 8); + + return SUCCESS; +} +#endif + COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { BYTE FAR *cp; diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index 64c868d..bbcdf47 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -42,10 +42,6 @@ segment HMA_TEXT extern critical_sp:wrt DGROUP extern _lpUserStack:wrt DGROUP extern _user_r:wrt DGROUP - extern _api_sp:wrt DGROUP ; api stacks - for context - extern _api_ss:wrt DGROUP ; switching - extern _usr_sp:wrt DGROUP ; user stacks - extern _usr_ss:wrt DGROUP extern _dosidle_flag:wrt DGROUP ; ; @@ -71,10 +67,6 @@ Do_DosI: push word [_user_r+2] push word [_lpUserStack] push word [_lpUserStack+2] - push word [_api_sp] - push word [_api_ss] - push word [_usr_sp] - push word [_usr_ss] mov es,word [_cu_psp] push word [es:PSP_USERSS] push word [es:PSP_USERSP] @@ -84,10 +76,6 @@ Do_DosI: mov es,word [_cu_psp] pop word [es:PSP_USERSP] pop word [es:PSP_USERSS] - pop word [_usr_ss] - pop word [_usr_sp] - pop word [_api_ss] - pop word [_api_sp] pop word [_lpUserStack+2] pop word [_lpUserStack] pop word [_user_r+2] diff --git a/kernel/dsk.c b/kernel/dsk.c index 4d050da..1e6d8ef 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -34,6 +34,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.19 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -165,16 +168,17 @@ static BYTE *dskRcsId = "$Id$"; #ifdef PROTO -BOOL fl_reset(WORD); -COUNT fl_readdasd(WORD); -COUNT fl_diskchanged(WORD); -COUNT fl_rd_status(WORD); +BOOL ASMCFUNC fl_reset(WORD); +COUNT ASMCFUNC fl_readdasd(WORD); +COUNT ASMCFUNC fl_diskchanged(WORD); +COUNT ASMCFUNC fl_rd_status(WORD); -COUNT fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT ASMCFUNC fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT ASMCFUNC fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT ASMCFUNC fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +VOID ASMCFUNC fl_readkey(VOID); -extern COUNT fl_lba_ReadWrite (BYTE drive, WORD mode, +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, @@ -187,20 +191,22 @@ COUNT fl_rd_status(); COUNT fl_read(); COUNT fl_write(); COUNT fl_verify(); +VOID fl_readkey(); #endif #define NENTRY 26 /* total size of dispatch table */ 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; #define LBA_VERIFY 0x4400 -extern void __int__(int); - /* this buffer must not overlap a 64K boundary due to DMA transfers this is certainly true, if located somewhere @@ -312,7 +318,7 @@ static WORD(*dispatch[NENTRY]) () = -#define hd(x) ((x) & 0x80) +#define hd(x) ((x) & DF_FIXED) /* ----------------------------------------------------------------------- */ /* F U N C T I O N S --------------------------------------------------- */ @@ -321,7 +327,7 @@ static WORD(*dispatch[NENTRY]) () = -COUNT FAR blk_driver(rqptr rp) +COUNT FAR ASMCFUNC blk_driver(rqptr rp) { if (rp->r_unit >= nUnits && rp->r_command != C_INIT) return failure(E_UNIT); @@ -342,45 +348,83 @@ WORD _dsk_init(rqptr rp, ddt *pddt) return S_DONE; /* to keep the compiler happy */ } -WORD mediachk(rqptr rp, ddt *pddt) +STATIC WORD play_dj(ddt*pddt) +{ + /* play the DJ ... */ + if ((pddt->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == DF_MULTLOG) + { + int i; + ddt *pddt2 = getddt(0); + for (i = 0; i < nUnits; i++, pddt2++) + { + if (pddt->ddt_driveno == pddt2->ddt_driveno && + (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == + (DF_MULTLOG | DF_CURLOG)) + break; + } + if (i == nUnits) + { + 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("Press the any key to continue ... \n"); + fl_readkey(); + pddt2->ddt_descflags &= ~DF_CURLOG; + pddt->ddt_descflags |= DF_CURLOG; + return M_CHANGED; + } + return M_NOT_CHANGED; +} + +STATIC WORD diskchange(ddt *pddt) { - COUNT drive = pddt->ddt_driveno; COUNT result; /* if it's a hard drive, media never changes */ - if (hd(drive)) - rp->r_mcretcode = M_NOT_CHANGED; - else - /* else, check floppy status */ + if (hd(pddt->ddt_descflags)) + return M_NOT_CHANGED; + + if (play_dj(pddt) == M_CHANGED) + return M_CHANGED; + + if (pddt->ddt_descflags & DF_CHANGELINE) /* if we can detect a change ... */ { - if ((result = fl_readdasd(drive)) == 2) /* if we can detect a change ... */ - { - if ((result = fl_diskchanged(drive)) == 1) /* check if it has changed... */ - rp->r_mcretcode = M_CHANGED; - else if (result == 0) - rp->r_mcretcode = M_NOT_CHANGED; - else - rp->r_mcretcode = tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; - } - else if (result == 3) /* if it's a fixed disk, then no change */ - rp->r_mcretcode = M_NOT_CHANGED; - else /* can not detect or error... */ - rp->r_mcretcode = tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; + if ((result = fl_diskchanged(pddt->ddt_driveno)) == 1) + /* check if it has changed... */ + return M_CHANGED; + else if (result == 0) + return M_NOT_CHANGED; } + /* can not detect or error... */ + return tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; +} + +WORD mediachk(rqptr rp, ddt *pddt) +{ + /* check floppy status */ + if (pddt->ddt_descflags & DF_DISKCHANGE) + { + pddt->ddt_descflags &= ~DF_DISKCHANGE; + rp->r_mcretcode = M_DONT_KNOW; + } + else + { + rp->r_mcretcode = diskchange(pddt); + } return S_DONE; } /* * Read Write Sector Zero or Hard Drive Dos Bpb */ -STATIC WORD RWzero(rqptr rp, WORD t) +STATIC WORD RWzero(ddt *pddt, UWORD mode) { - ddt *pddt = getddt(rp->r_unit); UWORD done; - return LBA_Transfer(pddt, - t == 0 ? LBA_READ : LBA_WRITE, + return LBA_Transfer(pddt, mode, (UBYTE FAR *)&DiskTransferBuffer, pddt->ddt_offset,1,&done); } @@ -396,8 +440,8 @@ static WORD Getlogdev(rqptr rp, ddt *pddt) UNREFERENCED_PARAMETER(pddt); x++; - if( x > nblk_rel ) - return failure(E_UNIT); + if( x > Get_nblk_rel() ) + return failure(E_UNIT); rp->r_unit = x; return S_DONE; @@ -439,22 +483,24 @@ static WORD blk_Media(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - if (hd( pddt->ddt_driveno)) + if (hd( pddt->ddt_descflags)) return S_BUSY|S_DONE; /* Hard Drive */ else return S_DONE; /* Floppy */ } -STATIC WORD bldbpb(rqptr rp, ddt *pddt) +static getbpb(ddt *pddt) { ULONG count; bpb *pbpbarray = &pddt->ddt_bpb; WORD head,/*track,*/sector,ret; - ret = RWzero( rp, 0); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); + ret = RWzero(pddt, LBA_READ); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), &pbpbarray->bpb_nbyte); - pddt->ddt_descflags |= 0x200; /* set drive to not accessible */ + pddt->ddt_descflags |= DF_NOACCESS; /* set drive to not accessible and changed */ + if (diskchange(pddt) != M_NOT_CHANGED) + pddt->ddt_descflags |= DF_DISKCHANGE; if (ret != 0) return (dskerr(ret)); @@ -466,30 +512,41 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) return S_DONE; } - pddt->ddt_descflags &= ~0x200; /* set drive to accessible */ + pddt->ddt_descflags &= ~DF_NOACCESS; /* set drive to accessible */ -/*TE ~ 200 bytes*/ +/*TE ~ 200 bytes*/ - getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); - getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); - getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); - getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); - getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); - - - -/* Needs fat32 offset code */ + 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) { + TE: I'm not sure, what the _real_ decision point is, however MSDN + 'A_BF_BPB_SectorsPerFAT + The number of sectors per FAT. + Note: This member will always be zero in a FAT32 BPB. + Use the values from A_BF_BPB_BigSectorsPerFat... + */ + 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 { + /* 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); + 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); +#endif @@ -503,9 +560,7 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) printf("BPB_MDESC = %02x\n", pbpbarray->bpb_mdesc); printf("BPB_NFSECT = %04x\n", pbpbarray->bpb_nfsect); #endif - rp->r_bpptr = pbpbarray; - count = pbpbarray->bpb_nsize == 0 ? pbpbarray->bpb_huge : @@ -518,7 +573,7 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) tmark(); return failure(E_FAILURE); } - pddt->ddt_ncyl = count / (head * sector); + pddt->ddt_ncyl = (count + head * sector - 1) / (head * sector); tmark(); #ifdef DSK_DEBUG @@ -527,6 +582,19 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) printf("BPB_HIDDEN = %08lx\n", pbpbarray->bpb_hidden); printf("BPB_HUGE = %08lx\n", pbpbarray->bpb_huge); #endif + + return 0; +} + + +STATIC WORD bldbpb(rqptr rp, ddt *pddt) +{ + WORD result; + + if ((result = getbpb(pddt)) != 0) + return result; + + rp->r_bpptr = &pddt->ddt_bpb; return S_DONE; } @@ -553,14 +621,22 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt) { int ret; bpb FAR *pbpb; +#ifdef WITHFAT32 + int extended = 0; - switch(rp->r_count){ - case 0x0860: /* get device parameters */ + 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){ + case 0x60: /* get device parameters */ { struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; REG COUNT x = 5,y = 1,z = 0; - if (!hd(pddt->ddt_driveno)){ + if (!hd(pddt->ddt_descflags)){ y = 2; x = 8; /* any odd ball drives return this */ switch(pddt->ddt_bpb.bpb_nsize) @@ -590,57 +666,57 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt) gblp->gbio_ncyl = pddt->ddt_ncyl; /* use default dpb or current bpb? */ pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; +#ifdef WITHFAT32 + if (!extended) fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF); + else +#endif fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); - gblp->gbio_spcfunbit |= 0x04; /* bit 2 set if all sectors in track same size (should be set) */ gblp->gbio_nsecs = pbpb->bpb_nsector; break; } - case 0x0866: /* get volume serial number */ + case 0x66: /* get volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer[0x27]; - ret = RWzero( rp, 0); + ret = getbpb(pddt); if (ret != 0) - return (dskerr(ret)); + return (ret); - gioc->ioc_serialno = fs->serialno; - pddt->ddt_serialno = fs->serialno; - - fmemcpy(pddt->ddt_volume, fs->volume,11); - fmemcpy(pddt->ddt_volume, fs->fstype,8); + gioc->ioc_serialno = pddt->ddt_serialno; fmemcpy(gioc->ioc_volume, pddt->ddt_volume,11); fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype,8); } break; - case 0x0846: /* set volume serial number */ + case 0x46: /* set volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer[0x27]; - - ret = RWzero( rp, 0); + struct FS_info FAR * fs; + + ret = getbpb(pddt); if (ret != 0) - return (dskerr(ret)); + return (ret); + fs = (struct FS_info FAR *) &DiskTransferBuffer + [(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x27 : 0x43)]; fs->serialno = gioc->ioc_serialno; pddt->ddt_serialno = fs->serialno; - ret = RWzero( rp, 1); + ret = RWzero(pddt, LBA_WRITE); if (ret != 0) return (dskerr(ret)); } break; - case 0x0867: /* get access flag */ + case 0x67: /* get access flag */ { struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - ai->AI_Flag = pddt->ddt_descflags & 0x200 ? 0 : 1; /* bit 9 */ + ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ } break; - case 0x0847: /* set access flag */ + case 0x47: /* set access flag */ { struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - pddt->ddt_descflags &= ~0x200; - pddt->ddt_descflags |= (ai->AI_Flag ? 0 : 0x200); + pddt->ddt_descflags &= ~DF_NOACCESS; + pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS); } break; default: @@ -671,7 +747,7 @@ WORD blockio(rqptr rp, ddt *pddt) tmark(); start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); - pbpb = hd(pddt->ddt_driveno) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); if (start >= size || @@ -822,6 +898,9 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, int num_retries; + /* optionally change from A: to B: or back */ + play_dj(pddt); + *transferred = 0; /* @@ -908,7 +987,7 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, error_code = (mode == LBA_READ ? fl_read : fl_write)( pddt->ddt_driveno, - chs.Head, chs.Cylinder, chs.Sector, + chs.Head, (UWORD)chs.Cylinder, chs.Sector, count, transfer_address); if (error_code == 0 && @@ -916,7 +995,7 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, { error_code = fl_verify( pddt->ddt_driveno, - chs.Head, chs.Cylinder, chs.Sector, + chs.Head, (UWORD)chs.Cylinder, chs.Sector, count, transfer_address); } } diff --git a/kernel/dyndata.c b/kernel/dyndata.c index 20aaad9..6388896 100644 --- a/kernel/dyndata.c +++ b/kernel/dyndata.c @@ -10,4 +10,4 @@ #include "init-mod.h" #include "dyndata.h" -struct DynS Dyn; +struct DynS Dyn = {0}; diff --git a/kernel/dyndata.h b/kernel/dyndata.h index fb61dc3..fa30616 100644 --- a/kernel/dyndata.h +++ b/kernel/dyndata.h @@ -15,5 +15,5 @@ void DynFree(void *ptr); struct DynS { unsigned Allocated; - char Buffer[0]; + char Buffer[1]; }; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 2d90efa..a6bb222 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -39,7 +39,7 @@ additionally: */ #include "portab.h" #include "init-mod.h" -#include "dyndata.h" +#include "dyndata.h" #if defined(DEBUG) #define DebugPrintf(x) printf x @@ -48,7 +48,16 @@ additionally: #endif -extern struct DynS FAR Dyn; +/*extern struct DynS FAR Dyn;*/ + +#ifndef __TURBOC__ + #include "init-dat.h" + extern struct DynS DOSFAR Dyn; +#else + extern struct DynS FAR Dyn; +#endif + + void far *DynAlloc(char *what, unsigned num, unsigned size) { @@ -57,7 +66,7 @@ void far *DynAlloc(char *what, unsigned num, unsigned size) #ifndef DEBUG UNREFERENCED_PARAMETER(what); #endif - + if ((ULONG)total + Dyn.Allocated > 0xffff) { printf("PANIC:Dyn %lu\n", (ULONG)total + Dyn.Allocated); diff --git a/kernel/entry.asm b/kernel/entry.asm index 27d5904..30a8914 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.14 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.13 2001/04/21 22:32:53 bartoldeman ; Init DS=Init CS, fixed stack overflow problems and misc bugs. ; @@ -111,10 +114,6 @@ segment HMA_TEXT extern _MachineId:wrt DGROUP extern critical_sp:wrt DGROUP - extern _api_sp:wrt DGROUP ; api stacks - for context - extern _api_ss:wrt DGROUP ; switching - extern _usr_sp:wrt DGROUP ; user stacks - extern _usr_ss:wrt DGROUP extern int21regs_seg:wrt DGROUP extern int21regs_off:wrt DGROUP @@ -487,33 +486,28 @@ int2526: mov bx, DGROUP mov ds, bx - ; save away foreground process' stack - push word [_usr_ss] - push word [_usr_sp] - - mov word [_usr_ss],ss - mov word [_usr_sp],sp - ; setup our local stack cli mov ss,bx mov sp,_disk_api_tos sti + push dx + push cx ; save user stack + push dx ; SS:SP -> user stack push cx push ax ; was set on entry = 25,26 call _int2526_handler - add sp, byte 4 + add sp, byte 6 + pop cx + pop dx ; restore user stack ; restore foreground stack here cli - mov ss,word [_usr_ss] - mov sp,word [_usr_sp] - - pop word [_usr_sp] - pop word [_usr_ss] + mov ss, dx + mov sp, cx pop es pop ds @@ -593,10 +587,6 @@ CritErr05: push word [_MachineId] push word [int21regs_seg] push word [int21regs_off] - push word [_api_sp] - push word [_api_ss] - push word [_usr_sp] - push word [_usr_ss] push word [_user_r+2] push word [_user_r] mov [critical_sp],sp @@ -626,10 +616,6 @@ CritErr05: mov sp,[critical_sp] pop word [_user_r] pop word [_user_r+2] - pop word [_usr_ss] - pop word [_usr_sp] - pop word [_api_ss] - pop word [_api_sp] pop word [int21regs_off] pop word [int21regs_seg] pop word [_MachineId] diff --git a/kernel/fatdir.c b/kernel/fatdir.c index c3fe2d9..50b3c30 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.23 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.22 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -280,6 +283,18 @@ f_node_ptr dir_open(BYTE * dirname) /* Set the root flags since we always start from the root */ fnp->f_flags.f_droot = TRUE; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb)) { + fnp->f_flags.f_droot = FALSE; + fnp->f_flags.f_ddir = TRUE; + fnp->f_offset = 0l; + fnp->f_cluster_offset = 0l; + fnp->f_highwater = 0l; + fnp->f_cluster = fnp->f_dpb->dpb_xrootclst; + fnp->f_dirstart = fnp->f_dpb->dpb_xrootclst; + } +#endif + for (p = pszPath; *p != '\0';) { /* skip all path seperators */ @@ -349,8 +364,8 @@ f_node_ptr dir_open(BYTE * dirname) fnp->f_offset = 0l; fnp->f_cluster_offset = 0l; /*JPP */ fnp->f_highwater = 0l; - fnp->f_cluster = fnp->f_dir.dir_start; - fnp->f_dirstart = fnp->f_dir.dir_start; + fnp->f_cluster = getdstart(fnp->f_dir); + fnp->f_dirstart = fnp->f_cluster; /* reset the directory flags */ fnp->f_diroff = 0l; fnp->f_flags.f_dmod = FALSE; @@ -474,7 +489,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* Update the fnode's directory info */ fnp->f_flags.f_dfull = FALSE; fnp->f_flags.f_dmod = FALSE; - + /* and for efficiency, stop when we hit the first */ /* unused entry. */ if (fnp->f_dir.dir_name[0] == '\0') @@ -564,6 +579,9 @@ COUNT dir_write(REG f_node_ptr fnp) release_f_node(fnp); return 0; } + + 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]); @@ -690,8 +708,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* Test the attribute and return first found */ if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { - dmp->dm_dirstart= fnp->f_dirstart; - dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ + dmp->dm_dircluster = fnp->f_dirstart; /* TE */ memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); dir_close(fnp); return SUCCESS; @@ -708,15 +725,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) { dmp->dm_entry = 0; if (!fnp->f_flags.f_droot) - { - dmp->dm_cluster = fnp->f_dirstart; - dmp->dm_dirstart = fnp->f_dirstart; - } + dmp->dm_dircluster = fnp->f_dirstart; else - { - dmp->dm_cluster = 0; - dmp->dm_dirstart = 0; - } + dmp->dm_dircluster = 0; dir_close(fnp); return dos_findnext(); } @@ -772,11 +783,14 @@ COUNT dos_findnext(void) } fnp->f_offset = fnp->f_diroff; - - fnp->f_dirstart = - fnp->f_dir.dir_start = - fnp->f_cluster = - dmp->dm_dirstart; + + fnp->f_dir.dir_start = dmp->dm_dircluster; +#ifdef WITHFAT32 + fnp->f_dir.dir_start_high = dmp->dm_dircluster >> 16; +#endif + + fnp->f_cluster = fnp->f_dirstart = + dmp->dm_dircluster; fnp->f_flags.f_droot = fnp->f_dirstart == 0; fnp->f_flags.f_ddir = TRUE; @@ -790,7 +804,8 @@ COUNT dos_findnext(void) while (dir_read(fnp) == DIRENT_SIZE) { ++dmp->dm_entry; - 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 + && (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)) { @@ -817,8 +832,7 @@ COUNT dos_findnext(void) /* If found, transfer it to the dmatch structure */ if (found) { - dmp->dm_dirstart= fnp->f_dirstart; - dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ + dmp->dm_dircluster = fnp->f_dirstart; memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); } @@ -891,5 +905,4 @@ int FileName83Length(BYTE *filename83) ConvertName83ToNameSZ(buff, filename83); return strlen(buff); - } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 66ab745..28b2623 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.24 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.23 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -267,7 +270,7 @@ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); date dos_getdate(VOID); time dos_gettime(VOID); BOOL find_free(f_node_ptr); -UWORD find_fat_free(f_node_ptr); +CLUSTER find_fat_free(f_node_ptr); VOID wipe_out(f_node_ptr); BOOL last_link(f_node_ptr); BOOL extend(f_node_ptr); @@ -318,9 +321,6 @@ COUNT dos_open(BYTE * path, COUNT flag) fnp->f_highwater = fnp->f_dir.dir_size; fnp->f_back = LONG_LAST_CLUSTER; -/* /// Moved to below. - Ron Cemer - fnp->f_cluster = fnp->f_dir.dir_start; - fnp->f_cluster_offset = 0l; */ /*JPP */ fnp->f_flags.f_dmod = FALSE; fnp->f_flags.f_dnew = FALSE; @@ -329,7 +329,7 @@ COUNT dos_open(BYTE * path, COUNT flag) merge_file_changes(fnp, TRUE); /* /// Added - Ron Cemer */ /* /// Moved from above. - Ron Cemer */ - fnp->f_cluster = fnp->f_dir.dir_start; + fnp->f_cluster = getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; /*JPP */ return xlt_fnp(fnp); @@ -488,6 +488,55 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) return found; } +/* STATIC BOOL find_full_fname(f_node_ptr fnp, f_node_ptr lfnp, BYTE * fname, + BYTE * fext) +{ + BOOL found = FALSE; + + lfnp->f_cluster = LONG_LAST_CLUSTER; + while (dir_read(fnp) == DIRENT_SIZE) + { + if (fnp->f_dir.dir_name[0] != '\0') + { + if (fnp->f_dir.dir_name[0] == DELETED) + continue; + + if (fnp->f_dir.dir_attrib != 0xf) lfnp->f_cluster = LONG_LAST_CLUSTER; + else if (lfnp->f_cluster == LONG_LAST_CLUSTER) + memcpy(lfnp, struct fnp, sizeof(f_node)); + + 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; + break; + } + } + } + return found; +} */ + +/* input: fnp with valid non-LFN directory entry, not equal to '..' or +'.' */ +void remove_lfn_entries(f_node_ptr fnp) +{ + ULONG original_diroff = fnp->f_diroff; + while (TRUE) { + if(fnp->f_diroff == 0) break; + fnp->f_diroff -= 2*DIRENT_SIZE; + /* it cannot / should not get below 0 because of '.' and '..' + but maybe add another check for robustness */ + dir_read(fnp); + if (fnp->f_dir.dir_attrib != D_LFN) + break; + fnp->f_dir.dir_name[0] = DELETED; + fnp->f_flags.f_dmod = TRUE; + dir_write(fnp); + } + fnp->f_diroff = original_diroff - DIRENT_SIZE; + dir_read(fnp); +} /* /// 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 @@ -551,6 +600,9 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) { 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 + dst->f_dir.dir_start_high = src->f_dir.dir_start_high; +#endif dst->f_dir.dir_size = src->f_dir.dir_size; dst->f_dir.dir_date = src->f_dir.dir_date; dst->f_dir.dir_time = src->f_dir.dir_time; @@ -631,7 +683,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_mode = RDWR; fnp->f_dir.dir_size = 0l; - fnp->f_dir.dir_start = FREE; + setdstart(fnp->f_dir, FREE); fnp->f_dir.dir_attrib = attrib | D_ARCHIVE; fnp->f_dir.dir_time = dos_gettime(); fnp->f_dir.dir_date = dos_getdate(); @@ -651,7 +703,8 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_highwater = 0l; fnp->f_back = LONG_LAST_CLUSTER; - fnp->f_cluster = fnp->f_dir.dir_start = FREE; + fnp->f_cluster = FREE; + setdstart(fnp->f_dir, FREE); fnp->f_cluster_offset = 0l; /*JPP */ fnp->f_flags.f_dmod = TRUE; fnp->f_flags.f_ddate = FALSE; @@ -691,6 +744,7 @@ COUNT dos_delete(BYTE * path) /* Ok, so we can delete. Start out by */ /* clobbering all FAT entries for this file */ /* (or, in English, truncate the FAT). */ + remove_lfn_entries(fnp); wipe_out(fnp); fnp->f_dir.dir_size = 0l; *(fnp->f_dir.dir_name) = DELETED; @@ -745,11 +799,11 @@ COUNT dos_rmdir(BYTE * path) has many 'archive' directories 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)) +/* if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE|D_SYSTEM)) { dir_close(fnp); return DE_ACCESS; - } + } */ /* Check that the directory is empty. Only the */ /* "." and ".." are permissable. */ @@ -776,7 +830,7 @@ COUNT dos_rmdir(BYTE * path) { if (fnp1->f_dir.dir_name[0] == '\0') break; - if (fnp1->f_dir.dir_name[0] == DELETED) + if (fnp1->f_dir.dir_name[0] == DELETED || fnp1->f_dir.dir_attrib == D_LFN) continue; else { @@ -796,6 +850,7 @@ COUNT dos_rmdir(BYTE * path) /* Ok, so we can delete. Start out by */ /* clobbering all FAT entries for this file */ /* (or, in English, truncate the FAT). */ + remove_lfn_entries(fnp); wipe_out(fnp); fnp->f_dir.dir_size = 0l; *(fnp->f_dir.dir_name) = DELETED; @@ -880,6 +935,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) return ret; } } + remove_lfn_entries(fnp1); /* put the fnode's name into the directory. */ bcopy(szFileName, (BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE); @@ -888,6 +944,9 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* Set the fnode to the desired mode */ fnp2->f_dir.dir_size = fnp1->f_dir.dir_size; fnp2->f_dir.dir_start = fnp1->f_dir.dir_start; +#ifdef WITHFAT32 + fnp2->f_dir.dir_start_high = fnp1->f_dir.dir_start_high; +#endif fnp2->f_dir.dir_attrib = fnp1->f_dir.dir_attrib; fnp2->f_dir.dir_time = fnp1->f_dir.dir_time; fnp2->f_dir.dir_date = fnp1->f_dir.dir_date; @@ -916,22 +975,18 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* */ STATIC VOID wipe_out(f_node_ptr fnp) { - REG UWORD st, + REG CLUSTER st, next; struct dpb FAR *dpbp = fnp->f_dpb; - + /* if already free or not valid file, just exit */ - if ((fnp == NULL) || (fnp->f_dir.dir_start == FREE)) - return; - - /* if there are no FAT entries, just exit */ - if (fnp->f_dir.dir_start == FREE) + if ((fnp == NULL) || checkdstart(fnp->f_dir, FREE)) return; /* Loop from start until either a FREE entry is */ /* encountered (due to a fractured file system) of the */ /* last cluster is encountered. */ - for (st = fnp->f_dir.dir_start; + for (st = getdstart(fnp->f_dir); st != LONG_LAST_CLUSTER;) { /* get the next cluster pointed to */ @@ -952,6 +1007,9 @@ STATIC VOID wipe_out(f_node_ptr fnp) /* and just follow the linked list */ st = next; } +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif } STATIC BOOL find_free(f_node_ptr fnp) @@ -1139,9 +1197,9 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* */ /* Find free cluster in disk FAT table */ /* */ -STATIC UWORD find_fat_free(f_node_ptr fnp) +STATIC CLUSTER find_fat_free(f_node_ptr fnp) { - REG UWORD idx; + REG CLUSTER idx; #ifdef DISPLAY_GETBLOCK printf("[find_fat_free]\n"); @@ -1152,6 +1210,7 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) else idx = 2; + /* Search the FAT table looking for the first free */ /* entry. */ for (; idx <= fnp->f_dpb->dpb_size; idx++) @@ -1164,6 +1223,9 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) if (idx > fnp->f_dpb->dpb_size) { fnp->f_dpb->dpb_cluster = UNKNCLUSTER; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb)) write_fsinfo(fnp->f_dpb); +#endif dir_close(fnp); return LONG_LAST_CLUSTER; } @@ -1173,6 +1235,9 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) /* return the free entry */ fnp->f_dpb->dpb_cluster = idx; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb)) write_fsinfo(fnp->f_dpb); +#endif return idx; } @@ -1185,8 +1250,7 @@ COUNT dos_mkdir(BYTE * dir) REG f_node_ptr fnp; REG COUNT idx; struct buffer FAR *bp; - UWORD free_fat; - UWORD parent; + CLUSTER free_fat, parent; COUNT ret; /* first split the passed dir into comopnents (i.e. - */ @@ -1274,7 +1338,6 @@ COUNT dos_mkdir(BYTE * dir) fnp->f_back = LONG_LAST_CLUSTER; fnp->f_dir.dir_size = 0l; - fnp->f_dir.dir_start = FREE; fnp->f_dir.dir_attrib = D_DIR; fnp->f_dir.dir_time = dos_gettime(); fnp->f_dir.dir_date = dos_getdate(); @@ -1288,8 +1351,9 @@ COUNT dos_mkdir(BYTE * dir) /* Mark the cluster in the FAT as used */ - fnp->f_dir.dir_start = fnp->f_cluster = free_fat; - link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + fnp->f_cluster = free_fat; + setdstart(fnp->f_dir, free_fat); + link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Craft the new directory. Note that if we're in a new */ /* directory just under the root, ".." pointer is 0. */ @@ -1313,7 +1377,7 @@ COUNT dos_mkdir(BYTE * dir) DirEntBuffer.dir_attrib = D_DIR; DirEntBuffer.dir_time = dos_gettime(); DirEntBuffer.dir_date = dos_getdate(); - DirEntBuffer.dir_start = free_fat; + setdstart(DirEntBuffer, free_fat); DirEntBuffer.dir_size = 0l; /* And put it out */ @@ -1321,7 +1385,12 @@ COUNT dos_mkdir(BYTE * dir) /* create the ".." entry */ bcopy(".. ", (BYTE *) DirEntBuffer.dir_name, FNAME_SIZE); - DirEntBuffer.dir_start = parent; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb) && parent == fnp->f_dpb->dpb_xrootclst) { + parent = 0; + } +#endif + setdstart(DirEntBuffer, parent); /* and put it out */ putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]); @@ -1337,7 +1406,7 @@ COUNT dos_mkdir(BYTE * dir) { /* as we are overwriting it completely, don't read first */ - bp = getblockOver((ULONG) clus2phys(fnp->f_dir.dir_start, + bp = getblockOver((ULONG) clus2phys(getdstart(fnp->f_dir), (fnp->f_dpb->dpb_clsmask + 1), fnp->f_dpb->dpb_data) + idx, fnp->f_dpb->dpb_unit); @@ -1366,12 +1435,12 @@ COUNT dos_mkdir(BYTE * dir) BOOL last_link(f_node_ptr fnp) { - return (((UWORD) fnp->f_cluster == (UWORD) LONG_LAST_CLUSTER)); + return (fnp->f_cluster == LONG_LAST_CLUSTER); } STATIC BOOL extend(f_node_ptr fnp) { - UWORD free_fat; + CLUSTER free_fat; #ifdef DISPLAY_GETBLOCK printf("extend\n"); @@ -1386,9 +1455,9 @@ STATIC BOOL extend(f_node_ptr fnp) /* Now that we've found a free FAT entry, mark it as the last */ /* entry and save. */ - link_fat(fnp->f_dpb, (UCOUNT) fnp->f_back, free_fat); + link_fat(fnp->f_dpb, fnp->f_back, free_fat); fnp->f_cluster = free_fat; - link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; @@ -1445,7 +1514,7 @@ STATIC COUNT extend_dir(f_node_ptr fnp) /* JPP: finds the next free cluster in the FAT */ STATIC BOOL first_fat(f_node_ptr fnp) { - UWORD free_fat; + CLUSTER free_fat; /* get an empty cluster, so that we make it into a file. */ free_fat = find_fat_free(fnp); @@ -1459,9 +1528,9 @@ STATIC BOOL first_fat(f_node_ptr fnp) /* entry and save it. */ /* BUG!! this caused wrong allocation, if file was created, then seeked, then written */ - fnp->f_cluster = - fnp->f_dir.dir_start = free_fat; - link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + fnp->f_cluster = free_fat; + setdstart(fnp->f_dir, free_fat); + link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; @@ -1485,12 +1554,13 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_cluster_offset, fnp->f_offset, fnp->f_offset - fnp->f_cluster_offset); #endif + /* The variable clssize will be used later. */ clssize = (ULONG)fnp->f_dpb->dpb_secsize * (fnp->f_dpb->dpb_clsmask + 1); /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ - if ((mode == XFR_WRITE) && (fnp->f_dir.dir_start == FREE)) + if ((mode == XFR_WRITE) && checkdstart(fnp->f_dir, FREE)) { /* If there are no more free fat entries, then we are full! */ if (!first_fat(fnp)) @@ -1508,7 +1578,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) idx = fnp->f_offset; fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - fnp->f_dir.dir_start; + getdstart(fnp->f_dir); fnp->f_cluster_offset = 0; } @@ -1532,7 +1602,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) /* the last cluster marker. */ else if ((mode == XFR_WRITE) && last_link(fnp)) { - if (!extend(fnp)) { dir_close(fnp); @@ -1545,6 +1614,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); fnp->f_cluster_offset += clssize; } + #ifdef DISPLAY_GETBLOCK printf("done.\n"); #endif @@ -1627,7 +1697,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* initializing to the starting cluster and */ /* setting all offsets to zero. */ fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - fnp->f_dir.dir_start; + getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; fnp->f_back = LONG_LAST_CLUSTER; @@ -1679,7 +1749,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_boff = fnp->f_offset & (secsize - 1); #ifdef DSK_DEBUG - printf("read %d links; dir offset %ld, cluster %d\n", + printf("read %d links; dir offset %ld, cluster %lx\n", fnp->f_count, fnp->f_diroff, fnp->f_cluster); @@ -1853,7 +1923,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* will have a start cluster of FREE. If we're */ /* doing a write and this is the first time */ /* through, allocate a new cluster to the file. */ - if (fnp->f_dir.dir_start == FREE) + if (checkdstart(fnp->f_dir, FREE)) if (!first_fat(fnp)) /* get a free cluster */ { /* error means disk full */ dir_close(fnp); @@ -1864,7 +1934,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* initializing to the starting cluster and */ /* setting all offsets to zero. */ fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - fnp->f_dir.dir_start; + getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; fnp->f_back = LONG_LAST_CLUSTER; @@ -2105,12 +2175,12 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) } /* returns the number of unused clusters */ -UWORD 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 */ - REG UWORD i; - REG UWORD cnt = 0; + REG CLUSTER i; + REG CLUSTER cnt = 0; /* UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * * (ULONG) (dpbp->dpb_clsmask + 1) - (dpbp->dpb_data + 1) ) * / (dpbp->dpb_clsmask + 1) ) + 2; @@ -2119,7 +2189,7 @@ UWORD dos_free(struct dpb FAR *dpbp) /*?? UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) / (dpbp->dpb_clsmask + 1) ) + 1; */ - UWORD max_cluster = dpbp->dpb_size + 1; + CLUSTER max_cluster = dpbp->dpb_size + 1; if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) return dpbp->dpb_nfreeclst; @@ -2131,6 +2201,9 @@ UWORD dos_free(struct dpb FAR *dpbp) ++cnt; } dpbp->dpb_nfreeclst = cnt; +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif return cnt; } } @@ -2262,46 +2335,82 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) } #endif +#ifdef WITHFAT32 +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) +#endif { ULONG size; REG COUNT i; - dpbp->dpb_mdb = bpbp->bpb_mdesc; - dpbp->dpb_secsize = bpbp->bpb_nbyte; - dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; - 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; -/* patch point - dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); -*/ - 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 * dpbp->dpb_dirents - + (dpbp->dpb_secsize - 1)) - / dpbp->dpb_secsize); -/* - Michal Meller patch to jimtabor -*/ - dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_mdb = bpbp->bpb_mdesc; + dpbp->dpb_secsize = bpbp->bpb_nbyte; + dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; + 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; + dpbp->dpb_wfatsize = bpbp->bpb_nfsect; + dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + + dpbp->dpb_fats * dpbp->dpb_wfatsize; + dpbp->dpb_wdata = dpbp->dpb_dirstrt + + ((DIRENT_SIZE * dpbp->dpb_dirents + + (dpbp->dpb_secsize - 1)) + / dpbp->dpb_secsize); +/* Michal Meller patch to jimtabor */ + dpbp->dpb_wsize = ((size - dpbp->dpb_wdata) + / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_flags = 0; + dpbp->dpb_wcluster = UNKNCLUSTER; + /* number of free clusters */ + *((UWORD FAR *)(&dpbp->dpb_nfreeclst)) = UNKNCLSTFREE16; - dpbp->dpb_flags = 0; -/* dpbp->dpb_next = (struct dpb FAR *)-1;*/ - dpbp->dpb_cluster = UNKNCLUSTER; - dpbp->dpb_nfreeclst = UNKNCLSTFREE; /* number of free clusters */ - for (i = 1, dpbp->dpb_shftcnt = 0; - i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ - dpbp->dpb_shftcnt++, i <<= 1) - { - if (i >= bpbp->bpb_nsector) - break; - } +#ifdef WITHFAT32 + if (extended) + { + dpbp->dpb_fatsize = bpbp->bpb_nfsect == 0 ? bpbp->bpb_xnfsect + : bpbp->bpb_nfsect; + dpbp->dpb_cluster = UNKNCLUSTER; + dpbp->dpb_nfreeclst = UNKNCLSTFREE; /* number of free clusters */ + + dpbp->dpb_xflags = 0; + dpbp->dpb_xfsinfosec = 0xffff; + dpbp->dpb_xbackupsec = 0xffff; + dpbp->dpb_xrootclst = 0; + dpbp->dpb_size = ((size - (dpbp->dpb_fatstrt + dpbp->dpb_fats + * dpbp->dpb_fatsize)) + / ((ULONG) bpbp->bpb_nsector) + 1); + + if (ISFAT32(dpbp)) + { + dpbp->dpb_xflags = bpbp->bpb_xflags; + dpbp->dpb_xfsinfosec = bpbp->bpb_xfsinfosec; + dpbp->dpb_xbackupsec = bpbp->bpb_xbackupsec; + dpbp->dpb_dirents = 0; + dpbp->dpb_dirstrt = 0xffff; + dpbp->dpb_wsize = 0; + dpbp->dpb_data = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_xrootclst = bpbp->bpb_xrootclst; + read_fsinfo(dpbp); + } + else + { + dpbp->dpb_data = dpbp->dpb_wdata; + dpbp->dpb_size = dpbp->dpb_wsize; + } + } +#endif + + for (i = 1, dpbp->dpb_shftcnt = 0; + i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ + dpbp->dpb_shftcnt++, i <<= 1) + { + if (i >= bpbp->bpb_nsector) + break; + } } COUNT media_check(REG struct dpb FAR * dpbp) @@ -2384,7 +2493,11 @@ COUNT media_check(REG struct dpb FAR * dpbp) } } } +#ifdef WITHFAT32 + bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, TRUE); +#else bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); +#endif return SUCCESS; } } @@ -2435,10 +2548,10 @@ STATIC VOID shrink_file(f_node_ptr fnp) #else ULONG lastoffset = fnp->f_offset; /* has to be saved */ - UCOUNT next,st; + CLUSTER next,st; struct dpb FAR *dpbp = fnp->f_dpb; - if (fnp->f_flags.f_ddir) /* can't shrink dirs */ + if (fnp->f_flags.f_ddir || (fnp->f_dir.dir_attrib & D_DIR)) /* can't shrink dirs */ return; fnp->f_offset = fnp->f_highwater; /* end of file */ @@ -2446,17 +2559,17 @@ STATIC VOID shrink_file(f_node_ptr fnp) if (fnp->f_offset) fnp->f_offset--; /* last existing cluster */ if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */ - goto done; - - - st = fnp->f_cluster; + goto done; - if (st == FREE || st == LONG_LAST_CLUSTER) /* first cluster is free or EOC, done */ + st = fnp->f_cluster; + + /* first cluster is free or EOC */ + if (st == FREE || st == LONG_LAST_CLUSTER) goto done; next = next_cluster(dpbp, st); - if ( next == LONG_LAST_CLUSTER) /* last cluster found */ + if (next == LONG_LAST_CLUSTER) /* last cluster found */ goto done; /* Loop from start until either a FREE entry is */ @@ -2467,7 +2580,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) if (fnp->f_highwater == 0) { - fnp->f_dir.dir_start = FREE; + setdstart(fnp->f_dir, FREE); link_fat(dpbp, st, FREE); } else @@ -2491,12 +2604,14 @@ STATIC VOID shrink_file(f_node_ptr fnp) if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st)) dpbp->dpb_cluster = st; - } done: fnp->f_offset = lastoffset; /* has to be restored */ - +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif + #endif } diff --git a/kernel/fattab.c b/kernel/fattab.c index 095fc20..1943259 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.7 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -111,15 +114,19 @@ static BYTE *RcsId = "$Id$"; */ #ifdef PROTO -UCOUNT link_fat12(struct dpb FAR *, UCOUNT, UCOUNT); -UCOUNT link_fat16(struct dpb FAR *, UCOUNT, UCOUNT); -UWORD next_cl12(struct dpb FAR *, UCOUNT); -UWORD next_cl16(struct dpb FAR *, UCOUNT); +UCOUNT link_fat12(struct dpb FAR *, CLUSTER, CLUSTER); +UCOUNT link_fat16(struct dpb FAR *, CLUSTER, CLUSTER); +UCOUNT link_fat32(struct dpb FAR *, CLUSTER, CLUSTER); +CLUSTER next_cl12(struct dpb FAR *, CLUSTER); +CLUSTER next_cl16(struct dpb FAR *, CLUSTER); +CLUSTER next_cl32(struct dpb FAR *, CLUSTER); #else UCOUNT link_fat12(); UCOUNT link_fat16(); -UWORD next_cl12(); -UWORD next_cl16(); +UCOUNT link_fat32(); +CLUSTER next_cl12(); +CLUSTER next_cl16(); +CLUSTER next_cl32(); #endif /************************************************************************/ @@ -128,33 +135,87 @@ UWORD next_cl16(); /* */ /************************************************************************/ -struct buffer FAR *getFATblock(UWORD cluster, struct dpb FAR *dpbp) +#ifndef ISFAT32 +int ISFAT32(struct dpb FAR *dpbp) +{ + return _ISFAT32(dpbp); +} +#endif + + +struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp) { ULONG sector; struct buffer FAR *bp; - + if (ISFAT12(dpbp)) { sector = ((cluster << 1) + cluster) >> 1; - } - else /* FAT16 */ + } +#ifdef WITHFAT32 + else if (ISFAT32(dpbp)) + { + sector = (ULONG)cluster * SIZEOF_CLST32; + } +#endif + else { sector = (ULONG)cluster * SIZEOF_CLST16; } sector = sector / dpbp->dpb_secsize + dpbp->dpb_fatstrt; +#ifdef WITHFAT32 + 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_fatsize; + } +#endif bp = getblock(sector, dpbp->dpb_unit); if (bp) { - bp->b_flag &= ~(BFR_DATA | BFR_DIR); - bp->b_flag |= BFR_FAT | BFR_VALID; - bp->b_copies = dpbp->dpb_fats; - bp->b_offset_lo = dpbp->dpb_fatsize; - bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT | BFR_VALID; + bp->b_copies = dpbp->dpb_fats; +#ifdef WITHFAT32 + if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) bp->b_copies = 1; +#endif + bp->b_offset = dpbp->dpb_fatsize; } return bp; } + +#ifdef WITHFAT32 +void read_fsinfo(struct dpb FAR *dpbp) +{ + struct buffer FAR *bp; + struct fsinfo FAR *fip; + + bp = getblock(dpbp->dpb_xfsinfosec, dpbp->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT | BFR_DIRTY); + bp->b_flag |= BFR_VALID; + + fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4]; + dpbp->dpb_nfreeclst = fip->fi_nfreeclst; + dpbp->dpb_cluster = fip->fi_cluster; +} + +void write_fsinfo(struct dpb FAR *dpbp) +{ + struct buffer FAR *bp; + struct fsinfo FAR *fip; + + bp = getblock(dpbp->dpb_xfsinfosec, dpbp->dpb_unit); + 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->fi_nfreeclst = dpbp->dpb_nfreeclst; + fip->fi_cluster = dpbp->dpb_cluster; +} +#endif + /* */ /* The FAT file system is difficult to trace through FAT table. */ /* There are two kinds of FAT's, 12 bit and 16 bit. The 16 bit */ @@ -171,7 +232,7 @@ struct buffer FAR *getFATblock(UWORD cluster, struct dpb FAR *dpbp) /* 12 bytes are compressed to 9 bytes */ /* */ -UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) +UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) { UCOUNT res; @@ -179,41 +240,76 @@ UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) res = link_fat12(dpbp, Cluster1, Cluster2); else if (ISFAT16(dpbp)) res = link_fat16(dpbp, Cluster1, Cluster2); +#ifdef WITHFAT32 + else if (ISFAT32(dpbp)) + res = link_fat32(dpbp, Cluster1, Cluster2); +#endif else return DE_BLKINVLD; - /* update the free space count */ + /* update the free space count */ if (res == SUCCESS) if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) { if (Cluster2 == FREE) - { - /* update the free space count for returned */ - /* cluster */ - ++dpbp->dpb_nfreeclst; - } + { + /* update the free space count for returned */ + /* cluster */ + ++dpbp->dpb_nfreeclst; + } - /* update the free space count for removed */ + /* update the free space count for removed */ /* cluster */ /* BUG: was counted twice for 2nd,.. cluster. moved to find_fat_free() */ - - /* else { - --dpbp->dpb_nfreeclst; - } - */ - } + + /* else + { + --dpbp->dpb_nfreeclst; + } */ + } +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif return res; } -UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +#ifdef WITHFAT32 +UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) { UCOUNT idx; struct buffer FAR *bp; /* 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 = (UWORD)((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize); + + /* Finally, put the word into the buffer and mark the */ + /* buffer as dirty. */ + fputlong((DWORD FAR *) & Cluster2, (VOID FAR *) & (bp->b_buffer[idx])); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + + /* Return successful. */ + + return SUCCESS; +} + +#endif + +UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) +{ + UCOUNT idx; + struct buffer FAR *bp; + + /* Get the block that this cluster is in */ + bp = getFATblock(Cluster1, dpbp); if (bp == NULL) return DE_BLKINVLD; @@ -232,7 +328,7 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) return SUCCESS; } -UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) { REG UBYTE FAR *fbp0, FAR * fbp1; @@ -247,7 +343,7 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((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,19 +381,44 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* Given the disk parameters, and a cluster number, this function looks at the FAT, and returns the next cluster in the clain. */ -UWORD next_cluster(struct dpb FAR *dpbp, UCOUNT ClusterNum) +CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) { - if (ISFAT12(dpbp)) + if (ClusterNum == LONG_LAST_CLUSTER) printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); + if (ISFAT12(dpbp)) return next_cl12(dpbp, ClusterNum); else if (ISFAT16(dpbp)) return next_cl16(dpbp, ClusterNum); +#ifdef WITHFAT32 + else if (ISFAT32(dpbp)) + return next_cl32(dpbp, ClusterNum); +#endif else return LONG_LAST_CLUSTER; } -UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) +#ifdef WITHFAT32 +CLUSTER next_cl32(struct dpb FAR *dpbp, CLUSTER ClusterNum) { struct buffer FAR *bp; + UDWORD res; + + /* Get the block that this cluster is in */ + bp = getFATblock(ClusterNum, dpbp); + + if (bp == NULL) + return DE_BLKINVLD; + + res = *(UDWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST32) % dpbp->dpb_secsize)]); + if (res > LONG_BAD) return LONG_LAST_CLUSTER; + + return res; +} +#endif + +CLUSTER next_cl16(struct dpb FAR *dpbp, CLUSTER ClusterNum) +{ + struct buffer FAR *bp; + UWORD res; /* Get the block that this cluster is in */ bp = getFATblock( ClusterNum, dpbp); @@ -307,7 +428,6 @@ UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) #ifndef I86 UCOUNT idx; - UWORD RetCluster; /* form an index so that we can read the block as a */ /* byte array */ @@ -315,17 +435,17 @@ UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) /* Get the cluster number, */ - fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster); + fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & res); - /* and return successful. */ - return RetCluster; #else /* this saves 2 WORDS of stack :-) */ - return *(UWORD FAR *)&(bp->b_buffer[(ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize]); - + res = *(UWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize)]); #endif - + if ((res & MASK16) == MASK16) return LONG_LAST_CLUSTER; + else if ((res & BAD16) == BAD16) return LONG_BAD; + + return res; } #if 0 @@ -385,7 +505,7 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) /* new version - 50 byte smaller, saves 10 bytes on stack :-) */ -UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) +CLUSTER next_cl12(struct dpb FAR *dpbp, REG CLUSTER ClusterNum) { union { UBYTE bytes[2]; @@ -403,7 +523,7 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; + idx = (UCOUNT)(((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; clusterbuff.bytes[0] = bp->b_buffer[idx]; @@ -440,10 +560,9 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) ClusterNum = clusterbuff.word & 0x0fff; #endif - - if ((ClusterNum & MASK) == MASK) + if ((ClusterNum & MASK12) == MASK12) ClusterNum = LONG_LAST_CLUSTER; - else if ((ClusterNum & BAD) == BAD) + else if ((ClusterNum & BAD12) == BAD12) ClusterNum = LONG_BAD; return ClusterNum; } diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index cdf2b91..5da0c18 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.17 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -177,6 +180,10 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, { struct dpb FAR *dpbp; struct cds FAR *cdsp; +#ifdef WITHFAT32 + UCOUNT shift = 0; + ULONG cluster_size, ntotal; +#endif /* first check for valid drive */ *spc = -1; @@ -211,9 +218,23 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, return; } +#ifdef WITHFAT32 + cluster_size = (dpbp->dpb_clsmask + 1) * dpbp->dpb_secsize; + ntotal = dpbp->dpb_size - 1; + while (cluster_size <= 0x7fff) { + cluster_size <<= 1; + ntotal >>= 1; + shift++; + } + /* get the data available from dpb */ + if (ntotal > 0xfffe) ntotal = 0xfffe; + *nc = (UCOUNT)ntotal; + *spc = (dpbp->dpb_clsmask + 1) << shift; +#else /* get the data vailable from dpb */ *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; +#endif *bps = dpbp->dpb_secsize; /* Point to the media desctriptor for this drive */ @@ -268,12 +289,12 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) if (*(*lpFileName + 1) == ':') { /* non-portable construct to be changed */ - REG UBYTE Drive = DosUpFChar(**lpFileName) - 'A' + 1; + REG UBYTE Drive = DosUpFChar(**lpFileName) - 'A'; if (Drive >= lastdrive) return PARSE_RET_BADDRIVE; - lpFcb->fcb_drive = Drive; + lpFcb->fcb_drive = Drive + 1; *lpFileName += 2; } @@ -744,10 +765,6 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - if ((UCOUNT)FcbDrive >= lastdrive) { - return DE_INVLDDRV; - } - /* check for a device */ if (IsDevice(SecPathName)) { @@ -952,7 +969,7 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) *lpDir++ = FcbDrive; fmemcpy(lpDir, &SearchDir, sizeof(struct dirent)); - lpFcb->fcb_dirclst = Dmatch.dm_dirstart; + lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; /* @@ -993,8 +1010,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_strtclst; - Dmatch.dm_cluster = lpFcb->fcb_dirclst; - Dmatch.dm_dirstart= lpFcb->fcb_dirclst; + Dmatch.dm_dircluster = lpFcb->fcb_dirclst; if ((xfcb FAR *) lpFcb != lpXfcb) { @@ -1015,7 +1031,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) *lpDir++ = FcbDrive; fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent)); - lpFcb->fcb_dirclst = Dmatch.dm_dirstart; + lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; lpFcb->fcb_sftno = Dmatch.dm_drive; diff --git a/kernel/globals.h b/kernel/globals.h index cf33fde..d1db37a 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.16 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -215,6 +218,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #include "network.h" #include "config.h" #include "buffer.h" +#include "xstructs.h" /* JPP: for testing/debuging disk IO */ /*#define DISPLAY_GETBLOCK */ @@ -288,12 +292,17 @@ static BYTE *Globals_hRcsId = "$Id$"; /* FAT cluster special flags */ #define FREE 0x000 +#ifdef WITHFAT32 +#define LONG_LAST_CLUSTER 0x0FFFFFFFl +#define LONG_BAD 0x0FFFFFF7l +#else #define LONG_LAST_CLUSTER 0xFFFF -#define LONG_MASK 0xFFF8 -#define LONG_BAD 0xFFF0 -#define LAST_CLUSTER 0x0FFF -#define MASK 0xFF8 -#define BAD 0xFF0 +#define LONG_BAD 0xFFF8 +#endif +#define MASK16 0xFFF8 +#define BAD16 0xFFF0 +#define MASK12 0xFF8 +#define BAD12 0xFF0 /* Keyboard buffer maximum size */ #ifdef LINESIZE @@ -314,20 +323,8 @@ FAR clk_dev, /* Clock 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 */ -#ifdef I86 - - api_sp, /* api stacks - for context */ -#endif - - api_ss, /* switching */ - usr_sp, /* user stack */ - usr_ss; + ram_top; /* How much ram in Kbytes */ extern COUNT * -#ifdef MC68K - api_sp, /* api stacks - for context */ -#endif - error_tos, /* error stack */ disk_api_tos, /* API handler stack - disk fns */ char_api_tos; /* API handler stack - char fns */ @@ -381,29 +378,26 @@ GLOBAL WORD bDumpRdWrParms GLOBAL BYTE copyright[] #ifdef MAIN -#if 0 -= "(C) Copyright 1995, 1996, 1997, 1998\nPasquale J. Villani\nAll Rights Reserved\n" -#else -= "" -#endif += "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n\ +All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n\ +WARRANTY; you can redistribute it and/or modify it under the terms of the\n\ +GNU General Public License as published by the Free Software Foundation;\n\ +either version 2, or (at your option) any later version.\n" #endif ; GLOBAL BYTE os_release[] #ifdef MAIN #if 0 -= "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n\ -\n\ -DOS-C is free software; you can redistribute it and/or modify it under the\n\ -terms of the GNU General Public License as published by the Free Software\n\ -Foundation; either version 2, or (at your option) any later version.\n\n\ -For technical information and description of the DOS-C operating system\n\ += "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n" +#endif += "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\ consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ \n" -#else -= "FreeDOS kernel version %d.%d.%d"SUB_BUILD - " (Build %d"SUB_BUILD") [" __DATE__ " " __TIME__ "]\n\n" #endif #endif ; @@ -584,13 +578,6 @@ GLOBAL f_node_ptr f_nodes; /* pointer to the array */ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ -GLOBAL struct buffer -FAR *lastbuf; /* tail of ditto */ -/* FAR * buffers; /* pointer to array of track buffers */ - -/*GLOBAL BYTE FAR * dma_scratch;*/ /* scratchpad used for working around */ - /* DMA transfers during disk I/O */ - GLOBAL iregs FAR * ustackp, /* user stack */ FAR * kstackp; /* kernel stack */ @@ -603,34 +590,31 @@ GLOBAL iregs /* Process related functions - not under automatic generation. */ /* Typically, these are in ".asm" files. */ VOID -FAR cpm_entry(VOID), -INRPT FAR re_entry(VOID) /*, - INRPT FAR handle_break(VOID) */ ; +FAR ASMCFUNC cpm_entry(VOID) +/*INRPT FAR handle_break(VOID) */ ; VOID enable(VOID), disable(VOID); COUNT -CriticalError( +ASMCFUNC CriticalError( COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); #ifdef PROTO -VOID FAR CharMapSrvc(VOID); -VOID FAR set_stack(VOID); -VOID FAR restore_stack(VOID); -WORD execrh(request FAR *, struct dhdr FAR *); +VOID FAR ASMCFUNC CharMapSrvc(VOID); +VOID FAR ASMCFUNC set_stack(VOID); +VOID FAR ASMCFUNC restore_stack(VOID); +WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); /*VOID INRPT FAR handle_break(VOID); */ -VOID tmark(VOID); -BOOL tdelay(LONG); -BYTE FAR *device_end(VOID); -COUNT kb_data(VOID); -COUNT kb_input(VOID); -COUNT kb_init(VOID); -VOID setvec(UWORD, VOID(INRPT FAR *) ()); -BYTE FAR *getvec(UWORD); +VOID ASMCFUNC tmark(VOID); +BOOL ASMCFUNC tdelay(LONG); +BYTE FAR *ASMCFUNC device_end(VOID); +COUNT ASMCFUNC kb_data(VOID); +COUNT ASMCFUNC kb_input(VOID); +COUNT ASMCFUNC kb_init(VOID); +VOID ASMCFUNC setvec(UWORD, VOID(INRPT FAR *) ()); +BYTE FAR *ASMCFUNC getvec(UWORD); COUNT con(COUNT); -VOID getdirent(BYTE FAR *, struct dirent FAR *); -VOID putdirent(struct dirent FAR *, BYTE FAR *); #else VOID FAR CharMapSrvc(); VOID FAR set_stack(); @@ -647,8 +631,6 @@ COUNT kb_init(); VOID setvec(); BYTE FAR *getvec(); COUNT con(); -VOID getdirent(); -VOID putdirent(); #endif /* */ @@ -687,12 +669,12 @@ VOID fputbyte(); #endif #ifdef I86 -#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) +#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr)) #endif /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ -void spawn_int23(void); /* procsupt.asm */ +void ASMCFUNC spawn_int23(void); /* procsupt.asm */ int control_break(void); /* break.c */ void handle_break(void); /* break.c */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index cc6d6aa..102e641 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -21,10 +21,6 @@ #include "nls.h" #include "buffer.h" -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - /* * The null macro `INIT' can be used to allow the reader to differentiate * between functions defined in `INIT_TEXT' and those defined in `_TEXT'. @@ -43,14 +39,14 @@ void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ #define fstrncpy reloc_call_fstrncpy #define strcpy reloc_call_strcpy #define strlen reloc_call_strlen -WORD execrh(request FAR *, struct dhdr FAR *); -VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); -void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void memset(REG VOID * s, REG int ch, REG COUNT n); -VOID strcpy(REG BYTE * d, REG BYTE * s); -VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, REG COUNT n); -COUNT fstrlen(REG BYTE FAR * s); -COUNT strlen(REG BYTE * s); +WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); +VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * 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); +VOID ASMCFUNC strcpy(REG BYTE * d, REG BYTE * s); +VOID ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, REG COUNT n); +COUNT ASMCFUNC fstrlen(REG BYTE FAR * s); +COUNT ASMCFUNC strlen(REG BYTE * s); #undef LINESIZE #define LINESIZE KBD_MAXLENGTH @@ -60,7 +56,7 @@ COUNT strlen(REG BYTE * s); extern BYTE DosLoadedInHMA; extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); -#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) +#define setvec(n, isr) (void)(*(VOID (FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr)) #define fbcopy(s, d, n) fmemcpy(d,s,n) #define GLOBAL extern @@ -133,15 +129,15 @@ INIT COUNT toupper(COUNT c); 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 Umb_Test(void); -INIT COUNT UMB_get_largest(UCOUNT *seg, UCOUNT *size); +INIT COUNT ASMCFUNC Umb_Test(void); +INIT COUNT ASMCFUNC UMB_get_largest(UCOUNT *seg, UCOUNT *size); INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); /* diskinit.c */ COUNT dsk_init(VOID); /* int2f.asm */ -COUNT Umb_Test(void); +COUNT ASMCFUNC Umb_Test(void); /* inithma.c */ int MoveKernelToHMA(void); @@ -152,45 +148,41 @@ UWORD init_oem(void); /* intr.asm */ -void init_call_intr(int nr, iregs *rp); -UCOUNT read(int fd, void *buf, UCOUNT count); -int open(const char *pathname, int flags); -int close(int fd); -int dup2(int oldfd, int newfd); -int allocmem(UWORD size, seg *segp); -INIT VOID init_PSPInit(seg psp_seg); -INIT VOID init_PSPSet(seg psp_seg); -INIT COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); -INIT VOID keycheck(VOID); +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); +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 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 int21_entry(iregs UserRegs); -VOID int21_service(iregs far * r); -VOID INRPT FAR int0_handler(void); -VOID INRPT FAR int6_handler(void); -VOID INRPT FAR empty_handler(void); -VOID INRPT far got_cbreak(void); /* procsupt.asm */ -VOID INRPT far int20_handler(iregs UserRegs); -VOID INRPT far int21_handler(iregs UserRegs); -VOID INRPT FAR int22_handler(void); -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 int24_handler(void); -VOID INRPT FAR low_int25_handler(void); -VOID INRPT FAR low_int26_handler(void); -VOID INRPT FAR int27_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 int28_handler(void); -VOID INRPT FAR int29_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 int2a_handler(void); -VOID INRPT FAR int2f_handler(void); +VOID far ASMCFUNC int21_entry(iregs UserRegs); +VOID ASMCFUNC int21_service(iregs far * r); +VOID FAR ASMCFUNC int0_handler(void); +VOID FAR ASMCFUNC int6_handler(void); +VOID FAR ASMCFUNC empty_handler(void); +VOID far ASMCFUNC got_cbreak(void); /* procsupt.asm */ +VOID far ASMCFUNC int20_handler(iregs UserRegs); +VOID far ASMCFUNC int21_handler(iregs UserRegs); +VOID FAR ASMCFUNC int22_handler(void); +VOID FAR ASMCFUNC int24_handler(void); +VOID FAR ASMCFUNC low_int25_handler(void); +VOID FAR ASMCFUNC low_int26_handler(void); +VOID FAR ASMCFUNC int27_handler(void); +VOID FAR ASMCFUNC int28_handler(void); +VOID FAR ASMCFUNC int29_handler(void); +VOID FAR ASMCFUNC int2a_handler(void); +VOID FAR ASMCFUNC int2f_handler(void); /* main.c */ -INIT VOID main(void); +INIT VOID ASMCFUNC FreeDOSmain(void); INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); INIT VOID init_fatal(BYTE * err_msg); @@ -201,3 +193,10 @@ void MoveKernel(unsigned NewKernelSegment); extern WORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; + +#if defined(WATCOM) && 0 +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 */ +#endif diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 62f5531..bedf800 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -26,6 +26,7 @@ #include "portab.h" #include "init-mod.h" +#include "init-dat.h" #include "dyndata.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; @@ -34,11 +35,11 @@ static BYTE *dskRcsId = "$Id$"; /* data shared between DSK.C and INITDISK.C */ -extern UBYTE FAR DiskTransferBuffer[1 * SEC_SIZE]; +extern UBYTE DOSFAR DiskTransferBuffer[1 * SEC_SIZE]; -extern COUNT FAR nUnits; +extern COUNT DOSFAR nUnits; -extern UWORD FAR LBA_WRITE_VERIFY; +extern UWORD DOSFAR LBA_WRITE_VERIFY; /* * Rev 1.0 13 May 2001 tom ehlert @@ -150,10 +151,19 @@ extern UWORD FAR LBA_WRITE_VERIFY; #define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ (parttyp) == EXTENDED_LBA ) -#define IsFAT16Partition(parttyp) ((parttyp) == FAT12 || \ - (parttyp) == FAT16SMALL || \ - (parttyp) == FAT16LARGE || \ - (parttyp) == FAT16_LBA ) +#ifdef WITHFAT32 +#define IsFATPartition(parttyp) ((parttyp) == FAT12 || \ + (parttyp) == FAT16SMALL || \ + (parttyp) == FAT16LARGE || \ + (parttyp) == FAT16_LBA || \ + (parttyp) == FAT32 || \ + (parttyp) == FAT32_LBA) +#else +#define IsFATPartition(parttyp) ((parttyp) == FAT12 || \ + (parttyp) == FAT16SMALL || \ + (parttyp) == FAT16LARGE || \ + (parttyp) == FAT16_LBA) +#endif #define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */ #define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */ @@ -204,6 +214,23 @@ struct PartTableEntry /* INTERNAL representation of partition table entry */ UBYTE GlobalEnableLBAsupport = 1; /* = 0 --> disable LBA support */ +COUNT init_readdasd(UBYTE drive) +{ + static iregs regs; + + regs.a.b.h = 0x15; + regs.d.b.l = drive; + init_call_intr(0x13,®s); + if ((regs.flags & 1) == 0) switch (regs.a.b.h) + { + case 2: + return DF_CHANGELINE; + case 3: + return DF_FIXED; + } + return 0; +} + /* translate LBA sectors into CHS addressing copied and pasted from dsk.c! @@ -343,26 +370,29 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) fmemcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); break; - /* FAT 32 code: commented out for now */ #ifdef WITHFAT32 case FAT32: /* For FAT32, use 4k clusters on sufficiently large file systems, * otherwise 1 sector per cluster. This is also what M$'s format * command does for FAT32. */ - defbpb->bpb_nsector = ((long long)blocks*SECTORS_PER_BLOCK >= 512*1024 ? 8 : 1); + defbpb->bpb_nsector = (NumSectors >= 512*1024 ? 8 : 1); do { - clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / - ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); + /* simple calculation - no long long available */ + clust = (ULONG)fatdata / defbpb->bpb_nsector; + /* this calculation below yields a smaller value - the above is non-optimal + but should not be dangerous */ + /* clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / + ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); */ fatlength = cdiv ((clust+2) * 4, defbpb->bpb_nbyte); /* Need to recalculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; maxclust = (fatlength * defbpb->bpb_nbyte) / 4; - if (maxclust > MAX_CLUST_32) - maxclust = MAX_CLUST_32; + if (maxclust > FAT_MAGIC32) + maxclust = FAT_MAGIC32; DebugPrintf(( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", - clust, fatlength, maxclust, FAT_MAGIC )); + clust, fatlength, maxclust, FAT_MAGIC32 )); if (clust > maxclust) { clust = 0; @@ -372,10 +402,9 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) break; defbpb->bpb_nsector <<= 1; } while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); - bpb_nfsect = fatlength; defbpb->bpb_nfsect = 0; - defbpb->fat32.fat32_length = fatlength; - memcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); + defbpb->bpb_xnfsect = fatlength; + fmemcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); break; #endif } @@ -396,6 +425,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, } pddt->ddt_driveno = driveParam->driveno; + pddt->ddt_logdriveno = nUnits; pddt->ddt_LBASupported = driveParam->LBA_supported; pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; pddt->ddt_ncyl = driveParam->chs.Cylinder; @@ -420,7 +450,8 @@ void DosDefinePartition(struct DriveParamS *driveParam, CalculateFATData(pddt, pEntry->NumSect, pEntry->FileSystem); pddt->ddt_serialno = 0x12345678l; - pddt->ddt_descflags = 0x200; /* drive inaccessible until bldbpb successful */ + /* drive inaccessible until bldbpb successful */ + pddt->ddt_descflags = init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); #ifdef _BETA_ /* Alain whishes to keep this in later versions, too */ @@ -443,10 +474,6 @@ void DosDefinePartition(struct DriveParamS *driveParam, } - -void __int__(int); - - /* Get the parameters of the hard disk */ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) { @@ -658,7 +685,7 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, partitionStart = startSector + pEntry->RelSect; - if (!IsFAT16Partition(pEntry->FileSystem)) + if (!IsFATPartition(pEntry->FileSystem)) { continue; } @@ -680,13 +707,13 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, chs.Head != pEntry->Begin.Head || chs.Sector != pEntry->Begin.Sector ) { - printf("NOT using suspect partition %u FS %02x:", + printf("WARNING: using suspect partition %u FS %02x:", i, pEntry->FileSystem); - printCHS(" start calc ",&chs); - printCHS(" != ",&pEntry->Begin); + printCHS(" with calculated values ",&chs); + printCHS(" instead of ",&pEntry->Begin); printf("\n"); + fmemcpy(&pEntry->Begin, &chs, sizeof(struct CHS)); - continue; } @@ -695,14 +722,20 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, end.Head != pEntry->End.Head || end.Sector != pEntry->End.Sector ) { - printf("NOT using suspect partition %u FS %02x:", + if (pEntry->NumSect == 0) + { + printf("Not using partition %u with 0 sectors\n", i); + continue; + } + + printf("WARNING: using suspect partition %u FS %02x:", i, pEntry->FileSystem); - printCHS(" end calc ",&end); - printCHS(" != ",&pEntry->End); + printCHS(" with calculated values ",&end); + printCHS(" instead of ",&pEntry->End); printf("\n"); + fmemcpy(&pEntry->End, &end, sizeof(struct CHS)); - continue; } @@ -1053,6 +1086,7 @@ void ReadAllPartitionTables(void) bpb FAR *pbpbarray; int Unit; ddt FAR *pddt; + static iregs regs; /* Setup media info and BPBs arrays for floppies (this is a 360kb flop) */ for (Unit = 0; Unit < nUnits; Unit++) @@ -1073,12 +1107,12 @@ void ReadAllPartitionTables(void) pbpbarray->bpb_nsecs = 9; pddt->ddt_driveno = 0; + pddt->ddt_logdriveno = Unit; pddt->ddt_ncyl = 40; pddt->ddt_LBASupported = FALSE; + pddt->ddt_descflags = init_readdasd(0); pddt->ddt_offset = 0l; - - pddt->ddt_serialno = 0x12345678l; fmemcpy(&pddt->ddt_bpb, pbpbarray, sizeof(bpb)); } @@ -1087,14 +1121,15 @@ void ReadAllPartitionTables(void) this is a quick patch - see if B: exists test for A: also, need not exist */ - { - iregs r; - - init_call_intr(0x11,&r); /* get equipment list */ - if ((r.a.x & 1) && (r.a.x & 0xc0)) - pddt->ddt_driveno = 1; - /* floppy drives installed and a B: drive */ - /*if ((r.a.x & 1)==0) */ /* no floppy drives installed */ + init_call_intr(0x11,®s); /* get equipment list */ + if ((regs.a.x & 1) && (regs.a.x & 0xc0)) { + pddt->ddt_driveno = 1; + pddt->ddt_descflags = init_readdasd(1); + /* floppy drives installed and a B: drive */ + /*if ((r.a.x & 1)==0) */ /* no floppy drives installed */ + } else { /* set up the DJ method : multiple logical drives */ + (pddt-1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; + pddt->ddt_descflags |= DF_MULTLOG; } nHardDisk = min(nHardDisk,MAX_HARD_DRIVE-1); diff --git a/kernel/inithma.c b/kernel/inithma.c index a3441ba..fd10425 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -66,9 +66,9 @@ #include "portab.h" #include "init-mod.h" +#include "init-dat.h" -extern BYTE FAR version_flags; /* minor version number */ extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */ @@ -81,6 +81,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.9 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -112,22 +115,28 @@ static BYTE *RcsId = "$Id$"; * initial creation */ -void ClaimHMA(VOID); BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */ -WORD HMAFree; /* first byte in HMA not yet used */ +WORD HMAFree = 0; /* first byte in HMA not yet used */ -extern BYTE FAR * FAR XMSDriverAddress; -extern FAR _EnableA20(VOID); -extern FAR _DisableA20(VOID); +extern BYTE FAR * DOSTEXTFAR ASMCFUNC XMSDriverAddress; +extern FAR ASMCFUNC _EnableA20(VOID); +extern FAR ASMCFUNC _DisableA20(VOID); -extern void FAR *DetectXMSDriver(VOID); - +extern void FAR *ASMCFUNC DetectXMSDriver(VOID); +extern int ASMCFUNC init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); + #ifdef DEBUG - #define int3() __int__(3); + #ifdef __TURBOC__ + #define int3() __int__(3); + #else + void int3() + { __asm int 3; + } + #endif #else #define int3() #endif @@ -158,14 +167,6 @@ VOID hdump(BYTE FAR *p) #endif -#ifdef __TURBOC__ - void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ - unsigned char __inportb__(int portid); - void __outportb__ (int portid, unsigned char value); -#endif - - - #define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) @@ -240,23 +241,13 @@ int MoveKernelToHMA() return TRUE; } - { - void FAR *pXMS = DetectXMSDriver(); - - if (pXMS != NULL) - { - XMSDriverAddress = pXMS; - } - else - return FALSE; - } - - + if ((XMSDriverAddress = DetectXMSDriver()) == NULL) + return FALSE; +#ifdef DEBUG /* A) for debugging purpose, suppress this, if any shift key is pressed */ -#ifdef DEBUG if (KeyboardShiftState() & 0x0f) { printf("Keyboard state is %0x, NOT moving to HMA\n",KeyboardShiftState()); @@ -273,7 +264,15 @@ int MoveKernelToHMA() return FALSE; } - ClaimHMA(); + /* allocate HMA through XMS driver */ + + if (HMAclaimed == 0 && + (HMAclaimed = init_call_XMScall( XMSDriverAddress, 0x0100, 0xffff)) == 0) + { + printf("Can't reserve HMA area ??\n"); + + return FALSE; + } MoveKernel(0xffff); @@ -293,12 +292,8 @@ int MoveKernelToHMA() /* report the fact we are running high thorugh int 21, ax=3306 */ version_flags |= 0x10; - return TRUE; -errorReturn: - printf("HMA errors, not doing HMA\n"); - return FALSE; } @@ -345,35 +340,6 @@ void InstallVDISK(VOID) #endif -int init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); - - -/* - allocate HMA through XMS driver -*/ - -void ClaimHMA(VOID) -{ - void FAR *pXMS; - - if (!DosLoadedInHMA) return; - if (HMAclaimed) return; - - - pXMS = DetectXMSDriver(); - - if (pXMS != NULL) - { - XMSDriverAddress = pXMS; - - if (init_call_XMScall( pXMS, 0x0100, 0xffff)) - { - printf("HMA area successfully claimed\n"); - HMAclaimed = TRUE; - } - } -} - /* this should be called, after each device driver has been loaded with FALSE @@ -430,7 +396,7 @@ void MoveKernel(unsigned NewKernelSegment) UBYTE FAR *HMASource; unsigned len; - __int__(3); + int3(); if (CurrentKernelSegment == 0) CurrentKernelSegment = FP_SEG(_HMATextEnd); @@ -497,12 +463,12 @@ void MoveKernel(unsigned NewKernelSegment) UWORD jmpSegment; }; extern struct RelocationTable - FAR _HMARelocationTableStart[], - FAR _HMARelocationTableEnd[]; + DOSTEXTFAR _HMARelocationTableStart[], + DOSTEXTFAR _HMARelocationTableEnd[]; struct RelocationTable FAR *rp, rtemp ; - /* verify, that all entries are valid */ + /* verify, that all entries are valid */ for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) { @@ -511,7 +477,8 @@ void MoveKernel(unsigned NewKernelSegment) rp->callNear != 0xe8 || /* call NEAR */ 0) { - printf("illegal relocation entry # %d\n",rp - _HMARelocationTableStart); + printf("illegal relocation entry # %d\n",(FP_OFF(rp) - FP_OFF(_HMARelocationTableStart))/sizeof(struct RelocationTable)); + int3(); goto errorReturn; } } diff --git a/kernel/initoem.c b/kernel/initoem.c index 883adc6..2e52b4e 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -90,20 +93,15 @@ static BYTE *RcsId = "$Id$"; * Initial revision. */ -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - UWORD init_oem(void) { UWORD top_k; #ifndef __TURBOC__ - _asm + asm { - int 12 h - mov top_k, - ax + int 0x12; + mov top_k,ax; } #else __int__(0x12); diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 43cb5d4..d73bdba 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.13 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.12 2001/08/19 12:58:36 bartoldeman ; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading ; @@ -107,7 +110,6 @@ %include "stacks.inc" segment HMA_TEXT - extern _nul_dev:wrt DGROUP extern _cu_psp:wrt DGROUP extern _syscall_MUX14:wrt HMA_TEXT @@ -158,153 +160,46 @@ Int2f?iret: iret -FarTabRetnBX: pop bx - jmp FarTabRetn -; -;return dos data seg. -IntDosCal: - cmp al, 31h - ja FarTabRetn - push bx - mov bl, al - mov bh, 0 - shl bx, 1 - jmp [cs:bx+DosCalTbl] -DosCalTbl: -dw retff, IntDosCal_1, IntDosCal_2, IntDosCal_3, IntDosCal_4, IntDosCal_5, -dw IntDosCal_6, IntDosCal_7, IntDosCal_8, IntDosCal_9, IntDosCal_a, -dw IntDosCal_b, IntDosCal_c, IntDosCal_d, IntDosCal_e, IntDosCal_f, -dw IntDosCal_10, IntDosCal_11, IntDosCal_12, IntDosCal_13, IntDosCal_14, -dw IntDosCal_15, IntDosCal_16, IntDosCal_17, IntDosCal_18, IntDosCal_19, -dw IntDosCal_1a, IntDosCal_1b, IntDosCal_1c, IntDosCal_1d, IntDosCal_1e, -dw IntDosCal_1f, IntDosCal_20, IntDosCal_21, IntDosCal_22, IntDosCal_23, -dw IntDosCal_24, IntDosCal_25, IntDosCal_26, IntDosCal_27, IntDosCal_28, -dw IntDosCal_29, IntDosCal_2a, IntDosCal_2b, IntDosCal_2c, IntDosCal_2d, -dw IntDosCal_2e, IntDosCal_2f, IntDosCal_30, IntDosCal_31 +;*********************************************************** +; internal doscalls INT2F/11xx - handled through C +;*********************************************************** +IntDosCal: + ; set up register frame +;struct int2f12regs +;{ +; UWORD es,ds; +; UWORD di,si,bp,bx,dx,cx,ax; +; UWORD ip,cs,flags; +; UWORD callerARG1; +;}; + push ax + push cx + push dx + push bx + push bp + push si + push di + push ds + push es -retff: mov al,0ffh - jmp FarTabRetnBX - -IntDosCal_3: - push ax - mov ax, seg _nul_dev - mov ds,ax - pop ax - clc - jmp FarTabRetnBX - -IntDosCal_8: - ; decrease SFT reference count - dec word [es:di] - jnz .skip - dec word [es:di] -.skip: - jmp FarTabRetnBX - -IntDosCal_1: -IntDosCal_2: -IntDosCal_4: -IntDosCal_5: -IntDosCal_6: -IntDosCal_7: -IntDosCal_9: -IntDosCal_a: -IntDosCal_b: -IntDosCal_c: -IntDosCal_d: -IntDosCal_e: -IntDosCal_f: -IntDosCal_10: -IntDosCal_11: -IntDosCal_13: -IntDosCal_14: -IntDosCal_15: -IntDosCal_16: -IntDosCal_17: -IntDosCal_19: -IntDosCal_1a: -IntDosCal_1c: -IntDosCal_1d: -IntDosCal_1e: -IntDosCal_1f: -IntDosCal_20: -IntDosCal_22: -IntDosCal_23: -IntDosCal_24: -IntDosCal_26: -IntDosCal_27: -IntDosCal_28: -IntDosCal_29: -IntDosCal_2b: -IntDosCal_2d: -IntDosCal_2e: -IntDosCal_2f: -IntDosCal_30: -IntDosCal_31: - jmp FarTabRetnBX - -; get length of asciiz string -IntDosCal_12: - push di - push es - extern _fstrlen - call _fstrlen - add sp, byte 4 - mov cx, ax - inc cx - jmp FarTabRetnBX - -; get caller's registers -IntDosCal_18: - extern _user_r - lds si, [_user_r] - jmp FarTabRetnBX - -; #days in February - valid until 2099. -IntDosCal_1b: - mov al, 28 - test cl, 3 - jnz .noleap - inc al -.noleap: jmp FarTabRetnBX - -; truename -IntDosCal_21: - xor bx, bx - push bx - push es - push di - push ds - push si - extern _truename - call _truename - add sp, byte 10 - jmp FarTabRetnBX - -; get length of asciiz string -IntDosCal_25: - push si - push ds - call _fstrlen - add sp, byte 4 - mov cx, ax - inc cx - jmp FarTabRetnBX - -; -;Set FastOpen but does nothing. -IntDosCal_2a: - clc - jmp FarTabRetn -; -; added by James Tabor For Zip Drives -;Return Null Device Pointer -IntDosCal_2c: - mov ax,_nul_dev - mov bx,seg _nul_dev - clc - jmp FarTabRetn + mov ax,DGROUP + mov ds,ax + extern _int2F_12_handler:wrt HGROUP + call _int2F_12_handler + + pop es + pop ds + pop di + pop si + pop bp + pop bx + pop dx + pop cx + pop ax + + iret + ; Int 2F Multipurpose Remote System Calls diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d016792..7b3161c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.31 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.30 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -274,11 +277,19 @@ VOID FAR int21_entry(iregs UserRegs) } #endif +/* Structures needed for int 25 / int 26 */ +struct HugeSectorBlock +{ + ULONG blkno; + WORD nblks; + BYTE FAR *buf; +}; + /* Normal entry. This minimizes user stack usage by avoiding local */ /* variables needed for the rest of the handler. */ /* this here works on the users stack !! and only very few functions are allowed */ -VOID int21_syscall(iregs FAR * irp) +VOID ASMCFUNC int21_syscall(iregs FAR * irp) { Int21AX = irp->AX; @@ -364,7 +375,7 @@ VOID int21_syscall(iregs FAR * irp) } -VOID int21_service(iregs FAR * r) +VOID ASMCFUNC int21_service(iregs FAR * r) { COUNT rc = 0, rc1; @@ -893,7 +904,11 @@ dispatch: } dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ +#ifdef WITHFAT32 + if (media_check(dpb) < 0 || ISFAT32(dpb)) +#else if (media_check(dpb) < 0) +#endif { r->AL = 0xff; CritErrCode = 0x0f; @@ -1255,7 +1270,11 @@ 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) +#endif + ); break; /* Get verify state */ @@ -1645,7 +1664,7 @@ dispatch: /* Get/Set Serial Number */ case 0x69: - rc = ( r->BL == 0 ? default_drive : r->BL - 1); + rc = (r->BL == 0 ? default_drive : r->BL - 1); if (rc < lastdrive) { UWORD saveCX = r->CX; @@ -1679,7 +1698,7 @@ dispatch: case 0x6b: dummy func: return AL=0 */ /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ - case 0x6c: + case 0x6c: { COUNT x = 0; @@ -1721,27 +1740,227 @@ break_out: break; } - /* case 0x6d and above not implemented : see default; return AL=0 */ - - } +#ifdef WITHFAT32 + /* DOS 7.0+ FAT32 extended funcitons */ + case 0x73: + { + switch(r->AL) + { + /* Get extended drive parameter block */ + case 0x02: + { + struct xdpbdata FAR *xddp = (struct xdpbdata FAR *)MK_FP(r->ES, r->DI); + struct dpb FAR *dpb; + + if (r->CX < sizeof(struct xdpbdata)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } + + dpb = GetDriveDPB(r->DL, &rc); + if (rc != SUCCESS) goto error_exit; + + dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ + + if (media_check(dpb) < 0) + { + r->AX = -DE_INVLDDRV; + goto error_out; + } + + fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); + xddp->xdd_dpbsize = sizeof(struct dpb); + CLEAR_CARRY_FLAG(); + + break; + } + /* Get extended free drive space */ + case 0x03: + { + struct xfreespace FAR *xfsp = + (struct xfreespace FAR *)MK_FP(r->ES, r->DI); + if (r->CX < sizeof(struct xfreespace)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } + CLEAR_CARRY_FLAG(); + rc = DosGetExtFree((BYTE FAR *)FP_DS_DX, xfsp); + if (rc != SUCCESS) + goto error_exit; + xfsp->xfs_datasize = sizeof(struct xfreespace); + xfsp->xfs_version.actual = 0; + break; + } + /* Set DPB to use for formatting */ + case 0x04: + { + struct xdpbforformat FAR *xdffp = + (struct xdpbforformat FAR *)MK_FP(r->ES, r->DI); + struct dpb FAR *dpb; + if (r->CX < sizeof(struct xdpbforformat)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } + dpb = GetDriveDPB(r->DL, &rc); + 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) + { + case 0x00: + { + DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; + DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; + if ((dpb->dpb_xfsinfosec == 0xffff && (nfreeclst != 0 || + cluster != 0)) || + nfreeclst == 1 || nfreeclst > dpb->dpb_size || + cluster == 1 || cluster > dpb->dpb_size) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + dpb->dpb_nfreeclst = nfreeclst; + dpb->dpb_cluster = cluster; + write_fsinfo(dpb); + break; + } + case 0x01: + { + ddt *pddt = getddt(r->DL); + fmemcpy(&pddt->ddt_bpb, xdffp->xdff_f.rebuilddpb.bpbp, + sizeof(bpb)); + } + case 0x02: + { +rebuild_dpb: + dpb->dpb_flags = M_CHANGED; + + if (media_check(dpb) < 0) + { + r->AX = -DE_INVLDDRV; + goto error_out; + } + + break; + } + case 0x03: + { + struct buffer FAR *bp; + bpb FAR *bpbp; + DWORD newmirroring = xdffp->xdff_f.setmirroring.newmirroring; + if (newmirroring != -1 && newmirroring & ~(0xf | 0x80)) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + xdffp->xdff_f.setmirroring.oldmirroring = dpb->dpb_xflags; + if (newmirroring != -1) + { + 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_xflags = newmirroring; + } + goto rebuild_dpb; + } + case 0x04: + { + struct buffer FAR *bp; + bpb FAR *bpbp; + DWORD rootclst = xdffp->xdff_f.setroot.newrootclst; + if (rootclst != -1 && (rootclst == 1 || + rootclst > dpb->dpb_size)) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + xdffp->xdff_f.setroot.oldrootclst = dpb->dpb_xrootclst; + if (rootclst != -1) + { + 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_xrootclst = rootclst; + } + goto rebuild_dpb; + } + } + + break; + } + /* Extended absolute disk read/write */ + /* TODO(vlp) consider using of the 13-14th bits of SI */ + case 0x05: + { + struct HugeSectorBlock FAR *SectorBlock = + (struct HugeSectorBlock FAR *)MK_FP(r->DS, r->BX); + UBYTE mode; + + if (r->CX != 0xffff || ((r->SI & 1) == 0 && r->SI != 0) + || (r->SI & ~0x6001)) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + + if (r->DL - 1 >= lastdrive || r->DL == 0) + { + r->AX = 0x207; + goto error_out; + } + CLEAR_CARRY_FLAG(); + + if (r->SI == 0) mode = DSKREAD; + else mode = DSKWRITE; + InDOS++; + + r->AX=dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf, + SectorBlock->nblks, mode); + + if (mode == DSKWRITE) + if (r->AX <= 0) + setinvld(r->DL - 1); + + if (r->AX > 0) + { + r->AX = 0x20c; + r->flags |= FLG_CARRY; + --InDOS; + return; + } + + + r->AX = 0; + r->flags &= ~FLG_CARRY; + --InDOS; + break; + } + } + break; + } +#endif + } #ifdef DEBUG if (bDumpRegs) - { - fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, - sizeof(iregs)); - dump_regs = TRUE; - dump(); - } + { + fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, + sizeof(iregs)); + dump_regs = TRUE; + dump(); + } #endif } -/* terminate handler */ -VOID INRPT FAR int22_handler(void) -{ -} - #if 0 /* No kernel INT-23 handler required no longer -- 1999/04/15 ska */ /* ctrl-Break handler */ @@ -1760,14 +1979,6 @@ VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int } #endif -/* Structures needed for int 25 / int 26 */ -struct HugeSectorBlock -{ - ULONG blkno; - WORD nblks; - BYTE FAR *buf; -}; - struct int25regs { UWORD es, @@ -1788,7 +1999,7 @@ struct int25regs /* this function is called from an assembler wrapper function */ -VOID int2526_handler(WORD mode, struct int25regs FAR * r) +VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) { ULONG blkno; UWORD nblks; @@ -1806,7 +2017,16 @@ VOID int2526_handler(WORD mode, struct int25regs FAR * r) r->flags |= FLG_CARRY; return; } - + +#ifdef WITHFAT32 + if (!(CDSp->cds_table[drv].cdsFlags & CDSNETWDRV) && + ISFAT32(CDSp->cds_table[drv].cdsDpb)) + { + r->ax = 0x207; + r->flags |= FLG_CARRY; + return; + } +#endif nblks = r->cx; blkno = r->dx; @@ -1868,3 +2088,138 @@ static VOID StartTrace(VOID) } #endif +/* + 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; + UWORD callerARG1; /* used if called from INT2F/12 */ +}; + +VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) +{ + UWORD function = r.ax & 0xff; + + if (function > 0x31) + return; + + switch(function) + { + case 0x00: /* installation check */ + r.ax |= 0x00ff; + break; + + case 0x03: /* get DOS data segment */ + r.ds = FP_SEG(&nul_dev); + break; + + case 0x08: /* decrease SFT reference count */ + { + UWORD FAR *SFTp = MK_FP(r.es,r.di); + + r.ax = *SFTp; + + if (--*SFTp == 0) --*SFTp; + + } + break; + + case 0x12: /* get length of asciiz string */ + + r.cx = fstrlen(MK_FP(r.es, r.di))+1; + + break; + + + + case 0x18: /* get caller's registers */ + + r.ds = FP_SEG(user_r); + r.si = FP_OFF(user_r); + break; + + 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); + + break; + + case 0x25: /* get length of asciiz string */ + + r.cx = fstrlen(MK_FP(r.ds, r.si))+1; + break; + + + case 0x2a: /* Set FastOpen but does nothing. */ + + r.flags &= ~FLG_CARRY; + break; + + 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*/ + r.bx = FP_SEG(nul_dev.dh_next); + r.ax = FP_OFF(nul_dev.dh_next); + + break; + + case 0x2e: /* GET or SET error table addresse - ignored + called by MS debug with DS != DOSDS, printf + doesn't work!! */ + 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 + ES:DI pointer to SFT entry */ + { + sft FAR *p = get_sft(r.bx); + + r.es = FP_SEG(p); + r.di = FP_OFF(p); + break; + } + + + case 0x17: /* get current directory structure for drive - used by NET.EXE + STACK: drive (0=A:,1=B,...) + ; returns + ; CF set if error + ; DS:SI pointer to CDS for drive + ; + ; called like + ; push 2 (c-drive) + ; mov ax,1217 + ; int 2f + ; + ; probable use: get sizeof(CDSentry) + */ + { + UWORD drv = r.callerARG1 & 0xff; + + if (drv >= lastdrive) + r.flags |= FLG_CARRY; + else + { + r.ds = FP_SEG(CDSp); + r.si = FP_OFF(&CDSp->cds_table[drv]); + r.flags &= ~FLG_CARRY; + } + break; + } + default: + printf("unknown internal dos function INT2F/12%02x\n",function); + + } + +} diff --git a/kernel/intr.h b/kernel/intr.h index be03c57..2b6fd90 100644 --- a/kernel/intr.h +++ b/kernel/intr.h @@ -6,4 +6,4 @@ struct REGPACK { unsigned r_bp, r_di, r_si, r_ds, r_es, r_flags; }; -extern void intr(int intrnr, struct REGPACK *rp); +extern void ASMCFUNC intr(int intrnr, struct REGPACK *rp); diff --git a/kernel/io.asm b/kernel/io.asm index 37fec88..1708c9b 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.10 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.9 2001/04/29 17:34:40 bartoldeman ; A new SYS.COM/config.sys single stepping/console output/misc fixes. ; @@ -217,6 +220,15 @@ _blk_dev equ $ _nblk_rel db 4 db 0,0,0,0,0,0,0 +; quick hack for MSC + global _Get_nblk_rel +_Get_nblk_rel: + mov ah,0 + mov al,[cs:_nblk_rel] + retf +;end of hack + + ; ; Temporary table until next release diff --git a/kernel/io.inc b/kernel/io.inc index 800ca2a..4a62ab2 100644 --- a/kernel/io.inc +++ b/kernel/io.inc @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.4 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -63,6 +66,25 @@ %include "segs.inc" +; +; Error Return Codes +; + +%define E_WRPRT 0 ; Write Protect +%define E_UNIT 1 ; Unknown Unit +%define E_NOTRDY 2 ; Device Not Ready +%define E_CMD 3 ; Unknown Command +%define E_CRC 4 ; Crc Error +%define E_LENGTH 5 ; Bad Length +%define E_SEEK 6 ; Seek Error +%define E_MEDIA 7 ; Unknown MEDIA +%define E_NOTFND 8 ; Sector Not Found +%define E_PAPER 9 ; No Paper +%define E_WRITE 10 ; Write Fault +%define E_READ 11 ; Read Fault +%define E_FAILURE 12 ; General Failure + + extern _IOExit:wrt TGROUP extern _IOSuccess:wrt TGROUP extern _IOErrorExit:wrt TGROUP diff --git a/kernel/kernel.asm b/kernel/kernel.asm index ca74ba5..5898e3a 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.18 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.17 2001/08/19 12:58:36 bartoldeman ; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading ; @@ -171,7 +174,7 @@ beyond_entry: resb 256-(beyond_entry-entry) segment INIT_TEXT - extern _main:wrt IGROUP + extern _FreeDOSmain:wrt IGROUP ; ; kernel start-up @@ -255,7 +258,7 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from mov ax,cs mov ds,ax mov es,ax - jmp _main + jmp _FreeDOSmain segment INIT_TEXT_END @@ -292,6 +295,8 @@ segment _FIXED_DATA ; use. A 0 indicates MS-DOS 3.X style, a 1 indicates MS-DOS 4.0-6.X style. global DATASTART DATASTART: + global _DATASTART +_DATASTART: dos_data db 0 dw kernel_start db 0 ; padding @@ -326,7 +331,7 @@ _sfthead dw _firstsftt ; 0004 System File Table head global _clock _clock dd 0 ; 0008 CLOCK$ device global _syscon -_syscon dd 0 ; 000c console device +_syscon dw _con_dev,seg _con_dev ; 000c console device global _maxbksize _maxbksize dw 512 ; 0010 maximum bytes/sector of any block device dw buf_info ; 0012 pointer to buffers info structure @@ -654,14 +659,6 @@ intr_dos_stk resw 1 intr_dos_seg resw 1 - global _api_sp -_api_sp dw 0 ; api stacks - for context - global _api_ss -_api_ss dw 0 ; switching - global _usr_sp -_usr_sp dw 0 ; user stacks - global _usr_ss -_usr_ss dw 0 global _ram_top _ram_top dw 0 @@ -763,10 +760,12 @@ segment _STACK class=STACK stack segment _TEXT ; dummy interrupt return handlers - + + global _int22_handler global _int28_handler global _int2a_handler global _empty_handler +_int22_handler: _int28_handler: _int2a_handler: _empty_handler: diff --git a/kernel/main.c b/kernel/main.c index 943f267..2293cab 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -29,6 +29,10 @@ #include "portab.h" #include "init-mod.h" +#include "dyndata.h" +#include "init-dat.h" + + /* These are the far variables from the DOS data segment that we need here. The @@ -38,31 +42,31 @@ -- Bart */ -extern UBYTE FAR nblkdev, - FAR lastdrive; /* value of last drive */ +extern UBYTE DOSFAR nblkdev, + DOSFAR lastdrive; /* value of last drive */ GLOBAL BYTE - FAR os_major, /* major version number */ - FAR os_minor, /* minor version number */ - FAR dosidle_flag, - FAR BootDrive, /* Drive we came up from */ - FAR default_drive; /* default drive for dos */ + DOSFAR os_major, /* major version number */ + DOSFAR os_minor, /* minor version number */ + DOSFAR dosidle_flag, + DOSFAR BootDrive, /* Drive we came up from */ + DOSFAR default_drive; /* default drive for dos */ -GLOBAL BYTE FAR os_release[]; -GLOBAL BYTE FAR copyright[]; -GLOBAL seg FAR RootPsp; /* Root process -- do not abort */ +GLOBAL BYTE DOSFAR os_release[]; +GLOBAL BYTE DOSFAR copyright[]; +GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ -extern struct dpb FAR * FAR DPBp; /* First drive Parameter Block */ -extern cdstbl FAR * FAR 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 * FAR clock, /* CLOCK$ device */ - FAR * FAR syscon; /* console device */ -extern struct dhdr FAR con_dev, /* console device drive */ - FAR clk_dev, /* Clock device driver */ - FAR blk_dev; /* Block device (Disk) driver */ +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 - FAR ram_top; /* How much ram in Kbytes */ -extern iregs FAR * FAR user_r; /* User registers for int 21h call */ + 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 @@ -71,6 +75,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.20 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -234,9 +241,32 @@ INIT static VOID init_kernel(VOID); INIT static VOID signon(VOID); INIT VOID kernel(VOID); INIT VOID FsConfig(VOID); +INIT VOID InitPrinters(VOID); -INIT VOID main(void) +#ifdef _MSC_VER + BYTE _acrtused = 0; +#endif + +#ifdef _MSC_VER +__segment DosDataSeg = 0; /* serves for all references to the DOS DATA segment + necessary for MSC+our funny linking model + */ +__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; +#endif + + + setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ @@ -295,7 +325,7 @@ INIT void init_kernel(void) lpOldTop = lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); /* Fake int 21h stack frame */ - user_r = (iregs FAR *) DOS_PSP + 0xD0; + user_r = (iregs FAR *) MK_FP(DOS_PSP,0xD0); #ifndef KDB for (i = 0x20; i <= 0x3f; i++) @@ -304,6 +334,7 @@ INIT void init_kernel(void) /* Initialize IO subsystem */ InitIO(); + InitPrinters(); #ifndef KDB /* set interrupt vectors */ @@ -431,14 +462,31 @@ INIT VOID FsConfig(VOID) INIT VOID signon() { - BYTE tmp_or[81]; /* ugly constant, but this string should fit on one line */ + printf("\n%S" ,(void FAR *)os_release); - printf("\nFreeDOS Kernel compatibility %d.%d\n%S\n", - os_major, os_minor, copyright); - fmemcpy(tmp_or, os_release, 81); - printf(tmp_or, - REVISION_MAJOR, REVISION_MINOR, REVISION_SEQ, - BUILD); + printf("Kernel compatibility %d.%d", + os_major, os_minor ); + +#if defined(__TURBOC__) + printf(" - TURBOC"); +#elif defined(_MSC_VER) + printf(" - MSC"); +#elif defined(__WATCOMC__) + printf(" - WATCOMC"); +#else + generate some bullshit error here, as the compiler should be known +#endif + +#if defined (I386) + printf(" - 80386 CPU required"); +#elif defined (I186) + printf(" - 80186 CPU required"); +#endif + +#ifdef WITHFAT32 + printf(" - FAT32 support"); +#endif + printf("\n\n%S",(void FAR *)copyright); } INIT void kernel() @@ -683,3 +731,29 @@ VOID init_fatal(BYTE * err_msg) printf("\nInternal kernel error - %s\nSystem halted\n", err_msg); for (;;) ; } + +/* + Initialize all printers + + this should work. IMHO, this might also be done on first use + of printer, as I never liked the noise by a resetting printer, and + I usually much more often reset my system, then I print :-) + */ + +INIT VOID InitPrinters(VOID) +{ + iregs r; + int num_printers,i; + + 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++) + { + r.a.x = 0x0100; /* initialize printer */ + r.d.x = i; + init_call_intr(0x17,&r); + } +} + diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 116b3cf..3537ed2 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.14 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -524,6 +527,12 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) for (i = 0; i < 8; i++) q->m_name[i] = '\0'; } + + /* MS network client NET.EXE: DosMemChange sets the PSP * + * not tested, if always, or only on success TE* + * only on success seems more logical to me - Bart */ + p->m_psp = cu_psp; + return SUCCESS; } diff --git a/kernel/newstuff.c b/kernel/newstuff.c index f9b1741..00a31c4 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.13 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -255,7 +258,7 @@ COUNT get_verify_drive(char FAR *src) */ -COUNT truename(char FAR * src, char FAR * dest, COUNT t) +COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; char *bufp = buf + 3; @@ -353,7 +356,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) if (*src != '\\' && *src != '/') /* append current dir */ { - DosGetCuDir(i+1, bufp); + DosGetCuDir((UBYTE)(i+1), bufp); if (*bufp) { while (*bufp) diff --git a/kernel/nls.c b/kernel/nls.c index 1dfe9d5..5b8b3ac 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.8 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -482,7 +485,7 @@ VOID DosUpMem(VOID FAR * str, unsigned len) * the HiByte of the first argument must remain unchanged. * See NLSSUPT.ASM -- 2000/03/30 ska */ -unsigned char DosUpChar(unsigned char ch) +unsigned char ASMCFUNC DosUpChar(unsigned char ch) /* upcase a single character */ { assertDSeqSS(); /* because "&ch" */ @@ -629,11 +632,10 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) Return value: AL register to be returned if AL == 0, Carry must be cleared, otherwise set */ -#pragma argsused -UWORD syscall_MUX14(DIRECT_IREGS) +UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS) { struct nlsPackage FAR*nls; /* addressed NLS package */ - if (flags || cs || ip || ds || es || si); + UNREFERENCED_PARAMETER (flags || cs || ip || ds || es || si); log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", AL, BX, DX) ); diff --git a/kernel/prf.c b/kernel/prf.c index 2d73e7d..d43a352 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,7 +28,7 @@ #include "portab.h" -/* #define DOSEMU */ +/*#define DOSEMU*/ #ifdef FORINIT #define fstrlen reloc_call_fstrlen @@ -41,7 +41,7 @@ #define hexd init_hexd #endif -COUNT 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 @@ -50,6 +50,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.11 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -75,6 +78,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.12 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.11 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -141,7 +147,7 @@ static BYTE *prfRcsId = "$Id$"; * Initial revision. */ -static BYTE *charp; +static BYTE *charp = 0; #ifdef PROTO VOID handle_char(COUNT); @@ -162,10 +168,6 @@ VOID cso(COUNT); VOID cso(); #endif -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - #ifdef FORSYS COUNT fstrlen (BYTE FAR * s) /* don't want globals.h, sorry */ { @@ -188,9 +190,18 @@ put_console(COUNT c) #ifdef FORSYS write(1,&c,1); /* write character to stdout */ #else +#if defined(__TURBOC__) _AX = 0x0e00 | c; _BX = 0x0070; __int__(0x10); +#else + __asm { + mov al, byte ptr c; + mov ah, 0x0e; + mov bx, 0x0070; + int 0x10; + } +#endif /* __TURBO__*/ #endif } @@ -227,7 +238,9 @@ BYTE * p = q = s; do { /* generate digits in reverse order */ - *p++ = "0123456789abcdef"[(UWORD)(u % base)]; + static char hexDigits[] = "0123456789abcdef"; + + *p++ = hexDigits[(UWORD)(u % base)]; } while ((u /= base) > 0); @@ -365,9 +378,10 @@ COUNT case 'p': { WORD w[2]; + static char pointerFormat[] = "%04x:%04x"; w[1] = *((unsigned int*) arg)++; w[0] = *((unsigned int*) arg)++; - do_printf("%04x:%04x",(BYTE**)&w); + do_printf(pointerFormat,(BYTE**)&w); continue; } diff --git a/kernel/printer.asm b/kernel/printer.asm index a3718a8..ee855ec 100644 --- a/kernel/printer.asm +++ b/kernel/printer.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -52,6 +55,17 @@ %include "io.inc" + %define PRT_TIMEOUT 01h + %define PRT_IOERROR 08h + %define PRT_SELECTED 10h + %define PRT_OUTOFPAPER 20h + %define PRT_ACK 40h + %define PRT_NOTBUSY 80h + + %define PRT_WRITECHAR 00h + %define PRT_INITPORT 01h + %define PRT_GETSTATUS 02h + segment _IO_FIXED_DATA global LptTable @@ -93,18 +107,16 @@ uPrtQuantum dw 50h PrtWrite: jcxz PrtWr3 ; Exit if nothing to write PrtWr1: - mov bx,2 + mov bx,2 ; number of retries PrtWr2: - mov al,[es:di] - inc di - xor ah,ah ; Zero register - call PrtIOCall ; (0800) + + call PrintSingleCharacter + jnz PrtWr4 ; Exit if done loop PrtWr1 ; otherwise loop PrtWr3: jmp _IOExit PrtWr4: - dec di dec bx jnz PrtWr2 PrtWr5: @@ -115,32 +127,32 @@ PrtWr5: PrtOutStat: call GetPrtStat jnz PrtWr5 - mov al,9 - test ah,20h + mov al, E_PAPER + test ah, PRT_OUTOFPAPER jnz PrtWr5 - test ah,80h + test ah, PRT_NOTBUSY jnz PrtWr3 jmp _IODone GetPrtStat: - mov ah,2 + mov ah,PRT_GETSTATUS PrtIOCall: call GetUnitNum int 17h ; print char al, get status ah - test ah,8 - jz PrtIOCal2 - mov al,9 - test ah,20h + test ah, PRT_TIMEOUT|PRT_IOERROR + jnz PrtIOCal2 + mov al, E_PAPER + test ah, PRT_OUTOFPAPER jnz PrtIOCal1 - inc al + inc al ; al<-E_WRITE PrtIOCal1: retn PrtIOCal2: - mov al,2 - test ah,1 + mov al, E_NOTRDY + test ah, PRT_TIMEOUT retn @@ -161,7 +173,7 @@ PrtOtBsy1: PrtOtBsy2: call GetPrtStat jnz PrtOtBsy3 - test ah,80h + test ah, PRT_NOTBUSY loopz PrtOtBsy2 pop cx jz PrtOtBsy4 @@ -206,3 +218,66 @@ PrtGnIoctl3: mov [cs:uPrtQuantum+bx],cx mov [es:di],cx jmp _IOExit + + + +; +; original implementation didn't work at all. +; this one's not much better either, +; but should print a little bit +; +; the status bits = AH +; +; 1 0 +; 80 - BUSY not busy busy +; 40 - ACK transfer finished not yet finished +; 20 - PAP no paper available paper OK +; 10 - ONOF printer online not online +; 08 - ERR some error no error +; 01 - TIM some error when transfer OK +; +; some states +; 30 - there is no printer at all +; c8 - there is a printer without power +; 10 - printer with power, but not initialized +; 90 - this one is fine +; + + +; you must not simply print without asking for status +; as the BIOS has a LARGE timeout before aborting +; + +PrintSingleCharacter: + + mov ah, PRT_GETSTATUS ; get status, ah=2 + call GetUnitNum + int 17h ; print char al, get status ah + + test ah, PRT_OUTOFPAPER|PRT_IOERROR + jnz decode_error + + test ah, PRT_NOTBUSY + jz decode_error + + + mov al,[es:di] + mov ah,PRT_WRITECHAR ; print character, ah=0 + call GetUnitNum + int 17h ; print char al, get status ah + + test ah, PRT_OUTOFPAPER|PRT_IOERROR|PRT_TIMEOUT + jnz decode_error + inc di + xor al,al ; set zero flag + clear al + ret + + +decode_error: + mov al, E_PAPER + test ah, PRT_OUTOFPAPER ;out_of_paper, 20h + jnz out_of_paper + mov al, E_WRITE +out_of_paper: + or al,al ; reset zero flag + ret diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index d5402b3..aa7a898 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.7 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.6 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -93,10 +96,6 @@ %include "segs.inc" - extern _api_sp:wrt DGROUP ; api stacks - for context - extern _api_ss:wrt DGROUP ; switching - extern _usr_sp:wrt DGROUP ; user stacks - extern _usr_ss:wrt DGROUP extern _lpUserStack:wrt DGROUP extern _break_flg:wrt DGROUP ; break detected flag @@ -104,14 +103,14 @@ %include "stacks.inc" -segment _TEXT +segment HMA_TEXT extern _DGROUP_:wrt TGROUP ; ; Special call for switching processes ; -; void interrupt far exec_user(irp) +; void exec_user(irp) ; iregs far *irp; ; global _exec_user @@ -123,10 +122,10 @@ _exec_user: ; ; ; - mov bp,sp + pop ax ; return address (unused) - mov ax,word [bp+6] ; irp (user ss:sp) - mov dx,word [bp+8] + pop ax ; irp (user ss:sp) + pop dx cli mov ss,dx mov sp,ax ; set-up user stack @@ -135,7 +134,7 @@ _exec_user: POP$ALL iret - +segment _TEXT ;; Called whenever the BIOS detects a ^Break state @@ -208,8 +207,6 @@ _spawn_int23: mov ss, [_lpUserStack+2] mov sp, [_lpUserStack] -; mov ss,[_usr_ss] -; mov sp,[_usr_sp] sti ; get all the user registers back diff --git a/kernel/proto.h b/kernel/proto.h index 3631c90..93211a5 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.22 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.21 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -199,7 +202,7 @@ BOOL flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); /* *** Changed on 9/4/00 BER */ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); -/* *** End of change +/* *** End of change */ /* chario.c */ VOID sto(COUNT c); @@ -218,6 +221,9 @@ UCOUNT sti(keyboard * kp); sft FAR *get_sft(UCOUNT); /* dosfns.c */ +#ifdef WITHFAT32 +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); @@ -238,6 +244,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode); COUNT DosClose(COUNT hndl); COUNT DosCloseSft(WORD sft_idx); VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT 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); @@ -260,7 +267,7 @@ sft FAR *idx_to_sft(COUNT SftIndex); COUNT get_sft_idx(UCOUNT hndl); /*dosidle.asm */ -VOID DosIdle_int(void); +VOID ASMCFUNC DosIdle_int(void); /* dosnames.c */ VOID SpacePad(BYTE *, COUNT); @@ -268,7 +275,8 @@ COUNT ParseDosName(BYTE *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); /* COUNT ParseDosPath(BYTE *, COUNT *, BYTE *, BYTE FAR *); */ /* dsk.c */ -COUNT FAR blk_driver(rqptr rp); +COUNT FAR ASMCFUNC blk_driver(rqptr rp); +ddt *getddt(int dev); /* error.c */ VOID dump(void); @@ -312,7 +320,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); -UWORD dos_free(struct dpb FAR *dpbp); +CLUSTER dos_free(struct dpb FAR *dpbp); VOID trim_path(BYTE FAR * s); @@ -327,15 +335,23 @@ 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); +#else VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp); +#endif /* fattab.c */ -UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2); -UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT 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); @@ -397,22 +413,22 @@ VOID fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n); */ VOID strcpy(REG BYTE * d, REG BYTE * s); #define scopy(s, d) strcpy(d,s) -VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); +VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); #define fbcopy(s, d, n) fmemcpy(d,s,n) /*VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);*/ -VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); #define fscopy(s,d) fstrcpy(d,s) -VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); /*VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n);*/ -void memcpy(REG void * d, REG VOID * s, REG COUNT n); +void ASMCFUNC memcpy(REG void * d, REG VOID * s, REG COUNT n); #define bcopy(s,d,n) memcpy(d,s,n) -void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void memset(REG VOID * s, REG int ch, 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); /* nls.c */ @@ -420,7 +436,7 @@ BYTE DosYesNo(unsigned char ch); #ifndef DosUpMem VOID DosUpMem(VOID FAR * str, unsigned len); #endif -unsigned char DosUpChar(unsigned char ch); +unsigned char ASMCFUNC DosUpChar(unsigned char ch); VOID DosUpString(char FAR *str); VOID DosUpFMem(VOID FAR *str, unsigned len); unsigned char DosUpFChar(unsigned char ch); @@ -435,7 +451,7 @@ COUNT DosSetCountry(UWORD cntry); #endif COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP); COUNT DosSetCodepage(UWORD actCP, UWORD sysCP); -UWORD syscall_MUX14(DIRECT_IREGS); +UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); @@ -444,38 +460,43 @@ WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...); VOID hexd(char *title,VOID FAR *p,COUNT numBytes); /* strings.c */ -COUNT strlen(REG BYTE * s); -COUNT fstrlen(REG BYTE FAR * s); -VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); -VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l); -COUNT strcmp(REG BYTE * d, REG BYTE * s); -COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); -COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); -COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l); +COUNT ASMCFUNC strlen(REG BYTE * s); +COUNT ASMCFUNC fstrlen(REG BYTE FAR * s); +VOID ASMCFUNC _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +VOID ASMCFUNC strncpy(REG BYTE * d, REG BYTE * s, COUNT l); +COUNT ASMCFUNC strcmp(REG BYTE * d, REG BYTE * s); +COUNT ASMCFUNC fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); +COUNT ASMCFUNC fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); +COUNT ASMCFUNC strncmp(REG BYTE * d, REG BYTE * s, COUNT l); /* void fsncopy(REG BYTE FAR * s, REG BYTE FAR * d, COUNT l); #define fstrncpy(d,s,l) fsncopy(s,d,l) */ -void fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, 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 *strchr(BYTE * s, BYTE c); +BYTE * ASMCFUNC strchr(BYTE * s, BYTE c); /* sysclk.c */ -WORD FAR clk_driver(rqptr rp); +WORD FAR ASMCFUNC clk_driver(rqptr rp); COUNT BcdToByte(COUNT x); COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); COUNT ByteToBcd(COUNT x); LONG WordToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); +/* syspack.c */ +#ifdef NONNATIVE +VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp); +VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp); +#else +#define getdirent(vp, dp) fmemcpy(dp, vp, sizeof(struct dirent)) +#define putdirent(dp, vp) fmemcpy(vp, dp, sizeof(struct dirent)) +#endif + /* syscon.c */ WORD con_driver(rqptr rp); VOID break_handler(void); -/* syspack.c */ -VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp); -VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp); - /* systime.c */ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); @@ -499,11 +520,11 @@ VOID InitPSP(VOID); int SetJFTSize(UWORD nHandles); int DosMkTmp(BYTE FAR * pathname, UWORD attr); COUNT get_verify_drive(char FAR * src); -COUNT truename(char FAR * src, char FAR * dest, COUNT t); +COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t); /* network.c */ -COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); -COUNT QRemote_Fn(char FAR * s, char FAR * d); +COUNT ASMCFUNC int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); +COUNT ASMCFUNC QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); @@ -511,7 +532,7 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e COUNT Remote_find(UWORD func); /* procsupt.asm */ -VOID INRPT FAR exec_user(iregs FAR * irp); +VOID ASMCFUNC exec_user(iregs FAR * irp); /* detect.c */ unsigned long FAR is_dosemu(void); @@ -527,4 +548,11 @@ unsigned long FAR is_dosemu(void); ASSERT_CONST( (BYTE FAR *)x->fcb_ext - (BYTE FAR *)x->fcbname == 8) */ -#define ASSERT_CONST(x) { typedef struct { char x[2 * (x) - 1]; } xx ; } +#define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; } + +#if defined(WATCOM) && 0 +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 */ +#endif diff --git a/kernel/segs.inc b/kernel/segs.inc index c550eeb..3a39e58 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.9 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.8 2001/07/09 22:19:33 bartoldeman ; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings ; @@ -71,9 +74,9 @@ group PGROUP PSP group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA +group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA DCONST group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END -group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E +group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E IC IDATA segment PSP class=PSP segment _TEXT class=CODE @@ -84,6 +87,8 @@ segment _DATA class=DATA align=2 segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS +;for MSC +segment DCONST class=DCONST align=2 segment DYN_DATA class=DYN_DATA segment HMA_TEXT_START class=HMA align=16 segment HMA_TEXT class=HMA @@ -94,7 +99,9 @@ segment INIT_TEXT_END class=INIT segment ID_B class=ID align=2 segment ID class=ID align=2 segment ID_E class=ID align=2 +segment IDATA class=ID align=2 segment IB_B class=IB align=2 segment IB class=IB align=2 segment IB_E class=IB align=2 +segment IC class=IC align=2 diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 5fd3707..8fe7108 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.8 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -102,9 +105,9 @@ static BYTE *RcsId = "$Id$"; */ #ifdef PROTO -BOOL ReadPCClock(ULONG *); -VOID WriteATClock(BYTE *, BYTE, BYTE, BYTE); -VOID WritePCClock(ULONG); +BOOL ASMCFUNC ReadPCClock(ULONG *); +VOID ASMCFUNC WriteATClock(BYTE *, BYTE, BYTE, BYTE); +VOID ASMCFUNC WritePCClock(ULONG); COUNT BcdToByte(COUNT); COUNT BcdToWord(BYTE *, UWORD *, UWORD *, UWORD *); COUNT ByteToBcd(COUNT); @@ -141,14 +144,14 @@ static ULONG Ticks; */ UWORD DaysSinceEpoch = 0; -BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); +BOOL ASMCFUNC ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); static COUNT BcdToByte(COUNT x) { return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); } -WORD FAR clk_driver(rqptr rp) +WORD FAR ASMCFUNC clk_driver(rqptr rp) { COUNT c; diff --git a/kernel/syspack.c b/kernel/syspack.c index 3e7d1ee..2947bac 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -36,6 +36,9 @@ static BYTE *syspackRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -134,7 +137,6 @@ VOID fputbyte(BYTE FAR * bp, VOID FAR * vp) { *(BYTE FAR *) vp = *bp; } -#endif VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp) { @@ -162,3 +164,4 @@ VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp) for (i = 0, p = (BYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++) *p++ = NULL; } +#endif \ No newline at end of file diff --git a/kernel/task.c b/kernel/task.c index 1420480..a7bbd8e 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.17 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -191,10 +194,6 @@ static exe_header header; + 1 byte: '\0' -- 1999/04/21 ska */ -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - #ifndef PROTO COUNT ChildEnv(exec_blk FAR *, UWORD *, char far *); #else @@ -326,7 +325,7 @@ VOID new_psp(psp FAR * p, int psize) /* CP/M-like entry point - jump to special entry */ p->ps_farcall = 0xea; - p->ps_reentry = cpm_entry; + p->ps_reentry = (VOID(FAR *) ())cpm_entry; /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ p->ps_unix[0] = 0xcd; p->ps_unix[1] = 0x21; @@ -347,11 +346,11 @@ VOID new_psp(psp FAR * p, int psize) p->ps_dta = (BYTE FAR *) (&p->ps_cmd_count); /* terminate address */ - p->ps_isv22 = (VOID(interrupt FAR *) (void))getvec(0x22); + p->ps_isv22 = (VOID(INRPT FAR *) (void))getvec(0x22); /* break address */ - p->ps_isv23 = (VOID(interrupt FAR *) (void))getvec(0x23); + p->ps_isv23 = (VOID(INRPT FAR *) (void))getvec(0x23); /* critical error address */ - p->ps_isv24 = (VOID(interrupt FAR *) (void))getvec(0x24); + p->ps_isv24 = (VOID(INRPT FAR *) (void))getvec(0x24); /* File System parameters */ /* user stack pointer - int 21 */ @@ -465,7 +464,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) LONG com_size; int ModeLoadHigh = mode & 0x80; - int UMBstate = uppermem_link; + UBYTE UMBstate = uppermem_link; mode &= 0x7f; @@ -522,7 +521,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if ( ModeLoadHigh && uppermem_root) { - DosUmbLink(UMBstate); /* restore link state */ + DosUmbLink(UMBstate); /* restore link state */ } @@ -684,7 +683,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) LONG exe_size; int ModeLoadHigh = mode & 0x80; - int UMBstate = uppermem_link; + UBYTE UMBstate = uppermem_link; mode &= 0x7f; diff --git a/sys/sys.mak b/sys/sys.mak index 80f72b2..50d8323 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.9 2001/09/23 20:39:44 bartoldeman +# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +# # Revision 1.8 2001/04/29 17:34:41 bartoldeman # A new SYS.COM/config.sys single stepping/console output/misc fixes. # @@ -49,7 +52,7 @@ !include "..\config.mak" CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -DI86;PROTO;FORSYS + -DI86;PROTO;FORSYS;WITHFAT32 # *Implicit Rules* .c.obj: @@ -77,6 +80,9 @@ b_fat12.h: ..\boot\b_fat12.bin bin2c.com b_fat16.h: ..\boot\b_fat16.bin bin2c.com bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 +b_fat32.h: ..\boot\b_fat32.bin bin2c.com + bin2c ..\boot\b_fat32.bin b_fat32.h b_fat32 + #floppy.obj: ..\drivers\floppy.asm # $(NASM) -fobj -DSYS=1 ..\drivers\floppy.asm -o floppy.obj @@ -88,13 +94,13 @@ sys.com: $(EXE_dependencies) $(CLIB); clobber: clean - $(RM) sys.com b_fat12.h b_fat16.h + $(RM) sys.com b_fat12.h b_fat16.h b_fat32.h clean: $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me # *Individual File Dependencies* -sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h +sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h # RULES (DEPENDENCIES) # ----------------