umass_loader.c revision 199767f8919635c4928607450d9e0abb932109ce
/* $FreeBSD$ */
/*-
* Copyright (c) 2014 Hans Petter Selasky <hselasky@FreeBSD.org>
* All rights reserved.
*
* This software was developed by SRI International and the University of
* ("CTSRD"), as part of the DARPA CRASH research programme.
*
* 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.
*/
#include <bootstrap.h>
#include <stdarg.h>
#include <stand.h>
#include <disk.h>
#define HAVE_STANDARD_DEFS
#include USB_GLOBAL_INCLUDE_FILE
#include "umass_common.h"
static int umass_disk_init(void);
static int umass_disk_open(struct open_file *,...);
static int umass_disk_close(struct open_file *);
static void umass_disk_cleanup(void);
static void umass_disk_print(int);
struct devsw umass_disk = {
.dv_name = "umass",
};
static int
umass_disk_init(void)
{
usb_init();
/* wait 8 seconds for a USB mass storage device to appear */
usb_idle();
time++;
callout_process(1);
return (0);
}
return (0);
}
static int
{
return (ENXIO);
*rsizep = 0;
return (EINVAL);
return (EINVAL);
} else {
return (EROFS);
}
return (0);
}
static int
{
return (EINVAL);
}
static int
umass_disk_open(struct open_file *f,...)
{
struct disk_devdesc *dev;
return (ENXIO);
return (EIO);
return (umass_disk_open_sub(dev));
}
static int
{
switch (cmd) {
case IOCTL_GET_BLOCK_SIZE:
case IOCTL_GET_BLOCKS:
return (EINVAL);
if (cmd == IOCTL_GET_BLOCKS)
else
return (0);
default:
return (ENXIO);
}
}
static int
umass_disk_close(struct open_file *f)
{
struct disk_devdesc *dev;
return (disk_close(dev));
}
static void
umass_disk_print(int verbose)
{
struct disk_devdesc dev;
pager_output(" umass0 UMASS device\n");
if (umass_disk_open_sub(&dev) == 0) {
disk_close(&dev);
}
}
static void
umass_disk_cleanup(void)
{
usb_uninit();
}
/* USB specific functions */
extern void callout_process(int);
extern void usb_idle(void);
extern void usb_init(void);
extern void usb_uninit(void);
void
{
}
int
{
if (timeout == 0)
timeout = 1;
return (0);
}