Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 1 | /* |
| 2 | * BIOS run time interface routines. |
| 3 | * |
Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 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 |
Russ Anderson | 7f59423 | 2008-10-03 11:59:15 -0500 | [diff] [blame^] | 17 | * |
| 18 | * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. |
| 19 | * Copyright (c) Russ Anderson |
Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 20 | */ |
| 21 | |
Russ Anderson | 7f59423 | 2008-10-03 11:59:15 -0500 | [diff] [blame^] | 22 | #include <linux/efi.h> |
| 23 | #include <asm/efi.h> |
| 24 | #include <linux/io.h> |
Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 25 | #include <asm/uv/bios.h> |
| 26 | |
Russ Anderson | 7f59423 | 2008-10-03 11:59:15 -0500 | [diff] [blame^] | 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) |
Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 30 | { |
Russ Anderson | 7f59423 | 2008-10-03 11:59:15 -0500 | [diff] [blame^] | 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); |
| 41 | } |
| 42 | |
| 43 | s64 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 | |
| 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(); |
| 64 | |
| 65 | return ret; |
Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | long |
Russ Anderson | 7f59423 | 2008-10-03 11:59:15 -0500 | [diff] [blame^] | 69 | x86_bios_freq_base(unsigned long clock_type, unsigned long *ticks_per_second, |
| 70 | unsigned long *drift_info) |
Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 71 | { |
Russ Anderson | 7f59423 | 2008-10-03 11:59:15 -0500 | [diff] [blame^] | 72 | return uv_bios_call(UV_BIOS_FREQ_BASE, clock_type, |
| 73 | (u64)ticks_per_second, 0, 0, 0); |
Russ Anderson | 7019cc2 | 2008-07-09 15:27:19 -0500 | [diff] [blame] | 74 | } |
| 75 | EXPORT_SYMBOL_GPL(x86_bios_freq_base); |
Russ Anderson | 7f59423 | 2008-10-03 11:59:15 -0500 | [diff] [blame^] | 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 | |