Deleted Added
full compact
bioscd.c (226746) bioscd.c (298230)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * Copyright (c) 2001 John H. Baldwin <jhb@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * Copyright (c) 2001 John H. Baldwin <jhb@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/boot/pc98/libpc98/bioscd.c 226746 2011-10-25 19:45:12Z jhb $");
29__FBSDID("$FreeBSD: head/sys/boot/pc98/libpc98/bioscd.c 298230 2016-04-18 23:09:22Z allanjude $");
30
31/*
32 * BIOS CD device handling for CD's that have been booted off of via no
33 * emulation booting as defined in the El Torito standard.
34 *
35 * Ideas and algorithms from:
36 *
37 * - FreeBSD libi386/biosdisk.c

--- 41 unchanged lines hidden (view full) ---

79
80/*
81 * List of BIOS devices, translation from disk unit number to
82 * BIOS unit number.
83 */
84static struct bcinfo {
85 int bc_unit; /* BIOS unit number */
86 struct specification_packet bc_sp;
30
31/*
32 * BIOS CD device handling for CD's that have been booted off of via no
33 * emulation booting as defined in the El Torito standard.
34 *
35 * Ideas and algorithms from:
36 *
37 * - FreeBSD libi386/biosdisk.c

--- 41 unchanged lines hidden (view full) ---

79
80/*
81 * List of BIOS devices, translation from disk unit number to
82 * BIOS unit number.
83 */
84static struct bcinfo {
85 int bc_unit; /* BIOS unit number */
86 struct specification_packet bc_sp;
87 int bc_open; /* reference counter */
88 void *bc_bcache; /* buffer cache data */
87} bcinfo [MAXBCDEV];
88static int nbcinfo = 0;
89
89} bcinfo [MAXBCDEV];
90static int nbcinfo = 0;
91
92#define BC(dev) (bcinfo[(dev)->d_unit])
93
90static int bc_read(int unit, daddr_t dblk, int blks, caddr_t dest);
91static int bc_init(void);
92static int bc_strategy(void *devdata, int flag, daddr_t dblk,
94static int bc_read(int unit, daddr_t dblk, int blks, caddr_t dest);
95static int bc_init(void);
96static int bc_strategy(void *devdata, int flag, daddr_t dblk,
93 size_t size, char *buf, size_t *rsize);
97 size_t offset, size_t size, char *buf, size_t *rsize);
98static int bc_realstrategy(void *devdata, int flag, daddr_t dblk,
99 size_t offset, size_t size, char *buf, size_t *rsize);
94static int bc_open(struct open_file *f, ...);
95static int bc_close(struct open_file *f);
96static void bc_print(int verbose);
97
98struct devsw bioscd = {
99 "cd",
100 DEVT_CD,
101 bc_init,

--- 53 unchanged lines hidden (view full) ---

155 /* SCSI CD-ROM only */
156 if ((biosdev & 0xf0) != 0xa0)
157 return (-1);
158 if ((((uint32_t *)PTOV(0xA1460))[biosdev & 0x0f] & 0x1f) != 5)
159 return (-1);
160
161 printf("BIOS CD is cd%d\n", nbcinfo);
162 nbcinfo++;
100static int bc_open(struct open_file *f, ...);
101static int bc_close(struct open_file *f);
102static void bc_print(int verbose);
103
104struct devsw bioscd = {
105 "cd",
106 DEVT_CD,
107 bc_init,

--- 53 unchanged lines hidden (view full) ---

161 /* SCSI CD-ROM only */
162 if ((biosdev & 0xf0) != 0xa0)
163 return (-1);
164 if ((((uint32_t *)PTOV(0xA1460))[biosdev & 0x0f] & 0x1f) != 5)
165 return (-1);
166
167 printf("BIOS CD is cd%d\n", nbcinfo);
168 nbcinfo++;
169 bcache_add_dev(nbcinfo); /* register cd device in bcache */
163 return(0);
164}
165
166/*
167 * Print information about disks
168 */
169static void
170bc_print(int verbose)

--- 20 unchanged lines hidden (view full) ---

191 va_start(ap, f);
192 dev = va_arg(ap, struct i386_devdesc *);
193 va_end(ap);
194 if (dev->d_unit >= nbcinfo) {
195 DEBUG("attempt to open nonexistent disk");
196 return(ENXIO);
197 }
198
170 return(0);
171}
172
173/*
174 * Print information about disks
175 */
176static void
177bc_print(int verbose)

--- 20 unchanged lines hidden (view full) ---

198 va_start(ap, f);
199 dev = va_arg(ap, struct i386_devdesc *);
200 va_end(ap);
201 if (dev->d_unit >= nbcinfo) {
202 DEBUG("attempt to open nonexistent disk");
203 return(ENXIO);
204 }
205
206 BC(dev).bc_open++;
207 if (BC(dev).bc_bcache == NULL)
208 BC(dev).bc_bcache = bcache_allocate();
199 return(0);
200}
201
202static int
203bc_close(struct open_file *f)
204{
209 return(0);
210}
211
212static int
213bc_close(struct open_file *f)
214{
215 struct i386_devdesc *dev;
205
216
217 dev = (struct i386_devdesc *)f->f_devdata;
218 BC(dev).bc_open--;
219 if (BC(dev).bc_open == 0) {
220 bcache_free(BC(dev).bc_bcache);
221 BC(dev).bc_bcache = NULL;
222 }
206 return(0);
207}
208
223 return(0);
224}
225
226static int
227bc_strategy(void *devdata, int rw, daddr_t dblk, size_t offset, size_t size,
228 char *buf, size_t *rsize)
229{
230 struct bcache_devdata bcd;
231 struct i386_devdesc *dev;
232
233 dev = (struct i386_devdesc *)devdata;
234 bcd.dv_strategy = bc_realstrategy;
235 bcd.dv_devdata = devdata;
236 bcd.dv_cache = BC(dev).bc_bcache;
237
238 return (bcache_strategy(&bcd, rw, dblk, offset, size, buf, rsize));
239}
240
209static int
241static int
210bc_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf,
211 size_t *rsize)
242bc_realstrategy(void *devdata, int rw, daddr_t dblk, size_t offset, size_t size,
243 char *buf, size_t *rsize)
212{
213 struct i386_devdesc *dev;
214 int unit;
215 int blks;
216#ifdef BD_SUPPORT_FRAGS
217 char fragbuf[BIOSCD_SECSIZE];
218 size_t fragsize;
219

--- 160 unchanged lines hidden ---
244{
245 struct i386_devdesc *dev;
246 int unit;
247 int blks;
248#ifdef BD_SUPPORT_FRAGS
249 char fragbuf[BIOSCD_SECSIZE];
250 size_t fragsize;
251

--- 160 unchanged lines hidden ---