]> rtime.felk.cvut.cz Git - jailhouse.git/blob - inmates/demos/arm/uart-demo.c
arm: basic inmates demos
[jailhouse.git] / inmates / demos / arm / uart-demo.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) ARM Limited, 2014
5  *
6  * Authors:
7  *  Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <inmates/inmate.h>
14
15 /*
16  * To ease the debugging, we can send a spurious hypercall, which should return
17  * -ENOSYS, but appear in the hypervisor stats for this cell.
18  */
19 static void heartbeat(void)
20 {
21         asm volatile (
22         ".arch_extension virt\n"
23         "mov    r0, %0\n"
24         "hvc    #0\n"
25         : : "r" (0xbea7) : "r0");
26 }
27
28 void inmate_main(void)
29 {
30         unsigned int i = 0, j;
31         /*
32          * The cell config can set up a mapping to access UARTx instead of UART0
33          */
34         while(++i) {
35                 for (j = 0; j < 100000000; j++);
36                 printk("Hello %d from cell!\n", i);
37                 heartbeat();
38         }
39
40         /* lr should be 0, so a return will go back to the reset vector */
41 }