µ±Ç°Î»ÖãºLinux½Ì³Ì - Linux - ÕâÊÇһƪ±È½ÏÏ꾡µÄÄں˱àÒë˵Ã÷!!!!

ÕâÊÇһƪ±È½ÏÏ꾡µÄÄں˱àÒë˵Ã÷!!!!



         Linux Äں˱àÒë˵Ã÷
    1.LinuxÄÚºËÔ´Âë½á¹¹£º
    ÄÚºËÔ´ÂëÖÐÖ÷Òª°üº¬ÒÔÏÂ×ÓĿ¼£º
    arch £º°üº¬ÁËÓëÌåϵ½á¹¹Ïà¹ØµÄ´úÂë
    ¶ÔÓ¦ÓÚÿһ¸öÖ§³ÖµÄÌåϵ½á¹¹£¬ÓÐÒ»¸öÏàÓ¦µÄ×ÓĿ¼Èçi386¡¢arm¡¢alphaµÈ¡£
    Æäÿ¸öÌåϵ½á¹¹×ÓĿ¼Ï°üº¬¼¸¸öÖ÷ÒªµÄ×ÓĿ¼£º
    kernel £º°üº¬ÓëÌåϵ½á¹¹Ïà¹ØµÄÄں˴úÂë
    mm £º °üº¬ÓëÌåϵ½á¹¹Ïà¹ØµÄÄÚ´æ¹ÜÀí´úÂë
    lib £º °üº¬ÓëÌåϵ½á¹¹Ïà¹ØµÄ¿â´úÂë
    documentation£º°üº¬Äں˵ÄÎĵµ
    drivers £º°üº¬É豸Çý¶¯´úÂ롣ÿÀàÉ豸ÓÐÏàÓ¦µÄ×ÓĿ¼£¬Èçchar ¡¢block¡¢netµÈ
    fs £º °üº¬ÎļþϵͳµÄ´úÂ롣ÿ¸öÖ§³ÖµÄÎļþϵͳÓÐÏàÓ¦µÄ×ÓĿ¼£¬Èç ext2¡¢procµÈ
    include £ºÄÚºËÍ·Îļþ£¬¶ÔÿһÖÖÌåϵ½á¹¹£¬·Ö±ðÓÐÏàÓ¦µÄ×ÓĿ¼¡£
    init £º °üº¬Äں˳õʼ»¯´úÂë
    lib £º °üº¬Äں˵Ŀâ´úÂë
    mm £º°üº¬ÄÚ´æ¹ÜÀí´úÂë
    kernel £º°üº¬Äں˹ÜÀí´úÂë
    net £º°üº¬ÍøÂ粿·ÖµÄ´úÂë

    2.ϵͳÒýµ¼µÄ¹ý³Ì
    ÔÚpc»úÉÏϵͳÆô¶¯¹ý³Ì£º
    ϵͳ¼ÓµçÒÔºóbois¶ÔϵͳÍê³É¼à²âÉèÖú󽫿ØÖÆȨ½»¸øÓ²ÅÌÉÏMBRÖÐµÄ BootLoaderÔÚÕâÀï¼´ÊÇlilo»ògrubµÈ¡£
    BootLoader ½«²Ù×÷ϵͳ´úÂëµ÷ÈëÄڴ棬Ȼºó½«¿ØÖÆȨ½»¸øarch/i386/bootÖеÄSetup.SÕâ¶Î³ÌÐò¡£
    Setup.S Õâ¶Î³ÌÐòÔÚ386ʵģʽ϶Ôϵͳ½øÐлù±¾µÄ¼ì²âºÍÉèÖúóתÈë±£»¤Ä£Ê½°Ñ¿ØÖÆȨ½»¸øHead.S
    Head.S ½¨Á¢ÄÚ´æ¹ÜÀíºÍÖжϹÜÀíµÄ¿ò¼Üºóµ÷ÓÃinit/main.cÖеÄstart_kernel£¨£©º¯ÊýÔÚstart_kernelÖ´ÐÐÍê³ÉºóÓû§¾Í¿ÉÒԵǼºÍʹÓÃlinuxÁË¡£Start_kernel()º¯ÊýÔÚinit/main.c Öж¨Òå¡£
    Start_kernelµÄÁ÷³ÌÖеÄÖ÷Òª²½Ö裺
    setup_arch(&command_line); ÓÃÓںʹ¦ÀíÆ÷¡¢ÄÚ´æµÈ×î»ù±¾µÄÓ²¼þÏà¹Ø²¿·ÖµÄ³õʼ»¯¡£ ÔÚ arch/i386/kernel/setup.c Öж¨Ò壻
    parse_options(command_line); °ÑÆô¶¯Ê±µÃµ½µÄ²ÎÊý´ÓÃüÁîÐеÄ×Ö·û´®ÖзÖÀë³öÀ´²¢¸³¸øÏàÓ¦µÄ±äÁ¿¡£ÔÚ init/main.c Öж¨Ò壻
    trap_init(); ¶ÔÖжÏÏòÁ¿±í½øÐгõʼ»¯¡£ÔÚ arch/i386/kernel/trap.c Öж¨Ò壻
    init_IRQ(); ÓëÖжÏÓйصijõʼ»¯£¬ ÔÚ arch/i386/kernel/i8259.c Öж¨Ò壻
    sched_init(); ½ø³Ìµ÷¶È³õʼ»¯¡£ ÔÚ kernel/sched.c Öж¨Ò壻
    softirq_init(); ÔÚ kernel/softirq.c Öж¨Ò壻
    time_init(); ʱ¼ä²¿·Ö³õʼ»¯¡£ ÔÚ arch/i386/kernel/time.c Öж¨Ò壻
    console_init(); ¶ÔÖն˳õʼ»¯¡£ ÔÚ drivers/char/tty_io.c Öж¨Ò壻
    buffer_init(mempages); ¶ÔÓÃÓÚָʾ¿é»º´æµÄbuff free list ³õʼ»¯¡£ ÔÚfs/buffer.c Öж¨Ò壻
    mem_init(); ÄÚ´æ¹ÜÀí³õʼ»¯¡£ ÔÚ arch/i386/mm/init.cÖж¨Ò壻
    rest_init(); ´Ëº¯ÊýÖе÷ÓÃ
    kernel_thread(init,NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL)º¯Êýʱ»áµ÷ÓÃinit/main.cÖеÄinit()º¯Êý ÔÚinit()º¯ÊýÖн«»á½¨Á¢dbflush¡¢kswapdÁ½¸öеÄÄÚºËÏ̡߳£³õʼ»¯tty1É豸¡£Ñ°ÕÒ/etc/init»ò/sbin/init »ò/bin/initÀ´½¨Á¢Ò»¸öinit½ø³Ì¡£
    Init½ø³Ì¸ù¾Ý/etc/inittabÎļþ½øÐÐÎļþϵͳ¼ì²é¡¢Æô¶¯ÏµÍ³ÊØ»¤½ø³ÌΪÁª»úÖն˽¨Á¢getty½ø³Ì£¬Ö´ÐÐ/etc/rcϵÄÃüÁîÎļþ¡£
    ´Ëºógetty»áÔÚÖÕ¶ËÉÏÏÔʾloginÌáʾ·û£¬ÒԵȴýÓû§µÇ¼¡£

    3.ʹÓÃmake½¨Á¢ÄÚºË
    1.ʹÓÃmake menuconfigÃüÁ
    ʹÓÃÒÔϱàÒëÑ¡Ïî:
    Processor type and features --->
    (Pentium-Pro/Celeron/Pentium-II) Processor family
    (3GB) Maximum Virtual Memory
    General setup --->
    (ELF) Kernel core (/proc/kcore) format
    [*] Kernel support for ELF binaries
    File systems --->
    [*] /proc file system support
    [*] Second extended fs support
    ATA/IDE/MFM/RLL support --->
    [*] ATA/IDE/MFM/RLL support
    [*] Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
    [*] Include IDE/ATA-2 DISK support
    Character devices --->
    [*] Virtual terminal
    Console drivers --->
    [*] VGA text console

    Éú³ÉÄÚºËbzImage ´óСΪ 309892 byte;
    ´ËÄں˿ÉÔÚpcÉϳɹ¦Òýµ¼ÏµÍ³

    ´ËÃüÁîÉú³ÉÒ»¸öÎļþ .config ÆäÖиù¾ÝÄãÔÚmenuconfigÖеÄÑ¡Ôñ¶¨ÒåÁËÏàÓ¦µÄ±äÁ¿¡£ÔÚMakefileÎļþÖн«»á°üº¬Õâ¸öÎļþ¡£

    2.ʹÓÃmake depÃüÁî ½¨Á¢ÒÀÀµ¹Øϵ¡£

    3.ʹÓÃmake bzImage ÃüÁÁ¢Äںˡ£
    ÈçÉèÖÃÕýÈ·½«ÔÚarch/i386/boot/Ŀ¼ÏÂÉú³ÉÄÚºËbzImageÎļþ
    4.make bzImageµÄÁ÷³Ì¼òµ¥ËµÃ÷
    µ±ÎÒÃÇʹÓÃmakeÃüÁîʱ£¬make³ÌÐò½«Ê×ÏÈÕÒµ½µ±Ç°Ä¿Â¼ÏµÄMakefileÎļþ¡£¸ù¾ÝMakefileÎļþµÄÓï·¨½øÐд¦Àí¡£
    ÔÚÖ÷MakefileÎļþÖаüº¬ÁËarch/i386/MakefileÎÒÃÇmakeµÄÄ¿±êbzImage¼´ÔÚ¸ÃÎļþÖж¨£º
    bzImage: vmlinux
    @$(MAKEBOOT) bzImage #´ËÃüÁ½âÊÍΪ£ºmake -C arch/i386/boot bzImage
    ÏÖÔÚmakeÐèÒªÏÈÈ¥½¨Á¢Ä¿±ê vmlinux È»ºóÔÙÖ´ÐÐ arch/i386/boot/ Ŀ¼Ï嵀 make bzImae¡£ÎÒÃÇÏÖÔÚ¼ÙÉèvmlinuxÄ¿±êÒÑÉú³É£¬Ôò arch/i386/bootĿ¼ÏµÄmake³ÌÐò½«Ö´ÐÐÈçϲÙ×÷£º
    tools/build -b bbootsect bsetup compressed/bvmlinux.out ./ bzImage
    ¼´½«vmlinux Óà tools/build¹¤¾ßѹËõ³ÉÄ¿±êÎļþ bzImage£¨Ôڴ˹ý³ÌÖУ¬»¹»á¹¹½¨build ³ÌÐò£¬½«vmlinuxת»»³Ébvmlinux.outµÈ£¬¿É²Î¿¼tools ºÍ compressedĿ¼ÏµÄMakefileÎļþ£©¡£

    Éú³ÉvmlinuxÄ¿±ê£º
    ÔÚÖ÷Ŀ¼ÏÂMakefileÎļþÖÐvmlinuxÉú³É¹æÔòÈçÏ£º
    vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs
    $(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \
    --start-group \
    $(CORE_FILES) \
    $(DRIVERS) \
    $(NETWORKS) \
    $(LIBS) \
    --end-group \
    -o vmlinux #Éú³Évmlinux
    $(NM) vmlinux |grep ¨Cv \(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\) | sort > System.map #´ËÃüÁî¸ù¾ÝvmlinuxÉú³ÉSystem.mapÎļþ

    ÔÚµ±Ç°ÉèÖÃÏ´ËldÁ¬½ÓÃüÁî±»½âÊÍΪ£º

    ld -m elf_i386 -T /home/arm/linux/arch/i386/vmlinux.lds -e stext arch/i386/kernel/head.o arch/i386/kernel/init_task.o init/main.o init/version.o --start-group arch/i386/kernel/kernel.o arch/i386/mm/mm.o kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o drivers/char/char.o drivers/block/block.o drivers/misc/misc.o drivers/net/net.o drivers/media/media.o drivers/ide/idedriver.o drivers/video/video.o net/network.o /home/arm/linux/arch/i386/lib/lib.a /home/arm/linux/lib/lib.a /home/arm/linux/arch/i386/lib/lib.a --end-group -o vmlinux

    ¼´Á¬½Ó³ÌÐòld ½«¸÷¸ö.oÎļþÁ¬½Ó³ÉÄ¿±êÎļþ vmlinux ¡£
    ´ËÃüÁîÖÐÓõ½µÄ¸÷¸ö .oÎļþmake³ÌÐò»á¸ù¾ÝMakefileÎļþµÄ¹æÔòÈ¥×Ô¶¯Éú³É£¬ÏÂÃæ¼òµ¥½éÉÜÒ»ÏÂÓÉipcĿ¼Éú³Éipc.o¹ý³Ì£º
    ÆäipcĿ¼ÏÂMakefileÎļþÄÚÈÝÈçÏ£º
    O_TARGET := ipc.o
    obj-y := util.o
    obj-$(CONFIG_SYSVIPC) += msg.o sem.o shm.o
    include $(TOPDIR)/Rules.make #°üº¬µÄRules.makeÎļþÖÐΪͨÓõĹæÔò£»

    ÈçÎÒÃÇÔÚmake menuconfigʱѡÖÐÁËSYSVIPCÑ¡ÏÔò .configÎļþÖн«¶¨Òå±äÁ¿ CONFIG_SYSVIPC=y; Ôòobj£­y ¾ÍµÈÓÚutil.o msg.o sem.o shm.o£»¸ù¾ÝRules.make½«Ëĸö.cÎļþ±àÒëΪ .oÎļþ¡£ÔÙ½«Ëĸö.oÎļþÁ¬½Ó³É ipc.oÎļþ¡£ÔÚÎÒÃǵĵ±Ç°ÉèÖÃÖÐûÓÐÑ¡ÔñSYSVIPC;½«Ö»Ê¹ÓÃutil.oÒ»¸öÎļþÉú³ÉÄ¿±ê ipc.o £»¶øutil.oÓÉutil.cÉú³É¡£

    µ±ËùÓÐÐèÒªµÄ.oÎļþÉú³ÉÒÔºó£¬ÓÉld½«ÆäÁ¬½ÓÉú³ÉvmlinuxÎļþ£¬ÔÙ½«ÆäѹËõ³ÉÎÒÃÇËùÐèÒªµÄÄÚºËÎļþ bzImage¡£Make³ÌÐò¾ÍÖ´ÐÐÍêÁË¡£


    2002Äê9ÔÂ13ÈÕ
    ·¢²¼ÈË:srh À´×Ô: