Sat Jul 24 20:45:45 2021 UTC ()
Build fix: vtophys takes vaddr_t, not a ptr


(jmcneill)
diff -r1.6 -r1.7 src/sys/arch/x86/x86/bios32.c

cvs diff -r1.6 -r1.7 src/sys/arch/x86/x86/bios32.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/bios32.c 2021/07/24 11:39:19 1.6
+++ src/sys/arch/x86/x86/bios32.c 2021/07/24 20:45:45 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bios32.c,v 1.6 2021/07/24 11:39:19 jmcneill Exp $ */ 1/* $NetBSD: bios32.c,v 1.7 2021/07/24 20:45:45 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -76,27 +76,27 @@ @@ -76,27 +76,27 @@
76 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 76 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
77 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 77 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
78 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 78 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
79 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 79 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
80 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 80 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
81 * THE POSSIBILITY OF SUCH DAMAGE. 81 * THE POSSIBILITY OF SUCH DAMAGE.
82 */ 82 */
83 83
84/* 84/*
85 * Basic interface to BIOS32 services. 85 * Basic interface to BIOS32 services.
86 */ 86 */
87 87
88#include <sys/cdefs.h> 88#include <sys/cdefs.h>
89__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.6 2021/07/24 11:39:19 jmcneill Exp $"); 89__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.7 2021/07/24 20:45:45 jmcneill Exp $");
90 90
91#include <sys/param.h> 91#include <sys/param.h>
92#include <sys/systm.h> 92#include <sys/systm.h>
93#include <sys/device.h> 93#include <sys/device.h>
94 94
95#include <dev/isa/isareg.h> 95#include <dev/isa/isareg.h>
96#include <machine/isa_machdep.h> 96#include <machine/isa_machdep.h>
97 97
98#include <machine/segments.h> 98#include <machine/segments.h>
99#include <machine/bios32.h> 99#include <machine/bios32.h>
100#include <dev/smbiosvar.h> 100#include <dev/smbiosvar.h>
101#include <x86/smbios_machdep.h> 101#include <x86/smbios_machdep.h>
102#include <x86/efi.h> 102#include <x86/efi.h>
@@ -242,27 +242,27 @@ bios32_service(uint32_t service, bios32_ @@ -242,27 +242,27 @@ bios32_service(uint32_t service, bios32_
242static void 242static void
243smbios2_map_kva(const uint8_t *p) 243smbios2_map_kva(const uint8_t *p)
244{ 244{
245 const struct smbhdr *sh = (const struct smbhdr *)p; 245 const struct smbhdr *sh = (const struct smbhdr *)p;
246 paddr_t pa, end; 246 paddr_t pa, end;
247 vaddr_t eva; 247 vaddr_t eva;
248 248
249 pa = trunc_page(sh->addr); 249 pa = trunc_page(sh->addr);
250 end = round_page(sh->addr + sh->size); 250 end = round_page(sh->addr + sh->size);
251 eva = uvm_km_alloc(kernel_map, end - pa, 0, UVM_KMF_VAONLY); 251 eva = uvm_km_alloc(kernel_map, end - pa, 0, UVM_KMF_VAONLY);
252 if (eva == 0) 252 if (eva == 0)
253 return; 253 return;
254 254
255 smbios_entry.hdrphys = vtophys(p); 255 smbios_entry.hdrphys = vtophys((vaddr_t)p);
256 smbios_entry.tabphys = sh->addr; 256 smbios_entry.tabphys = sh->addr;
257 smbios_entry.addr = (uint8_t *)(eva + (sh->addr & PGOFSET)); 257 smbios_entry.addr = (uint8_t *)(eva + (sh->addr & PGOFSET));
258 smbios_entry.len = sh->size; 258 smbios_entry.len = sh->size;
259 smbios_entry.rev = 0; 259 smbios_entry.rev = 0;
260 smbios_entry.mjr = sh->majrev; 260 smbios_entry.mjr = sh->majrev;
261 smbios_entry.min = sh->minrev; 261 smbios_entry.min = sh->minrev;
262 smbios_entry.doc = 0; 262 smbios_entry.doc = 0;
263 smbios_entry.count = sh->count; 263 smbios_entry.count = sh->count;
264 264
265 for (; pa < end; pa+= NBPG, eva+= NBPG) 265 for (; pa < end; pa+= NBPG, eva+= NBPG)
266#ifdef XENPV 266#ifdef XENPV
267 pmap_kenter_ma(eva, pa, VM_PROT_READ, 0); 267 pmap_kenter_ma(eva, pa, VM_PROT_READ, 0);
268#else 268#else
@@ -277,27 +277,27 @@ smbios2_map_kva(const uint8_t *p) @@ -277,27 +277,27 @@ smbios2_map_kva(const uint8_t *p)
277static void 277static void
278smbios3_map_kva(const uint8_t *p) 278smbios3_map_kva(const uint8_t *p)
279{ 279{
280 const struct smb3hdr *sh = (const struct smb3hdr *)p; 280 const struct smb3hdr *sh = (const struct smb3hdr *)p;
281 paddr_t pa, end; 281 paddr_t pa, end;
282 vaddr_t eva; 282 vaddr_t eva;
283 283
284 pa = trunc_page(sh->addr); 284 pa = trunc_page(sh->addr);
285 end = round_page(sh->addr + sh->size); 285 end = round_page(sh->addr + sh->size);
286 eva = uvm_km_alloc(kernel_map, end - pa, 0, UVM_KMF_VAONLY); 286 eva = uvm_km_alloc(kernel_map, end - pa, 0, UVM_KMF_VAONLY);
287 if (eva == 0) 287 if (eva == 0)
288 return; 288 return;
289 289
290 smbios_entry.hdrphys = vtophys(p); 290 smbios_entry.hdrphys = vtophys((vaddr_t)p);
291 smbios_entry.tabphys = sh->addr; 291 smbios_entry.tabphys = sh->addr;
292 smbios_entry.addr = (uint8_t *)(eva + ((vaddr_t)sh->addr & PGOFSET)); 292 smbios_entry.addr = (uint8_t *)(eva + ((vaddr_t)sh->addr & PGOFSET));
293 smbios_entry.len = sh->size; 293 smbios_entry.len = sh->size;
294 smbios_entry.rev = sh->eprev; 294 smbios_entry.rev = sh->eprev;
295 smbios_entry.mjr = sh->majrev; 295 smbios_entry.mjr = sh->majrev;
296 smbios_entry.min = sh->minrev; 296 smbios_entry.min = sh->minrev;
297 smbios_entry.doc = sh->docrev; 297 smbios_entry.doc = sh->docrev;
298 smbios_entry.count = UINT16_MAX; 298 smbios_entry.count = UINT16_MAX;
299 299
300 for (; pa < end; pa += NBPG, eva += NBPG) 300 for (; pa < end; pa += NBPG, eva += NBPG)
301#ifdef XENPV 301#ifdef XENPV
302 pmap_kenter_ma(eva, pa, VM_PROT_READ, 0); 302 pmap_kenter_ma(eva, pa, VM_PROT_READ, 0);
303#else 303#else