Sat Jun 20 08:31:37 2009 UTC ()
use M_ZERO, no need for memset.
Ansify kvm86_init function definition.


(cegger)
diff -r1.18 -r1.19 src/sys/arch/i386/i386/kvm86.c

cvs diff -r1.18 -r1.19 src/sys/arch/i386/i386/Attic/kvm86.c (expand / switch to unified diff)

--- src/sys/arch/i386/i386/Attic/kvm86.c 2009/04/09 10:56:41 1.18
+++ src/sys/arch/i386/i386/Attic/kvm86.c 2009/06/20 08:31:37 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kvm86.c,v 1.18 2009/04/09 10:56:41 sborrill Exp $ */ 1/* $NetBSD: kvm86.c,v 1.19 2009/06/20 08:31:37 cegger Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002 4 * Copyright (c) 2002
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer. 11 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: kvm86.c,v 1.18 2009/04/09 10:56:41 sborrill Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: kvm86.c,v 1.19 2009/06/20 08:31:37 cegger Exp $");
31 31
32#include "opt_multiprocessor.h" 32#include "opt_multiprocessor.h"
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/proc.h> 36#include <sys/proc.h>
37#include <sys/user.h> 37#include <sys/user.h>
38#include <sys/malloc.h> 38#include <sys/malloc.h>
39#include <sys/mutex.h> 39#include <sys/mutex.h>
40#include <sys/cpu.h> 40#include <sys/cpu.h>
41 41
42#include <uvm/uvm.h> 42#include <uvm/uvm.h>
43 43
@@ -72,43 +72,42 @@ struct kvm86_data *bioscallvmd; @@ -72,43 +72,42 @@ struct kvm86_data *bioscallvmd;
72void *bioscallscratchpage; 72void *bioscallscratchpage;
73/* where this page is mapped in the vm86 */ 73/* where this page is mapped in the vm86 */
74#define BIOSCALLSCRATCHPAGE_VMVA 0x1000 74#define BIOSCALLSCRATCHPAGE_VMVA 0x1000
75/* a virtual page to map in vm86 memory temporarily */ 75/* a virtual page to map in vm86 memory temporarily */
76vaddr_t bioscalltmpva; 76vaddr_t bioscalltmpva;
77 77
78int kvm86_tss_sel; 78int kvm86_tss_sel;
79 79
80kmutex_t kvm86_mp_lock; 80kmutex_t kvm86_mp_lock;
81 81
82#define KVM86_IOPL3 /* not strictly necessary, saves a lot of traps */ 82#define KVM86_IOPL3 /* not strictly necessary, saves a lot of traps */
83 83
84void 84void
85kvm86_init() 85kvm86_init(void)
86{ 86{
87 size_t vmdsize; 87 size_t vmdsize;
88 char *buf; 88 char *buf;
89 struct kvm86_data *vmd; 89 struct kvm86_data *vmd;
90 struct i386tss *tss; 90 struct i386tss *tss;
91 int i; 91 int i;
92 int slot; 92 int slot;
93 93
94 vmdsize = round_page(sizeof(struct kvm86_data)) + PAGE_SIZE; 94 vmdsize = round_page(sizeof(struct kvm86_data)) + PAGE_SIZE;
95 95
96 buf = malloc(vmdsize, M_DEVBUF, M_NOWAIT); 96 buf = malloc(vmdsize, M_DEVBUF, M_NOWAIT | M_ZERO);
97 if ((u_long)buf & (PAGE_SIZE - 1)) { 97 if ((u_long)buf & (PAGE_SIZE - 1)) {
98 printf("struct kvm86_data unaligned\n"); 98 printf("struct kvm86_data unaligned\n");
99 return; 99 return;
100 } 100 }
101 memset(buf, 0, vmdsize); 
102 /* first page is stack */ 101 /* first page is stack */
103 vmd = (struct kvm86_data *)(buf + PAGE_SIZE); 102 vmd = (struct kvm86_data *)(buf + PAGE_SIZE);
104 tss = &vmd->tss; 103 tss = &vmd->tss;
105 104
106 /* 105 /*
107 * we want to access all IO ports, so we need a full-size 106 * we want to access all IO ports, so we need a full-size
108 * permission bitmap 107 * permission bitmap
109 */ 108 */
110 memcpy(tss, &curcpu()->ci_tss, sizeof(*tss)); 109 memcpy(tss, &curcpu()->ci_tss, sizeof(*tss));
111 tss->tss_esp0 = (int)vmd; 110 tss->tss_esp0 = (int)vmd;
112 tss->tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); 111 tss->tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
113 for (i = 0; i < sizeof(vmd->iomap) / 4; i++) 112 for (i = 0; i < sizeof(vmd->iomap) / 4; i++)
114 vmd->iomap[i] = 0; 113 vmd->iomap[i] = 0;