* Re: ISA BUS, memory, and mmap
1998-05-20 4:00 ` Peter A Fein
@ 1998-05-20 4:00 ` Linus Torvalds
1998-05-20 4:00 ` Peter A Fein
1998-05-20 4:00 ` Robert Hyatt
1998-05-21 4:00 ` lsr
2 siblings, 1 reply; 8+ messages in thread
From: Linus Torvalds @ 1998-05-20 4:00 UTC (permalink / raw)
In article <873ee4u1zf.fsf@bj2-64.rh.uchicago.edu>,
Peter A Fein <p-fein@uchicago.edu> wrote:
>lsr@snerd.ddns.org writes:
>
>> Greetings,
>>
>> I am writing a C program to access a card installed in a ISA slot in a DEC
>> Alpha 500au workstation. The card is designed to be accessible via the memory
>> bus and installs at memory address 0xFC0000 which is configurable via
>> jumpers. The question is: Is this really the address that it will appear at,
>> or is there some non obvious translation that needs to occur? Any info would
>> be greatly appreciated. Thanks.
>
>First, which OS are you using, as this is probably going to make a
>difference in how you access this memory. I don't know anything about
>OSF, but in linux, user programs can't access real memory locations
>b/c of virtual memory. You'd need to write a kernel-level driver
>which provided a user interface to the hardware. I have heard some
>talk of adding user-level direct adressing, but I don't believe it's
>going to be implemented any time soon.
You _can_ do user-level direct addressing under Linux, and this is what
the X server does. It's not trivial, and it needs some setup, but it
does work. You'd have to look into X sources to see how they do all the
details, I suspect.
I assume the same could work on OSF/1 if they got the HAE handling
correct (HAE can be a bitch to get right if you want to be able to do
reliable IO from user space - I know Linux does this correctly, but it
may be that the DEC engineers decided that direct IO from user space
wasn't something they wanted to support).
If you're writing a kernel driver, the thing is trivial to use under
Linux. The only thing you need to be aware of are the functions to
access IO memory, and there is actually documentation for this in the
file linux/Documentation/IO-mapping.txt in the 2.1.x kernel tree.
You'd be using something like this:
unsigned int base_address = 0xFC0000;
__u32 word;
/* Move a 32-bit word in IO memory from offset 0x10 to 0x20 */
word = readl(base_address + 0x10);
writel(word, base_address + 0x20);
/* Clear the low 32 bytes of the PCI memory region */
memset_io(base_addres, 0, 0x20);
etc. See IO-mapping.txt for more details.
Linus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ISA BUS, memory, and mmap
1998-05-20 4:00 ` Linus Torvalds
@ 1998-05-20 4:00 ` Peter A Fein
0 siblings, 0 replies; 8+ messages in thread
From: Peter A Fein @ 1998-05-20 4:00 UTC (permalink / raw)
torvalds@transmeta.com (Linus Torvalds) writes:
> You _can_ do user-level direct addressing under Linux, and this is what
> the X server does. It's not trivial, and it needs some setup, but it
> does work. You'd have to look into X sources to see how they do all the
> details, I suspect.
I'll look at those some point this weekend. I was under the impression
though that the translations involved in virtual memory meant that the
user's persepective had no relation to what was going on in real
memory. Can readl/writel & friends in io.h be called from the user
level or is there another way around this problem that I'm missing?
> Linus
You probably get this sort of thing a lot, but it makes me feel like I
have a bit of a clue to have you correct me. Thanks.
--
Peter Fein 773-834-6206
1005 E. 60th St. Chicago, IL 60637
p-fein@uchicago.edu http://pfein.home.ml.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ISA BUS, memory, and mmap
1998-05-20 4:00 ` Peter A Fein
1998-05-20 4:00 ` Linus Torvalds
@ 1998-05-20 4:00 ` Robert Hyatt
1998-05-21 4:00 ` lsr
2 siblings, 0 replies; 8+ messages in thread
From: Robert Hyatt @ 1998-05-20 4:00 UTC (permalink / raw)
In comp.os.linux.development.system Peter A Fein <p-fein@uchicago.edu> wrote:
: lsr@snerd.ddns.org writes:
:> Greetings,
:>
:> I am writing a C program to access a card installed in a ISA slot in a DEC
:> Alpha 500au workstation. The card is designed to be accessible via the memory
:> bus and installs at memory address 0xFC0000 which is configurable via
:> jumpers. The question is: Is this really the address that it will appear at,
:> or is there some non obvious translation that needs to occur? Any info would
:> be greatly appreciated. Thanks.
: First, which OS are you using, as this is probably going to make a
: difference in how you access this memory. I don't know anything about
: OSF, but in linux, user programs can't access real memory locations
: b/c of virtual memory. You'd need to write a kernel-level driver
: which provided a user interface to the hardware. I have heard some
: talk of adding user-level direct adressing, but I don't believe it's
: going to be implemented any time soon.
for non-portable programs, you could open /proc/kcore, as root, and
be careful of where you read. Or /dev/kmem for a different way of
accessing this... But it wouldn't work for user-level applications
due to permissions... unless you go the setuid route and don't
break something in the process...
: --
: Peter Fein 773-834-6206
: 1005 E. 60th St. Chicago, IL 60637
: p-fein@uchicago.edu http://pfein.home.ml.org/
--
Robert Hyatt Computer and Information Sciences
hyatt@cis.uab.edu University of Alabama at Birmingham
(205) 934-2213 115A Campbell Hall, UAB Station
(205) 934-5473 FAX Birmingham, AL 35294-1170
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ISA BUS, memory, and mmap
1998-05-20 4:00 ` Peter A Fein
1998-05-20 4:00 ` Linus Torvalds
1998-05-20 4:00 ` Robert Hyatt
@ 1998-05-21 4:00 ` lsr
1998-05-21 4:00 ` Wayne J. Salamon
1998-05-21 4:00 ` Peter A Fein
2 siblings, 2 replies; 8+ messages in thread
From: lsr @ 1998-05-21 4:00 UTC (permalink / raw)
In article <873ee4u1zf.fsf@bj2-64.rh.uchicago.edu>,
Peter A Fein <p-fein@uchicago.edu> wrote:
>
> lsr@snerd.ddns.org writes:
>
> > Greetings,
> >
> > I am writing a C program to access a card installed in a ISA slot in a DEC
> > Alpha 500au workstation. The card is designed to be accessible via the
memory
> > bus and installs at memory address 0xFC0000 which is configurable via
> > jumpers. The question is: Is this really the address that it will appear
at,
> > or is there some non obvious translation that needs to occur? Any info
would
> > be greatly appreciated. Thanks.
>
> First, which OS are you using, as this is probably going to make a
> difference in how you access this memory. I don't know anything about
> OSF, but in linux, user programs can't access real memory locations
> b/c of virtual memory. You'd need to write a kernel-level driver
> which provided a user interface to the hardware. I have heard some
> talk of adding user-level direct adressing, but I don't believe it's
> going to be implemented any time soon.
>
> --
> Peter Fein
773-834-6206
> 1005 E. 60th St. Chicago, IL
60637
> p-fein@uchicago.edu
http://pfein.home.ml.org/
>
I guess I should have been a little more specific in my request. I understand
virtual memory vs physical memory etc. My question should have been: If I
have an ISA card that is setup via jumpers for memory mapped IO beggining at
address 0xFC0000, can I use that address as the offset in the mmap function
call, or is there some translation that I must do. I'm interested in both
Linux and DEC OSF. Thanks.
-lsr
lsr@iquest.net
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ISA BUS, memory, and mmap
1998-05-21 4:00 ` lsr
@ 1998-05-21 4:00 ` Wayne J. Salamon
1998-05-21 4:00 ` Peter A Fein
1 sibling, 0 replies; 8+ messages in thread
From: Wayne J. Salamon @ 1998-05-21 4:00 UTC (permalink / raw)
lsr@snerd.ddns.org wrote:
: Peter A Fein <p-fein@uchicago.edu> wrote:
: >
: > First, which OS are you using, as this is probably going to make a
: > difference in how you access this memory. I don't know anything about
: > OSF, but in linux, user programs can't access real memory locations
: > b/c of virtual memory. You'd need to write a kernel-level driver
: > which provided a user interface to the hardware. I have heard some
: > talk of adding user-level direct adressing, but I don't believe it's
: > going to be implemented any time soon.
: >
: > --
: I guess I should have been a little more specific in my request. I understand
: virtual memory vs physical memory etc. My question should have been: If I
: have an ISA card that is setup via jumpers for memory mapped IO beggining at
: address 0xFC0000, can I use that address as the offset in the mmap function
: call, or is there some translation that I must do. I'm interested in both
: Linux and DEC OSF. Thanks.
For Linux on Intel machines, it's fairly simple to write a device
driver to map a card into user space. For a DEC Alpha, things are
more complicated. DEC Unix (and OSF, I believe) do not support the
mmap() call "officially". I have a driver for our card that
maps the card into user space via mmap(). It may help you.
The Linux driver is at ftp://cmr.ncsl.nist.gov/pub/multikron/mk_Linux.tar.Z,
(for Intel machines), while the DEC Unix/Alpha driver is at
ftp://cmr.ncsl.nist.gov/pub/multikron/mk_Alpha.tar.Z.
For DEC Unix system, the user program doesn't access the card
via the virtual address directly; there are some translation
macros that must be used. These macros are in one of the include
files in the tar file I gave above.
Good luck,
WJS
--
----------------------------------------------------------------------
| Wayne J. Salamon | National Institute of Standards & Technology |
| Computer Scientist | Gaithersburg, MD 20899 |
| wsalamon@nist.gov | |
----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ISA BUS, memory, and mmap
1998-05-21 4:00 ` lsr
1998-05-21 4:00 ` Wayne J. Salamon
@ 1998-05-21 4:00 ` Peter A Fein
1 sibling, 0 replies; 8+ messages in thread
From: Peter A Fein @ 1998-05-21 4:00 UTC (permalink / raw)
lsr@snerd.ddns.org writes:
> In article <873ee4u1zf.fsf@bj2-64.rh.uchicago.edu>,
> Peter A Fein <p-fein@uchicago.edu> wrote:
> >
> > lsr@snerd.ddns.org writes:
> >
> > > Greetings,
> > >
> > > I am writing a C program to access a card installed in a ISA slot in a DEC
> > > Alpha 500au workstation. The card is designed to be accessible via the
> memory
> > > bus and installs at memory address 0xFC0000 which is configurable via
> > > jumpers. The question is: Is this really the address that it will appear
> at,
> > > or is there some non obvious translation that needs to occur? Any info
> would
> > > be greatly appreciated. Thanks.
> >
> > First, which OS are you using, as this is probably going to make a
> > difference in how you access this memory. I don't know anything about
> > OSF, but in linux, user programs can't access real memory locations
> > b/c of virtual memory. You'd need to write a kernel-level driver
> > which provided a user interface to the hardware. I have heard some
> > talk of adding user-level direct adressing, but I don't believe it's
> > going to be implemented any time soon.
> >
> > --
> > Peter Fein
> 773-834-6206
> > 1005 E. 60th St. Chicago, IL
> 60637
> > p-fein@uchicago.edu
> http://pfein.home.ml.org/
> >
>
> I guess I should have been a little more specific in my request. I understand
> virtual memory vs physical memory etc. My question should have been: If I
> have an ISA card that is setup via jumpers for memory mapped IO beggining at
> address 0xFC0000, can I use that address as the offset in the mmap function
> call, or is there some translation that I must do. I'm interested in both
> Linux and DEC OSF. Thanks.
>
Ok. It's just that there seem to have been a number of "How do I
address memory directly, like under DOS?"-type requests lately. If
you check the manpage for mmap, it appears to indicate that you pass
it a base address, a length and some flags & it returns the address
you should use in your local space (ie, the one it mapped to). Other
posts seem to indicate that such programs need to be setuid root. Not
actually having used this stuff myself, I'm not the final authority
(but that's no reason no to conjecture. ;) ).
--
Peter Fein 773-834-6206
1005 E. 60th St. Chicago, IL 60637
p-fein@uchicago.edu http://pfein.home.ml.org/
^ permalink raw reply [flat|nested] 8+ messages in thread