资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
为相应的设备写好基本驱动程序 并向VFS(virtual file system)注册即可,当上层应用要使用该设备时,VFS就会调用相应的设备函数。设备驱动程序可以归为以下3类: 1 块设备(block)以块为单位,允许随机访问,多用缓存技术 2 字符设备(char)以字节为单位,只能按顺序访问,不用缓存 3 网络接口(net)设备号:系统用主设备号(MAJOR)和次设备号(MINOR)来唯一标示一般设备 相同主设备号表示同一类设备,次设备号表示同类设备的个数,在(/dev目录)下有相应的文件,这样字符设备和块设备都可以通过文件操作的系统调用完成。 字符设备的驱动程序通过在device_struct数据结构的chrdevs向量中增加一项的方法来向内核注册自己注册:int result result=register_chrdev(主设备号,设备名,&结构体) (GPIO_MAJOR_NR,DEVICE_NAME,&gpio_fops)字符设备驱动驱动程序编译进内核的步骤:1 在uClinux-dist/linux2.4.x/drivers/char目录下编写驱动程序(gpio.h,gpio.c)2 修改uClinux-dist/linux2.4.x/dirvers/char/Config.in,在适当的位置添加一行: bool gpiotest supportCONFIG_GPIO在make menuconfig时 看见的是gpiotest support 选择这个时,既配置了CONFIG_GPIO3 修改uClinux-dist/linux2.4.x/dirvers/char/Makefile 在适当的位置添加一行: obj-$(CONFIG_GPIO) += gpio.o4 在uClinux-dist/linux2.4.x/dirvers/char/mem.c 中添加初始化 #ifdef CONFIG_GPIOextern int gpio_init(void);/在内核启动的时候对GPIO驱动程序进行注册 #endif 在这个函数中 int _init chr_dev_init(void) #ifdef CONFIG_GPIO gpio_init();/在内核启动的时候对GPIO驱动程序进行注册#endif 测试(应用)程序的编写和添加内核配置make clean 清除之前编译好的make menuconfig vendor/Product Selection-厂商和产品的选择 选择samsung 44b0 Kernel/Library/Defaults Selection内核和库的选择 -Kernel is linux-2.4.x (uClibc)Libc Version压缩的libc 的库 Default all settings(lose changes) * Customize Kernel Settings 内核的设定,添加驱动程序 * Customize Vendor/User Settings根文件系统,ram fs 内核配置目录:Code maturity level options-代码成熟度还在开发阶段的 Loadable module support-Enable Loadable module support内核模块的支持System Type -系统类型 (Samsung)ARM system type Generate big endian code 大小端的选择 *Set flash/sdram size and base addr 选择存储器的大小 (0c000000)(S)DRAM Base Address (00800000)(S)DRAM Size (00000000)FLASH Base Address (00200000)FLASH Size 2M (RAM)Kernel executes from (S3C44B0X-MBA44) Board InplementationGeneral setup-通用设定 Support hot-pluggable devices热拔插 *Networking support 网络的支持 System V IPC进程间通信 Reduced memory footprint BSD Process Accouting Sysct1 support *NMFPE math emulation模拟数字协处理器 (ELF)Kernel core(/proc/kcore) format内核格式 *Support uClinux FLAT format binaries 对没有MMU 的处理器的支持 *Support FLAT format compressed binaries RISC OS personality Compiled-in Kernel Boot Parameter *Timer and CPU usage LEDs *Timer LED *CPU usage LED Kernel -mode alignment trap handler m68knommu-style attached romfs in RAM support Networking options-网络选项Network device support网卡的支持Amateur Radio support 启动无线网络IrDA (infrared)supportATA/IDE/MFM/RLL supportSCSI support 一种存储接口ISDN subsystem数字电话的Parallel port support并行接口Memory Technology Devices(MTD)内存设备Plug and Play configuration即插即用设备Block devices块设备File systems文件系统Character devices字符设备USB supportI2O device supportKernel hackingCryptographic optionsLibrary routinesLoad an Alternate Configuration FileSave Configuration to an Alternate File进行应用程序的配置Core Alications 核心配置*init *enable console shell *execute firewall rulesLibrary Configuration 库的配置FLASH Tools Flash 一些工具Filesystem Applications 文件系统的应用Network Applications 网络配置Miscellaneous ApplicationsBusyBoxTinyloginMicroWindowsGamesNiscellaneous ConfiuggurationDebug Buildsgsm modemLED testS3C rtc testS3C adc testS3C ps2 testS3C eirq test再make depmake lib_onlymake user_onlymake romfs创建文件系统make image 创建镜像make
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号