3 changes:

1/ Makefile:  the maximum size for boot2 is 7.5K not 7K,
so don't complain until it reaches THAT size..
newfs leaves 8K and boot 1 is 512k. leaving 7.5K becasue the disklabel
is considered to part of the boot2 file.

[512  boot1][512 disklabel][     7K boot2 code        ]
[boot1 file][               boot2 file                ]

2/ Boot2.S: move the soring of the default name read from block 2 to AFTER
clearing the BSS.

3/ boot.c:
Move the parsing of the command line into the
place it's called for clarity.. alsoi comment it a bit and clean it
up a bit.. for some reason this seems ot have made it a little
larger, but I can't work out why.. maybe bruce might have ideas?
compensated for by shrinkage elsewhere..

the practical result of this is htat the default string can now contain args
e.g. if you change the default string to have -gd
then the machine will boot to the dgb debugger stub by default..
this is mostly useful with the nextboot utility..
as it now allows you to remotely force a machine to reboot into
the debugger.
This commit is contained in:
Julian Elischer
1996-09-04 18:28:36 +00:00
parent 30cb1d45ae
commit bf709d2564
3 changed files with 92 additions and 82 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
# $Id: Makefile,v 1.41 1996/07/09 02:28:15 julian Exp $
# $Id: Makefile,v 1.42 1996/07/12 05:17:36 bde Exp $
#
PROG= boot
@@ -75,7 +75,7 @@ boot1: boot.nohdr
boot2: boot.nohdr
dd if=boot.nohdr of=boot2 bs=512 skip=1
@dd if=boot2 skip=14 of=sizetest 2> /dev/null
@dd if=boot2 skip=15 of=sizetest 2> /dev/null
@if [ -s sizetest ] ; then \
echo "*** Boot2 is too BIG ***" ; exit 2 ; \
fi
+85 -74
View File
@@ -24,7 +24,7 @@
* the rights to redistribute these changes.
*
* from: Mach, [92/04/03 16:51:14 rvb]
* $Id: boot.c,v 1.54 1996/08/27 19:45:37 pst Exp $
* $Id: boot.c,v 1.55 1996/08/28 18:29:51 ache Exp $
*/
@@ -62,33 +62,36 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define NAMEBUF_LEN (8*1024)
#ifdef NAMEBLOCK
char *dflt_name;
char *dflt_name ;
/*char *dflt_name = (char *)0x0000ffb0; */ /* force it to not be in the BSS */
#endif
char namebuf[NAMEBUF_LEN];
struct exec head;
struct bootinfo bootinfo;
int loadflags;
static void getbootdev(char *ptr, int *howto);
static void loadprog(void);
/* NORETURN */
void
boot(int drive)
{
char *ptr;
int howto;
char c;
int ret;
#ifdef PROBE_KEYBOARD
if (probe_keyboard()) {
init_serial();
loadflags |= RB_SERIAL;
loadflags = RB_SERIAL;
printf("\nNo keyboard found.");
}
#endif
#ifdef FORCE_COMCONSOLE
init_serial();
loadflags |= RB_SERIAL;
loadflags = RB_SERIAL;
printf("\nSerial console forced.");
#endif
@@ -131,17 +134,15 @@ boot(int drive)
}
#ifdef NAMEBLOCK
/*
* XXX
* DAMN! I don't understand why this is not being set
* by the code in boot2.S
* this is set by the code in boot2.S
*/
dflt_name= (char *)0x0000ffb0;
if( (*dflt_name++ == 'D') && (*dflt_name++ == 'N')) {
name = dflt_name;
strcpy(namebuf,dflt_name);
} else
#endif /*NAMEBLOCK*/
loadstart:
name = dflname; /* re-initialize in case of loop */
strcpy(namebuf,dflname);/* re-initialize in case of loop */
name = dflname; /* XXX check if needed */
/* print this all each time.. (saves space to do so) */
/* If we have looped, use the previous entries as defaults */
printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n"
@@ -151,17 +152,85 @@ boot(int drive)
ouraddr, bootinfo.bi_basemem, bootinfo.bi_extmem,
dosdev & 0x7f, devs[maj], unit, name);
loadflags &= RB_SERIAL; /* clear all, but leave serial console */
getbootdev(namebuf, &loadflags);
/*
* Be paranoid and make doubly sure that the input buffer is empty.
*/
if(howto = (loadflags &= RB_SERIAL))
init_serial(); /* clear all, but leave serial console */
if (!gets(namebuf)) {
putchar('\n');
}
ptr = namebuf;
/*
* now parse out the boot options from what was given to us
* (or was read from the default string)
*/
while ((c = *ptr) != '\0') {
/*
* pass any leading (or inter-arg) spaces
*/
if (c == ' ') {
ptr++;
continue;
}
/*
* If it's an arg, take as many letters as we can
*/
if (c == '-') {
while ((c = *++ptr) != '\0') {
if (c == ' ')
break;
if (c == 'C')
howto |= RB_CDROM;
if (c == 'a')
howto |= RB_ASKNAME;
if (c == 'b')
howto |= RB_HALT;
if (c == 'c')
howto |= RB_CONFIG;
if (c == 'd')
howto |= RB_KDB;
if (c == 'h') {
howto ^= RB_SERIAL;
if (howto & RB_SERIAL)
init_serial();
}
if (c == 'g')
howto |= RB_GDB;
if (c == 'r')
howto |= RB_DFLTROOT;
if (c == 's')
howto |= RB_SINGLE;
if (c == 'v')
howto |= RB_VERBOSE;
}
continue;
}
/*
* we have struck something that's not an arg,
* nor a space.
* break it off into a separate string.. "name"
* The default string will at least hit this..
*/
name = ptr;
while (*++ptr != '\0') {
if (*ptr == ' ') {
*ptr++ = '\0';
break;
}
}
}
loadflags = howto;
/*
* Now use "name" to try open the device and file for reading
*/
ret = openrd();
if (ret != 0) {
if (ret > 0)
printf("Can't find %s\n", name);
goto loadstart;
}
/* if (inode.i_mode&IEXEC)
loadflags |= RB_KDB;
*/
loadprog();
goto loadstart;
}
@@ -294,61 +363,3 @@ loadprog(void)
(int)&bootinfo + ouraddr);
}
void
getbootdev(char *ptr, int *howto)
{
char c;
/*
* Be paranoid and make doubly sure that the input buffer is empty.
*/
if (*howto & RB_SERIAL)
init_serial();
if (!gets(ptr)) {
putchar('\n');
return;
}
while ((c = *ptr) != '\0') {
nextarg:
while (c == ' ')
c = *++ptr;
if (c == '-')
while ((c = *++ptr) != '\0') {
if (c == ' ')
goto nextarg;
if (c == 'C')
*howto |= RB_CDROM;
if (c == 'a')
*howto |= RB_ASKNAME;
if (c == 'b')
*howto |= RB_HALT;
if (c == 'c')
*howto |= RB_CONFIG;
if (c == 'd')
*howto |= RB_KDB;
if (c == 'h') {
*howto ^= RB_SERIAL;
if (*howto & RB_SERIAL)
init_serial();
}
if (c == 'g')
*howto |= RB_GDB;
if (c == 'r')
*howto |= RB_DFLTROOT;
if (c == 's')
*howto |= RB_SINGLE;
if (c == 'v')
*howto |= RB_VERBOSE;
}
if (c == '\0')
return;
name = ptr;
while (*++ptr != '\0') {
if (*ptr == ' ') {
*ptr++ = '\0';
break;
}
}
}
}
+5 -6
View File
@@ -24,7 +24,7 @@
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:26 rpd
* $Id: boot2.S,v 1.7 1996/07/05 19:55:04 julian Exp $
* $Id: boot2.S,v 1.8 1996/07/12 05:25:46 bde Exp $
*/
#include "asm.h"
@@ -58,11 +58,6 @@ ENTRY(boot2)
mov %ax, %es
data32
shll $4, %eax
#ifdef NAMEBLOCK
addr32
data32
movl %esp, EXT(dflt_name)
#endif
/* fix up GDT entries for bootstrap */
#define FIXUP(gdt_index) \
@@ -170,6 +165,10 @@ ENTRY(boot2)
rep
stosb
#ifdef NAMEBLOCK
movl %esp, EXT(dflt_name)
#endif
movzbl %dl, %edx /* discard head (%dh) and random high bits */
pushl %edx
call EXT(boot)