From owner-freebsd-hackers Tue May 9 2:55:44 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from Mail.Openet-Telecom.COM (opentisdn.isdn.dublin.esat.net [193.120.50.79]) by hub.freebsd.org (Postfix) with ESMTP id 0FBB937B8F8 for ; Tue, 9 May 2000 02:55:40 -0700 (PDT) (envelope-from peter.edwards@openet-telecom.com) Received: from openet-telecom.com (rocklobster.openet-telecom.lan [10.0.0.40]) by Mail.Openet-Telecom.COM (8.9.3/8.9.3) with ESMTP id LAA45485; Tue, 9 May 2000 11:03:27 +0100 (IST) (envelope-from peter.edwards@openet-telecom.com) Message-ID: <3917E087.B2477FA0@openet-telecom.com> Date: Tue, 09 May 2000 10:55:19 +0100 From: Peter Edwards Organization: Openet Telecom X-Mailer: Mozilla 4.72 [en] (X11; I; FreeBSD 4.0-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: hackers@freebsd.org Cc: Coleman Kane Subject: Re: mmap cdev function in device drivers References: <20000508020139.A10146@cokane.yi.org> <20000508133654.A2018@cokane.yi.org> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, Just trying to take some of the aforementioned "magic" out of i386_btop / vtop :-) > return( atop(vtophys(bktr->bigbuf) + offset) ); atop (I assume) stands for "address to page" (given a pointer, give the number of the page it is in) vtophys is "virtual to physical". (given a pointer in a virtual address space, find out the physical address of the backing memory.) My understanding is that mmap(2) will allocate a portion of the calling process's address space, and for each page it needs to map, will call the device's mmap function, giving it the calculated offset (and the protection attributes). The device's mmap returns the index of the physical page of the memory to be inserted under the virtual addresses the process sees. simplified_mmap_syscall_for_device(dev_t device, size_t len, off_t offset) { caddr_t ptr = alloc_address_space(len); assert(ptr % PAGESIZE == 0); while (len) { pageno = device->mmap(offset); /* Call device's mmap */ map_address_to_page(ptr, pageno); len -= PAGESIZE; offset += PAGESIZE; ptr += PAGESIZE; } } So, the call above is returning the page number (of the physical address (of bktr->bigbuf)). Of course, My ignorance will probably be corrected in due course! -- Peter. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message