*BSD News Article 5348


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!uunet!cs.utexas.edu!sun-barr!ames!agate!tfs.com!tfs.com!julian
From: julian@tfs.com (Julian Elischer)
Subject: BIOS BOOT BLOCKS part 2 of 2 (REPOST with several fixes included)
Message-ID: <1992Sep20.214102.27244@tfs.com>
Organization: TRW Financial Systems
Date: Sun, 20 Sep 1992 21:41:02 GMT
Lines: 1543

WARNING:
THE file i386/boot/rmaouthdr in the first shar file
should have its permissions changed toadd execute bits.
(I forgot)

julian

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	i386/boot/boot2.s
#	i386/boot/boot.sed
#	i386/boot/boot.h
#	i386/boot/boot.c
#	i386/boot/bios.s
#	i386/boot/asm.s
#	i386/boot/README.MACH
#	i386/boot/README.386BSD
#	i386/boot/Makefile
#
echo x - i386/boot/boot2.s
sed 's/^X//' >i386/boot/boot2.s << 'END-of-i386/boot/boot2.s'
X/*
X * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
X *
X * Mach Operating System
X * Copyright (c) 1992, 1991 Carnegie Mellon University
X * All Rights Reserved.
X * 
X * Permission to use, copy, modify and distribute this software and its
X * documentation is hereby granted, provided that both the copyright
X * notice and this permission notice appear in all copies of the
X * software, derivative works or modified versions, and any portions
X * thereof, and that both notices appear in supporting documentation.
X * 
X * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
X * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
X * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
X * 
X * Carnegie Mellon requests users of this software to return to
X * 
X *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
X *  School of Computer Science
X *  Carnegie Mellon University
X *  Pittsburgh PA 15213-3890
X * 
X * any improvements or extensions that they make and grant Carnegie Mellon
X * the rights to redistribute these changes.
X */
X
X/*
X * HISTORY
X * $Log:	boot2.s,v $
X * Revision 2.2  92/04/04  11:35:26  rpd
X * 	From 2.5
X * 	[92/03/30            rvb]
X * 
X * Revision 2.2  91/04/02  14:39:21  mbj
X * 	Put into rcs tree
X * 	[90/02/09            rvb]
X * 
X */
X
X#include	"asm.h"
X#define LOADMSG 1
X/*
X * boot2() -- second stage boot
X */
X
X.globl _ouraddr
X
XENTRY(boot2)
X	movl	%cs, %ax
X	movl	%ax, %ds
X	movl	%ax, %es
X	data32
X	sall	$4, %eax
X	data32
X	movl	%eax, _ouraddr
X	/* save the drive type and ID */ 
X	data32
X	pushl	%edx
X	/* change to protected mode */
X	data32
X	call	_real_to_prot
X
X	call	_boot
X	ret
X
X	.data
X        .align 2
X_ouraddr:
X        .long 0
X
X
END-of-i386/boot/boot2.s
echo x - i386/boot/boot.sed
sed 's/^X//' >i386/boot/boot.sed << 'END-of-i386/boot/boot.sed'
X/^[ 	]*.data/c\
X	.text
X/^[ 	]*.ident/d
END-of-i386/boot/boot.sed
echo x - i386/boot/boot.h
sed 's/^X//' >i386/boot/boot.h << 'END-of-i386/boot/boot.h'
X/*
X * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
X *
X * Mach Operating System
X * Copyright (c) 1992, 1991 Carnegie Mellon University
X * All Rights Reserved.
X * 
X * Permission to use, copy, modify and distribute this software and its
X * documentation is hereby granted, provided that both the copyright
X * notice and this permission notice appear in all copies of the
X * software, derivative works or modified versions, and any portions
X * thereof, and that both notices appear in supporting documentation.
X * 
X * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
X * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
X * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
X * 
X * Carnegie Mellon requests users of this software to return to
X * 
X *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
X *  School of Computer Science
X *  Carnegie Mellon University
X *  Pittsburgh PA 15213-3890
X * 
X * any improvements or extensions that they make and grant Carnegie Mellon
X * the rights to redistribute these changes.
X */
X
X/*
X * HISTORY
X * $Log:	boot.h,v $
X * Revision 2.2  92/04/04  11:35:03  rpd
X * 	Fabricated from 3.0 bootstrap.  But too many things are global.
X * 	[92/03/30            mg32]
X * 
X */
X
X#include <sys/types.h>
X#include <sys/param.h>
X#include <ufs/quota.h>
X#include <ufs/fs.h>
X#include <ufs/inode.h>
X
Xextern char *devs[], *name, *iodest;
Xextern struct fs *fs;
Xextern struct inode inode;
Xextern int dosdev, unit, part, maj, boff, poff, bnum, cnt;
Xextern	long int	ouraddr;
END-of-i386/boot/boot.h
echo x - i386/boot/boot.c
sed 's/^X//' >i386/boot/boot.c << 'END-of-i386/boot/boot.c'
X/*
X * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
X *
X * Mach Operating System
X * Copyright (c) 1992, 1991 Carnegie Mellon University
X * All Rights Reserved.
X * 
X * Permission to use, copy, modify and distribute this software and its
X * documentation is hereby granted, provided that both the copyright
X * notice and this permission notice appear in all copies of the
X * software, derivative works or modified versions, and any portions
X * thereof, and that both notices appear in supporting documentation.
X * 
X * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
X * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
X * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
X * 
X * Carnegie Mellon requests users of this software to return to
X * 
X *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
X *  School of Computer Science
X *  Carnegie Mellon University
X *  Pittsburgh PA 15213-3890
X * 
X * any improvements or extensions that they make and grant Carnegie Mellon
X * the rights to redistribute these changes.
X */
X
X/*
X * HISTORY
X * $Log:	boot.c,v $
X * Revision 2.2  92/04/04  11:34:37  rpd
X * 	Change date in banner.
X * 	[92/04/03  16:51:14  rvb]
X * 
X * 	Fix Intel Copyright as per B. Davies authorization.
X * 	[92/04/03            rvb]
X * 	From 2.5 version.
X * 	[92/03/30            mg32]
X * 
X */
X
X/*
X  Copyright 1988, 1989, 1990, 1991, 1992 
X   by Intel Corporation, Santa Clara, California.
X
X                All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and
Xits documentation for any purpose and without fee is hereby
Xgranted, provided that the above copyright notice appears in all
Xcopies and that both the copyright notice and this permission notice
Xappear in supporting documentation, and that the name of Intel
Xnot be used in advertising or publicity pertaining to distribution
Xof the software without specific, written prior permission.
X
XINTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
XINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
XIN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
XCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
XLOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
XNEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
XWITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X*/
X
X#include <sys/param.h>
X#include "boot.h"
X#include <a.out.h>
X#include <sys/reboot.h>
X
X
Xstruct exec head;
Xint argv[10], esym;
Xchar *name;
Xchar *names[] = {
X	"/386bsd", "/386bsd.old",
X	"/vmunix", "/vmunix.old"
X};
X#define NUMNAMES	(sizeof(names)/sizeof(char *))
X
Xextern int end;
Xboot(drive)
Xint drive;
X{
X	int loadflags, currname = 0;
X	printf("\n>> 386bsd BOOT @ 0x%x: %d/%d k of memory  [20/9/92]\n",
X		ouraddr,
X		argv[7] = memsize(0),
X		argv[8] = memsize(1));
X	printf("use options hd(1,...... to boot sd0 when wd0 is also installed\n");
X	gateA20();
Xloadstart:
X	/***************************************************************\
X	* As a default set it to the first partition of the first	*
X	* floppy or hard drive						*
X	\***************************************************************/
X	part = unit = 0;
X	maj = (drive&0x80 ? 0 : 2);		/* a good first bet */
X	name = names[currname++];
X
X	loadflags = 0;
X	if (currname == NUMNAMES)
X		currname = 0;
X	getbootdev(&loadflags);
X	if (openrd()) {
X		printf("Can't find %s\n", name);
X		goto loadstart;
X	}
X/*	if (inode.i_mode&IEXEC)
X		loadflags |= RB_KDB;
X*/
X	loadprog(loadflags);
X	goto loadstart;
X}
X
Xloadprog(howto)
X	int		howto;
X{
X	long int startaddr;
X	long int addr;	/* physical address.. not directly useable */
X	int i;
X	static int (*x_entry)() = 0;
X	unsigned char	tmpbuf[4096]; /* we need to load the first 4k here */
X
X	argv[3] = 0;
X	argv[4] = 0;
X	read(&head, sizeof(head));
X	if (head.a_magic == 0413 )
X	{
X		poff = 4096;
X	}
X	else
X	{
X		printf("Invalid format!\n");
X		return;
X	}
X
X	startaddr = (int)head.a_entry;
X	addr = (startaddr & 0x00f00000); /* some MEG boundary */
X	printf("Booting %s(%d,%c)%s @ 0x%x\n"
X			, devs[maj]
X			, unit
X			, 'a'+part
X			, name
X			, addr);
X	if(addr < ouraddr)
X	{
X		if((addr + head.a_text + head.a_data) > ouraddr)
X		{
X			printf("kernel will not fit below loader\n");
X			return;
X		}
X		if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000)
X		{
X			printf("kernel too big, won't fit in 640K with bss\n");
X			printf("Only hope is to link the kernel for > 1MB\n");
X			return;
X		}
X		if((addr + head.a_text + head.a_data + head.a_bss) > ouraddr)
X		{
X			printf("loader overlaps bss, kernel must bzero\n");
X		}
X	}
X	printf("text=0x%x", head.a_text);
X	/********************************************************/
X	/* LOAD THE TEXT SEGMENT				*/
X	/* don't clobber the first 4k yet (BIOS NEEDS IT) 	*/
X	/********************************************************/
X	read(tmpbuf,4096);
X	addr += 4096; 
X	xread(addr, head.a_text - 4096);
X	addr += head.a_text - 4096;
X
X	/********************************************************/
X	/* Load the Initialised data after the text		*/
X	/********************************************************/
X	while (addr & CLOFSET)
X                *(char *)addr++ = 0;
X
X	printf(" data=0x%x", head.a_data);
X	xread(addr, head.a_data);
X	addr += head.a_data;
X
X	/********************************************************/
X	/* Skip over the uninitialised data			*/
X	/* (but clear it)					*/
X	/********************************************************/
X	printf(" bss=0x%x", head.a_bss);
X	if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr))
X	{
X		pbzero(addr,ouraddr - (int)addr);
X	}
X	else
X	{
X		pbzero(addr,head.a_bss);
X	}
X	argv[3] = (addr += head.a_bss);
X
X#ifdef LOADSYMS /* not yet, haven't worked this out yet */
X	if (addr > 0x100000)
X	{
X		/********************************************************/
X		/*copy in the symbol header				*/
X		/********************************************************/
X		pcpy(&head.a_syms, addr, sizeof(head.a_syms));
X		addr += sizeof(head.a_syms);
X	
X		/********************************************************/
X		/* READ in the symbol table				*/
X		/********************************************************/
X		printf(" symbols=[+0x%x", head.a_syms);
X		xread(addr, head.a_syms);
X		addr += head.a_syms;
X	
X		/********************************************************/
X		/* Followed by the next integer (another header)	*/
X		/* more debug symbols?					*/
X		/********************************************************/
X		read(&i, sizeof(int));
X		pcpy(&i, addr, sizeof(int));
X		i -= sizeof(int);
X		addr += sizeof(int);
X	
X	
X		/********************************************************/
X		/* and that many bytes of (debug symbols?)		*/
X		/********************************************************/
X		printf("+0x%x]", i);
X		xread(addr, i);
X		addr += i;
X	}
X#endif	LOADSYMS
X	/********************************************************/
X	/* and note the end address of all this			*/
X	/********************************************************/
X
X	argv[4] = ((addr+sizeof(int)-1))&~(sizeof(int)-1);
X	printf(" total=0x%x",argv[4]);
X
X
X	/*
X	 *  We now pass the various bootstrap parameters to the loaded
X	 *  image via the argument list
X	 *  (THIS IS A BIT OF HISTORY FROM MACH.. LEAVE FOR NOW)
X	 *  arg1 = boot flags
X	 *  arg2 = boot device
X	 *  arg3 = start of symbol table (0 if not loaded)
X	 *  arg4 = end of symbol table (0 if not loaded)
X	 *  arg5 = transfer address from image
X	 *  arg6 = transfer address for next image pointer
X	 */
X	switch(maj)
X	{
X	case 2:
X		printf("\n\nInsert file system floppy \n");
X		getchar();
X		break;
X	case 4:
X		break;
X	}
X	argv[1] = howto;
X	argv[2] = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ;
X	argv[5] = (head.a_entry &= 0xfffffff);
X	argv[6] = (int) &x_entry;
X	argv[0] = 8;
X	/****************************************************************/
X	/* copy that first page and overwrite any BIOS variables	*/
X	/****************************************************************/
X	printf(" entry point=0x%x \n" ,((int)startaddr) & 0xffffff);
X	pcpy(tmpbuf, 0, 4096);
X	startprog(((int)startaddr & 0xffffff),argv);
X}
X
Xchar namebuf[100];
Xgetbootdev(howto)
X     int *howto;
X{
X	char c, *ptr = namebuf;
X	printf("Boot: [[[%s(%d,%c)]%s][-s][-a][-d]] :- "
X			, devs[maj]
X			, unit
X			, 'a'+part
X			, name);
X	if (gets(namebuf)) {
X		while (c=*ptr) {
X			while (c==' ')
X				c = *++ptr;
X			if (!c)
X				return;
X			if (c=='-')
X				while ((c = *++ptr) && c!=' ')
X					switch (c) {
X					      case 'a':
X						*howto |= RB_ASKNAME; continue;
X					      case 's':
X						*howto |= RB_SINGLE; continue;
X					      case 'd':
X						*howto |= RB_KDB; continue;
X					      case 'b':
X						*howto |= RB_HALT; continue;
X					}
X			else {
X				name = ptr;
X				while ((c = *++ptr) && c!=' ');
X				if (c)
X					*ptr++ = 0;
X			}
X		}
X	}
X}
X
END-of-i386/boot/boot.c
echo x - i386/boot/bios.s
sed 's/^X//' >i386/boot/bios.s << 'END-of-i386/boot/bios.s'
X/*
X * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
X *
X * Mach Operating System
X * Copyright (c) 1992, 1991 Carnegie Mellon University
X * All Rights Reserved.
X * 
X * Permission to use, copy, modify and distribute this software and its
X * documentation is hereby granted, provided that both the copyright
X * notice and this permission notice appear in all copies of the
X * software, derivative works or modified versions, and any portions
X * thereof, and that both notices appear in supporting documentation.
X * 
X * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
X * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
X * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
X * 
X * Carnegie Mellon requests users of this software to return to
X * 
X *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
X *  School of Computer Science
X *  Carnegie Mellon University
X *  Pittsburgh PA 15213-3890
X * 
X * any improvements or extensions that they make and grant Carnegie Mellon
X * the rights to redistribute these changes.
X */
X
X/*
X * HISTORY
X * $Log:	bios.s,v $
X * Revision 2.2  92/04/04  11:34:26  rpd
X * 	Fix Intel Copyright as per B. Davies authorization.
X * 	[92/04/03            rvb]
X * 	From 2.5 version
X * 	[92/03/30            mg32]
X * 
X * Revision 2.2  91/04/02  14:35:21  mbj
X * 	Add Intel copyright
X * 	[90/02/09            rvb]
X * 
X */
X
X
X/*
X  Copyright 1988, 1989, 1990, 1991, 1992 
X   by Intel Corporation, Santa Clara, California.
X
X                All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and
Xits documentation for any purpose and without fee is hereby
Xgranted, provided that the above copyright notice appears in all
Xcopies and that both the copyright notice and this permission notice
Xappear in supporting documentation, and that the name of Intel
Xnot be used in advertising or publicity pertaining to distribution
Xof the software without specific, written prior permission.
X
XINTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
XINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
XIN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
XCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
XLOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
XNEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
XWITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X*/
X
X	.file	"bios.s"
X
X#include "asm.h"
X	.text
X
X# biosread(dev, cyl, head, sec)
X#	Read one sector from disk into the internal buffer "intbuf" which
X#	is the first 512 bytes of the boot loader.
X# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
X#	Call with	%ah = 0x2
X#			%al = number of sectors
X#			%ch = cylinder
X#			%cl = sector
X#			%dh = head
X#			%dl = drive (0x80 for hard disk, 0x0 for floppy disk)
X#			%es:%bx = segment:offset of buffer
X#	Return:		
X#			%al = 0x0 on success; err code on failure
X
XENTRY(biosread)
X	push	%ebp
X	mov	%esp, %ebp
X
X	push	%ebx
X	push	%ecx
X	push	%edx
X	push	%es
X
X	movb	0x10(%ebp), %dh
X	movw	0x0c(%ebp), %cx
X	xchgb	%ch, %cl	# cylinder; the highest 2 bits of cyl is in %cl
X	rorb	$2, %cl
X	movb	0x14(%ebp), %al
X	orb	%al, %cl
X	incb	%cl		# sector; sec starts from 1, not 0
X	movb	0x8(%ebp), %dl	# device
X	xor	%ebx, %ebx	# offset -- 0
X				# prot_to_real will set %es to BOOTSEG
X
X	call	EXT(prot_to_real)	# enter real mode
X	movb	$0x2, %ah	# subfunction
X	movb	$0x1, %al	# number of sectors -- one
X
X	sti
X	int	$0x13
X	cli
X
X	mov	%eax, %ebx	# save return value
X
X	data16
X	call	EXT(real_to_prot) # back to protected mode
X
X	xor	%eax, %eax
X	movb	%bh, %al	# return value in %ax
X
X	pop	%es
X	pop	%edx
X	pop	%ecx
X	pop	%ebx
X	pop	%ebp
X
X	ret
X
X
X# putc(ch)
X# BIOS call "INT 10H Function 0Eh" to write character to console
X#	Call with	%ah = 0x0e
X#			%al = character
X#			%bh = page
X#			%bl = foreground color ( graphics modes)
X
X
XENTRY(putc)
X	push	%ebp
X	mov	%esp, %ebp
X	push	%ebx
X	push	%ecx
X
X	movb	0x8(%ebp), %cl
X
X	call	EXT(prot_to_real)
X
X	data16
X	mov	$0x1, %ebx	# %bh=0, %bl=1 (blue)
X	movb	$0xe, %ah
X	movb	%cl, %al
X	sti
X	int	$0x10		# display a byte
X	cli
X
X	data16
X	call	EXT(real_to_prot)
X
X	pop	%ecx
X	pop	%ebx
X	pop	%ebp
X	ret
X
X
X# getc()
X# BIOS call "INT 16H Function 00H" to read character from keyboard
X#	Call with	%ah = 0x0
X#	Return:		%ah = keyboard scan code
X#			%al = ASCII character
X
XENTRY(getc)
X	push	%ebp
X	mov	%esp, %ebp
X	push	%ebx		# save %ebx
X
X	call	EXT(prot_to_real)
X
X	movb	$0x0, %ah
X	sti
X	int	$0x16
X	cli
X
X	movb	%al, %bl	# real_to_prot uses %eax
X
X	data16
X	call	EXT(real_to_prot)
X
X	xor	%eax, %eax
X	movb	%bl, %al
X
X	pop	%ebx
X	pop	%ebp
X	ret
X/*
X# ischar()
X#       if there is a character pending, return it; otherwise return 0
X# BIOS call "INT 16H Function 01H" to check whether a character is pending
X#	Call with	%ah = 0x1
X#	Return:
X#		If key waiting to be input:
X#			%ah = keyboard scan code
X#			%al = ASCII character
X#			Zero flag = clear
X#		else
X#			Zero flag = set
X*/
XENTRY(ischar)
X	push	%ebp
X	mov	%esp, %ebp
X	push	%ebx
X
X	call	EXT(prot_to_real)		# enter real mode
X
X	xor	%ebx, %ebx
X	movb	$0x1, %ah
X	sti
X	int	$0x16
X	cli
X	data16
X	jz	nochar
X	movb	%al, %bl
X
Xnochar:
X	data16
X	call	EXT(real_to_prot)
X
X	xor	%eax, %eax
X	movb	%bl, %al
X
X	pop	%ebx
X	pop	%ebp
X	ret
X
X#
X# get_diskinfo():  return a word that represents the
X#	max number of sectors and  heads and drives for this device
X#
X
XENTRY(get_diskinfo)
X	push	%ebp
X	mov	%esp, %ebp
X	push	%es
X	push	%ebx
X	push	%ecx
X	push	%edx
X
X	movb	0x8(%ebp), %dl		# diskinfo(drive #)
X	call	EXT(prot_to_real)	# enter real mode
X
X	movb	$0x8, %ah		# ask for disk info
X
X	sti
X	int	$0x13
X	cli
X
X	data16
X	call	EXT(real_to_prot)	# back to protected mode
X
X	xor	%eax, %eax
X
X#	form a longword representing all this gunk
X	movb	%dh, %ah		# # heads
X	andb	$0x3f, %cl		# mask of cylinder gunk
X	movb	%cl, %al		# # sectors
X
X	pop	%edx
X	pop	%ecx
X	pop	%ebx
X	pop	%es
X	pop	%ebp
X	ret
X
X#
X# memsize(i) :  return the memory size in KB. i == 0 for conventional memory,
X#		i == 1 for extended memory
X#	BIOS call "INT 12H" to get conventional memory size
X#	BIOS call "INT 15H, AH=88H" to get extended memory size
X#		Both have the return value in AX.
X#
X
XENTRY(memsize)
X	push	%ebp
X	mov	%esp, %ebp
X	push	%ebx
X
X	mov	8(%ebp), %ebx
X
X	call	EXT(prot_to_real)		# enter real mode
X
X	cmpb	$0x1, %bl
X	data16
X	je	xext
X	
X	sti
X	int	$0x12
X	cli
X	data16
X	jmp	xdone
X
Xxext:	movb	$0x88, %ah
X	sti
X	int	$0x15
X	cli
X
Xxdone:
X	mov	%eax, %ebx
X
X	data16
X	call	EXT(real_to_prot)
X
X	mov	%ebx, %eax
X	pop	%ebx
X	pop	%ebp
X	ret
END-of-i386/boot/bios.s
echo x - i386/boot/asm.s
sed 's/^X//' >i386/boot/asm.s << 'END-of-i386/boot/asm.s'
X/*
X * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
X *
X * Mach Operating System
X * Copyright (c) 1992, 1991 Carnegie Mellon University
X * All Rights Reserved.
X * 
X * Permission to use, copy, modify and distribute this software and its
X * documentation is hereby granted, provided that both the copyright
X * notice and this permission notice appear in all copies of the
X * software, derivative works or modified versions, and any portions
X * thereof, and that both notices appear in supporting documentation.
X * 
X * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
X * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
X * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
X * 
X * Carnegie Mellon requests users of this software to return to
X * 
X *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
X *  School of Computer Science
X *  Carnegie Mellon University
X *  Pittsburgh PA 15213-3890
X * 
X * any improvements or extensions that they make and grant Carnegie Mellon
X * the rights to redistribute these changes.
X */
X
X/*
X * HISTORY
X * $Log:	asm.s,v $
X * Revision 2.2  92/04/04  11:34:13  rpd
X * 	Fix Intel Copyright as per B. Davies authorization.
X * 	[92/04/03            rvb]
X * 	From 2.5 boot: pruned inb(), outb(), and pzero().
X * 	[92/03/30            rvb]
X * 
X * Revision 2.2  91/04/02  14:35:10  mbj
X * 	Added _sp() => where is the stack at. [kupfer]
X * 	Add Intel copyright
X * 	[90/02/09            rvb]
X * 
X */
X
X/*
X  Copyright 1988, 1989, 1990, 1991, 1992 
X   by Intel Corporation, Santa Clara, California.
X
X                All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and
Xits documentation for any purpose and without fee is hereby
Xgranted, provided that the above copyright notice appears in all
Xcopies and that both the copyright notice and this permission notice
Xappear in supporting documentation, and that the name of Intel
Xnot be used in advertising or publicity pertaining to distribution
Xof the software without specific, written prior permission.
X
XINTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
XINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
XIN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
XCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
XLOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
XNEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
XWITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X*/
X
X	.file "asm.s"
X
X#include "asm.h"
X
X
XCR0_PE_ON	=	0x1
XCR0_PE_OFF	=	0xfffffffe
X
X.globl	_ouraddr
X	.text
X
X#
X# real_to_prot()
X# 	transfer from real mode to protected mode.
X#
X
XENTRY(real_to_prot)
X	# guarantee that interrupt is disabled when in prot mode
X	cli
X
X	# load the gdtr
X	addr16
X	data32
X	lgdt	EXT(Gdtr)
X
X	# set the PE bit of CR0
X	mov	%cr0, %eax
X
X	data32
X	or	$CR0_PE_ON, %eax
X	mov	%eax, %cr0 
X
X	# make intrasegment jump to flush the processor pipeline and
X	# reload CS register
X	data32
X	ljmp	$0x18, $xprot
X
Xxprot:
X	# we are in USE32 mode now
X	# set up the protective mode segment registers : DS, SS, ES
X	mov	$0x20, %eax
X	movw	%ax, %ds
X	movw	%ax, %ss
X	movw	%ax, %es
X
X	ret
X
X#
X# prot_to_real()
X# 	transfer from protected mode to real mode
X# 
X
XENTRY(prot_to_real)
X
X	# set up a dummy stack frame for the second seg change.
X	movl 	_ouraddr, %eax
X	sarl	$4, %eax
X	pushw	%ax
X	pushw	$xreal
X
X	# Change to use16 mode.
X	ljmp	$0x28, $x16
X
Xx16:
X	# clear the PE bit of CR0
X	mov	%cr0, %eax
X	data32
X	and 	$CR0_PE_OFF, %eax
X	mov	%eax, %cr0
X
X
X	# make intersegment jmp to flush the processor pipeline
X	# using the fake stack frame set up earlier
X	# and reload CS register
X	lret
X
X
Xxreal:
X	# we are in real mode now
X	# set up the real mode segment registers : DS, SS, ES
X	movw	%cs, %ax
X	movw	%ax, %ds
X	movw	%ax, %ss
X	movw	%ax, %es
X
X	data32
X	ret
X
X#
X# startprog(phyaddr)
X#	start the program on protected mode where phyaddr is the entry point
X#
X
XENTRY(startprog)
X	push	%ebp
X	mov	%esp, %ebp
X
X
X
X	# get things we need into registers
X	movl	0x8(%ebp), %ecx		# entry offset 
X	movl	0x0c(%ebp), %eax	# &argv
X
X	# make a new stack at 0:0xa0000 (big segs)
X	mov	$0x10, %ebx
X	movw	%bx, %ss
X	movl	$0xa0000,%ebx
X	movl	%ebx,%esp
X	
X	
X	# push some number of args onto the stack
X	pushl	$0			# nominally a cyl offset in the boot.
X	pushl	0x8(%eax)		# argv[2] = bootdev
X	pushl	0x4(%eax)		# argv[1] = howto
X	pushl	$0			# dummy 'return' address
X	
X	# push on our entry address
X	mov	$0x08, %ebx		# segment
X	pushl	%ebx
X	pushl	%ecx
X
X	# convert over the other data segs
X	mov	$0x10, %ebx
X	movw	%bx, %ds
X	movw	%bx, %es
X
X	# convert the PC (and code seg)
X	lret
X#
X# pbzero( dst, cnt)
X#	where src is a virtual address and dst is a physical address
X#
X
XENTRY(pbzero)
X	push	%ebp
X	mov	%esp, %ebp
X	push	%es
X	push	%esi
X	push	%edi
X	push	%ecx
X
X	cld
X
X	# set %es to point at the flat segment
X	mov	$0x10, %eax
X	movw	%ax, %es
X
X	mov	0x8(%ebp), %edi		# destination
X	mov	0xc(%ebp), %ecx		# count
X	mov	$0x0,%eax		# value
X
X	rep
X	stosb
X
X	pop	%ecx
X	pop	%edi
X	pop	%esi
X	pop	%es
X	pop	%ebp
X
X	ret
X#
X# pcpy(src, dst, cnt)
X#	where src is a virtual address and dst is a physical address
X#
X
XENTRY(pcpy)
X	push	%ebp
X	mov	%esp, %ebp
X	push	%es
X	push	%esi
X	push	%edi
X	push	%ecx
X
X	cld
X
X	# set %es to point at the flat segment
X	mov	$0x10, %eax
X	movw	%ax, %es
X
X	mov	0x8(%ebp), %esi		# source
X	mov	0xc(%ebp), %edi		# destination
X	mov	0x10(%ebp), %ecx	# count
X
X	rep
X	movsb
X
X	pop	%ecx
X	pop	%edi
X	pop	%esi
X	pop	%es
X	pop	%ebp
X
X	ret
X
END-of-i386/boot/asm.s
echo x - i386/boot/README.MACH
sed 's/^X//' >i386/boot/README.MACH << 'END-of-i386/boot/README.MACH'
X/*
X * Ported to boot 386BSD by Julian Elischer, September 1992
X *
X * Mach Operating System
X * Copyright (c) 1992, 1991 Carnegie Mellon University
X * All Rights Reserved.
X * 
X * Permission to use, copy, modify and distribute this software and its
X * documentation is hereby granted, provided that both the copyright
X * notice and this permission notice appear in all copies of the
X * software, derivative works or modified versions, and any portions
X * thereof, and that both notices appear in supporting documentation.
X * 
X * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
X * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
X * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
X * 
X * Carnegie Mellon requests users of this software to return to
X * 
X *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
X *  School of Computer Science
X *  Carnegie Mellon University
X *  Pittsburgh PA 15213-3890
X * 
X * any improvements or extensions that they make and grant Carnegie Mellon
X * the rights to redistribute these changes.
X */
X
X/*
X * HISTORY
X * $Log:	README,v $
X * Revision 2.2  92/04/04  11:33:55  rpd
X * 	From 2.5
X * 	[92/03/30            mg32]
X * 
X */
X
X********NOTE: This is not all relevant to the 386BSD version**********
X
X		AT386 Protected Mode Bootstrap Loader
X		=====================================
X
X1. Overview of Startup
X   -------------------
X
X	After the system is rebooted, the BIOS bootstrap routine reads Sector
X	1, Track 0 into memory at location 0000:7C00H.  If location 0000:7DFEH
X	(last two bytes of that sector) contains the value AA55H, the BIOS
X	bootstrap routine will transfer control to 0000:7C00H.  Otherwise, the
X	boot code in that sector is bad and the boot routine stops.
X	
X	For DOS compatibility reason, one extra stage of boot is required if
X	the boot device is a hard disk.  The first sector of the hard disk will
X	contain the MOS-DOS boot code and a boot record partition table.
X	When this sector is loaded into 0000:7C00H, it will relocate itself
X	to somewhere else and then load the first sector of the active
X	partition into 0000:7C00H.  Both UNIX and DOS use the command "fdisk"
X[ 386bsd does not have an 'fdisk' (yet) ]
X	to install this first sector into the hard disk and to manipulate
X	the hard disk partitions.
X
X	
X
X2. The First Stage Bootstrap Loader
X   --------------------------------
X
X	After startup, the first stage boot is loaded at 0000:7C00H.  This
X	first stage boot will load itself and the second stage boot into
X	memory at location 0000:1000H.  For floppy disks, the first cylinder
X	is reserved as the boot cylinder, and the boot code (first and second)
X	will be loaded from there.  Currently, only double sided, high density
X	(15 sectors per track) floppies are supported.  For hard disks, the
X	first 29 sectors of the active partition is reserved for boot code
X	which will be loaded by the first stage boot.  All the disk types
X	recognized by BIOS are supported by this bootstrap loader. 
X[for 386bsd we load the second stage booter to 9000:0]
X
X
X
X3. The Second Stage Bootstrap Loader
X   --------------------------------
X
X	After the boot code is loaded, the control is passed to the second
X	stage bootstrap loader "boot2()".  In order to be able to load the
X	big kernel image (bigger than 512K or 640K, depends on the memory
X	configuration), the second stage boot loader will run on the protected
X	mode.  This bootstarp loader does not have any stand alone device
X	drivers, all the I/O's are through the BIOS calls.  Since the first
X	stage boot code will no longer be used at this moment, the memory
X	location of the first stage boot code (0000:1000H to 0000:1200H) will
X	be used as an internal buffer for BIOS calls.  Immediately after this 
X	internal buffer is the GDT table for the second stage boot loader. 
X	Since this boot loader needs to switch back and forth between protected
X	and real mode in order to use BIOS calls, the limit of the boot code
X	and boot data segments must not be greater than 64K.
X	
X	The boot loader loads the kernel image at memory location above 1 MB
X	to skip the memory hole between 521K/640K and 1MB.  After the kernel
X	is loaded, the boot loader stores the information in the stack and
X	then passes control to kernel.  Currently, the three information passed
X	fromm the boot loader to the kernel are type of the boot device, size
X	of the base memory and size of the extended memory.
X
X[ 386bsd receives: howto, bootdev]
X
X[ 386bsd is loaded where-ever the "MByte" bits of the load address specify,
Xso if you link it for FE100000 it will load to 1MB, but if you link
Xit for FE000000 it will load ad 0MB]
X
X[for machines with only 512KB normal ram the kernel will need to  be linked
Xfor 1MB and the bootblocks modified to run below 512KB. (8000:0)]
X
X
X4. The UNIX Startup
X   ----------------
X
X	Since the boot loader loads the kernel image at memory location above
X	1MB, the kernel has to start as protected mode.  In addition, the
X	link editor description file (vuifile) has to indicate that
X	the text and data segments start above 1MB.  Also, the boot loader
X	passes the infomation to the kernel through the stack.
X
X[MOST of what is mentionned below is NOT relevant to 386bsd]
X
X5. Disk Layout and Bad Block Handling
X   ---------------------------------
X	
X    The System V/386 Release 3.2 (AT) disk layout will be used as the disk
X    layout for the MACH System on the AT platform.
X
X    This disk layout is as follows:
X
X	* Reserve the first sector of cylinder 0 for the DOS boot record which
X	  contains the master boot code (446 bytes) and the partition table.
X	  (Refer to DOS Technical Reference Manual page 9-6 to 9-10).
X
X	* Reserve the first 29 sectors of the UNIX partition for the first
X	  and the second stage bootstrap.
X
X	* Reserve the 30th sector of the UNIX partition for the pdinfo and
X	  the vtoc tables.
X
X	* Reserve the 31st to the 34th sectors of the UNIX partition for the
X	  bad track and the bad block mapping tables.
X
X	* Reserve up to 253 consecutive tracks when required, beginning with
X	  the 35th sector of the UNIX partition, for alternate tracks.
X
X	* Reserve up to 253 consecutive blocks, beginning with the first
X	  sector after the alternate tracks area, for alternate blocks.
X
X	 SEC
X	  1
X	----------------------------------------------------
X	| X |                                              | CYL 0, TRK 0
X	----------------  ..........    --------------------
X	|                 ..........                       |
X	----------------  ..........    --------------------
X	|                 ..........                       |
X   ===============================================================
X    ^   |               BOOTSTRAP                          | CYL N, TRK M
X    |   ----------------------------------------------------
X    |   |                              |30 |31 |32 |33 |34 |
X	----------------------------------------------------  ---
X    U   |                 ..........                       |   ^
X    N   ----------------  ..........   ---------------------   |
X    I   |                 ..........                       | Alternate Tracks
X    X   ----------------  ..........   ---------------------   |
X        |                 ..........                       |   V
X    P   ----------------------------------------------------  --- 
X    A   |                 ..........                       |   ^
X    R   ----------------  ..........   ---------------------   |
X    T   |                 ..........                       | Alternate Blocks
X    I   ----------------  ..........   --------------------    |
X    T   |                 ..........                       |   V
X    I   ----------------------------------------------------  ---
X    O   |  Unix root partition starts from here            |
X    N   ----------------                   -----------------
X  	|                                                  |
X        ----------------------------------------------------
X        |                                                  |
X	----------------------------------------------------
X	|                                                  |
X    |   ---------------------------------------------------
X    |   |                                                  |
X    |   ----------------------------------------------------
X    V   |                                                  |
X   ===============================================================
X  	|                   ........                       |
X	---------------     ........          --------------
X	|                   ........                       |
X	----------------------------------------------------
X
X
X	The bad block handling mechanism is as follows:
X
X	* Use the alternate track in the alternate tracks area if the
X	  track containing the target sector is bad.
X
X	* Use the alternate block in the alternate blocks area if the
X	  target sector is bad.
X
X
X
X
X6. How to make:
X   -----------
X
X	Since the kernel image is loaded above 1 MB, the kernel must start
X	as protected mode.  This means that this bootstrap loader will work
X	only when the corresponding changes on the kernel startup code are done.
X
X	The make command to generate this bootstrap loader is:
X
X	make -f boot.mk fdboot      (floppy boot loader)
X	make -f boot.mk hdboot      (wini boot loader)
X[to make 386bsd bootblocks  "make sd wd" (warning: they will be installed
Xin /dev/mdec.. take backups)]
END-of-i386/boot/README.MACH
echo x - i386/boot/README.386BSD
sed 's/^X//' >i386/boot/README.386BSD << 'END-of-i386/boot/README.386BSD'
XThis Boot code is different from the original boot code that came with
X386BSD in that it uses the BIOS to load the kernel and to provide all i/o
Xservices. The advantage ofthis is that the same boot code exactly, can run
Xon any device that is supported by the BIOS. (That's most of them)
XThis is important for the 'generic scsi' project because it means we can
Xwrite drivers for new scsi adapters without having to develop an new
Xset of boot blocks for each.
X
XAt this point you should read the first part of README.MACH... come back here
Xwhen you have done that:
X
XIn normal operation, when co-existing with other operating systems, the
Xfollowing operations occur:
X
X1/ the BIOS loads the first block of the disk (called the Master Boot Record
Xor MBR) and if it has the correct magic numbers, jumps into it:
X
X2/ The  MBR code, looks at the Partition table that is embedded within it,
Xto detirmine which is the partition to boot from. If you are using the os-bs
Xbootblocks (highly recommended) then it will give you a menu to choose from.
X
X3/ The MBR will load  the first record of the selected partition and
Xif it has (the same) magic numbers, jumps into it. In 386bsd this is the
Xfirst stage boot, (or boot1) it is represented in /usr/mdec by
Xwdboot, asboot and sdboot. If the disk has been set up without DOS partitioning
Xthen this block will be at block zero, and will have been loaded directly by
Xthe BIOS.
X
X4/ Boot1 will look at block0 (which might be itself if there are no DOS
Xpartitions) and will find the 386bsd partition, and using the information
Xregarding the start position of that partition, will load the next 13 sectors
Xor so, to around 90000 (640k - 64k). and will jump into it at the appropriate
Xentry point. Since boot1 and boot2 were compiled together as one file
Xand then split later, boot1 knows the exact position within boot2 of the
Xentry point.
X
XBoot 1 also contains a compiled in DOS partition table
X(in case it is at block 0), which contains a 386bsd partition starting
Xat 0. This ensures that the same code can work whether or not
Xboot1 is at block 0.
X
X5/ Boot2 asks the user for a boot device, partition and filename, and then
Xloads the MBR of the selected device. This may or may not be the device
Xwhich was originally used to boot the first MBR. The partition table
Xof the new MBR is searched for a 386bsd partition, and if one is found,
Xthat is then in turn searched for the disklabel. This could all be on the
Xsecond disk at this point, if the user selected it.
X
X6/On finding the disklabel, boot2 can find the correct unix partition
Xwithin the 386bsd partition, and using cutdown filesystem code,
Xlook for the file to boot (e.g. 386bsd).
X
X7/ Boot2 loads this file starting at the location specified by the a.out header,
X(see later) and leaps into it at the location specified in he header.
X
Xif the file does not exist or cannot be loaded, boot2 goes back to  step 5.
X
X386bsd is now running and will hopefully start vm etc. and get to multi-user
Xmode.
X
X##########################################################################
XDuring all these steps, all i/o is performed using the BIOS. This has a number
Xof side effects:
X
X1/ Since BIOS disk calls are specified in terms of cylinder,head and sector,
Xand the BIOS read the disk information from either the CMOS or from some other
Xlocation which is un-available to us, we must use the cyl,head,sec information
Xthat is given in the MBR, rather than the start address in the MBR, because
Xwe cannot guarentee that we can corectly calculate C,H,S from the start address.
X
XTherefore, the C,H,S information in the MBR must be as correct for this boot
Xto work as it would be for DOS to boot. For example, adaptec BIOS routines
Xassume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder.
XYou must use these figures to calculate the correct values. Luckily, the DOS
Xfdisk program will do all this for you if you tell it to give you a DOS
Xpartition, and you can change it to a 386BSD partition later. If you use 
Xno DOS partitioning, then the compiled in table in Boot1 will do just fine.
X
XIf you want to do it by hand remember that BIOS counts sectors starting at 1.
X(cylinders and heads start at 0  (??))
X
X2/ you cannot overwrite the bottom 4k of ram until you have finished ALL
Xbios calls, as BIOS uses this area as scratch memory.
X
X3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode,
XBoot 2 switches back to real mode just before each BIOS call and then
Xback to protected mode on each return. Touch this at your peril.!
X
X#########################################################################
XIn answering the prompt from Boot2:
Xyou can, 
X1/ leave it alone.. it will boot the indicated file from the first 
Xpartition of the first drive seen by the BIOS (C:)
X
X2/ enter only "-s" to boot the default to single user mode
X
X3/ enter only a filename (optionally with -s) to boot that kernel,
X
X4/ enter a whole line of the form shown in the prompt. This allows you to
Xboot some other partition, possibly on the second drive, as root.
X
X
X##########################################################################
XIn the case you have two drives the same type (both scsi or bith IDE/ESDI),
Xwd(0,a)xxx
X	will boot xxx from drive 0, a partition.
Xwd(1,a)xxx
X	will boot xxx from drive 1, a partition.
X
Xsimilarly for sd.
X
Xif you have one wd drive and one scsi drive, then you MUST
Xuse device 'hd'
X
Xotherwise the following will happen:
X
Xwith wd0 and sd0, you specify sd1 or wd1 to indicate the 2nd drive.
Xit boots the kernel correctly, then tells the kernel to use sd1 as root.
Xyou however may not have an sd1, and problems arise.
X
Xhd is special in that the kernel is always told to use unit 0,
XThe correct TYPE of device will be specified too, so the kernel
Xwill be told either sd0 or wd0.
X
XWhether sd or wd is specified to the kernel is read from the disklabel,
Xso ensure that all SCSI disks have type SCSI in their disklabel or the
Xboot code will assume they are ESDI or IDE. (Remember, because it is
Xworking through the BIOS it has ho idea what kind of disk it is.
X
X##########################################################################
XInstalling:
XThe makefile supplied has a target install which will create the
Xfiles wdboot,bootwd ,sdboot and bootsd in /usr/mdec.
XBEWARE these will overwrite the existing wdboot and bootwd. (so back
Xthem up)
X
Xthere are also targets wd and sd which wil only do one of them
X
XThe commented out targets wd0 and sd0 are examples of how to 
Xload the new bootblocks, however,make sure you change the 
Xdevice type and label to suit your drive if you uncomment them.
X(see 'man disklabel')
X
XIf you already have made partitions using the old bootblocks
Xthese should install painlessly.
X
XBefore you do this ensure you have a booting floppy with correct
Xdisktab and bootblock files on it so that if it doesn't work, you can
Xre-disklabel from the floppy.
END-of-i386/boot/README.386BSD
echo x - i386/boot/Makefile
sed 's/^X//' >i386/boot/Makefile << 'END-of-i386/boot/Makefile'
X#
X# Ported to boot 386BSD by Julian Elischer (julian@tfs.com)
X# September 1992
X#
X# Permission to use, copy, modify and distribute this software and its
X# documentation is hereby granted, provided that both the copyright
X# notice and this permission notice appear in all copies of the
X# software, derivative works or modified versions, and any portions
X# thereof, and that both notices appear in supporting documentation.
X#
X# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
X# CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
X# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
X#
X# Carnegie Mellon requests users of this software to return to
X#
X#  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
X#  School of Computer Science
X#  Carnegie Mellon University
X#  Pittsburgh PA 15213-3890
X#
X# any improvements or extensions that they make and grant Carnegie Mellon
X# the rights to redistribute these changes.
X#
X#
X# HISTORY
X# $Log: Makefile,v $
X# Revision 2.2	92/04/04  11:33:46  rpd
X#	Fabricated for MACH 3.0
X#	[92/03/30	     mg32]
X#
X# Thu Sep 10 22:40:23 PDT 1992
X# Ported to 386BSD by Julian Elischer
X# julian@tfs.com
X#
X
XCFLAGS	= -O
XLIBS= -lc
XINC= -I../..
X
X# start.o should be first, table.o should be second
XOBJS = start.o table.o boot2.o boot.o asm.o bios.o io.o disk.o sys.o
X
X.SUFFIXES: .s .c .o
X
X# These are wierd because we don't want separate code and data segments.. ok?
X.c.o:
X	@echo $(CC) -c $(CFLAGS) $(INC) $*.c
X	-@trap "/bin/rm -f $*.i $*.s; exit 0" 0 1 2 3 10 15; \
X	$(CC)  $(CFLAGS) $(INC) -S $<;	\
X	if [ $$? != 0 ]; then :; else \
X		sed -f boot.sed $*.s > $*.i;	\
X		$(AS) $*.i -o $@; \
X	fi
X
X.s.o:
X	@echo $(AS) -o $*.o $<
X	-@trap "/bin/rm -f $*.i X$*.c; exit 0" 0 1 2 3 10 15; \
X	/bin/rm -f X$*.c;	\
X	ln $*.s X$*.c;	\
X	$(CC) -E $(CFLAGS) X$*.c > $*.i;	\
X	if [ $$? != 0 ]; then :;	\
X	else \
X		$(AS) $*.i -o $@;	\
X	fi
X
X
Xboot: boot.sed $(OBJS)
X	$(LD) -N -T 0 -o boot $(OBJS) $(LIBS)
X	cp boot boot.sym
X	@strip boot
X	@./rmaouthdr boot boot.tmp
X	@mv -f boot.tmp boot
X	@ls -l boot
X
Xbiosboot:	boot
X	dd if=boot of=biosboot count=1
X
Xbootbios:	boot
X	dd if=boot of=bootbios skip=1
X
X/usr/mdec/bootsd:	bootbios
X	cp bootbios /usr/mdec/bootsd
X
X/usr/mdec/bootwd:	bootbios
X	cp bootbios /usr/mdec/bootwd
X
X/usr/mdec/sdboot:	biosboot
X	cp biosboot /usr/mdec/sdboot
X
X/usr/mdec/wdboot:	biosboot
X	cp biosboot /usr/mdec/wdboot
X
Xwd:	/usr/mdec/bootwd /usr/mdec/wdboot
X
X#wd0:	/usr/mdec/bootwd /usr/mdec/wdboot
X#	disklabel -r -w wd0 julian julian5 /usr/mdec/wdboot /usr/mdec/bootwd
X#
Xsd:	/usr/mdec/bootsd /usr/mdec/sdboot
X
X#sd0:	/usr/mdec/bootsd /usr/mdec/sdboot
X#	disklabel -r -w sd0 XT-8760 scsitest /usr/mdec/sdboot /usr/mdec/bootsd
X#
X
Xinstall: wd sd
X
Xclean:
X	/bin/rm -f *.o *.d boot bootbios biosboot boot.sym
X
X
END-of-i386/boot/Makefile
exit