Running bin file from a module


 
Thread Tools Search this Thread
Top Forums Programming Running bin file from a module
# 15  
Old 03-17-2011
Quote:
Originally Posted by Chrisdot
Hmm... so if I create simple doing nothing (or printing text to dmesg) kernel space dynamic library, save it wherever on HDD and try to use from device driver - would that work?
You're talking about kernel modules, I think. These can be loaded whenever. Make both these things, your little loader thing and the thing which uses it, both modules, and have the main thing depend on the little thing. Whenever the main module is loaded it will try to load your loader module first. It will look for it in a specific place on the hard drive (/lib/modules/kernel-version/kernel/...).

You can also manually tell the kernel to load a module file whenever with modprobe modulename if the module's installed under /lib/..., or insmod filename.ko to point it to a specific file.

I haven't used module dependencies myself so can't be more specific, sorry.
Quote:
Is there a way to create dynamic library in kernel space and call it from device driver?
Create a dynamic library? As in convert from source code into a module? Creating a module takes gcc and dozens of megs of kernel source, all of which happens in userspace. No.

Again though -- what you do really depends on what the contents of this mysterious "block" are and where it will be and how you must get at it. Do you have any information whatsoever on what it actually is? If not, you really don't have the information you need to write a driver.
This User Gave Thanks to Corona688 For This Post:
# 16  
Old 03-17-2011
Quote:
My friend is creating an UEFI emulator that redefine calls and do all necessary operations.
Humm, it is not as easy as refining calls.

If you and your friend are creating a UEFI emulator, I assume that you have studied all 2200 plus pages of the UEFI 2.3 specification and looked at the TianoCore reference implementation sources.

I should point out that the UDK2010 release contains a port of the emulator to OS X which was done by Andrew Fish of Apple. Andrew's port was then ported to Fedora 14 - see UEFI Emulator on Fedora 14.

I still cannot see why you are trying to load a UEFI driver binary into a Linux kernel. That makes absolutely no sense. Loading a UEFI driver into the UEFI emulator makes sense; existing UEFI emulators do that all the time. You can do this programmatically or from a UEFI shell. If you feel that you need extra functionally in the Linux kernel when you load a UEFI driver, you need to write a suitable Linux kernel driver to do the necessary and then write a suitable glue layer in the UEFI emulator.

Working on the internals of a UEFI emulator is not for the faint of heart! Good luck to you.
This User Gave Thanks to fpmurphy For This Post:
# 17  
Old 03-18-2011
Well, I show you "Big picture" as you asked for.

Actors:
User
PC with preinstalled OS: RedHat from 2010year
Network Interface Card (let's call it "NIC") produced in 2011year

Usage model:
1. User plugs NIC to PCIe bus in PC
2. User turns on PC
3. User has got an internet connection

Do you got the idea? Just plug and play - no drivers, no additional installations, etc.
Of course - there are some limitations I tell about later.
If user wants to install regular drivers - he download it from vendor site and install.

- how is it possible?
There is known UEFI API for NIC before NIC is released to the market and even before silicon is created
- how many adapters it is dedicated for?
For now it is only one specific adapter model (it may changes in future).
- what functionality is to be implemented?
Only very basic options like: send packet, receive packet, obtain IP address from DHCP. It even does not has to run at full speed.
- how much resources are to do that?
It is about 8 months, few engineers
- has user to use UEFI machine?
No - he can use UEFI based machine or BIOS one

If you have another questions I try to answer but for sure I cannot tell all the details because of copyrights, and other law-connected things.

Now I have to create demos and propositions to solve some problems to set way of doing all the work (and discuss it with other people).


I show you some scenarios (at this moment I do not know exactly how UEFI Emulator presented by fpmurphy works):

1.
Actors:
RedHat with preinstalled MyLinuxDriver
NIC with UEFI Driver

On boot MyLinuxDriver copies UEFI Driver from NIC's flash to HDD/RAM
After that all calls to MyLinuxDriver are translated through UEFI Emulator to UEFI Driver.

2.
Actors:
RedHat with preinstalled MyLinuxDriver
NIC with UEFI Driver

On boot MyLinuxDriver copies UEFI Driver from NIC's flash to HDD/RAM and at the same time UEFI Emulator translates it to linux-understandable format.
All calls to MyLinuxDriver are redirected to UEFI TRANSLATED Driver.



What I need to know:
- how to load UEFI Driver from NIC's flash? (for demo purposes it could be 'how to load whatever from whenever', just to show that such operation is possible)
- where to load that driver? (RAM/HDD)
- when translate UEFI Driver to linux-understandable format (on boot, or on each call)

Thank you very much for your attention and useful information. I really apreciate your help guys!

PS.
Quote:
Originally Posted by fpmurphy
I still cannot see why you are trying to load a UEFI driver binary into a Linux kernel.
I am not trying to do that - I am trying to find proper way to solve my problem described above.

Last edited by Chrisdot; 03-18-2011 at 08:06 PM..
# 18  
Old 03-18-2011
Quote:
Originally Posted by Chrisdot
Well, I show you "Big picture" as you asked for.

Actors:
User
PC with preinstalled OS: RedHat from 2010year
Network Interface Card (let's call it "NIC") produced in 2011year

Usage model:
1. User plugs NIC to PCIe bus in PC
2. User turns on PC
3. User has got an internet connection

Do you got the idea? Just plug and play - no drivers, no additional installations, etc.
Well that only took three entire pages of begging. THANK YOU.

I think you may be going about this the wrong way still though. The way to do this would be to add general-purpose UEFI support to Linux, not to hack one special thing that supports UEFI. And you'd probably want to use some sort of emulator, not something that converts UEFI code into whatever code your kernel uses.

But the biggest problem is I'm not sure UEFI even applies once an operating system's been loaded. Linux used to support BIOS-mode disk devices, for example, until it became clear that there were just too many corner cases where running in protected mode and controlling your own interrupts and DMA and all that jazz prevented BIOS calls from being able to work the way it was intended no matter how hard you tried to fool them. Sometimes. Very firmware-dependent. So they dropped that and added support for droves of different hard drive controllers instead, and that's how it's worked for a long time. Some coherent standards like AHCI are helping make drivers more generic again though.

You could make something like a DOS around raw UEFI devices -- a small self-contained OS which relies on system firmware to do most of the work. It could be surprisingly sophisticated with the system firmware features available now. Networking and graphics could be sufficient to run a reasonable impression of a web browser to download and save drivers with.

Last edited by Corona688; 03-18-2011 at 06:04 PM..
# 19  
Old 03-18-2011
I added one point to my "Big Picture":
- has user to use UEFI machine?
No - he can use UEFI based machine or BIOS one

After UEFI loads regular OS it becames useless. I would like to use only UEFI Driver placed in Network Interface Card's flash - no general UEFI OS. My solution has to run on BIOS machine and works as well as on UEFI machine.

I think that "adding general-purpose UEFI support to Linux" is out of range. Such work needs much more resources.

Quote:
Originally Posted by Corona688
You could make something like a DOS around raw UEFI devices -- a small self-contained OS which relies on system firmware to do most of the work.
Could you continue your tought? I have never heard about this.
# 20  
Old 03-18-2011
Quote:
Originally Posted by Chrisdot
After UEFI loads regular OS it becames useless.
And how do you propose to overcome this problem? Simply loading it in the kernel isn't enough to make it work. Once an OS loads, the environment's not right anymore.
Quote:
I think that "adding general-purpose UEFI support to Linux" is out of range.
Which is unfortunate since I think that's the only way you'd get linux to do what you want -- use UEFI devices exclusively so you don't have to use your own drivers and in doing so alter the machine's environment.
Quote:
Could you continue your tought? I have never heard about this.
DOS is an extremely simple operating system. It doesn't have or need device drivers for basic functionality and it doesn't modify the system environment much at all. It relies on BIOS calls(i.e. firmware code) almost exclusively instead.

The original IBM PC BIOS calls were rather limited in function though, so raw DOS doesn't get you anything but disk+console+keyboard, and it's performance is poor compared to what real device drivers could do.

A DOS-like thing that fully utilized UEFI firmware capabilities could have much more features than DOS did. It wouldn't be anything like Linux but might be useful since you could still run many tools in it. You could check out LILO or GRUB to see how they use UEFI.
# 21  
Old 03-18-2011
Quote:
What I need to know:
- how to load UEFI Driver from NIC's flash? (for demo purposes it could be 'how to load whatever from whenever', just to show that such operation is possible)
- where to load that driver? (RAM/HDD)
- when translate UEFI Driver to linux-understandable format (on boot, or on each call)
From the OS you cannot load the UEFI driver from the NIC flash because, according to you, there is no UEFI driver in place to access the NIC flash in the first place. Your NIC is unknown to UEFI if it cannot be enumerated. Chicken and egg situation. Now if you set up things so that your NIC is found when UEFI is probing devices, then you could write an UEFI app that could access the NIC flash, get driver image and store it in the ESP. It could then unload the existing driver and load the new driver in its place. All this needs to be done before the OS boots.

You cannot translate UEFI driver to "linux-understandable format." Period. UEFI using protocols and Linux uses APIs. They use different calling conventions also. A UEFI driver has no place in the Linux kernel.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question