/*
 * dos.i86  -  Definition of various DOS structures and functions
 *
 * Copyright (C) 2003-2007 Gero Kuhlmann   <gero@gkminix.han.de>
 *
 *  This program 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 of the License, or
 *  any later version.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: dos.i86,v 1.5 2007/01/06 18:31:23 gkminix Exp $
 *
 */

#ifndef HEADERS_DOS_I86
#define HEADERS_DOS_I86


/*
 *====================================================================
 *
 * This file can only get included into assembler source files
 */
#if !defined(_ASSEMBLY_) || !defined(_TARGET_)
# error This file can only get included into assembler source files
#endif




/*
 *====================================================================
 *
 * Include general DOS definitions
 */
#include <dos/general.i86>
#include <dos/functions.i86>
#include <dos/ioctl.i86>
#include <dos/exec.i86>



/*
 *====================================================================
 *
 * Load segments for various parts of the DOS kernel
 */
#define DIR_SEG		0x0050		/* segment where DOS expects root dir */
#define FREEDOS_SEG	0x0060		/* load segment for KERNEL.SYS */
#define IOSYS_SEG	0x0070		/* load segment for IO.SYS */




/*
 *====================================================================
 *
 * Definition of BIOS parameter block as used by DOS. Note that the first
 * 25 bytes of the BPB are the same as in the boot sector.
 */
#define BPB_SIZE	36		/* size of DOS BIOS parameter block */
#define BPB_BOOT_SIZE	25		/* size of BPB within boot sector */

			.struct	0
bpb_sectsize:		.struct	.+2	/* sector size */
bpb_spclust:		.struct	.+1	/* sectors per cluster */
bpb_reserved:		.struct	.+2	/* number of reserved sectors */
bpb_fatnum:		.struct	.+1	/* number of FATs */
bpb_dirnum:		.struct	.+2	/* number of root directory entries */
bpb_totsect:		.struct	.+2	/* number of total sectors */
bpb_mediaid:		.struct	.+1	/* media ID */
bpb_spfat:		.struct	.+2	/* sectors per FAT */
bpb_sptrack:		.struct	.+2	/* sectors per track */
bpb_headnum:		.struct	.+2	/* number of heads */
bpb_hidden:		.struct	.+4	/* number of hidden sectors */
bpb_totsect32:		.struct	.+4	/* number of total sectors */
			.struct	.+6
bpb_cylnum:		.struct	.+2	/* numer of cylinders */
bpb_devtype:		.struct	.+1	/* device type */
bpb_devattr:		.struct	.+2	/* device attributes */



/*
 * Definition of extended BIOS parameter block. This is only used by DOS
 * versions 7.0 and higher. The first 25 bytes are the same as in the
 * standard BPB.
 */
#define BPB_EXT_SIZE	53		/* size of extended BPB */
#define BPB_EXT_OFS	0x0019		/* offset to extended BPB */

			.struct	BPB_EXT_OFS
bpb_spfat16:		.struct	.+4	/* number of sectors per FAT */
bpb_extflags:		.struct	.+2	/* extended flags */
bpb_fsversion:		.struct	.+2	/* file system version */
bpb_rootclust:		.struct	.+4	/* root directory clusters */
bpb_fsinfo:		.struct	.+2	/* FS info sector number */
bpb_bkupboot:		.struct	.+2	/* backup boot sector number */




/*
 *====================================================================
 *
 * Definitions for EXE-style DOS kernel file
 */
#define EXE_SIG		0x5A4D		/* signature of EXE type kernel file */
#define EXE_EXECADDR	0x0200		/* execution address of EXE type file */


#endif

