Commit | Line | Data |
---|---|---|
2e1ae9c0 LYB |
1 | /* |
2 | * ePAPR para-virtualization support. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License, version 2, as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program; if not, write to the Free Software | |
15 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
16 | * | |
17 | * Copyright (C) 2012 Freescale Semiconductor, Inc. | |
18 | */ | |
19 | ||
20 | #include <linux/of.h> | |
21 | #include <asm/epapr_hcalls.h> | |
22 | #include <asm/cacheflush.h> | |
23 | #include <asm/code-patching.h> | |
2f979de8 LYB |
24 | #include <asm/machdep.h> |
25 | ||
26 | extern void epapr_ev_idle(void); | |
27 | extern u32 epapr_ev_idle_start[]; | |
2e1ae9c0 LYB |
28 | |
29 | bool epapr_paravirt_enabled; | |
30 | ||
31 | static int __init epapr_paravirt_init(void) | |
32 | { | |
33 | struct device_node *hyper_node; | |
34 | const u32 *insts; | |
35 | int len, i; | |
36 | ||
37 | hyper_node = of_find_node_by_path("/hypervisor"); | |
38 | if (!hyper_node) | |
39 | return -ENODEV; | |
40 | ||
41 | insts = of_get_property(hyper_node, "hcall-instructions", &len); | |
42 | if (!insts) | |
43 | return -ENODEV; | |
44 | ||
45 | if (len % 4 || len > (4 * 4)) | |
46 | return -ENODEV; | |
47 | ||
2f979de8 | 48 | for (i = 0; i < (len / 4); i++) { |
2e1ae9c0 | 49 | patch_instruction(epapr_hypercall_start + i, insts[i]); |
2f979de8 LYB |
50 | patch_instruction(epapr_ev_idle_start + i, insts[i]); |
51 | } | |
52 | ||
53 | if (of_get_property(hyper_node, "has-idle", NULL)) | |
54 | ppc_md.power_save = epapr_ev_idle; | |
2e1ae9c0 LYB |
55 | |
56 | epapr_paravirt_enabled = true; | |
57 | ||
58 | return 0; | |
59 | } | |
60 | ||
61 | early_initcall(epapr_paravirt_init); |