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