博文

回顾2010

这一年就要过完了,照例要总结一下,这一年都做了一些什么。明年的这个时候应该都拿到offer了。等待毕业和入职了。每想到此,既兴奋又紧张。明年的一年又是紧张的一年,不知道系统能否顺利做完。 这一年最大的收获,应该是入了Linux的门,并且看了不少关于编译链接,计算机系统结构和操作系统方面的书。感觉羽翼一点点丰满,不过,当然距离大牛还有很长的路要走。 上半年的时候,基本上把精力都放在了Linux驱动方面了。看过了宋宝华的Linux驱动开发的书和Linux Device Driver,除此之外,还看了unstanding linux kenrel.和Linux kernel development. 下半年把精力都放在了项目上,移植了yaffs到xenarm上,并且将原来支持的128MB支持到了768MB,当然最大能够达到950MB。将xenheap的大小扩大到了64MB。这一块,我感觉,还是蛮有成就感。内存太小,肯定干不成事情。跑一个android,最少需要70MB以上的,原来的128MB一定是不够用的。特别是,当yaffs在xenarm里面跑成功以后,那种感觉是难以形容的。每看到自己写的代码,就像看到自己的孩子似的。现在的xenarm已经能够跑起来两个android了。不过缺点是,相关的设备虚拟化程度仍然不够。调度算法仍然不完整,调度两个android,明显bug太多,另外,由于设备虚拟化的问题,现在只能跑两个一模一样的系统。因为要公用nand嘛,nand里放的是root fs.在下半年,也看了一些书,这些书,增加了我的一些自信。《自己动手写OS-第二版》《程序员自我修养--链接装载与库》《代码揭秘》《CODE》其中前两本,给我的感觉很棒。除此之外,还看了PHP和SHELL方面的两本书,同时还看了正则表达式方面的书。当然,看过之后,没有怎么用,都忘记了,不过重新拾起来应该比较快。 去年的这个时候,我按照月份,把每个月所做的事情都列了一下。今年,想到此,便想到了在实验室每个月7号写的QA,我想也许是因为,我对QA已经恐惧了,所以,不写的那么具体了。总结一下,以告慰自己,又过了一年,没有虚度年华。

xenarm代码片段注释

ENTRY(ret_to_user)       test_all_events :         disable_irq     r1                      @ ensure IRQs are disabled               bl      get_irq_stat                    @ get softirq pending status         ldr     r1, [r0, #OFFSET_SOFTIRQ_PENDING]@指针操作,返回值放到r0中         ldr     r0, = 0xffff           tst     r1, r0                          @ bit mask check is needed!!!         beq     test_guest_events         enable_irq      r1                      @ sti       @ r1.. ok??????         bl      do_softirq         b       test_all_events /*  disable_irq r1         .macro  disable_irq, temp         msr     cpsr_c, #PSR_STATUS_I | PSR_MODE_SVC //只更改控制位0~8,禁止中断标志位         .endm   */ ENTRY(test_guest_events)         vcpu    r10                           @从在xenheap中堆栈页的最下部分得到vcpu结构         ldr     r11, [r10, #OFFSET_VCPU_INFO] @获得vcpu_info         ldrb    r9, [r11, #OFFSET_EVTCHN_UPCALL_MASK]     @r9为evtchn_upcall_mask         tst     r9, # 0xFF                                  @如果r9为非零则,bne...

like-linux系统链表原理简单分析

  1 /*   2  like-linux系统下链表结构分析   3  *在like-linux系统中,链表的可移植性比较好,并不像在大学学到的链表结构那样的死板。其原理在很多linux的讲解中都有描述。   4  *原理部分可以看一下李先静老师写的《系统程序员成长之路》一书。   5  *本文根据xenarm中的链表来具体得理一下在like-linux系统中的链表原理。   6     7  *因为时间有限,只是把相关宏定义简单扩展,并把代码做了注释和筛捡。没有成文,望各位看官见谅   8   */   9  10  11 /*  12  *定义了一个相关结构和spinlock  13   */  14 spinlock_t consistent_lock;  15 struct  arm_vm_region {  16          struct  list_head        vm_list;  17          unsigned   long            vm_start;  18          unsigned   long            vm_end;  19    ...

Android on OKL4 Tutorials

图片
可能在博客里面xml内容显示不正常,移步docs.google,查看 http://docs.google.com/View?id=df6sncnm_899k8tqgng5 Android on OKL4 OKL4 3.0 was originally ported to run on the HTC Dream (found here ). A student, Michael Hills, developed a rudimentary Android port that removes Linux and runs natively on OKL4 3.0 for his undergraduate thesis. The supplied code demonstrates the Lunar Lander application found in the Android SDK running on the Dalvik VM on OKL4. Getting the source 1. First create a base directory to contain all of the source of this project. 2.Then download the Android repo tool and place it into a directory that is in your environment's PATH. 3.Then inside the project base directory, create a directory for the Android source and initialize the repo.      You may need to prepare your build environment to compile Android as specified at http://source.android.com/source/index.html . curl http://android.git.kernel.org/repo >~/bin/repo chmod a+x ~/bin/repo mkdir android-1.5r2 cd android-1.5r2 repo...

xen-arm 算法技巧赏析(0)

1 /* 2 原以为,在平时的工程实现中,算法几乎是用不上的。但在看内核的过程中,发现算法还是比较重要的。 3 尤其是一些细微而又精巧的程序设计技巧。这些技巧是需要掌握的。 4 5 下面的这段程序摘自:xen-arm中,的内存初始化部分。 6 功能:从first_page页开始的nr_pages页在页位图中,表示为空闲页。 7 页位图,位于_end之后。_end标识xen-arm kernel的结束地址。 8 9 */ 10 static void map_free( unsigned long first_page, unsigned long nr_pages) 11 { 12 unsigned long start_off, end_off, curr_idx, end_idx; 13 14 #ifndef NDEBUG 15 unsigned long i; 16 /* Check that the block isn't already freed. */ 17 for ( i = 0 ; i < nr_pages; i++ ) 18 ASSERT(allocated_in_map(first_page + i)); //ASSERT:如果条件不成立,就报错 19 #endif 20 21 curr_idx  = (first_page-min_page) / PAGES_PER_MAPWORD; 22 start_off = (first_page-min_page) & (PAGES_PER_MAPWORD- 1 ); 23 end_idx   = (first_page-min_page + nr_pages) / PAGES_PER_MAPWORD; 24 end_off   = (first_page-min_page + nr_pages) & (PAGES_PER_MAPWORD- 1 ); 25 26 if ( curr_idx == end_idx ) 27 { 28 //这个算法还是比较巧妙的 29 //1<<start_off - 1 从start_off位开始,全部为1 30 /* 31 -(1<...

Printf从函数库到OS跟踪流程

首先需要弄清楚:API-用户编程借口与 系统调用的区别,这里有一篇非常好的文章: http://www.tek-life.org/2010/10/12/linux%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%EF%BC%BBz%EF%BC%BD/ 另外,printf具体内部原理请见: http://www.tek-life.org/2010/10/12/printf%E5%92%8C%E6%A0%87%E5%87%86%E8%BE%93%E5%87%BA%EF%BC%BBz%EF%BC%BD/ 我仅仅是进行了code review arch/x86/boot/printf.c int printf(const char *fmt, ...) { char printf_buf[1024]; va_list args; int printed; va_start(args, fmt); printed = vsprintf(printf_buf, fmt, args); va_end(args); puts(printf_buf); return printed; } void __attribute__((section(".inittext"))) puts(const char *str) { int n = 0; while (*str) { putchar (*str++); n++; } } /* * These functions are in .inittext so they can be used to signal * error during initialization. */ void __attribute__((section(".inittext"))) putchar (int ch) { unsigned char c = ch; if (c == '\n') putchar('\r'); /* \n -> \r\n */ /* int $0x10 is known to have bugs involving touching registers it shouldn't. Be extra c...