]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/arm/setup.c
arm: implement the cell creation
[jailhouse.git] / hypervisor / arch / arm / setup.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.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 <asm/control.h>
14 #include <asm/irqchip.h>
15 #include <asm/percpu.h>
16 #include <asm/platform.h>
17 #include <asm/setup.h>
18 #include <asm/sysregs.h>
19 #include <jailhouse/control.h>
20 #include <jailhouse/entry.h>
21 #include <jailhouse/paging.h>
22 #include <jailhouse/string.h>
23
24 static int arch_check_features(void)
25 {
26         u32 pfr1;
27         arm_read_sysreg(ID_PFR1_EL1, pfr1);
28
29         if (!PFR1_VIRT(pfr1))
30                 return -ENODEV;
31
32         return 0;
33 }
34
35 int arch_init_early(void)
36 {
37         int err = 0;
38
39         if ((err = arch_check_features()) != 0)
40                 return err;
41
42         err = arch_mmu_cell_init(&root_cell);
43         if (err)
44                 return err;
45
46         err = arch_map_device(UART_BASE_PHYS, UART_BASE_VIRT, PAGE_SIZE);
47
48         return err;
49 }
50
51 int arch_cpu_init(struct per_cpu *cpu_data)
52 {
53         int err = 0;
54         unsigned long hcr = HCR_VM_BIT | HCR_IMO_BIT | HCR_FMO_BIT;
55
56         cpu_data->psci_mbox.entry = 0;
57
58         /*
59          * Copy the registers to restore from the linux stack here, because we
60          * won't be able to access it later
61          */
62         memcpy(&cpu_data->linux_reg, (void *)cpu_data->linux_sp, NUM_ENTRY_REGS
63                         * sizeof(unsigned long));
64
65         err = switch_exception_level(cpu_data);
66         if (err)
67                 return err;
68
69         /*
70          * Save pointer in the thread local storage
71          * Must be done early in order to handle aborts and errors in the setup
72          * code.
73          */
74         arm_write_sysreg(TPIDR_EL2, cpu_data);
75
76         /* Setup guest traps */
77         arm_write_sysreg(HCR, hcr);
78
79         err = arch_mmu_cpu_cell_init(cpu_data);
80         if (err)
81                 return err;
82
83         err = irqchip_init();
84         if (err)
85                 return err;
86
87         err = irqchip_cpu_init(cpu_data);
88
89         return err;
90 }
91
92 int arch_init_late(void)
93 {
94         return map_root_memory_regions();
95 }
96
97 void arch_cpu_activate_vmm(struct per_cpu *cpu_data)
98 {
99         /* Return to the kernel */
100         cpu_return_el1(cpu_data);
101
102         while (1);
103 }
104
105 void arch_cpu_restore(struct per_cpu *cpu_data)
106 {
107 }
108
109 // catch missing symbols
110 void arch_shutdown_cpu(unsigned int cpu_id) {}
111 void arch_flush_cell_vcpu_caches(struct cell *cell) {}
112 void arch_cell_destroy(struct cell *new_cell) {}
113 void arch_config_commit(struct cell *cell_added_removed) {}
114 void arch_shutdown(void) {}
115 void arch_panic_stop(void) {__builtin_unreachable();}
116 void arch_panic_park(void) {}