Commit | Line | Data |
---|---|---|
7019cc2d RA |
1 | /* |
2 | * BIOS run time interface routines. | |
3 | * | |
7019cc2d RA |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
7f594232 RA |
17 | * |
18 | * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. | |
19 | * Copyright (c) Russ Anderson | |
7019cc2d RA |
20 | */ |
21 | ||
7f594232 RA |
22 | #include <linux/efi.h> |
23 | #include <asm/efi.h> | |
24 | #include <linux/io.h> | |
7019cc2d RA |
25 | #include <asm/uv/bios.h> |
26 | ||
7f594232 RA |
27 | struct uv_systab uv_systab; |
28 | ||
29 | s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5) | |
7019cc2d | 30 | { |
7f594232 RA |
31 | struct uv_systab *tab = &uv_systab; |
32 | ||
33 | if (!tab->function) | |
34 | /* | |
35 | * BIOS does not support UV systab | |
36 | */ | |
37 | return BIOS_STATUS_UNIMPLEMENTED; | |
38 | ||
39 | return efi_call6((void *)__va(tab->function), | |
40 | (u64)which, a1, a2, a3, a4, a5); | |
7019cc2d RA |
41 | } |
42 | ||
7f594232 RA |
43 | s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, |
44 | u64 a4, u64 a5) | |
7019cc2d | 45 | { |
7f594232 RA |
46 | unsigned long bios_flags; |
47 | s64 ret; | |
48 | ||
49 | local_irq_save(bios_flags); | |
50 | ret = uv_bios_call(which, a1, a2, a3, a4, a5); | |
51 | local_irq_restore(bios_flags); | |
52 | ||
53 | return ret; | |
54 | } | |
55 | ||
56 | s64 uv_bios_call_reentrant(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, | |
57 | u64 a4, u64 a5) | |
58 | { | |
59 | s64 ret; | |
60 | ||
61 | preempt_disable(); | |
62 | ret = uv_bios_call(which, a1, a2, a3, a4, a5); | |
63 | preempt_enable(); | |
7019cc2d | 64 | |
7f594232 RA |
65 | return ret; |
66 | } | |
67 | ||
68 | long | |
69 | x86_bios_freq_base(unsigned long clock_type, unsigned long *ticks_per_second, | |
70 | unsigned long *drift_info) | |
71 | { | |
72 | return uv_bios_call(UV_BIOS_FREQ_BASE, clock_type, | |
73 | (u64)ticks_per_second, 0, 0, 0); | |
7019cc2d RA |
74 | } |
75 | EXPORT_SYMBOL_GPL(x86_bios_freq_base); | |
7f594232 RA |
76 | |
77 | ||
78 | #ifdef CONFIG_EFI | |
79 | void uv_bios_init(void) | |
80 | { | |
81 | struct uv_systab *tab; | |
82 | ||
83 | if ((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || | |
84 | (efi.uv_systab == (unsigned long)NULL)) { | |
85 | printk(KERN_CRIT "No EFI UV System Table.\n"); | |
86 | uv_systab.function = (unsigned long)NULL; | |
87 | return; | |
88 | } | |
89 | ||
90 | tab = (struct uv_systab *)ioremap(efi.uv_systab, | |
91 | sizeof(struct uv_systab)); | |
92 | if (strncmp(tab->signature, "UVST", 4) != 0) | |
93 | printk(KERN_ERR "bad signature in UV system table!"); | |
94 | ||
95 | /* | |
96 | * Copy table to permanent spot for later use. | |
97 | */ | |
98 | memcpy(&uv_systab, tab, sizeof(struct uv_systab)); | |
99 | iounmap(tab); | |
100 | ||
101 | printk(KERN_INFO "EFI UV System Table Revision %d\n", tab->revision); | |
102 | } | |
103 | #else /* !CONFIG_EFI */ | |
104 | ||
105 | void uv_bios_init(void) { } | |
106 | #endif | |
107 |