~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to grub-core/commands/mips/loongson/lsspd.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-09-13 18:02:04 UTC
  • mfrom: (1.17.15 upstream)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 145.
  • Revision ID: package-import@ubuntu.com-20120913180204-mojnmocbimlom4im
Tags: upstream-2.00
ImportĀ upstreamĀ versionĀ 2.00

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  GRUB  --  GRand Unified Bootloader
 
3
 *  Copyright (C) 2010  Free Software Foundation, Inc.
 
4
 *
 
5
 *  GRUB is free software: you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation, either version 3 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  GRUB is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include <grub/types.h>
 
20
#include <grub/misc.h>
 
21
#include <grub/mm.h>
 
22
#include <grub/err.h>
 
23
#include <grub/dl.h>
 
24
#include <grub/command.h>
 
25
#include <grub/cs5536.h>
 
26
#include <grub/i18n.h>
 
27
 
 
28
GRUB_MOD_LICENSE ("GPLv3+");
 
29
 
 
30
static grub_err_t
 
31
grub_cmd_lsspd (grub_command_t cmd __attribute__ ((unused)),
 
32
                int argc __attribute__ ((unused)),
 
33
                char **args __attribute__ ((unused)))
 
34
{
 
35
  grub_pci_device_t dev;
 
36
  grub_port_t smbbase;
 
37
  int i;
 
38
  grub_err_t err;
 
39
 
 
40
  if (!grub_cs5536_find (&dev))
 
41
    {
 
42
      grub_puts_ (N_("No CS5536 found"));
 
43
      return GRUB_ERR_NONE;
 
44
    }
 
45
  grub_printf_ (N_("CS5536 at %d:%d.%d\n"), grub_pci_get_bus (dev),
 
46
                grub_pci_get_device (dev), grub_pci_get_function (dev));
 
47
  
 
48
  err = grub_cs5536_init_smbus (dev, 0x7fff, &smbbase);
 
49
  if (err)
 
50
    return err;
 
51
 
 
52
  /* TRANSLATORS: System management bus is often used to access components like
 
53
     RAM (info only, not data) or batteries. I/O space is where in memory
 
54
     its ports are.  */
 
55
  grub_printf_ (N_("System management bus controller I/O space is at 0x%x\n"),
 
56
                smbbase);
 
57
 
 
58
  for (i = GRUB_SMB_RAM_START_ADDR;
 
59
       i < GRUB_SMB_RAM_START_ADDR + GRUB_SMB_RAM_NUM_MAX; i++)
 
60
    {
 
61
      struct grub_smbus_spd spd;
 
62
      grub_memset (&spd, 0, sizeof (spd));
 
63
      /* TRANSLATORS: it's shown in a report in a way
 
64
         like number 1: ... number 2: ...
 
65
       */
 
66
      grub_printf_ (N_("RAM slot number %d\n"), i);
 
67
      err = grub_cs5536_read_spd (smbbase, i, &spd);
 
68
      if (err)
 
69
        {
 
70
          grub_print_error ();
 
71
          continue;
 
72
        }
 
73
      grub_printf_ (N_("Written SPD bytes: %d B.\n"), spd.written_size);
 
74
      grub_printf_ (N_("Total flash size: %d B.\n"),
 
75
                    1 << spd.log_total_flash_size);
 
76
      if (spd.memory_type == GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2)
 
77
        {
 
78
          char str[sizeof (spd.ddr2.part_number) + 1];
 
79
          grub_puts_ (N_("Memory type: DDR2."));
 
80
          grub_memcpy (str, spd.ddr2.part_number,
 
81
                       sizeof (spd.ddr2.part_number));
 
82
          str[sizeof (spd.ddr2.part_number)] = 0;
 
83
          grub_printf_ (N_("Part no: %s.\n"), str);
 
84
        }
 
85
      else
 
86
        grub_puts_ (N_("Memory type: Unknown."));
 
87
    }
 
88
 
 
89
  return GRUB_ERR_NONE;
 
90
}
 
91
 
 
92
static grub_command_t cmd;
 
93
 
 
94
GRUB_MOD_INIT(lsspd)
 
95
{
 
96
  cmd = grub_register_command ("lsspd", grub_cmd_lsspd, 0,
 
97
                               N_("Print Memory information."));
 
98
}
 
99
 
 
100
GRUB_MOD_FINI(lsspd)
 
101
{
 
102
  grub_unregister_command (cmd);
 
103
}