在uclinux添加裝置驅動的完整過程(ZT)

來源:互聯網
上載者:User

下面以添加一個字元裝置為例,說明添加裝置驅動的過程.塊裝置與網路裝置可以比照處理.

1.原檔案放在 linux-2.4.x/driver/char/ ;本例中,名為xyz.c

2.裝置驅動原檔案必須包括這樣的一個函數:
void xyz_init(void){register(254, 'xyz', &xyz_fops)} 這個函數完成註冊.在linux-2.4.x/driver/mem.c 將會調用它.
這個函數也可以寫成:
void __init xyz_init(void){register(254, 'xyz', &xyz_fops)} 這樣不必須在 linux-2.4.x/driver/mem.c 調用它

3.修改 linux-2.4.x/driver/char/Makefile 在適當位置添加一行:
obj_$(CONFIG_XYZ) += xyz.o

4.修改linux-2.4.x/driver/char/Config.in, 添加一行:
bool 'xyz hahahaha' CONFIG_XYZ
便於在 make menuconfig 時選擇

5.修改linux-2.4.x/driver/char/mem.c
在適當位置(你去找就會發現,在檔案頭部)添加:
#ifdef CONFIG_XYZ
extern void xyz_init(void);
#endif
在chr_dev_init()函數添加:
#ifdef CONFIG_XYZ
xyz_init();
#endif
6. 修改vendor/Samsung/4510b/Makefile ,建立裝置節點;
在12---35行間,DEVICE 部分添加 如下內容
xzy,c,254,0

7.make menuconfig 選中 xyz hahahaha,
編譯,下載;啟動後你會看到 /proc/devices 中字元裝置多了一項 xyz 254

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.