Sponsored Content
Top Forums Programming Running bin file from a module Post 302505611 by Corona688 on Thursday 17th of March 2011 12:06:04 PM
Old 03-17-2011
Quote:
Originally Posted by Chrisdot
Well, Corona688 I see you have very large knowledge about writing linux drivers
I've done enough work with them to know they are a severe challenge. I've occasionally had to alter some predefined values. I wrote a linux driver that prints 'hello world' to dmesg. I couldn't write a real driver yet.

But I know enough to tell you that windmills device drivers don't work that way. The kernel isn't going to reach into userspace, rip one function out of your userspace program, and run it raw because you don't get the same kind of stack; you don't get an ordinary heap; you don't get anything from libc; you don't get the same kind of files -- what does stderr even mean when you have no descriptor table? -- you don't get easy system calls like read() and write(); you don't even get easy, direct access to large amounts of available memory, and what memory there is is laid out in an alien way. The ease of all these things in userspace is a convincing illusion created by the kernel, more or less, and the way to use them is to be in userspace. Ordinary code can't run in kernel space any more than you could breathe in a vacuum.

Nearly all communication with the kernel is done through files and system calls instead. Your device driver can create a device file under /dev/ tied to your own kernel functions. someone opens it and your driver's read handler gets called, someone reads it and your device's read-handler gets called, etc. On boot, something in userspace could read from the ROM device and dump it into your special firmware-loading device file, and you'd be done.

Last edited by Corona688; 03-17-2011 at 01:15 PM..
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies

2. Programming

find the fully-qualified path for the app my module is running in

Hi- I need the cpp call that will tell me the full path to the app I'm running in. For example, I'm running in a loaded library for either mozilla or firefox, but would like to know the full path to the executable /usr/bin/firefox /usr/bin/mozilla /usr/local/firefox1_5 etc... (For... (4 Replies)
Discussion started by: erwinfletch
4 Replies

3. Linux

How to convert Linux Kernel built-in module into a loadable module

Hi all, I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/. I need to know if I can... (0 Replies)
Discussion started by: anitemp
0 Replies

4. Shell Programming and Scripting

Why does my /bin/csh take longer than /bin/perl?

Okay, so I have two "Hello, world!" scripts, "test.pl" and "test.sh". #!/bin/perl -w use strict; print "Hello, world!\n"; #!/bin/csh echo Hello,\ world! When I run test.pl, it runs instantly, always. When I run test.sh, it takes anywhere between 4 and 22 seconds! I'd like to know what... (3 Replies)
Discussion started by: acheong87
3 Replies

5. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies

6. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

7. Programming

Why am i getting these strange packets while running my packet capture module written in c.?

I have made an packet capture application running on intel machine, it is capturing packets with src address- 17.0.0.0 destination ip- 66.0.0.0, source port- 0, destination port- 0, and protocol- 0 what does these packets mean ? The code written to interpreter captured bytes is given below.... (5 Replies)
Discussion started by: arunpushkar
5 Replies

8. Ubuntu

Compile smbfs module in kernel version 3.10 running Ubuntu 12.04 LTS

Is there any way to compile smbfs module in kernel 3.10 running Ubuntu 12.04 LTS. I did a 'make menuconfig' and it shows cifs. I found out online that smbfs is deprecated and replaced by cifs. I have an old system with kernel version 2.4 which only has smbfs (no cifs). Is it possible to compile... (1 Reply)
Discussion started by: Monil
1 Replies

9. AIX

Redistribution bin required for AIX. j7r164redist.7.1.0.25.bin

Hi, I am planning to install a version of Informatica on my AIX box. It requires a specific java build in pap6470_27sr2-20141101_01(SR2). The current link for IBM 64-bit SDK for AIX®, JavaTM Technology Edition, Version 7 Release 1 has a more recent version in j7r164redist.7.1.0.75.bin. Is... (4 Replies)
Discussion started by: meetpraveens
4 Replies

10. Shell Programming and Scripting

Usage of #!/bin/sh vs #!/bin/bash shell scripts?

Some question about the usage of shell scripts: 1.) Are the commands of the base shell scripts a subset of bash commands? 2.) Assume I got a long, long script WITHOUT the first line. How can I find out if the script was originally designed für "sh" or "bash"? 3.) How can I check a given... (3 Replies)
Discussion started by: pstein
3 Replies
iomap(7)						 Miscellaneous Information Manual						  iomap(7)

NAME
iomap - physical I/O address mapping SYNOPSIS
DESCRIPTION
The mechanism allows the mapping (thus direct access) of physical I/O addresses into the user process address space. For PA-RISC machines, the physical I/O address space begins at and extends to The special (device) files for devices are character special files using the dynamic major number allocation scheme. The minor number for devices is of the form: The physical I/O address is formed by prefixing 0xAAAA with 0xF, and by appending 0x000 (this forces the I/O address to be page-aligned). The size of the region to be mapped is given by the expression M*(2^S) 4K pages. For example, the minor number for a device starting at that occupies 64MB is The driver must be explicitly added to the file, the kernel rebuilt, and the system subsequently rebooted prior to first using I/O space is always mapped with both read and write access rights, regardless of the actual permissions on the device special file. Multiple processes can have concurrently a single device opened and mapped. It is the responsibility of the processes to synchronize their access. Successive calls to to map the same I/O space must be identical to the first mapping. Identical mappings have the same address and size. Note that a process can additionally share I/O space (mapped by with a kernel driver. However, this is only possible if the driver maps in the I/O space with user read/write access rights using the appropriate driver I/O mapping services. Any I/O space mapped by drivers with kernel read/write access rights cannot be concurrently mapped by processes using No or system calls are supported by the driver. The function is used to control the device. The following requests are defined in Map the device into user address space at the location specified by the pointer to which the third argument to points. If the argument points to a variable containing a null pointer, the system selects an appropriate address. then returns the user address where the device was mapped, storing it at the address pointed to by the third argument (see below). Multiple processes can concurrently have the same device mapped. Unmap the device from the user address space. shuts down the file descriptor associated with the device. If the close is for the last system wide open on the device, the device is also unmapped from the user address space; otherwise it is left mapped into the user address space (see above). WARNINGS
Be extremely careful when creating and using devices. Inappropriate accesses to I/O devices or RAM can result in a system crash. ERRORS
The address field was out of range, or the request was invalid. Not enough memory could be allocated for the mapping. Device was already mapped and this mapping was not identical to the initial mapping (same address, size and access rights). Read and write calls are unsupported. No such device at the address specified by the minor number. Required resources for mapping could not be allocated. Inappropriate request for this device type; fildes is not a file descriptor for an device file. EXAMPLES
Consider the following code fragment: ... ... where is an open file descriptor for the device special file and is the address originally requested by the program. If is a null pointer, the system selects a suitable address then returns the selected address in addr. If the value in addr is not a null pointer, it is used as a specified address for allocating memory. If the specified address cannot be used, an error is returned (see SEE ALSO
mknod(1M). OBSOLETED iomap(7)
All times are GMT -4. The time now is 10:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy