aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuss Anderson <rja@sgi.com>2008-10-03 12:59:15 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-16 10:53:13 -0400
commit7f5942329e0787087a5e4dced838cee711ac2b58 (patch)
tree7bf3d4d91e15694977ff5d46bf6ceab7ebbd6c54
parenta50f70b17541c0060967c6df61133e968bad3652 (diff)
x86: Add UV bios call infrastructure v4
Add the EFI callback function and associated wrapper code. Initialize SAL system table entry info at boot time. Signed-off-by: Russ Anderson <rja@sgi.com> Signed-off-by: Paul Jackson <pj@sgi.com> Acked-by: Huang Ying <ying.huang@intel.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/bios_uv.c101
-rw-r--r--arch/x86/kernel/genx2apic_uv_x.c1
-rw-r--r--include/asm-x86/efi.h13
-rw-r--r--include/asm-x86/uv/bios.h73
4 files changed, 135 insertions, 53 deletions
diff --git a/arch/x86/kernel/bios_uv.c b/arch/x86/kernel/bios_uv.c
index fdd585f9c53d..5481eb59f783 100644
--- a/arch/x86/kernel/bios_uv.c
+++ b/arch/x86/kernel/bios_uv.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * BIOS run time interface routines. 2 * BIOS run time interface routines.
3 * 3 *
4 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
@@ -16,33 +14,94 @@
16 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
19 * Copyright (c) Russ Anderson
19 */ 20 */
20 21
22#include <linux/efi.h>
23#include <asm/efi.h>
24#include <linux/io.h>
21#include <asm/uv/bios.h> 25#include <asm/uv/bios.h>
22 26
23const char * 27struct uv_systab uv_systab;
24x86_bios_strerror(long status) 28
29s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5)
25{ 30{
26 const char *str; 31 struct uv_systab *tab = &uv_systab;
27 switch (status) { 32
28 case 0: str = "Call completed without error"; break; 33 if (!tab->function)
29 case -1: str = "Not implemented"; break; 34 /*
30 case -2: str = "Invalid argument"; break; 35 * BIOS does not support UV systab
31 case -3: str = "Call completed with error"; break; 36 */
32 default: str = "Unknown BIOS status code"; break; 37 return BIOS_STATUS_UNIMPLEMENTED;
33 } 38
34 return str; 39 return efi_call6((void *)__va(tab->function),
40 (u64)which, a1, a2, a3, a4, a5);
35} 41}
36 42
37long 43s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
38x86_bios_freq_base(unsigned long which, unsigned long *ticks_per_second, 44 u64 a4, u64 a5)
39 unsigned long *drift_info)
40{ 45{
41 struct uv_bios_retval isrv; 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();
42 64
43 BIOS_CALL(isrv, BIOS_FREQ_BASE, which, 0, 0, 0, 0, 0, 0); 65 return ret;
44 *ticks_per_second = isrv.v0; 66}
45 *drift_info = isrv.v1; 67
46 return isrv.status; 68long
69x86_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);
47} 74}
48EXPORT_SYMBOL_GPL(x86_bios_freq_base); 75EXPORT_SYMBOL_GPL(x86_bios_freq_base);
76
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
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index b689075bbe2f..aa2e5e15bf69 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -427,6 +427,7 @@ void __init uv_system_init(void)
427 gnode_upper = (((unsigned long)node_id.s.node_id) & 427 gnode_upper = (((unsigned long)node_id.s.node_id) &
428 ~((1 << n_val) - 1)) << m_val; 428 ~((1 << n_val) - 1)) << m_val;
429 429
430 uv_bios_init();
430 uv_rtc_init(); 431 uv_rtc_init();
431 432
432 for_each_present_cpu(cpu) { 433 for_each_present_cpu(cpu) {
diff --git a/include/asm-x86/efi.h b/include/asm-x86/efi.h
index ed2de22e8705..313438e63348 100644
--- a/include/asm-x86/efi.h
+++ b/include/asm-x86/efi.h
@@ -94,4 +94,17 @@ extern void efi_reserve_early(void);
94extern void efi_call_phys_prelog(void); 94extern void efi_call_phys_prelog(void);
95extern void efi_call_phys_epilog(void); 95extern void efi_call_phys_epilog(void);
96 96
97#ifndef CONFIG_EFI
98/*
99 * IF EFI is not configured, have the EFI calls return -ENOSYS.
100 */
101#define efi_call0(_f) (-ENOSYS)
102#define efi_call1(_f, _a1) (-ENOSYS)
103#define efi_call2(_f, _a1, _a2) (-ENOSYS)
104#define efi_call3(_f, _a1, _a2, _a3) (-ENOSYS)
105#define efi_call4(_f, _a1, _a2, _a3, _a4) (-ENOSYS)
106#define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS)
107#define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS)
108#endif /* CONFIG_EFI */
109
97#endif /* ASM_X86__EFI_H */ 110#endif /* ASM_X86__EFI_H */
diff --git a/include/asm-x86/uv/bios.h b/include/asm-x86/uv/bios.h
index 7cd6d7ec1308..f63e46e5337c 100644
--- a/include/asm-x86/uv/bios.h
+++ b/include/asm-x86/uv/bios.h
@@ -2,9 +2,7 @@
2#define ASM_X86__UV__BIOS_H 2#define ASM_X86__UV__BIOS_H
3 3
4/* 4/*
5 * BIOS layer definitions. 5 * UV BIOS layer definitions.
6 *
7 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
8 * 6 *
9 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -19,50 +17,61 @@
19 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
22 * Copyright (c) Russ Anderson
22 */ 23 */
23 24
24#include <linux/rtc.h> 25#include <linux/rtc.h>
25 26
26#define BIOS_FREQ_BASE 0x01000001 27/*
28 * Values for the BIOS calls. It is passed as the first * argument in the
29 * BIOS call. Passing any other value in the first argument will result
30 * in a BIOS_STATUS_UNIMPLEMENTED return status.
31 */
32enum uv_bios_cmd {
33 UV_BIOS_COMMON,
34 UV_BIOS_GET_SN_INFO,
35 UV_BIOS_FREQ_BASE
36};
27 37
38/*
39 * Status values returned from a BIOS call.
40 */
28enum { 41enum {
29 BIOS_FREQ_BASE_PLATFORM = 0, 42 BIOS_STATUS_SUCCESS = 0,
30 BIOS_FREQ_BASE_INTERVAL_TIMER = 1, 43 BIOS_STATUS_UNIMPLEMENTED = -ENOSYS,
31 BIOS_FREQ_BASE_REALTIME_CLOCK = 2 44 BIOS_STATUS_EINVAL = -EINVAL,
45 BIOS_STATUS_UNAVAIL = -EBUSY
32}; 46};
33 47
34# define BIOS_CALL(result, a0, a1, a2, a3, a4, a5, a6, a7) \ 48/*
35 do { \ 49 * The UV system table describes specific firmware
36 /* XXX - the real call goes here */ \ 50 * capabilities available to the Linux kernel at runtime.
37 result.status = BIOS_STATUS_UNIMPLEMENTED; \ 51 */
38 isrv.v0 = 0; \ 52struct uv_systab {
39 isrv.v1 = 0; \ 53 char signature[4]; /* must be "UVST" */
40 } while (0) 54 u32 revision; /* distinguish different firmware revs */
55 u64 function; /* BIOS runtime callback function ptr */
56};
41 57
42enum { 58enum {
43 BIOS_STATUS_SUCCESS = 0, 59 BIOS_FREQ_BASE_PLATFORM = 0,
44 BIOS_STATUS_UNIMPLEMENTED = -1, 60 BIOS_FREQ_BASE_INTERVAL_TIMER = 1,
45 BIOS_STATUS_EINVAL = -2, 61 BIOS_FREQ_BASE_REALTIME_CLOCK = 2
46 BIOS_STATUS_ERROR = -3
47}; 62};
48 63
49struct uv_bios_retval { 64/*
50 /* 65 * bios calls have 6 parameters
51 * A zero status value indicates call completed without error. 66 */
52 * A negative status value indicates reason of call failure. 67extern s64 uv_bios_call(enum uv_bios_cmd, u64, u64, u64, u64, u64);
53 * A positive status value indicates success but an 68extern s64 uv_bios_call_irqsave(enum uv_bios_cmd, u64, u64, u64, u64, u64);
54 * informational value should be printed (e.g., "reboot for 69extern s64 uv_bios_call_reentrant(enum uv_bios_cmd, u64, u64, u64, u64, u64);
55 * change to take effect"). 70
56 */ 71extern void uv_bios_init(void);
57 s64 status;
58 u64 v0;
59 u64 v1;
60 u64 v2;
61};
62 72
63extern long 73extern long
64x86_bios_freq_base(unsigned long which, unsigned long *ticks_per_second, 74x86_bios_freq_base(unsigned long which, unsigned long *ticks_per_second,
65 unsigned long *drift_info); 75 unsigned long *drift_info);
66extern const char *x86_bios_strerror(long status);
67 76
68#endif /* ASM_X86__UV__BIOS_H */ 77#endif /* ASM_X86__UV__BIOS_H */