LinuxÉ豸Çý¶¯±à³ÌÖ®ÄÚ´æÓëI/O²Ù×÷£¨×ª£©
תÖÁ£º http://dev.yesky.com/412/2639912.shtml
¶ÔÓÚÌṩÁËMMU£¨´æ´¢¹ÜÀíÆ÷£¬¸¨Öú²Ù×÷ϵͳ½øÐÐÄÚ´æ¹ÜÀí£¬ÌṩÐéʵµØַת»»µÈÓ²¼þÖ§³Ö£©µÄ´¦ÀíÆ÷¶øÑÔ£¬LinuxÌṩÁ˸´ÔӵĴ洢¹ÜÀíϵͳ£¬Ê¹µÃ½ø³ÌËùÄÜ·ÃÎʵÄÄÚ´æ´ïµ½4GB¡£
¡¡¡¡½ø³ÌµÄ4GBÄÚ´æ¿Õ¼ä±»ÈËΪµÄ·ÖΪÁ½¸ö²¿·Ö--Óû§¿Õ¼äÓëÄں˿ռ䡣Óû§¿Õ¼äµØÖ··Ö²¼´Ó0µ½3GB(PAGE_OFFSET£¬ÔÚ0x86ÖÐËüµÈÓÚ0xC0000000)£¬3GBµ½4GBΪÄں˿ռ䣬ÈçÏÂͼ£º
¡¡¡¡Äں˿ռäÖУ¬´Ó3Gµ½vmalloc_startÕâ¶ÎµØÖ·ÊÇÎïÀíÄÚ´æÓ³ÉäÇøÓò£¨¸ÃÇøÓòÖаüº¬ÁËÄں˾µÏñ¡¢ÎïÀíÒ³¿ò±ímem_mapµÈµÈ£©£¬±ÈÈçÎÒÃÇʹÓõÄVMwareÐéÄâϵͳÄÚ´æÊÇ160M£¬ÄÇô3G¡«3G+160MÕâƬÄÚ´æ¾ÍÓ¦¸ÃÓ³ÉäÎïÀíÄÚ´æ¡£ÔÚÎïÀíÄÚ´æÓ³ÉäÇøÖ®ºó£¬¾ÍÊÇvmallocÇøÓò¡£¶ÔÓÚ160MµÄϵͳ¶øÑÔ£¬vmalloc_startλÖÃÓ¦ÔÚ3G+160M¸½½ü£¨ÔÚÎïÀíÄÚ´æÓ³ÉäÇøÓëvmalloc_startÆڼ仹´æÔÚÒ»¸ö8MµÄgapÀ´·ÀÖ¹Ô¾½ç£©£¬vmalloc_endµÄλÖýӽü4G(×îºóλÖÃϵͳ»á±£ÁôһƬ128k´óСµÄÇøÓòÓÃÓÚרÓÃÒ³ÃæÓ³Éä)£¬ÈçÏÂͼ£º
¡¡¡¡kmallocºÍget_free_pageÉêÇëµÄÄÚ´æλÓÚÎïÀíÄÚ´æÓ³ÉäÇøÓò£¬¶øÇÒÔÚÎïÀíÉÏÒ²ÊÇÁ¬ÐøµÄ£¬ËüÃÇÓëÕæʵµÄÎïÀíµØÖ·Ö»ÓÐÒ»¸ö¹Ì¶¨µÄÆ«ÒÆ£¬Òò´Ë´æÔڽϼòµ¥µÄת»»¹Øϵ£¬virt_to_phys()¿ÉÒÔʵÏÖÄÚºËÐéÄâµØַת»¯ÎªÎïÀíµØÖ·£º
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
extern inline unsigned long virt_to_phys(volatile void * address)
{
¡¡return __pa(address);
}
¡¡¡¡ÉÏÃæת»»¹ý³ÌÊǽ«ÐéÄâµØÖ·¼õÈ¥3G£¨PAGE_OFFSET=0XC000000£©¡£
¡¡¡¡ÓëÖ®¶ÔÓ¦µÄº¯ÊýΪphys_to_virt()£¬½«ÄÚºËÎïÀíµØַת»¯ÎªÐéÄâµØÖ·£º
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
extern inline void * phys_to_virt(unsigned long address)
{
¡¡return __va(address);
}
¡¡¡¡virt_to_phys()ºÍphys_to_virt()¶¼¶¨ÒåÔÚinclude\asm-i386\io.hÖС£
¡¡¡¡¶øvmallocÉêÇëµÄÄÚ´æÔòλÓÚvmalloc_start¡«vmalloc_endÖ®¼ä£¬ÓëÎïÀíµØַûÓмòµ¥µÄת»»¹Øϵ£¬ËäÈ»ÔÚÂß¼ÉÏËüÃÇÒ²ÊÇÁ¬ÐøµÄ£¬µ«ÊÇÔÚÎïÀíÉÏËüÃDz»ÒªÇóÁ¬Ðø¡£
¡¡¡¡ÎÒÃÇÓÃÏÂÃæµÄ³ÌÐòÀ´ÑÝʾkmalloc¡¢get_free_pageºÍvmallocµÄÇø±ð£º
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
MODULE_LICENSE("GPL");
unsigned char *pagemem;
unsigned char *kmallocmem;
unsigned char *vmallocmem;
int __init mem_module_init(void)
{
¡¡//×îºÃÿ´ÎÄÚ´æÉêÇ붼¼ì²éÉêÇ
Ïà¹ØÎĵµ£º
Ò». Æô¶¯,¹Ø»ú,µÇÈë,µÇ³öÏà¹ØÃüÁî
<login> 怬
<logout> µÇ³ö
<exit> µÇ³ö
<shutdown> ֹͣϵͳ
<halt> ֹͣϵͳ
<reboot> ÖØÆô¶¯
<poweroff> ÇжϵçÔ´
<sync> °ÑÄÚ´æÀïµÄÄÚÈÝдÈë´ÅÅÌ
<lilo> °²×°liloÆô¶¯¹ÜÀí³ÌÐò
<grub> °²×°liloÆô¶¯¹ÜÀí³ÌÐò
......
1¡¢¼òµ¥µÄ²éÕÒ²¢Ì滻ΪеÄ×Ö·û´®
:%s/²éÕÒµÄ×Ö·û´®/еÄ×Ö·û´®/g
eg£º²éÕÒ“liliang” ²¢½«ÆäÌ滻Ϊ“liangli”
:%s/liliang/liangli/g
ÆäÖГ\”ΪתÒå·û
eg£º²éÕÒ“li/liang” ²¢½«ÆäÌ滻Ϊ“liliang”(¼´°Ñ±»²éÕÒ×Ö·û´®ÖеÄб¸ÜÈ¥µô)
:%s/li\/liang/liliang ......
LinuxÄÚºË2.4°æÖÐÈ¥µôÁËÀÏ°æ±¾ÄÚºËÖеľ²Ì¬¶¨Ê±Æ÷»úÖÆ£¬¶øÖ»Áô϶¯Ì¬¶¨Ê±Æ÷¡£ÏàÓ¦µØÔÚtimer_bh()º¯ÊýÖÐÒ²²»ÔÙͨ¹ýrun_old_timers()º¯ÊýÀ´ÔËÐÐÀÏʽµÄ¾²Ì¬¶¨Ê±Æ÷¡£¶¯Ì¬¶¨Ê±Æ÷Ó뾲̬¶¨Ê±Æ÷Õâ¶þ¸ö¸ÅÄîÊÇÏà¶ÔÓÚLinuxÄں˶¨Ê±Æ÷»úÖƵĿÉÀ©Õ¹¹¦ÄܶøÑԵģ¬¶¯Ì¬¶¨Ê±Æ÷ÊÇÖ¸Äں˵Ķ¨Ê±Æ÷¶ÓÁÐÊÇ¿ÉÒÔ¶¯Ì¬±ä»¯µÄ£¬È»¶ø¾Í¶¨Ê±Æ÷±¾Éí¶ ......