From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 16 03:01:09 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 59B9316A4BF for ; Thu, 16 Oct 2003 03:01:09 -0700 (PDT) Received: from arginine.spc.org (arginine.spc.org [195.206.69.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5896943F3F for ; Thu, 16 Oct 2003 03:01:08 -0700 (PDT) (envelope-from bms@spc.org) Received: from localhost (localhost [127.0.0.1]) by arginine.spc.org (Postfix) with ESMTP id 6C44265473; Thu, 16 Oct 2003 11:01:07 +0100 (BST) Received: from arginine.spc.org ([127.0.0.1]) by localhost (arginine.spc.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 50140-01-10; Thu, 16 Oct 2003 11:01:06 +0100 (BST) Received: from saboteur.dek.spc.org (unknown [81.3.72.68]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by arginine.spc.org (Postfix) with ESMTP id 54AD76530E; Thu, 16 Oct 2003 11:01:06 +0100 (BST) Received: by saboteur.dek.spc.org (Postfix, from userid 1001) id 283C940; Thu, 16 Oct 2003 11:01:01 +0100 (BST) Date: Thu, 16 Oct 2003 11:01:01 +0100 From: Bruce M Simpson To: lauri.jarvenpaa@students.turkuamk.fi Message-ID: <20031016100101.GG3470@saboteur.dek.spc.org> Mail-Followup-To: lauri.jarvenpaa@students.turkuamk.fi, Mathew Kanner , freebsd-hackers@freebsd.org References: <20031016000052.648ca035.lauri.jarvenpaa@students.turkuamk.fi> <20031015211329.GE1810@cnd.mcgill.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031015211329.GE1810@cnd.mcgill.ca> cc: freebsd-hackers@freebsd.org Subject: Re: to write a device driver or not to write (i/o, opl3, stupidity) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Oct 2003 10:01:09 -0000 > > I mean, what services do drivers offer? What services they _need_ to offer? Do they just create appropriate device nodes and let the applications to worry about using them or do they do some data manipulation or do they offer routines and interfaces for applications or what? What should this particular driver do as I just want to read/write data. > > I think for your application running in userland is fine, if kernel programming is likely to be a steep learning curve. You can use nanosleep() to get the timing you need. On Wed, Oct 15, 2003 at 05:13:29PM -0400, Mathew Kanner wrote: > I'm not positive about this but I think that you can do it > from usermode by opening /dev/io (as root) and the use inb, outb > macros defined in cpufunc.h. You can also use i386_get_ioperm() and i386_set_ioperm(). These change the I/O port permission bitmap in the process's Task State Segment (TSS) accordingly, so that you can issue IN/OUT instructions without segfaulting in a similar way to opening /dev/io. The only trouble with /dev/io is that it's an all-or-nothing approach (processes literally can write anywhere in I/O space); better to ask for what you need than ask for everything, IMHO. BMS