2011年12月27日 星期二

Linux char device driver todo list

  • __init 和 __exit function裡面implement add/remove cdev structure, apply/release device ID
  • implement file_operation 裡有用到的function 如 read() write() ioctl()

另外在driver 的Makefile裡
obj-y 代表 build進kernel
obj-m 代表build成module 型式, 也就是*.ko
obj-n 代表不build

通常obj-後面會用Kconfig裡的變數取代, 在make menuconfig後, kconfig會把各目錄下的.config parse一遍, 知道user的設定在shell的variables裡, 然後在building time依據設定build kernel

2011年12月23日 星期五

Some Useful EFI blogs

2011年12月21日 星期三

C/C++中 union 用法

平常因為工作內容的關係, 從沒用過union

今天突然看到, 竟然忘記這資料結構是甚麼 ! 筆記一下大陸人的網頁
#include <stdio.h>
void main()
{
union number
{ /*定义一个联合*/
int i;
struct
{ /*在联合中定义一个结构*/
char first;
char second;
}half;
}num;
num.i=0x4241; /*联合成员赋值*/
printf("%c%c\n", num.half.first, num.half.second);
num.half.first='a'; /*联合中结构成员赋值*/
num.half.second='b';
printf("%x\n", num.i);
getchar();
}
输出结果为: 
AB 
6261 

2011年12月20日 星期二

shell script

最近學習linux的shell script 
做一寫筆記備用


$1 $2 .....     parameter 1 2 ....
$# total number of parameter
$? return value of previous command
$@ list of all parameters one bye one
$* list all parameters with one string


logic operator
1. 
while [ true ] ; do
done
2. 
until [ ] ; do
done
3. 
for arg in " "
do
done
4. 
if [ ]
then
else
fi

Online Tutorial Link