From owner-freebsd-hackers@FreeBSD.ORG Wed May 30 16:39:54 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2F54C16A41F for ; Wed, 30 May 2007 16:39:54 +0000 (UTC) (envelope-from mwm-keyword-freebsdhackers2.e313df@mired.org) Received: from mired.org (vpn.mired.org [66.92.153.74]) by mx1.freebsd.org (Postfix) with SMTP id C5EB613C4BF for ; Wed, 30 May 2007 16:39:53 +0000 (UTC) (envelope-from mwm-keyword-freebsdhackers2.e313df@mired.org) Received: (qmail 72312 invoked by uid 1001); 30 May 2007 16:39:10 -0000 Received: by bhuda.mired.org (tmda-sendmail, from uid 1001); Wed, 30 May 2007 12:39:10 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18013.43182.474113.794494@bhuda.mired.org> Date: Wed, 30 May 2007 12:39:10 -0400 To: rmgls@wanadoo.fr In-Reply-To: <20070530085506.163217000088@mwinf2816.orange.fr> References: <20070530085506.163217000088@mwinf2816.orange.fr> X-Mailer: VM 7.19 under Emacs 21.3.1 X-Primary-Address: mwm@mired.org X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`; h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ X-Delivery-Agent: TMDA/1.1.11 (Ladyburn) From: Mike Meyer Cc: freebsd-hackers@freebsd.org Subject: Re: direct I/O access X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 16:39:54 -0000 In <20070530085506.163217000088@mwinf2816.orange.fr>, rmgls@wanadoo.fr typed: > >And I have to ask. The hardware has changed a lot since the days of > >DoS, and things that worked then may cause strange results on modern > >hardware. Do you know modern hardware, or are you still using dos-era > >hardware? > > > yes i am aware of this, and have a few understanding of protected mode too, > also about music softs. Actually, protected mode is just the beginnings of it. I've never done much x86 assembly, but going from the '020 to the '030 (or maybe it was the '010 to the '020). I had to start invalidating the hardware caches after certain operations. After that, I switched to RISC hardware, which were designed assuming that the real people writing assembler would be few and far between, and did crazy things like rearrange the instruction sequence behind your back and add extra instructions. Modern systems do this kind of stuff as well. > ---cut--- > >> > >> .data > >> .align 4 > >> params: .word 0x330,2,1 # midi port => enabling IO ??? > >> > >> .text > >> .align 4 > >> .global _start > >> _start: > >> nop > >> pushl params > >> pushl $0x4 > > > >I believe this should be $0x4, as you want to *set* the values, not > >get them. > > > is it necessary to restore the permissions on exit? > > >You also need to open the file "/dev/io". I believe that leaving this > >file open for anything more than a handful of instructions would be a > >bad thing, but I'm not going to verify it. > > > > i tried this, but without set_ioperm, it was not clear on the doc > that one have to use these two funcions: > in io man: i find SEE ALSO: i386_get(set)_ioperm... > > is my understanding correct? Sounds like it. You have to do i386_set_ioperm to say what port range you want access to, and open /dev/io to actually allow it to work. It doesn't look like it's order dependent, so doing the i386_set_ioperm and then opening/closing /dev/io should work. I no longer have root on a machine running i386 FreeBSD, so I can't test it very easily. This really is a kludge, though. You haven't said what you're trying to do. If you're trying to keep an old one-of device working, this is probably the best way. But if it's a real device that other people might be using, then writing a real device driver, or seeing if you can make the device work with something like the iic drivers might be better. http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information.