efivars: Refactor sanity checking code into separate function
[linux/fpc-iii.git] / arch / powerpc / kernel / epapr_paravirt.c
blob7898be90f2dcd013ecec5d17dcb4897e9a1b62f7
1 /*
2 * ePAPR para-virtualization support.
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.
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.
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.
17 * Copyright (C) 2012 Freescale Semiconductor, Inc.
20 #include <linux/of.h>
21 #include <linux/of_fdt.h>
22 #include <asm/epapr_hcalls.h>
23 #include <asm/cacheflush.h>
24 #include <asm/code-patching.h>
25 #include <asm/machdep.h>
27 #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
28 extern void epapr_ev_idle(void);
29 extern u32 epapr_ev_idle_start[];
30 #endif
32 bool epapr_paravirt_enabled;
34 static int __init early_init_dt_scan_epapr(unsigned long node,
35 const char *uname,
36 int depth, void *data)
38 const u32 *insts;
39 unsigned long len;
40 int i;
42 insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
43 if (!insts)
44 return 0;
46 if (len % 4 || len > (4 * 4))
47 return -1;
49 for (i = 0; i < (len / 4); i++) {
50 patch_instruction(epapr_hypercall_start + i, insts[i]);
51 #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
52 patch_instruction(epapr_ev_idle_start + i, insts[i]);
53 #endif
56 #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
57 if (of_get_flat_dt_prop(node, "has-idle", NULL))
58 ppc_md.power_save = epapr_ev_idle;
59 #endif
61 epapr_paravirt_enabled = true;
63 return 1;
66 int __init epapr_paravirt_early_init(void)
68 of_scan_flat_dt(early_init_dt_scan_epapr, NULL);
70 return 0;