《驱动程序设计课程大作业》由会员分享,可在线阅读,更多相关《驱动程序设计课程大作业(20页珍藏版)》请在金锄头文库上搜索。
1、驱动程序设计课程大作业驱动程序设计课程大作业任选下面的一个题目。如果是程序设计题目,要求在源码中必须包含足够的 注释,并提交一个不少于 5 页的文档,其内容包括: (1)程序的主要设计思路、 实现方式; (2)程序的模块划分,及对每个模块的说明(3)所遇到的问题及解 决的方法; (4)程序运行结果及使用说明; (5)收获及意见。1、编写一个 Linux 平台下实现通用 I/O 端口读写功能的字符设备驱动程序及其应用层测试程序,该驱动程序的主要功能如下: (1) 能够向指定的 I/O 端口写入一个或多个字节。 (2) 能够从指定的 I/O 端口读出一个或多个字节。 (3) 能够同时支持多个用户程
2、序。 应用层测试程序要求实现如下三个功能之一: (1) 能够读出、写入 BIOS CMOS 内存中的内容。CMOS 是一个 128 字节 大小的储存区, 它存放了有关机器 BIOS 配置的重要信息。IBM PC 兼 容机分配了 70H 和 71H 端口给 CMOS, 通过这两个端口我们可以访问 或者修改 CMOS 的配置信息。访问 70H,确定访问 CMOS 内存的地 址(0H-80H), 然后通过向已确定后的 CMOS 内存地址来访问 71H 数据 端口,从而达到访问或者修改 CMOS 内存数据的目的。CMOS 内存区 的详细定义见附录。 (2) 能够利用自己编写的通用I/O驱动做一个通过R
3、S232串口控制LED灯 的实验。在微机中一般用可编程芯片 8250 来实现串行通信,8250 共 有 10 个寄存器,被映射到 3F8H3FFH 地址范围内,这些寄存器的详 细定义和用法见后面的附录。 可以通过 3FCH 寄存器控制 RS232 名为 DTR 或 RTS 的管脚输出电平的高低,进而控制 LED 的亮和灭。(3) 能够控制 PC 扬声器发出音符“1 2 3 4 5 6 7 1” 。 2、编写一个 Linux 字符设备驱动程序,该程序能够扫描并显示所在计算机系统上的所有 PCI 设备的 I/O 配置信息。附录 1:BIOS CMOS 内存结构定义Offset Hex Offset
4、 Dec Field SizeFunction00h01 byteRTC seconds.Contains the seconds value of current time01h11 byteRTC seconds alarm.Contains the seconds value for theRTC alarm02h21 byteRTC minutes.Contains the minutes value of the currenttime03h31 byteRTC minutes alarm.Contains the minutes value for theRTC alarm04h4
5、1 byteRTC hours.Contains the hours value of the current time05h51 byteRTC hours alarm.Contains the hours value for the RTCalarm06h61 byteRTC day of week.Contains the current day of the week07h71 byteRTC date day.Contains day value of current date08h81 byteRTC date month.Contains the month value of c
6、urrentdate09h91 byteRTC date year.Contains the year value of current date0Ah101 byteStatus Register ABit 7 = Update in progress (0 = Date and time can be read,1 = Time update in progress)Bits 6-4 = Time frequency divider (010 = 32.768KHzBits 3-0 = Rate selection frequency (0110 = 1.024KHzsquare wave
7、 frequency)0Bh111 byteStatus Register BBit 7 = Clock update cycle (0 = Update normally, 1 = Abortupdate in progress)Bit 6 = Periodic interrupt (0 = Disable interrupt (default), 1= Enable interrupt)Bit 5 = Alarm interrupt (0 = Disable interrupt (default), 1 =Enable interrupt)Bit 4 = Update ended inte
8、rrupt (0 = Disable interrupt(default), 1 = Enable interrupt)Bit 3 = Status register A square wave frequency (0 =Disable square wave (default), 1 = Enable square wave)Bit 2 = 24 hour clock (0 = 24 hour mode (default), 1 = 12hour mode)Bit 1 = Daylight savings time (0 = Disable daylight savings(default
9、), 1 = Enable daylight savings)0Ch121 byteStatus Register C - Read only flags indicating system statusconditionsBit 7 = IRQF flagBit 6 = PF flagBit 5 = AF flagBit 4 UF flagBits 3-0 = Reserved0Dh131 byteStatus Register D - Valid CMOS RAM flag on bit 7 (batterycondition flag)Bit 7 = Valid CMOS RAM fla
10、g (0 = CMOS battery dead, 1 =CMOS battery power good)Bit 6-0 = Reserved0Eh141 byteDiagnostic StatusBit 7 = Real time clock power status (0 = CMOS has notlost power, 1 = CMOS has lost power)Bit 6 = CMOS checksum status (0 = Checksum is good, 1 =Checksum is bad)Bit 5 = POST configuration information s
11、tatus (0 =Configuration information is valid, 1 = Configurationinformation in invalid)Bit 4 = Memory size compare during POST (0 = POSTmemory equals configuration, 1 = POST memory not equalto configuration)Bit 3 = Fixed disk/adapter initialization (0 = Initializationgood, 1 = Initialization bad)Bit
12、2 = CMOS time status indicator (0 = Time is valid, 1 =Time is invalid)Bit 1-0 = Reserved0Fh151 byteCMOS Shutdown Status00h = Power on or soft reset01h = Memory size pass02h = Memory test pass03h = Memory test fail04h = POST complete; boot system05h = JMP double word pointer with EOI06h = Protected m
13、ode tests pass07h = protected mode tests fail08h = Memory size fail09h = Int 15h block move0Ah = JMP double word pointer without EOI0Bh = Used by 8038610h161 byteFloppy Disk Drive TypesBits 7-4 = Drive 0 typeBits 3-0 = Drive 1 type0000 = None0001 = 360KB0010 = 1.2MB0011 = 720KB0100 = 1.44MB11h171 by
14、teSystem Configuration SettingsBit 7 = Mouse support disable/enableBit 6 = Memory test above 1MB disable/enableBit 5 = Memory test tick sound disable/enableBit 4 = Memory parity error check disable/enableBit 3 = Setup utility trigger display disable/enableBit 2 = Hard disk type 47 RAM area (0:300h o
15、r upper 1KBof DOS area)Bit 1 = Wait for if any error message disable/enableBit 0 = System boot up with Numlock (off/on)12h181 byteHard Disk TypesBits 7-4 = Hard disk 0 typeBits 3-0 = Hard disk 1 type0000 = No drive installed0001 = Type 1 installed1110 = Type 14 installed1111 = Type 16-47 (defined la
16、ter in 19h)13h191 byteTypematic ParametersBit 7 = typematic rate programming disable/enabledBit 6-5 = typematic rate delayBit 4-2 = Typematic rate14h201 byteInstalled EquipmentBits 7-6 = Number of floppy disks (00 = 1 floppy disk, 01 =2 floppy disks)Bits 5-4 = Primary display (00 = Use display adapter BIOS,01 = CGA 40 column, 10 = CGA 80 column, 11 =Monochrome Display Adapter)Bit 3 = Display adapter installed/not installedBit 2 = Keyboard installed/not installedBit 1 = math coprocessor install