vaseboot/VasEBoot-core/commands/efi/lssal.c

164 lines
5.2 KiB
C

/* lssal.c - Display EFI SAL systab. */
/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#include <VasEBoot/types.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/normal.h>
#include <VasEBoot/charset.h>
#include <VasEBoot/efi/api.h>
#include <VasEBoot/efi/efi.h>
#include <VasEBoot/dl.h>
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static void
disp_sal (void *table)
{
struct VasEBoot_efi_sal_system_table *t = table;
void *desc;
VasEBoot_uint32_t len, l, i;
VasEBoot_printf ("SAL rev: %02x, signature: %x, len:%x\n",
t->sal_rev, t->signature, t->total_table_len);
VasEBoot_printf ("nbr entry: %d, chksum: %02x, SAL version A: %02x B: %02x\n",
t->entry_count, t->checksum,
t->sal_a_version, t->sal_b_version);
VasEBoot_printf ("OEM-ID: %-32s\n", t->oem_id);
VasEBoot_printf ("Product-ID: %-32s\n", t->product_id);
desc = t->entries;
len = t->total_table_len - sizeof (struct VasEBoot_efi_sal_system_table);
if (t->total_table_len <= sizeof (struct VasEBoot_efi_sal_system_table))
return;
for (i = 0; i < t->entry_count; i++)
{
switch (*(VasEBoot_uint8_t *) desc)
{
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR:
{
struct VasEBoot_efi_sal_system_table_entrypoint_descriptor *c = desc;
l = sizeof (*c);
VasEBoot_printf (" Entry point: PAL=%016" PRIxVAS_EBOOT_UINT64_T
" SAL=%016" PRIxVAS_EBOOT_UINT64_T " GP=%016"
PRIxVAS_EBOOT_UINT64_T "\n",
c->pal_proc_addr, c->sal_proc_addr,
c->global_data_ptr);
}
break;
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR:
{
struct VasEBoot_efi_sal_system_table_memory_descriptor *c = desc;
l = sizeof (*c);
VasEBoot_printf (" Memory descriptor entry addr=%016" PRIxVAS_EBOOT_UINT64_T
" len=%" PRIuVAS_EBOOT_UINT64_T "KB\n",
c->addr, c->len * 4);
VasEBoot_printf (" sal_used=%d attr=%x AR=%x attr_mask=%x "
"type=%x usage=%x\n",
c->sal_used, c->attr, c->ar, c->attr_mask, c->mem_type,
c->usage);
}
break;
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES:
{
struct VasEBoot_efi_sal_system_table_platform_features *c = desc;
l = sizeof (*c);
VasEBoot_printf (" Platform features: %02x", c->flags);
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK)
VasEBoot_printf (" BusLock");
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT)
VasEBoot_printf (" IrqRedirect");
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT)
VasEBoot_printf (" IPIRedirect");
if (c->flags & VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT)
VasEBoot_printf (" ITCDrift");
VasEBoot_printf ("\n");
}
break;
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR:
{
struct VasEBoot_efi_sal_system_table_translation_register_descriptor *c
= desc;
l = sizeof (*c);
VasEBoot_printf (" TR type=%d num=%d va=%016" PRIxVAS_EBOOT_UINT64_T
" pte=%016" PRIxVAS_EBOOT_UINT64_T "\n",
c->register_type, c->register_number,
c->addr, c->page_size);
}
break;
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE:
{
struct VasEBoot_efi_sal_system_table_purge_translation_coherence *c
= desc;
l = sizeof (*c);
VasEBoot_printf (" PTC coherence nbr=%d addr=%016" PRIxVAS_EBOOT_UINT64_T "\n",
c->ndomains, c->coherence);
}
break;
case VAS_EBOOT_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP:
{
struct VasEBoot_efi_sal_system_table_ap_wakeup *c = desc;
l = sizeof (*c);
VasEBoot_printf (" AP wake-up: mec=%d vect=%" PRIxVAS_EBOOT_UINT64_T "\n",
c->mechanism, c->vector);
}
break;
default:
VasEBoot_printf (" unknown entry 0x%x\n", *(VasEBoot_uint8_t *)desc);
return;
}
desc = (VasEBoot_uint8_t *)desc + l;
if (len <= l)
return;
len -= l;
}
}
static VasEBoot_err_t
VasEBoot_cmd_lssal (struct VasEBoot_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
static VasEBoot_guid_t guid = VAS_EBOOT_EFI_SAL_TABLE_GUID;
void *table = VasEBoot_efi_find_configuration_table (&guid);
if (table == NULL)
{
VasEBoot_printf ("SAL not found\n");
return VAS_EBOOT_ERR_NONE;
}
disp_sal (table);
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VAS_EBOOT_MOD_INIT(lssal)
{
cmd = VasEBoot_register_command ("lssal", VasEBoot_cmd_lssal, "",
"Display SAL system table.");
}
VAS_EBOOT_MOD_FINI(lssal)
{
VasEBoot_unregister_command (cmd);
}