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 2001 Apr 16 - Build 2024
-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) -------- Bart Oldeman (bart.oldeman@bristol.ac.uk)
+ Fixes * Use turboc.cfg to avoid long command lines; edit ALLCFLAGS + 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$ * $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 * Revision 1.3 2000/05/25 20:56:19 jimtabor
* Fixed project history * Fixed project history
* *
@ -78,6 +81,18 @@ static BYTE *file_hRcsId = "$Id$";
* Initial revision. * 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_RDONLY SFT_MREAD
#define O_WRONLY SFT_MWRITE #define O_WRONLY SFT_MWRITE
#define O_RDWR SFT_MRDWR #define O_RDWR SFT_MRDWR

View File

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

View File

@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.8 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes. * 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. 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, BOOL searchblock(ULONG blkno, COUNT dsk,
struct buffer FAR ** pReplacebp) struct buffer FAR ** pBuffp)
{ {
int fat_count = 0; int fat_count = 0;
struct buffer FAR *bp; struct buffer FAR *bp;
@ -271,8 +277,8 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK
printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp)); printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp));
#endif #endif
*pBuffp = bp;
return (bp); return TRUE;
} }
if (bp->b_flag & BFR_FAT) if (bp->b_flag & BFR_FAT)
@ -290,7 +296,8 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
{ {
lbp = lastNonFat; lbp = lastNonFat;
} }
*pReplacebp = lbp;
*pBuffp = lbp;
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK
printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp)); 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; 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 *getblock(ULONG blkno, COUNT dsk)
{ {
struct buffer FAR *bp; struct buffer FAR *bp;
struct buffer FAR *Replacebp;
/* Search through buffers to see if the required block */ /* Search through buffers to see if the required block */
/* is already in a buffer */ /* is already in a buffer */
bp = searchblock(blkno, dsk, &Replacebp); if (searchblock(blkno, dsk, &bp))
if (bp)
{ {
return (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. */ /* take the buffer that lbp points to and flush it, then read new block. */
if (flush1(Replacebp) && fill(Replacebp, blkno, dsk)) /* success */ if (!flush1(bp))
{ return NULL;
return Replacebp;
} /* Fill the indicated disk buffer with the current track and sector */
else
if (dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD))
{ {
return NULL; 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) BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk)
{ {
struct buffer FAR *bp; struct buffer FAR *bp;
struct buffer FAR *Replacebp;
/* Search through buffers to see if the required block */ /* Search through buffers to see if the required block */
/* is already in a buffer */ /* is already in a buffer */
bp = searchblock(blkno, dsk, &Replacebp); if (searchblock(blkno, dsk, &bp))
if (bp)
{ {
*pbp = bp; *pbp = bp;
return TRUE; return TRUE;
@ -382,12 +391,12 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk)
/* available. */ /* available. */
/* take the buffer than lbp points to and flush it, then make it 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; bp->b_flag = 0;
Replacebp->b_unit = dsk; bp->b_unit = dsk;
setblkno(Replacebp, blkno); setblkno(bp, blkno);
*pbp = Replacebp; *pbp = bp;
return TRUE; return TRUE;
} }
else else
@ -494,29 +503,6 @@ BOOL flush(void)
return (ok); 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$ * $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 * Revision 1.6 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * 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, REG UWORD c,
cu_pos = scr_pos; cu_pos = scr_pos;
UWORD UWORD
virt_pos = scr_pos; virt_pos = scr_pos;
WORD init_count = kp->kb_count; WORD init_count = kp->kb_count;
BOOL eof = FALSE;
#ifndef NOSPCL #ifndef NOSPCL
static BYTE local_buffer[LINESIZE]; static BYTE local_buffer[LINESIZE];
#endif #endif
if (kp->kb_size == 0) if (kp->kb_size == 0)
return; return eof;
if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR) if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR)
kp->kb_count = 0; kp->kb_count = 0;
FOREVER FOREVER
@ -391,7 +396,10 @@ VOID sti(keyboard FAR * kp)
(BYTE FAR *) local_buffer, (COUNT) kp->kb_count); (BYTE FAR *) local_buffer, (COUNT) kp->kb_count);
local_buffer[kp->kb_count] = '\0'; local_buffer[kp->kb_count] = '\0';
#endif #endif
return; if (eof)
return eof;
else
return kp->kb_count;
case LF: case LF:
sto(CR); sto(CR);
@ -405,8 +413,12 @@ VOID sti(keyboard FAR * kp)
for (c = 0; c < cu_pos; c++) for (c = 0; c < cu_pos; c++)
sto(' '); sto(' ');
kp->kb_count = init_count; kp->kb_count = init_count;
eof = FALSE;
break; break;
case CTL_Z:
eof = kp->kb_count;
/* fall through */
default: default:
kbfill(kp, c, FALSE, &virt_pos); kbfill(kp, c, FALSE, &virt_pos);
break; break;

View File

@ -27,12 +27,52 @@
/* Cambridge, MA 02139, USA. */ /* Cambridge, MA 02139, USA. */
/****************************************************************/ /****************************************************************/
#define CONFIG #include "portab.h"
#include "init-mod.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
#include "nls.h" 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 #ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$"; static BYTE *RcsId = "$Id$";
@ -40,6 +80,9 @@ static BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.20 2001/04/16 14:44:29 bartoldeman
* Removed debug printf. * Removed debug printf.
* *
@ -178,28 +221,44 @@ static BYTE *RcsId = "$Id$";
* Added NLS, int2f and config.sys processing * 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 #ifdef KDB
#include <alloc.h> #include <alloc.h>
#define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) #define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x)))
#endif #endif
BYTE FAR *lpBase = 0; struct config Config
BYTE FAR *upBase = 0; =
static BYTE FAR *lpOldLast = 0; {
static COUNT nCfgLine = 0; NUMBUFF,
static COUNT nPass = 0; NFILES,
COUNT UmbState = 0; NFCBS,
static BYTE szLine[256]={0}; 0,
static BYTE szBuf[256]={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 zumcb_init(mcb FAR * mcbp, UWORD size);
INIT VOID mumcb_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); extern void HMAconfig(int finalize);
VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ 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); INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr);
#ifndef I86 #ifndef I86
#define AlignParagraph(x) (x) #define AlignParagraph(x) (x)
@ -287,7 +342,7 @@ INIT BYTE FAR *KernelAllocDma(WORD);
BYTE *pLineStart; BYTE *pLineStart;
BYTE HMATextIsAvailable = 0; BYTE HMATextIsAvailable;
void FAR * ConfigAlloc(COUNT bytes) void FAR * ConfigAlloc(COUNT bytes)
{ {
@ -320,7 +375,10 @@ INIT void PreConfig(void)
lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart); lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart);
#ifdef DEBUG #ifdef DEBUG
{
extern BYTE FAR internal_data[];
printf("SDA located at 0x%p\n", internal_data); printf("SDA located at 0x%p\n", internal_data);
}
#endif #endif
/* Begin by initializing our system buffers */ /* Begin by initializing our system buffers */
/* the dms_scratch buffer is statically allocated /* the dms_scratch buffer is statically allocated
@ -447,7 +505,6 @@ INIT void PostConfig(void)
#ifdef DEBUG #ifdef DEBUG
printf("f_node allocated at 0x%p\n",f_nodes); printf("f_node allocated at 0x%p\n",f_nodes);
printf("FCB table allocated at 0x%p\n",FCBp); printf("FCB table allocated at 0x%p\n",FCBp);
printf("sft table allocated at 0x%p\n",sfthead); 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 */ /* Check to see if we have a config.sys file. If not, just */
/* exit since we don't force the user to have one. */ /* 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 #ifdef DEBUG
printf("FDCONFIG.SYS not found\n"); printf("FDCONFIG.SYS not found\n");
#endif #endif
if ((nFileDesc = init_DosOpen("config.sys", 0)) < 0) if ((nFileDesc = open("config.sys", 0)) < 0)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("CONFIG.SYS not found\n"); printf("CONFIG.SYS not found\n");
@ -578,7 +635,7 @@ INIT VOID DoConfig(VOID)
/* Read a line from config */ /* Read a line from config */
/* Interrupt processing if read error or no bytes read */ /* 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; break;
/* If the buffer was not filled completely, append a /* If the buffer was not filled completely, append a
@ -653,7 +710,7 @@ INIT VOID DoConfig(VOID)
pLine += strlen(pLine) + 1; pLine += strlen(pLine) + 1;
} }
} }
init_DosClose(nFileDesc); close(nFileDesc);
} }
INIT struct table *LookUp(struct table *p, BYTE * token) 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) INIT BOOL SkipLine(char *pLine)
{ {
char kbdbuf[16]; char kbdbuf[16];
keyboard *kp = (keyboard *) kbdbuf; char *pKbd = kbdbuf;
char *pKbd = &kp->kb_buf[0];
kp->kb_size = 12;
kp->kb_count = 0;
printf("%s [Y,N]?", pLine); printf("%s [Y,N]?", pLine);
sti(kp); read(STDIN, kbdbuf, 12);
pKbd = skipwh(pKbd); pKbd = skipwh(pKbd);
@ -809,7 +862,7 @@ INIT static VOID Dosmem(BYTE * pLine)
BYTE *pTmp; BYTE *pTmp;
BYTE UMBwanted = FALSE, HMAwanted = FALSE; BYTE UMBwanted = FALSE, HMAwanted = FALSE;
extern BYTE INITDataSegmentClaimed; /* extern BYTE FAR INITDataSegmentClaimed; */
pLine = GetStringArg(pLine, szBuf); 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, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; }
if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; } 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); pTmp = skipwh(pTmp);
if (*pTmp != ',') if (*pTmp != ',')
@ -1046,40 +1099,18 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
#endif #endif
if (DosExec(3, &eb, szBuf) == SUCCESS) if (init_DosExec(3, &eb, szBuf) == SUCCESS)
{ {
/* that's a nice hack >:-) strcpy(szBuf, pLine);
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.
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 */ /* add \r\n to the command line */
pLine-=2; strcat(szBuf, "\r\n");
strcpy(pLine, pLine+2);
strcat(pLine, "\r\n");
/* TE this fixes the loading of devices drivers with /* TE this fixes the loading of devices drivers with
multiple devices in it. NUMEGA's SoftIce is such a beast multiple devices in it. NUMEGA's SoftIce is such a beast
*/ */
for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff && 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) ; dhp = next_dhp)
{ {
next_dhp = dhp->dh_next; next_dhp = dhp->dh_next;

View File

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

View File

@ -28,6 +28,9 @@
; $Id$ ; $Id$
; ;
; $Log$ ; $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 ; Revision 1.12 2001/04/16 14:28:32 bartoldeman
; Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs ; 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 ; NOTE: On exit, DS must point to kernel stack, SS:SP user stack after
; PUSH$ALL and BP == SP. ; PUSH$ALL and BP == SP.
; ;
%if 0 ; this is dead code now
_RestartSysCall: _RestartSysCall:
cli ; no interrupts cli ; no interrupts
mov bp,word [_lpUserStack+2] ;Get frame mov bp,word [_lpUserStack+2] ;Get frame
@ -200,6 +204,7 @@ _RestartSysCall:
sti sti
POP$ALL ; get the original regs POP$ALL ; get the original regs
jmp short int21_reentry ; restart the system call jmp short int21_reentry ; restart the system call
%endif
; ;
@ -235,6 +240,14 @@ zero_done:
mov ax,04c7fh ; terminate with errorlevel 127 mov ax,04c7fh ; terminate with errorlevel 127
int 21h 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 ; 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 ; NB: At this point, SS != DS and won't be set that way
; until later when which stack to run on is determined. ; until later when which stack to run on is determined.
; ;
int21_reentry_crit: int21_reentry:
mov dx,DGROUP mov dx,DGROUP
mov ds,dx mov ds,dx
int21_reentry:
cmp ah,33h cmp ah,33h
je int21_user je int21_user
cmp ah,50h cmp ah,50h
@ -691,4 +703,4 @@ CritErrAbort:
mov ax,4C00h mov ax,4C00h
mov [bp+reg_ax],ax mov [bp+reg_ax],ax
sti sti
jmp int21_reentry_crit ; restart the system call jmp int21_reentry ; restart the system call

View File

@ -30,6 +30,9 @@
; $Id$ ; $Id$
; ;
; $Log$ ; $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 ; Revision 1.6 2001/04/15 03:21:50 bartoldeman
; See history.txt for the list of fixes. ; See history.txt for the list of fixes.
; ;
@ -102,7 +105,7 @@ segment HMA_TEXT
_execrh: _execrh:
push bp ; perform c entry push bp ; perform c entry
mov bp,sp mov bp,sp
push bx ; random char on display ; push bx ; random char on display
push si push si
push es ; sometimes it get lost push es ; sometimes it get lost
push ds ; sp=bp-8 push ds ; sp=bp-8
@ -129,6 +132,6 @@ _execrh:
pop ds pop ds
pop es pop es
pop si pop si
pop bx ; pop bx
pop bp pop bp
ret ret

View File

@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.15 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
* *
@ -823,8 +826,11 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2)
COUNT ret; COUNT ret;
if ((ret = extend_dir(fnp2)) != SUCCESS) if ((ret = extend_dir(fnp2)) != SUCCESS)
{
dir_close(fnp1);
return ret; return ret;
} }
}
if (!find_fname(fnp1, szPriFileName, szPriFileExt)) if (!find_fname(fnp1, szPriFileName, szPriFileExt))
{ {
@ -1411,7 +1417,6 @@ COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode)
{ {
ULONG idx; ULONG idx;
UWORD clssize; UWORD clssize;
UWORD secsize;
#ifdef DISPLAY_GETBLOCK #ifdef DISPLAY_GETBLOCK
printf("map_cluster: current %lu, offset %lu, diff=%lu ", 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); fnp->f_offset - fnp->f_cluster_offset);
#endif #endif
/* The variable clssize will be used later. */ /* The variable clssize will be used later. */
secsize = fnp->f_dpb->dpb_secsize; clssize = fnp->f_dpb->dpb_secsize * (fnp->f_dpb->dpb_clsmask + 1);
clssize = secsize * (fnp->f_dpb->dpb_clsmask + 1);
/* If someone did a seek, but no writes have occured, we will */ /* If someone did a seek, but no writes have occured, we will */
/* need to initialize the fnode. */ /* need to initialize the fnode. */

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.4 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes. * 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 /* Given the disk parameters, and a cluster number, this function
looks at the FAT, and returns the next cluster in the clain. */ 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)) if (ISFAT12(dpbp))
return next_cl12(dpbp, ClusterNum); return next_cl12(dpbp, ClusterNum);
@ -290,11 +293,9 @@ UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum)
return LONG_LAST_CLUSTER; 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; struct buffer FAR *bp;
UWORD RetCluster;
/* Get the block that this cluster is in */ /* Get the block that this cluster is in */
bp = getblock((ULONG) (((ULONG) ClusterNum) * SIZEOF_CLST16) / dpbp->dpb_secsize + dpbp->dpb_fatstrt, 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_lo = dpbp->dpb_fatsize;
bp->b_offset_hi = dpbp->dpb_fatsize >> 8; 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 */ /* form an index so that we can read the block as a */
/* byte array */ /* byte array */
idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize;
/* Get the cluster number, */ /* Get the cluster number, */
fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster); fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster);
/* and return successful. */ /* and return successful. */
return RetCluster; 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) UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum)

View File

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

View File

@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.11 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes. * See history.txt for the list of fixes.
* *
@ -199,6 +202,7 @@ static BYTE *Globals_hRcsId = "$Id$";
#include "version.h" #include "version.h"
#include "network.h" #include "network.h"
#include "config.h" #include "config.h"
#include "buffer.h"
/* JPP: for testing/debuging disk IO */ /* JPP: for testing/debuging disk IO */
/*#define DISPLAY_GETBLOCK */ /*#define DISPLAY_GETBLOCK */
@ -226,26 +230,8 @@ static BYTE *Globals_hRcsId = "$Id$";
/* Constants and macros */ /* Constants and macros */
/* */ /* */
/* Defaults and limits - System wide */ /* Defaults and limits - System wide */
#define PARSE_MAX 67 /* maximum # of bytes in path */ #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 NAMEMAX PARSE_MAX /* Maximum path for CDS */ #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 */ /* internal error from failure or aborted operation */
#define ERROR -1 #define ERROR -1
@ -296,45 +282,7 @@ static BYTE *Globals_hRcsId = "$Id$";
#ifdef LINESIZE #ifdef LINESIZE
#undef LINESIZE #undef LINESIZE
#endif #endif
#define LINESIZE 256 #define LINESIZE KBD_MAXLENGTH
/* */
/* 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 */
/* NLS character table type */ /* NLS character table type */
typedef BYTE *UPMAP; typedef BYTE *UPMAP;
@ -381,9 +329,6 @@ extern struct ClockRecord
/* */ /* */
/* Global variables */ /* Global variables */
/* */ /* */
GLOBAL
seg master_env; /* Master environment segment */
GLOBAL BYTE GLOBAL BYTE
os_major, /* major version number */ os_major, /* major version number */
os_minor, /* minor version number */ os_minor, /* minor version number */
@ -417,14 +362,17 @@ GLOBAL WORD bDumpRdWrParms
#endif #endif
#endif #endif
GLOBAL BYTE *copyright GLOBAL BYTE copyright[]
#ifdef MAIN
#if 0 #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 #else
; = ""
#endif #endif
#endif
;
GLOBAL BYTE *os_release GLOBAL BYTE os_release[]
#ifdef MAIN #ifdef MAIN
#if 0 #if 0
= "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n\ = "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n\
@ -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\ For technical information and description of the DOS-C operating system\n\
consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\ consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\
Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\
\n"; \n"
#else #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
#endif #endif
#else
; ;
#endif
/* Globally referenced variables - WARNING: ORDER IS DEFINED IN */ /* Globally referenced variables - WARNING: ORDER IS DEFINED IN */
/* KERNAL.ASM AND MUST NOT BE CHANGED. DO NOT CHANGE ORDER BECAUSE THEY */ /* KERNAL.ASM AND MUST NOT BE CHANGED. DO NOT CHANGE ORDER BECAUSE THEY */
@ -633,54 +581,6 @@ GLOBAL iregs
FAR * ustackp, /* user stack */ FAR * ustackp, /* user stack */
FAR * kstackp; /* kernel 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 */ /* Function prototypes - automatically generated */
/* */ /* */
@ -784,3 +684,5 @@ void handle_break(void); /* break.c */
GLOBAL BYTE ReturnAnyDosVersionExpected; 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 #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 * The null macro `INIT' can be used to allow the reader to differentiate
* between functions defined in `INIT_TEXT' and those defined in `_TEXT'. * 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 * calls for the latter functions therefore need to be wrapped up with far
* entry points. * entry points.
*/ */
#define DosExec reloc_call_DosExec #define printf init_printf
#define DosMemAlloc reloc_call_DosMemAlloc
#define execrh reloc_call_execrh #define execrh reloc_call_execrh
#define fatal reloc_call_fatal
#define fmemcpy reloc_call_fmemcpy #define fmemcpy reloc_call_fmemcpy
#define memcpy reloc_call_memcpy
#define fmemset reloc_call_fmemset #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 strcpy reloc_call_strcpy
#define sti reloc_call_sti
#define strcmp reloc_call_strcmp
#define strlen reloc_call_strlen #define strlen reloc_call_strlen
#define WritePCClock reloc_call_WritePCClock WORD execrh(request FAR *, struct dhdr FAR *);
#define DaysFromYearMonthDay reloc_call_DaysFromYearMonthDay VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n);
#define p_0 reloc_call_p_0 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 "init-mod.h"
#include "portab.h" extern BYTE FAR version_flags; /* minor version number */
#include "globals.h"
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 #ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$"; static BYTE *RcsId = "$Id$";
@ -75,6 +80,9 @@ static BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.4 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * 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 DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */
BYTE HMAclaimed; /* set to TRUE if claimed from HIMEM */ BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */
WORD HMAFree; /* first byte in HMA not yet used */ WORD HMAFree; /* first byte in HMA not yet used */
@ -387,16 +395,15 @@ int MoveKernelToHMA()
UWORD jmpSegment; UWORD jmpSegment;
}; };
extern struct initRelocationTable extern struct initRelocationTable
FAR _HMAinitRelocationTableStart[], _HMAinitRelocationTableStart[],
FAR _HMAinitRelocationTableEnd[]; _HMAinitRelocationTableEnd[];
struct initRelocationTable FAR *rp, FAR *endrp; struct initRelocationTable *rp;
/* verify, that all entries are valid */ /* verify, that all entries are valid */
UWORD HMATextSegment = FP_SEG( _HMATextStart ); 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 ( if (
rp->callNear != 0xe8 || /* call NEAR */ rp->callNear != 0xe8 || /* call NEAR */
@ -405,14 +412,14 @@ int MoveKernelToHMA()
0) 0)
{ {
printf("illegal init relocation entry # %d\n", printf("illegal init relocation entry # %d\n",
FP_OFF(rp) - FP_OFF(_HMAinitRelocationTableStart)); rp - _HMAinitRelocationTableStart);
goto errorReturn; goto errorReturn;
} }
} }
/* OK, all valid, go to relocate*/ /* 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->jmpSegment = HMASEGMENT;
rp->callOffset = rp->callOffset-5; /* near calls are relative */ rp->callOffset = rp->callOffset-5; /* near calls are relative */

View File

@ -27,10 +27,8 @@
/* */ /* */
/****************************************************************/ /****************************************************************/
#include "init-mod.h"
#include "portab.h" #include "portab.h"
#include "globals.h" #include "init-mod.h"
#ifdef VERSION_STRINGS #ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$"; static BYTE *RcsId = "$Id$";
@ -38,6 +36,9 @@ static BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history * Fixed project history
* *

View File

@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.21 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
* *
@ -486,9 +489,9 @@ dispatch:
/* Check Stdin Status */ /* Check Stdin Status */
case 0x0b: case 0x0b:
if (StdinBusy()) if (StdinBusy())
r->AL = 0xFF;
else
r->AL = 0x00; r->AL = 0x00;
else
r->AL = 0xFF;
break; break;
/* Flush Buffer, Read Keayboard */ /* Flush Buffer, Read Keayboard */

View File

@ -51,9 +51,9 @@ intr?2 mov bx, [bp+6] ; regpack structure
mov ax, [bx] mov ax, [bx]
mov cx, [bx+4] mov cx, [bx+4]
mov dx, [bx+6] mov dx, [bx+6]
mov bp, [bx+8] mov si, [bx+8]
mov di, [bx+10] mov di, [bx+10]
mov si, [bx+12] mov bp, [bx+12]
push Word [bx+14] ; ds push Word [bx+14] ; ds
mov es, [bx+16] mov es, [bx+16]
mov bx, [bx+2] mov bx, [bx+2]
@ -73,14 +73,14 @@ intr?1:
mov [bx+2], ax mov [bx+2], ax
mov [bx+4], cx mov [bx+4], cx
mov [bx+6], dx mov [bx+6], dx
mov [bx+8], bp mov [bx+8], si
mov [bx+10], di mov [bx+10], di
mov [bx+12], si mov [bx+12], bp
pop ax pop ax
mov [bx+14], ax mov [bx+14], ax
mov [bx+16], es mov [bx+16], es
pop ax pop ax
mov [bx+18], ax mov [bx+22], ax
pop es pop es
pop ds pop ds
@ -120,9 +120,9 @@ init_intr?2 mov bx, [bp+6] ; regpack structure
mov ax, [bx] mov ax, [bx]
mov cx, [bx+4] mov cx, [bx+4]
mov dx, [bx+6] mov dx, [bx+6]
mov bp, [bx+8] mov si, [bx+8]
mov di, [bx+10] mov di, [bx+10]
mov si, [bx+12] mov bp, [bx+12]
push Word [bx+14] ; ds push Word [bx+14] ; ds
mov es, [bx+16] mov es, [bx+16]
mov bx, [bx+2] mov bx, [bx+2]
@ -142,14 +142,14 @@ init_intr?1:
mov [bx+2], ax mov [bx+2], ax
mov [bx+4], cx mov [bx+4], cx
mov [bx+6], dx mov [bx+6], dx
mov [bx+8], bp mov [bx+8], si
mov [bx+10], di mov [bx+10], di
mov [bx+12], si mov [bx+12], bp
pop ax pop ax
mov [bx+14], ax mov [bx+14], ax
mov [bx+16], es mov [bx+16], es
pop ax pop ax
mov [bx+18], ax mov [bx+22], ax
pop es pop es
pop ds pop ds
@ -207,9 +207,9 @@ _keycheck:
int 16h int 16h
ret ret
;; COUNT init_DosOpen(BYTE *fname, COUNT mode) ;; int open(const char *pathname, int flags);
global _init_DosOpen global _open
_init_DosOpen: _open:
;; first implementation of init calling DOS through ints: ;; first implementation of init calling DOS through ints:
mov bx, sp mov bx, sp
mov ah, 3dh mov ah, 3dh
@ -217,33 +217,44 @@ _init_DosOpen:
mov al, [bx+4] mov al, [bx+4]
mov dx, [bx+2] mov dx, [bx+2]
int 21h int 21h
common_exit:
jnc open_no_error
;; AX has file handle ;; AX has file handle
neg ax
;; negative value for error code common_exit:
open_no_error: jnc common_no_error
common_error:
mov ax, -1
common_no_error:
ret ret
;; COUNT init_DosClose(COUNT hndl) ;; int close(int fd);
global _init_DosClose global _close
_init_DosClose: _close:
mov bx, sp mov bx, sp
mov bx, [bx+2] mov bx, [bx+2]
mov ah, 3eh mov ah, 3eh
int 21h int 21h
jmp common_exit jmp short common_exit
;; COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n) ;; UCOUNT read(int fd, void *buf, UCOUNT count);
global _init_DosRead global _read
_init_DosRead: _read:
mov bx, sp mov bx, sp
mov cx, [bx+6] mov cx, [bx+6]
mov dx, [bx+4] mov dx, [bx+4]
mov bx, [bx+2] mov bx, [bx+2]
mov ah, 3fh mov ah, 3fh
int 21h 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) ;; VOID init_PSPInit(seg psp_seg)
global _init_PSPInit global _init_PSPInit
@ -257,3 +268,33 @@ _init_PSPInit:
pop si pop si
ret 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$ ; $Header$
; ;
; $Log$ ; $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 ; Revision 1.7 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones. ; 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 global _clk_dev
_clk_dev equ $ _clk_dev equ $
dw _blk_dev,TGROUP dw _blk_dev,TGROUP
dw 8004h ; clock device dw 8008h ; clock device
dw GenStrategy dw GenStrategy
dw clk_entry dw clk_entry
db 'CLOCK$ ' db 'CLOCK$ '
@ -540,13 +543,8 @@ blk_entry:
pushf pushf
push ax push ax
push bx push bx
push cx
push dx
push bp
push si
push di
push ds push ds
push es
; small model ; small model
mov ax,DGROUP ; correct for segments mov ax,DGROUP ; correct for segments
@ -560,24 +558,39 @@ blk_entry:
mov sp,blk_stk_top mov sp,blk_stk_top
push bx push bx
popf ; restore interrupt flag 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+2]
push word [cs:_ReqPktPtr] push word [cs:_ReqPktPtr]
call far _reloc_call_blk_driver call far _reloc_call_blk_driver
pop cx pop cx
pop cx pop cx
les bx,[cs:_ReqPktPtr] ; now return completion code les bx,[cs:_ReqPktPtr] ; now return completion code
mov word [es:bx+status],ax ; mark operation complete 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 es
pop ds
pop di pop di
pop si pop si
pop bp pop bp
pop dx pop dx
pop cx pop cx
cli ; no interrupts
mov sp,[blk_dos_stk] ; use dos stack
mov ss,[blk_dos_seg]
pop ds
pop bx pop bx
pop ax pop ax
popf popf

View File

@ -28,6 +28,9 @@
; $Id$ ; $Id$
; ;
; $Log$ ; $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 ; Revision 1.9 2001/04/15 03:21:50 bartoldeman
; See history.txt for the list of fixes. ; See history.txt for the list of fixes.
; ;
@ -126,7 +129,7 @@
%include "segs.inc" %include "segs.inc"
segment _TEXT segment PSP
extern _ReqPktPtr:wrt TGROUP extern _ReqPktPtr:wrt TGROUP
@ -145,7 +148,7 @@ segment INIT_TEXT
; kernel start-up ; kernel start-up
; ;
kernel_start: kernel_start:
mov ax,DGROUP mov ax,IGROUP
cli cli
mov ss,ax mov ss,ax
mov sp,init_tos mov sp,init_tos
@ -170,6 +173,8 @@ kernel_start:
push ax push ax
retf retf
cont: ; inititalize api stacks for high water tests cont: ; inititalize api stacks for high water tests
mov ax,cs
mov ss,ax
mov di,seg apistk_bottom mov di,seg apistk_bottom
mov es,di mov es,di
mov di,apistk_bottom mov di,apistk_bottom
@ -181,7 +186,7 @@ cont: ; inititalize api stacks for high water tests
cld cld
rep stosw rep stosw
; Now set up call frame ; Now set up call frame
mov ax,ss mov ax,DGROUP
mov ds,ax mov ds,ax
mov es,ax mov es,ax
mov bp,sp ; and set up stack frame for c 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 inc al
mov byte [_NumFloppies],al ; and how many mov byte [_NumFloppies],al ; and how many
mov ax,ds mov ax,cs
mov ds,ax
mov es,ax mov es,ax
jmp _main jmp _main
segment INIT_TEXT_END segment INIT_TEXT_END
init_end:
segment _TEXT segment _TEXT
@ -271,7 +276,7 @@ _clock dd 0 ; 0008 CLOCK$ device
global _syscon global _syscon
_syscon dd 0 ; 000c console device _syscon dd 0 ; 000c console device
global _maxbksize global _maxbksize
_maxbksize dw 0 ; 0010 Number of Drives in system _maxbksize dw 512 ; 0010 maximum bytes/sector of any block device
global _firstbuf; global _firstbuf;
_firstbuf dd 0 ; 0012 head of buffers linked list _firstbuf dd 0 ; 0012 head of buffers linked list
global _CDSp global _CDSp
@ -286,7 +291,9 @@ _nblkdev db 0 ; 0020 number of block devices
_lastdrive db 0 ; 0021 value of last drive _lastdrive db 0 ; 0021 value of last drive
global _nul_dev global _nul_dev
_nul_dev: ; 0022 device chain root _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 8004h ; attributes = char device, NUL bit set
dw _nul_strtgy dw _nul_strtgy
dw _nul_intr dw _nul_intr
@ -300,7 +307,7 @@ setverPtr dw 0,0 ; 0037 setver list
dw 1 ; 003F number of buffers dw 1 ; 003F number of buffers
dw 1 ; 0041 size of pre-read buffer dw 1 ; 0041 size of pre-read buffer
global _BootDrive 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) db 0 ; 0044 cpu type (1 if >=386)
dw 0 ; 0045 Extended memory in KBytes dw 0 ; 0045 Extended memory in KBytes
buf_info dd 0 ; 0047 disk buffer chain buf_info dd 0 ; 0047 disk buffer chain
@ -328,8 +335,6 @@ SysVarEnd:
; We've got (01fb-006a) some room here: don't use all zeros! ; 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 ; Some references seem to indicate that this data should start at 01fbh in
; order to maintain 100% MS-DOS compatibility. ; order to maintain 100% MS-DOS compatibility.
times (01fbh - ($ - DATASTART)) db 0 times (01fbh - ($ - DATASTART)) db 0
@ -409,13 +414,14 @@ _CritErrCode dw 0 ; 04 - DOS format error Code
_CritErrAction db 0 ; 06 - Error Action Code _CritErrAction db 0 ; 06 - Error Action Code
_CritErrClass db 0 ; 07 - Error Class _CritErrClass db 0 ; 07 - Error Class
_CritErrDev dd 0 ; 08 - Failing Device Address _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 _cu_psp dw 0 ; 10 - Current PSP
break_sp dw 0 ; 12 - used in int 23 break_sp dw 0 ; 12 - used in int 23
_return_code db 0 ; 14 - return code from process _return_code db 0 ; 14 - return code from process
_return_mode db 0 ; 15 - reason for process terminate _return_mode db 0 ; 15 - reason for process terminate
_default_drive db 0 ; 16 - Current Drive _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 ; 18 - flag, code page switching
db 0 ; 19 - flag, copy of 18 on int 24h abort 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 ; mark front and end of bss area to clear
segment _BSSSTART segment IB_B
global __bssstart global __ib_start
__bssstart: __ib_start:
segment _BSSEND segment IB_E
global __bssend global __ib_end
__bssend: __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 segment _BSSEND
; blockdev private stack ; blockdev private stack
@ -622,12 +639,8 @@ clk_stk_top:
; times 256 dw 0 ; times 256 dw 0
;intr_stk_top: ;intr_stk_top:
segment ID ; init data global __bssend
retaddr dd 0 ; return address to jump to from HMA_TEXT __bssend:
; kernel startup stack
global init_tos
times 256 dw 0
init_tos:
segment ID_B segment ID_B
global __INIT_DATA_START global __INIT_DATA_START
@ -659,7 +672,9 @@ segment HMA_TEXT
times 16 db 0 ; filler [ffff:0..ffff:10] times 16 db 0 ; filler [ffff:0..ffff:10]
times 22 db 0 ; filler [sizeof VDISK info] 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 ;End of HMA segment
segment HMA_TEXT_END segment HMA_TEXT_END
@ -699,77 +714,38 @@ segment INIT_TEXT
call far initforceEnableA20 ; first enable A20 or not call far initforceEnableA20 ; first enable A20 or not
manip_stack_A20: manip_stack_A20:
pop word [retaddr+2] ; get last ret address pop dx ; get last ret address
pop word [retaddr] ; get near ret address of init caller pop word [retoff] ; get near ret address of init caller
mov ax, init_ret ; new init caller ret address mov ax, init_ret_np ; new init caller ret address
push ax push ax
push word [retaddr+2] ; and back to the relocation entry jmp dx ; and back to the relocation entry
mov [retaddr+2], cs ; retaddr is now a far pointer to where we came from
ret
global __HMAinitRelocationTableStart global __HMAinitRelocationTableStart
__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 extern _execrh
global _reloc_call_execrh global _reloc_call_execrh
_reloc_call_execrh: _reloc_call_execrh:
call manip_stack_A20 call manip_stack_A20
jmp far _execrh jmp far _execrh
extern _fatal
global _reloc_call_fatal
_reloc_call_fatal:
call manip_stack_A20
jmp far _fatal
extern _fmemcpy extern _fmemcpy
global _reloc_call_fmemcpy global _reloc_call_fmemcpy
_reloc_call_fmemcpy: _reloc_call_fmemcpy:
call manip_stack_A20 call manip_stack_A20
jmp far _fmemcpy 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 extern _strcpy
global _reloc_call_strcpy global _reloc_call_strcpy
_reloc_call_strcpy: _reloc_call_strcpy:
call manip_stack_A20 call manip_stack_A20
jmp far _strcpy jmp far _strcpy
extern _sti extern _fstrncpy
global _reloc_call_sti global _reloc_call_fstrncpy
_reloc_call_sti: _reloc_call_fstrncpy:
call manip_stack_A20 call manip_stack_A20
jmp far _sti jmp far _fstrncpy
extern _strcmp
global _reloc_call_strcmp
_reloc_call_strcmp:
call manip_stack_A20
jmp far _strcmp
extern _strlen extern _strlen
global _reloc_call_strlen global _reloc_call_strlen
@ -777,17 +753,11 @@ _reloc_call_strlen:
call manip_stack_A20 call manip_stack_A20
jmp far _strlen jmp far _strlen
extern _WritePCClock extern _fstrlen
global _reloc_call_WritePCClock global _reloc_call_fstrlen
_reloc_call_WritePCClock: _reloc_call_fstrlen:
call manip_stack_A20 call manip_stack_A20
jmp far _WritePCClock jmp far _fstrlen
extern _DaysFromYearMonthDay
global _reloc_call_DaysFromYearMonthDay
_reloc_call_DaysFromYearMonthDay:
call manip_stack_A20
jmp far _DaysFromYearMonthDay
extern _fmemset extern _fmemset
global _reloc_call_fmemset global _reloc_call_fmemset
@ -795,11 +765,11 @@ _reloc_call_fmemset:
call manip_stack_A20 call manip_stack_A20
jmp far _fmemset jmp far _fmemset
extern _p_0 extern _memset
global _reloc_call_p_0 global _reloc_call_memset
_reloc_call_p_0: _reloc_call_memset:
call manip_stack_A20 call manip_stack_A20
jmp far _p_0 jmp far _memset
global __HMAinitRelocationTableEnd global __HMAinitRelocationTableEnd
__HMAinitRelocationTableEnd: __HMAinitRelocationTableEnd:
@ -850,6 +820,11 @@ _int27_handler: jmp far reloc_call_int27_handler
_int0_handler: jmp far reloc_call_int0_handler _int0_handler: jmp far reloc_call_int0_handler
call near forceEnableA20 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 global _cpm_entry
extern reloc_call_cpm_entry extern reloc_call_cpm_entry
_cpm_entry: jmp far reloc_call_cpm_entry _cpm_entry: jmp far reloc_call_cpm_entry

View File

@ -5,6 +5,9 @@
# #
# $Log$ # $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 # Revision 1.9 2001/04/16 14:28:32 bartoldeman
# Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs # Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs
# #
@ -134,7 +137,8 @@ INCLUDEPATH = ..\HDR
#AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR #AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR
NASMFLAGS = -i../hdr/ NASMFLAGS = -i../hdr/
LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB 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 CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT
HDR=../hdr/ HDR=../hdr/
@ -190,6 +194,7 @@ EXE_dependencies = \
nls_hc.obj \ nls_hc.obj \
nlssupt.obj \ nlssupt.obj \
prf.obj \ prf.obj \
initprf.obj \
printer.obj \ printer.obj \
procsupt.obj \ procsupt.obj \
serial.obj \ serial.obj \
@ -224,7 +229,7 @@ kernel.exe: $(EXE_dependencies) $(LIBS)
$(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs
$(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc $(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc
$(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr $(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 +systime +task +int2f +irqstack +apisupt
$(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break
$(LIBUTIL) kernel +dosidle $(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 $(HDR)version.h proto.h turboc.cfg
$(CC) $(INITCFLAGS) -c initHMA.c $(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 # XXX: I generated these using `gcc -MM' and `sed', so they may not be
# completely correct... -- ror4 # completely correct... -- ror4
blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \ blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \

View File

@ -27,10 +27,48 @@
/* Cambridge, MA 02139, USA. */ /* Cambridge, MA 02139, USA. */
/****************************************************************/ /****************************************************************/
#include "portab.h"
#include "init-mod.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 #ifdef VERSION_STRINGS
static BYTE *mainRcsId = "$Id$"; static BYTE *mainRcsId = "$Id$";
@ -38,6 +76,9 @@ static BYTE *mainRcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.14 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
* *
@ -168,18 +209,13 @@ static BYTE *mainRcsId = "$Id$";
* Initial revision. * Initial revision.
*/ */
extern UWORD DaysSinceEpoch;
extern WORD days[2][13]; extern WORD days[2][13];
extern BYTE FAR * lpBase; extern BYTE FAR * lpBase;
extern BYTE FAR * upBase; extern BYTE FAR * upBase;
extern BYTE _ib_start[], _ib_end[];
INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *);
VOID WritePCClock(ULONG);
INIT VOID configDone(VOID); INIT VOID configDone(VOID);
INIT static void InitIO(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 update_dcb(struct dhdr FAR *);
INIT static VOID init_kernel(VOID); INIT static VOID init_kernel(VOID);
@ -187,29 +223,15 @@ INIT static VOID signon(VOID);
INIT VOID kernel(VOID); INIT VOID kernel(VOID);
INIT VOID FsConfig(VOID); INIT VOID FsConfig(VOID);
#ifdef __TURBOC__
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
#endif
INIT VOID main(void) INIT VOID main(void)
{ {
setvec(0, int0_handler); /* zero divide */ setvec(0, int0_handler); /* zero divide */
setvec(1, empty_handler); /* single step */ setvec(1, empty_handler); /* single step */
setvec(3, empty_handler); /* debug breakpoint */ 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(); init_kernel();
@ -231,20 +253,17 @@ INIT VOID main(void)
at least one known utility (norton DE) seems to access them directly. at least one known utility (norton DE) seems to access them directly.
ok, so we access for all drives, that the stuff gets build 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) void InitializeAllBPBs(VOID)
{ {
static char filename[] = "A:-@JUNK@-.TMP"; static char filename[] = "A:-@JUNK@-.TMP";
int drive,fileno; int drive,fileno;
for (drive = 'Z'; drive >= 'C'; drive--) for (drive = 'C'; drive < 'A'+nblkdev; drive++)
{ {
filename[0] = drive; filename[0] = drive;
if ((fileno = init_DosOpen(filename, O_RDONLY)) >= 0) if ((fileno = open(filename, O_RDONLY)) >= 0)
init_DosClose(fileno); close(fileno);
} }
} }
*/
INIT void init_kernel(void) INIT void init_kernel(void)
{ {
@ -253,24 +272,12 @@ INIT void init_kernel(void)
os_major = MAJOR_RELEASE; os_major = MAJOR_RELEASE;
os_minor = MINOR_RELEASE; os_minor = MINOR_RELEASE;
nblkdev = 0;
maxbksize = 0x200;
switchar = '/';
dosidle_flag = 1;
/* Init oem hook - returns memory size in KB */ /* Init oem hook - returns memory size in KB */
ram_top = init_oem(); ram_top = init_oem();
UMB_top = 0;
umb_start = 0;
/* Fake int 21h stack frame */ /* Fake int 21h stack frame */
user_r = (iregs FAR *) DOS_PSP + 0xD0; user_r = (iregs FAR *) DOS_PSP + 0xD0;
/* Set Init DTA to Tempbuffer */
dta = (BYTE FAR *) &TempBuffer;
#ifndef KDB #ifndef KDB
for (i = 0x20; i <= 0x3f; i++) for (i = 0x20; i <= 0x3f; i++)
setvec(i, empty_handler); setvec(i, empty_handler);
@ -278,8 +285,6 @@ INIT void init_kernel(void)
/* Initialize IO subsystem */ /* Initialize IO subsystem */
InitIO(); InitIO();
syscon = (struct dhdr FAR *)&con_dev;
clock = (struct dhdr FAR *)&clk_dev;
#ifndef KDB #ifndef KDB
/* set interrupt vectors */ /* set interrupt vectors */
@ -297,10 +302,6 @@ INIT void init_kernel(void)
setvec(0x2f, int2f_handler); setvec(0x2f, int2f_handler);
#endif #endif
/* Initialize the screen handler for backspaces */
scr_pos = 0;
break_ena = TRUE;
init_PSPInit(DOS_PSP); init_PSPInit(DOS_PSP);
/* Do first initialization of system variable buffers so that */ /* Do first initialization of system variable buffers so that */
@ -318,7 +319,7 @@ INIT void init_kernel(void)
/* Close all (device) files */ /* Close all (device) files */
for (i = 0; i < lastdrive; i++) for (i = 0; i < lastdrive; i++)
init_DosClose(i); close(i);
/* and do final buffer allocation. */ /* and do final buffer allocation. */
PostConfig(); PostConfig();
@ -334,18 +335,13 @@ INIT void init_kernel(void)
/* Close all (device) files */ /* Close all (device) files */
for (i = 0; i < lastdrive; i++) for (i = 0; i < lastdrive; i++)
init_DosClose(i); close(i);
/* Now config the final file system */ /* Now config the final file system */
FsConfig(); FsConfig();
#endif #endif
/* Now to initialize all special flags, etc. */ InitializeAllBPBs();
mem_access_mode = FIRST_FIT;
verify_ena = FALSE;
InDOS = 0;
pDirFileNode = 0;
dosidle_flag = 0;
} }
INIT VOID FsConfig(VOID) INIT VOID FsConfig(VOID)
@ -353,38 +349,31 @@ INIT VOID FsConfig(VOID)
REG COUNT i; REG COUNT i;
struct dpb FAR *dpb; 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 */ /* 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_next = (sfttbl FAR *) - 1;
sfthead->sftt_count = Config.cfgFiles; 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_count = 0;
sfthead->sftt_table[i].sft_status = -1; sfthead->sftt_table[i].sft_status = -1;
} }
/* 0 is /dev/con (stdin) */ /* 0 is /dev/con (stdin) */
init_DosOpen("CON", SFT_MREAD); open("CON", O_RDWR);
sfthead->sftt_table[0].sft_flags |= SFT_FCONIN | SFT_FCONOUT;
/* 1 is /dev/con (stdout) */ /* 1 is /dev/con (stdout) */
init_DosOpen("CON", SFT_MWRITE); dup2(STDIN, STDOUT);
sfthead->sftt_table[1].sft_flags |= SFT_FCONIN | SFT_FCONOUT;
/* 2 is /dev/con (stderr) */ /* 2 is /dev/con (stderr) */
init_DosOpen("CON", SFT_MWRITE); dup2(STDIN, STDERR);
sfthead->sftt_table[2].sft_flags |= SFT_FCONIN | SFT_FCONOUT;
/* 3 is /dev/aux */ /* 3 is /dev/aux */
init_DosOpen("AUX", SFT_MRDWR); open("AUX", O_RDWR);
sfthead->sftt_table[3].sft_flags &= ~SFT_FEOF;
/* 4 is /dev/prn */ /* 4 is /dev/prn */
init_DosOpen("PRN", SFT_MWRITE); open("PRN", O_WRONLY);
sfthead->sftt_table[4].sft_flags &= ~SFT_FEOF;
/* Log-in the default drive. */ /* Log-in the default drive. */
/* Get the boot drive from the ipl and use it for default. */ /* Get the boot drive from the ipl and use it for default. */
@ -423,32 +412,43 @@ INIT VOID FsConfig(VOID)
INIT VOID signon() 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); os_major, os_minor, copyright);
printf(os_release, fmemcpy(tmp_or, os_release, 81);
printf(tmp_or,
REVISION_MAJOR, REVISION_MINOR, REVISION_SEQ, REVISION_MAJOR, REVISION_MINOR, REVISION_SEQ,
BUILD); BUILD);
} }
INIT void kernel() INIT void kernel()
{ {
seg asize; #if 0
BYTE FAR *ep, BYTE FAR *ep,
*sp; *sp;
#endif
exec_blk exb;
CommandTail Cmd;
int rc;
#ifndef KDB #ifndef KDB
static BYTE *path = "PATH=."; static BYTE master_env[] = "PATH=.\0\0\0\0\0";
/* static BYTE *path = "PATH=.";*/
#endif #endif
#ifdef KDB #ifdef KDB
kdb(); kdb();
#else #else
#if 0
/* create the master environment area */ /* 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 */ /* populate it with the minimum environment */
++master_env; ++exb.exec.env_seg;
ep = MK_FP(master_env, 0); ep = MK_FP(exb.exec.env_seg, 0);
for (sp = path; *sp != 0;) for (sp = path; *sp != 0;)
*ep++ = *sp++; *ep++ = *sp++;
@ -457,9 +457,55 @@ INIT void kernel()
*ep++ = '\0'; *ep++ = '\0';
*((int FAR *)ep) = 0; *((int FAR *)ep) = 0;
ep += sizeof(int); ep += sizeof(int);
#else
exb.exec.env_seg = DOS_PSP+8;
fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env));
#endif #endif
#endif
RootPsp = ~0; 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 */ /* check for a block device and update device control block */
@ -548,49 +594,27 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_
update_dcb(dhp); update_dcb(dhp);
} }
if (dhp->dh_attr & ATTR_CONIN)
syscon = dhp;
else if (dhp->dh_attr & ATTR_CLOCK)
clock = dhp;
return FALSE; return FALSE;
} }
INIT static void InitIO(void) INIT static void InitIO(void)
{ {
BYTE bcd_days[4],
bcd_minutes,
bcd_hours,
bcd_seconds;
ULONG ticks;
/* Initialize driver chain */ /* Initialize driver chain */
nul_dev.dh_next = (struct dhdr FAR *)&con_dev;
setvec(0x29, int29_handler); /* Requires Fast Con Driver */ setvec(0x29, int29_handler); /* Requires Fast Con Driver */
init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top); init_device(&con_dev, NULL, NULL, ram_top);
init_device((struct dhdr FAR *)&clk_dev, NULL, NULL, ram_top); init_device(&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))
/* issue an internal error message */
VOID init_fatal(BYTE * err_msg)
{ {
DaysSinceEpoch = DaysFromYearMonthDay( printf("\nInternal kernel error - %s\nSystem halted\n", err_msg);
100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]), for (;;) ;
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 static COUNT BcdToByte(COUNT x)
{
return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf));
}

View File

@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.13 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * 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) it will be useful (maybe for storing environments)
*/ */
#if 0
BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */ BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */
extern BYTE _INIT_DATA_START[], _INIT_DATA_END[]; extern BYTE _INIT_DATA_START[], _INIT_DATA_END[];
@ -739,5 +742,5 @@ VOID ClaimINITDataSegment()
first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4); first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4);
} }
#endif
#endif #endif

View File

@ -28,6 +28,17 @@
#include "portab.h" #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 */ COUNT fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */
@ -37,6 +48,9 @@ static BYTE *prfRcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.8 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * 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 * recoded for smaller object footprint, added main() for testing+QA
* *
* $Log$ * $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 * Revision 1.8 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * 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) void hexd(char *title,UBYTE FAR *p,COUNT numBytes)
{ {
int loop; int loop;
printf("%s%04x|",title,p); printf("%s%04x|", title, FP_SEG(p));
for (loop = 0; loop < numBytes; loop++) for (loop = 0; loop < numBytes; loop++)
printf("%02x ", p[loop]); printf("%02x ", p[loop]);
printf("|"); printf("|");

View File

@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.14 2001/04/16 01:45:26 bartoldeman
* Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs
* *
@ -166,8 +169,6 @@ static BYTE *Proto_hRcsId = "$Id$";
*Initial revision. *Initial revision.
*/ */
#define INIT
/* blockio.c */ /* blockio.c */
ULONG getblkno(struct buffer FAR *); ULONG getblkno(struct buffer FAR *);
VOID setblkno(struct buffer FAR *, ULONG); VOID setblkno(struct buffer FAR *, ULONG);
@ -193,24 +194,10 @@ BOOL con_break(void);
BOOL StdinBusy(void); BOOL StdinBusy(void);
VOID KbdFlush(void); VOID KbdFlush(void);
VOID Do_DosIdle_loop(void); VOID Do_DosIdle_loop(void);
VOID sti(keyboard FAR * kp); UCOUNT sti(keyboard FAR * kp);
sft FAR *get_sft(COUNT); 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 */ /* dosfns.c */
BYTE FAR *get_root(BYTE FAR *); BYTE FAR *get_root(BYTE FAR *);
BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); 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, UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err,
BOOL force_binary); BOOL force_binary);
COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode); 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); 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 DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos);
COUNT DosCreat(BYTE FAR * fname, COUNT attrib); COUNT DosCreat(BYTE FAR * fname, COUNT attrib);
@ -355,49 +343,9 @@ BOOL FcbClose(xfcb FAR * lpXfcb);
BOOL FcbFindFirst(xfcb FAR * lpXfcb); BOOL FcbFindFirst(xfcb FAR * lpXfcb);
BOOL FcbFindNext(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 */ /* ioctl.c */
COUNT DosDevIOctl(iregs FAR * r); 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 */ /* memmgr.c */
seg far2para(VOID FAR * p); seg far2para(VOID FAR * p);
seg long2para(ULONG size); seg long2para(ULONG size);
@ -497,7 +445,6 @@ LONG WordToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr);
/* syscon.c */ /* syscon.c */
WORD con_driver(rqptr rp); WORD con_driver(rqptr rp);
VOID break_handler(void); 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 */ /* syspack.c */
VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp); 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); VOID return_user(void);
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
VOID InitPSP(VOID); VOID InitPSP(VOID);
VOID p_0(VOID);
/* irqstack.asm */
VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize);
/* newstuff.c */ /* newstuff.c */
int SetJFTSize(UWORD nHandles); 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 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 QRemote_Fn(char FAR * s, char FAR * d);
COUNT Umb_Test(void);
UWORD get_machine_name(BYTE FAR * netname); UWORD get_machine_name(BYTE FAR * netname);
VOID set_machine_name(BYTE FAR * netname, UWORD name_num); 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); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err);

View File

@ -29,6 +29,9 @@
; $Header$ ; $Header$
; ;
; $Log$ ; $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 ; Revision 1.5 2001/04/15 03:21:50 bartoldeman
; See history.txt for the list of fixes. ; See history.txt for the list of fixes.
; ;
@ -60,11 +63,13 @@
; $EndLog ; $EndLog
; ;
group PGROUP PSP
group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA 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 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 _TEXT class=CODE
segment _IO_TEXT class=CODE segment _IO_TEXT class=CODE
segment _IO_FIXED_DATA class=CODE align=2 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 _BSSSTART class=BSS align=2
segment _BSS class=BSS align=2 segment _BSS class=BSS align=2
segment _BSSEND class=BSS 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_START class=HMA
segment HMA_TEXT class=HMA segment HMA_TEXT class=HMA
segment HMA_TEXT_END class=HMA segment HMA_TEXT_END class=HMA
segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT_START class=INIT align=16
segment INIT_TEXT class=INIT segment INIT_TEXT class=INIT
segment INIT_TEXT_END 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$ * $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 * Revision 1.5 2001/04/15 03:21:50 bartoldeman
* See history.txt for the list of fixes. * See history.txt for the list of fixes.
* *
@ -130,15 +133,48 @@ static BYTE bcdSeconds;
static ULONG Ticks; static ULONG Ticks;
UWORD DaysSinceEpoch = 0; 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) WORD FAR clk_driver(rqptr rp)
{ {
COUNT COUNT
c; c;
WORD *pdays; WORD *pdays;
BYTE bcd_days[4],
bcd_minutes,
bcd_hours,
bcd_seconds;
ULONG ticks;
switch (rp->r_command) switch (rp->r_command)
{ {
case C_INIT: 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_endaddr = device_end();
rp->r_nunits = 0; rp->r_nunits = 0;
return S_DONE; return S_DONE;

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/* /*
* $Log$ * $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 * Revision 1.12 2001/04/16 14:28:32 bartoldeman
* Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs * 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 * Rev 1.0 02 Jul 1995 8:34:06 patv
* Initial revision. * Initial revision.
*/ */
#if 0
extern VOID ClaimINITDataSegment(VOID); extern VOID ClaimINITDataSegment(VOID);
#endif
#define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) #define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c))
#define LOADNGO 0 #define LOADNGO 0
@ -451,8 +454,8 @@ set_name:
COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{ {
COUNT rc, COUNT rc
err /* err */
/*,env_size*/; /*,env_size*/;
COUNT nread; COUNT nread;
UWORD mem; UWORD mem;
@ -553,7 +556,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
} }
do do
{ {
nread = DosRead(rc, CHUNK, sp, &err); nread = DosRead(rc, CHUNK, sp, &UnusedRetVal);
sp = add_far((VOID FAR *) sp, (ULONG) nread); sp = add_far((VOID FAR *) sp, (ULONG) nread);
} }
while ((com_size -= nread) > 0 && nread == CHUNK); 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 1 microsecond from COMMAND.COM
now we claim the ID = INIT_DATA segment, now we claim the ID = INIT_DATA segment,
which should no longer be used which should no longer be used
*/
ClaimINITDataSegment(); ClaimINITDataSegment();
*/
if (InDOS) if (InDOS)
--InDOS; --InDOS;
@ -668,7 +671,7 @@ VOID return_user(void)
COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{ {
COUNT rc, COUNT rc,
err, /*err, */
/*env_size,*/ /*env_size,*/
i; i;
COUNT nBytesRead; COUNT nBytesRead;
@ -883,7 +886,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
do 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); sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead);
exe_size -= 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); doslseek(rc, (LONG) header.exRelocTable, 0);
for (i = 0; i < header.exRelocItems; i++) 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; 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 1 microsecond from COMMAND.COM
now we claim the ID = INIT_DATA segment, now we claim the ID = INIT_DATA segment,
which should no longer be used which should no longer be used
*/
ClaimINITDataSegment(); ClaimINITDataSegment();
*/
if (InDOS) if (InDOS)
--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 DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
{ {
COUNT rc, COUNT rc;
err;
exec_blk leb; exec_blk leb;
/* BYTE FAR *cp;*/ /* 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)) != sizeof(exe_header))
{ {
bIsCom = TRUE; bIsCom = TRUE;
@ -1024,32 +1026,4 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
return rc; 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 (;;) ;
}