flat assembler
Message board for the users of flat assembler.
Index
> Linux > Direct hardware access [Bit off-topic] |
Author |
|
crc 21 Oct 2004, 12:38
It is possible to do direct hardware access, but it's not easy You have to use IOCTL's to set permissions, and quite possibly run the program as root. If you write a kernel module, it should be easier (though you do risk killing the kernel if you're not careful)
|
|||
21 Oct 2004, 12:38 |
|
gunblade 21 Oct 2004, 12:42
Now thats a bloody quick answer
So the best idea for direct access is making a kernel module? Is there not another way of making a program execute with the permissions of the kernel? Thanks, Gunblade |
|||
21 Oct 2004, 12:42 |
|
crc 21 Oct 2004, 14:09
Quote: So the best idea for direct access is making a kernel module? Yes. Quote: Is there not another way of making a program execute with the permissions of the kernel? Not that I'm aware of. You can use IOCTL's (fairly difficult IIRC) to request read/write permission for specific ports and possibly memory ranges, but it's not easy. They aren't well documented, and you may still have to use the files in /dev for some hardware. Keep in mind that Linux (and most other modern OSes) are designed to keep hardware access from userspace to a minimum. |
|||
21 Oct 2004, 14:09 |
|
fasm9 31 Oct 2004, 11:28
Quote: So the best idea for direct access is making a kernel module? x11/x* is not kernel module but it's popular. it is user-mode device driver. so it doesn't care about kernel like openbsd, freebsd, linux, hurd, macosx, ... -- |
|||
31 Oct 2004, 11:28 |
|
crc 31 Oct 2004, 12:48
Does X11 directly access the hardware? I *know* that you can use IOCTL's to gain access to specific areas of the hardware, but full, unrestricted access is limited to kernel space. IOCTL's are a pain to use; which is why I suggest making a kernel module if you need direct hardware access.
|
|||
31 Oct 2004, 12:48 |
|
fasm9 31 Oct 2004, 13:35
no it isn't.
x11/x* use linux's system-call. these 250 system-call(x86) units can access to the abstract hardware. But, in unix(monolithic) environment, it's meaningless to classify system programming and application programming, the mechanism is different, everything is file/(c programming dmr, ken) .. -- |
|||
31 Oct 2004, 13:35 |
|
Endre 03 Jan 2005, 14:36
gunblade wrote: Hey, 1.) Check out functions ioperm and iopl. With these functions (syscalls) you can get right for access to IO ports (see in/out assembly instructions). 2.) When communicating to the device, you likely need a contiguous memory place in order to serve the DMA transfer. Since you are in user space thus you are in virtual-address space. That is the virtual (or linear) addresses you see are not equal to physical ones the device needs, not speaking about that the memory you see to be virtually contiguous can physically be fregmented which is not what you want. Here is a kernel patch I used when writing NIC drivers for MenuetOS. With this you can reach your aims, however I was able to allocate merely 4K (one page), but fortunately it was enough for me and at least I could supply DMA with it. Maybe it have been improved since then. http://www.gelato.unsw.edu.au/IA64wiki/UserLevelDrivers Endre. |
|||
03 Jan 2005, 14:36 |
|
gunblade 06 Jan 2005, 01:55
thank you very much Endre,
that link proved very useful And yeah, so now i see, its either a kernel device driver, or ioctl. So thank you again gunblade |
|||
06 Jan 2005, 01:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.