Kernel modules can be developed for two types of devices.
Block Devices
Block Devices
As the name says, Kernel accesses block devices by blocks (usually 1kb). It is generally used for hosting file systems.
Character Devices
Kernel accesses char devices like a file. Parallel port, Serial ports are char devices.
Kernel modules can be loaded or unloaded into kernel dynamically in runtime. So kernel module has a generic structure*.
struct module
{
unsigned long size_of_struct;
struct module *next;
const char *name;
unsigned long size;
long usecount;
unsigned long flags;
unsigned int nsyms;
unsigned int ndeps;
struct module_symbol *syms;
struct module_ref *deps;
struct module_ref *refs;
int (*init)(void);
void (*cleanup)(void);
const struct exception_table_entry *ex_table_start;
const struct exception_table_entry *ex_table_end;
#ifdef __alpha__
unsigned long gp;
#endif
};
I still don't know how this structure works. I only know about two methods (marked blue). First one initializes a module to be inserted, second one does the job of removing.
I'll study abouth the other methods eventually.
*courtesy: module structure, http://www.freeos.com/articles/2677/
struct module
{
unsigned long size_of_struct;
struct module *next;
const char *name;
unsigned long size;
long usecount;
unsigned long flags;
unsigned int nsyms;
unsigned int ndeps;
struct module_symbol *syms;
struct module_ref *deps;
struct module_ref *refs;
int (*init)(void);
void (*cleanup)(void);
const struct exception_table_entry *ex_table_start;
const struct exception_table_entry *ex_table_end;
#ifdef __alpha__
unsigned long gp;
#endif
};
Return Values
On success, zero is returned. On error, -1 is returned
and errno is set appropriately.
I still don't know how this structure works. I only know about two methods (marked blue). First one initializes a module to be inserted, second one does the job of removing.
I'll study abouth the other methods eventually.
*courtesy: module structure, http://www.freeos.com/articles/2677/
No comments:
Post a Comment