direct I/O access

Eygene Ryabinkin rea-fbsd at codelabs.ru
Wed May 30 05:05:33 UTC 2007


Raoul, good day.

Tue, May 29, 2007 at 08:10:26PM +0200, rmgls at wanadoo.fr wrote:
> i am trying to port my old assembler soft for Dos to FreeBSD.
> i need to write and read directly to the midi and scsi device.
> when i try something like this i receive a sigbus error

Seems like that the following fragment

>params: .word 0x330,2,1 # midi port => enabling IO ???
>[...]
> 	pushl	params
> 	pushl	$0x3
> 	movl	$0Xa5,%eax
> 	int	$0x80
> 	addl	$0x08,%esp

translates to the call i386_get_ioperm(0x330, 2, 1).  But you should
use the i386_set_ioperm(0x330, 2, 1), aren't you?  You're trying
to grant the IO permissions for your process?  Then use i386_set_ioperm
that will be equivalent to the first parameter to the 'int 0x80' to
0x04 instead 0x03.

With 0x03 you're just trying to make the system to write the _current_
IO permissions starting with port 0x330 to the _addresses_ 0x02 and
0x01.  And this is obviously wrong, but it should provoke the segfault
error instead of sigbus.

I am not sure about the 'pushl params' statement: will it push all
three arguments to the stack?  My GNU assembler knowledge is rather
rusty and incomplete, sorry.  But maybe it is the reason why you're
getting the sigbus instead of 'correct' sigsegv.
-- 
Eygene


More information about the freebsd-hackers mailing list