你好,游客 登录 注册 搜索
背景:
阅读新闻

miniOS_V2.0更新

[日期:2012-07-10] 来源:Linux社区  作者:mr_raptor [字体:大 中 小]
excp_handle.c增加了一点功能:

当出现异常状态时,蜂鸣器会长鸣,同时打印出异常发生前所有寄存器的值和Kernel panic,以方便朋友们调试。

  1. #include "serial.h"   
  2. #include "buzzer.h"   
  3. #include "libs.h"   
  4.   
  5. /* print the kernel panic information */  
  6. #define kernel_panic()                      \   
  7.     do{                                     \  
  8.         printk("\r\nKernel panic!!\r\n");   \  
  9.         buzzer_on();                        \  
  10.         while(1);                           \  
  11.     } while(0)  
  12.   
  13.   
  14. void undef_excp(unsigned long * sp)  
  15. {  
  16.     printk("\r\nUndefine exception\r\n");  
  17.     stack_dump(sp);  
  18.     kernel_panic();  
  19.     // this will print the stack content   
  20. }  
  21.   
  22. void prefetch_abt(unsigned long * sp)  
  23. {  
  24.     printk("\r\nPrefetch abort exception\r\n");  
  25.     stack_dump(sp);  
  26.     kernel_panic();  
  27.     // this will print the stack content   
  28. }  
  29.   
  30. void data_abt(unsigned long * sp)  
  31. {  
  32.     printk("\r\nData abort exception\r\n");  
  33.     stack_dump(sp);  
  34.     kernel_panic();  
  35.     // this will print the stack content   
  36. }  

stack_dump实现在libs/libs.c中:

里面主要有:

  • 16进制数转换成字符串函数:xtos
  • 10进制数转换成字符串函数:dtos
  • 内存设置函数:memset
  • 内存数据打印函数:mem_dump和栈数据打印函数:stack_dump
  • mem_dump可以放到os中任意位置,打印指定地址处的数值。
  1. #include "serial.h"   
  2. #include "s3c2440.h"   
  3.       
  4. void xtos(unsigned long n){  
  5.     unsigned long i;  
  6.     if((i=n/16)!=0)  
  7.         xtos(i);  
  8.     if(n%16 > 9)  
  9.         putc(n%16 - 10 +'A');  
  10.     else  
  11.         putc(n%16+'0');  
  12. }  
  13.   
  14. void dtos(unsigned long n){  
  15.     unsigned long i;  
  16.     if((i=n/10)!=0)  
  17.         xtos(i);  
  18.     putc(n%10+'0');  
  19. }  
  20.       
  21. void memset(char * dest, long len, int value){  
  22.     if(dest == NULL || len <= 0)  
  23.         return;  
  24.     while(len--)  
  25.         *dest++ = value;  
  26.     return ;  
  27. }  
  28.       
  29. // not safe copy    
  30. char * memcpy(char * dest, const char * src, long len){  
  31.     char * temp = dest;  
  32.     if(dest == NULL || src == NULL || len <= 0)  
  33.         return NULL;  
  34.       
  35.     while((dest - temp) != len)  
  36.         *dest++ = *src++;  
  37.     return temp;  
  38. }  
  39.   
  40. void mem_dump(const unsigned long * src, long len){  
  41.     const unsigned long * temp = src;  
  42.     if(src == NULL || len <= 0)  
  43.         return;  
  44.     while(src-temp != len){  
  45.         printk("\r\n 0x");  
  46.         xtos(*src++);  
  47.         if((src-temp)%5 == 0)  
  48.             printk("\r\n");  
  49.     }  
  50.     printk("\r\n");  
  51. }  
  52.   
  53.   
  54. void stack_dump(unsigned long * sp){  
  55.     printk("\r\n CPSR:0x");  
  56.     xtos(*sp++);  
  57.     printk("\r\n   R0:0x");  
  58.     xtos(*sp++);  
  59.     printk("\r\n   R1:0x");  
  60.     xtos(*sp++);  
  61.     printk("\r\n   R2:0x");  
  62.     xtos(*sp++);  
  63.     printk("\r\n   R3:0x");  
  64.     xtos(*sp++);  
  65.     printk("\r\n   R4:0x");  
  66.     xtos(*sp++);  
  67.     printk("\r\n   R5:0x");  
  68.     xtos(*sp++);  
  69.     printk("\r\n   R6:0x");  
  70.     xtos(*sp++);  
  71.     printk("\r\n   R7:0x");  
  72.     xtos(*sp++);  
  73.     printk("\r\n   R8:0x");  
  74.     xtos(*sp++);  
  75.     printk("\r\n   R9:0x");  
  76.     xtos(*sp++);  
  77.     printk("\r\n  R10:0x");  
  78.     xtos(*sp++);  
  79.     printk("\r\n  R11:0x");  
  80.     xtos(*sp++);  
  81.     printk("\r\n  R12:0x");  
  82.     xtos(*sp++);  
  83.     printk("\r\n   SP:0x");  
  84.     xtos(*sp++);  
  85.     printk("\r\n   LR:0x");  
  86.     xtos(*sp++);  
  87.     printk("\r\n   PC:0x");  
  88.     xtos(*sp++);  
  89. }  


主要就是上述的改变,最新源码,请到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更新/

linux
相关资讯       miniOS  miniOS下载 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款