efipart.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 2010 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
#include <stddef.h>
#include <stdarg.h>
#include <bootstrap.h>
#include <efi.h>
#include <efilib.h>
#include <efiprot.h>
static int efipart_init(void);
size_t *);
size_t *);
static int efipart_open(struct open_file *, ...);
static int efipart_close(struct open_file *);
static int efipart_print(int);
struct devsw efipart_dev = {
.dv_name = "part",
.dv_init = efipart_init,
.dv_open = efipart_open,
.dv_cleanup = NULL
};
/*
* info structure to support bcache
*/
struct pdinfo
{
int pd_unit; /* unit number */
int pd_open; /* reference counter */
void *pd_bcache; /* buffer cache data */
};
static int npdinfo = 0;
static int
efipart_init(void)
{
int err;
sz = 0;
if (status == EFI_BUFFER_TOO_SMALL) {
hin);
}
return (efi_status_to_errno(status));
/* Filter handles to only include illumos partitions. */
nout = 0;
return (ENOMEM);
for (n = 0; n < nin; n++) {
(void **)&devpath);
continue;
}
}
(void**)&blkio);
continue;
continue;
/*
* If we come across a logical partition of subtype CDROM
* it doesn't refer to the CD filesystem itself, but rather
* to any usable El Torito boot image on it. In this case
* we try to find the parent device and add that instead as
* that will be the CD filesystem.
*/
node = devpathcpy;
&handle);
continue;
} else
nout++;
npdinfo++;
}
return (err);
}
static int
efipart_print(int verbose)
{
char line[80];
EFI_HANDLE h;
int ret = 0;
}
if (ret != 0)
break;
}
return (ret);
}
static int
efipart_open(struct open_file *f, ...)
{
EFI_HANDLE h;
if (h == NULL)
return (EINVAL);
return (efi_status_to_errno(status));
return (EAGAIN);
return (0);
}
static int
efipart_close(struct open_file *f)
{
return (EINVAL);
}
return (0);
}
/*
* efipart_readwrite()
* Internal equivalent of efipart_strategy(), which operates on the
* media-native block size. This function expects all I/O requests
* to be within the media size and returns an error if such is not
* the case.
*/
static int
char *buf)
{
return (ENXIO);
return (EIO);
return (EIO);
switch (rw) {
case F_READ:
break;
case F_WRITE:
return (EROFS);
break;
default:
return (ENOSYS);
}
return (efi_status_to_errno(status));
}
static int
{
struct bcache_devdata bcd;
}
static int
{
char *blkbuf;
int error;
return (EINVAL);
return (ENXIO);
return (EIO);
/* make sure we don't read past disk end */
}
/*
* The block size of the media is not 512B per sector.
*/
return (ENOMEM);
error = 0;
while (size > 0) {
if (error)
break;
blk++;
blkoff = 0;
}
return (error);
}