summaryrefslogtreecommitdiffstats
path: root/include/libtf/vmach.h
blob: d3023669cf4e873f2cef47cde182f743fb7ba077 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* vmach.h - "virtual" machine and cpu contexts
 *
 * Copyright (C) 2009 Timo Teräs <timo.teras@iki.fi>
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 or later as
 * published by the Free Software Foundation.
 *
 * See http://www.gnu.org/ for details.
 */

#ifndef TF_VMACH_H
#define TF_VMACH_H

#include <libtf/fiber.h>

struct tf_vmach {
	struct tf_poll_hooks *		poll_ops;
	void *				poll_fiber;
	void *				timeout_fiber;
	struct tf_fiber			startup_fiber;
	int				num_user_fibers;
	struct tf_list_head		run_q;
};

struct tf_vcpu {
	struct tf_vmach *		machine;
};

static inline struct tf_vmach *tf_vmach_get_current(void)
{
	extern __thread struct tf_vmach *tf_current_vmach;
	return tf_current_vmach;
}

static inline struct tf_vcpu *tf_vmach_get_current_cpu(void)
{
	extern __thread struct tf_vcpu *tf_current_vcpu;
	return tf_current_vcpu;
}

void tf_vmach_start(void);
void tf_vmach_stop(void);

void tf_vmach_run(struct tf_vmach *vm, struct tf_fiber *f);
void tf_vmach_run_dedicated(struct tf_vmach *vm, struct tf_fiber *f);

#endif