1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/of.h>
21#include <asm/epapr_hcalls.h>
22#include <asm/cacheflush.h>
23#include <asm/code-patching.h>
24#include <asm/machdep.h>
25
26#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
27extern void epapr_ev_idle(void);
28extern u32 epapr_ev_idle_start[];
29#endif
30
31bool epapr_paravirt_enabled;
32
33static int __init early_init_dt_scan_epapr(unsigned long node,
34 const char *uname,
35 int depth, void *data)
36{
37 const u32 *insts;
38 unsigned long len;
39 int i;
40
41 insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
42 if (!insts)
43 return 0;
44
45 if (len % 4 || len > (4 * 4))
46 return -1;
47
48 for (i = 0; i < (len / 4); i++) {
49 patch_instruction(epapr_hypercall_start + i, insts[i]);
50#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
51 patch_instruction(epapr_ev_idle_start + i, insts[i]);
52#endif
53 }
54
55#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
56 if (of_get_flat_dt_prop(node, "has-idle", NULL))
57 ppc_md.power_save = epapr_ev_idle;
58#endif
59
60 epapr_paravirt_enabled = true;
61
62 return 1;
63}
64
65int __init epapr_paravirt_early_init(void)
66{
67 of_scan_flat_dt(early_init_dt_scan_epapr, NULL);
68
69 return 0;
70}
71
72