diff options
author | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2015-09-02 04:09:25 +0000 |
---|---|---|
committer | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2015-09-02 04:09:25 +0000 |
commit | 25c065e3fb0f3cf72fd4ccd77fbb5f3b9bf41e5d (patch) | |
tree | 9300d5f16470a49c31de5f3c54ae45f6c4b97b38 /sys | |
parent | 493c06b693cc5008b2512212aa374ee840d0a565 (diff) |
Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.
input and ok deraadt
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/stand/boot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/cdboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/exec_i386.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/stand/pxeboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/cdboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/cdboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/alloca.S | 49 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/biosdev.c | 17 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/biosdev.h | 5 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/cmd_i386.c | 20 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/disk.h | 9 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/diskprobe.c | 89 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/exec_i386.c | 25 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/machdep.c | 10 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/memprobe.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/softraid.c | 13 | ||||
-rw-r--r-- | sys/arch/i386/stand/pxeboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/pxeboot/conf.c | 4 |
21 files changed, 186 insertions, 106 deletions
diff --git a/sys/arch/amd64/stand/boot/conf.c b/sys/arch/amd64/stand/boot/conf.c index 492b6d209a8..85a8bd55428 100644 --- a/sys/arch/amd64/stand/boot/conf.c +++ b/sys/arch/amd64/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.31 2014/02/18 13:56:02 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.32 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -42,7 +42,7 @@ #include <biosdev.h> #include <dev/cons.h> -const char version[] = "3.28"; +const char version[] = "3.29"; int debug = 1; diff --git a/sys/arch/amd64/stand/cdboot/conf.c b/sys/arch/amd64/stand/cdboot/conf.c index 486e8e422a6..b554724b3a5 100644 --- a/sys/arch/amd64/stand/cdboot/conf.c +++ b/sys/arch/amd64/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.26 2014/02/18 13:56:02 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.27 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -43,7 +43,7 @@ #include <biosdev.h> #include <dev/cons.h> -const char version[] = "3.23"; +const char version[] = "3.24"; int debug = 1; diff --git a/sys/arch/amd64/stand/efiboot/conf.c b/sys/arch/amd64/stand/efiboot/conf.c index 58375ea564d..065fdeb1078 100644 --- a/sys/arch/amd64/stand/efiboot/conf.c +++ b/sys/arch/amd64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.1 2015/09/02 01:52:25 yasuoka Exp $ */ +/* $OpenBSD: conf.c,v 1.2 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -37,7 +37,7 @@ #include "efiboot.h" #include "efidev.h" -const char version[] = "3.28"; +const char version[] = "3.29"; #ifdef EFI_DEBUG int debug = 0; diff --git a/sys/arch/amd64/stand/libsa/exec_i386.c b/sys/arch/amd64/stand/libsa/exec_i386.c index c1ac421a05c..687e5435963 100644 --- a/sys/arch/amd64/stand/libsa/exec_i386.c +++ b/sys/arch/amd64/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.13 2015/09/02 01:52:26 yasuoka Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.14 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -120,7 +120,11 @@ run_loadfile(u_long *marks, int howto) * This code may be used both for 64bit and 32bit. Make sure the * bootarg is 32bit always on even on amd64. */ +#ifdef __amd64__ makebootargs32(av, &ac); +#else + makebootargs(av, &ac); +#endif entry = marks[MARK_ENTRY] & 0x0fffffff; diff --git a/sys/arch/amd64/stand/pxeboot/conf.c b/sys/arch/amd64/stand/pxeboot/conf.c index c0538790a0d..e1e1a3839dd 100644 --- a/sys/arch/amd64/stand/pxeboot/conf.c +++ b/sys/arch/amd64/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.30 2014/02/18 13:56:02 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.31 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -45,7 +45,7 @@ #include "pxeboot.h" #include "pxe_net.h" -const char version[] = "3.23"; +const char version[] = "3.24"; int debug = 0; #undef _TEST diff --git a/sys/arch/i386/stand/boot/Makefile b/sys/arch/i386/stand/boot/Makefile index e37b2a54d21..87ed7a81d1c 100644 --- a/sys/arch/i386/stand/boot/Makefile +++ b/sys/arch/i386/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.56 2014/07/13 09:26:08 jasper Exp $ +# $OpenBSD: Makefile,v 1.57 2015/09/02 04:09:24 yasuoka Exp $ COPTS?= MAN?= boot.8 @@ -33,7 +33,7 @@ SRCS+= boot.c bootarg.c cmd.c vars.c .PATH: ${SADIR}/libsa SRCS+= debug_i386.S -SRCS+= alloca.S gidt.S random_i386.S +SRCS+= gidt.S random_i386.S SRCS+= apmprobe.c debug.c pciprobe.c ps2probe.c SRCS+= cmd_i386.c dev_i386.c exec_i386.c gateA20.c machdep.c SRCS+= bioscons.c biosdev.c diskprobe.c memprobe.c time.c diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c index ad4531ae8c8..164887a5a2e 100644 --- a/sys/arch/i386/stand/boot/conf.c +++ b/sys/arch/i386/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.55 2014/02/18 13:56:02 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.56 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -43,7 +43,7 @@ #include <dev/cons.h> #include "debug.h" -const char version[] = "3.26"; +const char version[] = "3.27"; int debug = 1; diff --git a/sys/arch/i386/stand/cdboot/Makefile b/sys/arch/i386/stand/cdboot/Makefile index a25af88214f..6306887a728 100644 --- a/sys/arch/i386/stand/cdboot/Makefile +++ b/sys/arch/i386/stand/cdboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.23 2014/07/15 22:14:37 deraadt Exp $ +# $OpenBSD: Makefile,v 1.24 2015/09/02 04:09:24 yasuoka Exp $ MAN= cdboot.8 @@ -17,7 +17,7 @@ BINMODE=644 CLEANFILES+= crt0.o ${PROG}.whole .PATH: ${SADIR}/libsa -SRCS+= alloca.S debug_i386.S gidt.S random_i386.S +SRCS+= debug_i386.S gidt.S random_i386.S SRCS+= cmd_i386.c dev_i386.c exec_i386.c gateA20.c machdep.c SRCS+= apmprobe.c bioscons.c biosdev.c debug.c diskprobe.c memprobe.c \ pciprobe.c ps2probe.c time.c diff --git a/sys/arch/i386/stand/cdboot/conf.c b/sys/arch/i386/stand/cdboot/conf.c index fafd6619225..d188c1dd23e 100644 --- a/sys/arch/i386/stand/cdboot/conf.c +++ b/sys/arch/i386/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.24 2014/02/18 13:56:02 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.25 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -44,7 +44,7 @@ #include <dev/cons.h> #include "debug.h" -const char version[] = "3.23"; +const char version[] = "3.24"; int debug = 1; #undef _TEST diff --git a/sys/arch/i386/stand/libsa/alloca.S b/sys/arch/i386/stand/libsa/alloca.S index 13cd68c3918..e69de29bb2d 100644 --- a/sys/arch/i386/stand/libsa/alloca.S +++ b/sys/arch/i386/stand/libsa/alloca.S @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <machine/asm.h> - -/* like alloc, but automatic free in return */ - -ENTRY(alloca) - popl %edx /* pop return addr */ - popl %eax /* pop amount to allocate */ - movl %esp,%ecx - addl $3,%eax /* round up to next word */ - andl $-4,%eax - subl %eax,%esp - movl %esp,%eax /* base of newly allocated space */ - pushl 8(%ecx) /* copy possible saved registers */ - pushl 4(%ecx) - pushl 0(%ecx) - pushl %eax /* dummy to pop at callsite */ - jmp *%edx /* "return" */ diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c index 2e2911378fa..d7fa3745494 100644 --- a/sys/arch/i386/stand/libsa/biosdev.c +++ b/sys/arch/i386/stand/libsa/biosdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.c,v 1.89 2014/03/29 18:09:29 guenther Exp $ */ +/* $OpenBSD: biosdev.c,v 1.90 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -52,6 +52,7 @@ static int biosdisk_errno(u_int); int CHS_rw (int, int, int, int, int, int, void *); static int EDD_rw (int, int, u_int32_t, u_int32_t, void *); +static int biosd_io(int, bios_diskinfo_t *, u_int, int, void *); static u_int findopenbsd(bios_diskinfo_t *, const char **); extern int debug; @@ -246,7 +247,7 @@ biosd_io(int rw, bios_diskinfo_t *bd, u_int off, int nsect, void *buf) { int dev = bd->bios_number; int j, error; - void *bb; + void *bb, *bb1 = NULL; int bbsize = nsect * DEV_BSIZE; if (bd->flags & BDI_EL_TORITO) { /* It's a CD device */ @@ -273,7 +274,7 @@ biosd_io(int rw, bios_diskinfo_t *bd, u_int off, int nsect, void *buf) * XXX we believe that all the io is buffered * by fs routines, so no big reads anyway */ - bb = alloca(bbsize); + bb = bb1 = alloc(bbsize); if (rw != F_READ) bcopy(buf, bb, bbsize); } else @@ -327,6 +328,8 @@ biosd_io(int rw, bios_diskinfo_t *bd, u_int off, int nsect, void *buf) if (bb != buf && rw == F_READ) bcopy(bb, buf, bbsize); + if (bb1 != NULL) + free(bb1, bbsize); #ifdef BIOS_DEBUG if (debug) { @@ -339,6 +342,11 @@ biosd_io(int rw, bios_diskinfo_t *bd, u_int off, int nsect, void *buf) return error; } +int +biosd_diskio(int rw, struct diskinfo *dip, u_int off, int nsect, void *buf) +{ + return biosd_io(rw, &dip->bios_info, off, nsect, buf); +} /* * Try to read the bsd label on the given BIOS device. */ @@ -417,7 +425,7 @@ const char * bios_getdisklabel(bios_diskinfo_t *bd, struct disklabel *label) { u_int start = 0; - char *buf; + char buf[DEV_BSIZE]; const char *err = NULL; int error; @@ -438,7 +446,6 @@ bios_getdisklabel(bios_diskinfo_t *bd, struct disklabel *label) start = LABELSECTOR + start; /* Load BSD disklabel */ - buf = alloca(DEV_BSIZE); #ifdef BIOS_DEBUG if (debug) printf("loading disklabel @ %u\n", start); diff --git a/sys/arch/i386/stand/libsa/biosdev.h b/sys/arch/i386/stand/libsa/biosdev.h index 3cd99d18217..96a812b10e9 100644 --- a/sys/arch/i386/stand/libsa/biosdev.h +++ b/sys/arch/i386/stand/libsa/biosdev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.h,v 1.33 2011/03/14 22:14:40 krw Exp $ */ +/* $OpenBSD: biosdev.h,v 1.34 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -41,6 +41,7 @@ struct consdev; struct open_file; +struct diskinfo; /* biosdev.c */ extern const char *biosdevs[]; @@ -49,7 +50,7 @@ int biosopen(struct open_file *, ...); int biosclose(struct open_file *); int biosioctl(struct open_file *, u_long, void *); int bios_getdiskinfo(int, bios_diskinfo_t *); -int biosd_io(int, bios_diskinfo_t *, u_int, int, void *); +int biosd_diskio(int, struct diskinfo *, u_int, int, void *); const char * bios_getdisklabel(bios_diskinfo_t *, struct disklabel *); /* diskprobe.c */ diff --git a/sys/arch/i386/stand/libsa/cmd_i386.c b/sys/arch/i386/stand/libsa/cmd_i386.c index 57f19d6d595..ab098a67b71 100644 --- a/sys/arch/i386/stand/libsa/cmd_i386.c +++ b/sys/arch/i386/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.33 2013/10/23 05:05:19 mlarkin Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.34 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -38,6 +38,9 @@ #include "libsa.h" #include <cmd.h> +#ifdef EFIBOOT +#include "efiboot.h" +#endif extern const char version[]; @@ -55,6 +58,11 @@ const struct cmd_table cmd_machine[] = { { "comaddr", CMDT_CMD, Xcomaddr }, { "diskinfo", CMDT_CMD, Xdiskinfo }, { "memory", CMDT_CMD, Xmemory }, +#ifdef EFIBOOT + { "video", CMDT_CMD, Xvideo_efi }, + { "exit", CMDT_CMD, Xexit_efi }, + { "poweroff", CMDT_CMD, Xpoweroff_efi }, +#endif #ifdef DEBUG { "regs", CMDT_CMD, Xregs }, #endif @@ -82,9 +90,12 @@ Xregs(void) int Xboot(void) { +#ifdef EFIBOOT + printf("Not supported yet\n"); +#else #ifndef _TEST int dev, part, st; - bios_diskinfo_t *bd = NULL; + struct diskinfo *dip; char buf[DEV_BSIZE], *dest = (void *)BOOTBIOS_ADDR; if (cmd.argc != 2) { @@ -117,8 +128,8 @@ Xboot(void) printf("[%x]\n", dev); /* Read boot sector from device */ - bd = bios_dklookup(dev); - st = biosd_io(F_READ, bd, 0, 1, buf); + dip = dklookup(dev); + st = dip->diskio(F_READ, dip, 0, 1, buf); if (st) goto bad; @@ -140,6 +151,7 @@ Xboot(void) bad: printf("Invalid device!\n"); #endif +#endif return 0; } diff --git a/sys/arch/i386/stand/libsa/disk.h b/sys/arch/i386/stand/libsa/disk.h index e1ea7b262c6..5ad8df3c64b 100644 --- a/sys/arch/i386/stand/libsa/disk.h +++ b/sys/arch/i386/stand/libsa/disk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disk.h,v 1.5 2012/10/31 13:55:58 jsing Exp $ */ +/* $OpenBSD: disk.h,v 1.6 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -32,12 +32,19 @@ #include <sys/queue.h> +struct efi_diskinfo; +typedef struct efi_diskinfo *efi_diskinfo_t; + /* All the info on a disk we've found */ struct diskinfo { + efi_diskinfo_t efi_info; bios_diskinfo_t bios_info; struct disklabel disklabel; struct sr_boot_volume *sr_vol; + int (*diskio)(int, struct diskinfo *, u_int, int, void *); + int (*strategy)(void *, int, daddr32_t, size_t, void *, size_t *); + dev_t bsddev, bootdev; TAILQ_ENTRY(diskinfo) list; diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c index cfb6fb23b7b..97aa5aade84 100644 --- a/sys/arch/i386/stand/libsa/diskprobe.c +++ b/sys/arch/i386/stand/libsa/diskprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskprobe.c,v 1.39 2014/07/12 20:58:31 tedu Exp $ */ +/* $OpenBSD: diskprobe.c,v 1.40 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -46,6 +46,9 @@ #ifdef SOFTRAID #include "softraid.h" #endif +#ifdef EFIBOOT +#include "efidev.h" +#endif #define MAX_CKSUMLEN MAXBSIZE / DEV_BSIZE /* Max # of blks to cksum */ @@ -62,6 +65,15 @@ extern int debug; extern int bios_bootdev; extern int bios_cddev; +#ifndef EFIBOOT +static void +diskinfo_init(struct diskinfo *dip) +{ + bzero(dip, sizeof(*dip)); + dip->diskio = biosd_diskio; + dip->strategy = biosstrategy; +} + /* Probe for all BIOS floppies */ static void floppyprobe(void) @@ -72,7 +84,7 @@ floppyprobe(void) /* Floppies */ for (i = 0; i < 4; i++) { dip = alloc(sizeof(struct diskinfo)); - bzero(dip, sizeof(*dip)); + diskinfo_init(dip); if (bios_getdiskinfo(i, &dip->bios_info)) { #ifdef BIOS_DEBUG @@ -101,7 +113,6 @@ floppyprobe(void) } } - /* Probe for all BIOS hard disks */ static void hardprobe(void) @@ -115,7 +126,7 @@ hardprobe(void) /* Hard disks */ for (i = 0x80; i < (0x80 + *dc); i++) { dip = alloc(sizeof(struct diskinfo)); - bzero(dip, sizeof(*dip)); + diskinfo_init(dip); if (bios_getdiskinfo(i, &dip->bios_info)) { #ifdef BIOS_DEBUG @@ -165,7 +176,63 @@ hardprobe(void) TAILQ_INSERT_TAIL(&disklist, dip, list); } } +#endif + +#ifdef EFIBOOT +static void +efi_hardprobe(void) +{ + int n; + struct diskinfo *dip, *dipt; + u_int bsdunit, type = 0; + u_int scsi= 0, ide = 0; + extern struct disklist_lh + efi_disklist; + + n = 0; + TAILQ_FOREACH_SAFE(dip, &efi_disklist, list, dipt) { + TAILQ_REMOVE(&efi_disklist, dip, list); + printf(" hd%u", n); + + dip->bios_info.bios_number = 0x80 | n; + /* Try to find the label, to figure out device type */ + if ((efi_getdisklabel(dip->efi_info, &dip->disklabel))) { + printf("*"); + bsdunit = ide++; + } else { + /* Best guess */ + switch (dip->disklabel.d_type) { + case DTYPE_SCSI: + type = 4; + bsdunit = scsi++; + dip->bios_info.flags |= BDI_GOODLABEL; + break; + + case DTYPE_ESDI: + case DTYPE_ST506: + type = 0; + bsdunit = ide++; + dip->bios_info.flags |= BDI_GOODLABEL; + break; + default: + dip->bios_info.flags |= BDI_BADLABEL; + type = 0; /* XXX Suggest IDE */ + bsdunit = ide++; + } + } + + dip->bios_info.checksum = 0; /* just in case */ + /* Fill out best we can */ + dip->bios_info.bsd_dev = + MAKEBOOTDEV(type, 0, 0, bsdunit, RAW_PART); + + /* Add to queue of disks */ + TAILQ_INSERT_TAIL(&disklist, dip, list); + n++; + } +} +#endif /* Probe for all BIOS supported disks */ u_int32_t bios_cksumlen; @@ -181,6 +248,7 @@ diskprobe(void) /* Init stuff */ TAILQ_INIT(&disklist); +#ifndef EFIBOOT /* Do probes */ floppyprobe(); #ifdef BIOS_DEBUG @@ -188,6 +256,9 @@ diskprobe(void) printf(";"); #endif hardprobe(); +#else + efi_hardprobe(); +#endif #ifdef SOFTRAID srprobe(); @@ -216,7 +287,7 @@ diskprobe(void) bios_diskinfo); } - +#ifndef EFIBOOT void cdprobe(void) { @@ -229,7 +300,7 @@ cdprobe(void) return; dip = alloc(sizeof(struct diskinfo)); - bzero(dip, sizeof(*dip)); + diskinfo_init(dip); #if 0 if (bios_getdiskinfo(cddev, &dip->bios_info)) { @@ -290,6 +361,7 @@ cdprobe(void) /* Add to queue of disks */ TAILQ_INSERT_TAIL(&disklist, dip, list); } +#endif /* Find info on given BIOS disk */ @@ -358,9 +430,8 @@ disksum(int blk) { struct diskinfo *dip, *dip2; int st, reprobe = 0; - char *buf; + char buf[DEV_BSIZE]; - buf = alloca(DEV_BSIZE); for (dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) { bios_diskinfo_t *bdi = &dip->bios_info; @@ -369,7 +440,7 @@ disksum(int blk) continue; /* Adler32 checksum */ - st = biosd_io(F_READ, bdi, blk, 1, buf); + st = dip->diskio(F_READ, dip, blk, 1, buf); if (st) { bdi->flags |= BDI_INVALID; continue; diff --git a/sys/arch/i386/stand/libsa/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c index 5f022a5cbc4..9165f1ce055 100644 --- a/sys/arch/i386/stand/libsa/exec_i386.c +++ b/sys/arch/i386/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.39 2012/11/01 00:55:38 jsing Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.40 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -43,6 +43,10 @@ #include "softraid.h" #endif +#ifdef EFIBOOT +#include "efiboot.h" +#endif + typedef void (*startfuncp)(int, int, int, int, int, int, int, int) __attribute__ ((noreturn)); @@ -70,6 +74,11 @@ run_loadfile(u_long *marks, int howto) struct sr_boot_volume *bv; #endif +#ifdef EFIBOOT + if ((av = alloc(ac)) == NULL) + panic("alloc for bootarg"); + efi_makebootargs(); +#endif if (sa_cleanup != NULL) (*sa_cleanup)(); @@ -108,15 +117,27 @@ run_loadfile(u_long *marks, int howto) /* Pass memory map to the kernel */ mem_pass(); - makebootargs(av, &ac); + /* + * This code may be used both for 64bit and 32bit. Make sure the + * bootarg is 32bit always on even on amd64. + */ + makebootargs32(av, &ac); entry = marks[MARK_ENTRY] & 0x0fffffff; printf("entry point at 0x%x\n", (int)entry); +#if defined(EFIBOOT) + efi_cleanup(); +#endif +#if defined(EFIBOOT) && defined(__amd64__) + (*run_i386)((u_long)run_i386, entry, howto, bootdev, BOOTARG_APIVER, + marks[MARK_END], extmem, cnvmem, ac, (intptr_t)av); +#else /* stack and the gung is ok at this point, so, no need for asm setup */ (*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER, marks[MARK_END], extmem, cnvmem, ac, (int)av); /* not reached */ #endif +#endif } diff --git a/sys/arch/i386/stand/libsa/machdep.c b/sys/arch/i386/stand/libsa/machdep.c index 1e77754e561..e4676e351a2 100644 --- a/sys/arch/i386/stand/libsa/machdep.c +++ b/sys/arch/i386/stand/libsa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.36 2007/04/27 10:08:34 tom Exp $ */ +/* $OpenBSD: machdep.c,v 1.37 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -32,6 +32,10 @@ #include <machine/apmvar.h> #include <machine/biosvar.h> +#ifdef EFIBOOT +#include "efiboot.h" +#endif + volatile struct BIOS_regs BIOS_regs; #if defined(DEBUG) && !defined(_TEST) @@ -66,5 +70,9 @@ machdep(void) int check_skip_conf(void) { /* Return non-zero (skip boot.conf) if Control "shift" key down */ +#ifndef EFIBOOT return (pc_getshifts(0) & 0x04); +#else + return (efi_cons_getshifts(0) & 0x04); +#endif } diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c index aab27dbe97f..4f9f0a5ef8c 100644 --- a/sys/arch/i386/stand/libsa/memprobe.c +++ b/sys/arch/i386/stand/libsa/memprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memprobe.c,v 1.53 2014/03/29 18:09:29 guenther Exp $ */ +/* $OpenBSD: memprobe.c,v 1.54 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -36,7 +36,8 @@ u_int cnvmem, extmem; /* XXX - compatibility */ - +bios_memmap_t bios_memmap[64]; /* This is easier */ +#ifndef EFIBOOT /* * Check gateA20 * @@ -232,7 +233,7 @@ addrprobe(u_int kloc) u_int save[nitems(addrprobe_pat)]; /* Get location */ - loc = (int *)(kloc * 1024); + loc = (int *)(intptr_t)(kloc * 1024); save[0] = *loc; /* Probe address */ @@ -295,7 +296,6 @@ badprobe(bios_memmap_t *mp) return ++mp; } -bios_memmap_t bios_memmap[64]; /* This is easier */ #ifndef _TEST void memprobe(void) @@ -366,6 +366,7 @@ memprobe(void) printf("a20=o%s] ", checkA20()? "n" : "ff!"); } #endif +#endif void dump_biosmem(bios_memmap_t *tm) diff --git a/sys/arch/i386/stand/libsa/softraid.c b/sys/arch/i386/stand/libsa/softraid.c index f43d46056d8..2f45421f6fb 100644 --- a/sys/arch/i386/stand/libsa/softraid.c +++ b/sys/arch/i386/stand/libsa/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.11 2015/07/21 03:30:51 krw Exp $ */ +/* $OpenBSD: softraid.c,v 1.12 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> @@ -30,7 +30,6 @@ #include <lib/libsa/rijndael.h> #include "libsa.h" -#include "biosdev.h" #include "disk.h" #include "softraid.h" @@ -173,8 +172,7 @@ srprobe(void) bzero(md, SR_META_SIZE * DEV_BSIZE); off = DL_SECTOBLK(&dip->disklabel, DL_GETPOFFSET(pp)); off += SR_META_OFFSET; - error = biosd_io(F_READ, &dip->bios_info, off, - SR_META_SIZE, md); + error = dip->diskio(F_READ, dip, off, SR_META_SIZE, md); if (error) continue; @@ -356,7 +354,7 @@ sr_strategy(struct sr_boot_volume *bv, int rw, daddr32_t blk, size_t size, blk += bv->sbv_data_blkno; /* XXX - If I/O failed we should try another chunk... */ - return biosstrategy(dip, rw, blk, size, buf, rsize); + return dip->strategy(dip, rw, blk, size, buf, rsize); } else if (bv->sbv_level == 'C') { @@ -377,7 +375,7 @@ sr_strategy(struct sr_boot_volume *bv, int rw, daddr32_t blk, size_t size, for (i = 0; i < nsect; i++) { blkno = blk + i; bp = ((u_char *)buf) + i * DEV_BSIZE; - err = biosstrategy(dip, rw, bv->sbv_data_blkno + blkno, + err = dip->strategy(dip, rw, bv->sbv_data_blkno + blkno, DEV_BSIZE, bp, NULL); if (err != 0) return err; @@ -402,7 +400,7 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) struct dos_partition *dp; struct dos_mbr mbr; u_int start = 0; - char *buf; + char buf[DEV_BSIZE]; int i; /* Check for MBR to determine partition offset. */ @@ -426,7 +424,6 @@ sr_getdisklabel(struct sr_boot_volume *bv, struct disklabel *label) start += LABELSECTOR; /* Read the disklabel. */ - buf = alloca(DEV_BSIZE); sr_strategy(bv, F_READ, start, sizeof(struct disklabel), buf, NULL); #ifdef BIOS_DEBUG diff --git a/sys/arch/i386/stand/pxeboot/Makefile b/sys/arch/i386/stand/pxeboot/Makefile index 01019f6ce42..922724685e5 100644 --- a/sys/arch/i386/stand/pxeboot/Makefile +++ b/sys/arch/i386/stand/pxeboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.20 2014/11/19 20:10:01 miod Exp $ +# $OpenBSD: Makefile,v 1.21 2015/09/02 04:09:24 yasuoka Exp $ MAN= pxeboot.8 @@ -17,7 +17,7 @@ BINMODE=644 CLEANFILES+= crt0.o ${PROG}.whole .PATH: ${SADIR}/libsa -SRCS+= alloca.S debug_i386.S gidt.S random_i386.S +SRCS+= debug_i386.S gidt.S random_i386.S SRCS+= cmd_i386.c exec_i386.c gateA20.c machdep.c SRCS+= apmprobe.c bioscons.c biosdev.c debug.c diskprobe.c memprobe.c \ pciprobe.c ps2probe.c time.c diff --git a/sys/arch/i386/stand/pxeboot/conf.c b/sys/arch/i386/stand/pxeboot/conf.c index ad7e4dc904a..d9e9d2a3e7b 100644 --- a/sys/arch/i386/stand/pxeboot/conf.c +++ b/sys/arch/i386/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.29 2014/02/18 13:56:02 jsing Exp $ */ +/* $OpenBSD: conf.c,v 1.30 2015/09/02 04:09:24 yasuoka Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -46,7 +46,7 @@ #include "pxeboot.h" #include "pxe_net.h" -const char version[] = "3.23"; +const char version[] = "3.24"; int debug = 1; #undef _TEST |