Deleted Added
full compact
cpu_machdep.c (58934) cpu_machdep.c (59249)
1/*-
2 * Copyright (c) 1992 Terrence R. Lambert.
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *

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

30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
1/*-
2 * Copyright (c) 1992 Terrence R. Lambert.
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *

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

30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
38 * $FreeBSD: head/sys/i386/i386/machdep.c 58934 2000-04-02 15:24:56Z phk $
38 * $FreeBSD: head/sys/i386/i386/machdep.c 59249 2000-04-15 05:54:02Z phk $
39 */
40
41#include "apm.h"
42#include "ether.h"
43#include "npx.h"
44#include "opt_atalk.h"
45#include "opt_compat.h"
46#include "opt_cpu.h"

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

2357#include <sys/disklabel.h>
2358
2359/*
2360 * Determine the size of the transfer, and make sure it is
2361 * within the boundaries of the partition. Adjust transfer
2362 * if needed, and signal errors or early completion.
2363 */
2364int
39 */
40
41#include "apm.h"
42#include "ether.h"
43#include "npx.h"
44#include "opt_atalk.h"
45#include "opt_compat.h"
46#include "opt_cpu.h"

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

2357#include <sys/disklabel.h>
2358
2359/*
2360 * Determine the size of the transfer, and make sure it is
2361 * within the boundaries of the partition. Adjust transfer
2362 * if needed, and signal errors or early completion.
2363 */
2364int
2365bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
2365bounds_check_with_label(struct bio *bp, struct disklabel *lp, int wlabel)
2366{
2366{
2367 struct partition *p = lp->d_partitions + dkpart(bp->b_dev);
2367 struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
2368 int labelsect = lp->d_partitions[0].p_offset;
2369 int maxsz = p->p_size,
2368 int labelsect = lp->d_partitions[0].p_offset;
2369 int maxsz = p->p_size,
2370 sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
2370 sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
2371
2372 /* overwriting disk label ? */
2373 /* XXX should also protect bootstrap in first 8K */
2371
2372 /* overwriting disk label ? */
2373 /* XXX should also protect bootstrap in first 8K */
2374 if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsect &&
2374 if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
2375#if LABELSECTOR != 0
2375#if LABELSECTOR != 0
2376 bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
2376 bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
2377#endif
2377#endif
2378 (bp->b_iocmd == BIO_WRITE) && wlabel == 0) {
2379 bp->b_error = EROFS;
2378 (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
2379 bp->bio_error = EROFS;
2380 goto bad;
2381 }
2382
2383#if defined(DOSBBSECTOR) && defined(notyet)
2384 /* overwriting master boot record? */
2380 goto bad;
2381 }
2382
2383#if defined(DOSBBSECTOR) && defined(notyet)
2384 /* overwriting master boot record? */
2385 if (bp->b_blkno + p->p_offset <= DOSBBSECTOR &&
2386 (bp->b_iocmd == BIO_WRITE) && wlabel == 0) {
2387 bp->b_error = EROFS;
2385 if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
2386 (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
2387 bp->bio_error = EROFS;
2388 goto bad;
2389 }
2390#endif
2391
2392 /* beyond partition? */
2388 goto bad;
2389 }
2390#endif
2391
2392 /* beyond partition? */
2393 if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
2393 if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
2394 /* if exactly at end of disk, return an EOF */
2394 /* if exactly at end of disk, return an EOF */
2395 if (bp->b_blkno == maxsz) {
2396 bp->b_resid = bp->b_bcount;
2395 if (bp->bio_blkno == maxsz) {
2396 bp->bio_resid = bp->bio_bcount;
2397 return(0);
2398 }
2399 /* or truncate if part of it fits */
2397 return(0);
2398 }
2399 /* or truncate if part of it fits */
2400 sz = maxsz - bp->b_blkno;
2400 sz = maxsz - bp->bio_blkno;
2401 if (sz <= 0) {
2401 if (sz <= 0) {
2402 bp->b_error = EINVAL;
2402 bp->bio_error = EINVAL;
2403 goto bad;
2404 }
2403 goto bad;
2404 }
2405 bp->b_bcount = sz << DEV_BSHIFT;
2405 bp->bio_bcount = sz << DEV_BSHIFT;
2406 }
2407
2406 }
2407
2408 bp->b_pblkno = bp->b_blkno + p->p_offset;
2408 bp->bio_pblkno = bp->bio_blkno + p->p_offset;
2409 return(1);
2410
2411bad:
2409 return(1);
2410
2411bad:
2412 bp->b_ioflags |= BIO_ERROR;
2412 bp->bio_flags |= BIO_ERROR;
2413 return(-1);
2414}
2415
2416#ifdef DDB
2417
2418/*
2419 * Provide inb() and outb() as functions. They are normally only
2420 * available as macros calling inlined functions, thus cannot be

--- 40 unchanged lines hidden ---
2413 return(-1);
2414}
2415
2416#ifdef DDB
2417
2418/*
2419 * Provide inb() and outb() as functions. They are normally only
2420 * available as macros calling inlined functions, thus cannot be

--- 40 unchanged lines hidden ---