2010年10月25日 星期一

Driver: passing Command Line Argument to a Module

#include
#include
#include
#include
#include



#define DRIVER_AUTHOR "winnie@quanta"
#define DRIVER_DESC "hello"
static int myinit = 3;

module_param(myinit, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(myinit, "An integer");

static int __init hello_init(void)
{
printk(KERN_INFO "hello init myinit= %d \n", myinit);
if(myinit==0)
printk(KERN_INFO "@@myinit is zero = %d \n", myinit);
else
printk(KERN_INFO "@@myinit other = %d \n", myinit);
return 0;
}

static void __exit hello_exit(void)
{
printk(KERN_INFO "hellp exit \n");
}

module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);

insmod proc.ko myinit=10

S_IRUSR/S_IWUSR/S_IRGRP/S_IWGRP

S_IRUSR
Permits the file's owner to read it.

S_IWUSR
Permits the file's owner to write to it.

S_IRGRP
Permits the file's group to read it.

S_IWGRP
Permits the file's group to write to it.

Can't rmmod driver on Android

mkdir -p /lib/modules
cd /lib/modules
ln -s /system/lib/modules `uname -r`

2010年10月20日 星期三

linux driver

http://www.tldp.org/LDP/lkmpg/2.6/html/

http://www.captain.at/howto-linux-kernel-parallel-port-interrupt.php

http://tw.myblog.yahoo.com/chimei-015/archive?l=f&id=20

2010年10月18日 星期一

cscope & ctags

find . -name '*.h' -o -name '*.c' | cscope -i - -b &

-----------------------------------------------------
@@cscope setting on ubuntu
1./usr/share/vim/vim72/plugin/cscope_map.vim

@@Step 1 : Create cscope.out file on project.
#find . -name '*.h' -o -name '*.c' | cscope -i - -b &
or
#find . -name '*.[hc]' | cscope -i - -b -R &

Step 2 : At cscope.out directory and trace code by cscope

Search "Ctrl+[" in my PC.

General using "Ctrl+\" in general PC.

Step 3 :


@@ctags: "ctags -R ."

Start trace code "Ctrl+]"


----------------------------------------------------
ctaglist:
vi /etc/vim/vimrc


"Taglist edit"
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
nnoremap :TlistToggle


----------------------------------------------------
reference:
http://www.cmlab.csie.ntu.edu.tw/~daniel/linux/vim_source_navigation.html

2010年10月17日 星期日

Using screen to paste

Enter CTRL+A+[
Then, Using " " to select region
Finally, Using " " to return select region.

Go to another screen, Using CTRL+A+]

2010年10月14日 星期四

objdump

objdump -t u-boot
objdump -d u-boot

-i objdump –i 顯示支援的檔案格式與機器架構
-f objdump -f a.o 顯示檔頭資訊 (-file-headers)
-h objdump -h a.o 顯示區段表頭 (-[section-]header)
-x objdump -x a.o 顯示所有表頭 (-all-headers)
-d objdump -d a.o 反組譯程式段 (-disassemble)
-D objdump -D a.o 反組譯全部區段 (-disassemble-all)
-t objdump -t a.o 顯示符號表 (-syms)
-r objdump -r a.o 顯示重定位記錄 (-reloc)