[IA64] esi-support
Add support for making ESI calls [1]. ESI stands for "Extensible SAL
specification" and is basically a way for invoking firmware
subroutines which are identified by a GUID. I don't know whether ESI
is used by vendors other than HP (if you do, please let me know) but
as firmware "backdoors" go, this seems one of the cleaner methods, so
it seems reasonable to support it, even though I'm not aware of any
publicly documented ESI calls. I'd have liked to make the ESI module
completely stand-alone, but unfortunately that is not easily (or not
at all) possible because in order to make ESI calls in physical mode,
a small stub similar to the EFI stub is needed in the kernel proper.
I did try to create a stub that would work in user-level, but it
quickly got ugly beyond recognition (e.g., the stub had to make
assumptions about how the module-loader generated call-stubs work) and
I didn't even get it to work (that's probably fixable, but I didn't
bother because I concluded it was too ugly anyhow). While it's not
terribly elegant to have kernel code which isn't actively used in the
kernel proper, I think it might be worth making an exception here for
two reasons: the code is trivially small (all that's really needed is
esi_stub.S) and by including it in the normal kernel distro, it might
encourage other OEMs to also use ESI, which I think would be far
better than each inventing their own firmware "backdoor".
The code was originally written by Alex. I just massaged and packaged
it a bit (and perhaps messed up some things along the way...).
Changes since first version of patch that was posted to mailing list:
* Export ia64_esi_call and ia64_esi_call_phys() as GPL symbols.
* Disallow building esi.c as a module for now. Building as a module
would currently lead to an unresolved reference to "sal_lock" on SMP kernels
because that symbol doesn't get exported.
* Export esi_call_phys() only if ESI is enabled.
* Remove internal stuff from esi.h and add a "proc_type" argument to
ia64_esi_call() such that serialization-requirements can be expressed (ESI
follows SAL here, where procedure calls may have to be serialized, are
MP-safe, or MP-safe andr reentrant).
[1] h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,919,00.html
Signed-off-by: David Mosberger <David.Mosberger@acm.org>
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
2006-06-21 11:19:22 -07:00
|
|
|
/*
|
|
|
|
* Extensible SAL Interface (ESI) support routines.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Hewlett-Packard Co
|
|
|
|
* Alex Williamson <alex.williamson@hp.com>
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
|
|
#include <asm/esi.h>
|
|
|
|
#include <asm/sal.h>
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Alex Williamson <alex.williamson@hp.com>");
|
|
|
|
MODULE_DESCRIPTION("Extensible SAL Interface (ESI) support");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
#define MODULE_NAME "esi"
|
|
|
|
|
|
|
|
#define ESI_TABLE_GUID \
|
|
|
|
EFI_GUID(0x43EA58DC, 0xCF28, 0x4b06, 0xB3, \
|
|
|
|
0x91, 0xB7, 0x50, 0x59, 0x34, 0x2B, 0xD4)
|
|
|
|
|
|
|
|
enum esi_systab_entry_type {
|
|
|
|
ESI_DESC_ENTRY_POINT = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entry type: Size:
|
|
|
|
* 0 48
|
|
|
|
*/
|
|
|
|
#define ESI_DESC_SIZE(type) "\060"[(unsigned) (type)]
|
|
|
|
|
|
|
|
typedef struct ia64_esi_desc_entry_point {
|
|
|
|
u8 type;
|
|
|
|
u8 reserved1[15];
|
|
|
|
u64 esi_proc;
|
|
|
|
u64 gp;
|
|
|
|
efi_guid_t guid;
|
|
|
|
} ia64_esi_desc_entry_point_t;
|
|
|
|
|
|
|
|
struct pdesc {
|
|
|
|
void *addr;
|
|
|
|
void *gp;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ia64_sal_systab *esi_systab;
|
|
|
|
|
|
|
|
static int __init esi_init (void)
|
|
|
|
{
|
|
|
|
efi_config_table_t *config_tables;
|
|
|
|
struct ia64_sal_systab *systab;
|
|
|
|
unsigned long esi = 0;
|
|
|
|
char *p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
config_tables = __va(efi.systab->tables);
|
|
|
|
|
|
|
|
for (i = 0; i < (int) efi.systab->nr_tables; ++i) {
|
|
|
|
if (efi_guidcmp(config_tables[i].guid, ESI_TABLE_GUID) == 0) {
|
|
|
|
esi = config_tables[i].table;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!esi)
|
2009-06-28 09:26:07 -07:00
|
|
|
return -ENODEV;
|
[IA64] esi-support
Add support for making ESI calls [1]. ESI stands for "Extensible SAL
specification" and is basically a way for invoking firmware
subroutines which are identified by a GUID. I don't know whether ESI
is used by vendors other than HP (if you do, please let me know) but
as firmware "backdoors" go, this seems one of the cleaner methods, so
it seems reasonable to support it, even though I'm not aware of any
publicly documented ESI calls. I'd have liked to make the ESI module
completely stand-alone, but unfortunately that is not easily (or not
at all) possible because in order to make ESI calls in physical mode,
a small stub similar to the EFI stub is needed in the kernel proper.
I did try to create a stub that would work in user-level, but it
quickly got ugly beyond recognition (e.g., the stub had to make
assumptions about how the module-loader generated call-stubs work) and
I didn't even get it to work (that's probably fixable, but I didn't
bother because I concluded it was too ugly anyhow). While it's not
terribly elegant to have kernel code which isn't actively used in the
kernel proper, I think it might be worth making an exception here for
two reasons: the code is trivially small (all that's really needed is
esi_stub.S) and by including it in the normal kernel distro, it might
encourage other OEMs to also use ESI, which I think would be far
better than each inventing their own firmware "backdoor".
The code was originally written by Alex. I just massaged and packaged
it a bit (and perhaps messed up some things along the way...).
Changes since first version of patch that was posted to mailing list:
* Export ia64_esi_call and ia64_esi_call_phys() as GPL symbols.
* Disallow building esi.c as a module for now. Building as a module
would currently lead to an unresolved reference to "sal_lock" on SMP kernels
because that symbol doesn't get exported.
* Export esi_call_phys() only if ESI is enabled.
* Remove internal stuff from esi.h and add a "proc_type" argument to
ia64_esi_call() such that serialization-requirements can be expressed (ESI
follows SAL here, where procedure calls may have to be serialized, are
MP-safe, or MP-safe andr reentrant).
[1] h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,919,00.html
Signed-off-by: David Mosberger <David.Mosberger@acm.org>
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
2006-06-21 11:19:22 -07:00
|
|
|
|
|
|
|
systab = __va(esi);
|
|
|
|
|
|
|
|
if (strncmp(systab->signature, "ESIT", 4) != 0) {
|
|
|
|
printk(KERN_ERR "bad signature in ESI system table!");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = (char *) (systab + 1);
|
|
|
|
for (i = 0; i < systab->entry_count; i++) {
|
|
|
|
/*
|
|
|
|
* The first byte of each entry type contains the type
|
|
|
|
* descriptor.
|
|
|
|
*/
|
|
|
|
switch (*p) {
|
|
|
|
case ESI_DESC_ENTRY_POINT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_WARNING "Unkown table type %d found in "
|
|
|
|
"ESI table, ignoring rest of table\n", *p);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
p += ESI_DESC_SIZE(*p);
|
|
|
|
}
|
|
|
|
|
|
|
|
esi_systab = systab;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ia64_esi_call (efi_guid_t guid, struct ia64_sal_retval *isrvp,
|
|
|
|
enum esi_proc_type proc_type, u64 func,
|
|
|
|
u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6,
|
|
|
|
u64 arg7)
|
|
|
|
{
|
|
|
|
struct ia64_fpreg fr[6];
|
|
|
|
unsigned long flags = 0;
|
|
|
|
int i;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (!esi_systab)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
p = (char *) (esi_systab + 1);
|
|
|
|
for (i = 0; i < esi_systab->entry_count; i++) {
|
|
|
|
if (*p == ESI_DESC_ENTRY_POINT) {
|
|
|
|
ia64_esi_desc_entry_point_t *esi = (void *)p;
|
|
|
|
if (!efi_guidcmp(guid, esi->guid)) {
|
|
|
|
ia64_sal_handler esi_proc;
|
|
|
|
struct pdesc pdesc;
|
|
|
|
|
|
|
|
pdesc.addr = __va(esi->esi_proc);
|
|
|
|
pdesc.gp = __va(esi->gp);
|
|
|
|
|
|
|
|
esi_proc = (ia64_sal_handler) &pdesc;
|
|
|
|
|
|
|
|
ia64_save_scratch_fpregs(fr);
|
|
|
|
if (proc_type == ESI_PROC_SERIALIZED)
|
|
|
|
spin_lock_irqsave(&sal_lock, flags);
|
|
|
|
else if (proc_type == ESI_PROC_MP_SAFE)
|
|
|
|
local_irq_save(flags);
|
|
|
|
else
|
|
|
|
preempt_disable();
|
|
|
|
*isrvp = (*esi_proc)(func, arg1, arg2, arg3,
|
|
|
|
arg4, arg5, arg6, arg7);
|
|
|
|
if (proc_type == ESI_PROC_SERIALIZED)
|
|
|
|
spin_unlock_irqrestore(&sal_lock,
|
|
|
|
flags);
|
|
|
|
else if (proc_type == ESI_PROC_MP_SAFE)
|
|
|
|
local_irq_restore(flags);
|
|
|
|
else
|
|
|
|
preempt_enable();
|
|
|
|
ia64_load_scratch_fpregs(fr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p += ESI_DESC_SIZE(*p);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(ia64_esi_call);
|
|
|
|
|
|
|
|
int ia64_esi_call_phys (efi_guid_t guid, struct ia64_sal_retval *isrvp,
|
|
|
|
u64 func, u64 arg1, u64 arg2, u64 arg3, u64 arg4,
|
|
|
|
u64 arg5, u64 arg6, u64 arg7)
|
|
|
|
{
|
|
|
|
struct ia64_fpreg fr[6];
|
|
|
|
unsigned long flags;
|
|
|
|
u64 esi_params[8];
|
|
|
|
char *p;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!esi_systab)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
p = (char *) (esi_systab + 1);
|
|
|
|
for (i = 0; i < esi_systab->entry_count; i++) {
|
|
|
|
if (*p == ESI_DESC_ENTRY_POINT) {
|
|
|
|
ia64_esi_desc_entry_point_t *esi = (void *)p;
|
|
|
|
if (!efi_guidcmp(guid, esi->guid)) {
|
|
|
|
ia64_sal_handler esi_proc;
|
|
|
|
struct pdesc pdesc;
|
|
|
|
|
|
|
|
pdesc.addr = (void *)esi->esi_proc;
|
|
|
|
pdesc.gp = (void *)esi->gp;
|
|
|
|
|
|
|
|
esi_proc = (ia64_sal_handler) &pdesc;
|
|
|
|
|
|
|
|
esi_params[0] = func;
|
|
|
|
esi_params[1] = arg1;
|
|
|
|
esi_params[2] = arg2;
|
|
|
|
esi_params[3] = arg3;
|
|
|
|
esi_params[4] = arg4;
|
|
|
|
esi_params[5] = arg5;
|
|
|
|
esi_params[6] = arg6;
|
|
|
|
esi_params[7] = arg7;
|
|
|
|
ia64_save_scratch_fpregs(fr);
|
|
|
|
spin_lock_irqsave(&sal_lock, flags);
|
|
|
|
*isrvp = esi_call_phys(esi_proc, esi_params);
|
|
|
|
spin_unlock_irqrestore(&sal_lock, flags);
|
|
|
|
ia64_load_scratch_fpregs(fr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p += ESI_DESC_SIZE(*p);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(ia64_esi_call_phys);
|
|
|
|
|
|
|
|
static void __exit esi_exit (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(esi_init);
|
|
|
|
module_exit(esi_exit); /* makes module removable... */
|