Posts

Showing posts from February, 2012

Microkernel(relative to monolithic kernel)

Image
Microkernel (relative to   monolithic   kernel) Microkernel is the  near-minimum amount  of software that can  provide the mechanisms   needed  to  implement an operating system  (OS). From this sentence, we can get several points below: 1) Microkernel is very  small . 2) Microkernel contains some program such as  low-level address space management ,  thread management ,  scheduling ,  IPC(inter-process communication)  and so on which are all very  basic tools . 3) The  functionalities  mentioned above are all very  necessary  for a  OS kernel (here kernel  don't need to provide these features any more , maybe just some drivers, internet module or something else). So Microkernel OS is  much more portable  because of  its small size . 4) Here other  operating systems  are implemented on  user mode  above the microkernel. 5) From t...

Full stack and empty stack

Image
Full stack and empty stack Full stack: A full stack is where the stack pointer points to the last data item written Empty stack: Empty stack is where the stack pointer points to the first free slot. How to manage a stack:

Only 56 instructions in ARM Cortex-M0

16-Bit Thumb Instructions Supported on the Cortex-M0 Processor ADC      ADD        ADR     AND     ASR     B           BIC        BLX          BKPT     BX CMN     CMP        CPS      EOR     LDM     LDR     LDRH     LDRSH     LDRB     LDRSB LSL        LSR         MOV    MVN    MUL    NOP     ORR       POP          PUSH     REV REV16   REVSH    ROR     RSB      SBC     SEV      STM       STR          STRH      STRB SUB       SVC         SXTB   S...

Status flags

Status flags in ARM processor The most common status flags are:  V  (overflow),  N  (sign status),  Z  (zero or not),  C  (carry bit, remember it is not borrow bit of substraction). V  -  This flag is set when the sign of result is wrong . This methodology is called " twos complement " For addition, V is set if msb (s) is equal to msb (d) and msb (result) is not equal to msb (d), which means  the addition two positive numbers is negative, or the addition of two negative numbers is positive . For substraction, V is set if msb (s) is not equal to msb (d) and msb (result) is not equal to msb (d), which means  the result of one positive number substracting negative number is negative, or  the result of one negative number substracting positive number is positive . Anyway, because  the most significant bit represents the sign bit , so when we do some operation with  large number  which will  make...

TQ2440 linux 移植

这里使用的都是 天嵌公司提供的资源 来移植的。 内核编译: 首先编译系统内核,这个可以按照《 linux移植之step by step 》的 附录5 来一步步操作。当然我已经将配置好的config文件保存起来了,即 /opt/EmbedSky/linux-2.6.30.4/arch/arm/configs/s3c2410_defconfig 。(这里一定要注意一点,配置完内核后 要保存配置信息 ,同时还要保存为另一个配置文件名称 .config ,否则系统会按默认的配置进行内核编译。),执行 make 和 make zImage 来编译内核。 编译内核时,要使用root用户,否则会出现各种莫名其妙的错误。 根文件系统编译: 接着创建根 文件系统 ,首先创建 一系列目录以及目录中相关的文件 ,然后使用命令 mkyaffs2image 命令来 将整个文件夹制作成根文件系统镜像 。 以后, 每次编译完新的程序就可以放到该文件系统目录中,然后再编译整个目录,再下载到板子中 。 如果每次都将根文件系统下载到flash中,不但 损伤flash ,同时也会 浪费时间 (写入flash的时间要比写入SDRAM的时间要长)。所以最好可以把文件系统 直接下载到SDRAM 来进行 程序调试 。基本上有两种方法可以提供: 使用 u-boot 中的 tftp 指令来将内核或者根文件系统下载到SDRAM。 使用 openjtag ,用软件 openocd 来直接将内核和文件系统下载到指定位置。 用TFTP协议来下载文件(ubuntu10.10): 1, 首先下载tftp软件包 -  tftp (客户端),  tftpd (服务器),  xinetd (网络请求的守护进程, 当xinetd接到连接时,它能够确定连接所需的程序,启动相应的进程,并把socket交给它)。 sudo apt-get install xinetd tftpd tftp 2, 创建tftp配置文件 /etc/xinetd.d/tftp 。 sudo vi /etc/xinetd.d/tftp 配置如下: service tftp {       ...

How to compile drivers into linux kernel

The working principle of kernel compiling: There are files need to change in the relevant directory -  Kconfig  and  Makefile . All these configures and makefiles are based on the great program "make". When we enter "make menuconfig", the "make" program will build a visual configure interface according to Kconfig files existing in different directories. After finish configuring the system, "make" will produce a configure file ".config" which contains the information of your configure options. Then compile the system using "make", gcc will compile the system according to the Makefiles which will choose to compile drivers as kernel, or module, or not according to the configure file ".config". The format of Kconfig file: menu "Name of menu" config SYMBOL1                                   ...

The differences between array and pointer

Image
In fact, the name of array and pointer are totally different stuff.  The name of array represents a certain kind of data structure of array. For example, when you declare an array with " char amessage[]= "now is the time"  ". Then declare a pointer with " char *pmessage="now is the time" ". Then array amessage is built as a data structure which contains the whole copy of string "now is the time". However pointer pmessage just contains the address of the  string literal . So the size of amessage is 16, however the size of pmessage is only 4 . But why sometimes the name of array can be used as pointer? This is because of the compiler. When the compiler finds that the name of array appears in the right of a statement without index,  the compiler will make it act as pointer - something like &amessage .  But whatever  the name of array is not pointer after all, so it cannot appear in the left of statement . C...

Software Requirement Specification

Image
Software Requirement Specification What is SRS and its usages? SRS (Software Requirements Specification) is used to describe the behavior of a system. SRS should include  functional requirements  and  non-functional requirements . Funcational requirements tell you about  what the software is used for  and  how it interact with users . Non-functional requirements tells  how good the software should perform . Basically, it is some  constrains  imposed on the design and implementation  (Remember every system has constraints, otherwise you will be able to do anything you want, that is unreasonable. So when you try to do something in life, find the constraints. This is not just about software development, it is pratical for everything) . Take game development as an example. Functional requirement should think about  what kind game it is ,  how to play it ,  how the players operate the console ,  etc . And...

Programming tricks

Swap the contents of two registers. XOR R0, R1 XOR R1, R0 XOR R0, R1 Remember  "1" in result  means  differences , while  "0" means same . However when the number  apears in operation of XOR ,  "1" means reverse  and  "0" means keep . To judge if two numbers are equal, we can also use XOR. XOR R0, R1 If the result is 0, then R0 and R1 are equal. Otherwise they are not. Struct type allows the  specification of elements of a structure into a fixed number of bits . struct fivebits {     unsigned int flag : 1;  // act as switch, on (1) or off (0)     signed int num   : 4;  // number ranges from -8...7                             : 3;  // empty 3 bits used to align to 8bits, this is necessary for manipulation }