paravirt.h 6.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/******************************************************************************
 * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
 *                    VA Linux Systems Japan K.K.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


#ifndef __ASM_PARAVIRT_H
#define __ASM_PARAVIRT_H

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#ifndef __ASSEMBLY__
/******************************************************************************
 * fsys related addresses
 */
struct pv_fsys_data {
	unsigned long *fsyscall_table;
	void *fsys_bubble_down;
};

extern struct pv_fsys_data pv_fsys_data;

unsigned long *paravirt_get_fsyscall_table(void);
char *paravirt_get_fsys_bubble_down(void);
#endif

40 41
#ifdef CONFIG_PARAVIRT_GUEST

42 43 44
#define PARAVIRT_HYPERVISOR_TYPE_DEFAULT	0
#define PARAVIRT_HYPERVISOR_TYPE_XEN		1

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#ifndef __ASSEMBLY__

#include <asm/hw_irq.h>
#include <asm/meminit.h>

/******************************************************************************
 * general info
 */
struct pv_info {
	unsigned int kernel_rpl;
	int paravirt_enabled;
	const char *name;
};

extern struct pv_info pv_info;

static inline int paravirt_enabled(void)
{
	return pv_info.paravirt_enabled;
}

static inline unsigned int get_kernel_rpl(void)
{
	return pv_info.kernel_rpl;
}

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
/******************************************************************************
 * initialization hooks.
 */
struct rsvd_region;

struct pv_init_ops {
	void (*banner)(void);

	int (*reserve_memory)(struct rsvd_region *region);

	void (*arch_setup_early)(void);
	void (*arch_setup_console)(char **cmdline_p);
	int (*arch_setup_nomca)(void);

	void (*post_smp_prepare_boot_cpu)(void);
};

extern struct pv_init_ops pv_init_ops;

static inline void paravirt_banner(void)
{
	if (pv_init_ops.banner)
		pv_init_ops.banner();
}

static inline int paravirt_reserve_memory(struct rsvd_region *region)
{
	if (pv_init_ops.reserve_memory)
		return pv_init_ops.reserve_memory(region);
	return 0;
}

static inline void paravirt_arch_setup_early(void)
{
	if (pv_init_ops.arch_setup_early)
		pv_init_ops.arch_setup_early();
}

static inline void paravirt_arch_setup_console(char **cmdline_p)
{
	if (pv_init_ops.arch_setup_console)
		pv_init_ops.arch_setup_console(cmdline_p);
}

static inline int paravirt_arch_setup_nomca(void)
{
	if (pv_init_ops.arch_setup_nomca)
		return pv_init_ops.arch_setup_nomca();
	return 0;
}

static inline void paravirt_post_smp_prepare_boot_cpu(void)
{
	if (pv_init_ops.post_smp_prepare_boot_cpu)
		pv_init_ops.post_smp_prepare_boot_cpu();
}

128 129 130 131 132 133 134
/******************************************************************************
 * replacement of iosapic operations.
 */

struct pv_iosapic_ops {
	void (*pcat_compat_init)(void);

135
	struct irq_chip *(*__get_irq_chip)(unsigned long trigger);
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

	unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
	void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
};

extern struct pv_iosapic_ops pv_iosapic_ops;

static inline void
iosapic_pcat_compat_init(void)
{
	if (pv_iosapic_ops.pcat_compat_init)
		pv_iosapic_ops.pcat_compat_init();
}

static inline struct irq_chip*
iosapic_get_irq_chip(unsigned long trigger)
{
153
	return pv_iosapic_ops.__get_irq_chip(trigger);
154 155 156 157 158 159 160 161 162 163 164 165 166 167
}

static inline unsigned int
__iosapic_read(char __iomem *iosapic, unsigned int reg)
{
	return pv_iosapic_ops.__read(iosapic, reg);
}

static inline void
__iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
{
	return pv_iosapic_ops.__write(iosapic, reg, val);
}

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
/******************************************************************************
 * replacement of irq operations.
 */

struct pv_irq_ops {
	void (*register_ipi)(void);

	int (*assign_irq_vector)(int irq);
	void (*free_irq_vector)(int vector);

	void (*register_percpu_irq)(ia64_vector vec,
				    struct irqaction *action);

	void (*resend_irq)(unsigned int vector);
};

extern struct pv_irq_ops pv_irq_ops;

static inline void
ia64_register_ipi(void)
{
	pv_irq_ops.register_ipi();
}

static inline int
assign_irq_vector(int irq)
{
	return pv_irq_ops.assign_irq_vector(irq);
}

static inline void
free_irq_vector(int vector)
{
	return pv_irq_ops.free_irq_vector(vector);
}

static inline void
register_percpu_irq(ia64_vector vec, struct irqaction *action)
{
	pv_irq_ops.register_percpu_irq(vec, action);
}

static inline void
ia64_resend_irq(unsigned int vector)
{
	pv_irq_ops.resend_irq(vector);
}

216 217 218 219 220 221 222 223 224 225 226 227
/******************************************************************************
 * replacement of time operations.
 */

extern struct itc_jitter_data_t itc_jitter_data;
extern volatile int time_keeper_id;

struct pv_time_ops {
	void (*init_missing_ticks_accounting)(int cpu);
	int (*do_steal_accounting)(unsigned long *new_itm);

	void (*clocksource_resume)(void);
228 229

	unsigned long long (*sched_clock)(void);
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
};

extern struct pv_time_ops pv_time_ops;

static inline void
paravirt_init_missing_ticks_accounting(int cpu)
{
	if (pv_time_ops.init_missing_ticks_accounting)
		pv_time_ops.init_missing_ticks_accounting(cpu);
}

static inline int
paravirt_do_steal_accounting(unsigned long *new_itm)
{
	return pv_time_ops.do_steal_accounting(new_itm);
}

247 248 249 250 251
static inline unsigned long long paravirt_sched_clock(void)
{
	return pv_time_ops.sched_clock();
}

252 253 254 255 256
#endif /* !__ASSEMBLY__ */

#else
/* fallback for native case */

257 258 259 260 261 262 263 264 265 266
#ifndef __ASSEMBLY__

#define paravirt_banner()				do { } while (0)
#define paravirt_reserve_memory(region)			0

#define paravirt_arch_setup_early()			do { } while (0)
#define paravirt_arch_setup_console(cmdline_p)		do { } while (0)
#define paravirt_arch_setup_nomca()			0
#define paravirt_post_smp_prepare_boot_cpu()		do { } while (0)

267 268 269
#define paravirt_init_missing_ticks_accounting(cpu)	do { } while (0)
#define paravirt_do_steal_accounting(new_itm)		0

270 271 272
#endif /* __ASSEMBLY__ */


273 274 275
#endif /* CONFIG_PARAVIRT_GUEST */

#endif /* __ASM_PARAVIRT_H */