Tue Aug 15 06:27:40 2017 UTC ()
Merge into x86/.
(maxv)
diff -r1.23 -r0 src/sys/arch/amd64/amd64/bios32.c
diff -r1.90 -r1.91 src/sys/arch/amd64/conf/files.amd64
diff -r1.385 -r1.386 src/sys/arch/i386/conf/files.i386
diff -r1.32 -r0 src/sys/arch/i386/i386/bios32.c
diff -r1.88 -r1.89 src/sys/arch/x86/conf/files.x86
diff -r0 -r1.1 src/sys/arch/x86/x86/bios32.c
diff -r1.154 -r1.155 src/sys/arch/xen/conf/files.xen
--- src/sys/arch/amd64/conf/files.amd64 2017/08/01 13:47:49 1.90
+++ src/sys/arch/amd64/conf/files.amd64 2017/08/15 06:27:40 1.91
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.amd64,v 1.90 2017/08/01 13:47:49 maxv Exp $ | | 1 | # $NetBSD: files.amd64,v 1.91 2017/08/15 06:27:40 maxv Exp $ |
2 | # | | 2 | # |
3 | # new style config file for amd64 architecture | | 3 | # new style config file for amd64 architecture |
4 | # | | 4 | # |
5 | | | 5 | |
6 | ifndef xen | | 6 | ifndef xen |
7 | | | 7 | |
8 | # maxpartitions must be first item in files.${ARCH}.newconf | | 8 | # maxpartitions must be first item in files.${ARCH}.newconf |
9 | maxpartitions 16 | | 9 | maxpartitions 16 |
10 | | | 10 | |
11 | maxusers 2 16 128 | | 11 | maxusers 2 16 128 |
12 | | | 12 | |
13 | # delay before cpu_reset() for reboot. | | 13 | # delay before cpu_reset() for reboot. |
14 | defparam CPURESET_DELAY | | 14 | defparam CPURESET_DELAY |
| @@ -74,30 +74,26 @@ include "dev/scsipi/files.scsipi" | | | @@ -74,30 +74,26 @@ include "dev/scsipi/files.scsipi" |
74 | # | | 74 | # |
75 | | | 75 | |
76 | include "dev/ata/files.ata" | | 76 | include "dev/ata/files.ata" |
77 | | | 77 | |
78 | # Memory Disk for install floppy | | 78 | # Memory Disk for install floppy |
79 | file dev/md_root.c memory_disk_hooks | | 79 | file dev/md_root.c memory_disk_hooks |
80 | | | 80 | |
81 | # | | 81 | # |
82 | # Machine-independent I2O drivers | | 82 | # Machine-independent I2O drivers |
83 | # | | 83 | # |
84 | | | 84 | |
85 | include "dev/i2o/files.i2o" | | 85 | include "dev/i2o/files.i2o" |
86 | | | 86 | |
87 | # BIOS32 routines | | | |
88 | define bios32 | | | |
89 | file arch/amd64/amd64/bios32.c bios32 needs-flag | | | |
90 | | | | |
91 | # | | 87 | # |
92 | # System bus types | | 88 | # System bus types |
93 | # | | 89 | # |
94 | | | 90 | |
95 | # XXX BIOS32 only if something that uses it is configured! | | 91 | # XXX BIOS32 only if something that uses it is configured! |
96 | device mainbus: isabus, pcibus, bios32, acpibus, cpubus, ioapicbus, ipmibus | | 92 | device mainbus: isabus, pcibus, bios32, acpibus, cpubus, ioapicbus, ipmibus |
97 | attach mainbus at root | | 93 | attach mainbus at root |
98 | file arch/amd64/amd64/mainbus.c mainbus | | 94 | file arch/amd64/amd64/mainbus.c mainbus |
99 | | | 95 | |
100 | # | | 96 | # |
101 | # PCI-only drivers | | 97 | # PCI-only drivers |
102 | # XXX MUST BE INCLUDED BEFORE files.isa, as long as files.isa attaches | | 98 | # XXX MUST BE INCLUDED BEFORE files.isa, as long as files.isa attaches |
103 | # XXX devices to 'pci'. | | 99 | # XXX devices to 'pci'. |
--- src/sys/arch/i386/conf/files.i386 2017/08/12 06:46:13 1.385
+++ src/sys/arch/i386/conf/files.i386 2017/08/15 06:27:40 1.386
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.i386,v 1.385 2017/08/12 06:46:13 maxv Exp $ | | 1 | # $NetBSD: files.i386,v 1.386 2017/08/15 06:27:40 maxv Exp $ |
2 | # | | 2 | # |
3 | # new style config file for i386 architecture | | 3 | # new style config file for i386 architecture |
4 | # | | 4 | # |
5 | | | 5 | |
6 | ifndef xen | | 6 | ifndef xen |
7 | | | 7 | |
8 | # maxpartitions must be first item in files.${ARCH}.newconf | | 8 | # maxpartitions must be first item in files.${ARCH}.newconf |
9 | maxpartitions 8 | | 9 | maxpartitions 8 |
10 | | | 10 | |
11 | maxusers 2 16 128 | | 11 | maxusers 2 16 128 |
12 | | | 12 | |
13 | defparam opt_kernbase.h KERNBASE | | 13 | defparam opt_kernbase.h KERNBASE |
14 | | | 14 | |
| @@ -107,30 +107,26 @@ include "dev/ata/files.ata" | | | @@ -107,30 +107,26 @@ include "dev/ata/files.ata" |
107 | file dev/md_root.c memory_disk_hooks & md | | 107 | file dev/md_root.c memory_disk_hooks & md |
108 | | | 108 | |
109 | # | | 109 | # |
110 | # Machine-independent I2O drivers | | 110 | # Machine-independent I2O drivers |
111 | # | | 111 | # |
112 | | | 112 | |
113 | include "dev/i2o/files.i2o" | | 113 | include "dev/i2o/files.i2o" |
114 | | | 114 | |
115 | # attribute used to bring in BIOS trampoline code for real-mode probing | | 115 | # attribute used to bring in BIOS trampoline code for real-mode probing |
116 | # of certain devices/BIOS features | | 116 | # of certain devices/BIOS features |
117 | define bioscall | | 117 | define bioscall |
118 | file arch/i386/i386/bioscall.S bioscall needs-flag | | 118 | file arch/i386/i386/bioscall.S bioscall needs-flag |
119 | | | 119 | |
120 | # BIOS32 routines | | | |
121 | define bios32 | | | |
122 | file arch/i386/i386/bios32.c bios32 needs-flag | | | |
123 | | | | |
124 | # i386 specific mainbus attributes | | 120 | # i386 specific mainbus attributes |
125 | define apmbus {} | | 121 | define apmbus {} |
126 | define pnpbiosbus {} | | 122 | define pnpbiosbus {} |
127 | | | 123 | |
128 | # | | 124 | # |
129 | # System bus types | | 125 | # System bus types |
130 | # | | 126 | # |
131 | | | 127 | |
132 | # XXX BIOS32 only if something that uses it is configured! | | 128 | # XXX BIOS32 only if something that uses it is configured! |
133 | device mainbus: isabus, eisabus, mcabus, pcibus, bios32, acpibus, | | 129 | device mainbus: isabus, eisabus, mcabus, pcibus, bios32, acpibus, |
134 | cpubus, ioapicbus, apmbus, pnpbiosbus, ipmibus, | | 130 | cpubus, ioapicbus, apmbus, pnpbiosbus, ipmibus, |
135 | bioscall | | 131 | bioscall |
136 | attach mainbus at root | | 132 | attach mainbus at root |
--- src/sys/arch/x86/conf/files.x86 2017/03/10 14:40:56 1.88
+++ src/sys/arch/x86/conf/files.x86 2017/08/15 06:27:40 1.89
| @@ -1,36 +1,40 @@ | | | @@ -1,36 +1,40 @@ |
1 | # $NetBSD: files.x86,v 1.88 2017/03/10 14:40:56 maxv Exp $ | | 1 | # $NetBSD: files.x86,v 1.89 2017/08/15 06:27:40 maxv Exp $ |
2 | | | 2 | |
3 | # options for MP configuration through the MP spec | | 3 | # options for MP configuration through the MP spec |
4 | defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI | | 4 | defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI |
5 | | | 5 | |
6 | # MTRR support | | 6 | # MTRR support |
7 | defflag MTRR | | 7 | defflag MTRR |
8 | | | 8 | |
9 | # Interrupt debug | | 9 | # Interrupt debug |
10 | defflag opt_intrdebug.h INTRDEBUG | | 10 | defflag opt_intrdebug.h INTRDEBUG |
11 | | | 11 | |
12 | # PCI fixup options | | 12 | # PCI fixup options |
13 | defflag opt_pcifixup.h PCI_ADDR_FIXUP PCI_BUS_FIXUP | | 13 | defflag opt_pcifixup.h PCI_ADDR_FIXUP PCI_BUS_FIXUP |
14 | PCI_INTR_FIXUP PCI_INTR_FIXUP_FORCE | | 14 | PCI_INTR_FIXUP PCI_INTR_FIXUP_FORCE |
15 | | | 15 | |
16 | # To be able to test for NetBSD/xen in shared files | | 16 | # To be able to test for NetBSD/xen in shared files |
17 | defflag opt_xen.h DO_NOT_DEFINE | | 17 | defflag opt_xen.h DO_NOT_DEFINE |
18 | | | 18 | |
19 | define cpubus { [apid = -1] } | | 19 | define cpubus { [apid = -1] } |
20 | define cpufeaturebus {} | | 20 | define cpufeaturebus {} |
21 | define ioapicbus { [apid = -1] } | | 21 | define ioapicbus { [apid = -1] } |
22 | define ipmibus {} | | 22 | define ipmibus {} |
23 | | | 23 | |
| | | 24 | # BIOS32 routines |
| | | 25 | define bios32 |
| | | 26 | file arch/x86/x86/bios32.c bios32 needs-flag |
| | | 27 | |
24 | # | | 28 | # |
25 | # CPU features | | 29 | # CPU features |
26 | # | | 30 | # |
27 | device cpu: cpufeaturebus | | 31 | device cpu: cpufeaturebus |
28 | attach cpu at cpubus | | 32 | attach cpu at cpubus |
29 | file arch/x86/x86/cpu.c cpu | | 33 | file arch/x86/x86/cpu.c cpu |
30 | file arch/x86/x86/cpu_rng.c cpu | | 34 | file arch/x86/x86/cpu_rng.c cpu |
31 | | | 35 | |
32 | device acpicpu: acpi | | 36 | device acpicpu: acpi |
33 | attach acpicpu at cpufeaturebus | | 37 | attach acpicpu at cpufeaturebus |
34 | file dev/acpi/acpi_cpu.c acpicpu | | 38 | file dev/acpi/acpi_cpu.c acpicpu |
35 | file dev/acpi/acpi_cpu_cstate.c acpicpu | | 39 | file dev/acpi/acpi_cpu_cstate.c acpicpu |
36 | file dev/acpi/acpi_cpu_pstate.c acpicpu | | 40 | file dev/acpi/acpi_cpu_pstate.c acpicpu |
/* $NetBSD: bios32.c,v 1.1 2017/08/15 06:27:40 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.
*/
/*
* Copyright (c) 1997-2001 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.
*/
/*
* Basic interface to BIOS32 services.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.1 2017/08/15 06:27:40 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)
{
uint8_t *p;
#ifdef i386
paddr_t entry = 0;
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), (u_long)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
/* 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)
{
#ifdef i386
uint32_t eax, ebx, ecx, edx;
paddr_t entry;
if (bios32_entry.offset == 0)
return (0); /* BIOS32 not present */
__asm volatile("lcall *(%%edi)"
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "0" (service), "1" (0), "D" (&bios32_entry));
if ((eax & 0xff) != 0)
return (0); /* service not found */
entry = ebx + edx;
if (entry < BIOS32_START || entry >= BIOS32_END) {
aprint_error("BIOS32: entry point for service %c%c%c%c is "
"outside allowable range\n",
service & 0xff,
(service >> 8) & 0xff,
(service >> 16) & 0xff,
(service >> 24) & 0xff);
return (0);
}
e->offset = (void *)ISA_HOLE_VADDR(entry);
e->segment = GSEL(GCODE_SEL, SEL_KPL);
ei->bei_base = ebx;
ei->bei_size = ecx;
ei->bei_entry = entry;
#else
(void)service;
(void)e;
(void)ei;
panic("bios32_service not implemented on amd64");
#endif
return (1);
}
/*
* smbios_find_table() takes a caller supplied smbios struct type and
* a pointer to a handle (struct smbtable) returning one if the structure
* is sucessfully located and zero otherwise. Callers should take care
* to initilize the cookie field of the smbtable structure to zero before
* the first invocation of this function.
* Multiple tables of the same type can be located by repeadtly calling
* smbios_find_table with the same arguments.
*/
int
smbios_find_table(uint8_t type, struct smbtable *st)
{
uint8_t *va, *end;
struct smbtblhdr *hdr;
int ret = 0, tcount = 1;
va = smbios_entry.addr;
end = va + smbios_entry.len;
/*
* The cookie field of the smtable structure is used to locate
* multiple instances of a table of an arbitrary type. Following the
* sucessful location of a table, the type is encoded as bits 0:7 of
* the cookie value, the offset in terms of the number of structures
* preceding that referenced by the handle is encoded in bits 15:31.
*/
if ((st->cookie & 0xfff) == type && st->cookie >> 16) {
if ((uint8_t *)st->hdr >= va && (uint8_t *)st->hdr < end) {
hdr = st->hdr;
if (hdr->type == type) {
va = (uint8_t *)hdr + hdr->size;
for (; va + 1 < end; va++)
if (*va == 0 && *(va + 1) == 0)
break;
va+= 2;
tcount = st->cookie >> 16;
}
}
}
for (; va + sizeof(struct smbtblhdr) < end && tcount <=
smbios_entry.count; tcount++) {
hdr = (struct smbtblhdr *)va;
if (hdr->type == type) {
ret = 1;
st->hdr = hdr;
st->tblhdr = va + sizeof(struct smbtblhdr);
st->cookie = (tcount + 1) << 16 | type;
break;
}
if (hdr->type == SMBIOS_TYPE_EOT)
break;
va+= hdr->size;
for (; va + 1 < end; va++)
if (*va == 0 && *(va + 1) == 0)
break;
va+=2;
}
return ret;
}
char *
smbios_get_string(struct smbtable *st, uint8_t indx, char *dest, size_t len)
{
uint8_t *va, *end;
char *ret = NULL;
int i;
va = (uint8_t *)st->hdr + st->hdr->size;
end = smbios_entry.addr + smbios_entry.len;
for (i = 1; va < end && i < indx && *va; i++)
while (*va++)
;
if (i == indx) {
if (va + len < end) {
ret = dest;
memcpy(ret, va, len);
ret[len - 1] = '\0';
}
}
return ret;
}
--- src/sys/arch/xen/conf/files.xen 2017/08/12 07:21:57 1.154
+++ src/sys/arch/xen/conf/files.xen 2017/08/15 06:27:39 1.155
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.xen,v 1.154 2017/08/12 07:21:57 maxv Exp $ | | 1 | # $NetBSD: files.xen,v 1.155 2017/08/15 06:27:39 maxv Exp $ |
2 | # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp | | 2 | # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp |
3 | # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp | | 3 | # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp |
4 | | | 4 | |
5 | ifdef i386 | | 5 | ifdef i386 |
6 | maxpartitions 8 | | 6 | maxpartitions 8 |
7 | else | | 7 | else |
8 | maxpartitions 16 | | 8 | maxpartitions 16 |
9 | endif | | 9 | endif |
10 | | | 10 | |
11 | maxusers 2 16 128 | | 11 | maxusers 2 16 128 |
12 | | | 12 | |
13 | defparam opt_kernbase.h KERNBASE | | 13 | defparam opt_kernbase.h KERNBASE |
14 | | | 14 | |
| @@ -142,31 +142,27 @@ file arch/x86/x86/pmap.c machdep | | | @@ -142,31 +142,27 @@ file arch/x86/x86/pmap.c machdep |
142 | file arch/x86/x86/pmap_tlb.c machdep | | 142 | file arch/x86/x86/pmap_tlb.c machdep |
143 | file arch/x86/x86/procfs_machdep.c procfs | | 143 | file arch/x86/x86/procfs_machdep.c procfs |
144 | file arch/x86/x86/sys_machdep.c machdep | | 144 | file arch/x86/x86/sys_machdep.c machdep |
145 | file arch/x86/x86/tsc.c machdep | | 145 | file arch/x86/x86/tsc.c machdep |
146 | file arch/x86/x86/vm_machdep.c machdep | | 146 | file arch/x86/x86/vm_machdep.c machdep |
147 | file arch/x86/x86/x86_machdep.c machdep | | 147 | file arch/x86/x86/x86_machdep.c machdep |
148 | file arch/x86/x86/cpu_topology.c machdep | | 148 | file arch/x86/x86/cpu_topology.c machdep |
149 | file arch/x86/x86/platform.c machdep | | 149 | file arch/x86/x86/platform.c machdep |
150 | | | 150 | |
151 | include "arch/xen/conf/files.compat" | | 151 | include "arch/xen/conf/files.compat" |
152 | | | 152 | |
153 | # BIOS32 routines | | 153 | # BIOS32 routines |
154 | define bios32 | | 154 | define bios32 |
155 | ifdef i386 | | 155 | file arch/x86/x86/bios32.c bios32 needs-flag |
156 | file arch/i386/i386/bios32.c bios32 needs-flag | | | |
157 | elifdef amd64 | | | |
158 | file arch/amd64/amd64/bios32.c bios32 needs-flag | | | |
159 | endif | | | |
160 | | | 156 | |
161 | # xen specific mainbus attributes | | 157 | # xen specific mainbus attributes |
162 | define cpubus { [apid = -1] } | | 158 | define cpubus { [apid = -1] } |
163 | define cpufeaturebus {} | | 159 | define cpufeaturebus {} |
164 | define ioapicbus { [apid = -1] } | | 160 | define ioapicbus { [apid = -1] } |
165 | define apmbus {} | | 161 | define apmbus {} |
166 | define pnpbiosbus {} | | 162 | define pnpbiosbus {} |
167 | define hypervisorbus {} | | 163 | define hypervisorbus {} |
168 | define xendevbus {} | | 164 | define xendevbus {} |
169 | define ipmibus {} | | 165 | define ipmibus {} |
170 | | | 166 | |
171 | # | | 167 | # |
172 | # System bus types | | 168 | # System bus types |