Re: direct I/O access
- From: Raoul MEGELAS <rmgls@xxxxxxxxx>
- Date: Thu, 31 May 2007 14:36:48 +0200
On Thu, 31 May 2007 08:44:33 +0400
Eygene Ryabinkin <rea-fbsd@xxxxxxxxxxx> wrote,
Wed, May 30, 2007 at 02:43:07AM -0400, Mike Meyer wrote:
I believe this should be $0x4, as you want to *set* the values, not
get them.
Right.
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 feel that the i386_set_ioperm directly manipulates the task's I/O
bitmap referenced by the task state segment (TSS), so you don't
need to mangle with /dev/io. /dev/io itself is the higher-level
semi machine-indenepdent abstraction. Opening /dev/io grants the
global access to all ports, while using i386_set_ioperm gives the
fine-grained access. When you closing /dev/io, the port I/O access
is revoked.
To summarise: either you open /dev/io and do all your port I/O as
in the good old days of the real-mode programs, or you're using
i386_set_ioperm to obtain the access permissions to the I/O port
range and again, do all port I/O as usual.
i rewrote my code and this time, all works fine.
thanks to Mike and Eygene.
here is the code as a proof of the above explanation:
# test_io.S
.include "system.inc"
BUFSIZE = 0x80
.data
params: .long 0x70,2,1,0
path: .asciz "/dev/io"
.bss
buffer: .fill BUFSIZE, 0
.text
.global _start
err:
pushl $0x1 # return failure
SysExit
_start:
addl $8,%esp # discard argc and argv[0]
leal params,%eax
pushl %eax
pushl $4
movl $0xa5,%eax
call bsd_kernel
addl $12,%esp
movl $0X330,%edx
inb %dx,%al
# if i try to read or write another port than 0x70/0x71, i have a segbus fault.
leal path,%ecx
pushl $0 # O_RDONLY
pushl %ecx
SysOpen
jc err # open failed
addl $8,%esp
movl $0X330,%edx
inb %dx,%al
# all is ok!
pushl $0 # return success
SysExit
Thanks again.
Raoul
rmgls@xxxxxxxxxx
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Prev by Date: Re: can we use disk device for iscsi-target port?
- Next by Date: Re: direct I/O access
- Previous by thread: Re: direct I/O access
- Next by thread: Freebsd 6.2 panic
- Index(es):
Relevant Pages
- Re: I/O Address Space
... > that the I/O port addresses were mapped by hardware. ... For example, an
I/O port BAR ... on a PCI card can be set to a specific I/O port by the BIOS or
OS. ... (comp.lang.asm.x86) - Re: open command failing on serial port
... >> it attempts to discover my port configuration, ... > IRQ and IO
address for that card. ... once it is installed you can't modify that card. ...
the 8th column is the ending I/O port address. ... (comp.unix.sco.misc) - Re: How to generate a #SMI?
... management mode (SMM for short). ... there is only one way to enter SMM, which
is through #SMI. ... the system provides a special I/O port; ... only occurs
on read or writes for the I/O port. ... (comp.lang.asm.x86) - Re: [patch 04/16] I/O driver for 8250-compatible UARTs
... PCI or MMIO UART, because you don't know what its name will be. ... If you gave
up the convenience and just always required an I/O port ... This syntax doesn't really
make sense on ia64, ... (Linux-Kernel) - Re: Clarification on IO Operations
... the I/O port read/write signal combination. ... it is either a part of the instruction
itself ... tauno voipio iki fi ... (comp.os.linux.development.system)