23
23
#include <grub/misc.h>
25
25
volatile grub_uint8_t *grub_cmos_port = 0;
27
grub_cmos_find_port (void)
27
/* Helper for grub_cmos_find_port. */
29
grub_cmos_find_port_iter (struct grub_ieee1275_devalias *alias)
29
auto int hook (struct grub_ieee1275_devalias *alias);
30
int hook (struct grub_ieee1275_devalias *alias)
32
grub_ieee1275_phandle_t dev;
33
grub_uint32_t addr[2];
35
/* Enough to check if it's "m5819" */
37
if (grub_ieee1275_finddevice (alias->path, &dev))
39
if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
42
if (grub_strcmp (compat, "m5819") != 0)
44
if (grub_ieee1275_get_integer_property (dev, "address",
45
addr, sizeof (addr), &actual))
49
grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
31
grub_ieee1275_phandle_t dev;
32
grub_uint32_t addr[2];
34
/* Enough to check if it's "m5819" */
36
if (grub_ieee1275_finddevice (alias->path, &dev))
38
if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
41
if (grub_strcmp (compat, "m5819") != 0)
43
if (grub_ieee1275_get_integer_property (dev, "address",
44
addr, sizeof (addr), &actual))
48
grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
53
52
#if GRUB_CPU_SIZEOF_VOID_P == 8
56
grub_cmos_port = (volatile grub_uint8_t *)
57
((((grub_addr_t) addr[0]) << 32) | addr[1]);
55
grub_cmos_port = (volatile grub_uint8_t *)
56
((((grub_addr_t) addr[0]) << 32) | addr[1]);
61
if (actual == 8 && addr[0] == 0)
63
grub_cmos_port = (volatile grub_uint8_t *) addr[1];
60
if (actual == 8 && addr[0] == 0)
62
grub_cmos_port = (volatile grub_uint8_t *) addr[1];
70
grub_ieee1275_devices_iterate (hook);
70
grub_cmos_find_port (void)
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");