1当驱动有误时,比如,访问的内存地址是非法的,便会打印一大串的oops出来
1.1以LED驱动为例
将open()函数里的ioremap()屏蔽掉,直接使用物理地址的GPIOF,如下图所示:
1.2然后编译装载26th_segmentfault并执行测试程序后,内核便打印了oops出来,如下图所示:
2.接下来,我们便来分析oops:
Unable to handle kernel paging request at virtual address 56000050
//无法处理内核页面请求的虚拟地址56000050
pgd = c3850000
[56000050] *pgd=00000000
Internal error: Oops: 5 [#1]
//内部错误oops
Modules linked in: 26th_segmentfault
//表示内部错误发生在26th_segmentfault.ko驱动模块里
CPU: 0 Not tainted (2.6.22.6 #2)
PC is at first_drv_open+0x78/0x12c [26th_segmentfault]
//PC值:程序运行成功的最后一次地址,位于first_drv_open()函数里,偏移值0x78,该函数总大小0x12c
LR is at 0xc0365ed8 //LR值
/*发生错误时的各个寄存器值*/
pc : [<bf000078>] lr : [<c0365ed8>] psr: 80000013
sp : c3fcbe80 ip : c0365ed8 fp : c3fcbe94
r10: 00000000 r9 : c3fca000 r8 : c04df960
r7 : 00000000 r6 : 00000000 r5 : bf000de4 r4 : 00000000
r3 : 00000000 r2 : 56000050 r1 : 00000001 r0 : 00000052
Flags: Nzcv IRQs on FIQs on Mode SVC_32 Segment user
Control: c000717f Table: 33850000 DAC: 00000015
Process 26th_segmentfau (pid: 813, stack limit = 0xc3