blob: 5481eb59f783ef21c4fcbf0b444b419ec8360d94 [file] [log] [blame]
Russ Anderson7019cc22008-07-09 15:27:19 -05001/*
2 * BIOS run time interface routines.
3 *
Russ Anderson7019cc22008-07-09 15:27:19 -05004 * 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
Russ Anderson7f594232008-10-03 11:59:15 -050017 *
18 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
19 * Copyright (c) Russ Anderson
Russ Anderson7019cc22008-07-09 15:27:19 -050020 */
21
Russ Anderson7f594232008-10-03 11:59:15 -050022#include <linux/efi.h>
23#include <asm/efi.h>
24#include <linux/io.h>
Russ Anderson7019cc22008-07-09 15:27:19 -050025#include <asm/uv/bios.h>
26
Russ Anderson7f594232008-10-03 11:59:15 -050027struct uv_systab uv_systab;
28
29s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5)
Russ Anderson7019cc22008-07-09 15:27:19 -050030{
Russ Anderson7f594232008-10-03 11:59:15 -050031 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);
41}
42
43s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
44 u64 a4, u64 a5)
45{
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
56s64 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();
64
65 return ret;
Russ Anderson7019cc22008-07-09 15:27:19 -050066}
67
68long
Russ Anderson7f594232008-10-03 11:59:15 -050069x86_bios_freq_base(unsigned long clock_type, unsigned long *ticks_per_second,
70 unsigned long *drift_info)
Russ Anderson7019cc22008-07-09 15:27:19 -050071{
Russ Anderson7f594232008-10-03 11:59:15 -050072 return uv_bios_call(UV_BIOS_FREQ_BASE, clock_type,
73 (u64)ticks_per_second, 0, 0, 0);
Russ Anderson7019cc22008-07-09 15:27:19 -050074}
75EXPORT_SYMBOL_GPL(x86_bios_freq_base);
Russ Anderson7f594232008-10-03 11:59:15 -050076
77
78#ifdef CONFIG_EFI
79void 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
105void uv_bios_init(void) { }
106#endif
107