diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/stand/efiboot/Makefile.common | 8 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/cmd_i386.c | 162 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/dev_i386.c | 207 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/diskprobe.c | 301 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/exec_i386.c | 220 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/machdep.c | 95 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/memprobe.c | 173 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/cmd_i386.c | 21 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/dev_i386.c | 23 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/diskprobe.c | 84 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/exec_i386.c | 48 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/machdep.c | 10 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/memprobe.c | 5 |
13 files changed, 1169 insertions, 188 deletions
diff --git a/sys/arch/amd64/stand/efiboot/Makefile.common b/sys/arch/amd64/stand/efiboot/Makefile.common index a3953f5070d..788e721d958 100644 --- a/sys/arch/amd64/stand/efiboot/Makefile.common +++ b/sys/arch/amd64/stand/efiboot/Makefile.common @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.common,v 1.15 2019/05/05 19:17:03 kettenis Exp $ +# $OpenBSD: Makefile.common,v 1.16 2019/05/10 21:20:42 mlarkin Exp $ S= ${.CURDIR}/../../../../.. SADIR= ${.CURDIR}/../.. @@ -25,7 +25,8 @@ AFLAGS+= -pipe -fPIC .PATH: ${.CURDIR}/.. SRCS+= self_reloc.c SRCS+= efiboot.c efidev.c efipxe.c efirng.c -SRCS+= conf.c +SRCS+= conf.c dev_i386.c cmd_i386.c diskprobe.c exec_i386.c machdep.c +SRCS+= memprobe.c .PATH: ${S}/stand/boot SRCS+= boot.c bootarg.c cmd.c vars.c @@ -50,8 +51,7 @@ SRCS+= divdi3.c moddi3.c qdivrem.c SRCS+= strlcpy.c .PATH: ${SADIR}/libsa -SRCS+= loadfile.c elf64.c elf32.c memprobe.c cmd_i386.c dev_i386.c exec_i386.c -SRCS+= machdep.c diskprobe.c +SRCS+= loadfile.c elf64.c elf32.c .if ${SOFTRAID:L} == "yes" SRCS+= softraid_amd64.c diff --git a/sys/arch/amd64/stand/efiboot/cmd_i386.c b/sys/arch/amd64/stand/efiboot/cmd_i386.c new file mode 100644 index 00000000000..f79e2b1e090 --- /dev/null +++ b/sys/arch/amd64/stand/efiboot/cmd_i386.c @@ -0,0 +1,162 @@ +/* $OpenBSD: cmd_i386.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */ + +/* + * Copyright (c) 1997-1999 Michael Shalayeff + * Copyright (c) 1997 Tobias Weingartner + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 <sys/param.h> +#include <sys/reboot.h> +#include <machine/biosvar.h> +#include <sys/disklabel.h> +#include "disk.h" +#include "biosdev.h" +#include "libsa.h" +#include <cmd.h> + +#include "efiboot.h" +#include "efidev.h" + +extern const char version[]; + +int Xboot(void); +int Xcomaddr(void); +int Xdiskinfo(void); +int Xmemory(void); +int Xregs(void); + +/* From gidt.S */ +int bootbuf(void *, int); + +const struct cmd_table cmd_machine[] = { + { "comaddr", CMDT_CMD, Xcomaddr }, + { "diskinfo", CMDT_CMD, Xdiskinfo }, + { "memory", CMDT_CMD, Xmemory }, + { "video", CMDT_CMD, Xvideo_efi }, + { "gop", CMDT_CMD, Xgop_efi }, + { "exit", CMDT_CMD, Xexit_efi }, + { "poweroff", CMDT_CMD, Xpoweroff_efi }, +#ifdef DEBUG + { "regs", CMDT_CMD, Xregs }, +#endif + { NULL, 0 } +}; + +int +Xdiskinfo(void) +{ + efi_dump_diskinfo(); + return 0; +} + +#ifdef DEBUG +int +Xregs(void) +{ + DUMP_REGS; + return 0; +} +#endif + +int +Xmemory(void) +{ + if (cmd.argc >= 2) { + int i; + /* parse the memory specs */ + + for (i = 1; i < cmd.argc; i++) { + char *p; + long long addr, size; + + p = cmd.argv[i]; + + size = strtoll(p + 1, &p, 0); + /* Size the size */ + switch (*p) { + case 'G': + case 'g': + size *= 1024; + case 'M': + case 'm': + size *= 1024; + case 'K': + case 'k': + size *= 1024; + p++; + } + + /* Handle (possibly non-existent) address part */ + switch (*p) { + case '@': + addr = strtoll(p + 1, NULL, 0); + break; + + /* Adjust address if we don't need it */ + default: + if (cmd.argv[i][0] == '=') + addr = -1; + else + addr = 0; + } + + if (addr == 0 || size == 0) { + printf("bad language\n"); + return 0; + } else { + switch (cmd.argv[i][0]) { + case '-': + mem_delete(addr, addr + size); + break; + case '+': + mem_add(addr, addr + size); + break; + case '=': + mem_limit(size); + break; + default : + printf("bad OP\n"); + return 0; + } + } + } + } + + dump_biosmem(NULL); + + return 0; +} + +int +Xcomaddr(void) +{ + extern int com_addr; + + if (cmd.argc >= 2) + com_addr = (int)strtol(cmd.argv[1], NULL, 0); + + return 0; +} diff --git a/sys/arch/amd64/stand/efiboot/dev_i386.c b/sys/arch/amd64/stand/efiboot/dev_i386.c new file mode 100644 index 00000000000..6e64155401f --- /dev/null +++ b/sys/arch/amd64/stand/efiboot/dev_i386.c @@ -0,0 +1,207 @@ +/* $OpenBSD: dev_i386.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */ + +/* + * Copyright (c) 1996-1999 Michael Shalayeff + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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 <sys/param.h> +#include <sys/queue.h> +#include <sys/disklabel.h> +#include <dev/cons.h> + +#include "libsa.h" +#include "biosdev.h" +#include "disk.h" + +#ifdef SOFTRAID +#include <dev/biovar.h> +#include <dev/softraidvar.h> +#include <lib/libsa/softraid.h> +#include "softraid_amd64.h" +#endif + +extern int debug; + +/* XXX use slot for 'rd' for 'hd' pseudo-device */ +const char bdevs[][4] = { + "wd", "", "fd", "", "sd", "st", "cd", "", + "", "", "", "", "", "", "", "", "", "hd", "" +}; +const int nbdevs = nitems(bdevs); + +const char cdevs[][4] = { + "cn", "", "", "", "", "", "", "", + "com", "", "", "", "pc" +}; +const int ncdevs = nitems(cdevs); + +/* pass dev_t to the open routines */ +int +devopen(struct open_file *f, const char *fname, char **file) +{ + struct devsw *dp = devsw; + register int i, rc = 1; + + *file = (char *)fname; + +#ifdef DEBUG + if (debug) + printf("devopen:"); +#endif + + for (i = 0; i < ndevs && rc != 0; dp++, i++) { +#ifdef DEBUG + if (debug) + printf(" %s: ", dp->dv_name); +#endif + if ((rc = (*dp->dv_open)(f, file)) == 0) { + f->f_dev = dp; + if (strcmp("TFTP", dp->dv_name) != 0) { + /* + * Clear bootmac, to signal that we loaded + * this file from a non-network device. + */ + extern char *bootmac; + bootmac = NULL; + } + return 0; + } +#ifdef DEBUG + else if (debug) + printf("%d", rc); +#endif + + } +#ifdef DEBUG + if (debug) + putchar('\n'); +#endif + + if ((f->f_flags & F_NODEV) == 0) + f->f_dev = dp; + + return rc; +} + +void +devboot(dev_t bootdev, char *p) +{ +#ifdef SOFTRAID + struct sr_boot_volume *bv; + struct sr_boot_chunk *bc; + struct diskinfo *dip = NULL; +#endif + int sr_boot_vol = -1; + int part_type = FS_UNUSED; + + if (!bootdev) { + *p++ = 't'; + *p++ = 'f'; + *p++ = 't'; + *p++ = 'p'; + *p = '\0'; + return; + } + +#ifdef SOFTRAID + /* + * Determine the partition type for the 'a' partition of the + * boot device. + */ + TAILQ_FOREACH(dip, &disklist, list) + if (dip->bios_info.bios_number == bootdev && + (dip->bios_info.flags & BDI_BADLABEL) == 0) + part_type = dip->disklabel.d_partitions[0].p_fstype; + + /* + * See if we booted from a disk that is a member of a bootable + * softraid volume. + */ + SLIST_FOREACH(bv, &sr_volumes, sbv_link) { + if (bv->sbv_flags & BIOC_SCBOOTABLE) + SLIST_FOREACH(bc, &bv->sbv_chunks, sbc_link) + if (bc->sbc_disk == bootdev) + sr_boot_vol = bv->sbv_unit; + if (sr_boot_vol != -1) + break; + } +#endif + + if (sr_boot_vol != -1 && part_type != FS_BSDFFS) { + *p++ = 's'; + *p++ = 'r'; + *p++ = '0' + sr_boot_vol; + } else if (bootdev & 0x100) { + *p++ = 'c'; + *p++ = 'd'; + *p++ = '0'; + } else { + if (bootdev & 0x80) + *p++ = 'h'; + else + *p++ = 'f'; + *p++ = 'd'; + *p++ = '0' + (bootdev & 0x7f); + } + *p++ = 'a'; + *p = '\0'; +} + +char ttyname_buf[8]; + +char * +ttyname(int fd) +{ + snprintf(ttyname_buf, sizeof ttyname_buf, "%s%d", + cdevs[major(cn_tab->cn_dev)], minor(cn_tab->cn_dev)); + + return ttyname_buf; +} + +dev_t +ttydev(char *name) +{ + int i, unit = -1; + char *no = name + strlen(name) - 1; + + while (no >= name && *no >= '0' && *no <= '9') + unit = (unit < 0 ? 0 : (unit * 10)) + *no-- - '0'; + if (no < name || unit < 0) + return NODEV; + for (i = 0; i < ncdevs; i++) + if (strncmp(name, cdevs[i], no - name + 1) == 0) + return makedev(i, unit); + return NODEV; +} + +int +cnspeed(dev_t dev, int sp) +{ + if (major(dev) == 8) /* comN */ + return comspeed(dev, sp); + + /* pc0 and anything else */ + return 9600; +} diff --git a/sys/arch/amd64/stand/efiboot/diskprobe.c b/sys/arch/amd64/stand/efiboot/diskprobe.c new file mode 100644 index 00000000000..4ddc5ae84a4 --- /dev/null +++ b/sys/arch/amd64/stand/efiboot/diskprobe.c @@ -0,0 +1,301 @@ +/* $OpenBSD: diskprobe.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */ + +/* + * Copyright (c) 1997 Tobias Weingartner + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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. + * + */ + +/* We want the disk type names from disklabel.h */ +#undef DKTYPENAMES + +#include <sys/param.h> +#include <sys/queue.h> +#include <sys/reboot.h> +#include <sys/disklabel.h> +#include <sys/hibernate.h> + +#include <lib/libz/zlib.h> +#include <machine/biosvar.h> +#include <stand/boot/bootarg.h> + +#include "disk.h" +#include "biosdev.h" +#include "libsa.h" + +#ifdef SOFTRAID +#include "softraid_amd64.h" +#endif +#include "efidev.h" + +#define MAX_CKSUMLEN MAXBSIZE / DEV_BSIZE /* Max # of blks to cksum */ + +/* Local Prototypes */ +static int disksum(int); + +int bootdev_has_hibernate(void); /* export for loadfile() */ + +/* List of disk devices we found/probed */ +struct disklist_lh disklist; + +/* Pointer to boot device */ +struct diskinfo *bootdev_dip; + +extern int debug; +extern int bios_bootdev; +extern int bios_cddev; + +static void +efi_hardprobe(void) +{ + int n; + struct diskinfo *dip, *dipt; + u_int bsdunit, type = 0; + u_int scsi= 0, ide = 0, atapi = 0; + extern struct disklist_lh + efi_disklist; + + n = 0; + TAILQ_FOREACH_SAFE(dip, &efi_disklist, list, dipt) { + TAILQ_REMOVE(&efi_disklist, dip, list); + n = scsi + ide; + + /* Try to find the label, to figure out device type */ + if ((efi_getdisklabel(dip->efi_info, &dip->disklabel))) { + type = 0; + printf(" hd%d*", n); + 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; + + case DTYPE_ATAPI: + type = 6; + n = atapi; + bsdunit = atapi++; + dip->bios_info.flags |= BDI_GOODLABEL + | BDI_EL_TORITO; + break; + + default: + dip->bios_info.flags |= BDI_BADLABEL; + type = 0; /* XXX Suggest IDE */ + bsdunit = ide++; + } + printf(" %cd%d", (type == 6)? 'c' : 'h', n); + } + if (type != 6) + dip->bios_info.bios_number = 0x80 | n; + else + dip->bios_info.bios_number = 0xe0 | n; + + dip->bios_info.checksum = 0; /* just in case */ + /* Fill out best we can */ + dip->bsddev = dip->bios_info.bsd_dev = + MAKEBOOTDEV(type, 0, 0, bsdunit, RAW_PART); + check_hibernate(dip); + + /* Add to queue of disks */ + TAILQ_INSERT_TAIL(&disklist, dip, list); + n++; + } +} + +/* Probe for all BIOS supported disks */ +u_int32_t bios_cksumlen; +void +diskprobe(void) +{ + struct diskinfo *dip; + int i; + + /* These get passed to kernel */ + bios_diskinfo_t *bios_diskinfo; + + /* Init stuff */ + TAILQ_INIT(&disklist); + + efi_hardprobe(); + +#ifdef SOFTRAID + srprobe(); +#endif + + /* Checksumming of hard disks */ + for (i = 0; disksum(i++) && i < MAX_CKSUMLEN; ) + ; + bios_cksumlen = i; + + /* Get space for passing bios_diskinfo stuff to kernel */ + for (i = 0, dip = TAILQ_FIRST(&disklist); dip; + dip = TAILQ_NEXT(dip, list)) + i++; + bios_diskinfo = alloc(++i * sizeof(bios_diskinfo_t)); + + /* Copy out the bios_diskinfo stuff */ + for (i = 0, dip = TAILQ_FIRST(&disklist); dip; + dip = TAILQ_NEXT(dip, list)) + bios_diskinfo[i++] = dip->bios_info; + + bios_diskinfo[i++].bios_number = -1; + /* Register for kernel use */ + addbootarg(BOOTARG_CKSUMLEN, sizeof(u_int32_t), &bios_cksumlen); + addbootarg(BOOTARG_DISKINFO, i * sizeof(bios_diskinfo_t), + bios_diskinfo); +} + +/* Find info on given BIOS disk */ +struct diskinfo * +dklookup(int dev) +{ + struct diskinfo *dip; + + for (dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) + if (dip->bios_info.bios_number == dev) + return dip; + + return NULL; +} + +void +dump_diskinfo(void) +{ + struct diskinfo *dip; + + printf("Disk\tBIOS#\tType\tCyls\tHeads\tSecs\tFlags\tChecksum\n"); + for (dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) { + bios_diskinfo_t *bdi = &dip->bios_info; + int d = bdi->bios_number; + int u = d & 0x7f; + char c; + + if (bdi->flags & BDI_EL_TORITO) { + c = 'c'; + u = 0; + } else { + c = (d & 0x80) ? 'h' : 'f'; + } + + printf("%cd%d\t0x%x\t%s\t%d\t%d\t%d\t0x%x\t0x%x\n", + c, u, d, + (bdi->flags & BDI_BADLABEL)?"*none*":"label", + bdi->bios_cylinders, bdi->bios_heads, bdi->bios_sectors, + bdi->flags, bdi->checksum); + } +} + +/* Find BIOS portion on given BIOS disk + * XXX - Use dklookup() instead. + */ +bios_diskinfo_t * +bios_dklookup(int dev) +{ + struct diskinfo *dip; + + dip = dklookup(dev); + if (dip) + return &dip->bios_info; + + return NULL; +} + +/* + * Checksum one more block on all harddrives + * + * Use the adler32() function from libz, + * as it is quick, small, and available. + */ +int +disksum(int blk) +{ + struct diskinfo *dip, *dip2; + int st, reprobe = 0; + char buf[DEV_BSIZE]; + + for (dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) { + bios_diskinfo_t *bdi = &dip->bios_info; + + /* Skip this disk if it is not a HD or has had an I/O error */ + if (!(bdi->bios_number & 0x80) || bdi->flags & BDI_INVALID) + continue; + + /* Adler32 checksum */ + st = dip->diskio(F_READ, dip, blk, 1, buf); + if (st) { + bdi->flags |= BDI_INVALID; + continue; + } + bdi->checksum = adler32(bdi->checksum, buf, DEV_BSIZE); + + for (dip2 = TAILQ_FIRST(&disklist); dip2 != dip; + dip2 = TAILQ_NEXT(dip2, list)) { + bios_diskinfo_t *bd = &dip2->bios_info; + if ((bd->bios_number & 0x80) && + !(bd->flags & BDI_INVALID) && + bdi->checksum == bd->checksum) + reprobe = 1; + } + } + + return reprobe; +} + +int +bootdev_has_hibernate(void) +{ + return ((bootdev_dip->bios_info.flags & BDI_HIBVALID)? 1 : 0); +} + +void +check_hibernate(struct diskinfo *dip) +{ + daddr_t sec; + int error; + union hibernate_info hib; + + /* read hibernate */ + if (dip->disklabel.d_partitions[1].p_fstype != FS_SWAP || + DL_GETPSIZE(&dip->disklabel.d_partitions[1]) == 0) + return; + + sec = DL_GETPOFFSET(&dip->disklabel.d_partitions[1]) + + DL_GETPSIZE(&dip->disklabel.d_partitions[1]) - + (sizeof(union hibernate_info) / DEV_BSIZE); + + error = dip->strategy(dip, F_READ, (daddr32_t)sec, sizeof hib, &hib, NULL); + if (error == 0 && hib.magic == HIBERNATE_MAGIC) + dip->bios_info.flags |= BDI_HIBVALID; /* Hibernate present */ +} diff --git a/sys/arch/amd64/stand/efiboot/exec_i386.c b/sys/arch/amd64/stand/efiboot/exec_i386.c new file mode 100644 index 00000000000..e4b39d6cd0c --- /dev/null +++ b/sys/arch/amd64/stand/efiboot/exec_i386.c @@ -0,0 +1,220 @@ +/* $OpenBSD: exec_i386.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */ + +/* + * Copyright (c) 1997-1998 Michael Shalayeff + * Copyright (c) 1997 Tobias Weingartner + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 <sys/param.h> +#include <sys/disklabel.h> +#include <dev/cons.h> +#include <lib/libsa/loadfile.h> +#include <machine/biosvar.h> +#include <machine/specialreg.h> +#include <stand/boot/bootarg.h> + +#include "cmd.h" +#include "disk.h" +#include "libsa.h" + +#ifdef SOFTRAID +#include <dev/softraidvar.h> +#include <lib/libsa/softraid.h> +#include "softraid_amd64.h" +#endif + +#include "efiboot.h" + +typedef void (*startfuncp)(int, int, int, int, int, int, int, int) + __attribute__ ((noreturn)); + +void ucode_load(void); +extern struct cmd_state cmd; + +char *bootmac = NULL; + +void +run_loadfile(uint64_t *marks, int howto) +{ + u_long entry; +#ifdef EXEC_DEBUG + extern int debug; +#endif + dev_t bootdev = bootdev_dip->bootdev; + size_t ac = BOOTARG_LEN; + caddr_t av = (caddr_t)BOOTARG_OFF; + bios_consdev_t cd; + extern int com_speed; /* from bioscons.c */ + extern int com_addr; + bios_ddb_t ddb; + extern int db_console; + bios_bootduid_t bootduid; +#ifdef SOFTRAID + bios_bootsr_t bootsr; + struct sr_boot_volume *bv; +#endif + int i; + u_long delta; + extern u_long efi_loadaddr; + + if ((av = alloc(ac)) == NULL) + panic("alloc for bootarg"); + efi_makebootargs(); + delta = DEFAULT_KERNEL_ADDRESS - efi_loadaddr; + if (sa_cleanup != NULL) + (*sa_cleanup)(); + + cd.consdev = cn_tab->cn_dev; + cd.conspeed = com_speed; + cd.consaddr = com_addr; + cd.consfreq = 0; + addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd); + + if (bootmac != NULL) + addbootarg(BOOTARG_BOOTMAC, sizeof(bios_bootmac_t), bootmac); + + if (db_console != -1) { + ddb.db_console = db_console; + addbootarg(BOOTARG_DDB, sizeof(ddb), &ddb); + } + + bcopy(bootdev_dip->disklabel.d_uid, &bootduid.duid, sizeof(bootduid)); + addbootarg(BOOTARG_BOOTDUID, sizeof(bootduid), &bootduid); + + ucode_load(); + +#ifdef SOFTRAID + if (bootdev_dip->sr_vol != NULL) { + bv = bootdev_dip->sr_vol; + bzero(&bootsr, sizeof(bootsr)); + bcopy(&bv->sbv_uuid, &bootsr.uuid, sizeof(bootsr.uuid)); + if (bv->sbv_maskkey != NULL) + bcopy(bv->sbv_maskkey, &bootsr.maskkey, + sizeof(bootsr.maskkey)); + addbootarg(BOOTARG_BOOTSR, sizeof(bios_bootsr_t), &bootsr); + explicit_bzero(&bootsr, sizeof(bootsr)); + } + + sr_clear_keys(); +#endif + + entry = marks[MARK_ENTRY] & 0x0fffffff; + entry += delta; + + printf("entry point at 0x%lx\n", entry); + + /* Sync the memory map and call ExitBootServices() */ + efi_cleanup(); + + /* Pass memory map to the kernel */ + mem_pass(); + + /* + * This code may be used both for 64bit and 32bit. Make sure the + * bootarg is always 32bit, even on amd64. + */ +#ifdef __amd64__ + makebootargs32(av, &ac); +#else + makebootargs(av, &ac); +#endif + + /* + * Move the loaded kernel image to the usual place after calling + * ExitBootServices(). + */ + memmove((void *)marks[MARK_START] + delta, (void *)marks[MARK_START], + marks[MARK_END] - marks[MARK_START]); + for (i = 0; i < MARK_MAX; i++) + marks[i] += delta; + +#ifdef __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); +#endif + /* not reached */ +} + +void +ucode_load(void) +{ + uint32_t model, family, stepping; + uint32_t dummy, signature; + uint32_t vendor[4]; + bios_ucode_t uc; + struct stat sb; + char path[128]; + size_t buflen; + char *buf; + int fd; + + CPUID(0, dummy, vendor[0], vendor[2], vendor[1]); + vendor[3] = 0; /* NULL-terminate */ + if (strcmp((char *)vendor, "GenuineIntel") != 0) + return; + + CPUID(1, signature, dummy, dummy, dummy); + family = (signature >> 8) & 0x0f; + model = (signature >> 4) & 0x0f; + if (family == 0x6 || family == 0xf) { + family += (signature >> 20) & 0xff; + model += ((signature >> 16) & 0x0f) << 4; + } + stepping = (signature >> 0) & 0x0f; + + snprintf(path, sizeof(path), "%s:/etc/firmware/intel/%02x-%02x-%02x", + cmd.bootdev, family, model, stepping); + + fd = open(path, 0); + if (fd == -1) + return; + + if (fstat(fd, &sb) == -1) + return; + + buflen = sb.st_size; + if (buflen > 128*1024) { + printf("ucode too large\n"); + return; + } + + buf = (char *)(1*1024*1024); + + if (read(fd, buf, buflen) != buflen) { + close(fd); + return; + } + + uc.uc_addr = (uint64_t)buf; + uc.uc_size = (uint64_t)buflen; + addbootarg(BOOTARG_UCODE, sizeof(uc), &uc); + + close(fd); +} diff --git a/sys/arch/amd64/stand/efiboot/machdep.c b/sys/arch/amd64/stand/efiboot/machdep.c new file mode 100644 index 00000000000..d994a0f4d74 --- /dev/null +++ b/sys/arch/amd64/stand/efiboot/machdep.c @@ -0,0 +1,95 @@ +/* $OpenBSD: machdep.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */ + +/* + * Copyright (c) 2004 Tom Cosgrove + * Copyright (c) 1997-1999 Michael Shalayeff + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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 "libsa.h" +#include "biosdev.h" +#include <machine/apmvar.h> +#include <machine/biosvar.h> +#include <machine/specialreg.h> +#include <machine/vmmvar.h> + +#include "efiboot.h" + +volatile struct BIOS_regs BIOS_regs; + +#if defined(DEBUG) +#define CKPT(c) (*(u_int16_t*)0xb8148 = 0x4700 + (c)) +#else +#define CKPT(c) /* c */ +#endif + +const char *vmm_hv_signature = VMM_HV_SIGNATURE; + +void +machdep(void) +{ + int i, j, vmm = 0; + struct i386_boot_probes *pr; + uint32_t dummy, ebx, ecx, edx; + dev_t dev; + + /* + * The list of probe routines is now in conf.c. + */ + for (i = 0; i < nibprobes; i++) { + pr = &probe_list[i]; + if (pr != NULL) { + printf("%s:", pr->name); + + for (j = 0; j < pr->count; j++) { + (*(pr->probes)[j])(); + } + + printf("\n"); + } + } + + CPUID(0x1, dummy, dummy, ecx, dummy); + if (ecx & CPUIDECX_HV) { + CPUID(0x40000000, dummy, ebx, ecx, edx); + if (memcmp(&ebx, &vmm_hv_signature[0], sizeof(uint32_t)) == 0 && + memcmp(&ecx, &vmm_hv_signature[4], sizeof(uint32_t)) == 0 && + memcmp(&edx, &vmm_hv_signature[8], sizeof(uint32_t)) == 0) + vmm = 1; + } + + /* Set console to com0/115200 by default in vmm */ + if (vmm) { + dev = ttydev("com0"); + cnspeed(dev, 115200); + cnset(dev); + } +} + +int +check_skip_conf(void) +{ + /* Return non-zero (skip boot.conf) if Control "shift" key down */ + return (efi_cons_getshifts(0) & 0x04); +} diff --git a/sys/arch/amd64/stand/efiboot/memprobe.c b/sys/arch/amd64/stand/efiboot/memprobe.c new file mode 100644 index 00000000000..f2f51c9669d --- /dev/null +++ b/sys/arch/amd64/stand/efiboot/memprobe.c @@ -0,0 +1,173 @@ +/* $OpenBSD: memprobe.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */ + +/* + * Copyright (c) 1997-1999 Michael Shalayeff + * Copyright (c) 1997-1999 Tobias Weingartner + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 <sys/param.h> +#include <machine/biosvar.h> +#include <dev/isa/isareg.h> +#include <stand/boot/bootarg.h> +#include "libsa.h" + +u_int cnvmem, extmem; /* XXX - compatibility */ + +bios_memmap_t bios_memmap[64]; /* This is easier */ + +void +dump_biosmem(bios_memmap_t *tm) +{ + register bios_memmap_t *p; + register u_int total = 0; + + if (tm == NULL) + tm = bios_memmap; + + for (p = tm; p->type != BIOS_MAP_END; p++) { + printf("Region %ld: type %u at 0x%llx for %uKB\n", + (long)(p - tm), p->type, p->addr, + (u_int)(p->size / 1024)); + + if (p->type == BIOS_MAP_FREE) + total += p->size / 1024; + } + + printf("Low ram: %dKB High ram: %dKB\n", cnvmem, extmem); + printf("Total free memory: %uKB\n", total); +} + +int +mem_limit(long long ml) +{ + register bios_memmap_t *p; + + for (p = bios_memmap; p->type != BIOS_MAP_END; p++) { + register int64_t sp = p->addr, ep = p->addr + p->size; + + if (p->type != BIOS_MAP_FREE) + continue; + + /* Wholly above limit, nuke it */ + if ((sp >= ml) && (ep >= ml)) { + bcopy (p + 1, p, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)p); + } else if ((sp < ml) && (ep >= ml)) { + p->size -= (ep - ml); + } + } + return 0; +} + +int +mem_delete(long long sa, long long ea) +{ + register bios_memmap_t *p; + + for (p = bios_memmap; p->type != BIOS_MAP_END; p++) { + if (p->type == BIOS_MAP_FREE) { + register int64_t sp = p->addr, ep = p->addr + p->size; + + /* can we eat it as a whole? */ + if ((sa - sp) <= PAGE_SIZE && (ep - ea) <= PAGE_SIZE) { + bcopy(p + 1, p, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)p); + break; + /* eat head or legs */ + } else if (sa <= sp && sp < ea) { + p->addr = ea; + p->size = ep - ea; + break; + } else if (sa < ep && ep <= ea) { + p->size = sa - sp; + break; + } else if (sp < sa && ea < ep) { + /* bite in half */ + bcopy(p, p + 1, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)p - + sizeof(bios_memmap[0])); + p[1].addr = ea; + p[1].size = ep - ea; + p->size = sa - sp; + break; + } + } + } + return 0; +} + +int +mem_add(long long sa, long long ea) +{ + register bios_memmap_t *p; + + for (p = bios_memmap; p->type != BIOS_MAP_END; p++) { + if (p->type == BIOS_MAP_FREE) { + register int64_t sp = p->addr, ep = p->addr + p->size; + + /* is it already there? */ + if (sp <= sa && ea <= ep) { + break; + /* join head or legs */ + } else if (sa < sp && sp <= ea) { + p->addr = sa; + p->size = ep - sa; + break; + } else if (sa <= ep && ep < ea) { + p->size = ea - sp; + break; + } else if (ea < sp) { + /* insert before */ + bcopy(p, p + 1, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)(p - 1)); + p->addr = sa; + p->size = ea - sa; + break; + } + } + } + + /* meaning add new item at the end of the list */ + if (p->type == BIOS_MAP_END) { + p[1] = p[0]; + p->type = BIOS_MAP_FREE; + p->addr = sa; + p->size = ea - sa; + } + + return 0; +} + +void +mem_pass(void) +{ + bios_memmap_t *p; + + for (p = bios_memmap; p->type != BIOS_MAP_END; p++) + ; + addbootarg(BOOTARG_MEMMAP, (p - bios_memmap + 1) * sizeof *bios_memmap, + bios_memmap); +} diff --git a/sys/arch/amd64/stand/libsa/cmd_i386.c b/sys/arch/amd64/stand/libsa/cmd_i386.c index 7be66cc234c..1f928af37f7 100644 --- a/sys/arch/amd64/stand/libsa/cmd_i386.c +++ b/sys/arch/amd64/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.13 2019/03/15 06:53:37 jsg Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.14 2019/05/10 21:20:43 mlarkin Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -37,11 +37,6 @@ #include "libsa.h" #include <cmd.h> -#ifdef EFIBOOT -#include "efiboot.h" -#include "efidev.h" -#endif - extern const char version[]; int Xboot(void); @@ -54,18 +49,10 @@ int Xregs(void); int bootbuf(void *, int); const struct cmd_table cmd_machine[] = { -#ifndef EFIBOOT { "boot", CMDT_CMD, Xboot }, -#endif { "comaddr", CMDT_CMD, Xcomaddr }, { "diskinfo", CMDT_CMD, Xdiskinfo }, { "memory", CMDT_CMD, Xmemory }, -#ifdef EFIBOOT - { "video", CMDT_CMD, Xvideo_efi }, - { "gop", CMDT_CMD, Xgop_efi }, - { "exit", CMDT_CMD, Xexit_efi }, - { "poweroff", CMDT_CMD, Xpoweroff_efi }, -#endif #ifdef DEBUG { "regs", CMDT_CMD, Xregs }, #endif @@ -75,11 +62,7 @@ const struct cmd_table cmd_machine[] = { int Xdiskinfo(void) { -#ifndef EFIBOOT dump_diskinfo(); -#else - efi_dump_diskinfo(); -#endif return 0; } @@ -92,7 +75,6 @@ Xregs(void) } #endif -#ifndef EFIBOOT int Xboot(void) { @@ -155,7 +137,6 @@ bad: printf("Invalid device!\n"); return 0; } -#endif int Xmemory(void) diff --git a/sys/arch/amd64/stand/libsa/dev_i386.c b/sys/arch/amd64/stand/libsa/dev_i386.c index 47f1c8b9dee..218b550814f 100644 --- a/sys/arch/amd64/stand/libsa/dev_i386.c +++ b/sys/arch/amd64/stand/libsa/dev_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_i386.c,v 1.22 2019/04/25 20:19:30 naddy Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.23 2019/05/10 21:20:43 mlarkin Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -78,16 +78,6 @@ devopen(struct open_file *f, const char *fname, char **file) #endif if ((rc = (*dp->dv_open)(f, file)) == 0) { f->f_dev = dp; -#ifdef EFIBOOT - if (strcmp("TFTP", dp->dv_name) != 0) { - /* - * Clear bootmac, to signal that we loaded - * this file from a non-network device. - */ - extern char *bootmac; - bootmac = NULL; - } -#endif return 0; } #ifdef DEBUG @@ -118,17 +108,6 @@ devboot(dev_t bootdev, char *p) int sr_boot_vol = -1; int part_type = FS_UNUSED; -#ifdef EFIBOOT - if (!bootdev) { - *p++ = 't'; - *p++ = 'f'; - *p++ = 't'; - *p++ = 'p'; - *p = '\0'; - return; - } -#endif - #ifdef SOFTRAID /* * Determine the partition type for the 'a' partition of the diff --git a/sys/arch/amd64/stand/libsa/diskprobe.c b/sys/arch/amd64/stand/libsa/diskprobe.c index 1d3351768fa..10bd0fb4167 100644 --- a/sys/arch/amd64/stand/libsa/diskprobe.c +++ b/sys/arch/amd64/stand/libsa/diskprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskprobe.c,v 1.23 2018/06/18 15:37:48 krw Exp $ */ +/* $OpenBSD: diskprobe.c,v 1.24 2019/05/10 21:20:43 mlarkin Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -47,9 +47,6 @@ #ifdef SOFTRAID #include "softraid_amd64.h" #endif -#ifdef EFIBOOT -#include "efidev.h" -#endif #define MAX_CKSUMLEN MAXBSIZE / DEV_BSIZE /* Max # of blks to cksum */ @@ -68,7 +65,6 @@ extern int debug; extern int bios_bootdev; extern int bios_cddev; -#ifndef EFIBOOT static void diskinfo_init(struct diskinfo *dip) { @@ -180,77 +176,6 @@ 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, atapi = 0; - extern struct disklist_lh - efi_disklist; - - n = 0; - TAILQ_FOREACH_SAFE(dip, &efi_disklist, list, dipt) { - TAILQ_REMOVE(&efi_disklist, dip, list); - n = scsi + ide; - - /* Try to find the label, to figure out device type */ - if ((efi_getdisklabel(dip->efi_info, &dip->disklabel))) { - type = 0; - printf(" hd%d*", n); - 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; - - case DTYPE_ATAPI: - type = 6; - n = atapi; - bsdunit = atapi++; - dip->bios_info.flags |= BDI_GOODLABEL - | BDI_EL_TORITO; - break; - - default: - dip->bios_info.flags |= BDI_BADLABEL; - type = 0; /* XXX Suggest IDE */ - bsdunit = ide++; - } - printf(" %cd%d", (type == 6)? 'c' : 'h', n); - } - if (type != 6) - dip->bios_info.bios_number = 0x80 | n; - else - dip->bios_info.bios_number = 0xe0 | n; - - dip->bios_info.checksum = 0; /* just in case */ - /* Fill out best we can */ - dip->bsddev = dip->bios_info.bsd_dev = - MAKEBOOTDEV(type, 0, 0, bsdunit, RAW_PART); - check_hibernate(dip); - - /* Add to queue of disks */ - TAILQ_INSERT_TAIL(&disklist, dip, list); - n++; - } -} -#endif /* Probe for all BIOS supported disks */ u_int32_t bios_cksumlen; @@ -266,7 +191,6 @@ diskprobe(void) /* Init stuff */ TAILQ_INIT(&disklist); -#ifndef EFIBOOT /* Do probes */ floppyprobe(); #ifdef BIOS_DEBUG @@ -274,9 +198,6 @@ diskprobe(void) printf(";"); #endif hardprobe(); -#else - efi_hardprobe(); -#endif #ifdef SOFTRAID srprobe(); @@ -305,7 +226,6 @@ diskprobe(void) bios_diskinfo); } -#ifndef EFIBOOT void cdprobe(void) { @@ -375,8 +295,6 @@ cdprobe(void) /* Add to queue of disks */ TAILQ_INSERT_TAIL(&disklist, dip, list); } -#endif - /* Find info on given BIOS disk */ struct diskinfo * diff --git a/sys/arch/amd64/stand/libsa/exec_i386.c b/sys/arch/amd64/stand/libsa/exec_i386.c index 9ee32ac6443..4b6aed12123 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.28 2019/04/20 23:00:07 deraadt Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.29 2019/05/10 21:20:43 mlarkin Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -46,10 +46,6 @@ #include "softraid_amd64.h" #endif -#ifdef EFIBOOT -#include "efiboot.h" -#endif - typedef void (*startfuncp)(int, int, int, int, int, int, int, int) __attribute__ ((noreturn)); @@ -78,16 +74,6 @@ run_loadfile(uint64_t *marks, int howto) bios_bootsr_t bootsr; struct sr_boot_volume *bv; #endif -#ifdef EFIBOOT - int i; - u_long delta; - extern u_long efi_loadaddr; - - if ((av = alloc(ac)) == NULL) - panic("alloc for bootarg"); - efi_makebootargs(); - delta = DEFAULT_KERNEL_ADDRESS - efi_loadaddr; -#endif if (sa_cleanup != NULL) (*sa_cleanup)(); @@ -126,48 +112,18 @@ run_loadfile(uint64_t *marks, int howto) #endif entry = marks[MARK_ENTRY] & 0x0fffffff; -#ifdef EFIBOOT - entry += delta; -#endif printf("entry point at 0x%lx\n", entry); -#ifdef EFIBOOT - /* Sync the memory map and call ExitBootServices() */ - efi_cleanup(); -#endif /* Pass memory map to the kernel */ mem_pass(); - /* - * This code may be used both for 64bit and 32bit. Make sure the - * bootarg is always 32bit, even on amd64. - */ -#ifdef __amd64__ - makebootargs32(av, &ac); -#else makebootargs(av, &ac); -#endif - -#ifdef EFIBOOT - /* - * Move the loaded kernel image to the usual place after calling - * ExitBootServices(). - */ - memmove((void *)marks[MARK_START] + delta, (void *)marks[MARK_START], - marks[MARK_END] - marks[MARK_START]); - for (i = 0; i < MARK_MAX; i++) - marks[i] += delta; -#endif -#ifdef __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); -#endif + /* not reached */ } diff --git a/sys/arch/amd64/stand/libsa/machdep.c b/sys/arch/amd64/stand/libsa/machdep.c index 246cda51cd8..22d9499c049 100644 --- a/sys/arch/amd64/stand/libsa/machdep.c +++ b/sys/arch/amd64/stand/libsa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.7 2018/07/11 14:48:40 mlarkin Exp $ */ +/* $OpenBSD: machdep.c,v 1.8 2019/05/10 21:20:43 mlarkin Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -34,10 +34,6 @@ #include <machine/specialreg.h> #include <machine/vmmvar.h> -#ifdef EFIBOOT -#include "efiboot.h" -#endif - volatile struct BIOS_regs BIOS_regs; #if defined(DEBUG) @@ -93,9 +89,5 @@ 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/amd64/stand/libsa/memprobe.c b/sys/arch/amd64/stand/libsa/memprobe.c index 302eea718b0..67ff6cee00b 100644 --- a/sys/arch/amd64/stand/libsa/memprobe.c +++ b/sys/arch/amd64/stand/libsa/memprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memprobe.c,v 1.17 2016/06/10 18:36:06 jcs Exp $ */ +/* $OpenBSD: memprobe.c,v 1.18 2019/05/10 21:20:43 mlarkin Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -37,7 +37,6 @@ u_int cnvmem, extmem; /* XXX - compatibility */ bios_memmap_t bios_memmap[64]; /* This is easier */ -#ifndef EFIBOOT /* * Check gateA20 * @@ -146,7 +145,6 @@ bios_int12(bios_memmap_t *mp) return ++mp; } - /* * addrprobe(kloc): Probe memory at address kloc * 1024. * @@ -311,7 +309,6 @@ memprobe(void) /* Check if gate A20 is on */ printf("a20=o%s] ", checkA20()? "n" : "ff!"); } -#endif void dump_biosmem(bios_memmap_t *tm) |