summaryrefslogtreecommitdiff
path: root/robot/hypervisor.c
blob: dbdc62a30c7208573a076f257d0f9abc043d7538 (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
#include "hypervisor.h"
#include "consts.h"
#include "errcatch.h"
#include "io.h"
#include "modes.h"
#include "orangutan_shim.h"
#include "sercomm.h"

void w2_hypervisor_main() {
	time_reset();

	w2_sercomm_main();
	unsigned long sercomm_time = get_ms();
	w2_errcatch_main();
	unsigned long errcatch_time = get_ms() - sercomm_time;
	w2_io_main();
	unsigned long io_time = get_ms() - errcatch_time;
	w2_modes_main();
	unsigned long mode_time = get_ms() - io_time;

#ifdef W2_SIM
	siminfo("sercomm:  %lums\n", sercomm_time);
	siminfo("errcatch: %lums\n", errcatch_time);
	siminfo("io:       %lums\n", io_time);
	siminfo("mode:     %lums\n", mode_time);

	usleep(100e3);
#endif

	if (mode_time > W2_MAX_MODULE_CYCLE_MS) w2_errcatch_throw(W2_E_WARN_CYCLE_EXPIRED);
}