From owner-freebsd-hackers Thu Dec 19 09:13:11 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id JAA00600 for hackers-outgoing; Thu, 19 Dec 1996 09:13:11 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id JAA00583; Thu, 19 Dec 1996 09:13:07 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id KAA11716; Thu, 19 Dec 1996 10:10:34 -0700 From: Terry Lambert Message-Id: <199612191710.KAA11716@phaeton.artisoft.com> Subject: Re: mmap problems? To: hasty@rah.star-gate.com (Amancio Hasty) Date: Thu, 19 Dec 1996 10:10:33 -0700 (MST) Cc: terry@lambert.org, hackers@freebsd.org, multimedia@freebsd.org In-Reply-To: <199612190619.WAA08457@rah.star-gate.com> from "Amancio Hasty" at Dec 18, 96 10:19:32 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > You'll have to look carefully at the driver to see which is happening > > (if either is the correct reason). [ ... ] Well, I did say "if". Personally, I'd: meteor_mmap(dev_t dev, int offset, int nprot) { int unit; meteor_reg_t *mtr; unit = UNIT(minor(dev)); printf( "meteor_mmap: unit=%d of %d, offset=%d, nprot=%08x\n", unit, NMETEOR, offset, nprot); if (unit >= NMETEOR) /* at this point could this happen? */ { printf( "meteor_mmap: failed: unit exceeded possible units\n"); return(-1); } mtr = &(meteor[unit]); if(nprot & PROT_EXEC) { printf("meteor_mmap: can't map a device PROT_EXEC!\n"); return -1; } printf("meteor_mmap: device pages(%08x)\n", mtr->alloc_pages * page_size); if(offset >= mtr->alloc_pages * PAGE_SIZE) { printf("meteor_mmap: offset (%08x) exceeds device pages\n", offset); return -1; } return i386_btop(vtophys(mtr->bigbuf) + offset); } This leaves a possible failure of (vtophys() + offset) to be valid; you can check that, but it's unlikely (the pages are wired). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.