2000-05-06 21:34:20 +02:00
|
|
|
/***************************************************************
|
|
|
|
|
|
|
|
sys.c
|
|
|
|
DOS-C
|
|
|
|
|
|
|
|
sys utility for DOS-C
|
|
|
|
|
|
|
|
Copyright (c) 1991
|
|
|
|
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.
|
|
|
|
|
|
|
|
***************************************************************/
|
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
#define DEBUG
|
2001-09-23 22:39:44 +02:00
|
|
|
/* #define DDEBUG */
|
|
|
|
|
2004-01-31 16:01:40 +01:00
|
|
|
#define SYS_VERSION "v3.1"
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <dos.h>
|
|
|
|
#include <ctype.h>
|
2002-02-03 23:40:24 +01:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
2001-09-23 22:39:44 +02:00
|
|
|
#ifdef __TURBOC__
|
2001-11-18 15:01:12 +01:00
|
|
|
#include <mem.h>
|
2001-09-23 22:39:44 +02:00
|
|
|
#else
|
2001-11-18 15:01:12 +01:00
|
|
|
#include <memory.h>
|
2001-09-23 22:39:44 +02:00
|
|
|
#endif
|
|
|
|
#include <string.h>
|
2002-01-27 02:13:07 +01:00
|
|
|
#ifdef __TURBOC__
|
2002-01-23 23:29:41 +01:00
|
|
|
#include <dir.h>
|
2002-01-27 02:13:07 +01:00
|
|
|
#endif
|
2002-01-23 23:29:41 +01:00
|
|
|
#define SYS_MAXPATH 260
|
2000-05-06 21:34:20 +02:00
|
|
|
#include "portab.h"
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#include "algnbyte.h"
|
|
|
|
#include "device.h"
|
|
|
|
#include "dcb.h"
|
|
|
|
#include "xstructs.h"
|
|
|
|
#include "date.h"
|
|
|
|
#include "../hdr/time.h"
|
|
|
|
#include "fat.h"
|
|
|
|
|
|
|
|
/* These definitions deliberately put here instead of
|
|
|
|
* #including <stdio.h> to make executable MUCH smaller
|
2003-08-28 22:36:16 +02:00
|
|
|
* using [s]printf from prf.c!
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
*/
|
2002-01-23 23:29:41 +01:00
|
|
|
extern WORD CDECL printf(CONST BYTE * fmt, ...);
|
2002-01-27 02:13:07 +01:00
|
|
|
extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#include "fat12com.h"
|
|
|
|
#include "fat16com.h"
|
2001-09-23 22:39:44 +02:00
|
|
|
#ifdef WITHFAT32
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#include "fat32chs.h"
|
|
|
|
#include "fat32lba.h"
|
2001-09-23 22:39:44 +02:00
|
|
|
#endif
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
#ifndef __WATCOMC__
|
2003-06-16 00:01:45 +02:00
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
#include <io.h>
|
2003-06-16 00:01:45 +02:00
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
#else
|
2003-06-16 00:01:45 +02:00
|
|
|
|
2004-01-25 22:44:17 +01:00
|
|
|
long filelength(int __handle);
|
|
|
|
#pragma aux filelength = \
|
|
|
|
"mov ax, 0x4202" \
|
|
|
|
"xor cx, cx" \
|
|
|
|
"xor dx, dx" \
|
|
|
|
"int 0x21" \
|
|
|
|
"push ax" \
|
|
|
|
"push dx" \
|
|
|
|
"mov ax, 0x4200" \
|
|
|
|
"xor cx, cx" \
|
|
|
|
"xor dx, dx" \
|
|
|
|
"int 0x21" \
|
|
|
|
"pop dx" \
|
|
|
|
"pop ax" \
|
|
|
|
parm [bx] \
|
|
|
|
modify [cx] \
|
|
|
|
value [dx ax];
|
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
extern int unlink(const char *pathname);
|
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
/* some non-conforming functions to make the executable smaller */
|
|
|
|
int open(const char *pathname, int flags, ...)
|
|
|
|
{
|
|
|
|
int handle;
|
|
|
|
int result = (flags & O_CREAT ?
|
|
|
|
_dos_creat(pathname, _A_NORMAL, &handle) :
|
|
|
|
_dos_open(pathname, flags & (O_RDONLY | O_WRONLY | O_RDWR),
|
|
|
|
&handle));
|
|
|
|
|
|
|
|
return (result == 0 ? handle : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int read(int fd, void *buf, unsigned count)
|
|
|
|
{
|
|
|
|
unsigned bytes;
|
|
|
|
int result = _dos_read(fd, buf, count, &bytes);
|
|
|
|
|
|
|
|
return (result == 0 ? bytes : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int write(int fd, const void *buf, unsigned count)
|
|
|
|
{
|
|
|
|
unsigned bytes;
|
|
|
|
int result = _dos_write(fd, buf, count, &bytes);
|
|
|
|
|
|
|
|
return (result == 0 ? bytes : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define close _dos_close
|
|
|
|
|
|
|
|
int stat(const char *file_name, struct stat *buf)
|
|
|
|
{
|
|
|
|
struct find_t find_tbuf;
|
2003-09-24 00:31:32 +02:00
|
|
|
UNREFERENCED_PARAMETER(buf);
|
|
|
|
|
|
|
|
return _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf);
|
2002-02-03 23:40:24 +01:00
|
|
|
}
|
2003-06-16 15:33:40 +02:00
|
|
|
|
|
|
|
/* WATCOM's getenv is case-insensitive which wastes a lot of space
|
|
|
|
for our purposes. So here's a simple case-sensitive one */
|
2003-06-16 00:01:45 +02:00
|
|
|
char *getenv(const char *name)
|
|
|
|
{
|
|
|
|
char **envp, *ep;
|
|
|
|
const char *np;
|
|
|
|
char ec, nc;
|
|
|
|
|
|
|
|
for (envp = environ; (ep = *envp) != NULL; envp++) {
|
|
|
|
np = name;
|
|
|
|
do {
|
|
|
|
ec = *ep++;
|
|
|
|
nc = *np++;
|
|
|
|
if (nc == 0) {
|
|
|
|
if (ec == '=')
|
|
|
|
return ep;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (ec == nc);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-06-16 15:33:40 +02:00
|
|
|
#endif
|
2002-02-03 23:40:24 +01:00
|
|
|
|
2001-11-04 20:47:39 +01:00
|
|
|
BYTE pgm[] = "SYS";
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2004-01-26 01:40:41 +01:00
|
|
|
void put_boot(int, char *, char *, int, int);
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
BOOL check_space(COUNT, ULONG);
|
2001-09-24 04:21:14 +02:00
|
|
|
BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
#define SEC_SIZE 512
|
2002-02-03 23:40:24 +01:00
|
|
|
#define COPY_SIZE 0x7e00
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
struct bootsectortype {
|
2000-05-06 21:34:20 +02:00
|
|
|
UBYTE bsJump[3];
|
|
|
|
char OemName[8];
|
|
|
|
UWORD bsBytesPerSec;
|
|
|
|
UBYTE bsSecPerClust;
|
|
|
|
UWORD bsResSectors;
|
|
|
|
UBYTE bsFATs;
|
|
|
|
UWORD bsRootDirEnts;
|
|
|
|
UWORD bsSectors;
|
|
|
|
UBYTE bsMedia;
|
|
|
|
UWORD bsFATsecs;
|
|
|
|
UWORD bsSecPerTrack;
|
|
|
|
UWORD bsHeads;
|
|
|
|
ULONG bsHiddenSecs;
|
|
|
|
ULONG bsHugeSectors;
|
|
|
|
UBYTE bsDriveNumber;
|
|
|
|
UBYTE bsReserved1;
|
|
|
|
UBYTE bsBootSignature;
|
|
|
|
ULONG bsVolumeID;
|
|
|
|
char bsVolumeLabel[11];
|
|
|
|
char bsFileSysType[8];
|
|
|
|
};
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
struct bootsectortype32 {
|
2001-09-23 22:39:44 +02:00
|
|
|
UBYTE bsJump[3];
|
|
|
|
char OemName[8];
|
|
|
|
UWORD bsBytesPerSec;
|
|
|
|
UBYTE bsSecPerClust;
|
|
|
|
UWORD bsResSectors;
|
|
|
|
UBYTE bsFATs;
|
|
|
|
UWORD bsRootDirEnts;
|
|
|
|
UWORD bsSectors;
|
|
|
|
UBYTE bsMedia;
|
|
|
|
UWORD bsFATsecs;
|
|
|
|
UWORD bsSecPerTrack;
|
|
|
|
UWORD bsHeads;
|
|
|
|
ULONG bsHiddenSecs;
|
|
|
|
ULONG bsHugeSectors;
|
|
|
|
ULONG bsBigFatSize;
|
|
|
|
UBYTE bsFlags;
|
|
|
|
UBYTE bsMajorVersion;
|
|
|
|
UWORD bsMinorVersion;
|
|
|
|
ULONG bsRootCluster;
|
|
|
|
UWORD bsFSInfoSector;
|
|
|
|
UWORD bsBackupBoot;
|
|
|
|
ULONG bsReserved2[3];
|
|
|
|
UBYTE bsDriveNumber;
|
|
|
|
UBYTE bsReserved3;
|
|
|
|
UBYTE bsExtendedSignature;
|
|
|
|
ULONG bsSerialNumber;
|
2001-11-18 15:01:12 +01:00
|
|
|
char bsVolumeLabel[11];
|
2001-09-23 22:39:44 +02:00
|
|
|
char bsFileSystemID[8];
|
|
|
|
};
|
2000-05-06 21:34:20 +02:00
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
/*
|
|
|
|
* globals needed by put_boot & check_space
|
|
|
|
*/
|
|
|
|
enum {FAT12 = 12, FAT16 = 16, FAT32 = 32} fs; /* file system type */
|
|
|
|
/* static */ struct xfreespace x; /* we make this static to be 0 by default -
|
|
|
|
this avoids FAT misdetections */
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
#define SBOFFSET 11
|
2001-04-29 19:34:41 +02:00
|
|
|
#define SBSIZE (sizeof(struct bootsectortype) - SBOFFSET)
|
2001-09-23 22:39:44 +02:00
|
|
|
#define SBSIZE32 (sizeof(struct bootsectortype32) - SBOFFSET)
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
/* essentially - verify alignment on byte boundaries at compile time */
|
2001-11-18 15:01:12 +01:00
|
|
|
struct VerifyBootSectorSize {
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
char failure1[sizeof(struct bootsectortype) == 62 ? 1 : -1];
|
|
|
|
char failure2[sizeof(struct bootsectortype) == 62 ? 1 : 0];
|
|
|
|
/* (Watcom has a nice warning for this, by the way) */
|
2001-11-14 00:36:45 +01:00
|
|
|
};
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
int FDKrnConfigMain(int argc, char **argv);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-09-24 04:21:14 +02:00
|
|
|
int main(int argc, char **argv)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-09-24 04:21:14 +02:00
|
|
|
COUNT drive; /* destination drive */
|
2001-11-14 00:36:45 +01:00
|
|
|
COUNT drivearg = 0; /* drive argument position */
|
2003-09-24 00:31:32 +02:00
|
|
|
COUNT srcarg = 0; /* source argument position */
|
2001-11-14 00:36:45 +01:00
|
|
|
BYTE *bsFile = NULL; /* user specified destination boot sector */
|
2002-01-27 02:13:07 +01:00
|
|
|
unsigned srcDrive; /* source drive */
|
2002-01-23 23:29:41 +01:00
|
|
|
BYTE srcPath[SYS_MAXPATH]; /* user specified source drive and/or path */
|
2001-09-24 04:21:14 +02:00
|
|
|
BYTE rootPath[4]; /* alternate source path to try if not '\0' */
|
2001-09-23 22:39:44 +02:00
|
|
|
WORD slen;
|
2003-09-24 00:31:32 +02:00
|
|
|
int argno = 0;
|
|
|
|
int bootonly = 0;
|
|
|
|
int both = 0;
|
|
|
|
char *kernel_name = "KERNEL.SYS";
|
2004-01-26 01:40:41 +01:00
|
|
|
int load_segment = 0x60;
|
2001-09-23 22:39:44 +02:00
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n");
|
2001-11-18 15:01:12 +01:00
|
|
|
|
|
|
|
if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0)
|
|
|
|
{
|
|
|
|
exit(FDKrnConfigMain(argc, argv));
|
|
|
|
}
|
2000-05-15 07:28:09 +02:00
|
|
|
|
2003-09-24 00:31:32 +02:00
|
|
|
for(argno = 1; argno < argc; argno++)
|
2001-09-23 22:39:44 +02:00
|
|
|
{
|
2003-09-24 00:31:32 +02:00
|
|
|
char *argp = argv[argno];
|
|
|
|
|
|
|
|
if (argp[1] == ':' && argp[2] == '\0' && drivearg <= srcarg)
|
|
|
|
drivearg = argno;
|
|
|
|
|
|
|
|
if (srcarg == 0)
|
2001-09-23 22:39:44 +02:00
|
|
|
{
|
2003-09-24 00:31:32 +02:00
|
|
|
srcarg = argno;
|
|
|
|
}
|
|
|
|
else if (argp[0] == '/' && toupper(argp[1]) == 'K' && argno + 1 < argc)
|
|
|
|
{
|
|
|
|
argno++;
|
|
|
|
kernel_name = argv[argno];
|
|
|
|
}
|
2004-01-26 01:40:41 +01:00
|
|
|
else if (argp[0] == '/' && toupper(argp[1]) == 'L' && argno + 1 < argc)
|
|
|
|
{
|
|
|
|
argno++;
|
|
|
|
load_segment = (int)strtol(argv[argno], NULL, 16);
|
|
|
|
}
|
2003-09-24 00:31:32 +02:00
|
|
|
else if (memicmp(argp, "BOOTONLY", 8) == 0 && !bootonly)
|
|
|
|
{
|
|
|
|
bootonly = 1;
|
|
|
|
}
|
|
|
|
else if (memicmp(argp, "BOTH", 4) == 0 && !both)
|
|
|
|
{
|
|
|
|
both = 1;
|
|
|
|
}
|
|
|
|
else if (drivearg != argno)
|
|
|
|
{
|
|
|
|
if (bsFile == NULL)
|
|
|
|
{
|
|
|
|
bsFile = argp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
drivearg = 0;
|
|
|
|
break;
|
|
|
|
}
|
2001-09-23 22:39:44 +02:00
|
|
|
}
|
|
|
|
}
|
2001-11-14 00:36:45 +01:00
|
|
|
|
|
|
|
if (drivearg == 0)
|
2001-09-23 22:39:44 +02:00
|
|
|
{
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
printf(
|
2004-01-26 01:40:41 +01:00
|
|
|
"Usage: %s [source] drive: [bootsect [BOTH]] [BOOTONLY] [/K name] [/L segm]\n"
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"
|
|
|
|
" drive = A,B,etc.\n"
|
|
|
|
" bootsect = name of 512-byte boot sector file image for drive:\n"
|
|
|
|
" to write to *instead* of real boot sector\n"
|
|
|
|
" BOTH : write to *both* the real boot sector and the image file\n"
|
|
|
|
" BOOTONLY : do *not* copy kernel / shell, only update boot sector or image\n"
|
2003-09-24 00:31:32 +02:00
|
|
|
" /K name : name of kernel to use instead of KERNEL.SYS\n"
|
2004-01-26 01:40:41 +01:00
|
|
|
" /L segm : hex load segment to use instead of 60\n"
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
"%s CONFIG /help\n", pgm, pgm);
|
2000-05-06 21:34:20 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2001-11-14 00:36:45 +01:00
|
|
|
drive = toupper(argv[drivearg][0]) - 'A';
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
if (drive < 0 || drive >= 26)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("%s: drive %c must be A:..Z:\n", pgm,
|
|
|
|
*argv[(argc == 3 ? 2 : 1)]);
|
2000-05-06 21:34:20 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2003-09-24 00:31:32 +02:00
|
|
|
srcPath[0] = '\0';
|
|
|
|
if (drivearg > srcarg && srcarg)
|
|
|
|
{
|
|
|
|
strncpy(srcPath, argv[srcarg], SYS_MAXPATH - 12);
|
|
|
|
/* leave room for COMMAND.COM\0 */
|
|
|
|
srcPath[SYS_MAXPATH - 13] = '\0';
|
|
|
|
/* make sure srcPath + "file" is a valid path */
|
|
|
|
slen = strlen(srcPath);
|
|
|
|
if ((srcPath[slen - 1] != ':') &&
|
|
|
|
((srcPath[slen - 1] != '\\') || (srcPath[slen - 1] != '/')))
|
|
|
|
{
|
|
|
|
srcPath[slen] = '\\';
|
|
|
|
slen++;
|
|
|
|
srcPath[slen] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
/* Get source drive */
|
|
|
|
if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */
|
2001-09-24 04:21:14 +02:00
|
|
|
srcDrive = toupper(*srcPath) - 'A';
|
2001-11-18 15:01:12 +01:00
|
|
|
else /* src doesn't specify drive, so assume current drive */
|
|
|
|
{
|
2001-11-04 20:47:39 +01:00
|
|
|
#ifdef __TURBOC__
|
2002-01-27 02:13:07 +01:00
|
|
|
srcDrive = (unsigned) getdisk();
|
2001-11-18 15:01:12 +01:00
|
|
|
#else
|
2001-11-04 20:47:39 +01:00
|
|
|
_dos_getdrive(&srcDrive);
|
2002-05-09 01:57:58 +02:00
|
|
|
srcDrive--;
|
2001-11-18 15:01:12 +01:00
|
|
|
#endif
|
|
|
|
}
|
2001-09-24 04:21:14 +02:00
|
|
|
|
|
|
|
/* Don't try root if src==dst drive or source path given */
|
2001-11-18 15:01:12 +01:00
|
|
|
if ((drive == srcDrive)
|
|
|
|
|| (*srcPath
|
|
|
|
&& ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2]))))
|
2001-09-24 04:21:14 +02:00
|
|
|
*rootPath = '\0';
|
|
|
|
else
|
|
|
|
sprintf(rootPath, "%c:\\", 'A' + srcDrive);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2003-08-28 22:36:16 +02:00
|
|
|
printf("Processing boot sector...\n");
|
2004-01-26 01:40:41 +01:00
|
|
|
put_boot(drive, bsFile, kernel_name, load_segment, both);
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2003-09-24 00:31:32 +02:00
|
|
|
if (!bootonly)
|
2002-10-22 04:40:19 +02:00
|
|
|
{
|
2003-09-24 00:31:32 +02:00
|
|
|
printf("\nCopying %s...\n", kernel_name);
|
|
|
|
if (!copy(drive, srcPath, rootPath, kernel_name))
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
{
|
2003-09-24 00:31:32 +02:00
|
|
|
printf("\n%s: cannot copy \"%s\"\n", pgm, kernel_name);
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
exit(1);
|
|
|
|
} /* copy kernel */
|
|
|
|
|
2003-06-16 00:01:45 +02:00
|
|
|
printf("\nCopying COMMAND.COM...\n");
|
|
|
|
if (!copy(drive, srcPath, rootPath, "COMMAND.COM"))
|
2002-10-22 04:40:19 +02:00
|
|
|
{
|
2003-06-16 00:01:45 +02:00
|
|
|
char *comspec = getenv("COMSPEC");
|
|
|
|
if (comspec != NULL)
|
|
|
|
{
|
|
|
|
printf("%s: Trying \"%s\"\n", pgm, comspec);
|
|
|
|
if (!copy(drive, comspec, NULL, "COMMAND.COM"))
|
|
|
|
comspec = NULL;
|
|
|
|
}
|
|
|
|
if (comspec == NULL)
|
|
|
|
{
|
2003-09-24 00:31:32 +02:00
|
|
|
printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm);
|
2003-06-16 00:01:45 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
} /* copy shell */
|
2003-09-24 00:31:32 +02:00
|
|
|
}
|
2002-10-22 04:40:19 +02:00
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
printf("\nSystem transferred.\n");
|
2001-09-24 04:21:14 +02:00
|
|
|
return 0;
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
2001-09-24 04:21:14 +02:00
|
|
|
#ifdef DDEBUG
|
2000-05-06 21:34:20 +02:00
|
|
|
VOID dump_sector(unsigned char far * sec)
|
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
COUNT x, y;
|
|
|
|
char c;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
for (x = 0; x < 32; x++)
|
|
|
|
{
|
|
|
|
printf("%03X ", x * 16);
|
|
|
|
for (y = 0; y < 16; y++)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("%02X ", sec[x * 16 + y]);
|
|
|
|
}
|
|
|
|
for (y = 0; y < 16; y++)
|
|
|
|
{
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
c = sec[x * 16 + y];
|
2001-11-18 15:01:12 +01:00
|
|
|
if (isprint(c))
|
|
|
|
printf("%c", c);
|
|
|
|
else
|
|
|
|
printf(".");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("\n");
|
2000-05-06 21:34:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
#ifdef __WATCOMC__
|
2003-06-16 00:01:45 +02:00
|
|
|
|
|
|
|
int absread(int DosDrive, int nsects, int foo, void *diskReadPacket);
|
|
|
|
#pragma aux absread = \
|
2004-03-02 11:46:28 +01:00
|
|
|
"push bp" \
|
2002-02-03 23:40:24 +01:00
|
|
|
"int 0x25" \
|
2004-03-02 11:46:28 +01:00
|
|
|
"popf" \
|
|
|
|
"pop bp" \
|
2003-06-16 00:01:45 +02:00
|
|
|
"sbb ax, ax" \
|
|
|
|
parm [ax] [cx] [dx] [bx] \
|
2004-03-02 11:46:28 +01:00
|
|
|
modify [si di] \
|
2003-06-16 00:01:45 +02:00
|
|
|
value [ax];
|
|
|
|
|
|
|
|
int abswrite(int DosDrive, int nsects, int foo, void *diskReadPacket);
|
|
|
|
#pragma aux abswrite = \
|
2004-03-02 11:46:28 +01:00
|
|
|
"push bp" \
|
2002-02-03 23:40:24 +01:00
|
|
|
"int 0x26" \
|
2004-03-02 11:46:28 +01:00
|
|
|
"popf" \
|
|
|
|
"pop bp" \
|
2003-06-16 00:01:45 +02:00
|
|
|
"sbb ax, ax" \
|
|
|
|
parm [ax] [cx] [dx] [bx] \
|
2004-03-02 11:46:28 +01:00
|
|
|
modify [si di] \
|
2002-02-03 23:40:24 +01:00
|
|
|
value [ax];
|
|
|
|
|
|
|
|
fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno);
|
|
|
|
#pragma aux fat32readwrite = \
|
|
|
|
"mov ax, 0x7305" \
|
|
|
|
"mov cx, 0xffff" \
|
|
|
|
"int 0x21" \
|
2003-06-16 00:01:45 +02:00
|
|
|
"sbb ax, ax" \
|
2002-02-03 23:40:24 +01:00
|
|
|
parm [dx] [bx] [si] \
|
|
|
|
modify [cx dx si] \
|
|
|
|
value [ax];
|
|
|
|
|
2002-11-09 20:07:11 +01:00
|
|
|
void reset_drive(int DosDrive);
|
|
|
|
#pragma aux reset_drive = \
|
|
|
|
"push ds" \
|
|
|
|
"inc dx" \
|
|
|
|
"mov ah, 0xd" \
|
|
|
|
"int 0x21" \
|
|
|
|
"mov ah,0x32" \
|
|
|
|
"int 0x21" \
|
|
|
|
"pop ds" \
|
|
|
|
parm [dx] \
|
|
|
|
modify [ax bx];
|
2003-06-16 00:01:45 +02:00
|
|
|
|
2003-06-16 15:33:40 +02:00
|
|
|
void truename(char far *dest, const char *src);
|
|
|
|
#pragma aux truename = \
|
|
|
|
"mov ah,0x60" \
|
|
|
|
"int 0x21" \
|
|
|
|
parm [es di] [si];
|
2004-01-31 16:01:40 +01:00
|
|
|
|
|
|
|
int generic_block_ioctl(unsigned char drive, unsigned cx, unsigned char *par);
|
|
|
|
#pragma aux generic_block_ioctl = \
|
|
|
|
"mov ax, 0x440d" \
|
|
|
|
"int 0x21" \
|
|
|
|
"sbb ax, ax" \
|
|
|
|
value [ax] \
|
|
|
|
parm [bl] [cx] [dx];
|
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
#else
|
2003-06-16 00:01:45 +02:00
|
|
|
|
|
|
|
#ifndef __TURBOC__
|
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno)
|
|
|
|
{
|
|
|
|
union REGS regs;
|
|
|
|
|
|
|
|
regs.h.al = (BYTE) DosDrive;
|
2002-02-09 16:39:35 +01:00
|
|
|
regs.x.bx = (short)diskReadPacket;
|
2002-02-03 23:40:24 +01:00
|
|
|
regs.x.cx = 0xffff;
|
|
|
|
|
|
|
|
int86(intno, ®s, ®s);
|
|
|
|
|
|
|
|
return regs.x.cflag;
|
|
|
|
}
|
|
|
|
|
2003-08-28 22:36:16 +02:00
|
|
|
#define absread(DosDrive, foo, cx, diskReadPacket) \
|
2003-06-16 00:01:45 +02:00
|
|
|
int2526readwrite(DosDrive, diskReadPacket, 0x25)
|
|
|
|
|
2003-08-28 22:36:16 +02:00
|
|
|
#define abswrite(DosDrive, foo, cx, diskReadPacket) \
|
2003-06-16 00:01:45 +02:00
|
|
|
int2526readwrite(DosDrive, diskReadPacket, 0x26)
|
|
|
|
|
|
|
|
#endif
|
2002-02-03 23:40:24 +01:00
|
|
|
|
|
|
|
fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno)
|
|
|
|
{
|
|
|
|
union REGS regs;
|
|
|
|
|
|
|
|
regs.x.ax = 0x7305;
|
2003-06-16 00:01:45 +02:00
|
|
|
regs.h.dl = DosDrive;
|
2002-02-09 16:39:35 +01:00
|
|
|
regs.x.bx = (short)diskReadPacket;
|
2002-02-03 23:40:24 +01:00
|
|
|
regs.x.cx = 0xffff;
|
2003-06-16 00:01:45 +02:00
|
|
|
regs.x.si = intno;
|
|
|
|
intdos(®s, ®s);
|
2002-02-03 23:40:24 +01:00
|
|
|
|
|
|
|
return regs.x.cflag;
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* fat32readwrite */
|
2002-11-09 20:07:11 +01:00
|
|
|
|
|
|
|
void reset_drive(int DosDrive)
|
|
|
|
{
|
|
|
|
union REGS regs;
|
|
|
|
|
|
|
|
regs.h.ah = 0xd;
|
2003-06-16 00:01:45 +02:00
|
|
|
intdos(®s, ®s);
|
2002-11-09 20:07:11 +01:00
|
|
|
regs.h.ah = 0x32;
|
|
|
|
regs.h.dl = DosDrive + 1;
|
2003-06-16 00:01:45 +02:00
|
|
|
intdos(®s, ®s);
|
|
|
|
} /* reset_drive */
|
2002-11-09 20:07:11 +01:00
|
|
|
|
2004-01-31 16:01:40 +01:00
|
|
|
int generic_block_ioctl(unsigned char drive, unsigned cx, unsigned char *par)
|
2003-08-28 22:36:16 +02:00
|
|
|
{
|
|
|
|
union REGS regs;
|
|
|
|
|
|
|
|
regs.x.ax = 0x440d;
|
2004-01-31 16:01:40 +01:00
|
|
|
regs.x.cx = cx;
|
|
|
|
regs.x.dx = (unsigned)par;
|
|
|
|
regs.h.bl = drive + 1;
|
2003-08-28 22:36:16 +02:00
|
|
|
intdos(®s, ®s);
|
2004-01-31 16:01:40 +01:00
|
|
|
return regs.x.cflag;
|
|
|
|
} /* generic_block_ioctl */
|
2003-08-28 22:36:16 +02:00
|
|
|
|
2003-06-16 15:33:40 +02:00
|
|
|
void truename(char *dest, const char *src)
|
|
|
|
{
|
|
|
|
union REGS regs;
|
|
|
|
struct SREGS sregs;
|
|
|
|
|
|
|
|
regs.h.ah = 0x60;
|
|
|
|
sregs.es = FP_SEG(dest);
|
|
|
|
regs.x.di = FP_OFF(dest);
|
|
|
|
sregs.ds = FP_SEG(src);
|
|
|
|
regs.x.si = FP_OFF(src);
|
|
|
|
intdosx(®s, ®s, &sregs);
|
2003-08-28 22:36:16 +02:00
|
|
|
} /* truename */
|
2003-06-16 15:33:40 +02:00
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
#endif
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer,
|
2003-06-16 00:01:45 +02:00
|
|
|
int write)
|
2001-07-10 00:19:33 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
struct {
|
|
|
|
unsigned long sectorNumber;
|
|
|
|
unsigned short count;
|
|
|
|
void far *address;
|
|
|
|
} diskReadPacket;
|
|
|
|
|
|
|
|
diskReadPacket.sectorNumber = sector;
|
|
|
|
diskReadPacket.count = count;
|
|
|
|
diskReadPacket.address = buffer;
|
|
|
|
|
2003-06-16 00:01:45 +02:00
|
|
|
if ((!write && absread(DosDrive, -1, -1, &diskReadPacket) == -1)
|
|
|
|
|| (write && abswrite(DosDrive, -1, -1, &diskReadPacket) == -1))
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
2002-02-03 23:40:24 +01:00
|
|
|
#ifdef WITHFAT32
|
2003-06-16 00:01:45 +02:00
|
|
|
return fat32readwrite(DosDrive + 1, &diskReadPacket, write);
|
2002-02-03 23:40:24 +01:00
|
|
|
#else
|
|
|
|
return 0xff;
|
2001-09-23 22:39:44 +02:00
|
|
|
#endif
|
2002-02-03 23:40:24 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* MyAbsReadWrite */
|
2002-02-03 23:40:24 +01:00
|
|
|
|
|
|
|
#ifdef __WATCOMC__
|
|
|
|
|
2003-06-16 00:01:45 +02:00
|
|
|
unsigned getextdrivespace(void far *drivename, void *buf, unsigned buf_size);
|
2002-02-03 23:40:24 +01:00
|
|
|
#pragma aux getextdrivespace = \
|
|
|
|
"mov ax, 0x7303" \
|
2002-02-07 23:30:58 +01:00
|
|
|
"stc" \
|
2002-02-03 23:40:24 +01:00
|
|
|
"int 0x21" \
|
2003-06-16 00:01:45 +02:00
|
|
|
"sbb ax, ax" \
|
|
|
|
parm [es dx] [di] [cx] \
|
2002-02-03 23:40:24 +01:00
|
|
|
value [ax];
|
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#else /* !defined __WATCOMC__ */
|
2002-02-03 23:40:24 +01:00
|
|
|
|
|
|
|
unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size)
|
|
|
|
{
|
|
|
|
union REGS regs;
|
|
|
|
struct SREGS sregs;
|
|
|
|
|
|
|
|
regs.x.ax = 0x7303; /* get extended drive free space */
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2002-02-03 23:40:24 +01:00
|
|
|
sregs.es = FP_SEG(buf);
|
|
|
|
regs.x.di = FP_OFF(buf);
|
|
|
|
sregs.ds = FP_SEG(drivename);
|
|
|
|
regs.x.dx = FP_OFF(drivename);
|
|
|
|
|
|
|
|
regs.x.cx = buf_size;
|
|
|
|
|
2003-06-16 00:01:45 +02:00
|
|
|
intdosx(®s, ®s, &sregs);
|
2002-02-07 23:30:58 +01:00
|
|
|
return regs.x.ax == 0x7300 || regs.x.cflag;
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* getextdrivespace */
|
2001-07-10 00:19:33 +02:00
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#endif /* defined __WATCOMC__ */
|
|
|
|
|
|
|
|
#ifdef __WATCOMC__
|
|
|
|
/*
|
|
|
|
* If BIOS has got LBA extensions, after the Int 13h call BX will be 0xAA55.
|
|
|
|
* If extended disk access functions are supported, bit 0 of CX will be set.
|
|
|
|
*/
|
|
|
|
BOOL haveLBA(void); /* return TRUE if we have LBA BIOS, FALSE otherwise */
|
|
|
|
#pragma aux haveLBA = \
|
|
|
|
"mov ax, 0x4100" /* IBM/MS Int 13h Extensions - installation check */ \
|
|
|
|
"mov bx, 0x55AA" \
|
|
|
|
"mov dl, 0x80" \
|
|
|
|
"int 0x13" \
|
|
|
|
"xor ax, ax" \
|
|
|
|
"cmp bx, 0xAA55" \
|
|
|
|
"jne quit" \
|
|
|
|
"and cx, 1" \
|
|
|
|
"xchg cx, ax" \
|
|
|
|
"quit:" \
|
|
|
|
modify [bx cx] \
|
|
|
|
value [ax];
|
|
|
|
#else
|
|
|
|
|
|
|
|
BOOL haveLBA(void)
|
|
|
|
{
|
|
|
|
union REGS r;
|
|
|
|
r.x.ax = 0x4100;
|
|
|
|
r.x.bx = 0x55AA;
|
|
|
|
r.h.dl = 0x80;
|
|
|
|
int86(0x13, &r, &r);
|
|
|
|
return r.x.bx == 0xAA55 && r.x.cx & 1;
|
|
|
|
}
|
2002-02-03 23:40:24 +01:00
|
|
|
#endif
|
|
|
|
|
2004-01-31 16:01:40 +01:00
|
|
|
void correct_bpb(struct bootsectortype *default_bpb,
|
|
|
|
struct bootsectortype *oldboot)
|
|
|
|
{
|
|
|
|
/* don't touch partitions (floppies most likely) that don't have hidden
|
|
|
|
sectors */
|
|
|
|
if (default_bpb->bsHiddenSecs == 0)
|
|
|
|
return;
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Old boot sector values: sectors/track: %u, heads: %u, hidden: %lu\n",
|
|
|
|
oldboot->bsSecPerTrack, oldboot->bsHeads, oldboot->bsHiddenSecs);
|
|
|
|
printf("Default and new boot sector values: sectors/track: %u, heads: %u, "
|
|
|
|
"hidden: %lu\n", default_bpb->bsSecPerTrack, default_bpb->bsHeads,
|
|
|
|
default_bpb->bsHiddenSecs);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
oldboot->bsSecPerTrack = default_bpb->bsSecPerTrack;
|
|
|
|
oldboot->bsHeads = default_bpb->bsHeads;
|
|
|
|
oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs;
|
|
|
|
}
|
|
|
|
|
2004-01-26 01:40:41 +01:00
|
|
|
void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-09-23 22:39:44 +02:00
|
|
|
#ifdef WITHFAT32
|
|
|
|
struct bootsectortype32 *bs32;
|
|
|
|
#endif
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
struct bootsectortype *bs;
|
|
|
|
static unsigned char oldboot[SEC_SIZE], newboot[SEC_SIZE];
|
2004-01-31 16:01:40 +01:00
|
|
|
static unsigned char default_bpb[0x5c];
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
#ifdef DEBUG
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("Reading old bootsector from drive %c:\n", drive + 'A');
|
|
|
|
#endif
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2004-01-31 16:01:40 +01:00
|
|
|
/* lock drive */
|
|
|
|
generic_block_ioctl((unsigned char)drive + 1, 0x84a, NULL);
|
|
|
|
|
2002-11-09 20:07:11 +01:00
|
|
|
reset_drive(drive);
|
2003-06-16 00:01:45 +02:00
|
|
|
/* suggestion: allow reading from a boot sector or image file here */
|
|
|
|
if (MyAbsReadWrite(drive, 1, 0, oldboot, 0) != 0)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
|
|
|
printf("can't read old boot sector for drive %c:\n", drive + 'A');
|
2000-05-06 21:34:20 +02:00
|
|
|
exit(1);
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
#ifdef DDEBUG
|
|
|
|
printf("Old Boot Sector:\n");
|
2000-05-06 21:34:20 +02:00
|
|
|
dump_sector(oldboot);
|
|
|
|
#endif
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
bs = (struct bootsectortype *)&oldboot;
|
|
|
|
|
|
|
|
{
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
/* see "FAT: General Overview of On-Disk Format" v1.02, 5.V.1999
|
|
|
|
* (http://www.nondot.org/sabre/os/files/FileSystems/FatFormat.pdf)
|
|
|
|
*/
|
|
|
|
ULONG fatSize, totalSectors, dataSectors, clusters;
|
|
|
|
UCOUNT rootDirSectors;
|
|
|
|
|
|
|
|
bs32 = (struct bootsectortype32 *)&oldboot;
|
|
|
|
rootDirSectors = (bs->bsRootDirEnts * DIRENT_SIZE /* 32 */
|
|
|
|
+ bs32->bsBytesPerSec - 1) / bs32->bsBytesPerSec;
|
|
|
|
fatSize = bs32->bsFATsecs ? bs32->bsFATsecs : bs32->bsBigFatSize;
|
|
|
|
totalSectors = bs32->bsSectors ? bs32->bsSectors : bs32->bsHugeSectors;
|
|
|
|
dataSectors = totalSectors
|
|
|
|
- bs32->bsResSectors - (bs32->bsFATs * fatSize) - rootDirSectors;
|
|
|
|
clusters = dataSectors / bs32->bsSecPerClust;
|
|
|
|
|
|
|
|
if (clusters < FAT_MAGIC) /* < 4085 */
|
|
|
|
fs = FAT12;
|
|
|
|
else if (clusters < FAT_MAGIC16) /* < 65525 */
|
|
|
|
fs = FAT16;
|
2001-09-23 22:39:44 +02:00
|
|
|
else
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
fs = FAT32;
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
if (bs->bsBytesPerSec != SEC_SIZE)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
printf("Sector size is not 512 but %d bytes - not currently supported!\n",
|
|
|
|
bs->bsBytesPerSec);
|
|
|
|
exit(1); /* Japan?! */
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|
2004-01-31 16:01:40 +01:00
|
|
|
|
|
|
|
/* bit 0 set if function to use current BPB, clear if Device
|
|
|
|
BIOS Parameter Block field contains new default BPB
|
|
|
|
bit 1 set if function to use track layout fields only
|
|
|
|
must be clear if CL=60h
|
|
|
|
bit 2 set if all sectors in track same size (should be set) (RBIL) */
|
|
|
|
default_bpb[0] = 4;
|
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
if (fs == FAT32)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
|
|
|
printf("FAT type: FAT32\n");
|
2004-01-31 16:01:40 +01:00
|
|
|
/* get default bpb (but not for floppies) */
|
|
|
|
if (drive >= 2 &&
|
|
|
|
generic_block_ioctl((unsigned char)drive + 1, 0x4860, default_bpb) == 0)
|
|
|
|
correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs);
|
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#ifdef WITHFAT32 /* copy one of the FAT32 boot sectors */
|
|
|
|
memcpy(newboot, haveLBA() ? fat32lba : fat32chs, SEC_SIZE);
|
2001-09-23 22:39:44 +02:00
|
|
|
#else
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
printf("SYS hasn't been compiled with FAT32 support.\n"
|
|
|
|
"Consider using -DWITHFAT32 option.\n");
|
2001-11-18 15:01:12 +01:00
|
|
|
exit(1);
|
2001-09-23 22:39:44 +02:00
|
|
|
#endif
|
2001-11-18 15:01:12 +01:00
|
|
|
}
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
else
|
|
|
|
{ /* copy the FAT12/16 CHS+LBA boot sector */
|
|
|
|
printf("FAT type: FAT1%c\n", fs + '0' - 10);
|
2004-01-31 16:01:40 +01:00
|
|
|
if (drive >= 2 &&
|
|
|
|
generic_block_ioctl((unsigned char)drive + 1, 0x860, default_bpb) == 0)
|
|
|
|
correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs);
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
memcpy(newboot, fs == FAT16 ? fat16com : fat12com, SEC_SIZE);
|
|
|
|
}
|
2001-07-10 00:19:33 +02:00
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Copy disk parameter from old sector to new sector */
|
2001-09-23 22:39:44 +02:00
|
|
|
#ifdef WITHFAT32
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
if (fs == FAT32)
|
2001-09-23 22:39:44 +02:00
|
|
|
memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE32);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
bs = (struct bootsectortype *)&newboot;
|
|
|
|
|
|
|
|
memcpy(bs->OemName, "FreeDOS ", 8);
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-09-23 22:39:44 +02:00
|
|
|
#ifdef WITHFAT32
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
if (fs == FAT32)
|
2001-11-18 15:01:12 +01:00
|
|
|
{
|
|
|
|
bs32 = (struct bootsectortype32 *)&newboot;
|
2002-08-04 03:14:18 +02:00
|
|
|
/* put 0 for A: or B: (force booting from A:), otherwise use DL */
|
2002-08-03 00:27:58 +02:00
|
|
|
bs32->bsDriveNumber = drive < 2 ? 0 : 0xff;
|
2004-01-26 01:40:41 +01:00
|
|
|
/* the location of the "0060" segment portion of the far pointer
|
|
|
|
in the boot sector is just before cont: in boot*.asm.
|
|
|
|
This happens to be offset 0x78 (=0x3c * 2) for FAT32 and
|
|
|
|
offset 0x5c (=0x2e * 2) for FAT16 */
|
|
|
|
/* i.e. BE CAREFUL WHEN YOU CHANGE THE BOOT SECTORS !!! */
|
|
|
|
((int *)newboot)[0x3C] = load_seg;
|
2001-09-23 22:39:44 +02:00
|
|
|
#ifdef DEBUG
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
printf(" FAT starts at sector %lx + %x\n",
|
2001-11-18 15:01:12 +01:00
|
|
|
bs32->bsHiddenSecs, bs32->bsResSectors);
|
2001-09-23 22:39:44 +02:00
|
|
|
#endif
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
}
|
2001-09-24 04:21:14 +02:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2002-08-04 03:14:18 +02:00
|
|
|
/* put 0 for A: or B: (force booting from A:), otherwise use DL */
|
|
|
|
bs->bsDriveNumber = drive < 2 ? 0 : 0xff;
|
2004-01-26 01:40:41 +01:00
|
|
|
((int *)newboot)[0x2E] = load_seg;
|
2001-09-24 04:21:14 +02:00
|
|
|
}
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2003-06-16 00:01:45 +02:00
|
|
|
#ifdef DEBUG /* add an option to display this on user request? */
|
2001-04-29 19:34:41 +02:00
|
|
|
printf("Root dir entries = %u\n", bs->bsRootDirEnts);
|
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
printf("FAT starts at sector (%lu + %u)\n",
|
2001-11-18 15:01:12 +01:00
|
|
|
bs->bsHiddenSecs, bs->bsResSectors);
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
printf("Root directory starts at sector (PREVIOUS + %u * %u)\n",
|
|
|
|
bs->bsFATsecs, bs->bsFATs);
|
2001-04-29 19:34:41 +02:00
|
|
|
#endif
|
2003-09-21 18:13:16 +02:00
|
|
|
{
|
2003-09-24 00:31:32 +02:00
|
|
|
int i = 0;
|
|
|
|
memset(&newboot[0x1f1], ' ', 11);
|
|
|
|
while (kernel_name[i] && kernel_name[i] != '.')
|
2003-09-21 18:13:16 +02:00
|
|
|
{
|
2003-09-24 00:31:32 +02:00
|
|
|
if (i < 8)
|
|
|
|
newboot[0x1f1+i] = toupper(kernel_name[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (kernel_name[i] == '.')
|
|
|
|
{
|
|
|
|
/* copy extension */
|
|
|
|
int j = 0;
|
|
|
|
i++;
|
|
|
|
while (kernel_name[i+j] && j < 3)
|
|
|
|
{
|
|
|
|
newboot[0x1f9+j] = toupper(kernel_name[i+j]);
|
|
|
|
j++;
|
|
|
|
}
|
2003-09-21 18:13:16 +02:00
|
|
|
}
|
|
|
|
}
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2003-09-24 00:31:32 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* there's a zero past the kernel name in all boot sectors */
|
|
|
|
printf("Boot sector kernel name set to %s\n", &newboot[0x1f1]);
|
2004-01-26 01:40:41 +01:00
|
|
|
printf("Boot sector load segment set to %Xh\n", load_seg);
|
2003-09-24 00:31:32 +02:00
|
|
|
#endif
|
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
#ifdef DDEBUG
|
|
|
|
printf("\nNew Boot Sector:\n");
|
2000-05-06 21:34:20 +02:00
|
|
|
dump_sector(newboot);
|
|
|
|
#endif
|
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
if ((bsFile == NULL) || both)
|
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
#ifdef DEBUG
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("writing new bootsector to drive %c:\n", drive + 'A');
|
|
|
|
#endif
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2003-06-16 00:01:45 +02:00
|
|
|
/* write newboot to a drive */
|
|
|
|
if (MyAbsReadWrite(drive, 1, 0, newboot, 1) != 0)
|
2001-04-29 19:34:41 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("Can't write new boot sector to drive %c:\n", drive + 'A');
|
2001-11-14 00:36:45 +01:00
|
|
|
exit(1);
|
2001-04-29 19:34:41 +02:00
|
|
|
}
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* if write boot sector */
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
if (bsFile != NULL)
|
|
|
|
{
|
|
|
|
int fd;
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("writing new bootsector to file %s\n", bsFile);
|
2001-11-18 15:01:12 +01:00
|
|
|
#endif
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-11-14 00:36:45 +01:00
|
|
|
/* write newboot to bsFile */
|
2003-06-16 00:01:45 +02:00
|
|
|
if ((fd = /* suggestion: do not trunc - allows to write to images */
|
2001-11-18 15:01:12 +01:00
|
|
|
open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,
|
|
|
|
S_IREAD | S_IWRITE)) < 0)
|
2001-11-14 00:36:45 +01:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno);
|
2001-11-14 00:36:45 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (write(fd, newboot, SEC_SIZE) != SEC_SIZE)
|
|
|
|
{
|
|
|
|
printf("Can't write %u bytes to %s\n", SEC_SIZE, bsFile);
|
|
|
|
close(fd);
|
|
|
|
unlink(bsFile);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
close(fd);
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* if write boot sector file */
|
2002-11-09 20:07:11 +01:00
|
|
|
reset_drive(drive);
|
2004-01-31 16:01:40 +01:00
|
|
|
|
|
|
|
/* unlock_drive */
|
|
|
|
generic_block_ioctl((unsigned char)drive + 1, 0x86a, NULL);
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* put_boot */
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
/*
|
|
|
|
* Returns TRUE if `drive` has at least `bytes` free space, FALSE otherwise.
|
|
|
|
* put_sector() must have been already called to determine file system type.
|
|
|
|
*/
|
|
|
|
BOOL check_space(COUNT drive, ULONG bytes)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#ifdef WITHFAT32
|
|
|
|
if (fs == FAT32)
|
|
|
|
{
|
|
|
|
char *drivename = "A:\\";
|
|
|
|
drivename[0] = 'A' + drive;
|
|
|
|
getextdrivespace(drivename, &x, sizeof(x));
|
|
|
|
return x.xfs_freeclusters > (bytes / (x.xfs_clussize * x.xfs_secsize));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
#ifdef __TURBOC__
|
|
|
|
struct dfree df;
|
|
|
|
getdfree(drive + 1, &df);
|
|
|
|
return (ULONG)df.df_avail * df.df_sclus * df.df_bsec >= bytes;
|
|
|
|
#else
|
|
|
|
struct _diskfree_t df;
|
|
|
|
_dos_getdiskfree(drive + 1, &df);
|
|
|
|
return (ULONG)df.avail_clusters * df.sectors_per_cluster
|
|
|
|
* df.bytes_per_sector >= bytes;
|
|
|
|
#endif
|
|
|
|
}
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* check_space */
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-09-23 22:39:44 +02:00
|
|
|
BYTE copybuffer[COPY_SIZE];
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-09-24 04:21:14 +02:00
|
|
|
BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2003-06-16 15:33:40 +02:00
|
|
|
static BYTE dest[SYS_MAXPATH], source[SYS_MAXPATH];
|
2001-04-29 19:34:41 +02:00
|
|
|
unsigned ret;
|
|
|
|
int fdin, fdout;
|
|
|
|
ULONG copied = 0;
|
2001-09-23 22:39:44 +02:00
|
|
|
struct stat fstatbuf;
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2002-10-22 04:40:19 +02:00
|
|
|
strcpy(source, srcPath);
|
|
|
|
if (rootPath != NULL) /* trick for comspec */
|
|
|
|
strcat(source, file);
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2001-09-24 04:21:14 +02:00
|
|
|
if (stat(source, &fstatbuf))
|
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("%s: \"%s\" not found\n", pgm, source);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2001-09-24 04:21:14 +02:00
|
|
|
if ((rootPath != NULL) && (*rootPath) /* && (errno == ENOENT) */ )
|
|
|
|
{
|
|
|
|
sprintf(source, "%s%s", rootPath, file);
|
|
|
|
printf("%s: Trying \"%s\"\n", pgm, source);
|
|
|
|
if (stat(source, &fstatbuf))
|
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("%s: \"%s\" not found\n", pgm, source);
|
2001-09-24 04:21:14 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-11-18 15:01:12 +01:00
|
|
|
|
2003-06-16 15:33:40 +02:00
|
|
|
truename(dest, source);
|
|
|
|
strcpy(source, dest);
|
|
|
|
sprintf(dest, "%c:\\%s", 'A' + drive, file);
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
if (stricmp(source, dest) == 0)
|
2003-06-16 15:33:40 +02:00
|
|
|
{
|
|
|
|
printf("%s: source and destination are identical: skipping \"%s\"\n",
|
|
|
|
pgm, source);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
if ((fdin = open(source, O_RDONLY | O_BINARY)) < 0)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("%s: failed to open \"%s\"\n", pgm, source);
|
2000-05-06 21:34:20 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-09-23 22:39:44 +02:00
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
if (!check_space(drive, filelength(fdin)))
|
|
|
|
{
|
|
|
|
printf("%s: Not enough space to transfer %s\n", pgm, file);
|
|
|
|
close(fdin);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
if ((fdout =
|
|
|
|
open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,
|
|
|
|
S_IREAD | S_IWRITE)) < 0)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno);
|
2001-04-29 19:34:41 +02:00
|
|
|
close(fdin);
|
2000-05-06 21:34:20 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
while ((ret = read(fdin, copybuffer, COPY_SIZE)) > 0)
|
|
|
|
{
|
|
|
|
if (write(fdout, copybuffer, ret) != ret)
|
2000-05-06 21:34:20 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
printf("Can't write %u bytes to %s\n", ret, dest);
|
|
|
|
close(fdout);
|
|
|
|
unlink(dest);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
copied += ret;
|
|
|
|
}
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2001-09-23 22:39:44 +02:00
|
|
|
{
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#if defined __WATCOMC__ || defined _MSC_VER /* || defined __BORLANDC__ */
|
|
|
|
unsigned short date, time;
|
|
|
|
_dos_getftime(fdin, &date, &time);
|
|
|
|
_dos_setftime(fdout, date, time);
|
|
|
|
#elif defined __TURBOC__
|
2001-09-23 22:39:44 +02:00
|
|
|
struct ftime ftime;
|
|
|
|
getftime(fdin, &ftime);
|
|
|
|
setftime(fdout, &ftime);
|
2001-11-18 15:01:12 +01:00
|
|
|
#endif
|
2002-01-27 02:13:07 +01:00
|
|
|
}
|
2001-04-29 19:34:41 +02:00
|
|
|
|
|
|
|
close(fdin);
|
|
|
|
close(fdout);
|
2001-11-18 15:01:12 +01:00
|
|
|
|
Version 2.7 luchezar, tomehlert, ericauer 2003/8/5
boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes)
512 byte sector size check removed (although Eric's boot32ea.asm does require
512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway).
boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho)
bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common)
Version 2.7beta, Luchezar Georgiev, 1 August 2003
o Now supports and includes the following new boot sectors:
1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July)
2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July)
3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July)
o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable,
non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used.
o dump_sector() showed ASCII debug printout for the old sector only - fixed.
o Put a boot sector only if sector size = 512 (may it not be so in Japan?!).
If non-512 byte sectors encountered, report to the fd-kernel mailing list.
o Now puts boot sector before copying kernel/shell so it works in WinNT now.
o check_space() now implemented at last (required significant modifications)
o New file system (FAT type) detection method according to a MS White Paper.
o Now BOOTONLY works even without a preceding boot sector image file name.
o Some minor code cleanups.
Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code.
use boot32lb.asm instead of boot32ea.asm
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b
2003-08-08 17:01:15 +02:00
|
|
|
#ifdef __SOME_OTHER_COMPILER__
|
2001-09-23 22:39:44 +02:00
|
|
|
{
|
2001-11-18 15:01:12 +01:00
|
|
|
#include <utime.h>
|
|
|
|
struct utimbuf utimb;
|
2001-09-23 22:39:44 +02:00
|
|
|
|
2001-11-18 15:01:12 +01:00
|
|
|
utimb.actime = /* access time */
|
|
|
|
utimb.modtime = fstatbuf.st_mtime; /* modification time */
|
|
|
|
utime(dest, &utimb);
|
2001-09-23 22:39:44 +02:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2001-04-29 19:34:41 +02:00
|
|
|
printf("%lu Bytes transferred", copied);
|
2000-05-06 21:34:20 +02:00
|
|
|
|
|
|
|
return TRUE;
|
2003-06-16 00:01:45 +02:00
|
|
|
} /* copy */
|
|
|
|
|