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

« back to all changes in this revision

Viewing changes to grub-core/lib/ieee1275/cmos.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-01-16 15:18:04 UTC
  • mfrom: (17.6.38 experimental)
  • Revision ID: package-import@ubuntu.com-20140116151804-3foouk7fpqcq3sxx
Tags: 2.02~beta2-2
* Convert patch handling to git-dpm.
* Add bi-endian support to ELF parser (Tomohiro B Berry).
* Adjust restore_mkdevicemap.patch to mark get_kfreebsd_version as static,
  to appease "gcc -Werror=missing-prototypes".
* Cherry-pick from upstream:
  - Change grub-macbless' manual page section to 8.
* Install grub-glue-efi, grub-macbless, grub-render-label, and
  grub-syslinux2cfg.
* grub-shell: Pass -no-pad to xorriso when building floppy images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <grub/misc.h>
24
24
 
25
25
volatile grub_uint8_t *grub_cmos_port = 0;
26
 
grub_err_t
27
 
grub_cmos_find_port (void)
 
26
 
 
27
/* Helper for grub_cmos_find_port.  */
 
28
static int
 
29
grub_cmos_find_port_iter (struct grub_ieee1275_devalias *alias)
28
30
{
29
 
  auto int hook (struct grub_ieee1275_devalias *alias);
30
 
  int hook (struct grub_ieee1275_devalias *alias)
31
 
  {
32
 
    grub_ieee1275_phandle_t dev;
33
 
    grub_uint32_t addr[2];
34
 
    grub_ssize_t actual;
35
 
    /* Enough to check if it's "m5819" */
36
 
    char compat[100];
37
 
    if (grub_ieee1275_finddevice (alias->path, &dev))
38
 
      return 0;
39
 
    if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
40
 
                                    0))
41
 
      return 0;
42
 
    if (grub_strcmp (compat, "m5819") != 0)
43
 
      return 0;
44
 
    if (grub_ieee1275_get_integer_property (dev, "address",
45
 
                                            addr, sizeof (addr), &actual))
46
 
      return 0;
47
 
    if (actual == 4)
48
 
      {
49
 
        grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
50
 
        return 1;
51
 
      }
 
31
  grub_ieee1275_phandle_t dev;
 
32
  grub_uint32_t addr[2];
 
33
  grub_ssize_t actual;
 
34
  /* Enough to check if it's "m5819" */
 
35
  char compat[100];
 
36
  if (grub_ieee1275_finddevice (alias->path, &dev))
 
37
    return 0;
 
38
  if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
 
39
                                  0))
 
40
    return 0;
 
41
  if (grub_strcmp (compat, "m5819") != 0)
 
42
    return 0;
 
43
  if (grub_ieee1275_get_integer_property (dev, "address",
 
44
                                          addr, sizeof (addr), &actual))
 
45
    return 0;
 
46
  if (actual == 4)
 
47
    {
 
48
      grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
 
49
      return 1;
 
50
    }
52
51
 
53
52
#if GRUB_CPU_SIZEOF_VOID_P == 8
54
 
    if (actual == 8)
55
 
      {
56
 
        grub_cmos_port = (volatile grub_uint8_t *) 
57
 
          ((((grub_addr_t) addr[0]) << 32) | addr[1]);
58
 
        return 1;
59
 
      }
 
53
  if (actual == 8)
 
54
    {
 
55
      grub_cmos_port = (volatile grub_uint8_t *) 
 
56
        ((((grub_addr_t) addr[0]) << 32) | addr[1]);
 
57
      return 1;
 
58
    }
60
59
#else
61
 
    if (actual == 8 && addr[0] == 0)
62
 
      {
63
 
        grub_cmos_port = (volatile grub_uint8_t *) addr[1];
64
 
        return 1;
65
 
      }
 
60
  if (actual == 8 && addr[0] == 0)
 
61
    {
 
62
      grub_cmos_port = (volatile grub_uint8_t *) addr[1];
 
63
      return 1;
 
64
    }
66
65
#endif
67
 
    return 0;
68
 
  }
69
 
  
70
 
  grub_ieee1275_devices_iterate (hook);
 
66
  return 0;
 
67
}
 
68
 
 
69
grub_err_t
 
70
grub_cmos_find_port (void)
 
71
{
 
72
  grub_ieee1275_devices_iterate (grub_cmos_find_port_iter);
71
73
  if (!grub_cmos_port)
72
74
    return grub_error (GRUB_ERR_IO, "no cmos found");
73
75