/* ofdisk.c - Open Firmware disk access. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* 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.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
static char *last_devpath;
struct ofdisk_hash_ent
{
char *devpath;
/* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */
const char *shortest;
};
static int
{
int hash = 0;
while (*devpath)
}
static struct ofdisk_hash_ent *
{
while (p)
{
break;
p = p->next;
}
return p;
}
static struct ofdisk_hash_ent *
{
struct ofdisk_hash_ent *p;
p = grub_malloc(sizeof (*p));
if (!p)
return NULL;
p->shortest = 0;
*head = p;
return p;
}
static struct ofdisk_hash_ent *
{
p = ofdisk_hash_add_real (devpath);
if (!curcan)
{
return p;
}
if (!pcan)
else
if (!pcan)
else
{
}
return p;
}
static void
scan (void)
{
{
return 0;
if (!op)
{
{
return 0;
}
}
return 0;
}
}
static int
{
unsigned i;
if (pull != GRUB_DISK_PULL_NONE)
return 0;
scan ();
for (i = 0; i < ARRAY_SIZE (ofdisk_hash); i++)
{
{
continue;
{
{
continue;
}
sizeof tmp, 0))
{
continue;
}
{
continue;
}
}
continue;
{
char *ptr;
return 1;
}
}
}
return 0;
}
static char *
{
char *p, c;
if (!devpath)
return NULL;
/* Un-escape commas. */
p = devpath;
while ((c = *name++) != '\0')
{
{
*p++ = ',';
name++;
}
else
*p++ = c;
}
*p++ = '\0';
return devpath;
}
static grub_err_t
{
char *devpath;
/* XXX: This should be large enough for any possible case. */
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"not IEEE1275 device");
if (! devpath)
return grub_errno;
{
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"can't read device properties");
}
&actual))
{
}
{
}
/* XXX: There is no property to read the number of blocks. There
should be a property `#blocks', but it is not there. Perhaps it
is possible to use seek for this. */
{
if (!op)
else
if (!op)
return grub_errno;
}
return 0;
}
static void
{
{
if (last_ihandle)
last_ihandle = 0;
last_devpath = NULL;
}
}
static grub_err_t
{
unsigned long long pos;
{
if (last_ihandle)
last_ihandle = 0;
last_devpath = NULL;
{
char *p;
*p++ = ':';
*p++ = '0';
*p = 0;
}
else
if (! last_ihandle)
}
if (status < 0)
return grub_error (GRUB_ERR_READ_ERROR,
"seek error, can't seek block %llu",
(long long) sector);
(long long) sector);
return 0;
}
static grub_err_t
{
return GRUB_ERR_NOT_IMPLEMENTED_YET;
}
{
.name = "ofdisk",
.open = grub_ofdisk_open,
.read = grub_ofdisk_read,
.next = 0
};
void
grub_ofdisk_init (void)
{
}
void
grub_ofdisk_fini (void)
{
if (last_ihandle)
last_ihandle = 0;
last_devpath = NULL;
}