Re: Newbie questions on the kernel programming
- From: "Lew Pitcher" <lpitcher@xxxxxxxxxxxx>
- Date: 19 Jun 2006 08:20:37 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
leo.liang.chen@xxxxxxxxx wrote:
Hi all,
I am learning linux kernel programming starting from "The Linux Kernel
Module Programming Guide"(http://www.faqs.org/docs/kernel/) . I have
background in Windows DDK, but I am confused on the following topics.
Can anyone here give me some hints.
1) MODULE_PARM() macro (http://www.faqs.org/docs/kernel/x350.html)
static short int myshort = 1;
static int myint = 420;
static long int mylong = 9999;
static char *mystring = "blah";
MODULE_PARM (myshort, "h");
MODULE_PARM (myint, "i");
MODULE_PARM (mylong, "l");
MODULE_PARM (mystring, "s");
In the sample code, it is said the MODULE_PARM macro can allow
arguments to be passed to the driver module. But how?
When the module is invoked (via modprobe or insmod), you can specify
the values to be passed to the module as 'options' to the load command
In /etc/modules.conf, you include an "options" line that gives the
values for your modules parameters
options mymodule myshort=5 myint=-3100 mylong=99999999
mystring="argh"
Alternately, you specify them on the modprobe or insmod commandline
modprobe mymodule myshort=1 myint=-7 mylong=9999999 mystring="blah"
or
insmod mymodule myshort=1 myint=-7 mylong=9999999 mystring="blah"
2) Character Device Drivers(http://www.faqs.org/docs/kernel/x571.html)
I can not catch the key points in this section. What should I learn
from the "chardev.c" sample? How can I install the module as a device?
How can I call the functions in the driver?
character devices do not support "random" access, or features that
require "random access", so you implement null (return error value)
functions for the entrypoints that service lseek, mmap, readdir, etc.
Really, a character device only really must support read, write, open,
close, and may support ioctl, etc. so those are the functions you /do/
implement.
Finally, you have to connect the driver when you load it, and
disconnect it to unload it.
3) The /proc File System(http://www.faqs.org/docs/kernel/x716.html)
What's the main points in the section. How does the /proc file system
matter linux kernel programming?
The /proc filesystem is used by the linux kernel (and kernel tools like
device drivers) to externalize status information and accept control
information. Think of it as an easier-to-use alternate to ioctl. A
device driver doesn't /have/ to implement a /proc interface, but it can
do so to accept control information, or to provide feedback that
otherwise must be handled through an ioctl or another device I/O.
- --
Lew Pitcher
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12
iD8DBQFElsC3agVFX4UWr64RAtPXAKDbME76HQgOTbwjQoibTKUuhv+rnwCgobSW
xxKcprdUHSdY86Up4tY/0to=
=s9Qx
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: Newbie questions on the kernel programming
- From: Grant Edwards
- Re: Newbie questions on the kernel programming
- References:
- Newbie questions on the kernel programming
- From: leo.liang.chen@xxxxxxxxx
- Newbie questions on the kernel programming
- Prev by Date: Re: Periodic Timer for 1 millisecond
- Next by Date: Re: Newbie questions on the kernel programming
- Previous by thread: Newbie questions on the kernel programming
- Next by thread: Re: Newbie questions on the kernel programming
- Index(es):
Relevant Pages
|
|