Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 May 2000 13:14:22 -0700
From:      Alfred Perlstein <bright@wintelcom.net>
To:        "G.B.Naidu" <gbnaidu@sasi.com>
Cc:        freebsd-net@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG
Subject:   Re: How do I time in kernel...
Message-ID:  <20000529131422.W28594@fw.wintelcom.net>
In-Reply-To: <Pine.LNX.4.21.0005291619070.775-100000@pcd75.sasi.com>; from gbnaidu@sasi.com on Mon, May 29, 2000 at 04:28:56PM %2B0530
References:  <20000529020845.U28594@fw.wintelcom.net> <Pine.LNX.4.21.0005291619070.775-100000@pcd75.sasi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* G.B.Naidu <gbnaidu@sasi.com> [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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000529131422.W28594>