Add an option to set bp_consaddr (serial console IO port address)
Only complain about small patch area if we would write something non-zero there.
This commit is contained in:
parent
84b11bd3be
commit
0b10fdb3b8
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: i386.c,v 1.16 2004/06/20 22:20:17 jmc Exp $ */
|
||||
/* $NetBSD: i386.c,v 1.17 2004/08/15 22:00:12 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(__lint)
|
||||
__RCSID("$NetBSD: i386.c,v 1.16 2004/06/20 22:20:17 jmc Exp $");
|
||||
__RCSID("$NetBSD: i386.c,v 1.17 2004/08/15 22:00:12 dsl Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -63,10 +63,11 @@ i386_setboot(ib_params *params)
|
|||
{
|
||||
int retval, i, bpbsize;
|
||||
uint8_t *bootstrapbuf;
|
||||
u_int bootstrapsize;
|
||||
uint bootstrapsize;
|
||||
ssize_t rv;
|
||||
uint32_t magic;
|
||||
struct x86_boot_params *bp;
|
||||
struct x86_boot_params bp, *bpp;
|
||||
int bplen;
|
||||
struct mbr_sector mbr;
|
||||
|
||||
assert(params != NULL);
|
||||
|
@ -182,21 +183,26 @@ i386_setboot(ib_params *params)
|
|||
|
||||
/*
|
||||
* Fill in any user-specified options into the
|
||||
* struct x86_boot_params
|
||||
* struct x86_boot_params
|
||||
* that's 8 bytes in from the start of the third sector.
|
||||
* See sys/arch/i386/stand/bootxx/bootxx.S for more information.
|
||||
*/
|
||||
bp = (void *)(bootstrapbuf + 512 * 2 + 8);
|
||||
if (le32toh(bp->bp_length) < sizeof *bp) {
|
||||
warnx("Patch area in stage1 bootstrap is too small");
|
||||
goto done;
|
||||
}
|
||||
bpp = (void *)(bootstrapbuf + 512 * 2 + 8);
|
||||
bplen = le32toh(bpp->bp_length);
|
||||
if (bplen > sizeof bp)
|
||||
/* Ignore pad space in bootxx */
|
||||
bplen = sizeof bp;
|
||||
/* Take (and update) local copy so we handle size mismatches */
|
||||
memset(&bp, 0, sizeof bp);
|
||||
memcpy(&bp, bpp, bplen);
|
||||
if (params->flags & IB_TIMEOUT)
|
||||
bp->bp_timeout = htole32(params->timeout);
|
||||
bp.bp_timeout = htole32(params->timeout);
|
||||
if (params->flags & IB_RESETVIDEO)
|
||||
bp->bp_flags |= htole32(X86_BP_FLAGS_RESET_VIDEO);
|
||||
bp.bp_flags |= htole32(X86_BP_FLAGS_RESET_VIDEO);
|
||||
if (params->flags & IB_CONSPEED)
|
||||
bp->bp_conspeed = htole32(params->conspeed);
|
||||
bp.bp_conspeed = htole32(params->conspeed);
|
||||
if (params->flags & IB_CONSADDR)
|
||||
bp.bp_consaddr = htole32(params->consaddr);
|
||||
if (params->flags & IB_CONSOLE) {
|
||||
static const char *names[] = {
|
||||
"pc", "com0", "com1", "com2", "com3",
|
||||
|
@ -214,17 +220,25 @@ i386_setboot(ib_params *params)
|
|||
if (strcmp(names[i], params->console) == 0)
|
||||
break;
|
||||
}
|
||||
bp->bp_consdev = htole32(i);
|
||||
bp.bp_consdev = htole32(i);
|
||||
}
|
||||
if (params->flags & IB_PASSWORD) {
|
||||
MD5_CTX md5ctx;
|
||||
MD5Init(&md5ctx);
|
||||
MD5Update(&md5ctx, params->password, strlen(params->password));
|
||||
MD5Final(bp->bp_password, &md5ctx);
|
||||
bp->bp_flags |= htole32(X86_BP_FLAGS_PASSWORD);
|
||||
MD5Final(bp.bp_password, &md5ctx);
|
||||
bp.bp_flags |= htole32(X86_BP_FLAGS_PASSWORD);
|
||||
}
|
||||
if (params->flags & IB_KEYMAP)
|
||||
strlcpy(bp->bp_keymap, params->keymap, sizeof bp->bp_keymap);
|
||||
strlcpy(bp.bp_keymap, params->keymap, sizeof bp.bp_keymap);
|
||||
/* Check we aren't trying to set anything we can't save */
|
||||
if (bplen < sizeof bp && memcmp((char *)&bp + bplen,
|
||||
(char *)&bp + bplen + 1,
|
||||
sizeof bp - bplen - 1) != 0) {
|
||||
warnx("Patch area in stage1 bootstrap is too small");
|
||||
goto done;
|
||||
}
|
||||
memcpy(bpp, &bp, bplen);
|
||||
|
||||
if (params->flags & IB_NOWRITE) {
|
||||
retval = 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: installboot.8,v 1.42 2004/06/25 15:08:45 wiz Exp $
|
||||
.\" $NetBSD: installboot.8,v 1.43 2004/08/15 22:00:12 dsl Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -252,6 +252,12 @@ Modify the default boot command line.
|
|||
Set the console device, \*[Lt]console name\*[Gt] must be one of:
|
||||
pc, com0, com1, com2, com3, com0kbd, com1kbd, com2kbd or com3kbd.
|
||||
.
|
||||
.It Sy ioaddr=\*[Lt]ioaddr\*[Gt]
|
||||
.Sy [ amd64 ,
|
||||
.Sy i386 ]
|
||||
Set the IO address to be used for the console serial port.
|
||||
Defaults to the IO address used by the system BIOS for the specified port.
|
||||
.
|
||||
.It Sy keymap=\*[Lt]keymap\*[Gt]
|
||||
.Sy [ amd64 ,
|
||||
.Sy i386 ]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: installboot.c,v 1.16 2004/06/20 22:20:17 jmc Exp $ */
|
||||
/* $NetBSD: installboot.c,v 1.17 2004/08/15 22:00:12 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: installboot.c,v 1.16 2004/06/20 22:20:17 jmc Exp $");
|
||||
__RCSID("$NetBSD: installboot.c,v 1.17 2004/08/15 22:00:12 dsl Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
@ -86,6 +86,7 @@ const struct option {
|
|||
{ "append", IB_APPEND, OPT_BOOL },
|
||||
{ "command", IB_COMMAND, OPT_STRING, OFFSET(command) },
|
||||
{ "console", IB_CONSOLE, OPT_WORD, OFFSET(console) },
|
||||
{ "ioaddr", IB_CONSADDR, OPT_INT, OFFSET(consaddr) },
|
||||
{ "keymap", IB_KEYMAP, OPT_WORD, OFFSET(keymap) },
|
||||
{ "password", IB_PASSWORD, OPT_WORD, OFFSET(password) },
|
||||
{ "resetvideo", IB_RESETVIDEO, OPT_BOOL },
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: installboot.h,v 1.24 2004/03/13 22:51:50 dsl Exp $ */
|
||||
/* $NetBSD: installboot.h,v 1.25 2004/08/15 22:00:12 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -69,6 +69,7 @@ typedef enum {
|
|||
IB_TIMEOUT = 1<<17, /* i386 boot timeout */
|
||||
IB_PASSWORD = 1<<18, /* i386 boot password */
|
||||
IB_KEYMAP = 1<<19, /* i386 console keymap */
|
||||
IB_CONSADDR = 1<<20, /* i386 console io address */
|
||||
} ib_flags;
|
||||
|
||||
typedef struct {
|
||||
|
@ -88,6 +89,7 @@ typedef struct {
|
|||
const char *command; /* name of command string */
|
||||
const char *console; /* name of console */
|
||||
int conspeed; /* console baud rate */
|
||||
int consaddr; /* console io address */
|
||||
const char *password; /* boot password */
|
||||
int timeout; /* interactive boot timeout */
|
||||
const char *keymap; /* keyboard translations */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machines.c,v 1.24 2004/06/20 22:20:17 jmc Exp $ */
|
||||
/* $NetBSD: machines.c,v 1.25 2004/08/15 22:00:12 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: machines.c,v 1.24 2004/06/20 22:20:17 jmc Exp $");
|
||||
__RCSID("$NetBSD: machines.c,v 1.25 2004/08/15 22:00:12 dsl Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -61,7 +61,7 @@ struct ib_mach machines[] = {
|
|||
IB_APPEND },
|
||||
#endif
|
||||
{ "i386", i386_setboot, no_clearboot,
|
||||
IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED |
|
||||
IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
|
||||
IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT },
|
||||
{ "macppc", macppc_setboot, macppc_clearboot,
|
||||
IB_STAGE2START },
|
||||
|
|
Loading…
Reference in New Issue