LinuxÄں˳£ÓÃÊý¾Ý½á¹¹ºÍ²Ù×÷
1. Ç°ÑÔ
±¾ÎĽéÉÜlinuxÄÚºËÖÐһЩ³£ÓõÄÊý¾Ý½á¹¹ºÍ²Ù×÷¡£
2. Ë«ÏòÁ´±í(list)
linuxÄÚºËÖеÄË«ÏòÁ´±íͨ¹ý½á¹¹ struct list_headÀ´½«¸÷¸ö½ÚµãÁ¬½ÓÆðÀ´£¬´Ë½á¹¹»á×÷ΪÁ´±íÔªËؽṹÖеÄÒ»¸ö²ÎÊý£º
struct list_head {
struct list_head *next, *prev;
};
Á´±íÍ·µÄ³õʼ»¯£¬×¢Ò⣬½á¹¹ÖеÄÖ¸ÕëΪNULL²¢²»Êdzõʼ»¯£¬¶øÊÇÖ¸Ïò×ÔÉí²ÅÊdzõʼ»¯£¬Èç¹ûÖ»ÊÇ°´ÆÕͨÇé¿öϵÄÖÃΪNULL£¬¶ø²»ÊÇÖ¸Ïò×ÔÉí£¬ÏµÍ³»á±ÀÀ££¬ÕâÊÇÒ»¸öÈÝÒ×·¸µÄ´íÎó£º
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
×î³£ÓõÄÁ´±í²Ù×÷£º
²åÈëµ½Á´±íÍ·:
void list_add(struct list_head *new, struct list_head *head);
²åÈëµ½Á´±íβ:
void list_add_tail(struct list_head *new, struct list_head *head);
ɾ³ýÁ´±í½Úµã:
void list_del(struct list_head *entry);
½«½ÚµãÒƶ¯µ½ÁíÒ»Á´±í:
void list_move(struct list_head *list, struct list_head *head);
½«½ÚµãÒƶ¯µ½Á´±íβ:
void list_move_tail(struct list_head *list,struct list_head *head);
ÅжÏÁ´±íÊÇ·ñΪ¿Õ£¬·µ»Ø1Ϊ¿Õ£¬0·Ç¿Õ
int list_empty(struct list_head *head);
°ÑÁ½¸öÁ´±íÆ´½ÓÆðÀ´£º
void list_splice(struct list_head *list, struct list_head *head)£»
È¡µÃ½ÚµãÖ¸Õ룺
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
±éÀúÁ´±íÖÐÿ¸ö½Úµã£º
#define list_for_each(pos, head) \
for (pos = (head)->next, prefetch(pos->next); pos != (head); \
pos = pos->next, prefetch(pos->next))
ÄæÏòÑ»·Á´±íÖÐÿ¸ö½Úµã£º
#define list_for_each_prev(pos, head) \
for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \
pos = pos->prev, prefetch(pos->prev))
¾ÙÀý£º
LISH_HEAD(mylist);
&n
Ïà¹ØÎĵµ£º
Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâƪ·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´ËתÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨Õâƪ²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......
1. ÏÈ´ÓÍøÉÏÏÂÔØjdk(jdk-1_5_0_02-linux-i586.rpm) £¬ÍƼöSUNµÄ¹Ù·½ÍøÕ¾www.sun.com£¬ÏÂÔغó·ÅÔÚ/homeĿ¼ÖУ¬µ±È»ÆäËüµØ·½Ò²ÐС£
½øÈ밲װĿ¼
#cd /home
#cp jdk-1_5_0_02-linux-i586.rpm /usr/local
#cd /usr/local
¸øËùÓÐÓû§Ìí¼Ó¿ÉÖ´ÐеÄȨÏÞ
#chmod +x jdk-1_5_0_02-linux-i586.rpm.bin
#./jdk-1_5_0_02-lin ......
ÎÒÃÇÖªµÀĬÈÏÍâÉèI/O×ÊÔ´ÊDz»ÔÚLinuxÄں˿ռäÖеģ¨Èçsram»òÓ²¼þ½Ó¿Ú¼Ä´æÆ÷µÈ£©£¬ÈôÐèÒª·ÃÎʸÃÍâÉèI/O×ÊÔ´£¬±ØÐëÏȽ«ÆäµØÖ·Ó³Éäµ½Äں˿ռäÖÐÀ´£¬È»ºó²ÅÄÜÔÚÄں˿ռäÖзÃÎÊËü¡£
LinuxÄں˷ÃÎÊÍâÉèI/OÄÚ´æ×ÊÔ´µÄ·½Ê½ÓÐÁ½ÖÖ£º¶¯Ì¬Ó³Éä(ioremap)ºÍ¾²Ì¬Ó³Éä(map_desc)¡£
Ò»¡¢¶¯Ì¬Ó³Éä(ioremap)·½Ê½
¶ ......
man -k [keyword ] ÔÚwhatis Êý¾Ý¿âÖвéÕҹؼü×Ö£»
•man -f [keyword ] ͬÉÏ£¬µ«keyword Ϊһ¸öÕû×Ö(whole word)
•man -a [keyword ] ͨ³£man »áÏÔʾµÚÒ»¸öÕÒµ½µÄkeywordµÄman page£¬µ« ......
gccµÄ±àÒë¹ý³Ì·ÖΪËIJ½£¬·Ö±ðΪ£º
(1)Ô¤±àÒë (Pre-Processing)
(2)±àÒë (Compiling)
(3)»ã±à (Assembling)
(4)Á´½Ó (Linking)
ÒÔhello.cΪÀý˵Ã÷£º
#include<stdio.h>
int main(void)
{
printf("Hello World!");
return 0;
}
(1)Ô¤±àÒë½×¶Î (Pre-Processing)
&nbs ......