Tell version info without booting kernel

This commit is contained in:
KJD 2012-10-15 06:41:07 -04:00
parent c431157156
commit a260927440
4 changed files with 66 additions and 12 deletions

View File

@ -21,6 +21,12 @@
' hit any key to continue to boot from 'diskette or CD'
wait ## seconds
if no key hit, boot from HD
Version_: only in kernel 2042 or higher, offline version identification
OemID: 0xFD for FreeDOS kernel, 0xDC for DosC kernel
Major: actual kernel version (not MS-DOS compatibility version), e.g. 2
Revision: revision sequence, e.g. 42 for kernel 2042
Release: 0 if released version, >0 for svn builds (e.g. svn revision #)
*/
typedef struct _KernelConfig {
@ -33,4 +39,11 @@ typedef struct _KernelConfig {
unsigned char ForceLBA;
unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */
signed char BootHarddiskSeconds;
/* for version 2042 and higher only */
unsigned char Version_OemID;
unsigned char Version_Major;
unsigned short Version_Revision;
unsigned short Version_Release;
} KernelConfig;

View File

@ -66,6 +66,12 @@ ForceLBA db 0 ;
GlobalEnableLBAsupport db 1 ;
BootHarddiskSeconds db 0 ;
; The following VERSION resource must be keep in sync with VERSION.H
Version_OemID db 0xFD ; OEM_ID
Version_Major db 2
Version_Revision dw 41 ; REVISION_SEQ
Version_Release dw 1 ; 0=release build, >0=svn#
configend:
;************************************************************

View File

@ -13,9 +13,7 @@
* merged into SYS by tom ehlert *
***************************************************************************/
/* This source compiled & tested with Borland C/C++ 3.1 + TC 2.01*/
char VERSION[] = "v1.00";
char VERSION[] = "v1.02";
char PROGRAM[] = "SYS CONFIG";
char KERNEL[] = "KERNEL.SYS";
@ -123,6 +121,10 @@ int readConfigSettings(int kfile, char *kfilename, KernelConfig * cfg)
exit(1);
}
/* check if config settings old UPX header and adjust */
if (cfg->ConfigSize == 19)
cfg->ConfigSize = 14; /* ignore 'nused87654321' */
return 1;
}
@ -148,38 +150,51 @@ void displayConfigSettings(KernelConfig * cfg)
{
/* print known options and current value - only if available */
/* show kernel version if available, read only, no option to modify */
if (cfg->ConfigSize >= 20)
{
printf
("%s kernel %s (build %d.%d OEM:%02X)\n",
(cfg->Version_OemID == 0xFD)?"FreeDOS":"DOS-C",
cfg->Version_Release?"SVN":"Release",
cfg->Version_Major,
cfg->Version_Revision,
cfg->Version_OemID
);
}
if (cfg->ConfigSize >= 1)
{
printf
("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n",
("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n",
cfg->DLASortByDriveNo);
}
if (cfg->ConfigSize >= 2)
{
printf
("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n",
("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n",
cfg->InitDiskShowDriveAssignment);
}
if (cfg->ConfigSize >= 3)
{
printf
("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8 : *2 sec (skip < 0)\n",
("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8: *2 sec (skip < 0)\n",
cfg->SkipConfigSeconds);
}
if (cfg->ConfigSize >= 4)
{
printf
("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n",
("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n",
cfg->ForceLBA);
}
if (cfg->ConfigSize >= 5)
{
printf
("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n",
("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n",
cfg->GlobalEnableLBAsupport);
}
@ -348,6 +363,7 @@ int FDKrnConfigMain(int argc, char **argv)
char *kfilename = KERNEL;
int kfile;
int updates = 0; /* flag used to indicate if we need to update kernel */
int readonly = 0; /* flag indicates kernel was opened read-only */
int argstart, i;
char *cptr;
char *argptr;
@ -355,7 +371,7 @@ int FDKrnConfigMain(int argc, char **argv)
printf("FreeDOS Kernel Configuration %s\n", VERSION);
/* 1st go through and just process arguments (help/filename/etc) */
for (i = 2; i < argc; i++)
for (i = 1; i < argc; i++)
{
argptr = argv[i];
@ -376,6 +392,10 @@ int FDKrnConfigMain(int argc, char **argv)
exit(1);
}
}
else if (memicmp(argptr, "CONFIG", 6) == 0)
{
/* ignore */
}
}
argstart = 2;
@ -400,7 +420,14 @@ int FDKrnConfigMain(int argc, char **argv)
kfile = open(kfilename, O_RDWR | O_BINARY);
if (kfile < 0)
printf("Error: unable to open kernel file <%s>\n", kfilename), exit(1);
{
/* attempt to open read only to allow viewing options */
kfile = open(kfilename, O_RDONLY | O_BINARY);
readonly = 1;
if (kfile < 0)
printf("Error: unable to open kernel file <%s>\n", kfilename), exit(1);
}
/* now that we know the filename (default or given) get config info */
readConfigSettings(kfile, kfilename, &cfg);
@ -454,8 +481,16 @@ int FDKrnConfigMain(int argc, char **argv)
}
}
/* warn user if attempt to modify read-only file */
if (updates && readonly)
{
printf("Kernel %s opened read-only, changes ignored!\n", kfilename);
/* reload current settings, ignore newly requested ones */
readConfigSettings(kfile, kfilename, &cfg);
}
/* write out new config values if modified */
if (updates)
if (updates && !readonly)
{
/* update it */
if (writeConfigSettings(kfile, &cfg))

View File

@ -263,7 +263,7 @@ static void write_header(FILE *dest, size_t size)
static char JumpBehindCode[] = {
/* kernel config header - 32 bytes */
0xeb, 0x1b, /* jmp short realentry */
'C', 'O', 'N', 'F', 'I', 'G', 32 - 2 - 6 - 2 - 3, 0, /* WORD */
'C', 'O', 'N', 'F', 'I', 'G', 6, 0, /* WORD */
0, /* DLASortByDriveNo db 0 */
1, /* InitDiskShowDriveAssignment db 1 */
2, /* SkipConfigSeconds db 2 */