2000-05-06 21:34:20 +02:00
|
|
|
/****************************************************************/
|
|
|
|
/* */
|
|
|
|
/* main.c */
|
|
|
|
/* DOS-C */
|
|
|
|
/* */
|
|
|
|
/* Main Kernel Functions */
|
|
|
|
/* */
|
|
|
|
/* Copyright (c) 1995, 1996 */
|
|
|
|
/* 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, */
|
2003-06-30 20:46:37 +02:00
|
|
|
/* write to the Free Software Foundation, Inc., */
|
|
|
|
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */
|
2000-05-06 21:34:20 +02:00
|
|
|
/****************************************************************/
|
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
#include "portab.h"
|
2000-05-06 21:34:20 +02:00
|
|
|
#include "init-mod.h"
|
2001-09-23 22:39:44 +02:00
|
|
|
#include "dyndata.h"
|
|
|
|
|
2003-06-20 21:54:18 +02:00
|
|
|
#ifdef VERSION_STRINGS
|
|
|
|
static BYTE *mainRcsId =
|
|
|
|
"$Id$";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static char copyright[] =
|
2004-01-31 17:04:00 +01:00
|
|
|
"(C) Copyright 1995-2004 Pasquale J. Villani and The FreeDOS Project.\n"
|
2001-11-04 20:47:39 +01:00
|
|
|
"All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n"
|
|
|
|
"WARRANTY; you can redistribute it and/or modify it under the terms of the\n"
|
|
|
|
"GNU General Public License as published by the Free Software Foundation;\n"
|
|
|
|
"either version 2, or (at your option) any later version.\n";
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2004-04-14 01:46:25 +02:00
|
|
|
struct _KernelConfig InitKernelConfig BSS_INIT({0});
|
2001-11-04 20:47:39 +01:00
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC VOID InitIO(void);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC VOID update_dcb(struct dhdr FAR *);
|
|
|
|
STATIC VOID init_kernel(VOID);
|
|
|
|
STATIC VOID signon(VOID);
|
|
|
|
STATIC VOID kernel(VOID);
|
|
|
|
STATIC VOID FsConfig(VOID);
|
|
|
|
STATIC VOID InitPrinters(VOID);
|
2003-11-14 22:55:25 +01:00
|
|
|
STATIC VOID InitSerialPorts(VOID);
|
2003-06-20 21:54:18 +02:00
|
|
|
STATIC void CheckContinueBootFromHarddisk(void);
|
2004-05-04 11:32:16 +02:00
|
|
|
STATIC void setup_int_vectors(void);
|
2002-12-09 01:17:15 +01:00
|
|
|
|
2001-09-23 22:39:44 +02:00
|
|
|
#ifdef _MSC_VER
|
2001-11-18 15:01:12 +01:00
|
|
|
BYTE _acrtused = 0;
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
__segment DosDataSeg = 0; /* serves for all references to the DOS DATA segment
|
|
|
|
necessary for MSC+our funny linking model
|
|
|
|
*/
|
|
|
|
__segment DosTextSeg = 0;
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2004-04-14 01:46:25 +02:00
|
|
|
#endif
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2003-06-20 21:54:18 +02:00
|
|
|
struct lol FAR *LoL = &DATASTART;
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
VOID ASMCFUNC FreeDOSmain(void)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2003-09-19 04:13:35 +02:00
|
|
|
unsigned char drv;
|
2004-04-10 11:38:38 +02:00
|
|
|
unsigned char FAR *p;
|
2003-09-19 04:13:35 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
extern FAR prn_dev;
|
|
|
|
DosDataSeg = (__segment) & DATASTART;
|
|
|
|
DosTextSeg = (__segment) & prn_dev;
|
|
|
|
#endif
|
|
|
|
|
2004-04-14 10:50:35 +02:00
|
|
|
/* clear the Init BSS area (what normally the RTL does */
|
|
|
|
memset(_ib_start, 0, _ib_end - _ib_start);
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
/* if the kernel has been UPX'ed,
|
|
|
|
CONFIG info is stored at 50:e2 ..fc
|
|
|
|
and the bootdrive (passed from BIOS)
|
|
|
|
at 50:e0
|
2003-09-19 04:13:35 +02:00
|
|
|
*/
|
|
|
|
|
2004-04-10 11:38:38 +02:00
|
|
|
drv = LoL->BootDrive + 1;
|
|
|
|
p = MK_FP(0, 0x5e0);
|
|
|
|
if (fmemcmp(p+2,"CONFIG",6) == 0) /* UPX */
|
2002-02-17 11:39:35 +01:00
|
|
|
{
|
2004-04-10 11:38:38 +02:00
|
|
|
fmemcpy(&InitKernelConfig, p+2, sizeof(InitKernelConfig));
|
2003-06-30 20:46:37 +02:00
|
|
|
|
2004-04-10 11:38:38 +02:00
|
|
|
drv = *p + 1;
|
|
|
|
*(DWORD FAR *)(p+2) = 0;
|
2003-09-19 04:13:35 +02:00
|
|
|
}
|
2002-01-23 23:29:41 +01:00
|
|
|
else
|
2002-02-17 11:39:35 +01:00
|
|
|
{
|
2004-04-10 11:38:38 +02:00
|
|
|
*p = drv - 1;
|
2002-02-17 11:39:35 +01:00
|
|
|
fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig));
|
|
|
|
}
|
2003-09-19 04:13:35 +02:00
|
|
|
|
|
|
|
if (drv >= 0x80)
|
|
|
|
drv = 3; /* C: */
|
|
|
|
LoL->BootDrive = drv;
|
|
|
|
|
2004-05-04 11:32:16 +02:00
|
|
|
setup_int_vectors();
|
2003-06-15 16:38:13 +02:00
|
|
|
|
|
|
|
CheckContinueBootFromHarddisk();
|
|
|
|
|
2002-05-09 00:49:35 +02:00
|
|
|
signon();
|
2000-05-06 21:34:20 +02:00
|
|
|
init_kernel();
|
2001-03-21 03:56:26 +01:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* Non-portable message kludge alert! */
|
2003-06-15 17:53:58 +02:00
|
|
|
printf("KERNEL: Boot drive = %c\n", 'A' + LoL->BootDrive - 1);
|
2000-05-06 21:34:20 +02:00
|
|
|
#endif
|
2003-03-13 00:06:48 +01:00
|
|
|
|
|
|
|
DoInstall();
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
kernel();
|
|
|
|
}
|
|
|
|
|
2001-03-30 21:30:06 +02:00
|
|
|
/*
|
|
|
|
InitializeAllBPBs()
|
|
|
|
|
|
|
|
or MakeNortonDiskEditorHappy()
|
|
|
|
|
|
|
|
it has been determined, that FDOS's BPB tables are initialized,
|
|
|
|
only when used (like DIR H:).
|
|
|
|
at least one known utility (norton DE) seems to access them directly.
|
|
|
|
ok, so we access for all drives, that the stuff gets build
|
|
|
|
*/
|
2001-04-15 05:21:50 +02:00
|
|
|
void InitializeAllBPBs(VOID)
|
2001-03-30 21:30:06 +02:00
|
|
|
{
|
|
|
|
static char filename[] = "A:-@JUNK@-.TMP";
|
2001-11-18 15:01:12 +01:00
|
|
|
int drive, fileno;
|
2003-06-15 17:53:58 +02:00
|
|
|
for (drive = 'C'; drive < 'A' + LoL->nblkdev; drive++)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
|
|
|
filename[0] = drive;
|
|
|
|
if ((fileno = open(filename, O_RDONLY)) >= 0)
|
|
|
|
close(fileno);
|
|
|
|
}
|
|
|
|
}
|
2001-03-30 21:30:06 +02:00
|
|
|
|
2004-03-17 22:28:54 +01:00
|
|
|
STATIC void PSPInit(void)
|
|
|
|
{
|
|
|
|
psp far *p = MK_FP(DOS_PSP, 0);
|
|
|
|
|
|
|
|
/* Clear out new psp first */
|
|
|
|
fmemset(p, 0, sizeof(psp));
|
|
|
|
|
|
|
|
/* initialize all entries and exits */
|
|
|
|
/* CP/M-like exit point */
|
|
|
|
p->ps_exit = 0x20cd;
|
|
|
|
|
|
|
|
/* CP/M-like entry point - call far to special entry */
|
|
|
|
p->ps_farcall = 0x9a;
|
|
|
|
p->ps_reentry = MK_FP(0, 0x30 * 4);
|
|
|
|
/* unix style call - 0xcd 0x21 0xcb (int 21, retf) */
|
|
|
|
p->ps_unix[0] = 0xcd;
|
|
|
|
p->ps_unix[1] = 0x21;
|
|
|
|
p->ps_unix[2] = 0xcb;
|
|
|
|
|
|
|
|
/* Now for parent-child relationships */
|
|
|
|
/* parent psp segment */
|
|
|
|
p->ps_parent = FP_SEG(p);
|
|
|
|
/* previous psp pointer */
|
|
|
|
p->ps_prevpsp = MK_FP(0xffff,0xffff);
|
|
|
|
|
|
|
|
/* Environment and memory useage parameters */
|
|
|
|
/* memory size in paragraphs */
|
|
|
|
/* p->ps_size = 0; clear from above */
|
|
|
|
/* environment paragraph */
|
|
|
|
p->ps_environ = DOS_PSP + 8;
|
|
|
|
/* terminate address */
|
|
|
|
p->ps_isv22 = getvec(0x22);
|
|
|
|
/* break address */
|
|
|
|
p->ps_isv23 = getvec(0x23);
|
|
|
|
/* critical error address */
|
|
|
|
p->ps_isv24 = getvec(0x24);
|
|
|
|
|
|
|
|
/* user stack pointer - int 21 */
|
|
|
|
/* p->ps_stack = NULL; clear from above */
|
|
|
|
|
|
|
|
/* File System parameters */
|
|
|
|
/* maximum open files */
|
|
|
|
p->ps_maxfiles = 20;
|
|
|
|
fmemset(p->ps_files, 0xff, 20);
|
|
|
|
|
|
|
|
/* open file table pointer */
|
|
|
|
p->ps_filetab = p->ps_files;
|
|
|
|
|
|
|
|
/* first command line argument */
|
|
|
|
/* p->ps_fcb1.fcb_drive = 0; already set */
|
|
|
|
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
|
|
|
|
/* second command line argument */
|
|
|
|
/* p->ps_fcb2.fcb_drive = 0; already set */
|
|
|
|
fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
|
|
|
|
|
|
|
|
/* local command line */
|
|
|
|
/* p->ps_cmd.ctCount = 0; command tail, already set */
|
|
|
|
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */
|
|
|
|
}
|
|
|
|
|
2004-05-10 22:15:37 +02:00
|
|
|
#ifndef __WATCOMC__
|
2004-05-10 22:49:43 +02:00
|
|
|
/* for WATCOMC we can use the ones in task.c */
|
|
|
|
intvec getvec(unsigned char intno)
|
|
|
|
{
|
|
|
|
intvec iv;
|
|
|
|
disable();
|
|
|
|
iv = *(intvec FAR *)MK_FP(0,4 * (intno));
|
|
|
|
enable();
|
|
|
|
return iv;
|
|
|
|
}
|
|
|
|
|
2004-05-04 11:32:16 +02:00
|
|
|
void setvec(unsigned char intno, intvec vector)
|
|
|
|
{
|
|
|
|
disable();
|
|
|
|
*(intvec FAR *)MK_FP(0,4 * intno) = vector;
|
|
|
|
enable();
|
|
|
|
}
|
2004-05-10 22:15:37 +02:00
|
|
|
#endif
|
2004-05-04 11:32:16 +02:00
|
|
|
|
|
|
|
STATIC void setup_int_vectors(void)
|
|
|
|
{
|
|
|
|
static struct vec
|
|
|
|
{
|
|
|
|
unsigned char intno;
|
|
|
|
size_t handleroff;
|
|
|
|
} vectors[] =
|
|
|
|
{
|
|
|
|
/* all of these are in the DOS DS */
|
|
|
|
{ 0x0, FP_OFF(int0_handler) }, /* zero divide */
|
|
|
|
{ 0x1, FP_OFF(empty_handler) }, /* single step */
|
|
|
|
{ 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */
|
|
|
|
{ 0x6, FP_OFF(int6_handler) }, /* invalid opcode */
|
|
|
|
{ 0x20, FP_OFF(int20_handler) },
|
|
|
|
{ 0x21, FP_OFF(int21_handler) },
|
|
|
|
{ 0x22, FP_OFF(int22_handler) },
|
|
|
|
{ 0x24, FP_OFF(int24_handler) },
|
|
|
|
{ 0x25, FP_OFF(low_int25_handler) },
|
|
|
|
{ 0x26, FP_OFF(low_int26_handler) },
|
|
|
|
{ 0x27, FP_OFF(int27_handler) },
|
|
|
|
{ 0x28, FP_OFF(int28_handler) },
|
|
|
|
{ 0x2a, FP_OFF(int2a_handler) },
|
|
|
|
{ 0x2f, FP_OFF(int2f_handler) }
|
|
|
|
};
|
|
|
|
struct vec *pvec;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0x23; i <= 0x3f; i++)
|
|
|
|
setvec(i, empty_handler);
|
|
|
|
for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++)
|
2004-05-10 03:00:40 +02:00
|
|
|
setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff));
|
2004-05-04 11:32:16 +02:00
|
|
|
pokeb(0, 0x30 * 4, 0xea);
|
|
|
|
pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry);
|
2004-05-24 00:04:42 +02:00
|
|
|
|
|
|
|
/* these two are in the device driver area LOWTEXT (0x70) */
|
|
|
|
setvec(0x1b, got_cbreak);
|
|
|
|
setvec(0x29, int29_handler); /* required for printf! */
|
2004-05-04 11:32:16 +02:00
|
|
|
}
|
2004-03-17 22:28:54 +01:00
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC void init_kernel(void)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
COUNT i;
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2003-06-15 21:26:49 +02:00
|
|
|
LoL->os_setver_major = LoL->os_major = MAJOR_RELEASE;
|
|
|
|
LoL->os_setver_minor = LoL->os_minor = MINOR_RELEASE;
|
2001-04-15 05:21:50 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Init oem hook - returns memory size in KB */
|
|
|
|
ram_top = init_oem();
|
2000-06-21 20:16:46 +02:00
|
|
|
|
2001-07-28 20:13:06 +02:00
|
|
|
/* move kernel to high conventional RAM, just below the init code */
|
2004-04-10 16:18:25 +02:00
|
|
|
#ifdef __WATCOMC__
|
|
|
|
lpTop = MK_FP(_CS, 0);
|
|
|
|
#else
|
2004-04-10 12:59:57 +02:00
|
|
|
lpTop = MK_FP(_CS - (FP_OFF(_HMATextEnd) + 15) / 16, 0);
|
2004-04-10 16:18:25 +02:00
|
|
|
#endif
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2001-07-28 20:13:06 +02:00
|
|
|
MoveKernel(FP_SEG(lpTop));
|
2004-03-26 22:50:12 +01:00
|
|
|
lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0);
|
2001-07-28 20:13:06 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Initialize IO subsystem */
|
|
|
|
InitIO();
|
2001-09-23 22:39:44 +02:00
|
|
|
InitPrinters();
|
2003-11-14 22:55:25 +01:00
|
|
|
InitSerialPorts();
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-06-03 16:16:18 +02:00
|
|
|
init_PSPSet(DOS_PSP);
|
2003-08-31 00:17:42 +02:00
|
|
|
set_DTA(MK_FP(DOS_PSP, 0x80));
|
2004-03-17 22:28:54 +01:00
|
|
|
PSPInit();
|
2001-04-15 05:21:50 +02:00
|
|
|
|
2002-12-09 01:17:15 +01:00
|
|
|
Init_clk_driver();
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Do first initialization of system variable buffers so that */
|
|
|
|
/* we can read config.sys later. */
|
2003-06-15 17:53:58 +02:00
|
|
|
LoL->lastdrive = Config.cfgLastdrive;
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2003-10-30 13:22:06 +01:00
|
|
|
/* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, &ram_top); */
|
2001-07-10 00:19:33 +02:00
|
|
|
blk_dev.dh_name[0] = dsk_init();
|
2001-07-28 20:13:06 +02:00
|
|
|
|
|
|
|
PreConfig();
|
|
|
|
|
2001-07-10 00:19:33 +02:00
|
|
|
/* Number of units */
|
|
|
|
if (blk_dev.dh_name[0] > 0)
|
2001-11-18 15:01:12 +01:00
|
|
|
update_dcb(&blk_dev);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
/* Now config the temporary file system */
|
|
|
|
FsConfig();
|
|
|
|
|
|
|
|
/* Now process CONFIG.SYS */
|
2002-01-23 23:29:41 +01:00
|
|
|
DoConfig(0);
|
|
|
|
DoConfig(1);
|
2001-04-16 03:45:26 +02:00
|
|
|
|
2003-06-15 15:24:53 +02:00
|
|
|
/* initialize near data and MCBs */
|
|
|
|
PreConfig2();
|
|
|
|
/* and process CONFIG.SYS one last time for device drivers */
|
|
|
|
DoConfig(2);
|
|
|
|
|
2003-06-20 21:54:18 +02:00
|
|
|
|
2001-04-16 03:45:26 +02:00
|
|
|
/* Close all (device) files */
|
2003-07-14 21:17:01 +02:00
|
|
|
for (i = 0; i < 20; i++)
|
2001-04-22 00:32:53 +02:00
|
|
|
close(i);
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* and do final buffer allocation. */
|
|
|
|
PostConfig();
|
|
|
|
|
2001-04-15 05:21:50 +02:00
|
|
|
/* Init the file system one more time */
|
2000-05-06 21:34:20 +02:00
|
|
|
FsConfig();
|
2003-06-20 21:54:18 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
configDone();
|
2000-05-08 06:30:00 +02:00
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
InitializeAllBPBs();
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC VOID FsConfig(VOID)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2003-06-20 21:54:18 +02:00
|
|
|
struct dpb FAR *dpb = LoL->DPBp;
|
|
|
|
int i;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-04-15 05:21:50 +02:00
|
|
|
/* Initialize the current directory structures */
|
2003-06-15 17:53:58 +02:00
|
|
|
for (i = 0; i < LoL->lastdrive; i++)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2003-06-15 17:53:58 +02:00
|
|
|
struct cds FAR *pcds_table = &LoL->CDSp[i];
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 00:26:45 +01:00
|
|
|
fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4);
|
2001-03-21 03:56:26 +01:00
|
|
|
|
|
|
|
pcds_table->cdsCurrentPath[0] += i;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2003-06-15 17:53:58 +02:00
|
|
|
if (i < LoL->nblkdev && (ULONG) dpb != 0xffffffffl)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-04-15 05:21:50 +02:00
|
|
|
pcds_table->cdsDpb = dpb;
|
2001-03-21 03:56:26 +01:00
|
|
|
pcds_table->cdsFlags = CDSPHYSDRV;
|
2001-04-15 05:21:50 +02:00
|
|
|
dpb = dpb->dpb_next;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-21 03:56:26 +01:00
|
|
|
pcds_table->cdsFlags = 0;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
2001-03-21 03:56:26 +01:00
|
|
|
pcds_table->cdsStrtClst = 0xffff;
|
|
|
|
pcds_table->cdsParam = 0xffff;
|
|
|
|
pcds_table->cdsStoreUData = 0xffff;
|
|
|
|
pcds_table->cdsJoinOffset = 2;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2003-06-15 17:53:58 +02:00
|
|
|
/* Log-in the default drive. */
|
|
|
|
init_setdrive(LoL->BootDrive - 1);
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
/* The system file tables need special handling and are "hand */
|
|
|
|
/* built. Included is the stdin, stdout, stdaux and stdprn. */
|
2002-10-22 04:40:19 +02:00
|
|
|
/* a little bit of shuffling is necessary for compatibility */
|
2002-01-23 23:29:41 +01:00
|
|
|
|
2002-10-22 04:40:19 +02:00
|
|
|
/* sft_idx=0 is /dev/aux */
|
|
|
|
open("AUX", O_RDWR);
|
|
|
|
|
|
|
|
/* handle 1, sft_idx=1 is /dev/con (stdout) */
|
2002-01-23 23:29:41 +01:00
|
|
|
open("CON", O_RDWR);
|
|
|
|
|
2002-10-22 04:40:19 +02:00
|
|
|
/* 3 is /dev/aux */
|
|
|
|
dup2(STDIN, STDAUX);
|
2002-01-23 23:29:41 +01:00
|
|
|
|
2002-10-22 04:40:19 +02:00
|
|
|
/* 0 is /dev/con (stdin) */
|
|
|
|
dup2(STDOUT, STDIN);
|
2002-01-23 23:29:41 +01:00
|
|
|
|
2002-10-22 04:40:19 +02:00
|
|
|
/* 2 is /dev/con (stdin) */
|
|
|
|
dup2(STDOUT, STDERR);
|
2002-01-23 23:29:41 +01:00
|
|
|
|
|
|
|
/* 4 is /dev/prn */
|
|
|
|
open("PRN", O_WRONLY);
|
|
|
|
|
2001-04-15 05:21:50 +02:00
|
|
|
/* Initialize the disk buffer management functions */
|
2001-03-21 03:56:26 +01:00
|
|
|
/* init_call_init_buffers(); done from CONFIG.C */
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC VOID signon()
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2004-04-24 17:14:43 +02:00
|
|
|
printf("\r%S"
|
|
|
|
"Kernel compatibility %d.%d - "
|
2004-02-07 19:16:27 +01:00
|
|
|
#if defined(__BORLANDC__)
|
|
|
|
"BORLANDC"
|
|
|
|
#elif defined(__TURBOC__)
|
|
|
|
"TURBOC"
|
2001-09-23 22:39:44 +02:00
|
|
|
#elif defined(_MSC_VER)
|
2004-02-07 19:16:27 +01:00
|
|
|
"MSC"
|
2001-09-23 22:39:44 +02:00
|
|
|
#elif defined(__WATCOMC__)
|
2004-02-07 19:16:27 +01:00
|
|
|
"WATCOMC"
|
2002-08-03 18:54:09 +02:00
|
|
|
#elif defined(__GNUC__)
|
2004-02-07 19:16:27 +01:00
|
|
|
"GNUC" /* this is hypothetical only */
|
2001-09-23 22:39:44 +02:00
|
|
|
#else
|
2004-02-07 19:16:27 +01:00
|
|
|
#error Unknown compiler
|
2001-11-18 15:01:12 +01:00
|
|
|
generate some bullshit error here, as the compiler should be known
|
2001-09-23 22:39:44 +02:00
|
|
|
#endif
|
|
|
|
#if defined (I386)
|
2004-02-07 19:16:27 +01:00
|
|
|
" - 80386 CPU required"
|
2001-09-23 22:39:44 +02:00
|
|
|
#elif defined (I186)
|
2004-02-07 19:16:27 +01:00
|
|
|
" - 80186 CPU required"
|
2001-11-18 15:01:12 +01:00
|
|
|
#endif
|
2001-09-23 22:39:44 +02:00
|
|
|
|
|
|
|
#ifdef WITHFAT32
|
2004-02-07 19:16:27 +01:00
|
|
|
" - FAT32 support"
|
2001-11-18 15:01:12 +01:00
|
|
|
#endif
|
2004-04-25 12:11:29 +02:00
|
|
|
"\n\n%s",
|
2004-04-24 17:14:43 +02:00
|
|
|
MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release)),
|
|
|
|
MAJOR_RELEASE, MINOR_RELEASE, copyright);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC void kernel()
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-04-22 00:32:53 +02:00
|
|
|
CommandTail Cmd;
|
|
|
|
|
2004-01-31 12:39:50 +01:00
|
|
|
if (master_env[0] == '\0') /* some shells panic on empty master env. */
|
|
|
|
strcpy(master_env, "PATH=.");
|
2004-03-07 13:19:43 +01:00
|
|
|
fmemcpy(MK_FP(DOS_PSP + 8, 0), master_env, sizeof(master_env));
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
/* process 0 */
|
2004-03-07 13:19:43 +01:00
|
|
|
/* Execute command.com from the drive we just booted from */
|
2002-02-09 01:40:33 +01:00
|
|
|
memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer));
|
2004-04-26 11:46:44 +02:00
|
|
|
strcpy(Cmd.ctBuffer, Config.cfgInitTail);
|
2001-04-22 00:32:53 +02:00
|
|
|
|
2002-02-09 01:40:33 +01:00
|
|
|
for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++)
|
2001-04-22 00:32:53 +02:00
|
|
|
if (Cmd.ctBuffer[Cmd.ctCount] == '\r')
|
|
|
|
break;
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
/* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */
|
|
|
|
|
2004-03-07 13:19:43 +01:00
|
|
|
/* 3 for string + 2 for "\r\n" */
|
|
|
|
if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 5)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
|
|
|
char *insertString = NULL;
|
|
|
|
|
|
|
|
if (singleStep)
|
|
|
|
insertString = " /Y"; /* single step AUTOEXEC */
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
if (SkipAllConfig)
|
|
|
|
insertString = " /D"; /* disable AUTOEXEC */
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
if (insertString)
|
|
|
|
{
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
/* insert /D, /Y as first argument */
|
2002-08-03 18:54:09 +02:00
|
|
|
char *p, *q;
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2002-08-03 18:54:09 +02:00
|
|
|
for (p = Cmd.ctBuffer; p < &Cmd.ctBuffer[Cmd.ctCount]; p++)
|
2001-04-29 19:34:41 +02:00
|
|
|
{
|
2002-08-03 18:54:09 +02:00
|
|
|
if (*p == ' ' || *p == '\t' || *p == '\r')
|
2001-04-29 19:34:41 +02:00
|
|
|
{
|
2004-03-07 13:19:43 +01:00
|
|
|
for (q = &Cmd.ctBuffer[Cmd.ctCount + 1]; q >= p; q--)
|
2002-08-03 18:54:09 +02:00
|
|
|
q[3] = q[0];
|
2004-02-24 01:25:56 +01:00
|
|
|
memcpy(p, insertString, 3);
|
2001-11-18 15:01:12 +01:00
|
|
|
break;
|
2001-04-29 19:34:41 +02:00
|
|
|
}
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|
2004-04-13 13:54:09 +02:00
|
|
|
/* save buffer -- on the stack it's fine here */
|
|
|
|
Config.cfgInitTail = Cmd.ctBuffer;
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|
2001-04-29 19:34:41 +02:00
|
|
|
}
|
2004-03-07 13:19:43 +01:00
|
|
|
init_call_p_0(&Config); /* go execute process 0 (the shell) */
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2001-04-15 05:21:50 +02:00
|
|
|
/* check for a block device and update device control block */
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC VOID update_dcb(struct dhdr FAR * dhp)
|
2001-04-15 05:21:50 +02:00
|
|
|
{
|
|
|
|
REG COUNT Index;
|
|
|
|
COUNT nunits = dhp->dh_name[0];
|
|
|
|
struct dpb FAR *dpb;
|
|
|
|
|
2003-06-15 17:53:58 +02:00
|
|
|
if (LoL->nblkdev == 0)
|
|
|
|
dpb = LoL->DPBp;
|
2001-11-18 15:01:12 +01:00
|
|
|
else
|
|
|
|
{
|
2003-06-15 17:53:58 +02:00
|
|
|
for (dpb = LoL->DPBp; (ULONG) dpb->dpb_next != 0xffffffffl;
|
2001-11-18 15:01:12 +01:00
|
|
|
dpb = dpb->dpb_next)
|
2001-04-15 05:21:50 +02:00
|
|
|
;
|
2001-11-18 15:01:12 +01:00
|
|
|
dpb = dpb->dpb_next =
|
2003-06-15 15:24:53 +02:00
|
|
|
KernelAlloc(nunits * sizeof(struct dpb), 'E', Config.cfgDosDataUmb);
|
2001-04-15 05:21:50 +02:00
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
for (Index = 0; Index < nunits; Index++)
|
|
|
|
{
|
|
|
|
dpb->dpb_next = dpb + 1;
|
2003-06-15 17:53:58 +02:00
|
|
|
dpb->dpb_unit = LoL->nblkdev;
|
2001-04-15 05:21:50 +02:00
|
|
|
dpb->dpb_subunit = Index;
|
|
|
|
dpb->dpb_device = dhp;
|
|
|
|
dpb->dpb_flags = M_CHANGED;
|
2003-06-15 17:53:58 +02:00
|
|
|
if ((LoL->CDSp != 0) && (LoL->nblkdev < LoL->lastdrive))
|
2001-04-15 05:21:50 +02:00
|
|
|
{
|
2003-06-15 17:53:58 +02:00
|
|
|
LoL->CDSp[LoL->nblkdev].cdsDpb = dpb;
|
|
|
|
LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV;
|
2001-04-15 05:21:50 +02:00
|
|
|
}
|
|
|
|
++dpb;
|
2003-06-15 17:53:58 +02:00
|
|
|
++LoL->nblkdev;
|
2001-04-15 05:21:50 +02:00
|
|
|
}
|
2001-11-18 15:01:12 +01:00
|
|
|
(dpb - 1)->dpb_next = (void FAR *)0xFFFFFFFFl;
|
2001-04-15 05:21:50 +02:00
|
|
|
}
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* If cmdLine is NULL, this is an internal driver */
|
|
|
|
|
2003-06-15 15:24:53 +02:00
|
|
|
BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode,
|
2003-10-30 13:22:06 +01:00
|
|
|
char FAR **r_top)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
|
|
|
request rq;
|
2003-06-15 15:24:53 +02:00
|
|
|
char name[8];
|
2003-06-30 20:46:37 +02:00
|
|
|
|
2003-09-09 19:29:19 +02:00
|
|
|
if (cmdLine) {
|
|
|
|
char *p, *q, ch;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
p = q = cmdLine;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
ch = *p;
|
|
|
|
if (ch == '\0' || ch == ' ' || ch == '\t')
|
|
|
|
break;
|
|
|
|
p++;
|
|
|
|
if (ch == '\\' || ch == '/' || ch == ':')
|
|
|
|
q = p; /* remember position after path */
|
|
|
|
}
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
ch = '\0';
|
|
|
|
if (p != q && *q != '.')
|
|
|
|
ch = *q++;
|
|
|
|
/* copy name, without extension */
|
|
|
|
name[i] = ch;
|
|
|
|
}
|
2003-06-30 20:46:37 +02:00
|
|
|
}
|
2003-09-09 19:29:19 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
rq.r_unit = 0;
|
|
|
|
rq.r_status = 0;
|
|
|
|
rq.r_command = C_INIT;
|
|
|
|
rq.r_length = sizeof(request);
|
2003-10-30 13:22:06 +01:00
|
|
|
rq.r_endaddr = *r_top;
|
2000-05-06 21:34:20 +02:00
|
|
|
rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n");
|
2003-06-15 17:53:58 +02:00
|
|
|
rq.r_firstunit = LoL->nblkdev;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
execrh((request FAR *) & rq, dhp);
|
2001-04-22 00:32:53 +02:00
|
|
|
|
2000-05-26 21:25:19 +02:00
|
|
|
/*
|
|
|
|
* Added needed Error handle
|
|
|
|
*/
|
2003-07-12 22:56:11 +02:00
|
|
|
if ((rq.r_status & (S_ERROR | S_DONE)) == S_ERROR)
|
2000-05-26 21:25:19 +02:00
|
|
|
return TRUE;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
if (cmdLine)
|
|
|
|
{
|
2003-06-15 15:24:53 +02:00
|
|
|
/* Don't link in device drivers which do not take up memory */
|
|
|
|
if (rq.r_endaddr == (BYTE FAR *) dhp)
|
|
|
|
return TRUE;
|
|
|
|
|
2003-10-26 14:07:49 +01:00
|
|
|
/* Fix for multisegmented device drivers: */
|
|
|
|
/* If there are multiple device drivers in a single driver file, */
|
|
|
|
/* only the END ADDRESS returned by the last INIT call should be */
|
|
|
|
/* the used. It is recommended that all the device drivers in */
|
|
|
|
/* the file return the same address */
|
|
|
|
|
|
|
|
if (FP_OFF(dhp->dh_next) == 0xffff)
|
|
|
|
{
|
|
|
|
KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16
|
|
|
|
- FP_SEG(dhp), 'D', name, mode);
|
|
|
|
}
|
2003-10-30 13:22:06 +01:00
|
|
|
|
|
|
|
/* Another fix for multisegmented device drivers: */
|
|
|
|
/* To help emulate the functionallity experienced with other DOS */
|
|
|
|
/* operating systems when calling multiple device drivers in a */
|
|
|
|
/* single driver file, save the end address returned from the */
|
|
|
|
/* last INIT call which will then be passed as the end address */
|
|
|
|
/* for the next INIT call. */
|
|
|
|
|
|
|
|
*r_top = (char FAR *)rq.r_endaddr;
|
2001-04-16 03:45:26 +02:00
|
|
|
}
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0))
|
|
|
|
{
|
2001-04-15 05:21:50 +02:00
|
|
|
dhp->dh_name[0] = rq.r_nunits;
|
|
|
|
update_dcb(dhp);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
2001-04-15 05:21:50 +02:00
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
if (dhp->dh_attr & ATTR_CONIN)
|
2003-06-15 17:53:58 +02:00
|
|
|
LoL->syscon = dhp;
|
2001-04-22 00:32:53 +02:00
|
|
|
else if (dhp->dh_attr & ATTR_CLOCK)
|
2003-06-15 17:53:58 +02:00
|
|
|
LoL->clock = dhp;
|
2001-04-22 00:32:53 +02:00
|
|
|
|
2000-05-26 21:25:19 +02:00
|
|
|
return FALSE;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC void InitIO(void)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2003-06-20 21:54:18 +02:00
|
|
|
struct dhdr far *device = &LoL->nul_dev;
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Initialize driver chain */
|
2003-06-20 21:54:18 +02:00
|
|
|
do {
|
2003-10-30 13:22:06 +01:00
|
|
|
init_device(device, NULL, 0, &lpTop);
|
2003-06-20 21:54:18 +02:00
|
|
|
device = device->dh_next;
|
|
|
|
}
|
|
|
|
while (FP_OFF(device) != 0xffff);
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
/* issue an internal error message */
|
|
|
|
VOID init_fatal(BYTE * err_msg)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-04-22 00:32:53 +02:00
|
|
|
printf("\nInternal kernel error - %s\nSystem halted\n", err_msg);
|
|
|
|
for (;;) ;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
2001-09-23 22:39:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Initialize all printers
|
|
|
|
|
|
|
|
this should work. IMHO, this might also be done on first use
|
|
|
|
of printer, as I never liked the noise by a resetting printer, and
|
|
|
|
I usually much more often reset my system, then I print :-)
|
|
|
|
*/
|
|
|
|
|
2002-01-23 23:29:41 +01:00
|
|
|
STATIC VOID InitPrinters(VOID)
|
2001-09-23 22:39:44 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
iregs r;
|
|
|
|
int num_printers, i;
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
init_call_intr(0x11, &r); /* get equipment list */
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
num_printers = (r.a.x >> 14) & 3; /* bits 15-14 */
|
|
|
|
|
|
|
|
for (i = 0; i < num_printers; i++)
|
|
|
|
{
|
|
|
|
r.a.x = 0x0100; /* initialize printer */
|
|
|
|
r.d.x = i;
|
|
|
|
init_call_intr(0x17, &r);
|
|
|
|
}
|
2001-09-23 22:39:44 +02:00
|
|
|
}
|
|
|
|
|
2003-11-14 22:55:25 +01:00
|
|
|
STATIC VOID InitSerialPorts(VOID)
|
|
|
|
{
|
|
|
|
iregs r;
|
|
|
|
int serial_ports, i;
|
|
|
|
|
|
|
|
init_call_intr(0x11, &r); /* get equipment list */
|
|
|
|
|
|
|
|
serial_ports = (r.a.x >> 9) & 7; /* bits 11-9 */
|
|
|
|
|
|
|
|
for (i = 0; i < serial_ports; i++)
|
|
|
|
{
|
|
|
|
r.a.x = 0xA3; /* initialize serial port to 2400,n,8,1 */
|
|
|
|
r.d.x = i;
|
|
|
|
init_call_intr(0x14, &r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-15 16:38:13 +02:00
|
|
|
/*****************************************************************
|
|
|
|
if kernel.config.BootHarddiskSeconds is set,
|
|
|
|
the default is to boot from harddisk, because
|
|
|
|
the user is assumed to just have forgotten to
|
|
|
|
remove the floppy/bootable CD from the drive.
|
|
|
|
|
|
|
|
user has some seconds to hit ANY key to continue
|
|
|
|
to boot from floppy/cd, else the system is
|
|
|
|
booted from HD
|
|
|
|
*/
|
|
|
|
|
|
|
|
EmulatedDriveStatus(int drive,char statusOnly)
|
|
|
|
{
|
|
|
|
iregs r;
|
2003-07-15 14:32:35 +02:00
|
|
|
char buffer[0x13];
|
2003-06-15 16:38:13 +02:00
|
|
|
buffer[0] = 0x13;
|
|
|
|
|
|
|
|
r.a.b.h = 0x4b; /* bootable CDROM - get status */
|
|
|
|
r.a.b.l = statusOnly;
|
|
|
|
r.d.b.l = (char)drive;
|
|
|
|
r.si = (int)buffer;
|
|
|
|
init_call_intr(0x13, &r);
|
|
|
|
|
|
|
|
if (r.flags & 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-06-20 21:54:18 +02:00
|
|
|
STATIC void CheckContinueBootFromHarddisk(void)
|
2003-06-15 16:38:13 +02:00
|
|
|
{
|
2003-06-17 13:55:44 +02:00
|
|
|
char *bootedFrom = "Floppy/CD";
|
2003-06-15 16:38:13 +02:00
|
|
|
iregs r;
|
2003-06-17 13:55:44 +02:00
|
|
|
int key;
|
|
|
|
|
2003-06-15 16:38:13 +02:00
|
|
|
if (InitKernelConfig.BootHarddiskSeconds == 0)
|
|
|
|
return;
|
|
|
|
|
2003-06-15 17:53:58 +02:00
|
|
|
if (LoL->BootDrive >= 3)
|
2003-06-15 16:38:13 +02:00
|
|
|
{
|
2003-07-15 14:32:35 +02:00
|
|
|
#if 0
|
2003-06-15 16:38:13 +02:00
|
|
|
if (!EmulatedDriveStatus(0x80,1))
|
2003-07-15 14:32:35 +02:00
|
|
|
#endif
|
2003-06-15 16:38:13 +02:00
|
|
|
{
|
|
|
|
/* already booted from HD */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-07-15 14:32:35 +02:00
|
|
|
#if 0
|
2003-06-15 16:38:13 +02:00
|
|
|
if (!EmulatedDriveStatus(0x00,1))
|
2003-07-15 14:32:35 +02:00
|
|
|
#endif
|
2003-06-15 16:38:13 +02:00
|
|
|
bootedFrom = "Floppy";
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n"
|
|
|
|
"\n"
|
|
|
|
"\n"
|
|
|
|
" Hit any key within %d seconds to continue booot from %s\n"
|
2003-06-17 13:55:44 +02:00
|
|
|
" Hit 'H' or wait %d seconds to boot from Harddisk\n",
|
2003-06-15 16:38:13 +02:00
|
|
|
InitKernelConfig.BootHarddiskSeconds,
|
2003-06-17 13:55:44 +02:00
|
|
|
bootedFrom,
|
|
|
|
InitKernelConfig.BootHarddiskSeconds
|
2003-06-15 16:38:13 +02:00
|
|
|
);
|
|
|
|
|
2003-06-17 13:55:44 +02:00
|
|
|
key = GetBiosKey(InitKernelConfig.BootHarddiskSeconds);
|
|
|
|
|
2003-06-18 21:27:40 +02:00
|
|
|
if (key != -1 && (key & 0xff) != 'h' && (key & 0xff) != 'H')
|
2003-06-15 16:38:13 +02:00
|
|
|
{
|
|
|
|
/* user has hit a key, continue to boot from floppy/CD */
|
|
|
|
printf("\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reboot from harddisk */
|
|
|
|
EmulatedDriveStatus(0x00,0);
|
|
|
|
EmulatedDriveStatus(0x80,0);
|
|
|
|
|
|
|
|
/* now jump and run */
|
|
|
|
r.a.x = 0x0201;
|
|
|
|
r.c.x = 0x0001;
|
|
|
|
r.d.x = 0x0080;
|
|
|
|
r.b.x = 0x7c00;
|
|
|
|
r.es = 0;
|
|
|
|
|
|
|
|
init_call_intr(0x13, &r);
|
|
|
|
|
|
|
|
{
|
2003-06-16 00:58:29 +02:00
|
|
|
void (far *reboot)(void) = (void (far*)(void)) MK_FP(0x0,0x7c00);
|
2003-06-15 16:38:13 +02:00
|
|
|
|
|
|
|
(*reboot)();
|
|
|
|
}
|
|
|
|
}
|