Init DS=Init CS, fixed stack overflow problems and misc bugs.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@204 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2001-04-21 22:32:53 +00:00
parent cb411f4ddd
commit cb13571dab
29 changed files with 964 additions and 653 deletions

View File

@ -1,3 +1,28 @@
2001 Apr 21 - Build 2024
-------- Bart Oldeman (bart.oldeman@bristol.ac.uk)
+ Fixes Tom:
* fixed a missing close_dir in fatfs.c.
* many reductions of stack space requirements.
we hope this fixes some FAT corruption problems.
Bart:
* fixed "copy con" and INT21/AH=0B. The SFT_FEOF flag,
strangely enough, if true indicates NOT end-of-file.
Alan Kamrowski
* fixed intr: it wasn't putting the flags back correctly
and swapped si and bp.
+ Update Bart:
* Changed initialization data segment to its code segment.
This frees up a few more kb.
* This required some header reorganisation:
init-mod.h is for the init modules, globals.h for all the
others.
* Eliminated the master environment, as it is normally
managed by command.com, not by the kernel. This saves 512
bytes and command.com now copies a default environment from
0068:0000; this is in the DOS_PSP at 60:0.
* Moved low memory code segment to 70:0.
+ Add Tom:
* Default interrupt 6 handler (invalid opcode).
2001 Apr 16 - Build 2024
-------- Bart Oldeman (bart.oldeman@bristol.ac.uk)
+ Fixes * Use turboc.cfg to avoid long command lines; edit ALLCFLAGS

76
hdr/buffer.h Normal file
View File

@ -0,0 +1,76 @@
/****************************************************************/
/* */
/* buffer.h */
/* */
/* Sector buffer structure */
/* */
/* Copyright (c) 2001 */
/* Pasquale J. Villani */
/* All Rights Reserved */
/* */
/* This file is part of DOS-C. */
/* */
/* DOS-C is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version */
/* 2, or (at your option) any later version. */
/* */
/* DOS-C is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
/* the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with DOS-C; see the file COPYING. If not, */
/* write to the Free Software Foundation, 675 Mass Ave, */
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#ifdef MAIN
#ifdef VERSION_STRINGS
static BYTE *buffer_hRcsId = "$Id$";
#endif
#endif
/*
* $Log$
* Revision 1.1 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Rev 1.0 20 Apr 2001 17:30:00 Bart Oldeman
* Initial revision.
*/
#define BUFFERSIZE 512
struct buffer
{
struct buffer
FAR *b_next; /* form linked list for LRU */
BYTE b_unit; /* disk for this buffer */
BYTE b_flag; /* buffer flags */
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) */
#if 0 /*TE*/
union
{
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 */
};
#define b_dpbp _b._b_dpbp
#define b_huge_blkno _b._b_huge_blkno
#define BFR_DIRTY 0x40 /* buffer modified */
#define BFR_VALID 0x20 /* buffer contains valid data */
#define BFR_DATA 0x08 /* buffer is from data area */
#define BFR_DIR 0x04 /* buffer is from dir area */
#define BFR_FAT 0x02 /* buffer is from fat area */
#define BFR_BOOT 0x01 /* buffer is boot disk */

View File

@ -36,6 +36,9 @@ static BYTE *file_hRcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.3 2000/05/25 20:56:19 jimtabor
* Fixed project history
*
@ -78,6 +81,18 @@ static BYTE *file_hRcsId = "$Id$";
* Initial revision.
*/
/* 0 = CON, standard input, can be redirected */
/* 1 = CON, standard output, can be redirected */
/* 2 = CON, standard error */
/* 3 = AUX, auxiliary */
/* 4 = PRN, list device */
/* 5 = 1st user file ... */
#define STDIN 0
#define STDOUT 1
#define STDERR 2
#define STDAUX 3
#define STDPRN 4
#define O_RDONLY SFT_MREAD
#define O_WRONLY SFT_MWRITE
#define O_RDWR SFT_MRDWR

View File

@ -44,3 +44,4 @@ static BYTE *date_hRcsId = "$Id$";
#define REVISION_MINOR 1
#define REVISION_SEQ 24
#define BUILD 2024
#define SUB_BUILD "a"

View File

@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$";
/*
* $Log$
* Revision 1.9 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.8 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes.
*
@ -232,14 +235,17 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno)
/*
this searches the buffer list for the given disk/block.
if found, the buffer is returned.
returns:
TRUE:
the buffer is found
FALSE:
the buffer is not found
*Buffp contains a block to flush and reuse later
if not found, NULL is returned, and *pReplacebp
contains a buffer to throw out.
*/
struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
struct buffer FAR ** pReplacebp)
BOOL searchblock(ULONG blkno, COUNT dsk,
struct buffer FAR ** pBuffp)
{
int fat_count = 0;
struct buffer FAR *bp;
@ -271,8 +277,8 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
#ifdef DISPLAY_GETBLOCK
printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp));
#endif
return (bp);
*pBuffp = bp;
return TRUE;
}
if (bp->b_flag & BFR_FAT)
@ -290,7 +296,8 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
{
lbp = lastNonFat;
}
*pReplacebp = lbp;
*pBuffp = lbp;
#ifdef DISPLAY_GETBLOCK
printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp));
@ -306,7 +313,7 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
firstbuf = lbp;
}
return NULL;
return FALSE;
}
@ -322,16 +329,13 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
{
struct buffer FAR *bp;
struct buffer FAR *Replacebp;
/* Search through buffers to see if the required block */
/* is already in a buffer */
bp = searchblock(blkno, dsk, &Replacebp);
if (bp)
if (searchblock(blkno, dsk, &bp))
{
return (bp);
}
@ -341,14 +345,22 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
/* take the buffer that lbp points to and flush it, then read new block. */
if (flush1(Replacebp) && fill(Replacebp, blkno, dsk)) /* success */
{
return Replacebp;
}
else
{
return NULL;
}
if (!flush1(bp))
return NULL;
/* Fill the indicated disk buffer with the current track and sector */
if (dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD))
{
return NULL;
}
bp->b_flag = BFR_VALID | BFR_DATA;
bp->b_unit = dsk;
setblkno(bp, blkno);
return bp;
}
/*
@ -365,14 +377,11 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk)
{
struct buffer FAR *bp;
struct buffer FAR *Replacebp;
/* Search through buffers to see if the required block */
/* is already in a buffer */
bp = searchblock(blkno, dsk, &Replacebp);
if (bp)
if (searchblock(blkno, dsk, &bp))
{
*pbp = bp;
return TRUE;
@ -382,12 +391,12 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk)
/* available. */
/* take the buffer than lbp points to and flush it, then make it available. */
if (flush1(Replacebp)) /* success */
if (flush1(bp)) /* success */
{
Replacebp->b_flag = 0;
Replacebp->b_unit = dsk;
setblkno(Replacebp, blkno);
*pbp = Replacebp;
bp->b_flag = 0;
bp->b_unit = dsk;
setblkno(bp, blkno);
*pbp = bp;
return TRUE;
}
else
@ -494,29 +503,6 @@ BOOL flush(void)
return (ok);
}
/* */
/* Fill the indicated disk buffer with the current track and sector */
/* */
/* This function assumes that the buffer is ready for use and that the
sector is not already in the buffer ring */
BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk)
{
/* Changed 9/4/00 BER */
UWORD result;
result = dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD);
/* End of change */
bp->b_flag = BFR_VALID | BFR_DATA;
bp->b_unit = dsk;
setblkno(bp, blkno);
/* Changed 9/4/00 BER */
if(result==0) return(TRUE); /* Temporary code to convert the result to */
else return(FALSE); /* the old BOOL result...BER */
/* return (result); This is what should eventually be returned */
/* End of change */
}
/************************************************************************/
/* */

View File

@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$";
/*
* $Log$
* Revision 1.7 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.6 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -295,19 +298,21 @@ static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp)
}
}
VOID sti(keyboard FAR * kp)
/* return number of characters before EOF if there is one, else just the total */
UCOUNT sti(keyboard FAR * kp)
{
REG UWORD c,
cu_pos = scr_pos;
UWORD
virt_pos = scr_pos;
WORD init_count = kp->kb_count;
BOOL eof = FALSE;
#ifndef NOSPCL
static BYTE local_buffer[LINESIZE];
#endif
if (kp->kb_size == 0)
return;
return eof;
if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR)
kp->kb_count = 0;
FOREVER
@ -391,7 +396,10 @@ VOID sti(keyboard FAR * kp)
(BYTE FAR *) local_buffer, (COUNT) kp->kb_count);
local_buffer[kp->kb_count] = '\0';
#endif
return;
if (eof)
return eof;
else
return kp->kb_count;
case LF:
sto(CR);
@ -405,8 +413,12 @@ VOID sti(keyboard FAR * kp)
for (c = 0; c < cu_pos; c++)
sto(' ');
kp->kb_count = init_count;
eof = FALSE;
break;
case CTL_Z:
eof = kp->kb_count;
/* fall through */
default:
kbfill(kp, c, FALSE, &virt_pos);
break;

View File

@ -27,12 +27,52 @@
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#define CONFIG
#include "portab.h"
#include "init-mod.h"
#include "portab.h"
#include "globals.h"
#include "nls.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
after use. I hope to clean this up to use the DOS List of List and Swappable
Data Area obtained via INT21.
-- Bart
*/
extern struct buffer FAR * FAR lastbuf;/* tail of ditto */
extern struct f_node FAR * 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 UBYTE FAR lastdrive, FAR nblkdev, FAR mem_access_mode,
FAR 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 */
extern struct dpb FAR * FAR DPBp;
/* First drive Parameter Block */
extern cdstbl FAR * FAR CDSp;
/* Current Directory Structure */
extern sfttbl FAR * FAR sfthead;
/* System File Table head */
extern sfttbl FAR * FAR FCBp;
extern BYTE FAR VgaSet,
FAR _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;
extern UWORD FAR ram_top, /* How much ram in Kbytes */
FAR UMB_top,
FAR umb_start,
FAR uppermem_root;
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
@ -40,6 +80,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.21 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.20 2001/04/16 14:44:29 bartoldeman
* Removed debug printf.
*
@ -178,28 +221,44 @@ static BYTE *RcsId = "$Id$";
* Added NLS, int2f and config.sys processing
*/
#ifdef __TURBOC__
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
#define int3() __int__(3);
#endif
#ifdef KDB
#include <alloc.h>
#define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x)))
#endif
BYTE FAR *lpBase = 0;
BYTE FAR *upBase = 0;
static BYTE FAR *lpOldLast = 0;
static COUNT nCfgLine = 0;
static COUNT nPass = 0;
COUNT UmbState = 0;
static BYTE szLine[256]={0};
static BYTE szBuf[256]={0};
struct config Config
=
{
NUMBUFF,
NFILES,
NFCBS,
0,
"command.com",
" /P\r\n",
NLAST,
NSTACKS,
128
/* COUNTRY= is initialized within DoConfig() */
,0 /* country ID */
,0 /* codepage */
,"" /* filename */
,0 /* amount required memory */
,0 /* pointer to loaded data */
,0 /* strategy for command.com is low by default */
}
;
int singleStep = 0;
BYTE FAR *lpBase;
BYTE FAR *upBase;
static BYTE FAR *lpOldLast;
static COUNT nCfgLine;
static COUNT nPass;
COUNT UmbState;
static BYTE szLine[256];
static BYTE szBuf[256];
int singleStep;
INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size);
INIT VOID mumcb_init(mcb FAR * mcbp, UWORD size);
@ -234,10 +293,6 @@ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s);
extern void HMAconfig(int finalize);
VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */
extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len);
INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr);
#ifndef I86
#define AlignParagraph(x) (x)
@ -287,7 +342,7 @@ INIT BYTE FAR *KernelAllocDma(WORD);
BYTE *pLineStart;
BYTE HMATextIsAvailable = 0;
BYTE HMATextIsAvailable;
void FAR * ConfigAlloc(COUNT bytes)
{
@ -320,7 +375,10 @@ INIT void PreConfig(void)
lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart);
#ifdef DEBUG
{
extern BYTE FAR internal_data[];
printf("SDA located at 0x%p\n", internal_data);
}
#endif
/* Begin by initializing our system buffers */
/* the dms_scratch buffer is statically allocated
@ -447,7 +505,6 @@ INIT void PostConfig(void)
#ifdef DEBUG
printf("f_node allocated at 0x%p\n",f_nodes);
printf("FCB table allocated at 0x%p\n",FCBp);
printf("sft table allocated at 0x%p\n",sfthead);
@ -532,12 +589,12 @@ INIT VOID DoConfig(VOID)
/* Check to see if we have a config.sys file. If not, just */
/* exit since we don't force the user to have one. */
if ((nFileDesc = init_DosOpen("fdconfig.sys", 0)) < 0)
if ((nFileDesc = open("fdconfig.sys", 0)) < 0)
{
#ifdef DEBUG
printf("FDCONFIG.SYS not found\n");
#endif
if ((nFileDesc = init_DosOpen("config.sys", 0)) < 0)
if ((nFileDesc = open("config.sys", 0)) < 0)
{
#ifdef DEBUG
printf("CONFIG.SYS not found\n");
@ -578,7 +635,7 @@ INIT VOID DoConfig(VOID)
/* Read a line from config */
/* Interrupt processing if read error or no bytes read */
if ((nRetCode = init_DosRead(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0)
if ((nRetCode = read(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0)
break;
/* If the buffer was not filled completely, append a
@ -653,7 +710,7 @@ INIT VOID DoConfig(VOID)
pLine += strlen(pLine) + 1;
}
}
init_DosClose(nFileDesc);
close(nFileDesc);
}
INIT struct table *LookUp(struct table *p, BYTE * token)
@ -671,14 +728,10 @@ INIT struct table *LookUp(struct table *p, BYTE * token)
INIT BOOL SkipLine(char *pLine)
{
char kbdbuf[16];
keyboard *kp = (keyboard *) kbdbuf;
char *pKbd = &kp->kb_buf[0];
kp->kb_size = 12;
kp->kb_count = 0;
char *pKbd = kbdbuf;
printf("%s [Y,N]?", pLine);
sti(kp);
read(STDIN, kbdbuf, 12);
pKbd = skipwh(pKbd);
@ -809,7 +862,7 @@ INIT static VOID Dosmem(BYTE * pLine)
BYTE *pTmp;
BYTE UMBwanted = FALSE, HMAwanted = FALSE;
extern BYTE INITDataSegmentClaimed;
/* extern BYTE FAR INITDataSegmentClaimed; */
pLine = GetStringArg(pLine, szBuf);
@ -822,7 +875,7 @@ INIT static VOID Dosmem(BYTE * pLine)
{
if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; }
if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; }
if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }
/* if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/
pTmp = skipwh(pTmp);
if (*pTmp != ',')
@ -1046,40 +1099,18 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
#endif
if (DosExec(3, &eb, szBuf) == SUCCESS)
if (init_DosExec(3, &eb, szBuf) == SUCCESS)
{
/* that's a nice hack >:-)
although we don't want HIMEM.SYS,(it's not free), other people
might load HIMEM.SYS to see if they are compatible to it.
strcpy(szBuf, pLine);
if it's HIMEM.SYS, we won't survive TESTMEM:ON
so simply add TESTMEM:OFF to the commandline
*/
if (DosLoadedInHMA)
if (stristr(szBuf, "HIMEM.SYS") != NULL)
{
if (stristr(pLine, "/TESTMEM:OFF") == NULL)
{
strcpy(szBuf+2, pLine);
pLine=szBuf+2;
strcat(pLine, " /TESTMEM:OFF");
}
}
/* end of HIMEM.SYS HACK */
/* add \r\n to the command line */
pLine-=2;
strcpy(pLine, pLine+2);
strcat(pLine, "\r\n");
strcat(szBuf, "\r\n");
/* TE this fixes the loading of devices drivers with
multiple devices in it. NUMEGA's SoftIce is such a beast
*/
for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff &&
(result=init_device(dhp, pLine, mode, top))==SUCCESS
(result=init_device(dhp, szBuf, mode, top))==SUCCESS
; dhp = next_dhp)
{
next_dhp = dhp->dh_next;

View File

@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$";
* /// Added SHARE support. 2000/09/04 Ron Cemer
*
* $Log$
* Revision 1.16 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.15 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes.
*
@ -354,10 +357,12 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err,
{
kb_buf.kb_size = LINESIZE - 1;
kb_buf.kb_count = 0;
sti((keyboard FAR *) & kb_buf);
ReadCount = sti((keyboard FAR *) & kb_buf);
if (ReadCount < kb_buf.kb_count)
s->sft_flags &= ~SFT_FEOF;
fbcopy((BYTE FAR *) kb_buf.kb_buf, bp, kb_buf.kb_count);
*err = SUCCESS;
return kb_buf.kb_count;
return ReadCount;
}
else
{
@ -404,10 +409,12 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err,
return 0;
}
#if 0
UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
{
return GenericRead(hndl, n, bp, err, FALSE);
}
#endif
UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
{
@ -451,7 +458,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err)
request rq;
/* set to no EOF */
s->sft_flags &= ~SFT_FEOF;
s->sft_flags |= SFT_FEOF;
/* if null just report full transfer */
if (s->sft_flags & SFT_FNUL)
@ -1361,11 +1368,8 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp)
or cleanup, such as converting "c:\a\b\.\c\.." to "C:\A\B".
- Ron Cemer
*/
BYTE tmp_name[128];
int i;
for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i];
tmp_name[i] = '\0';
return dos_getfattr(tmp_name, attrp);
memcpy(SecPathName,PriPathName,sizeof(SecPathName));
return dos_getfattr(SecPathName, attrp);
}
}
@ -1402,21 +1406,21 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp)
to get trashed somewhere in transit.
- Ron Cemer
*/
BYTE tmp_name[128];
int i;
for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i];
tmp_name[i] = '\0';
return dos_setfattr(name, attrp);
}
memcpy(SecPathName,PriPathName,sizeof(SecPathName));
return dos_setfattr(SecPathName, attrp);
}
}
UBYTE DosSelectDrv(UBYTE drv)
{
struct cds FAR *cdsp = &CDSp->cds_table[drv];
if ((drv < lastdrive) && (cdsp->cdsFlags & CDSVALID) &&
if ((drv < lastdrive) && (cdsp->cdsFlags & CDSVALID))
/*
&&
((cdsp->cdsFlags & CDSNETWDRV) ||
(cdsp->cdsDpb!=NULL && media_check(cdsp->cdsDpb)==SUCCESS)))
*/
{
current_ldt = cdsp;
default_drive = drv;

View File

@ -28,6 +28,9 @@
; $Id$
;
; $Log$
; Revision 1.13 2001/04/21 22:32:53 bartoldeman
; Init DS=Init CS, fixed stack overflow problems and misc bugs.
;
; Revision 1.12 2001/04/16 14:28:32 bartoldeman
; Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs
;
@ -191,6 +194,7 @@ cpm_error: mov al,0
; NOTE: On exit, DS must point to kernel stack, SS:SP user stack after
; PUSH$ALL and BP == SP.
;
%if 0 ; this is dead code now
_RestartSysCall:
cli ; no interrupts
mov bp,word [_lpUserStack+2] ;Get frame
@ -200,6 +204,7 @@ _RestartSysCall:
sti
POP$ALL ; get the original regs
jmp short int21_reentry ; restart the system call
%endif
;
@ -235,6 +240,14 @@ zero_done:
mov ax,04c7fh ; terminate with errorlevel 127
int 21h
invalid_opcode_message db 0dh,0ah,'Invalid Opcode',0dh,0ah,0
global reloc_call_int6_handler
reloc_call_int6_handler:
mov si,invalid_opcode_message
jmp short zero_message_loop
;
; Terminate the current process
;
@ -273,11 +286,10 @@ reloc_call_int21_handler:
; NB: At this point, SS != DS and won't be set that way
; until later when which stack to run on is determined.
;
int21_reentry_crit:
int21_reentry:
mov dx,DGROUP
mov ds,dx
int21_reentry:
cmp ah,33h
je int21_user
cmp ah,50h
@ -691,4 +703,4 @@ CritErrAbort:
mov ax,4C00h
mov [bp+reg_ax],ax
sti
jmp int21_reentry_crit ; restart the system call
jmp int21_reentry ; restart the system call

View File

@ -30,6 +30,9 @@
; $Id$
;
; $Log$
; Revision 1.7 2001/04/21 22:32:53 bartoldeman
; Init DS=Init CS, fixed stack overflow problems and misc bugs.
;
; Revision 1.6 2001/04/15 03:21:50 bartoldeman
; See history.txt for the list of fixes.
;
@ -102,7 +105,7 @@ segment HMA_TEXT
_execrh:
push bp ; perform c entry
mov bp,sp
push bx ; random char on display
; push bx ; random char on display
push si
push es ; sometimes it get lost
push ds ; sp=bp-8
@ -129,6 +132,6 @@ _execrh:
pop ds
pop es
pop si
pop bx
; pop bx
pop bp
ret

View File

@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.16 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.15 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -823,7 +826,10 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2)
COUNT ret;
if ((ret = extend_dir(fnp2)) != SUCCESS)
{
dir_close(fnp1);
return ret;
}
}
if (!find_fname(fnp1, szPriFileName, szPriFileExt))
@ -1411,7 +1417,6 @@ COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode)
{
ULONG idx;
UWORD clssize;
UWORD secsize;
#ifdef DISPLAY_GETBLOCK
printf("map_cluster: current %lu, offset %lu, diff=%lu ",
@ -1419,8 +1424,7 @@ COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode)
fnp->f_offset - fnp->f_cluster_offset);
#endif
/* The variable clssize will be used later. */
secsize = fnp->f_dpb->dpb_secsize;
clssize = secsize * (fnp->f_dpb->dpb_clsmask + 1);
clssize = 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. */

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.5 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.4 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes.
*
@ -280,7 +283,7 @@ 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, REG UCOUNT ClusterNum)
UWORD next_cluster(struct dpb FAR *dpbp, UCOUNT ClusterNum)
{
if (ISFAT12(dpbp))
return next_cl12(dpbp, ClusterNum);
@ -290,11 +293,9 @@ UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum)
return LONG_LAST_CLUSTER;
}
UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum)
UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum)
{
UCOUNT idx;
struct buffer FAR *bp;
UWORD RetCluster;
/* Get the block that this cluster is in */
bp = getblock((ULONG) (((ULONG) ClusterNum) * SIZEOF_CLST16) / dpbp->dpb_secsize + dpbp->dpb_fatstrt,
@ -310,15 +311,29 @@ UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum)
bp->b_offset_lo = dpbp->dpb_fatsize;
bp->b_offset_hi = dpbp->dpb_fatsize >> 8;
#ifndef I86
UCOUNT idx;
UWORD RetCluster;
/* form an index so that we can read the block as a */
/* byte array */
idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize;
/* Get the cluster number, */
fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster);
/* and return successful. */
return RetCluster;
#else
/* this saves 2 WORDS of stack :-) */
return *(WORD FAR *)&(bp->b_buffer[(ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize]);
#endif
}
UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum)

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.10 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.9 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes.
*
@ -148,6 +151,10 @@ BOOL FcbCalcRec();
VOID MoveDirInfo();
#endif
#define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL)
#define TestFieldSeps(lpFileName) (*(lpFileName) <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL)
static dmatch Dmatch;
VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps,
@ -265,6 +272,7 @@ BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName)
return lpFileName;
}
#if 0 /* defined above */
BOOL TestCmnSeps(BYTE FAR * lpFileName)
{
BYTE *pszTest,
@ -275,7 +283,9 @@ BOOL TestCmnSeps(BYTE FAR * lpFileName)
return TRUE;
return FALSE;
}
#endif
#if 0
BOOL TestFieldSeps(BYTE FAR * lpFileName)
{
BYTE *pszTest,
@ -290,6 +300,8 @@ BOOL TestFieldSeps(BYTE FAR * lpFileName)
return TRUE;
return FALSE;
}
#endif
BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField,
COUNT nFieldSize, BOOL * pbWildCard)

View File

@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$";
/*
* $Log$
* Revision 1.12 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.11 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes.
*
@ -199,6 +202,7 @@ static BYTE *Globals_hRcsId = "$Id$";
#include "version.h"
#include "network.h"
#include "config.h"
#include "buffer.h"
/* JPP: for testing/debuging disk IO */
/*#define DISPLAY_GETBLOCK */
@ -226,26 +230,8 @@ static BYTE *Globals_hRcsId = "$Id$";
/* Constants and macros */
/* */
/* Defaults and limits - System wide */
#define PARSE_MAX 67 /* maximum # of bytes in path */
#define NFILES 16 /* number of files in table */
#define NFCBS 16 /* number of fcbs */
#define NSTACKS 8 /* number of stacks */
#define NLAST 6 /* last drive */
#define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */
#define NAMEMAX PARSE_MAX /* Maximum path for CDS */
#define NUMBUFF 6 /* Number of track buffers */
/* -- must be at least 3 */
/* 0 = CON, standard input, can be redirected */
/* 1 = CON, standard output, can be redirected */
/* 2 = CON, standard error */
/* 3 = AUX, auxiliary */
/* 4 = PRN, list device */
/* 5 = 1st user file ... */
#define STDIN 0
#define STDOUT 1
#define STDERR 2
#define STDAUX 3
#define STDPRN 4
/* internal error from failure or aborted operation */
#define ERROR -1
@ -296,45 +282,7 @@ static BYTE *Globals_hRcsId = "$Id$";
#ifdef LINESIZE
#undef LINESIZE
#endif
#define LINESIZE 256
/* */
/* Data structures and unions */
/* */
/* Sector buffer structure */
#define BUFFERSIZE 512
struct buffer
{
struct buffer
FAR *b_next; /* form linked list for LRU */
BYTE b_unit; /* disk for this buffer */
BYTE b_flag; /* buffer flags */
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) */
#if 0 /*TE*/
union
{
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 */
};
#define b_dpbp _b._b_dpbp
#define b_huge_blkno _b._b_huge_blkno
#define BFR_DIRTY 0x40 /* buffer modified */
#define BFR_VALID 0x20 /* buffer contains valid data */
#define BFR_DATA 0x08 /* buffer is from data area */
#define BFR_DIR 0x04 /* buffer is from dir area */
#define BFR_FAT 0x02 /* buffer is from fat area */
#define BFR_BOOT 0x01 /* buffer is boot disk */
#define LINESIZE KBD_MAXLENGTH
/* NLS character table type */
typedef BYTE *UPMAP;
@ -381,9 +329,6 @@ extern struct ClockRecord
/* */
/* Global variables */
/* */
GLOBAL
seg master_env; /* Master environment segment */
GLOBAL BYTE
os_major, /* major version number */
os_minor, /* minor version number */
@ -417,14 +362,17 @@ GLOBAL WORD bDumpRdWrParms
#endif
#endif
GLOBAL BYTE *copyright
GLOBAL BYTE copyright[]
#ifdef MAIN
#if 0
= "(C) Copyright 1995, 1996, 1997, 1998\nPasquale J. Villani\nAll Rights Reserved\n";
= "(C) Copyright 1995, 1996, 1997, 1998\nPasquale J. Villani\nAll Rights Reserved\n"
#else
;
= ""
#endif
#endif
;
GLOBAL BYTE *os_release
GLOBAL BYTE os_release[]
#ifdef MAIN
#if 0
= "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n\
@ -435,13 +383,13 @@ 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\
consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\
Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\
\n";
\n"
#else
= "FreeDOS kernel version %d.%d.%d (Build %d) [" __DATE__ " " __TIME__ "]\n\n";
= "FreeDOS kernel version %d.%d.%d"SUB_BUILD
" (Build %d"SUB_BUILD") [" __DATE__ " " __TIME__ "]\n\n"
#endif
#else
;
#endif
;
/* Globally referenced variables - WARNING: ORDER IS DEFINED IN */
/* KERNAL.ASM AND MUST NOT BE CHANGED. DO NOT CHANGE ORDER BECAUSE THEY */
@ -633,54 +581,6 @@ GLOBAL iregs
FAR * ustackp, /* user stack */
FAR * kstackp; /* kernel stack */
/* Start of configuration variables */
extern struct config
{
UBYTE cfgBuffers; /* number of buffers in the system */
UBYTE cfgFiles; /* number of available files */
UBYTE cfgFcbs; /* number of available FCBs */
UBYTE cfgProtFcbs; /* number of protected FCBs */
BYTE cfgInit[NAMEMAX]; /* init of command.com */
BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */
UBYTE cfgLastdrive; /* last drive */
BYTE cfgStacks; /* number of stacks */
UWORD cfgStackSize; /* stacks size for each stack */
/* COUNTRY=
In Pass #1 these information is collected and in PostConfig()
the NLS package is loaded into memory.
-- 2000/06/11 ska*/
WORD cfgCSYS_cntry; /* country ID to be loaded */
WORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */
BYTE cfgCSYS_fnam[NAMEMAX]; /* filename of COUNTRY= */
WORD cfgCSYS_memory; /* number of bytes required for the NLS pkg;
0 if none */
VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */
UBYTE cfgP_0_startmode; /* load command.com high or not */
} Config
#ifdef CONFIG
=
{
NUMBUFF,
NFILES,
NFCBS,
0,
"command.com",
" /P\r\n",
NLAST,
NSTACKS,
128
/* COUNTRY= is initialized within DoConfig() */
,0 /* country ID */
,0 /* codepage */
,"" /* filename */
,0 /* amount required memory */
,0 /* pointer to loaded data */
,0 /* strategy for command.com is low by default */
};
#else
;
#endif
/* */
/* Function prototypes - automatically generated */
/* */
@ -784,3 +684,5 @@ void handle_break(void); /* break.c */
GLOBAL BYTE ReturnAnyDosVersionExpected;
GLOBAL COUNT UnusedRetVal; /* put unused errors here (to save stack space) */

View File

@ -1,5 +1,30 @@
/* Used by `proto.h'. */
/* Included by initialisation functions */
#define IN_INIT_MOD
#include "version.h"
#include "date.h"
#include "time.h"
#include "mcb.h"
#include "sft.h"
#include "fat.h"
#include "fnode.h"
#include "file.h"
#include "dcb.h"
#include "cds.h"
#include "device.h"
#include "kbd.h"
#include "error.h"
#include "fcb.h"
#include "tail.h"
#include "process.h"
#include "pcb.h"
#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'.
@ -10,19 +35,155 @@
* calls for the latter functions therefore need to be wrapped up with far
* entry points.
*/
#define DosExec reloc_call_DosExec
#define DosMemAlloc reloc_call_DosMemAlloc
#define printf init_printf
#define execrh reloc_call_execrh
#define fatal reloc_call_fatal
#define fmemcpy reloc_call_fmemcpy
#define memcpy reloc_call_memcpy
#define fmemset reloc_call_fmemset
#define printf reloc_call_printf
#define memset reloc_call_memset
#define fstrncpy reloc_call_fstrncpy
#define strcpy reloc_call_strcpy
#define sti reloc_call_sti
#define strcmp reloc_call_strcmp
#define strlen reloc_call_strlen
#define WritePCClock reloc_call_WritePCClock
#define DaysFromYearMonthDay reloc_call_DaysFromYearMonthDay
#define p_0 reloc_call_p_0
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);
#undef LINESIZE
#define LINESIZE KBD_MAXLENGTH
#define fbcopy(s, d, n) fmemcpy(d,s,n)
/*inithma.c*/
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 fbcopy(s, d, n) fmemcpy(d,s,n)
#define GLOBAL extern
#define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */
#define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */
#define NFILES 16 /* number of files in table */
#define NFCBS 16 /* number of fcbs */
#define NSTACKS 8 /* number of stacks */
#define NLAST 6 /* last drive */
#define NUMBUFF 6 /* Number of track buffers */
/* -- must be at least 3 */
/* Start of configuration variables */
struct config
{
UBYTE cfgBuffers;
/* number of buffers in the system */
UBYTE cfgFiles;
/* number of available files */
UBYTE cfgFcbs;
/* number of available FCBs */
UBYTE cfgProtFcbs;
/* number of protected FCBs */
BYTE cfgInit[NAMEMAX];
/* init of command.com */
BYTE cfgInitTail[NAMEMAX];
/* command.com's tail */
UBYTE cfgLastdrive;
/* last drive */
BYTE cfgStacks;
/* number of stacks */
UWORD cfgStackSize;
/* stacks size for each stack */
/* COUNTRY=
In Pass #1 these information is collected and in PostConfig()
the NLS package is loaded into memory.
-- 2000/06/11 ska*/
WORD cfgCSYS_cntry;
/* country ID to be loaded */
WORD cfgCSYS_cp;
/* requested codepage; NLS_DEFAULT if default */
BYTE cfgCSYS_fnam[NAMEMAX];
/* filename of COUNTRY= */
WORD cfgCSYS_memory;
/* number of bytes required for the NLS pkg;
0 if none */
VOID FAR *cfgCSYS_data;
/* where the loaded data is for PostConfig() */
UBYTE cfgP_0_startmode;
/* load command.com high or not */
};
extern struct config Config;
/* config.c */
INIT VOID PreConfig(VOID);
INIT VOID DoConfig(VOID);
INIT VOID PostConfig(VOID);
INIT BYTE FAR *KernelAlloc(WORD nBytes);
INIT BYTE *skipwh(BYTE * s);
INIT BYTE *scan(BYTE * s, BYTE * d);
INIT BOOL isnum(BYTE * pszString);
INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum);
INIT COUNT tolower(COUNT c);
INIT COUNT toupper(COUNT c);
INIT VOID mcb_init(mcb FAR * mcbp, UWORD size);
INIT VOID strcat(REG BYTE * d, REG BYTE * s);
INIT BYTE FAR *KernelAlloc(WORD nBytes);
INIT COUNT Umb_Test(void);
INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString);
/* int2f.asm */
COUNT Umb_Test(void);
/* inithma.c */
int MoveKernelToHMA(void);
VOID FAR *HMAalloc(COUNT bytesToAllocate);
/* initoem.c */
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 COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
INIT VOID keycheck(VOID);
/* irqstack.asm */
VOID 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);
/* main.c */
INIT VOID main(void);
INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top);
INIT VOID init_fatal(BYTE * err_msg);
/* prf.c */
WORD init_printf(CONST BYTE * fmt,...);

View File

@ -64,10 +64,15 @@
*/
#include "portab.h"
#include "init-mod.h"
#include "portab.h"
#include "globals.h"
extern BYTE FAR version_flags; /* minor version number */
extern BYTE
FAR _HMATextAvailable, /* first byte of available CODE area */
FAR _HMATextStart[], /* first byte of HMAable CODE area */
FAR _HMATextEnd[]; /* and the last byte of it */
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
@ -75,6 +80,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.5 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.4 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -92,8 +100,8 @@ static BYTE *RcsId = "$Id$";
*/
BYTE DosLoadedInHMA; /* set to TRUE if loaded HIGH */
BYTE HMAclaimed; /* set to TRUE if claimed from HIMEM */
BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */
BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */
WORD HMAFree; /* first byte in HMA not yet used */
@ -387,16 +395,15 @@ int MoveKernelToHMA()
UWORD jmpSegment;
};
extern struct initRelocationTable
FAR _HMAinitRelocationTableStart[],
FAR _HMAinitRelocationTableEnd[];
struct initRelocationTable FAR *rp, FAR *endrp;
_HMAinitRelocationTableStart[],
_HMAinitRelocationTableEnd[];
struct initRelocationTable *rp;
/* verify, that all entries are valid */
UWORD HMATextSegment = FP_SEG( _HMATextStart );
endrp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableEnd));
for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++)
for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++)
{
if (
rp->callNear != 0xe8 || /* call NEAR */
@ -405,14 +412,14 @@ int MoveKernelToHMA()
0)
{
printf("illegal init relocation entry # %d\n",
FP_OFF(rp) - FP_OFF(_HMAinitRelocationTableStart));
rp - _HMAinitRelocationTableStart);
goto errorReturn;
}
}
/* OK, all valid, go to relocate*/
for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++)
for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++)
{
rp->jmpSegment = HMASEGMENT;
rp->callOffset = rp->callOffset-5; /* near calls are relative */

View File

@ -27,10 +27,8 @@
/* */
/****************************************************************/
#include "init-mod.h"
#include "portab.h"
#include "globals.h"
#include "init-mod.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
@ -38,6 +36,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history
*

View File

@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.22 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.21 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -486,9 +489,9 @@ dispatch:
/* Check Stdin Status */
case 0x0b:
if (StdinBusy())
r->AL = 0xFF;
else
r->AL = 0x00;
else
r->AL = 0xFF;
break;
/* Flush Buffer, Read Keayboard */

View File

@ -51,9 +51,9 @@ intr?2 mov bx, [bp+6] ; regpack structure
mov ax, [bx]
mov cx, [bx+4]
mov dx, [bx+6]
mov bp, [bx+8]
mov si, [bx+8]
mov di, [bx+10]
mov si, [bx+12]
mov bp, [bx+12]
push Word [bx+14] ; ds
mov es, [bx+16]
mov bx, [bx+2]
@ -73,14 +73,14 @@ intr?1:
mov [bx+2], ax
mov [bx+4], cx
mov [bx+6], dx
mov [bx+8], bp
mov [bx+8], si
mov [bx+10], di
mov [bx+12], si
mov [bx+12], bp
pop ax
mov [bx+14], ax
mov [bx+16], es
pop ax
mov [bx+18], ax
mov [bx+22], ax
pop es
pop ds
@ -120,9 +120,9 @@ init_intr?2 mov bx, [bp+6] ; regpack structure
mov ax, [bx]
mov cx, [bx+4]
mov dx, [bx+6]
mov bp, [bx+8]
mov si, [bx+8]
mov di, [bx+10]
mov si, [bx+12]
mov bp, [bx+12]
push Word [bx+14] ; ds
mov es, [bx+16]
mov bx, [bx+2]
@ -142,14 +142,14 @@ init_intr?1:
mov [bx+2], ax
mov [bx+4], cx
mov [bx+6], dx
mov [bx+8], bp
mov [bx+8], si
mov [bx+10], di
mov [bx+12], si
mov [bx+12], bp
pop ax
mov [bx+14], ax
mov [bx+16], es
pop ax
mov [bx+18], ax
mov [bx+22], ax
pop es
pop ds
@ -207,9 +207,9 @@ _keycheck:
int 16h
ret
;; COUNT init_DosOpen(BYTE *fname, COUNT mode)
global _init_DosOpen
_init_DosOpen:
;; int open(const char *pathname, int flags);
global _open
_open:
;; first implementation of init calling DOS through ints:
mov bx, sp
mov ah, 3dh
@ -217,34 +217,45 @@ _init_DosOpen:
mov al, [bx+4]
mov dx, [bx+2]
int 21h
common_exit:
jnc open_no_error
;; AX has file handle
neg ax
;; negative value for error code
open_no_error:
common_exit:
jnc common_no_error
common_error:
mov ax, -1
common_no_error:
ret
;; COUNT init_DosClose(COUNT hndl)
global _init_DosClose
_init_DosClose:
;; int close(int fd);
global _close
_close:
mov bx, sp
mov bx, [bx+2]
mov ah, 3eh
int 21h
jmp common_exit
jmp short common_exit
;; COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n)
global _init_DosRead
_init_DosRead:
;; UCOUNT read(int fd, void *buf, UCOUNT count);
global _read
_read:
mov bx, sp
mov cx, [bx+6]
mov dx, [bx+4]
mov bx, [bx+2]
mov ah, 3fh
int 21h
jmp common_exit
jmp short common_exit
;; int dup2(int oldfd, int newfd);
global _dup2
_dup2:
mov bx, sp
mov cx, [bx+4]
mov bx, [bx+2]
mov ah, 46h
int 21h
jmp short common_exit
;; VOID init_PSPInit(seg psp_seg)
global _init_PSPInit
_init_PSPInit:
@ -256,4 +267,34 @@ _init_PSPInit:
int 21h
pop si
ret
;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
global _init_DosExec
_init_DosExec:
mov ah, 4bh
mov bx, sp
mov al, [bx+2]
push ds
pop es
mov dx, [bx+6] ; filename
mov bx, [bx+4] ; exec block
int 21h
jc short exec_no_error
xor ax, ax
exec_no_error
ret
;; int allocmem(UWORD size, seg *segp)
global _allocmem
_allocmem:
mov ah, 48h
mov bx, sp
mov bx, [bx+2]
int 21h
jc short common_error
mov bx, sp
mov bx, [bx+4]
mov [bx], ax
xor ax, ax
ret

View File

@ -28,6 +28,9 @@
; $Header$
;
; $Log$
; Revision 1.8 2001/04/21 22:32:53 bartoldeman
; Init DS=Init CS, fixed stack overflow problems and misc bugs.
;
; Revision 1.7 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
@ -191,7 +194,7 @@ _Com4Dev dw _clk_dev,TGROUP
global _clk_dev
_clk_dev equ $
dw _blk_dev,TGROUP
dw 8004h ; clock device
dw 8008h ; clock device
dw GenStrategy
dw clk_entry
db 'CLOCK$ '
@ -540,13 +543,8 @@ blk_entry:
pushf
push ax
push bx
push cx
push dx
push bp
push si
push di
push ds
push es
; small model
mov ax,DGROUP ; correct for segments
@ -560,24 +558,39 @@ blk_entry:
mov sp,blk_stk_top
push bx
popf ; restore interrupt flag
mov bp,sp ; make a c frame
push cx ; push these registers on
push dx ; BLK_STACK
push bp ; to save stack space
push si
push di
push es
push word [cs:_ReqPktPtr+2]
push word [cs:_ReqPktPtr]
call far _reloc_call_blk_driver
pop cx
pop cx
les bx,[cs:_ReqPktPtr] ; now return completion code
mov word [es:bx+status],ax ; mark operation complete
cli ; no interrupts
mov sp,[blk_dos_stk] ; use dos stack
mov ss,[blk_dos_seg]
pop es
pop ds
pop di
pop si
pop bp
pop dx
pop cx
cli ; no interrupts
mov sp,[blk_dos_stk] ; use dos stack
mov ss,[blk_dos_seg]
pop ds
pop bx
pop ax
popf

View File

@ -28,6 +28,9 @@
; $Id$
;
; $Log$
; Revision 1.10 2001/04/21 22:32:53 bartoldeman
; Init DS=Init CS, fixed stack overflow problems and misc bugs.
;
; Revision 1.9 2001/04/15 03:21:50 bartoldeman
; See history.txt for the list of fixes.
;
@ -126,7 +129,7 @@
%include "segs.inc"
segment _TEXT
segment PSP
extern _ReqPktPtr:wrt TGROUP
@ -145,7 +148,7 @@ segment INIT_TEXT
; kernel start-up
;
kernel_start:
mov ax,DGROUP
mov ax,IGROUP
cli
mov ss,ax
mov sp,init_tos
@ -170,6 +173,8 @@ kernel_start:
push ax
retf
cont: ; inititalize api stacks for high water tests
mov ax,cs
mov ss,ax
mov di,seg apistk_bottom
mov es,di
mov di,apistk_bottom
@ -181,7 +186,7 @@ cont: ; inititalize api stacks for high water tests
cld
rep stosw
; Now set up call frame
mov ax,ss
mov ax,DGROUP
mov ds,ax
mov es,ax
mov bp,sp ; and set up stack frame for c
@ -196,12 +201,12 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from
inc al
mov byte [_NumFloppies],al ; and how many
mov ax,ds
mov ax,cs
mov ds,ax
mov es,ax
jmp _main
segment INIT_TEXT_END
init_end:
segment _TEXT
@ -271,7 +276,7 @@ _clock dd 0 ; 0008 CLOCK$ device
global _syscon
_syscon dd 0 ; 000c console device
global _maxbksize
_maxbksize dw 0 ; 0010 Number of Drives in system
_maxbksize dw 512 ; 0010 maximum bytes/sector of any block device
global _firstbuf;
_firstbuf dd 0 ; 0012 head of buffers linked list
global _CDSp
@ -286,7 +291,9 @@ _nblkdev db 0 ; 0020 number of block devices
_lastdrive db 0 ; 0021 value of last drive
global _nul_dev
_nul_dev: ; 0022 device chain root
dd -1
extern _con_dev:wrt TGROUP
dw _con_dev, seg _con_dev
; next is con_dev at init time.
dw 8004h ; attributes = char device, NUL bit set
dw _nul_strtgy
dw _nul_intr
@ -300,7 +307,7 @@ setverPtr dw 0,0 ; 0037 setver list
dw 1 ; 003F number of buffers
dw 1 ; 0041 size of pre-read buffer
global _BootDrive
_BootDrive db 0 ; 0043 drive we booted from
_BootDrive db 1 ; 0043 drive we booted from
db 0 ; 0044 cpu type (1 if >=386)
dw 0 ; 0045 Extended memory in KBytes
buf_info dd 0 ; 0047 disk buffer chain
@ -327,8 +334,6 @@ _umb_start dw 0 ; 0068 para of last mem search
SysVarEnd:
; We've got (01fb-006a) some room here: don't use all zeros!
; Some references seem to indicate that this data should start at 01fbh in
; order to maintain 100% MS-DOS compatibility.
@ -409,13 +414,14 @@ _CritErrCode dw 0 ; 04 - DOS format error Code
_CritErrAction db 0 ; 06 - Error Action Code
_CritErrClass db 0 ; 07 - Error Class
_CritErrDev dd 0 ; 08 - Failing Device Address
_dta dd 0 ; 0C - current DTA
_dta dw _TempBuffer, seg _TempBuffer
; 0C - current DTA, initialize to TempBuffer.
_cu_psp dw 0 ; 10 - Current PSP
break_sp dw 0 ; 12 - used in int 23
_return_code db 0 ; 14 - return code from process
_return_mode db 0 ; 15 - reason for process terminate
_default_drive db 0 ; 16 - Current Drive
_break_ena db 0 ; 17 - Break Flag
_break_ena db 1 ; 17 - Break Flag (default TRUE)
db 0 ; 18 - flag, code page switching
db 0 ; 19 - flag, copy of 18 on int 24h abort
@ -598,12 +604,23 @@ _ram_top dw 0
;
; mark front and end of bss area to clear
segment _BSSSTART
global __bssstart
__bssstart:
segment _BSSEND
global __bssend
__bssend:
segment IB_B
global __ib_start
__ib_start:
segment IB_E
global __ib_end
__ib_end:
;; do not clear the other init BSS variables + STACK: too late.
retoff resw 1 ; return offset to jump to from HMA_TEXT
; kernel startup stack
global init_tos
resw 256
init_tos:
; the last paragraph of conventional memory might become an MCB
resb 16
init_end:
segment _BSSEND
; blockdev private stack
@ -615,20 +632,16 @@ blk_stk_top:
global clk_stk_top
times 64 dw 0
clk_stk_top:
; this is nowhere needed
; interrupt stack
; global intr_stk_top
; times 256 dw 0
;intr_stk_top:
segment ID ; init data
retaddr dd 0 ; return address to jump to from HMA_TEXT
; kernel startup stack
global init_tos
times 256 dw 0
init_tos:
global __bssend
__bssend:
segment ID_B
global __INIT_DATA_START
__INIT_DATA_START:
@ -659,7 +672,9 @@ segment HMA_TEXT
times 16 db 0 ; filler [ffff:0..ffff:10]
times 22 db 0 ; filler [sizeof VDISK info]
init_ret: jmp far [retaddr] ; return from init_calls.
init_ret_np: push ds
push word [retoff]
retf ; return from init_calls.
;End of HMA segment
segment HMA_TEXT_END
@ -698,78 +713,39 @@ _DGROUP_:
segment INIT_TEXT
call far initforceEnableA20 ; first enable A20 or not
manip_stack_A20:
pop word [retaddr+2] ; get last ret address
pop word [retaddr] ; get near ret address of init caller
mov ax, init_ret ; new init caller ret address
manip_stack_A20:
pop dx ; get last ret address
pop word [retoff] ; get near ret address of init caller
mov ax, init_ret_np ; new init caller ret address
push ax
push word [retaddr+2] ; and back to the relocation entry
mov [retaddr+2], cs ; retaddr is now a far pointer to where we came from
ret
jmp dx ; and back to the relocation entry
global __HMAinitRelocationTableStart
__HMAinitRelocationTableStart:
extern _DosExec
global _reloc_call_DosExec
_reloc_call_DosExec:
call manip_stack_A20
jmp far _DosExec
extern _DosMemAlloc
global _reloc_call_DosMemAlloc
_reloc_call_DosMemAlloc:
call manip_stack_A20
jmp far _DosMemAlloc
extern _execrh
global _reloc_call_execrh
_reloc_call_execrh:
call manip_stack_A20
jmp far _execrh
extern _fatal
global _reloc_call_fatal
_reloc_call_fatal:
call manip_stack_A20
jmp far _fatal
extern _fmemcpy
global _reloc_call_fmemcpy
_reloc_call_fmemcpy:
call manip_stack_A20
jmp far _fmemcpy
extern _memcpy
global _reloc_call_memcpy
_reloc_call_memcpy:
call manip_stack_A20
jmp far _memcpy
extern _printf
global _reloc_call_printf
_reloc_call_printf:
call manip_stack_A20
jmp far _printf
extern _strcpy
global _reloc_call_strcpy
_reloc_call_strcpy:
call manip_stack_A20
jmp far _strcpy
extern _sti
global _reloc_call_sti
_reloc_call_sti:
extern _fstrncpy
global _reloc_call_fstrncpy
_reloc_call_fstrncpy:
call manip_stack_A20
jmp far _sti
extern _strcmp
global _reloc_call_strcmp
_reloc_call_strcmp:
call manip_stack_A20
jmp far _strcmp
jmp far _fstrncpy
extern _strlen
global _reloc_call_strlen
@ -777,17 +753,11 @@ _reloc_call_strlen:
call manip_stack_A20
jmp far _strlen
extern _WritePCClock
global _reloc_call_WritePCClock
_reloc_call_WritePCClock:
extern _fstrlen
global _reloc_call_fstrlen
_reloc_call_fstrlen:
call manip_stack_A20
jmp far _WritePCClock
extern _DaysFromYearMonthDay
global _reloc_call_DaysFromYearMonthDay
_reloc_call_DaysFromYearMonthDay:
call manip_stack_A20
jmp far _DaysFromYearMonthDay
jmp far _fstrlen
extern _fmemset
global _reloc_call_fmemset
@ -795,12 +765,12 @@ _reloc_call_fmemset:
call manip_stack_A20
jmp far _fmemset
extern _p_0
global _reloc_call_p_0
_reloc_call_p_0:
extern _memset
global _reloc_call_memset
_reloc_call_memset:
call manip_stack_A20
jmp far _p_0
jmp far _memset
global __HMAinitRelocationTableEnd
__HMAinitRelocationTableEnd:
@ -850,6 +820,11 @@ _int27_handler: jmp far reloc_call_int27_handler
_int0_handler: jmp far reloc_call_int0_handler
call near forceEnableA20
global _int6_handler
extern reloc_call_int6_handler
_int6_handler: jmp far reloc_call_int6_handler
call near forceEnableA20
global _cpm_entry
extern reloc_call_cpm_entry
_cpm_entry: jmp far reloc_call_cpm_entry

View File

@ -5,6 +5,9 @@
#
# $Log$
# Revision 1.10 2001/04/21 22:32:53 bartoldeman
# Init DS=Init CS, fixed stack overflow problems and misc bugs.
#
# Revision 1.9 2001/04/16 14:28:32 bartoldeman
# Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs
#
@ -134,7 +137,8 @@ INCLUDEPATH = ..\HDR
#AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR
NASMFLAGS = -i../hdr/
LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB
INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP -zDIB -zRID -zTID
INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB \
-zGIGROUP -zSIGROUP
CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT
HDR=../hdr/
@ -190,6 +194,7 @@ EXE_dependencies = \
nls_hc.obj \
nlssupt.obj \
prf.obj \
initprf.obj \
printer.obj \
procsupt.obj \
serial.obj \
@ -224,7 +229,7 @@ kernel.exe: $(EXE_dependencies) $(LIBS)
$(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs
$(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc
$(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr
$(LIBUTIL) kernel +dosnames +prf +strings +network +sysclk +syspack
$(LIBUTIL) kernel +dosnames +prf +initprf +strings +network +sysclk +syspack
$(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt
$(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break
$(LIBUTIL) kernel +dosidle
@ -299,6 +304,10 @@ initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \
$(HDR)version.h proto.h turboc.cfg
$(CC) $(INITCFLAGS) -c initHMA.c
#the printf for INIT_TEXT:
initprf.obj: prf.c $(HDR)portab.h turboc.cfg
$(CC) -DFORINIT $(INITCFLAGS) -oinitprf.obj -c prf.c
# XXX: I generated these using `gcc -MM' and `sed', so they may not be
# completely correct... -- ror4
blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \

View File

@ -27,10 +27,48 @@
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#include "portab.h"
#include "init-mod.h"
#include "portab.h"
#include "globals.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
after use. I hope to clean this up to use the DOS List of List and Swappable
Data Area obtained via INT21.
-- Bart
*/
extern UBYTE FAR nblkdev,
FAR lastdrive; /* value of last drive */
GLOBAL struct f_node FAR
* FAR f_nodes; /* pointer to the array */
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 */
GLOBAL BYTE FAR os_release[];
GLOBAL BYTE FAR copyright[];
GLOBAL seg FAR RootPsp; /* Root process -- do not abort */
GLOBAL struct f_node * FAR pDirFileNode;
extern struct dpb FAR * FAR DPBp; /* First drive Parameter Block */
extern cdstbl FAR * FAR CDSp; /* Current Directory Structure */
extern sfttbl FAR * FAR sfthead; /* System File Table head */
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 UWORD
FAR ram_top; /* How much ram in Kbytes */
extern iregs FAR * FAR user_r; /* User registers for int 21h call */
#ifdef VERSION_STRINGS
static BYTE *mainRcsId = "$Id$";
@ -38,6 +76,9 @@ static BYTE *mainRcsId = "$Id$";
/*
* $Log$
* Revision 1.15 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.14 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -168,18 +209,13 @@ static BYTE *mainRcsId = "$Id$";
* Initial revision.
*/
extern UWORD DaysSinceEpoch;
extern WORD days[2][13];
extern BYTE FAR * lpBase;
extern BYTE FAR * upBase;
INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *);
VOID WritePCClock(ULONG);
extern BYTE _ib_start[], _ib_end[];
INIT VOID configDone(VOID);
INIT static void InitIO(void);
INIT static COUNT BcdToByte(COUNT);
/** INIT static COUNT BcdToDay(BYTE *);*/
INIT static VOID update_dcb(struct dhdr FAR *);
INIT static VOID init_kernel(VOID);
@ -187,30 +223,16 @@ INIT static VOID signon(VOID);
INIT VOID kernel(VOID);
INIT VOID FsConfig(VOID);
#ifdef __TURBOC__
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
#endif
INIT VOID main(void)
{
setvec(0, int0_handler); /* zero divide */
setvec(1, empty_handler); /* single step */
setvec(3, empty_handler); /* debug breakpoint */
setvec(6, empty_handler); /* invalid opcode */
/* clear the Init BSS area (what normally the RTL does */
memset(_ib_start, 0, _ib_end - _ib_start);
#ifdef KDB
BootDrive = 1;
#endif
{ /* clear the BSS area (what normally the RTL does */
extern BYTE _bssstart[],_bssend[];
fmemset(_bssstart,0,_bssend-_bssstart);
}
init_kernel();
#ifdef DEBUG
@ -231,20 +253,17 @@ INIT VOID main(void)
at least one known utility (norton DE) seems to access them directly.
ok, so we access for all drives, that the stuff gets build
*/
/*
should not be necessary anymore (see DosSelectDrv in dosfns.c)
void InitializeAllBPBs(VOID)
{
static char filename[] = "A:-@JUNK@-.TMP";
int drive,fileno;
for (drive = 'Z'; drive >= 'C'; drive--)
for (drive = 'C'; drive < 'A'+nblkdev; drive++)
{
filename[0] = drive;
if ((fileno = init_DosOpen(filename, O_RDONLY)) >= 0)
init_DosClose(fileno);
if ((fileno = open(filename, O_RDONLY)) >= 0)
close(fileno);
}
}
*/
INIT void init_kernel(void)
{
@ -253,24 +272,12 @@ INIT void init_kernel(void)
os_major = MAJOR_RELEASE;
os_minor = MINOR_RELEASE;
nblkdev = 0;
maxbksize = 0x200;
switchar = '/';
dosidle_flag = 1;
/* Init oem hook - returns memory size in KB */
ram_top = init_oem();
UMB_top = 0;
umb_start = 0;
/* Fake int 21h stack frame */
user_r = (iregs FAR *) DOS_PSP + 0xD0;
/* Set Init DTA to Tempbuffer */
dta = (BYTE FAR *) &TempBuffer;
#ifndef KDB
for (i = 0x20; i <= 0x3f; i++)
setvec(i, empty_handler);
@ -278,8 +285,6 @@ INIT void init_kernel(void)
/* Initialize IO subsystem */
InitIO();
syscon = (struct dhdr FAR *)&con_dev;
clock = (struct dhdr FAR *)&clk_dev;
#ifndef KDB
/* set interrupt vectors */
@ -297,10 +302,6 @@ INIT void init_kernel(void)
setvec(0x2f, int2f_handler);
#endif
/* Initialize the screen handler for backspaces */
scr_pos = 0;
break_ena = TRUE;
init_PSPInit(DOS_PSP);
/* Do first initialization of system variable buffers so that */
@ -318,7 +319,7 @@ INIT void init_kernel(void)
/* Close all (device) files */
for (i = 0; i < lastdrive; i++)
init_DosClose(i);
close(i);
/* and do final buffer allocation. */
PostConfig();
@ -334,18 +335,13 @@ INIT void init_kernel(void)
/* Close all (device) files */
for (i = 0; i < lastdrive; i++)
init_DosClose(i);
close(i);
/* Now config the final file system */
FsConfig();
#endif
/* Now to initialize all special flags, etc. */
mem_access_mode = FIRST_FIT;
verify_ena = FALSE;
InDOS = 0;
pDirFileNode = 0;
dosidle_flag = 0;
InitializeAllBPBs();
}
INIT VOID FsConfig(VOID)
@ -353,38 +349,31 @@ INIT VOID FsConfig(VOID)
REG COUNT i;
struct dpb FAR *dpb;
/* Initialize the file tables */
for (i = 0; i < Config.cfgFiles; i++)
f_nodes[i].f_count = 0;
/* The system file tables need special handling and are "hand */
/* built. Included is the stdin, stdout, stdaux and atdprn. */
/* built. Included is the stdin, stdout, stdaux and stdprn. */
sfthead->sftt_next = (sfttbl FAR *) - 1;
sfthead->sftt_count = Config.cfgFiles;
for (i = 0; i < sfthead->sftt_count; i++)
for (i = 0; i < Config.cfgFiles; i++)
{
/* Initialize the file tables */
f_nodes[i].f_count = 0;
sfthead->sftt_table[i].sft_count = 0;
sfthead->sftt_table[i].sft_status = -1;
}
/* 0 is /dev/con (stdin) */
init_DosOpen("CON", SFT_MREAD);
sfthead->sftt_table[0].sft_flags |= SFT_FCONIN | SFT_FCONOUT;
open("CON", O_RDWR);
/* 1 is /dev/con (stdout) */
init_DosOpen("CON", SFT_MWRITE);
sfthead->sftt_table[1].sft_flags |= SFT_FCONIN | SFT_FCONOUT;
dup2(STDIN, STDOUT);
/* 2 is /dev/con (stderr) */
init_DosOpen("CON", SFT_MWRITE);
sfthead->sftt_table[2].sft_flags |= SFT_FCONIN | SFT_FCONOUT;
dup2(STDIN, STDERR);
/* 3 is /dev/aux */
init_DosOpen("AUX", SFT_MRDWR);
sfthead->sftt_table[3].sft_flags &= ~SFT_FEOF;
open("AUX", O_RDWR);
/* 4 is /dev/prn */
init_DosOpen("PRN", SFT_MWRITE);
sfthead->sftt_table[4].sft_flags &= ~SFT_FEOF;
open("PRN", O_WRONLY);
/* Log-in the default drive. */
/* Get the boot drive from the ipl and use it for default. */
@ -423,32 +412,43 @@ INIT VOID FsConfig(VOID)
INIT VOID signon()
{
printf("\nFreeDOS Kernel compatibility %d.%d\n%s\n",
BYTE tmp_or[81]; /* ugly constant, but this string should fit on one line */
printf("\nFreeDOS Kernel compatibility %d.%d\n%S\n",
os_major, os_minor, copyright);
printf(os_release,
fmemcpy(tmp_or, os_release, 81);
printf(tmp_or,
REVISION_MAJOR, REVISION_MINOR, REVISION_SEQ,
BUILD);
}
INIT void kernel()
{
seg asize;
#if 0
BYTE FAR *ep,
*sp;
#endif
exec_blk exb;
CommandTail Cmd;
int rc;
#ifndef KDB
static BYTE *path = "PATH=.";
static BYTE master_env[] = "PATH=.\0\0\0\0\0";
/* static BYTE *path = "PATH=.";*/
#endif
#ifdef KDB
kdb();
#else
#if 0
/* create the master environment area */
if (DosMemAlloc(0x20, FIRST_FIT, (seg FAR *) & master_env, (seg FAR *) & asize) < 0)
fatal("cannot allocate master environment space");
if (allocmem(0x2, &exb.exec.env_seg))
init_fatal("cannot allocate master environment space");
/* populate it with the minimum environment */
++master_env;
ep = MK_FP(master_env, 0);
++exb.exec.env_seg;
ep = MK_FP(exb.exec.env_seg, 0);
for (sp = path; *sp != 0;)
*ep++ = *sp++;
@ -457,9 +457,55 @@ INIT void kernel()
*ep++ = '\0';
*((int FAR *)ep) = 0;
ep += sizeof(int);
#endif
#else
exb.exec.env_seg = DOS_PSP+8;
fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env));
#endif
#endif
RootPsp = ~0;
p_0();
/* process 0 */
/* Execute command.com /P from the drive we just booted from */
fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)-1);
for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++)
if (Cmd.ctBuffer[Cmd.ctCount] == '\r')
break;
exb.exec.cmd_line = (CommandTail FAR *) & Cmd;
exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0;
#ifdef DEBUG
printf("Process 0 starting: %s\n\n", Config.cfgInit);
#endif
while ((rc = init_DosExec(Config.cfgP_0_startmode, &exb, Config.cfgInit)) != SUCCESS)
{
BYTE *pLine;
printf("\nBad or missing Command Interpreter: %d\n", rc);
printf("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n");
rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer)-1);
Cmd.ctBuffer[rc]='\0';
/* Get the string argument that represents the new init pgm */
pLine = GetStringArg(Cmd.ctBuffer, Config.cfgInit);
/* Now take whatever tail is left and add it on as a single */
/* string. */
strcpy(Cmd.ctBuffer, pLine);
/* and add a DOS new line just to be safe */
strcat(Cmd.ctBuffer, "\r\n");
Cmd.ctCount = rc-(pLine-Cmd.ctBuffer);
#ifdef DEBUG
printf("Process 0 starting: %s\n\n", Config.cfgInit);
#endif
}
printf("\nSystem shutdown complete\nReboot now.\n");
for (;;) ;
}
/* check for a block device and update device control block */
@ -518,7 +564,7 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_
rq.r_firstunit = nblkdev;
execrh((request FAR *) & rq, dhp);
/*
* Added needed Error handle
*/
@ -548,49 +594,27 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_
update_dcb(dhp);
}
if (dhp->dh_attr & ATTR_CONIN)
syscon = dhp;
else if (dhp->dh_attr & ATTR_CLOCK)
clock = dhp;
return FALSE;
}
INIT static void InitIO(void)
{
BYTE bcd_days[4],
bcd_minutes,
bcd_hours,
bcd_seconds;
ULONG ticks;
/* Initialize driver chain */
nul_dev.dh_next = (struct dhdr FAR *)&con_dev;
setvec(0x29, int29_handler); /* Requires Fast Con Driver */
init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top);
init_device((struct dhdr FAR *)&clk_dev, NULL, NULL, ram_top);
/* If AT clock exists, copy AT clock time to system clock */
if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds))
{
DaysSinceEpoch = DaysFromYearMonthDay(
100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]),
BcdToByte(bcd_days[1]),
BcdToByte(bcd_days[0]) );
/*
* This is a rather tricky calculation. The number of timer ticks per
* second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080
* (the timer interrupt updates the midnight flag when the tick count
* reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX,
* so we can simply multiply the number of seconds by 19663 without
* worrying about overflow. :) -- ror4
*/
ticks = (3600ul * BcdToByte(bcd_hours) +
60ul * BcdToByte(bcd_minutes) +
BcdToByte(bcd_seconds)) * 19663ul / 1080ul;
WritePCClock(ticks);
}
init_device(&con_dev, NULL, NULL, ram_top);
init_device(&clk_dev, NULL, NULL, ram_top);
}
INIT static COUNT BcdToByte(COUNT x)
/* issue an internal error message */
VOID init_fatal(BYTE * err_msg)
{
return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf));
printf("\nInternal kernel error - %s\nSystem halted\n", err_msg);
for (;;) ;
}

View File

@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$";
/*
* $Log$
* Revision 1.14 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.13 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -698,7 +701,7 @@ DUL_exit:
it will be useful (maybe for storing environments)
*/
#if 0
BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */
extern BYTE _INIT_DATA_START[], _INIT_DATA_END[];
@ -739,5 +742,5 @@ VOID ClaimINITDataSegment()
first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4);
}
#endif
#endif

View File

@ -28,6 +28,17 @@
#include "portab.h"
#ifdef FORINIT
#define fstrlen reloc_call_fstrlen
#define put_console init_put_console
#define ltob init_ltob
#define do_printf init_do_printf
#define printf init_printf
#define sprintf init_sprintf
#define charp init_charp
#define hexd init_hexd
#endif
COUNT fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */
@ -37,6 +48,9 @@ static BYTE *prfRcsId = "$Id$";
/*
* $Log$
* Revision 1.9 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.8 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -53,6 +67,9 @@ static BYTE *prfRcsId = "$Id$";
* recoded for smaller object footprint, added main() for testing+QA
*
* $Log$
* Revision 1.9 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.8 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -377,7 +394,7 @@ do_outputstring:
void hexd(char *title,UBYTE FAR *p,COUNT numBytes)
{
int loop;
printf("%s%04x|",title,p);
printf("%s%04x|", title, FP_SEG(p));
for (loop = 0; loop < numBytes; loop++)
printf("%02x ", p[loop]);
printf("|");

View File

@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$";
/*
* $Log$
* Revision 1.15 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.14 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
*
@ -166,8 +169,6 @@ static BYTE *Proto_hRcsId = "$Id$";
*Initial revision.
*/
#define INIT
/* blockio.c */
ULONG getblkno(struct buffer FAR *);
VOID setblkno(struct buffer FAR *, ULONG);
@ -193,24 +194,10 @@ BOOL con_break(void);
BOOL StdinBusy(void);
VOID KbdFlush(void);
VOID Do_DosIdle_loop(void);
VOID sti(keyboard FAR * kp);
UCOUNT sti(keyboard FAR * kp);
sft FAR *get_sft(COUNT);
/* config.c */
INIT VOID PreConfig(VOID);
INIT VOID DoConfig(VOID);
INIT VOID PostConfig(VOID);
INIT BYTE *skipwh(BYTE * s);
INIT BYTE *scan(BYTE * s, BYTE * d);
INIT BOOL isnum(BYTE * pszString);
INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum);
INIT COUNT tolower(COUNT c);
INIT COUNT toupper(COUNT c);
INIT VOID mcb_init(mcb FAR * mcbp, UWORD size);
INIT VOID strcat(REG BYTE * d, REG BYTE * s);
INIT BYTE FAR *KernelAlloc(WORD nBytes);
/* dosfns.c */
BYTE FAR *get_root(BYTE FAR *);
BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT);
@ -218,7 +205,8 @@ BOOL check_break(void);
UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err,
BOOL force_binary);
COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode);
UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err);
/* COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */
#define DosRead(hndl,n,bp,err) GenericRead(hndl, n, bp, err,FALSE)
UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err);
COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos);
COUNT DosCreat(BYTE FAR * fname, COUNT attrib);
@ -355,49 +343,9 @@ BOOL FcbClose(xfcb FAR * lpXfcb);
BOOL FcbFindFirst(xfcb FAR * lpXfcb);
BOOL FcbFindNext(xfcb FAR * lpXfcb);
/* inithma.c */
int MoveKernelToHMA(void);
VOID FAR *HMAalloc(COUNT bytesToAllocate);
/* initoem.c */
UWORD init_oem(void);
/* inthndlr.c */
VOID INRPT far got_cbreak(void); /* procsupt.asm */
VOID INRPT far int20_handler(iregs UserRegs);
VOID INRPT far int21_handler(iregs UserRegs);
VOID far int21_entry(iregs UserRegs);
VOID int21_service(iregs far * r);
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 int25_handler();
VOID int26_handler();*/
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 int2a_handler(void);
VOID INRPT FAR int2f_handler(void);
VOID INRPT FAR empty_handler(void);
VOID INRPT FAR int0_handler(void);
/* intr.asm */
/* void init_call_intr(int nr, iregs *rp); */
INIT COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n);
INIT COUNT init_DosOpen(BYTE *fname, COUNT mode);
INIT COUNT init_DosClose(COUNT hndl);
INIT VOID init_PSPInit(seg psp_seg);
INIT VOID keycheck(VOID);
/* ioctl.c */
COUNT DosDevIOctl(iregs FAR * r);
/* main.c */
INIT VOID main(void);
INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top);
/* memmgr.c */
seg far2para(VOID FAR * p);
seg long2para(ULONG size);
@ -497,7 +445,6 @@ LONG WordToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr);
/* syscon.c */
WORD con_driver(rqptr rp);
VOID break_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);
/* syspack.c */
VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp);
@ -520,10 +467,6 @@ VOID new_psp(psp FAR * p, int psize);
VOID return_user(void);
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
VOID InitPSP(VOID);
VOID p_0(VOID);
/* irqstack.asm */
VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize);
/* newstuff.c */
int SetJFTSize(UWORD nHandles);
@ -535,8 +478,6 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t);
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 Umb_Test(void);
UWORD get_machine_name(BYTE FAR * netname);
VOID set_machine_name(BYTE FAR * netname, UWORD name_num);
UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err);

View File

@ -29,6 +29,9 @@
; $Header$
;
; $Log$
; Revision 1.6 2001/04/21 22:32:53 bartoldeman
; Init DS=Init CS, fixed stack overflow problems and misc bugs.
;
; Revision 1.5 2001/04/15 03:21:50 bartoldeman
; See history.txt for the list of fixes.
;
@ -60,11 +63,13 @@
; $EndLog
;
group PGROUP PSP
group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA
group DGROUP _FIXED_DATA _DATA _BSS _BSSEND ID_B ID ID_E
group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND
group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END
group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END
group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E
segment PSP class=PSP
segment _TEXT class=CODE
segment _IO_TEXT class=CODE
segment _IO_FIXED_DATA class=CODE align=2
@ -73,13 +78,16 @@ segment _DATA class=DATA align=2
segment _BSSSTART class=BSS align=2
segment _BSS class=BSS align=2
segment _BSSEND class=BSS
segment ID_B class=ID align=2
segment ID class=ID align=2
segment ID_E class=ID align=2
segment HMA_TEXT_START class=HMA
segment HMA_TEXT class=HMA
segment HMA_TEXT_END class=HMA
segment INIT_TEXT_START class=INIT align=16
segment INIT_TEXT class=INIT
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 IB_B class=IB align=2
segment IB class=IB align=2
segment IB_E class=IB align=2

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.6 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.5 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes.
*
@ -130,15 +133,48 @@ static BYTE bcdSeconds;
static ULONG Ticks;
UWORD DaysSinceEpoch = 0;
BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *);
static COUNT BcdToByte(COUNT x)
{
return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf));
}
WORD FAR clk_driver(rqptr rp)
{
COUNT
c;
WORD *pdays;
BYTE bcd_days[4],
bcd_minutes,
bcd_hours,
bcd_seconds;
ULONG ticks;
switch (rp->r_command)
{
case C_INIT:
/* If AT clock exists, copy AT clock time to system clock */
if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds))
{
DaysSinceEpoch = DaysFromYearMonthDay(
100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]),
BcdToByte(bcd_days[1]),
BcdToByte(bcd_days[0]) );
/*
* This is a rather tricky calculation. The number of timer ticks per
* second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080
* (the timer interrupt updates the midnight flag when the tick count
* reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX,
* so we can simply multiply the number of seconds by 19663 without
* worrying about overflow. :) -- ror4
*/
ticks = (3600ul * BcdToByte(bcd_hours) +
60ul * BcdToByte(bcd_minutes) +
BcdToByte(bcd_seconds)) * 19663ul / 1080ul;
WritePCClock(ticks);
}
rp->r_endaddr = device_end();
rp->r_nunits = 0;
return S_DONE;

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.13 2001/04/21 22:32:53 bartoldeman
* Init DS=Init CS, fixed stack overflow problems and misc bugs.
*
* Revision 1.12 2001/04/16 14:28:32 bartoldeman
* Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs
*
@ -157,9 +160,9 @@ static BYTE *RcsId = "$Id$";
* Rev 1.0 02 Jul 1995 8:34:06 patv
* Initial revision.
*/
#if 0
extern VOID ClaimINITDataSegment(VOID);
#endif
#define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c))
#define LOADNGO 0
@ -451,8 +454,8 @@ set_name:
COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
COUNT rc,
err
COUNT rc
/* err */
/*,env_size*/;
COUNT nread;
UWORD mem;
@ -553,7 +556,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
}
do
{
nread = DosRead(rc, CHUNK, sp, &err);
nread = DosRead(rc, CHUNK, sp, &UnusedRetVal);
sp = add_far((VOID FAR *) sp, (ULONG) nread);
}
while ((com_size -= nread) > 0 && nread == CHUNK);
@ -604,8 +607,8 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
now we 1 microsecond from COMMAND.COM
now we claim the ID = INIT_DATA segment,
which should no longer be used
*/
ClaimINITDataSegment();
*/
if (InDOS)
--InDOS;
@ -668,7 +671,7 @@ VOID return_user(void)
COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
COUNT rc,
err,
/*err, */
/*env_size,*/
i;
COUNT nBytesRead;
@ -883,7 +886,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
do
{
nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &err);
nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &UnusedRetVal);
sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead);
exe_size -= nBytesRead;
}
@ -894,7 +897,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
doslseek(rc, (LONG) header.exRelocTable, 0);
for (i = 0; i < header.exRelocItems; i++)
{
if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &err) != sizeof(reloc))
if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &UnusedRetVal) != sizeof(reloc))
{
return DE_INVLDDATA;
}
@ -960,8 +963,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
now we 1 microsecond from COMMAND.COM
now we claim the ID = INIT_DATA segment,
which should no longer be used
*/
ClaimINITDataSegment();
*/
if (InDOS)
--InDOS;
@ -987,8 +990,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
*/
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
{
COUNT rc,
err;
COUNT rc;
exec_blk leb;
/* BYTE FAR *cp;*/
@ -1003,7 +1005,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
}
if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &err)
if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &UnusedRetVal)
!= sizeof(exe_header))
{
bIsCom = TRUE;
@ -1024,32 +1026,4 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
return rc;
}
/* process 0 */
VOID p_0(VOID)
{
exec_blk exb;
CommandTail Cmd;
BYTE FAR *szfInitialPrgm = (BYTE FAR *) Config.cfgInit;
int rc;
/* Execute command.com /P from the drive we just booted from */
exb.exec.env_seg = master_env;
fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)-1);
for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++)
if (Cmd.ctBuffer[Cmd.ctCount] == '\r')
break;
exb.exec.cmd_line = (CommandTail FAR *) & Cmd;
exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0;
#ifdef DEBUG
printf("Process 0 starting: %s\n\n", (BYTE *) szfInitialPrgm);
#endif
if ((rc = DosExec(Config.cfgP_0_startmode,
(exec_blk FAR *) & exb, szfInitialPrgm)) != SUCCESS)
printf("\nBad or missing Command Interpreter: %d\n", rc);
else
printf("\nSystem shutdown complete\nReboot now.\n");
for (;;) ;
}