Fri Oct 24 21:09:24 2008 UTC ()
- rename init_events() to events_init(), to better reflect netbsd semantics

- change unbind_[pv]irq_from_evtch() so that they now return the event
channel the [PV]IRQ was bound to. It reflects the opposite behaviour of the
bind_[pv]irq_to_evtch() functions.

- remove xenbus_suspend() and xenbus_resume() prototypes, as they are not
used anywhere else, and will conflict with the xenbus pmf(9) handlers.

- make start_info aligned on a page boundary, as Xen expects it to be so.

- mask event channel during xbd detach before removing its handler (can
avoid spurious events).

- add the "protocol" entry in xenstore during xbd initialization. Normally
created during domU's boot by xentools, it is under domU's responsibility
in all other cases (save/restore, hot plugging, etc.).

- modifications to xs_init(), so that it can properly return an error.

Reviewed by Christoph (cegger@).


(jym)
diff -r1.16 -r1.17 src/sys/arch/xen/include/evtchn.h
diff -r1.9 -r1.10 src/sys/arch/xen/include/xenbus.h
diff -r1.10 -r1.11 src/sys/arch/xen/x86/x86_xpmap.c
diff -r1.38 -r1.39 src/sys/arch/xen/xen/evtchn.c
diff -r1.41 -r1.42 src/sys/arch/xen/xen/hypervisor.c
diff -r1.31 -r1.32 src/sys/arch/xen/xen/xbd_xenbus.c
diff -r1.4 -r1.5 src/sys/arch/xen/xenbus/xenbus_comms.h
diff -r1.24 -r1.25 src/sys/arch/xen/xenbus/xenbus_probe.c
diff -r1.15 -r1.16 src/sys/arch/xen/xenbus/xenbus_xs.c

cvs diff -r1.16 -r1.17 src/sys/arch/xen/include/evtchn.h (expand / switch to unified diff)

--- src/sys/arch/xen/include/evtchn.h 2008/07/01 18:49:21 1.16
+++ src/sys/arch/xen/include/evtchn.h 2008/10/24 21:09:24 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: evtchn.h,v 1.16 2008/07/01 18:49:21 bouyer Exp $ */ 1/* $NetBSD: evtchn.h,v 1.17 2008/10/24 21:09:24 jym Exp $ */
2 2
3/* 3/*
4 * 4 *
5 * Copyright (c) 2004 Christian Limpach. 5 * Copyright (c) 2004 Christian Limpach.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -29,42 +29,42 @@ @@ -29,42 +29,42 @@
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#ifndef _XEN_EVENTS_H_ 34#ifndef _XEN_EVENTS_H_
35#define _XEN_EVENTS_H_ 35#define _XEN_EVENTS_H_
36 36
37#define NR_PIRQS 256 37#define NR_PIRQS 256
38 38
39extern struct evtsource *evtsource[]; 39extern struct evtsource *evtsource[];
40 40
41void events_default_setup(void); 41void events_default_setup(void);
42void init_events(void); 42void events_init(void);
43unsigned int evtchn_do_event(int, struct intrframe *); 43unsigned int evtchn_do_event(int, struct intrframe *);
44void call_evtchn_do_event(int, struct intrframe *); 44void call_evtchn_do_event(int, struct intrframe *);
45void call_xenevt_event(int); 45void call_xenevt_event(int);
46int event_set_handler(int, int (*func)(void *), void *, int, const char *); 46int event_set_handler(int, int (*func)(void *), void *, int, const char *);
47int event_remove_handler(int, int (*func)(void *), void *); 47int event_remove_handler(int, int (*func)(void *), void *);
48 48
49struct intrhand; 49struct intrhand;
50void event_set_iplhandler(struct intrhand *, int); 50void event_set_iplhandler(struct intrhand *, int);
51 51
52extern int debug_port; 52extern int debug_port;
53extern int xen_debug_handler(void *); 53extern int xen_debug_handler(void *);
54 54
55int bind_virq_to_evtch(int); 55int bind_virq_to_evtch(int);
56int bind_pirq_to_evtch(int); 56int bind_pirq_to_evtch(int);
57void unbind_pirq_from_evtch(int); 57int unbind_pirq_from_evtch(int);
58void unbind_virq_from_evtch(int); 58int unbind_virq_from_evtch(int);
59 59
60struct pintrhand { 60struct pintrhand {
61 int pirq; 61 int pirq;
62 int evtch; 62 int evtch;
63 int (*func)(void *); 63 int (*func)(void *);
64 void *arg; 64 void *arg;
65}; 65};
66 66
67struct pintrhand *pirq_establish(int, int, int (*)(void *), void *, int, 67struct pintrhand *pirq_establish(int, int, int (*)(void *), void *, int,
68 const char *); 68 const char *);
69 69
70#endif /* _XEN_EVENTS_H_ */ 70#endif /* _XEN_EVENTS_H_ */

cvs diff -r1.9 -r1.10 src/sys/arch/xen/include/xenbus.h (expand / switch to unified diff)

--- src/sys/arch/xen/include/xenbus.h 2008/04/16 18:41:48 1.9
+++ src/sys/arch/xen/include/xenbus.h 2008/10/24 21:09:24 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xenbus.h,v 1.9 2008/04/16 18:41:48 cegger Exp $ */ 1/* $NetBSD: xenbus.h,v 1.10 2008/10/24 21:09:24 jym Exp $ */
2/****************************************************************************** 2/******************************************************************************
3 * xenbus.h 3 * xenbus.h
4 * 4 *
5 * Talks to Xen Store to figure out what devices we have. 5 * Talks to Xen Store to figure out what devices we have.
6 * 6 *
7 * Copyright (C) 2005 Rusty Russell, IBM Corporation 7 * Copyright (C) 2005 Rusty Russell, IBM Corporation
8 * Copyright (C) 2005 XenSource Ltd. 8 * Copyright (C) 2005 XenSource Ltd.
9 *  9 *
10 * This file may be distributed separately from the Linux kernel, or 10 * This file may be distributed separately from the Linux kernel, or
11 * incorporated into other software packages, subject to the following license: 11 * incorporated into other software packages, subject to the following license:
12 *  12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy 13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this source file (the "Software"), to deal in the Software without 14 * of this source file (the "Software"), to deal in the Software without
@@ -149,30 +149,26 @@ int xenbus_gather(struct xenbus_transact @@ -149,30 +149,26 @@ int xenbus_gather(struct xenbus_transact
149 149
150/* notifer routines for when the xenstore comes up */ 150/* notifer routines for when the xenstore comes up */
151// XXX int register_xenstore_notifier(struct notifier_block *nb); 151// XXX int register_xenstore_notifier(struct notifier_block *nb);
152// XXX void unregister_xenstore_notifier(struct notifier_block *nb); 152// XXX void unregister_xenstore_notifier(struct notifier_block *nb);
153 153
154int register_xenbus_watch(struct xenbus_watch *watch); 154int register_xenbus_watch(struct xenbus_watch *watch);
155void unregister_xenbus_watch(struct xenbus_watch *watch); 155void unregister_xenbus_watch(struct xenbus_watch *watch);
156void xs_suspend(void); 156void xs_suspend(void);
157void xs_resume(void); 157void xs_resume(void);
158 158
159/* Used by xenbus_dev to borrow kernel's store connection. */ 159/* Used by xenbus_dev to borrow kernel's store connection. */
160int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void **); 160int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void **);
161 161
162/* Called from xen core code. */ 
163void xenbus_suspend(void); 
164void xenbus_resume(void); 
165 
166void xenbus_probe(void *); 162void xenbus_probe(void *);
167 163
168int xenbus_free_device(struct xenbus_device *); 164int xenbus_free_device(struct xenbus_device *);
169 165
170#define XENBUS_IS_ERR_READ(str) ({ \ 166#define XENBUS_IS_ERR_READ(str) ({ \
171 if (!IS_ERR(str) && strlen(str) == 0) { \ 167 if (!IS_ERR(str) && strlen(str) == 0) { \
172 kfree(str); \ 168 kfree(str); \
173 str = ERR_PTR(-ERANGE); \ 169 str = ERR_PTR(-ERANGE); \
174 } \ 170 } \
175 IS_ERR(str); \ 171 IS_ERR(str); \
176}) 172})
177 173
178#define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE) 174#define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)

cvs diff -r1.10 -r1.11 src/sys/arch/xen/x86/x86_xpmap.c (expand / switch to unified diff)

--- src/sys/arch/xen/x86/x86_xpmap.c 2008/10/21 15:46:32 1.10
+++ src/sys/arch/xen/x86/x86_xpmap.c 2008/10/24 21:09:24 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: x86_xpmap.c,v 1.10 2008/10/21 15:46:32 cegger Exp $ */ 1/* $NetBSD: x86_xpmap.c,v 1.11 2008/10/24 21:09:24 jym Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Mathieu Ropert <mro@adviseo.fr> 4 * Copyright (c) 2006 Mathieu Ropert <mro@adviseo.fr>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies. 8 * copyright notice and this permission notice appear in all copies.
9 * 9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
@@ -69,27 +69,27 @@ @@ -69,27 +69,27 @@
69 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 69 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
70 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 70 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
71 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 71 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
72 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 72 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
73 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 73 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
74 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 74 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
75 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 75 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 76 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
77 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 77 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78 */ 78 */
79 79
80 80
81#include <sys/cdefs.h> 81#include <sys/cdefs.h>
82__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.10 2008/10/21 15:46:32 cegger Exp $"); 82__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.11 2008/10/24 21:09:24 jym Exp $");
83 83
84#include "opt_xen.h" 84#include "opt_xen.h"
85#include "opt_ddb.h" 85#include "opt_ddb.h"
86#include "ksyms.h" 86#include "ksyms.h"
87 87
88#include <sys/param.h> 88#include <sys/param.h>
89#include <sys/systm.h> 89#include <sys/systm.h>
90 90
91#include <uvm/uvm.h> 91#include <uvm/uvm.h>
92 92
93#include <machine/pmap.h> 93#include <machine/pmap.h>
94#include <machine/gdt.h> 94#include <machine/gdt.h>
95#include <xen/xenfunc.h> 95#include <xen/xenfunc.h>
@@ -113,27 +113,28 @@ static char XBUF[256]; @@ -113,27 +113,28 @@ static char XBUF[256];
113#define XENPRINTK2(x) 113#define XENPRINTK2(x)
114#endif 114#endif
115#define PRINTF(x) printf x 115#define PRINTF(x) printf x
116#define PRINTK(x) printk x 116#define PRINTK(x) printk x
117 117
118/* on x86_64 kernel runs in ring 3 */ 118/* on x86_64 kernel runs in ring 3 */
119#ifdef __x86_64__ 119#ifdef __x86_64__
120#define PG_k PG_u 120#define PG_k PG_u
121#else 121#else
122#define PG_k 0 122#define PG_k 0
123#endif 123#endif
124 124
125volatile shared_info_t *HYPERVISOR_shared_info; 125volatile shared_info_t *HYPERVISOR_shared_info;
126union start_info_union start_info_union; 126/* Xen requires the start_info struct to be page aligned */
 127union start_info_union start_info_union __aligned(PAGE_SIZE);
127unsigned long *xpmap_phys_to_machine_mapping; 128unsigned long *xpmap_phys_to_machine_mapping;
128 129
129void xen_failsafe_handler(void); 130void xen_failsafe_handler(void);
130 131
131#ifdef XEN3 132#ifdef XEN3
132#define HYPERVISOR_mmu_update_self(req, count, success_count) \ 133#define HYPERVISOR_mmu_update_self(req, count, success_count) \
133 HYPERVISOR_mmu_update((req), (count), (success_count), DOMID_SELF) 134 HYPERVISOR_mmu_update((req), (count), (success_count), DOMID_SELF)
134#else 135#else
135#define HYPERVISOR_mmu_update_self(req, count, success_count) \ 136#define HYPERVISOR_mmu_update_self(req, count, success_count) \
136 HYPERVISOR_mmu_update((req), (count), (success_count)) 137 HYPERVISOR_mmu_update((req), (count), (success_count))
137#endif 138#endif
138 139
139void 140void

cvs diff -r1.38 -r1.39 src/sys/arch/xen/xen/evtchn.c (expand / switch to unified diff)

--- src/sys/arch/xen/xen/evtchn.c 2008/05/24 15:09:34 1.38
+++ src/sys/arch/xen/xen/evtchn.c 2008/10/24 21:09:24 1.39
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: evtchn.c,v 1.38 2008/05/24 15:09:34 bouyer Exp $ */ 1/* $NetBSD: evtchn.c,v 1.39 2008/10/24 21:09:24 jym Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Manuel Bouyer. 4 * Copyright (c) 2006 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -54,27 +54,27 @@ @@ -54,27 +54,27 @@
54 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 54 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
55 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 55 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
56 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 56 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
57 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 57 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
62 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 */ 63 */
64 64
65 65
66#include <sys/cdefs.h> 66#include <sys/cdefs.h>
67__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.38 2008/05/24 15:09:34 bouyer Exp $"); 67__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.39 2008/10/24 21:09:24 jym Exp $");
68 68
69#include "opt_xen.h" 69#include "opt_xen.h"
70#include "isa.h" 70#include "isa.h"
71#include "pci.h" 71#include "pci.h"
72 72
73#include <sys/param.h> 73#include <sys/param.h>
74#include <sys/kernel.h> 74#include <sys/kernel.h>
75#include <sys/systm.h> 75#include <sys/systm.h>
76#include <sys/proc.h> 76#include <sys/proc.h>
77#include <sys/malloc.h> 77#include <sys/malloc.h>
78#include <sys/reboot.h> 78#include <sys/reboot.h>
79#include <sys/simplelock.h> 79#include <sys/simplelock.h>
80 80
@@ -164,27 +164,27 @@ events_default_setup(void) @@ -164,27 +164,27 @@ events_default_setup(void)
164 pirq_needs_unmask_notify[i] = 0; 164 pirq_needs_unmask_notify[i] = 0;
165#endif 165#endif
166 166
167 /* No event-channel are 'live' right now. */ 167 /* No event-channel are 'live' right now. */
168 for (i = 0; i < NR_EVENT_CHANNELS; i++) { 168 for (i = 0; i < NR_EVENT_CHANNELS; i++) {
169 evtsource[i] = NULL; 169 evtsource[i] = NULL;
170 evtch_bindcount[i] = 0; 170 evtch_bindcount[i] = 0;
171 hypervisor_mask_event(i); 171 hypervisor_mask_event(i);
172 } 172 }
173 173
174} 174}
175 175
176void 176void
177init_events(void) 177events_init(void)
178{ 178{
179#ifndef XEN3 179#ifndef XEN3
180 int evtch; 180 int evtch;
181 181
182 evtch = bind_virq_to_evtch(VIRQ_MISDIRECT); 182 evtch = bind_virq_to_evtch(VIRQ_MISDIRECT);
183 aprint_verbose("misdirect virtual interrupt using event channel %d\n", 183 aprint_verbose("misdirect virtual interrupt using event channel %d\n",
184 evtch); 184 evtch);
185 event_set_handler(evtch, &xen_misdirect_handler, NULL, IPL_HIGH, 185 event_set_handler(evtch, &xen_misdirect_handler, NULL, IPL_HIGH,
186 "misdirev"); 186 "misdirev");
187 hypervisor_enable_event(evtch); 187 hypervisor_enable_event(evtch);
188 188
189 /* This needs to be done early, but after the IRQ subsystem is 189 /* This needs to be done early, but after the IRQ subsystem is
190 * alive. */ 190 * alive. */
@@ -336,50 +336,52 @@ bind_virq_to_evtch(int virq) @@ -336,50 +336,52 @@ bind_virq_to_evtch(int virq)
336 evtchn = op.u.bind_virq.port; 336 evtchn = op.u.bind_virq.port;
337 337
338 virq_to_evtch[virq] = evtchn; 338 virq_to_evtch[virq] = evtchn;
339 } 339 }
340 340
341 evtch_bindcount[evtchn]++; 341 evtch_bindcount[evtchn]++;
342 342
343 simple_unlock(&irq_mapping_update_lock); 343 simple_unlock(&irq_mapping_update_lock);
344 splx(s); 344 splx(s);
345  345
346 return evtchn; 346 return evtchn;
347} 347}
348 348
349void 349int
350unbind_virq_from_evtch(int virq) 350unbind_virq_from_evtch(int virq)
351{ 351{
352 evtchn_op_t op; 352 evtchn_op_t op;
353 int evtchn = virq_to_evtch[virq]; 353 int evtchn = virq_to_evtch[virq];
354 int s = splhigh(); 354 int s = splhigh();
355 355
356 simple_lock(&irq_mapping_update_lock); 356 simple_lock(&irq_mapping_update_lock);
357 357
358 evtch_bindcount[evtchn]--; 358 evtch_bindcount[evtchn]--;
359 if (evtch_bindcount[evtchn] == 0) { 359 if (evtch_bindcount[evtchn] == 0) {
360 op.cmd = EVTCHNOP_close; 360 op.cmd = EVTCHNOP_close;
361#ifndef XEN3 361#ifndef XEN3
362 op.u.close.dom = DOMID_SELF; 362 op.u.close.dom = DOMID_SELF;
363#endif 363#endif
364 op.u.close.port = evtchn; 364 op.u.close.port = evtchn;
365 if (HYPERVISOR_event_channel_op(&op) != 0) 365 if (HYPERVISOR_event_channel_op(&op) != 0)
366 panic("Failed to unbind virtual IRQ %d\n", virq); 366 panic("Failed to unbind virtual IRQ %d\n", virq);
367 367
368 virq_to_evtch[virq] = -1; 368 virq_to_evtch[virq] = -1;
369 } 369 }
370 370
371 simple_unlock(&irq_mapping_update_lock); 371 simple_unlock(&irq_mapping_update_lock);
372 splx(s); 372 splx(s);
 373
 374 return evtchn;
373} 375}
374 376
375#if NPCI > 0 || NISA > 0 377#if NPCI > 0 || NISA > 0
376int 378int
377bind_pirq_to_evtch(int pirq) 379bind_pirq_to_evtch(int pirq)
378{ 380{
379 evtchn_op_t op; 381 evtchn_op_t op;
380 int evtchn, s; 382 int evtchn, s;
381 383
382 if (pirq >= NR_PIRQS) { 384 if (pirq >= NR_PIRQS) {
383 panic("pirq %d out of bound, increase NR_PIRQS", pirq); 385 panic("pirq %d out of bound, increase NR_PIRQS", pirq);
384 } 386 }
385 387
@@ -399,50 +401,52 @@ bind_pirq_to_evtch(int pirq) @@ -399,50 +401,52 @@ bind_pirq_to_evtch(int pirq)
399 printf("pirq %d evtchn %d\n", pirq, evtchn); 401 printf("pirq %d evtchn %d\n", pirq, evtchn);
400#endif 402#endif
401 pirq_to_evtch[pirq] = evtchn; 403 pirq_to_evtch[pirq] = evtchn;
402 } 404 }
403 405
404 evtch_bindcount[evtchn]++; 406 evtch_bindcount[evtchn]++;
405 407
406 simple_unlock(&irq_mapping_update_lock); 408 simple_unlock(&irq_mapping_update_lock);
407 splx(s); 409 splx(s);
408  410
409 return evtchn; 411 return evtchn;
410} 412}
411 413
412void 414int
413unbind_pirq_from_evtch(int pirq) 415unbind_pirq_from_evtch(int pirq)
414{ 416{
415 evtchn_op_t op; 417 evtchn_op_t op;
416 int evtchn = pirq_to_evtch[pirq]; 418 int evtchn = pirq_to_evtch[pirq];
417 int s = splhigh(); 419 int s = splhigh();
418 420
419 simple_lock(&irq_mapping_update_lock); 421 simple_lock(&irq_mapping_update_lock);
420 422
421 evtch_bindcount[evtchn]--; 423 evtch_bindcount[evtchn]--;
422 if (evtch_bindcount[evtchn] == 0) { 424 if (evtch_bindcount[evtchn] == 0) {
423 op.cmd = EVTCHNOP_close; 425 op.cmd = EVTCHNOP_close;
424#ifndef XEN3 426#ifndef XEN3
425 op.u.close.dom = DOMID_SELF; 427 op.u.close.dom = DOMID_SELF;
426#endif 428#endif
427 op.u.close.port = evtchn; 429 op.u.close.port = evtchn;
428 if (HYPERVISOR_event_channel_op(&op) != 0) 430 if (HYPERVISOR_event_channel_op(&op) != 0)
429 panic("Failed to unbind physical IRQ %d\n", pirq); 431 panic("Failed to unbind physical IRQ %d\n", pirq);
430 432
431 pirq_to_evtch[pirq] = -1; 433 pirq_to_evtch[pirq] = -1;
432 } 434 }
433 435
434 simple_unlock(&irq_mapping_update_lock); 436 simple_unlock(&irq_mapping_update_lock);
435 splx(s); 437 splx(s);
 438
 439 return evtchn;
436} 440}
437 441
438struct pintrhand * 442struct pintrhand *
439pirq_establish(int pirq, int evtch, int (*func)(void *), void *arg, int level, 443pirq_establish(int pirq, int evtch, int (*func)(void *), void *arg, int level,
440 const char *evname) 444 const char *evname)
441{ 445{
442 struct pintrhand *ih; 446 struct pintrhand *ih;
443 physdev_op_t physdev_op; 447 physdev_op_t physdev_op;
444 448
445 ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK); 449 ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
446 if (ih == NULL) { 450 if (ih == NULL) {
447 printf("pirq_establish: can't malloc handler info\n"); 451 printf("pirq_establish: can't malloc handler info\n");
448 return NULL; 452 return NULL;

cvs diff -r1.41 -r1.42 src/sys/arch/xen/xen/hypervisor.c (expand / switch to unified diff)

--- src/sys/arch/xen/xen/hypervisor.c 2008/10/24 18:02:58 1.41
+++ src/sys/arch/xen/xen/hypervisor.c 2008/10/24 21:09:24 1.42
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hypervisor.c,v 1.41 2008/10/24 18:02:58 jym Exp $ */ 1/* $NetBSD: hypervisor.c,v 1.42 2008/10/24 21:09:24 jym Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Manuel Bouyer. 4 * Copyright (c) 2005 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -53,27 +53,27 @@ @@ -53,27 +53,27 @@
53 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 53 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 */ 62 */
63 63
64 64
65#include <sys/cdefs.h> 65#include <sys/cdefs.h>
66__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.41 2008/10/24 18:02:58 jym Exp $"); 66__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42 2008/10/24 21:09:24 jym Exp $");
67 67
68#include <sys/param.h> 68#include <sys/param.h>
69#include <sys/systm.h> 69#include <sys/systm.h>
70#include <sys/device.h> 70#include <sys/device.h>
71#include <sys/malloc.h> 71#include <sys/malloc.h>
72 72
73#ifndef XEN3 73#ifndef XEN3
74#include <dev/sysmon/sysmonvar.h> 74#include <dev/sysmon/sysmonvar.h>
75#endif 75#endif
76 76
77#include "xenbus.h" 77#include "xenbus.h"
78#include "xencons.h" 78#include "xencons.h"
79#include "xennet_hypervisor.h" 79#include "xennet_hypervisor.h"
@@ -256,27 +256,27 @@ hypervisor_attach(device_t parent, devic @@ -256,27 +256,27 @@ hypervisor_attach(device_t parent, devic
256 256
257 xengnt_init(); 257 xengnt_init();
258 258
259 memset(&hac.hac_vcaa, 0, sizeof(hac.hac_vcaa)); 259 memset(&hac.hac_vcaa, 0, sizeof(hac.hac_vcaa));
260 hac.hac_vcaa.vcaa_name = "vcpu"; 260 hac.hac_vcaa.vcaa_name = "vcpu";
261 hac.hac_vcaa.vcaa_caa.cpu_number = 0; 261 hac.hac_vcaa.vcaa_caa.cpu_number = 0;
262 hac.hac_vcaa.vcaa_caa.cpu_role = CPU_ROLE_SP; 262 hac.hac_vcaa.vcaa_caa.cpu_role = CPU_ROLE_SP;
263 hac.hac_vcaa.vcaa_caa.cpu_func = 0; 263 hac.hac_vcaa.vcaa_caa.cpu_func = 0;
264 config_found_ia(self, "xendevbus", &hac.hac_vcaa, hypervisor_print); 264 config_found_ia(self, "xendevbus", &hac.hac_vcaa, hypervisor_print);
265#else 265#else
266 aprint_normal("\n"); 266 aprint_normal("\n");
267#endif 267#endif
268 268
269 init_events(); 269 events_init();
270 270
271#if NXENBUS > 0 271#if NXENBUS > 0
272 hac.hac_xenbus.xa_device = "xenbus"; 272 hac.hac_xenbus.xa_device = "xenbus";
273 config_found_ia(self, "xendevbus", &hac.hac_xenbus, hypervisor_print); 273 config_found_ia(self, "xendevbus", &hac.hac_xenbus, hypervisor_print);
274#endif 274#endif
275#if NXENCONS > 0 275#if NXENCONS > 0
276 hac.hac_xencons.xa_device = "xencons"; 276 hac.hac_xencons.xa_device = "xencons";
277 config_found_ia(self, "xendevbus", &hac.hac_xencons, hypervisor_print); 277 config_found_ia(self, "xendevbus", &hac.hac_xencons, hypervisor_print);
278#endif 278#endif
279#if NXENNET_HYPERVISOR > 0 279#if NXENNET_HYPERVISOR > 0
280 hac.hac_xennet.xa_device = "xennet"; 280 hac.hac_xennet.xa_device = "xennet";
281 xennet_scan(self, &hac.hac_xennet, hypervisor_print); 281 xennet_scan(self, &hac.hac_xennet, hypervisor_print);
282#endif 282#endif

cvs diff -r1.31 -r1.32 src/sys/arch/xen/xen/xbd_xenbus.c (expand / switch to unified diff)

--- src/sys/arch/xen/xen/xbd_xenbus.c 2008/10/24 18:02:58 1.31
+++ src/sys/arch/xen/xen/xbd_xenbus.c 2008/10/24 21:09:24 1.32
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xbd_xenbus.c,v 1.31 2008/10/24 18:02:58 jym Exp $ */ 1/* $NetBSD: xbd_xenbus.c,v 1.32 2008/10/24 21:09:24 jym Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Manuel Bouyer. 4 * Copyright (c) 2006 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -21,52 +21,53 @@ @@ -21,52 +21,53 @@
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * 30 *
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.31 2008/10/24 18:02:58 jym Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.32 2008/10/24 21:09:24 jym Exp $");
35 35
36#include "opt_xen.h" 36#include "opt_xen.h"
37#include "rnd.h" 37#include "rnd.h"
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/buf.h> 40#include <sys/buf.h>
41#include <sys/bufq.h> 41#include <sys/bufq.h>
42#include <sys/device.h> 42#include <sys/device.h>
43#include <sys/disk.h> 43#include <sys/disk.h>
44#include <sys/disklabel.h> 44#include <sys/disklabel.h>
45#include <sys/conf.h> 45#include <sys/conf.h>
46#include <sys/fcntl.h> 46#include <sys/fcntl.h>
47#include <sys/kernel.h> 47#include <sys/kernel.h>
48#include <sys/malloc.h> 48#include <sys/malloc.h>
49#include <sys/proc.h> 49#include <sys/proc.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/stat.h> 51#include <sys/stat.h>
52#include <sys/vnode.h> 52#include <sys/vnode.h>
53 53
54#include <dev/dkvar.h> 54#include <dev/dkvar.h>
55 55
56#include <uvm/uvm.h> 56#include <uvm/uvm.h>
57 57
58#include <xen/xen3-public/io/ring.h> 58#include <xen/xen3-public/io/ring.h>
59#include <xen/xen3-public/io/blkif.h> 59#include <xen/xen3-public/io/blkif.h>
 60#include <xen/xen3-public/io/protocols.h>
60 61
61#include <xen/granttables.h> 62#include <xen/granttables.h>
62#include <xen/xenbus.h> 63#include <xen/xenbus.h>
63#include "locators.h" 64#include "locators.h"
64 65
65#undef XBD_DEBUG 66#undef XBD_DEBUG
66#ifdef XBD_DEBUG 67#ifdef XBD_DEBUG
67#define DPRINTF(x) printf x; 68#define DPRINTF(x) printf x;
68#else 69#else
69#define DPRINTF(x) 70#define DPRINTF(x)
70#endif 71#endif
71 72
72#define GRANT_INVALID_REF -1 73#define GRANT_INVALID_REF -1
@@ -276,26 +277,27 @@ xbd_xenbus_detach(device_t dev, int flag @@ -276,26 +277,27 @@ xbd_xenbus_detach(device_t dev, int flag
276 dkwedge_delall(&sc->sc_dksc.sc_dkdev); 277 dkwedge_delall(&sc->sc_dksc.sc_dkdev);
277 278
278 s = splbio(); 279 s = splbio();
279 /* Kill off any queued buffers. */ 280 /* Kill off any queued buffers. */
280 bufq_drain(sc->sc_dksc.sc_bufq); 281 bufq_drain(sc->sc_dksc.sc_bufq);
281 bufq_free(sc->sc_dksc.sc_bufq); 282 bufq_free(sc->sc_dksc.sc_bufq);
282 splx(s); 283 splx(s);
283 284
284 /* detach disk */ 285 /* detach disk */
285 disk_detach(&sc->sc_dksc.sc_dkdev); 286 disk_detach(&sc->sc_dksc.sc_dkdev);
286 disk_destroy(&sc->sc_dksc.sc_dkdev); 287 disk_destroy(&sc->sc_dksc.sc_dkdev);
287 } 288 }
288 289
 290 hypervisor_mask_event(sc->sc_evtchn);
289 event_remove_handler(sc->sc_evtchn, &xbd_handler, sc); 291 event_remove_handler(sc->sc_evtchn, &xbd_handler, sc);
290 while (xengnt_status(sc->sc_ring_gntref)) { 292 while (xengnt_status(sc->sc_ring_gntref)) {
291 tsleep(xbd_xenbus_detach, PRIBIO, "xbd_ref", hz/2); 293 tsleep(xbd_xenbus_detach, PRIBIO, "xbd_ref", hz/2);
292 } 294 }
293 xengnt_revoke_access(sc->sc_ring_gntref); 295 xengnt_revoke_access(sc->sc_ring_gntref);
294 uvm_km_free(kernel_map, (vaddr_t)sc->sc_ring.sring, 296 uvm_km_free(kernel_map, (vaddr_t)sc->sc_ring.sring,
295 PAGE_SIZE, UVM_KMF_WIRED); 297 PAGE_SIZE, UVM_KMF_WIRED);
296 return 0; 298 return 0;
297} 299}
298 300
299static int 301static int
300xbd_xenbus_resume(void *p) 302xbd_xenbus_resume(void *p)
301{ 303{
@@ -336,26 +338,32 @@ again: @@ -336,26 +338,32 @@ again:
336 return ENOMEM; 338 return ENOMEM;
337 error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path, 339 error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path,
338 "ring-ref","%u", sc->sc_ring_gntref); 340 "ring-ref","%u", sc->sc_ring_gntref);
339 if (error) { 341 if (error) {
340 errmsg = "writing ring-ref"; 342 errmsg = "writing ring-ref";
341 goto abort_transaction; 343 goto abort_transaction;
342 } 344 }
343 error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path, 345 error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path,
344 "event-channel", "%u", sc->sc_evtchn); 346 "event-channel", "%u", sc->sc_evtchn);
345 if (error) { 347 if (error) {
346 errmsg = "writing event channel"; 348 errmsg = "writing event channel";
347 goto abort_transaction; 349 goto abort_transaction;
348 } 350 }
 351 error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path,
 352 "protocol", "%s", XEN_IO_PROTO_ABI_NATIVE);
 353 if (error) {
 354 errmsg = "writing protocol";
 355 goto abort_transaction;
 356 }
349 error = xenbus_switch_state(sc->sc_xbusd, xbt, XenbusStateInitialised); 357 error = xenbus_switch_state(sc->sc_xbusd, xbt, XenbusStateInitialised);
350 if (error) { 358 if (error) {
351 errmsg = "writing frontend XenbusStateInitialised"; 359 errmsg = "writing frontend XenbusStateInitialised";
352 goto abort_transaction; 360 goto abort_transaction;
353 } 361 }
354 error = xenbus_transaction_end(xbt, 0); 362 error = xenbus_transaction_end(xbt, 0);
355 if (error == EAGAIN) 363 if (error == EAGAIN)
356 goto again; 364 goto again;
357 if (error) { 365 if (error) {
358 xenbus_dev_fatal(sc->sc_xbusd, error, "completing transaction"); 366 xenbus_dev_fatal(sc->sc_xbusd, error, "completing transaction");
359 return -1; 367 return -1;
360 } 368 }
361 return 0; 369 return 0;

cvs diff -r1.4 -r1.5 src/sys/arch/xen/xenbus/xenbus_comms.h (expand / switch to unified diff)

--- src/sys/arch/xen/xenbus/xenbus_comms.h 2008/04/16 18:41:48 1.4
+++ src/sys/arch/xen/xenbus/xenbus_comms.h 2008/10/24 21:09:24 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xenbus_comms.h,v 1.4 2008/04/16 18:41:48 cegger Exp $ */ 1/* $NetBSD: xenbus_comms.h,v 1.5 2008/10/24 21:09:24 jym Exp $ */
2/* 2/*
3 * Private include for xenbus communications. 3 * Private include for xenbus communications.
4 *  4 *
5 * Copyright (C) 2005 Rusty Russell, IBM Corporation 5 * Copyright (C) 2005 Rusty Russell, IBM Corporation
6 * 6 *
7 * This file may be distributed separately from the Linux kernel, or 7 * This file may be distributed separately from the Linux kernel, or
8 * incorporated into other software packages, subject to the following license: 8 * incorporated into other software packages, subject to the following license:
9 *  9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this source file (the "Software"), to deal in the Software without 11 * of this source file (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use, copy, modify, 12 * restriction, including without limitation the rights to use, copy, modify,
13 * merge, publish, distribute, sublicense, and/or sell copies of the Software, 13 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
14 * and to permit persons to whom the Software is furnished to do so, subject to 14 * and to permit persons to whom the Software is furnished to do so, subject to
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * IN THE SOFTWARE. 26 * IN THE SOFTWARE.
27 */ 27 */
28 28
29#ifndef _XENBUS_COMMS_H 29#ifndef _XENBUS_COMMS_H
30#define _XENBUS_COMMS_H 30#define _XENBUS_COMMS_H
31 31
32void xenbus_kernfs_init(void); 32void xenbus_kernfs_init(void);
33int xs_init(void); 33int xs_init(device_t dev);
34int xb_init_comms(device_t dev); 34int xb_init_comms(device_t dev);
35 35
36/* Low level routines. */ 36/* Low level routines. */
37int xb_write(const void *data, unsigned len); 37int xb_write(const void *data, unsigned len);
38int xb_read(void *data, unsigned len); 38int xb_read(void *data, unsigned len);
39int xs_input_avail(void); 39int xs_input_avail(void);
40 40
41extern struct xenstore_domain_interface *xenstore_interface; 41extern struct xenstore_domain_interface *xenstore_interface;
42 42
43#endif /* _XENBUS_COMMS_H */ 43#endif /* _XENBUS_COMMS_H */
44 44
45/* 45/*
46 * Local variables: 46 * Local variables:

cvs diff -r1.24 -r1.25 src/sys/arch/xen/xenbus/xenbus_probe.c (expand / switch to unified diff)

--- src/sys/arch/xen/xenbus/xenbus_probe.c 2008/10/21 21:55:44 1.24
+++ src/sys/arch/xen/xenbus/xenbus_probe.c 2008/10/24 21:09:24 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xenbus_probe.c,v 1.24 2008/10/21 21:55:44 cegger Exp $ */ 1/* $NetBSD: xenbus_probe.c,v 1.25 2008/10/24 21:09:24 jym Exp $ */
2/****************************************************************************** 2/******************************************************************************
3 * Talks to Xen Store to figure out what devices we have. 3 * Talks to Xen Store to figure out what devices we have.
4 * 4 *
5 * Copyright (C) 2005 Rusty Russell, IBM Corporation 5 * Copyright (C) 2005 Rusty Russell, IBM Corporation
6 * Copyright (C) 2005 Mike Wray, Hewlett-Packard 6 * Copyright (C) 2005 Mike Wray, Hewlett-Packard
7 * Copyright (C) 2005 XenSource Ltd 7 * Copyright (C) 2005 XenSource Ltd
8 *  8 *
9 * This file may be distributed separately from the Linux kernel, or 9 * This file may be distributed separately from the Linux kernel, or
10 * incorporated into other software packages, subject to the following license: 10 * incorporated into other software packages, subject to the following license:
11 *  11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy 12 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this source file (the "Software"), to deal in the Software without 13 * of this source file (the "Software"), to deal in the Software without
14 * restriction, including without limitation the rights to use, copy, modify, 14 * restriction, including without limitation the rights to use, copy, modify,
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * The above copyright notice and this permission notice shall be included in 19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software. 20 * all copies or substantial portions of the Software.
21 *  21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 * IN THE SOFTWARE. 28 * IN THE SOFTWARE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.24 2008/10/21 21:55:44 cegger Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.25 2008/10/24 21:09:24 jym Exp $");
33 33
34#if 0 34#if 0
35#define DPRINTK(fmt, args...) \ 35#define DPRINTK(fmt, args...) \
36 printf("xenbus_probe (%s:%d) " fmt ".\n", __func__, __LINE__, ##args) 36 printf("xenbus_probe (%s:%d) " fmt ".\n", __func__, __LINE__, ##args)
37#else 37#else
38#define DPRINTK(fmt, args...) ((void)0) 38#define DPRINTK(fmt, args...) ((void)0)
39#endif 39#endif
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42#include <sys/null.h> 42#include <sys/null.h>
43#include <sys/errno.h> 43#include <sys/errno.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
@@ -556,27 +556,27 @@ xenbus_probe_init(void *unused) @@ -556,27 +556,27 @@ xenbus_probe_init(void *unused)
556 /* And finally publish the above info in /kern/xen */ 556 /* And finally publish the above info in /kern/xen */
557 xenbus_kernfs_init(); 557 xenbus_kernfs_init();
558 558
559 DELAY(1000); 559 DELAY(1000);
560#else /* DOM0OPS */ 560#else /* DOM0OPS */
561 kthread_exit(0); /* can't get a working xenstore in this case */ 561 kthread_exit(0); /* can't get a working xenstore in this case */
562#endif /* DOM0OPS */ 562#endif /* DOM0OPS */
563 } 563 }
564 564
565 /* register event handler */ 565 /* register event handler */
566 xb_init_comms(xenbus_dev); 566 xb_init_comms(xenbus_dev);
567 567
568 /* Initialize the interface to xenstore. */ 568 /* Initialize the interface to xenstore. */
569 err = xs_init();  569 err = xs_init(xenbus_dev);
570 if (err) { 570 if (err) {
571 aprint_error_dev(xenbus_dev, 571 aprint_error_dev(xenbus_dev,
572 "Error initializing xenstore comms: %i\n", err); 572 "Error initializing xenstore comms: %i\n", err);
573 goto err0; 573 goto err0;
574 } 574 }
575 575
576 if (!dom0) { 576 if (!dom0) {
577 xenstored_ready = 1; 577 xenstored_ready = 1;
578 xenbus_probe(NULL); 578 xenbus_probe(NULL);
579 } 579 }
580 580
581 DPRINTK("done"); 581 DPRINTK("done");
582 config_pending_decr(); 582 config_pending_decr();

cvs diff -r1.15 -r1.16 src/sys/arch/xen/xenbus/xenbus_xs.c (expand / switch to unified diff)

--- src/sys/arch/xen/xenbus/xenbus_xs.c 2008/10/24 18:02:58 1.15
+++ src/sys/arch/xen/xenbus/xenbus_xs.c 2008/10/24 21:09:24 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xenbus_xs.c,v 1.15 2008/10/24 18:02:58 jym Exp $ */ 1/* $NetBSD: xenbus_xs.c,v 1.16 2008/10/24 21:09:24 jym Exp $ */
2/****************************************************************************** 2/******************************************************************************
3 * xenbus_xs.c 3 * xenbus_xs.c
4 * 4 *
5 * This is the kernel equivalent of the "xs" library. We don't need everything 5 * This is the kernel equivalent of the "xs" library. We don't need everything
6 * and we use xenbus_comms for communication. 6 * and we use xenbus_comms for communication.
7 * 7 *
8 * Copyright (C) 2005 Rusty Russell, IBM Corporation 8 * Copyright (C) 2005 Rusty Russell, IBM Corporation
9 *  9 *
10 * This file may be distributed separately from the Linux kernel, or 10 * This file may be distributed separately from the Linux kernel, or
11 * incorporated into other software packages, subject to the following license: 11 * incorporated into other software packages, subject to the following license:
12 *  12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy 13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this source file (the "Software"), to deal in the Software without 14 * of this source file (the "Software"), to deal in the Software without
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * The above copyright notice and this permission notice shall be included in 20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software. 21 * all copies or substantial portions of the Software.
22 *  22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29 * IN THE SOFTWARE. 29 * IN THE SOFTWARE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.15 2008/10/24 18:02:58 jym Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.16 2008/10/24 21:09:24 jym Exp $");
34 34
35#if 0 35#if 0
36#define DPRINTK(fmt, args...) \ 36#define DPRINTK(fmt, args...) \
37 printf("xenbus_xs (%s:%d) " fmt ".\n", __func__, __LINE__, ##args) 37 printf("xenbus_xs (%s:%d) " fmt ".\n", __func__, __LINE__, ##args)
38#else 38#else
39#define DPRINTK(fmt, args...) ((void)0) 39#define DPRINTK(fmt, args...) ((void)0)
40#endif  40#endif
41 41
42#include <sys/types.h> 42#include <sys/types.h>
43#include <sys/null.h> 43#include <sys/null.h>
44#include <sys/errno.h> 44#include <sys/errno.h>
45#include <sys/malloc.h> 45#include <sys/malloc.h>
46#include <sys/systm.h> 46#include <sys/systm.h>
@@ -835,43 +835,47 @@ process_msg(void) @@ -835,43 +835,47 @@ process_msg(void)
835static void 835static void
836xenbus_thread(void *unused) 836xenbus_thread(void *unused)
837{ 837{
838 int err; 838 int err;
839 839
840 for (;;) { 840 for (;;) {
841 err = process_msg(); 841 err = process_msg();
842 if (err) 842 if (err)
843 printk("XENBUS error %d while reading message\n", err); 843 printk("XENBUS error %d while reading message\n", err);
844 } 844 }
845} 845}
846 846
847int 847int
848xs_init(void) 848xs_init(device_t dev)
849{ 849{
850 int err; 850 int err;
851 851
852 SIMPLEQ_INIT(&xs_state.reply_list); 852 SIMPLEQ_INIT(&xs_state.reply_list);
853 simple_lock_init(&xs_state.reply_lock); 853 simple_lock_init(&xs_state.reply_lock);
854 mutex_init(&xs_state.xs_lock, MUTEX_DEFAULT, IPL_NONE); 854 mutex_init(&xs_state.xs_lock, MUTEX_DEFAULT, IPL_NONE);
855 855
856 err = kthread_create(PRI_NONE, 0, NULL, xenwatch_thread, 856 err = kthread_create(PRI_NONE, 0, NULL, xenwatch_thread,
857 NULL, NULL, "xenwatch"); 857 NULL, NULL, "xenwatch");
858 if (err) 858 if (err) {
859 printf("kthread_create(xenwatch): %d\n", err); 859 aprint_error_dev(dev, "kthread_create(xenwatch): %d\n", err);
 860 return err;
 861 }
860 862
861 err = kthread_create(PRI_NONE, 0, NULL, xenbus_thread, 863 err = kthread_create(PRI_NONE, 0, NULL, xenbus_thread,
862 NULL, NULL, "xenbus"); 864 NULL, NULL, "xenbus");
863 if (err) 865 if (err) {
864 printf("kthread_create(xenbus): %d\n", err); 866 aprint_error_dev(dev, "kthread_create(xenbus): %d\n", err);
 867 return err;
 868 }
865 869
866 return 0; 870 return 0;
867} 871}
868 872
869/* 873/*
870 * Local variables: 874 * Local variables:
871 * c-file-style: "linux" 875 * c-file-style: "linux"
872 * indent-tabs-mode: t 876 * indent-tabs-mode: t
873 * c-indent-level: 8 877 * c-indent-level: 8
874 * c-basic-offset: 8 878 * c-basic-offset: 8
875 * tab-width: 8 879 * tab-width: 8
876 * End: 880 * End:
877 */ 881 */