Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Merge into x86/.
details: https://anonhg.NetBSD.org/src/rev/e6dd19d1f993
branches: trunk
changeset: 355790:e6dd19d1f993
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Aug 15 06:27:39 2017 +0000
description:
Merge into x86/.
diffstat:
sys/arch/amd64/amd64/bios32.c | 381 ----------------------------------
sys/arch/amd64/conf/files.amd64 | 6 +-
sys/arch/i386/conf/files.i386 | 6 +-
sys/arch/i386/i386/bios32.c | 436 ---------------------------------------
sys/arch/x86/conf/files.x86 | 6 +-
sys/arch/x86/x86/bios32.c | 440 ++++++++++++++++++++++++++++++++++++++++
sys/arch/xen/conf/files.xen | 8 +-
7 files changed, 449 insertions(+), 834 deletions(-)
diffs (truncated from 1351 to 300 lines):
diff -r 1e754afc5fd1 -r e6dd19d1f993 sys/arch/amd64/amd64/bios32.c
--- a/sys/arch/amd64/amd64/bios32.c Tue Aug 15 06:04:28 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,381 +0,0 @@
-/* $NetBSD: bios32.c,v 1.23 2017/08/15 06:04:28 maxv Exp $ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
-
-/*
- * Copyright (c) 1999, by UCHIYAMA Yasushi
- * 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. The name of the developer may NOT be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- */
-
-/*
- * Basic interface to BIOS32 services.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.23 2017/08/15 06:04:28 maxv Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-
-#include <dev/isa/isareg.h>
-#include <machine/isa_machdep.h>
-
-#include <machine/segments.h>
-#include <machine/bios32.h>
-#include <x86/smbiosvar.h>
-#include <x86/efi.h>
-
-#include <uvm/uvm.h>
-
-#include "ipmi.h"
-#include "opt_xen.h"
-
-#define BIOS32_START 0xe0000
-#define BIOS32_SIZE 0x20000
-#define BIOS32_END (BIOS32_START + BIOS32_SIZE - 0x10)
-
-struct bios32_entry bios32_entry;
-struct smbios_entry smbios_entry;
-
-static int smbios2_check_header(const uint8_t *);
-static void smbios2_map_kva(const uint8_t *);
-static int smbios3_check_header(const uint8_t *);
-static void smbios3_map_kva(const uint8_t *);
-
-/*
- * Initialize the BIOS32 interface.
- */
-void
-bios32_init(void)
-{
-#if 0 /* XXXfvdl need to set up compatibility segment for this */
- paddr_t entry = 0;
- uint8_t *p;
- unsigned char cksum;
- int i;
-
- for (p = (uint8_t *)ISA_HOLE_VADDR(BIOS32_START);
- p < (uint8_t *)ISA_HOLE_VADDR(BIOS32_END);
- p += 16) {
- if (*(int *)p != BIOS32_MAKESIG('_', '3', '2', '_'))
- continue;
-
- cksum = 0;
- for (i = 0; i < 16; i++)
- cksum += *(unsigned char *)(p + i);
- if (cksum != 0)
- continue;
-
- if (*(p + 9) != 1)
- continue;
-
- entry = *(uint32_t *)(p + 4);
-
- aprint_debug("BIOS32 rev. %d found at 0x%lx\n",
- *(p + 8), entry);
-
- if (entry < BIOS32_START ||
- entry >= BIOS32_END) {
- aprint_error("BIOS32 entry point outside "
- "allowable range\n");
- entry = 0;
- }
- break;
- }
-
- if (entry != 0) {
- bios32_entry.offset = (void *)ISA_HOLE_VADDR(entry);
- bios32_entry.segment = GSEL(GCODE_SEL, SEL_KPL);
- }
-#endif
- uint8_t *p;
-
- /* see if we have SMBIOS extensions */
-#ifndef XEN
- if (efi_probe()) {
- p = efi_getcfgtbl(&EFI_UUID_SMBIOS3);
- if (p != NULL && smbios3_check_header(p)) {
- smbios3_map_kva(p);
- return;
- }
- p = efi_getcfgtbl(&EFI_UUID_SMBIOS);
- if (p != NULL && smbios2_check_header(p)) {
- smbios2_map_kva(p);
- return;
- }
- }
-#endif
- for (p = ISA_HOLE_VADDR(SMBIOS_START);
- p < (uint8_t *)ISA_HOLE_VADDR(SMBIOS_END); p+= 16) {
- if (smbios3_check_header(p)) {
- smbios3_map_kva(p);
- return;
- }
- if (smbios2_check_header(p)) {
- smbios2_map_kva(p);
- return;
- }
- }
-}
-
-static int
-smbios2_check_header(const uint8_t *p)
-{
- const struct smbhdr *sh = (const struct smbhdr *)p;
- uint8_t chksum;
- int i;
-
- if (sh->sig != BIOS32_MAKESIG('_', 'S', 'M', '_'))
- return 0;
- i = sh->len;
- for (chksum = 0; i--; )
- chksum += p[i];
- if (chksum != 0)
- return 0;
- p += 0x10;
- if (p[0] != '_' || p[1] != 'D' || p[2] != 'M' ||
- p[3] != 'I' || p[4] != '_')
- return 0;
- for (chksum = 0, i = 0xf; i--; )
- chksum += p[i];
- if (chksum != 0)
- return 0;
-
- return 1;
-}
-
-static void
-smbios2_map_kva(const uint8_t *p)
-{
- const struct smbhdr *sh = (const struct smbhdr *)p;
- paddr_t pa, end;
- vaddr_t eva;
-
- pa = trunc_page(sh->addr);
- end = round_page(sh->addr + sh->size);
- eva = uvm_km_alloc(kernel_map, end - pa, 0, UVM_KMF_VAONLY);
- if (eva == 0)
- return;
-
- smbios_entry.addr = (uint8_t *)(eva + (sh->addr & PGOFSET));
- smbios_entry.len = sh->size;
- smbios_entry.rev = 0;
- smbios_entry.mjr = sh->majrev;
- smbios_entry.min = sh->minrev;
- smbios_entry.doc = 0;
- smbios_entry.count = sh->count;
-
- for (; pa < end; pa+= NBPG, eva+= NBPG)
-#ifdef XEN
- pmap_kenter_ma(eva, pa, VM_PROT_READ, 0);
-#else
- pmap_kenter_pa(eva, pa, VM_PROT_READ, 0);
-#endif
- pmap_update(pmap_kernel());
-
- aprint_debug("SMBIOS rev. %d.%d @ 0x%lx (%d entries)\n",
- sh->majrev, sh->minrev, (u_long)sh->addr,
- sh->count);
-}
-
-static int
-smbios3_check_header(const uint8_t *p)
-{
- const struct smb3hdr *sh = (const struct smb3hdr *)p;
- uint8_t chksum;
- int i;
-
- if (p[0] != '_' || p[1] != 'S' || p[2] != 'M' ||
- p[3] != '3' || p[4] != '_')
- return 0;
- i = sh->len;
- for (chksum = 0; i--; )
- chksum += p[i];
- if (chksum != 0)
- return 0;
- if (sh->eprev != SMBIOS3_EPREV_3_0)
- return 0;
-
- return 1;
-}
-
-static void
-smbios3_map_kva(const uint8_t *p)
-{
- const struct smb3hdr *sh = (const struct smb3hdr *)p;
- paddr_t pa, end;
- vaddr_t eva;
-
- pa = trunc_page(sh->addr);
- end = round_page(sh->addr + sh->size);
- eva = uvm_km_alloc(kernel_map, end - pa, 0, UVM_KMF_VAONLY);
- if (eva == 0)
- return;
-
- smbios_entry.addr = (uint8_t *)(eva + ((vaddr_t)sh->addr & PGOFSET));
- smbios_entry.len = sh->size;
- smbios_entry.rev = sh->eprev;
- smbios_entry.mjr = sh->majrev;
- smbios_entry.min = sh->minrev;
- smbios_entry.doc = sh->docrev;
- smbios_entry.count = UINT16_MAX;
-
- for (; pa < end; pa += NBPG, eva += NBPG)
-#ifdef XEN
- pmap_kenter_ma(eva, pa, VM_PROT_READ, 0);
-#else
- pmap_kenter_pa(eva, pa, VM_PROT_READ, 0);
-#endif
- pmap_update(pmap_kernel());
-
- aprint_debug("SMBIOS rev. %d.%d.%d @ 0x%lx\n",
- sh->majrev, sh->minrev, sh->docrev, (u_long)sh->addr);
-}
-
-/*
- * Call BIOS32 to locate the specified BIOS32 service, and fill
- * in the entry point information.
- */
-int
-bios32_service(uint32_t service, bios32_entry_t e, bios32_entry_info_t ei)
-{
- (void)service;
- (void)e;
- (void)ei;
- panic("bios32_service not implemented on amd64");
-
- return (1);
Home |
Main Index |
Thread Index |
Old Index