vaseboot/VasEBoot-core/commands/mips/loongson/lsspd.c

104 lines
3.2 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2010 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/misc.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/err.h>
#include <VasEBoot/dl.h>
#include <VasEBoot/command.h>
#include <VasEBoot/cs5536.h>
#include <VasEBoot/i18n.h>
VAS_EBOOT_MOD_LICENSE ("GPLv3+");
static VasEBoot_err_t
VasEBoot_cmd_lsspd (VasEBoot_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
VasEBoot_pci_device_t dev;
VasEBoot_port_t smbbase;
int i;
VasEBoot_err_t err;
if (!VasEBoot_cs5536_find (&dev))
{
VasEBoot_puts_ (N_("No CS5536 found"));
return VAS_EBOOT_ERR_NONE;
}
VasEBoot_printf_ (N_("CS5536 at %d:%d.%d\n"), VasEBoot_pci_get_bus (dev),
VasEBoot_pci_get_device (dev), VasEBoot_pci_get_function (dev));
err = VasEBoot_cs5536_init_smbus (dev, 0x7fff, &smbbase);
if (err)
return err;
/* TRANSLATORS: System management bus is often used to access components like
RAM (info only, not data) or batteries. I/O space is where in memory
its ports are. */
VasEBoot_printf_ (N_("System management bus controller I/O space is at 0x%x\n"),
smbbase);
for (i = VAS_EBOOT_SMB_RAM_START_ADDR;
i < VAS_EBOOT_SMB_RAM_START_ADDR + VAS_EBOOT_SMB_RAM_NUM_MAX; i++)
{
struct VasEBoot_smbus_spd spd;
VasEBoot_memset (&spd, 0, sizeof (spd));
/* TRANSLATORS: it's shown in a report in a way
like number 1: ... number 2: ...
*/
VasEBoot_printf_ (N_("RAM slot number %d\n"), i);
err = VasEBoot_cs5536_read_spd (smbbase, i, &spd);
if (err)
{
VasEBoot_print_error ();
continue;
}
VasEBoot_printf_ (N_("Written SPD bytes: %d B.\n"), spd.written_size);
VasEBoot_printf_ (N_("Total flash size: %d B.\n"),
1 << spd.log_total_flash_size);
if (spd.memory_type == VAS_EBOOT_SMBUS_SPD_MEMORY_TYPE_DDR2)
{
char str[sizeof (spd.ddr2.part_number) + 1];
VasEBoot_puts_ (N_("Memory type: DDR2."));
VasEBoot_memcpy (str, spd.ddr2.part_number,
sizeof (spd.ddr2.part_number));
str[sizeof (spd.ddr2.part_number)] = 0;
VasEBoot_printf_ (N_("Part no: %s.\n"), str);
}
else
VasEBoot_puts_ (N_("Memory type: Unknown."));
}
return VAS_EBOOT_ERR_NONE;
}
static VasEBoot_command_t cmd;
VAS_EBOOT_MOD_INIT(lsspd)
{
cmd = VasEBoot_register_command ("lsspd", VasEBoot_cmd_lsspd, 0,
N_("Print Memory information."));
}
VAS_EBOOT_MOD_FINI(lsspd)
{
VasEBoot_unregister_command (cmd);
}