1207673Sjoel/*-
2207673Sjoel * Copyright (c) 2004, 2005 Kip Macy
3181638Skmacy * All rights reserved.
4181638Skmacy *
5181638Skmacy * Redistribution and use in source and binary forms, with or without
6181638Skmacy * modification, are permitted provided that the following conditions
7181638Skmacy * are met:
8181638Skmacy * 1. Redistributions of source code must retain the above copyright
9181638Skmacy *    notice, this list of conditions and the following disclaimer.
10181638Skmacy * 2. Redistributions in binary form must reproduce the above copyright
11181638Skmacy *    notice, this list of conditions and the following disclaimer in the
12181638Skmacy *    documentation and/or other materials provided with the distribution.
13181638Skmacy *
14207673Sjoel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15207673Sjoel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16207673Sjoel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17207673Sjoel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18207673Sjoel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19207673Sjoel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20207673Sjoel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21207673Sjoel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22207673Sjoel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23207673Sjoel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24207673Sjoel * SUCH DAMAGE.
25181638Skmacy *
26181638Skmacy * $FreeBSD$
27181638Skmacy */
28181638Skmacy
29181638Skmacy#ifndef _XEN_XENFUNC_H_
30181638Skmacy#define _XEN_XENFUNC_H_
31181638Skmacy
32255040Sgibbs#include <xen/xen-os.h>
33186557Skmacy#include <xen/hypervisor.h>
34255040Sgibbs
35255040Sgibbs#include <vm/pmap.h>
36255040Sgibbs
37181638Skmacy#include <machine/xen/xenpmap.h>
38181638Skmacy#include <machine/segments.h>
39255040Sgibbs
40181638Skmacy#include <sys/pcpu.h>
41181638Skmacy#define BKPT __asm__("int3");
42181638Skmacy#define XPQ_CALL_DEPTH 5
43181638Skmacy#define XPQ_CALL_COUNT 2
44181638Skmacy#define PG_PRIV PG_AVAIL3
45181638Skmacytypedef struct {
46181638Skmacy	unsigned long pt_ref;
47181638Skmacy	unsigned long pt_eip[XPQ_CALL_COUNT][XPQ_CALL_DEPTH];
48181638Skmacy} pteinfo_t;
49181638Skmacy
50181638Skmacyextern pteinfo_t *pteinfo_list;
51181638Skmacy#ifdef XENDEBUG_LOW
52181638Skmacy#define	__PRINTK(x) printk x
53181638Skmacy#else
54181638Skmacy#define	__PRINTK(x)
55181638Skmacy#endif
56181638Skmacy
57181638Skmacychar *xen_setbootenv(char *cmd_line);
58181638Skmacy
59181638Skmacyint  xen_boothowto(char *envp);
60181638Skmacy
61181810Skmacyvoid _xen_machphys_update(vm_paddr_t, vm_paddr_t, char *file, int line);
62181638Skmacy
63181638Skmacy#ifdef INVARIANTS
64181638Skmacy#define xen_machphys_update(a, b) _xen_machphys_update((a), (b), __FILE__, __LINE__)
65181638Skmacy#else
66181638Skmacy#define xen_machphys_update(a, b) _xen_machphys_update((a), (b), NULL, 0)
67181638Skmacy#endif
68181638Skmacy
69181638Skmacyvoid xen_update_descriptor(union descriptor *, union descriptor *);
70181638Skmacy
71181638Skmacyextern struct mtx balloon_lock;
72181638Skmacy#if 0
73181638Skmacy#define balloon_lock(__flags)   mtx_lock_irqsave(&balloon_lock, __flags)
74181638Skmacy#define balloon_unlock(__flags) mtx_unlock_irqrestore(&balloon_lock, __flags)
75181638Skmacy#else
76181638Skmacy#define balloon_lock(__flags)   __flags = 1
77181638Skmacy#define balloon_unlock(__flags) __flags = 0
78181638Skmacy#endif
79181638Skmacy
80181638Skmacy
81181638Skmacy
82181638Skmacy#endif /* _XEN_XENFUNC_H_ */
83