break.c: check_handle_break() return type was undefined if no Ctrl-break

dosnames.c: macro to function conversion, optimisation and clean-up
dyninit.c:  "what" passed to the DynAlloc() function only in DEBUG mode
inithma.c:  InstallVDISK() function inlined, optimised and cleaned up
prf.c:      fixed long argument bug introduced in the previous optimisation


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1035 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Luchezar Georgiev 2004-09-11 15:52:57 +00:00
parent 6eff2f4bb2
commit 79720273dc
7 changed files with 67 additions and 97 deletions

View File

@ -308,11 +308,13 @@
(the last 2 changes needed to fix bugs discovered by Michael Devore) (the last 2 changes needed to fix bugs discovered by Michael Devore)
- added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0
* autoexec.bat now single-line for FreeCOM compatibility when EOL=LF * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF
* break.c: check_handle_break() return was undefined if no Ctrl-break
* config.sys: all commands removed as they were close to defaults * config.sys: all commands removed as they were close to defaults
* contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino * contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino
* country.asm / country.sys support now replaces hard-coded data * country.asm / country.sys support now replaces hard-coded data
* 8 countries added to country.asm: GR, RO, AT, KR, TR, IN, M.East, IL * 11 countries added to country.asm: GR,RO,AT,MA,SG,KR,CN,TR,IN,M.E,IL
* dyninit.c: unused function DynFree() commented out * dosnames.c: macro to function conversion, optimisation and clean-up
* dyninit.c: excluded unused DynFree(), "what" passed only on DEBUG
* fatfs.c: * fatfs.c:
- zero creation/access stamp on directory entry write as MS-DOS 7.10 - zero creation/access stamp on directory entry write as MS-DOS 7.10
- prevent removal or renaming of the current directory of that drive - prevent removal or renaming of the current directory of that drive
@ -323,6 +325,7 @@
- if no floppy drives present, don't initialise DDT for drive A: - if no floppy drives present, don't initialise DDT for drive A:
- " - Initdisk" no longer shifts text if no FAT partitions found - " - Initdisk" no longer shifts text if no FAT partitions found
- converted cdiv() from macro to function; optimise and clean-up - converted cdiv() from macro to function; optimise and clean-up
* inithma: InstallVDISK() function inlined, optimised and cleaned up
* intr.asm: lseek() added (necessary for COUNTRY.SYS processing) * intr.asm: lseek() added (necessary for COUNTRY.SYS processing)
* ioctl.c: * ioctl.c:
- r_si/r_di contents added as documented in PC-DOS Technical Update - r_si/r_di contents added as documented in PC-DOS Technical Update

View File

@ -53,7 +53,7 @@ unsigned char ctrl_break_pressed(void)
unsigned char check_handle_break(struct dhdr FAR **pdev) unsigned char check_handle_break(struct dhdr FAR **pdev)
{ {
unsigned char c; unsigned char c = 0;
if (ctrl_break_pressed() || if (ctrl_break_pressed() ||
(c = (unsigned char)ndread(&syscon)) == CTL_C || (c = (unsigned char)ndread(&syscon)) == CTL_C ||
*pdev != syscon && (c = (unsigned char)ndread(pdev)) == CTL_C) *pdev != syscon && (c = (unsigned char)ndread(pdev)) == CTL_C)
@ -76,7 +76,7 @@ unsigned char check_handle_break(struct dhdr FAR **pdev)
void handle_break(struct dhdr FAR **pdev, int sft_out) void handle_break(struct dhdr FAR **pdev, int sft_out)
{ {
char *buf = "^C\r\n"; static char *buf = "^C\r\n";
CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ CB_FLG &= ~CB_MSK; /* reset the ^Break flag */
con_flush(pdev); con_flush(pdev);

View File

@ -39,30 +39,10 @@ static BYTE *dosnamesRcsId =
const char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,"; const char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,";
#define PathSep(c) ((c)=='/'||(c)=='\\') STATIC BOOL charOK(const char *s, const char c)
#define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z'))
#define DirChar(c) (((unsigned char)(c)) >= ' ' && \
!strchr(_DirWildNameChars+5, (c)))
#define WildChar(c) (((unsigned char)(c)) >= ' ' && \
!strchr(_DirWildNameChars+2, (c)))
#define NameChar(c) (((unsigned char)(c)) >= ' ' && \
!strchr(_DirWildNameChars, (c)))
VOID XlateLcase(BYTE * szFname, COUNT nChars);
VOID DosTrimPath(BYTE * lpszPathNamep);
/* Should be converted to a portable version after v1.0 is released. */
#if 0
VOID XlateLcase(BYTE * szFname, COUNT nChars)
{ {
while (nChars--) return (UBYTE)c >= ' ' && !strchr(s, c);
{
if (*szFname >= 'a' && *szFname <= 'z')
*szFname -= ('a' - 'A');
++szFname;
}
} }
#endif
/* /*
MSD durring an FindFirst search string looks like this; MSD durring an FindFirst search string looks like this;
@ -89,18 +69,15 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards)
lpszLclDir = lpszLclFile = filename; lpszLclDir = lpszLclFile = filename;
filename += 2; filename += 2;
while (DirChar(*filename)) while (charOK(_DirWildNameChars + 5, *filename))
{ if (*filename++ == '\\')
if (*filename == '\\') lpszLclFile = filename;
lpszLclFile = filename + 1;
++filename;
}
nDirCnt = lpszLclFile - lpszLclDir; nDirCnt = lpszLclFile - lpszLclDir;
/* Parse out the file name portion. */ /* Parse out the file name portion. */
filename = lpszLclFile; filename = lpszLclFile;
while (bAllowWildcards ? WildChar(*filename) : while (charOK(bAllowWildcards ? _DirWildNameChars + 2
NameChar(*filename)) : _DirWildNameChars, *filename))
{ {
++nFileCnt; ++nFileCnt;
++filename; ++filename;
@ -108,12 +85,11 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards)
if (nFileCnt == 0) if (nFileCnt == 0)
{ {
int err = DE_PATHNOTFND;
if (bAllowWildcards && *filename == '\0' && if (bAllowWildcards && *filename == '\0' &&
(nDirCnt == 3 || filename[-1] != '\\')) (nDirCnt == 3 || filename[-1] != '\\'))
/* D:\ or D:\DOS but not D:\DOS\ */ /* D:\ or D:\DOS but not D:\DOS\ */
err = DE_NFILES; return DE_NFILES;
return err; return DE_PATHNOTFND;
} }
/* Now we have pointers set to the directory portion and the */ /* Now we have pointers set to the directory portion and the */
@ -124,8 +100,8 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards)
lpszLclExt = ++filename; lpszLclExt = ++filename;
while (*filename) while (*filename)
{ {
if (bAllowWildcards ? WildChar(*filename) : if (charOK(bAllowWildcards ? _DirWildNameChars + 2
NameChar(*filename)) : _DirWildNameChars, *filename))
{ {
++nExtCnt; ++nExtCnt;
++filename; ++filename;

View File

@ -9,7 +9,13 @@
moveable and Dyn.Buffer resizable, but not before moveable and Dyn.Buffer resizable, but not before
*/ */
#ifdef DEBUG
void far *DynAlloc(char *what, unsigned num, unsigned size); void far *DynAlloc(char *what, unsigned num, unsigned size);
#else
void far *_DynAlloc(unsigned num, unsigned size);
#define DynAlloc(what, num, size) (_DynAlloc((num), (size)))
#endif
void far *DynLast(void); void far *DynLast(void);
void DynFree(void *ptr); void DynFree(void *ptr);

View File

@ -54,16 +54,16 @@ extern struct DynS DOSFAR ASM Dyn;
extern struct DynS FAR ASM Dyn; extern struct DynS FAR ASM Dyn;
#endif #endif
#ifdef DEBUG
void far *DynAlloc(char *what, unsigned num, unsigned size) void far *DynAlloc(char *what, unsigned num, unsigned size)
#else
void far *_DynAlloc(unsigned num, unsigned size)
#endif
{ {
void far *now; void far *now;
unsigned total = num * size; unsigned total = num * size;
struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn));
#ifndef DEBUG
UNREFERENCED_PARAMETER(what);
#endif
if ((ULONG) total + Dynp->Allocated > 0xffff) if ((ULONG) total + Dynp->Allocated > 0xffff)
{ {
printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated); printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated);

View File

@ -224,12 +224,33 @@ int MoveKernelToHMA()
DosLoadedInHMA = TRUE; DosLoadedInHMA = TRUE;
} }
/* /*
on finalize, will install a VDISK now protect against HIMEM/FDXMS/... by simulating a VDISK
*/ FDXMS should detect us and not give HMA access to ohers
unfortunately this also disables HIMEM completely
InstallVDISK(); so: we install this after all drivers have been loaded
*/
{
static struct { /* Boot sector of a RAM-Disk */
UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */
char Name[5];
BYTE dummy2[3];
WORD BpS;
BYTE dummy3[6];
WORD Sectors;
BYTE dummy4;
} VDISK_BOOT_SECTOR = {
{0xcf,' ',' '},
{"VDISK"},
{" "}, 512,
{"FDOS "}, 128, /* 128 * 512 = 64K */
' '
};
fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SECTOR,
sizeof(VDISK_BOOT_SECTOR));
*(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64;
}
/* report the fact we are running high through int 21, ax=3306 */ /* report the fact we are running high through int 21, ax=3306 */
LoL->version_flags |= 0x10; LoL->version_flags |= 0x10;
@ -238,43 +259,6 @@ int MoveKernelToHMA()
} }
/*
now protect against HIMEM/FDXMS/... by simulating a VDISK
FDXMS should detect us and not give HMA access to ohers
unfortunately this also disables HIMEM completely
so: we install this after all drivers have been loaded
*/
STATIC void InstallVDISK(void)
{
static struct { /* Boot-Sektor of a RAM-Disk */
UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */
char Name[5];
BYTE dummy2[3];
WORD BpS;
BYTE dummy3[6];
WORD Sektoren;
BYTE dummy4;
} VDISK_BOOT_SEKTOR = {
{
0xcf, ' ', ' '},
{
'V', 'D', 'I', 'S', 'K'},
{
' ', ' ', ' '}, 512,
{
'F', 'D', 'O', 'S', ' ', ' '}, 128, /* 128*512 = 64K */
' '};
if (!DosLoadedInHMA)
return;
fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SEKTOR,
sizeof(VDISK_BOOT_SEKTOR));
*(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64;
}
/* /*
this allocates some bytes from the HMA area this allocates some bytes from the HMA area
only available if DOS=HIGH was successful only available if DOS=HIGH was successful
@ -368,7 +352,8 @@ void MoveKernel(unsigned NewKernelSegment)
FP_OFF(_HMARelocationTableStart)) / FP_OFF(_HMARelocationTableStart)) /
sizeof(struct RelocationTable)); sizeof(struct RelocationTable));
int3(); int3();
goto errorReturn; for (;;)
;
} }
} }
@ -402,9 +387,5 @@ void MoveKernel(unsigned NewKernelSegment)
} }
CurrentKernelSegment = NewKernelSegment; CurrentKernelSegment = NewKernelSegment;
return;
errorReturn:
for (;;) ;
} }

View File

@ -118,7 +118,7 @@ void put_console(int c)
} }
#endif /* DOSEMU */ #endif /* DOSEMU */
#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) #if defined(DEBUG) || defined(FORSYS) || defined(_INIT) || defined(TEST)
#ifndef FORSYS #ifndef FORSYS
/* copied from bcc (Bruce's C compiler) stdarg.h */ /* copied from bcc (Bruce's C compiler) stdarg.h */
@ -264,6 +264,7 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg)
{ {
long n; long n;
ULONG u; ULONG u;
BOOL minus = FALSE;
BYTE *t = s + sizeof(s) - 1; BYTE *t = s + sizeof(s) - 1;
if (flags & LONGARG) if (flags & LONGARG)
@ -280,13 +281,16 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg)
{ {
base = -base; base = -base;
if (n < 0) if (n < 0)
{
u = -n; u = -n;
minus++;
}
} }
*t = '\0'; /* terminate the number string */ *t = '\0'; /* terminate the number string */
do /* generate digits in reverse order */ do /* generate digits in reverse order */
*--t = "0123456789ABCDEF"[(UWORD)u % base]; *--t = "0123456789ABCDEF"[(UWORD)(u % base)];
while ((u /= base) > 0); while ((u /= base) > 0);
if (n < 0) if (minus)
*--t = '-'; *--t = '-';
p = t; p = t;
} }
@ -380,12 +384,12 @@ void put_string(const char *s)
compile like (note -DTEST !) compile like (note -DTEST !)
c:\tc\tcc -DTEST -DI86 -Ihdr kernel\prf.c c:\tc\tcc -DTEST -Ihdr kernel\prf.c
and run. If strings are wrong, the program will wait for ENTER and run. If strings are wrong, the program will wait for a key
*/ */
#include <stdio.h> #include <conio.h>
#include <string.h> #include <string.h>
struct { struct {
@ -470,8 +474,8 @@ void test(char *should, char *format, unsigned lowint, unsigned highint)
if (strcmp(b, should)) if (strcmp(b, should))
{ {
printf("\nhit ENTER\n"); printf("\nhit a key\n");
getchar(); getch();
} }
} }