当出现异常状态时,蜂鸣器会长鸣,同时打印出异常发生前所有寄存器的值和Kernel panic,以方便朋友们调试。
- #include "serial.h"
- #include "buzzer.h"
- #include "libs.h"
- /* print the kernel panic information */
- #define kernel_panic() \
- do{ \
- printk("\r\nKernel panic!!\r\n"); \
- buzzer_on(); \
- while(1); \
- } while(0)
- void undef_excp(unsigned long * sp)
- {
- printk("\r\nUndefine exception\r\n");
- stack_dump(sp);
- kernel_panic();
- // this will print the stack content
- }
- void prefetch_abt(unsigned long * sp)
- {
- printk("\r\nPrefetch abort exception\r\n");
- stack_dump(sp);
- kernel_panic();
- // this will print the stack content
- }
- void data_abt(unsigned long * sp)
- {
- printk("\r\nData abort exception\r\n");
- stack_dump(sp);
- kernel_panic();
- // this will print the stack content
- }
stack_dump实现在libs/libs.c中:
里面主要有:
- 16进制数转换成字符串函数:xtos
- 10进制数转换成字符串函数:dtos
- 内存设置函数:memset
- 内存数据打印函数:mem_dump和栈数据打印函数:stack_dump
- mem_dump可以放到os中任意位置,打印指定地址处的数值。
- #include "serial.h"
- #include "s3c2440.h"
- void xtos(unsigned long n){
- unsigned long i;
- if((i=n/16)!=0)
- xtos(i);
- if(n%16 > 9)
- putc(n%16 - 10 +'A');
- else
- putc(n%16+'0');
- }
- void dtos(unsigned long n){
- unsigned long i;
- if((i=n/10)!=0)
- xtos(i);
- putc(n%10+'0');
- }
- void memset(char * dest, long len, int value){
- if(dest == NULL || len <= 0)
- return;
- while(len--)
- *dest++ = value;
- return ;
- }
- // not safe copy
- char * memcpy(char * dest, const char * src, long len){
- char * temp = dest;
- if(dest == NULL || src == NULL || len <= 0)
- return NULL;
- while((dest - temp) != len)
- *dest++ = *src++;
- return temp;
- }
- void mem_dump(const unsigned long * src, long len){
- const unsigned long * temp = src;
- if(src == NULL || len <= 0)
- return;
- while(src-temp != len){
- printk("\r\n 0x");
- xtos(*src++);
- if((src-temp)%5 == 0)
- printk("\r\n");
- }
- printk("\r\n");
- }
- void stack_dump(unsigned long * sp){
- printk("\r\n CPSR:0x");
- xtos(*sp++);
- printk("\r\n R0:0x");
- xtos(*sp++);
- printk("\r\n R1:0x");
- xtos(*sp++);
- printk("\r\n R2:0x");
- xtos(*sp++);
- printk("\r\n R3:0x");
- xtos(*sp++);
- printk("\r\n R4:0x");
- xtos(*sp++);
- printk("\r\n R5:0x");
- xtos(*sp++);
- printk("\r\n R6:0x");
- xtos(*sp++);
- printk("\r\n R7:0x");
- xtos(*sp++);
- printk("\r\n R8:0x");
- xtos(*sp++);
- printk("\r\n R9:0x");
- xtos(*sp++);
- printk("\r\n R10:0x");
- xtos(*sp++);
- printk("\r\n R11:0x");
- xtos(*sp++);
- printk("\r\n R12:0x");
- xtos(*sp++);
- printk("\r\n SP:0x");
- xtos(*sp++);
- printk("\r\n LR:0x");
- xtos(*sp++);
- printk("\r\n PC:0x");
- xtos(*sp++);
- }
主要就是上述的改变,最新源码,请到LinuxIDC.com下载。
下载的代码只有针对QQ2440的,mini2440的和TQ2440的朋友,自己可以去将Key的驱动改一下即可。
miniOS_V2.0 默认是开启了调试模式的,可以在s3c2440.h中将DEBUG 改为0关闭。
PS:OS自带的两个测试应用程序,print应用也变了,在资源里一同下载。
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2012年资料/7月/10日/miniOS_V2.0更新/
