From owner-freebsd-hackers Mon May 29 12:39:39 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 3061B37BCE8; Mon, 29 May 2000 12:39:33 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e4TKEMh22398; Mon, 29 May 2000 13:14:22 -0700 (PDT) Date: Mon, 29 May 2000 13:14:22 -0700 From: Alfred Perlstein To: "G.B.Naidu" Cc: freebsd-net@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: How do I time in kernel... Message-ID: <20000529131422.W28594@fw.wintelcom.net> References: <20000529020845.U28594@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: ; from gbnaidu@sasi.com on Mon, May 29, 2000 at 04:28:56PM +0530 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * G.B.Naidu [000529 04:58] wrote: > > On Mon, 29 May 2000, Alfred Perlstein wrote: > > > It depends on how you call it, look at the sendfile implementation and > > see how it has to call writev(), userland_writev() != kernel_writev(), > > you need to munge with the arguements. > > > > The kernel_writev() calls requre a proc structure. Now my question is how > can I get a proc structure? All system calls pass the proc structure pointer in as the first arguement. > My requirement is as follows: I want to open a driver as > open("/dev/nic0"...), then I want to write() and read() from the driver. I > have two choices. Either to go for the kernel or user level. Kernel level > is to restrict the normal user from fiddling with the driver data. User > lever is for simplicity. Well since you can control exactly what data is allowed into the kernel there's no reason why you can't keep it simple and use the userland interface and force the constraints within the kernel code. > > Now which choice should I make? I'm not sure I fully understand what you're trying to accomplish so it's hard to say. > If I want to go for kernel level, my question is how do I do open, write, > read and close. For the kernel versions of these system calls, I need proc > structure. How do I get it? You can use curproc to 'borrow' a process context, however you can't do this from an interrupt handler so you'll have to be careful. > Next I read in the book : design of 4.4 BSD O/S that the user interface > for the system calls is thorugh library routines write(), open() etc. I > want to know where is the source code for these user land write(), > open() etc library calls. Where this implementation of interface between > library calls and system calls? How it is done? see the files in src/sys/i386/i386 for how the userland arguments are copying into a trap frame for the syscalls. trap.c should help. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message