




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2012 年上学期嵌入式系统设计课程大作业 1 叙述下列相关名词的含义 ARM xscale PXA255 RISC 体系结构 2 画出嵌入式硬件系统组成的模块结构图 3 叙述基于 linux 的嵌入式平台的搭建过程 4 如下为 xscale 处理器的内核框图 简述内核框图中每个模块的名称及指标 5 下述英文为 BTB 模块功能的详细介绍 阅读后说明该模块的作用 6 下面是 linux 下的一个简单的设备驱动程序 写出 linux 设备驱动常用的数 据结构 同时阅读下面代码 请给出测试程序中的每条语句加以注释 The BTB stores the history of branches that have executed along with their targets Figure 5 1 shows an entry in the BTB where the tag is the instruction address of a previously executed branch and the data contains the target address of the previously executed branch along with two bits of history information The BTB takes the current instruction address and checks to see if this address is a branch that was previously seen It uses bits 8 2 of the current address to select the tag from the BTB and then compares this tag to bits 31 9 1 of the current instruction address If the current instruction address matches the tag in the BTB and the history bits indicate that this branch is usually taken in the past the BTB uses the data target address as the next instruction address to send to the instruction cache 设备驱动程序 Keypad c 的源代码 include include include include include include include include include include include define LEDnKEY MAJOR 251 define KEYPAD NAME X Hyper250 Keypad define KEYPAD VERSION Version 0 1 define EXT KEY CS EXT PORT2 define EXT LED CS EXT PORT3 define LED SHOW 10 EXT KEY CS 为向外部LED进行数值设定 它定义在其它头文件里 void led off on int i EXT LED CS 0 xff for i 0 i 8 i EXT LED CS 1 i 点亮相应LED灯 udelay 30000 EXT LED CS 0 xff 应用程序用open来打开设备文件 实际上调用驱动的lednkey open 函数 int lednkey open struct inode inode struct file filp 打开设备文件 MOD INC USE COUNT 内核提供的一个宏 检查使用驱动程序的用户数 return 0 success int lednkey release struct inode inode struct file filp 释放设备文件 led off on MOD DEC USE COUNT return 0 ssize t lednkey read struct file filp char Putbuf size t length loff t f pos 按键读取函数 unsigned short BottonStatus unsigned char Bottontmp 0 int i BottonStatus EXT KEY CS 按键状态 for i 0 i i copy to user Putbuf 将数据从内核态拷贝到用户态 这是 由定义在里的特殊函数实现在不同的空间传输任意字节的数据 return length ssize t lednkey write struct file filp const char Getbuf size t length loff t f pos int num unsigned char UsrWantLed copy from user 将数据从用户态拷贝到核心态 num UsrWantLed 确定哪一位要进行设定 EXT LED CS 1 num 1 点亮相应LED灯 return 0 int lednkey ioctl struct inode inode struct file filp unsigned int cmd unsigned long arg lednkey ioctl 接口函数 主要用于获取或者改变正在运行的设备参数 switch cmd case LED SHOW 如果要点亮LED灯 if arg led off on break return 0 以下这些驱动函数是与用户的应用程序里对设备文件操作的函数相对应的 struct file operations lednkey fops open lednkey open read lednkey read write lednkey write ioctl lednkey ioctl release lednkey release static int init xhyper250 keypad init void 初始化设备函数 在函数名之前加上这 个属性之后 系统会在初始化完成之后丢弃初始化函数 收回它所占用的内存 以减小内核所 占用的内存空间 它只对内建的驱动起作用 int result result register chrdev LEDnKEY MAJOR lednkey 向操作系统 注册一个主号为251 设备名为 lednkey 并传递设备驱动程序的指针为lednkey fops 全局 变量 其中register chrdev 是内核提供的函数 作用是完成注册新的字符设备 printf s s initialized n KEYPAD NAME KEYPAD VERSION led off on return 0 static void exit xhyper250 keypad exit void 向操作系统卸载设备函数 unregister chrdev LEDnKEY MAJOR lednkey led off on module init xhyper250 keypad init 显式声明初始化设备函数 module exit xhyper250 keypad exit 显式声明卸载设备函数 通过上述两个声明内核知道驱动程序的进入点 测试文件的源代码如下 include include include include include include define LED SHOW 10 int fd static char dev name dev keypad int main int argc char argv int data 0 pre data fd open dev name O RDWR if fd 0 printf s file open failed n dev name exit 1 printf nkeypad App press the push button see show led
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农业灌溉智能化升级路径:2025年行业深度剖析报告
- 东兴市艺佳种苗进出口贸易有限公司年产1万吨矿粉加工项目环境影响报告表
- 安全教育训练培训总结课件
- 扶贫搬迁工程方案范文(3篇)
- 安全教育活动培训课件
- 狂欢节的最后一天课件
- 牧歌电气安全培训班课件
- 安全教育平台应用培训课件
- 江苏省常州市2025年初中化学学业水平考试试卷附真题答案
- 安全教育培训资料台账课件
- GB/T 8758-2006砷化镓外延层厚度红外干涉测量方法
- GB/T 6396-2008复合钢板力学及工艺性能试验方法
- GA/T 1661-2019法医学关节活动度检验规范
- 初中化学人教九年级上册第六单元 碳和碳的氧化物 专题复习-实验与科学探究PPT
- 第七课-自觉坚持无神论-树立科学世界观课件
- 滑板项目选材指标与标准
- 智慧养猪解决方案演示课件
- 最新中医骨伤科学考试题库及答案
- 产品形态设计课件完整
- 德国巴斯夫抗氧剂和紫外线吸收剂
- SG-A088接地装置安装工程工检验批质量验收记录
评论
0/150
提交评论