/*
* Copyright (c) 1996 Leo Weppelman.
* 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
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
*/
/*
* Misc. defines:
*/
#define RAMD_CHUNK (9 * 512) /* Chunk-size for auto-load */
#define RAMD_NDEV 3 /* Number of devices configured */
struct ramd_info {
u_long ramd_size; /* Size of disk in bytes */
u_long ramd_flag; /* see defs below */
dev_t ramd_dev; /* device to load from */
};
/*
* ramd_flag:
*/
#define RAMD_LOAD 0x01 /* Auto load when first opened */
#define RAMD_LCOMP 0x02 /* Input is compressed */
struct ramd_info rd_info[RAMD_NDEV] = {
{
1105920, /* 1Mb in 2160 sectors */
RAMD_LOAD, /* auto-load this device */
MAKEDISKDEV(2, 0, 2), /* XXX: This is crap! (720Kb flop) */
},
{
1474560, /* 1.44Mb in 2880 sectors */
RAMD_LOAD, /* auto-load this device */
MAKEDISKDEV(2, 0, 2), /* XXX: This is crap! (720Kb flop) */
},
{
1474560, /* 1.44Mb in 2880 sectors */
RAMD_LOAD, /* auto-load this device */
MAKEDISKDEV(2, 0, 3), /* XXX: This is crap! (1.44Mb flop) */
}
};
struct read_info {
struct buf *bp; /* buffer for strategy function */
long nbytes; /* total number of bytes to read */
long offset; /* offset in input medium */
char *bufp; /* current output buffer */
char *ebufp; /* absolute maximum for bufp */
int chunk; /* chunk size on input medium */
int media_sz; /* size of input medium */
void (*strat)(struct buf *); /* strategy function for read */
};
static int loaddisk(struct md_conf *, dev_t ld_dev, struct lwp *);
static int ramd_norm_read(struct read_info *);
#ifdef support_compression
static int cpy_uncompressed(void *, int, struct read_info *);
static int md_compressed(void *, int, struct read_info *);
#endif
/*
* This is called during autoconfig.
*/
void
md_attach_hook(int unit, struct md_conf *md)
{
if ((rsp->offset == rsp->media_sz) && (bytes_left != 0)) {
printf("\nInsert next media and hit any key...");
cngetc();
printf("\n");
rsp->offset = 0;
}
}
printf("\n");
return error;
}
#ifdef support_compression
/*
* Functions supporting uncompression:
*/
/*
* Copy from the uncompression buffer to the ramdisk
*/
static int
cpy_uncompressed(void * buf, int nbyte, struct read_info *rsp)
{
/*
* Read a maximum of 'nbyte' bytes into 'buf'.
*/
static int
md_compressed(void * buf, int nbyte, struct read_info *rsp)
{
static int dotc = 0;
struct buf *bp;
int nread = 0;
int done, error;
if ((rsp->offset == rsp->media_sz) && (nbyte != 0)) {
printf("\nInsert next media and hit any key...");
if (cngetc() != '\n')
printf("\n");
rsp->offset = 0;
}
}
return nread;
}
#endif /* support_compression */