﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-Wu.Country@侠缘</title><link>http://www.cnblogs.com/WuCountry/</link><description>勤学似春起之苗，不见其增，日有所长；辍学如磨刀之石，不见其损，日所有亏!</description><language>zh-cn</language><lastBuildDate>Mon, 06 Jul 2009 14:58:02 GMT</lastBuildDate><pubDate>Mon, 06 Jul 2009 14:58:02 GMT</pubDate><ttl>60</ttl><item><title>[每日一点]msgsnd函数代码跟踪</title><link>http://www.cnblogs.com/WuCountry/archive/2009/06/18/1506202.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Thu, 18 Jun 2009 14:31:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/06/18/1506202.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1506202.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/06/18/1506202.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1506202.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1506202.html</trackback:ping><description><![CDATA[摘要: 今天有一同事问我，如果msgsnd函数的最后一个flag如果直接置0，调用该函数会是什么结果！我不太清楚是怎样的，还是直接看代码：msgsnd是一个系统调用，所以它在glibc中只是一个桩函数：\glibc\glibc-2.4.src\sysvipc\msgsnd.cintmsgsnd (msqid, msgp, msgsz, msgflg) int msqid; const void *msgp&nbsp;&nbsp;<a href='http://www.cnblogs.com/WuCountry/archive/2009/06/18/1506202.html'>阅读全文</a><img src ="http://www.cnblogs.com/WuCountry/aggbug/1506202.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/48008/" target="_blank">IBM发布全球首款开源智能编译器</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>Linux(OpenSuse11.2)下.Net应用程序开发初窥(1)</title><link>http://www.cnblogs.com/WuCountry/archive/2009/05/31/1493297.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sun, 31 May 2009 15:41:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/05/31/1493297.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1493297.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/05/31/1493297.html#Feedback</comments><slash:comments>12</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1493297.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1493297.html</trackback:ping><description><![CDATA[<p>　　应该说在Linux上开发.Net应用程序不是很新鲜的事了。但在Suse11之前，也没有哪个正式的Linux版本集成了.Net开发环境。<a href="http://space.cnblogs.com/group/topic/12697/">http://space.cnblogs.com/group/topic/12697/</a></p>
<p>　　已经近两年没有在博客园上发表点什么了，一来是自己转向Linux和C了，对Windows下的C＃和VS.Net开发环境也很少使用了。但对.Net和C＃的热爱是一点也没有减少。相反，也一直在关注Linux下.Net应用程序开发的进展情况。在使用过几个版本的Linux以后，终于在前几天Suse11的网站上（<a href="http://en.opensuse.org/Download">http://en.opensuse.org/Download</a>）看到Suse11支持.Net应用程序开发的特性说明。于是花了一天时间下载，2天时间专门用一台机器安装了它。今天，终于可以小试一了。</p>
<p>　　先看看开发环境，MonoDevelop:</p>
<p><img height="725" alt="" src="http://images.cnblogs.com/cnblogs_com/wucountry/2009_5/Screenshot-Welcome-MonoDevelop.png" width="1024" border="0" /></p>
<p>&nbsp;</p>
<p>Hello World:</p>
<p><img height="701" alt="" src="http://images.cnblogs.com/cnblogs_com/wucountry/2009_5/Screenshot-CSharp-MonoDevelop.jpg" width="1024" border="0" /></p>
<p>命令行下执行：</p>
<p><img height="514" alt="" src="http://images.cnblogs.com/cnblogs_com/wucountry/2009_5/Screenshot-Terminal-1.png" width="807" border="0" /></p>
<p>再看看Linux下的.Net开发环境帮助：</p>
<p><img height="525" alt="" src="http://images.cnblogs.com/cnblogs_com/wucountry/2009_5/Screenshot-MonoDocumentationLibrary.jpg" width="830" border="0" /></p>
<p>　　非常不错的开发环境。简单的配置了一下，可以支持.Net1.1和2.0以及多种图形库。当然还有Web应用程序开发库。今天就先简单的写点，希望以后在博客园里看到更多的关于.Net在更多平台上开发的东西。</p>
<p>&nbsp;</p><img src ="http://www.cnblogs.com/WuCountry/aggbug/1493297.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/48007/" target="_blank">IE颓势不减 微软下月公布最新浏览器架构</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>How to uninstall GRUB</title><link>http://www.cnblogs.com/WuCountry/archive/2009/05/30/1491997.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sat, 30 May 2009 00:47:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/05/30/1491997.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1491997.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/05/30/1491997.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1491997.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1491997.html</trackback:ping><description><![CDATA[<font face="Times New Roman" size="3">
<div class="headline_area">
<h1 class="entry-title">How to uninstall GRUB</h1></div>
<div class="format_text entry-content">
<div style="margin-top: 0px; float: right; margin-left: 5px"><a title="See all Micro$oft related FAQ" href="http://www.cyberciti.biz/faq/category/windows/"><img alt="" src="http://figs.cyberciti.biz/3rdparty/wine.png" border="0" /></a></div>
<p><span style="color: rgb(255,0,0)">Q</span>. How do I uninstall GRUB? I need to uninstall everything before sending this hard disk to someone including GRUB. All I need to keep is windows XP.</p>
<p><span style="color: rgb(0,153,0)">A</span>. GNU GRUB ("GRUB" for short) is a boot loader package from the GNU Project. GRUB is the reference implementation of the Multiboot Specification, which allows a user to have several different operating systems on their computer at once, and to choose which one to run when the computer starts.</p>
<p>You can overwrite MBR with standard dd command. You can also use old good MS-DOS fdisk command to overwrite MBR. </p>
<h3>Using MS-DOS/Windows 9x boot disk</h3>
<p>In order to remove the GRUB bootloader from a Linux and Windows XP machine, boot with a <span style="color: rgb(255,0,0)">Windows 9x startup disk</span> or <span style="color: rgb(255,0,0)">CD</span> and execute the MS-DOS command:<br /><code><font style="background-color: #eeeeee" face="Courier" size="2">fdisk /mbr</font></code></p>
<h3>Using Windows XP boot disk</h3>
<p>Boot computer using Windows XP (Windows 2000)<span style="color: rgb(102,102,204)"> setup disc / CD / DVD</span>. Next, type the following commands:<br /><code><font style="background-color: #eeeeee" face="Courier" size="2"># fixmbr<br /># exit<br /></font></code></p>
<h3>Using Linux</h3>
<p>You can also use dd command from Linux itself (it removes partition table):<br /><code><font style="background-color: #eeeeee" face="Courier" size="2"># dd if=/dev/null of=/dev/sdX bs=512 count=1</font></code></p>
<p>Just remove MBR, without the partition table (see comment below):<br /><code><font style="background-color: #eeeeee" face="Courier" size="2"># dd if=/dev/null of=/dev/sdX bs=446 count=1</font></code></p>
<p>Replace /dev/hdX with your actual device name such as /dev/hda. Use fdisk -l command to find out device name:<br /><code><font style="background-color: #eeeeee" face="Courier" size="2"># fdisk -l</font></code>Output: </p><pre>Disk /dev/sda: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       30384   243955057+  83  Linux
/dev/sda3           30385       30515     1052257+  82  Linux swap
</pre><pre><p class="disclaimer">Disclaimer: This document is provided "as is" without warranty. Use at your own risk. In no event shall I be liable for any damage resulting from the use of this work.</p><p>This HOWTO applies if:</p><ul><li>Your machine already has Windows installed, and you are installing Linux as a second operating system, and</li><li>You want to leave the Windows boot loader (NTLDR) on the MBR (Master Boot Record). This allows you to continue to boot Windows with no issues. I've heard that Windows 2000/Windows XP or anti-virus software may complain if the MBR does not contain the Windows boot loader </li></ul><p>You can use either GRUB or LILO to dual-boot Windows 2000/Windows XP and Linux. Both functionally work fine, but from what I've read, GRUB requires less maintenance, as LILO requires you to reinstall the boot loader (by running <tt>/sbin/lilo</tt>) every time you rebuild the kernel or make changes to <tt>/etc/lilo.conf</tt>.</p><h3 id="Bios_1024_Limit">Requirements for <tt>/boot</tt> Partition</h3><p>The location of the <tt>/boot</tt> partition on the hard drive is critical so that you don't get screwed by the infamous <a href="http://www.tldp.org/HOWTO/Large-Disk-HOWTO-4.html#ss4.2">BIOS 1024 cylinder limit</a>. The BIOS of older systems can't access data beyond cylinder 1024, which is ~8.5 GB. A simple way to avoid the BIOS 1024 limit is to create <tt>/boot</tt> within the first 1024 cylinders (~8.5 GB) of the hard drive. <strong>If you have multiple hard drives (disks)</strong>, <tt>/boot</tt> must be on the same hard drive (probably the first hard drive) that has the Windows boot loader (NTLDR) on the MBR.</p><p>Here are some options for where to create <tt>/boot</tt> partition.</p><ol><li>(What I did) Shrink the Windows partition such that there is 50 MB of unused disk space at the beginning of the drive and lots of space after the Windows partition. You can install the <tt>/boot</tt> Linux partition in this first 50 MB and avoid any potential issues with the 1024-cylinder limit entirely.</li><li>Shrink the Windows partition such that it does not cross the 1024 cylinder (~8.5 GB), and install the <tt>/boot</tt> partition right after the Windows partition.</li><li>Use <a href="http://www.dictionary.com/search?q=Logical%20Block%20Addressing">LBA</a> (Logical Block Addressing). LBA allows you to boot beyond the 1024 cylinder. In order to use LBA, your BIOS must support it. In addition, for LILO, you must also add a flag to enable LBA support. GRUB <a href="http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/ref-guide/ch-grub.html">supports LBA</a> "out-of-the-box" </li></ol><p>To non-destructively shrink the Windows partition, you can use the free software program <a href="http://www.igd.fhg.de/~aschaefe/fips/">fips</a> (please note that fips does not currently support NTFS partitions). Another option is the excellent commercial product <a href="http://www.partitionmagic.com/">Partition Magic</a>. It has an easy-to-use GUI. Unfortunately, the tool that comes with Red Hat 7.2, Disk Druid, does not have the ability to shrink existing partitions. Once you've shrunk the Windows partition, you can use Disk Druid during the Red Hat Installation to create all the partitions you need for Linux.</p><h3>Dual-Boot Setup</h3><p>Following are the steps to get dual-boot working with GRUB; I figured out how to do this by looking at a <a href="http://users.wpi.edu/~naveen/projects/content/d/dualbootlin2000.html">similar procedure</a> for LILO. I've verified that this works for Windows 2000 and Windows XP, and this should work on Windows NT (all 3 OSs use the same booting architecture).</p><ol><li>Install GRUB on the first sector of the <tt>/boot</tt> partition. <strong>DO NOT INSTALL IT ON THE MBR!</strong>. <div>If you are performing the Red Hat installation, for the "Boot Loader Installation" screen: <ul><li>Select "Use GRUB as the boot loader"</li><li>Select Install Boot Loader record on "...First sector of boot partition".</li><li>After finishing the Red Hat installation, reboot into Linux. If you don't have a boot disk, try <a href="http://www.geocities.com/epark/linux/redhat72-install-HOWTO.html#Booting_Linux_in_Rescue_Mode">booting in linux rescue mode</a> </li></ul></div><div>If you already have Linux installed: <ul><li>Run the following command (e.g. assuming <tt>/boot</tt> is <tt>/dev/hda2</tt>): <tt>grub-install /dev/hda2</tt>. <div>If you don't know which partition contains <tt>/boot</tt>, run the <tt>df</tt> command and check the output.</div></li><li>Edit <tt>/etc/grub.conf</tt> and make sure there is an entry for your version of Windows. For reference, here is a copy of my <a href="http://www.geocities.com/epark/linux/grub.conf.txt"><tt>/etc/grub.conf</tt></a> file. </li></ul></div></li><li>Determine which partition contains the <tt>/boot</tt> partition by running the <tt>df</tt> command. You'll see output like this: <pre>Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda3              8665372   1639580   6585612  20% /
/dev/hda2                46636      5959     38269  14% /boot
/dev/hda6               513776    189504    324272  37% /osshare
none                    256624         0    256624   0% /dev/shm
</pre>From this output, we see that <tt>/boot</tt> is on <tt>/dev/hda2</tt>.</li><li>Make a copy of the Linux boot sector onto a floppy or onto a FAT32 partition. We'll name this copy <tt>linux.bin</tt>. <div>To make a copy onto a floppy: <ul><li>Mount the floppy drive if it's not mounted (assumes <tt>/mnt/floppy</tt> exists): <tt>mount -t msdos /dev/fd0 /mnt/floppy</tt></li><li>Run the following command: <tt>dd if=/dev/hda2 of=/mnt/floppy/linux.bin bs=512 count=1</tt> <div>Substitute the path for the <tt>if=</tt> parameter (the input file) with the appropriate partition from the previous step. E.g., set <tt>if=</tt> to <tt>/dev/hda2</tt>.</div></li></ul></div><div>To make a copy onto a FAT32 (vfat) partition: <ul><li>Mount the FAT32 partition if it's not mounted yet. If it isn't listed in the <tt>df</tt> output, it hasn't been mounted yet. Check out <a href="http://www.geocities.com/epark/linux/partition-share-HOWTO.html#linux">steps 3a-3c for mounting a FAT32 partition</a> on the "Share Partitions HOWTO".</li><li>Run the following command: <tt>dd if=/dev/hda2 of=/osshare/linux.bin bs=512 count=1</tt> <div>Substitute the path for the <tt>if=</tt> parameter (the input file) with the appropriate partition from the previous step. E.g., set <tt>if=</tt> to <tt>/dev/hda2</tt>. Substitute the path for the <tt>of=</tt> parameter (the output file) with whatever is appropriate for your system. The example here (<tt>of=/osshare/linux.bin</tt>) is for copying onto a FAT32 partition called <tt>osshare</tt>.</div></li></ul></div></li><li>Reboot into Windows</li><li>Copy the <tt>linux.bin</tt> file to <tt>C:\</tt></li><li>Run notepad and edit <tt>C:\boot.ini</tt>. Note that <tt>C:\boot.ini</tt> is a hidden system file, so it probably won't show up in Windows Explorer. To edit the file, try: <tt>Start-&gt;Run</tt> and enter: <tt>notepad C:\boot.ini</tt>. Add the following line at the end: <tt>c:\linux.bin="Linux"</tt> <div>If your <tt>C:</tt> filesystem is NTFS (not FAT32), you must edit <tt>C:\boot.ini</tt> as a user with administrator-level privileges.</div><div>To make <tt>C:\boot.ini</tt> writable, you can either : <ul><li>Use Explorer: <ul><li>Go to <tt>Tools-&gt;Folder Options-&gt;View</tt> and select <tt>Show hidden files and folders</tt> and deselect <tt>Hide protected operating system files (Recommended)</tt>.</li><li>Right-click on the file, view the <tt>Properties</tt> and uncheck <tt>Read-only</tt>. You can now edit the file.</li><li>After editing the file, restore the settings to their original state. </li></ul></li><li>Use the command-line: <ul><li>Make the file writable: <tt>attrib -R -S -H C:\boot.ini</tt>.</li><li>After you've finished editing the file, put the settings back: <tt>attrib +R +S +H C:\boot.ini</tt> </li></ul></li></ul></div>For reference, here is a copy of my <a href="http://www.geocities.com/epark/linux/boot.ini.txt"><tt>boot.ini</tt></a> file.</li><li>Reboot again. You should be able to pick either Windows or Linux. Selecting Linux will start GRUB </li></ol><h3>Troubleshooting</h3><ul><li class="question">When I select Linux from the boot menu, I get a frozen "GRUB" (or an "L" in the case of LILO)</li><li class="answer">Make sure you created the <tt>linux.bin</tt> file correctly with the <tt>dd</tt> command. If you think you ran the command correctly, the problem may be that your <tt>/boot</tt> partition is beyond cylinder 1024 and your BIOS can't reach it. At system startup, the Windows boot loader lists the choices from <tt>boot.ini</tt>. When you select Linux, the boot loader then loads the 512-byte <tt>linux.bin</tt> file, and then BIOS tries to access the <tt>/boot</tt> partition to run GRUB. Some BIOS implementations can only address the first 1024 cylinders of a hard drive, which corresponds to ~8.5 GB. How do you fix this? <a href="http://www.geocities.com/epark/linux/grub-w2k-HOWTO.html#Bios_1024_Limit">Create your <tt>/boot</tt> partition before cylinder 1024</a>; i.e. before ~8.5 GB.</li><li class="question">If I select Linux from the boot menu, I get an error message that says "Windows XP could not load: The file hal.dll (windows/system32/) is missing or corrupt. Please reinstall.</li><li class="answer">This is usually caused by an error in the <tt>boot.ini</tt> file. If you are unable to find and fix the error, check out <a href="http://www.kellys-korner-xp.com/xp_haldll_missing.htm">Kelly Theriot's page</a> that provides various methods for addressing the problem. </li></ul><h3>Acknowledgments</h3><ul><li>Jimmy Andriambao: for recommending the <a href="http://www.kellys-korner-xp.com/xp_haldll_missing.htm">link</a> regarding hal.dll problems</li><li>Leif Roger Kolberg: for creating a <a href="http://wwwstud.hint.no/~leifk/grub-w2k-howto-no.html">Norwegian translation of this page</a></li><li>Dirk Goepfert: for creating a <a href="http://www.locaproz.com/docs/Dual-Boot_W2K_XP_with_GRUB_HOWTO_DE.htm">German translation of this page</a></li><li>Fred van Lieshout: for creating a <a href="http://home.zonnet.nl/fred.van.lieshout/linux/HOWTO/grub-w2k-howto-nl.html">Dutch translation of this page</a></li><li>Rostislav "Udo" Galicek: for creating a <a href="http://www.volny.cz/galicek/linux%20ver%20XP/grub-w2k-HOWTO-cz.html">Czech translation of this page</a></li><li>Arun Swami: for validating the dual-boot setup with multiple hard drives. Thanks Arun!</li><li>Adri&#225;n I. Correa: for enthusiastically providing a <a href="http://www.geocities.com/epark/linux/grub-w2k-HOWTO-es.html">Spanish translation of this page</a>. Adri&#225;n said it best: "I love this wonder called The Internet!"</li><li>Devesh Mistry: for pointing out the use of <tt>chroot /mnt/sys/mnt/syimage</tt> when in linux rescue mode</li><li>Emmanuel Brun: for graciously providing a <a href="http://www.geocities.com/epark/linux/grub-w2k-HOWTO-fr.html">French translation of this page</a></li><li>Jason Noll: for reporting the hal.dll problem resulting from error(s) in <tt>boot.ini</tt></li><li>Garth Patil: for helping to troubleshoot why GRUB was freezing and having a great sense of humor</li><li>Piete Brooks: for pointing out that editing <tt>C:\boot.ini</tt> requires administrator-level privileges and providing the content for making the file editable using Explorer</li><li>Paul Feehan: for providing the commands to make <tt>C:\boot.ini</tt> editable for Windows XP</li><li>Jan Holm Jensen: for reporting that <tt>C:\boot.ini</tt> is a hidden system file</li><li>Hampus Hedberg Hankell: for the following suggestion: <div><em>I think you should add help for users in despair that already have installed grub on mbr ,thus loosing the their ability to boot into windows xp. Procedure for this is ,boot from a windows start disc and do a fdisk /mbr At least then they can reach their windows and this time doing it right</em></div></li><li>Mark Jordan: for verifying that this works on Windows XP and suggesting the content for copy to floppy</li><li><a href="http://www.darryl.net/">Darryl Eaton</a>: for introducting me to Red Hat Linux </li></ul></pre></div></font><img src ="http://www.cnblogs.com/WuCountry/aggbug/1491997.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/48002/" target="_blank">竞争日趋激烈 微软欲借 Windows 7 扭转战局</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>如何自己配置和编译一个完整的Linux嵌入式开发环境？</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/09/1407396.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Mon, 09 Mar 2009 15:44:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/09/1407396.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1407396.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/09/1407396.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1407396.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1407396.html</trackback:ping><description><![CDATA[这里我不得不推荐一书：Linux+From+Scratch(CN).CHM<BR>可以从CSDN上下载！<BR><BR>我的演练过程：<BR>1、配置好开发环境，最好的方法是VMWare(Redhat)；<BR>2、参照LFS中的说明，一条一条的编译；遇到问题就Google!<BR><BR>如果顺利，本周应该可以自己把整个开发工具链及环境全部过一遍!<BR><BR>如果只是使用的话，网上也有很多已经编译好的工具包，直接下载使用，一般都是200M左右!<BR><img src ="http://www.cnblogs.com/WuCountry/aggbug/1407396.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/48001/" target="_blank">上海电信计划2012年80%用户实现100M带宽</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>我的学习开发环境，呵呵！</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/08/1406385.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sun, 08 Mar 2009 11:40:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/08/1406385.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1406385.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/08/1406385.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1406385.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1406385.html</trackback:ping><description><![CDATA[<DIV>今天到电子市场去，花了近700块，弄了块ARM的学习单板，再也不用去搞什么虚拟机了！ </DIV>
<DIV>简单的看了一下开发手册，还有点麻烦，可能得花点时间去把它搞清楚！ </DIV>
<DIV>但这块单板的功能还是很强的，基本上可以满足常用的学习与测试了！ </DIV>
<DIV>更重要的是随单板一起有很多的工具，可以自己慢慢的学习和使用了！ <BR>以后的学习笔记就以这个环境为主了！呵呵！<BR><BR><IMG height=480 alt=030809191947.jpg src="http://www.cnblogs.com/images/cnblogs_com/wucountry/2009/030809191947.jpg" width=640 border=0><BR><BR><IMG height=480 alt=030809192013.jpg src="http://www.cnblogs.com/images/cnblogs_com/wucountry/2009/030809192013.jpg" width=640 border=0></DIV><img src ="http://www.cnblogs.com/WuCountry/aggbug/1406385.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/48000/" target="_blank">数万名网友签名抗议星际争霸2取消局域网功能</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>Linux中进程结构描述符</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/08/1406067.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sat, 07 Mar 2009 16:22:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/08/1406067.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1406067.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/08/1406067.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1406067.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1406067.html</trackback:ping><description><![CDATA[<P>include/linux/sched.h<BR>384&nbsp;&nbsp; struct task_struct {<BR>385&nbsp;&nbsp;&nbsp;&nbsp; volatile long state;<BR>386&nbsp;&nbsp;&nbsp;&nbsp; struct thread_info *thread_info;<BR>387&nbsp;&nbsp;&nbsp;&nbsp; atomic_t usage;<BR>388&nbsp;&nbsp;&nbsp;&nbsp; unsigned long flags;&nbsp; <BR>389&nbsp;&nbsp;&nbsp;&nbsp; unsigned long ptrace;<BR>390<BR>391&nbsp;&nbsp;&nbsp;&nbsp; int lock_depth;<BR>392<BR>393&nbsp;&nbsp;&nbsp;&nbsp; int prio, static_prio;<BR>394&nbsp;&nbsp;&nbsp;&nbsp; struct list_head run_list;<BR>395&nbsp;&nbsp;&nbsp;&nbsp; prio_array_t *array;<BR>396<BR>397&nbsp;&nbsp;&nbsp;&nbsp; unsigned long sleep_avg;<BR>398&nbsp;&nbsp;&nbsp;&nbsp; long interactive_credit;<BR>399&nbsp;&nbsp;&nbsp;&nbsp; unsigned long long timestamp;<BR>400&nbsp;&nbsp;&nbsp;&nbsp; int activated;<BR>401<BR>302&nbsp;&nbsp;&nbsp;&nbsp; unsigned long policy;<BR>403&nbsp;&nbsp;&nbsp;&nbsp; cpumask_t cpus_allowed;<BR>404&nbsp;&nbsp;&nbsp;&nbsp; unsigned int time_slice, first_time_slice;<A name=ch03index64></A><A name=ch03index65></A><A name=ch03index66></A><A name=ch03index67></A><A name=ch03index68></A><BR>405<BR>406&nbsp;&nbsp;&nbsp;&nbsp; struct list_head tasks;<BR>407&nbsp;&nbsp;&nbsp;&nbsp; struct list_head ptrace_children;<BR>408&nbsp;&nbsp;&nbsp;&nbsp; struct list_head ptrace_list;<BR>409<BR>410&nbsp;&nbsp;&nbsp;&nbsp; struct mm_struct *mm, *active_mm;<BR>...<BR>413&nbsp;&nbsp;&nbsp;&nbsp; struct linux_binfmt *binfmt;<BR>414&nbsp;&nbsp;&nbsp;&nbsp; int exit_code, exit_signal;<BR>415&nbsp;&nbsp;&nbsp;&nbsp; int pdeath_signal;<BR>...<BR>419&nbsp;&nbsp;&nbsp;&nbsp; pid_t pid;<BR>420&nbsp;&nbsp;&nbsp;&nbsp; pid_t tgid;<BR>...<BR>426&nbsp;&nbsp;&nbsp;&nbsp; struct task_struct *real_parent;<BR>427&nbsp;&nbsp;&nbsp;&nbsp; struct task_struct *parent;<BR>428&nbsp;&nbsp;&nbsp;&nbsp; struct list_head children;<BR>429&nbsp;&nbsp;&nbsp;&nbsp; struct list_head sibling;<BR>430&nbsp;&nbsp;&nbsp;&nbsp; struct task_struct *group_leader;<BR>...<BR>433&nbsp;&nbsp;&nbsp;&nbsp; struct pid_link pids[PIDTYPE_MAX];<BR>434<BR>435&nbsp;&nbsp;&nbsp;&nbsp; wait_queue_head_t wait_chldexit;<BR>436&nbsp;&nbsp;&nbsp;&nbsp; struct completion *vfork_done;<BR>437&nbsp;&nbsp;&nbsp;&nbsp; int __user *set_child_tid;<BR>438&nbsp;&nbsp;&nbsp;&nbsp; int __user *clear_child_tid;<BR>439<BR>440&nbsp;&nbsp;&nbsp;&nbsp; unsigned long rt_priority;<BR>441&nbsp;&nbsp;&nbsp;&nbsp; unsigned long it_real_value, it_prof_value, it_virt_value;<BR>442&nbsp;&nbsp;&nbsp;&nbsp; unsigned long it_real_incr, it_prof_incr, it_virt_incr;<BR>443&nbsp;&nbsp;&nbsp;&nbsp; struct timer_list real_timer;<BR>444&nbsp;&nbsp;&nbsp;&nbsp; unsigned long utime, stime, cutime, cstime;<BR>445&nbsp;&nbsp;&nbsp;&nbsp; unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;<BR>446&nbsp;&nbsp;&nbsp;&nbsp; u64 start_time;<BR>...<BR>450&nbsp;&nbsp;&nbsp;&nbsp; uid_t uid,euid,suid,fsuid;<BR>451&nbsp;&nbsp;&nbsp;&nbsp; gid_t gid,egid,sgid,fsgid;<BR>452&nbsp;&nbsp;&nbsp;&nbsp; struct group_info *group_info;<BR>453&nbsp;&nbsp;&nbsp;&nbsp; kernel_cap_t cap_effective, cap_inheritable, cap_permitted;<BR>454&nbsp;&nbsp;&nbsp;&nbsp; int keep_capabilities:1;<BR>455&nbsp;&nbsp;&nbsp;&nbsp; struct user_struct *user;<BR>...<BR>457&nbsp;&nbsp;&nbsp;&nbsp; struct rlimit rlim[RLIM_NLIMITS];<BR>458&nbsp;&nbsp;&nbsp;&nbsp; unsigned short used_math;<BR>459&nbsp;&nbsp;&nbsp;&nbsp; char comm[16];<BR>...<BR>461&nbsp;&nbsp;&nbsp;&nbsp; int link_count, total_link_count;<BR>...<BR>467&nbsp;&nbsp;&nbsp;&nbsp; struct fs_struct *fs;<BR>...<BR>469&nbsp;&nbsp;&nbsp;&nbsp; struct files_struct *files;<BR>...<BR>509&nbsp;&nbsp;&nbsp;&nbsp; unsigned long ptrace_message;<BR>510&nbsp;&nbsp;&nbsp;&nbsp; siginfo_t *last_siginfo;<BR>...<BR>516&nbsp;&nbsp; };<BR></P>
<P class=docText>The following categories describe some of the types of things a process descriptor must keep track of during a process' lifespan:　进程运行中必须保存的一些信息类别</P>
<UL>
<LI>
<P class=docList>Process attributes进程属性</P>
<LI>
<P class=docList>Process relationships进程间关系</P>
<LI>
<P class=docList>Process memory space进程内存空间</P>
<LI>
<P class=docList>File management文件管理</P>
<LI>
<P class=docList>Signal management信号管理</P>
<LI>
<P class=docList>Process credentials进程信任状态</P>
<LI>
<P class=docList>Resource limits资源限制</P>
<LI>
<P class=docList>Scheduling related fields调度相关的字段</P></LI></UL>
<P class=docList>current宏指向当前进程数据结构描述符！可以自己写一个小程序，将这些信息都打出来！</P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1406067.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/48000/" target="_blank">数万名网友签名抗议星际争霸2取消局域网功能</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>开始从代码入手学习内核</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/07/1405708.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sat, 07 Mar 2009 15:03:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/07/1405708.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1405708.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/07/1405708.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1405708.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1405708.html</trackback:ping><description><![CDATA[决定不再玩虚拟机了，直接弄个单板得了！<BR>想在虚拟机上运行ARM内核！试过了所有会的方法，没一次成功的！比较郁闷！<BR>决定明天去弄块单板，直接上板玩得了！<BR>另外，也不全部做翻译了，结合代码看书，翻译和笔记一起做！<BR>把2.6.21.1的内核代码添加到工程了，再加上glibc2.7，准备好好的看看代码了。<BR>一共2万千多个文件，慢慢看吧！<BR><BR><img src ="http://www.cnblogs.com/WuCountry/aggbug/1405708.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47999/" target="_blank">Silverlight打造杰克逊纪念专题</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>Linux 2.6.19.x 内核编译配置选项简介</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404949.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Fri, 06 Mar 2009 13:36:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404949.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1404949.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404949.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1404949.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1404949.html</trackback:ping><description><![CDATA[摘要: http://lamp.linux.gov.cn/Linux/kernel_options.htmlLinux 2.6.19.x 内核编译配置选项简介作者：金步国版权声明本文作者是一位自由软件爱好者，所以本文虽然不是软件，但是本着 GPL 的精神发布。任何人都可以自由使用、转载、复制和再分发，但必须保留作者署名，亦不得对声明中的任何条款作任何形式的修改，也不得附加任何其它条件。您可以自由链接、下载&nbsp;&nbsp;<a href='http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404949.html'>阅读全文</a><img src ="http://www.cnblogs.com/WuCountry/aggbug/1404949.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47998/" target="_blank">传诺基亚正在开发Android手机</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>Building and Testing gcc/glibc cross toolchains</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404906.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Fri, 06 Mar 2009 12:15:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404906.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1404906.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404906.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1404906.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1404906.html</trackback:ping><description><![CDATA[<A href="http://www.kegel.com/crosstool/#download">http://www.kegel.com/crosstool/#download</A><BR><BR>
<H1>Building and Testing gcc/glibc cross toolchains</H1>
<H2>Contents</H2>
<UL>
<LI><A href="http://www.kegel.com/crosstool/#trouble">Trouble in cross-compiler land</A> 
<LI><A href="http://www.kegel.com/crosstool/#enhancements">Enhancing the community build script</A> 
<LI><A href="http://www.kegel.com/crosstool/#results">Results</A> 
<LI><A href="http://www.kegel.com/crosstool/#download">Downloads</A> 
<LI><A href="http://www.kegel.com/crosstool/#author">About the author</A> </LI></UL>Note: be sure to read <A href="http://www.kegel.com/crosstool/current/doc/crosstool-howto.html">crosstool-howto.html</A>; that's the real doc. 
<H2><A name=trouble>Trouble in crosscompiler land</A></H2>Building a gcc / glibc cross-toolchain for use in embedded systems development used to be a scary prospect, requiring iron will, days if not weeks of effort, lots of Unix and Gnu lore, and sometimes willingness to take dodgy shortcuts. This is a problem not only for individual users, but also for the gcc project as a whole, since the gcc team relies on users to test upcoming releases of gcc, and the difficulty of building the toolchain for embedded targets restricted the number of people able to help with the testing. 
<P>At Ixia, I had been maintaining a toolchain by starting with a commercial free embedded linux toolchain, and overlaying it with newer versions compiled from scratch as needed to fix problems. This became harder to maintain as time went on. 
<H2><A name=enhancements>Enhancing the community build script</A></H2>After some months of frustration, it became clear we needed an easy way to build and test gcc/glibc cross-toolchains from scratch. Looking around, I realized that Bill Gatliff's <A href="http://www.billgatliff.com/">crossgcc FAQ and build script</A>, what most of the community used to build cross-compilers, was almost what I needed, so I rolled up my sleeves and: 
<UL>
<LI>made darn sure it worked properly for ppc and gcc-2.95 
<LI>removed newlib support so I could focus on glibc more easily 
<LI>updated it to handle gcc-3.2.x, gcc-3.3.x, and gcc-3.4.x, since I wasn't sure which of those I would need 
<LI>enhanced it to automatically download the source tarballs and apply the minimal set of patches needed to successfully build 
<LI>enhanced it to support all CPU types supported by glibc, since that was easy and was a good test of the script 
<LI>added support for running the gcc and glibc regression test suites, since at Ixia we need regression tests for everything we ship 
<LI><A href="http://www.kegel.com/crosstool/current/doc/dejagnu-remote-howto.html">documented how to run dejagnu regression tests remotely</A>, since that's how to test gcc on a small embedded platform, and the dejanu documentation is misleading and incomplete 
<LI><A href="http://www.kegel.com/crosstool/current/doc/chroot-login-howto.html">documented how to set up a chroot jail that allows remote login</A>, since a chroot jail is the easiest way to test alternate versions of glibc, and there weren't any good howto's on the subject 
<LI>added support for building userland (for now, just busybox, ncurses, libnet, and libpcap) with the new toolchain (see --builduserland option to all.sh) so you can test even if you don't have userland apps compatible with the new toolchain </LI></UL>
<H2><A name=results>Results</A></H2>I call my updated script and associated patches 'crosstool'. It's fairly easy to use and can be run unattended as part of an automatic build process, and should go a long way towards making it easier for the average developer to get started with gcc cross-compilers and help test new releases of gcc. 
<P>You can see from the <A href="http://www.kegel.com/crosstool/crosstool-0.43/buildlogs">build matrix included in the buildlogs directory of the crosstool tarball</A> that many combinations of CPU, gcc, glibc, and Linux produce toolchains which can in fact compile user programs and the Linux kernel. You can also see which combinations don't work, and by clicking on their entries in the matrix, you can see the last 300 lines of the build log, including the error that stopped the toolchain or kernel build. 
<P>(I used to have test results here for some embedded processors, but they're a bit out of date.) 
<P>Here are a few success reports from other users: 
<UL>
<LI><A href="http://sources.redhat.com/ml/crossgcc/2003-06/msg00131.html">Leif Huhn said</A> he used crosstool to generate a gcc3.2.3-glibc2.2.5 / arm-unknown-linux-gnu toolchain which successfully compiles static binaries for the Zaurus 5600. 
<LI>Several people (<A href="http://www.batbox.org/wrt54g.html">batbox.org</A>, <A href="http://www.seattlewireless.net/index.cgi/LinksysWrt54g">seattlewireless.net's wiki</A>) say they've used crosstool to generate a gcc3.2.3-glibc2.2.5 / mipsel-linux toolchain for the BCM4710 processor that powers the Linksys WRT54 Wireless Router. 
<LI><A href="http://www.davehylands.com/linux/ARM-bigendian/">Dave Hylands</A> had to add some patches, but reported success using crosstool to generate a gcc-2.95.3-glibc-2.2.2 / armv4b-linux big endian ARM toolchain. </LI></UL>Actual comments from happy users: 
<UL>
<LI>"Thanks for crosstool, it's a big time saver. I used demo-ppc405.sh on Red Hat Enterprise Linux 3 ... With this compiler I'm able to compile and boot a 2.4.19-rc3-based kernel on a PowerPPC 440 board." 
<LI>"Thanks for crosstool! It's been some time since I had to build a cross-compiler, but I remember it being a pain. Your tool makes it almost effortless." 
<LI>"Dan, your tool is full of Ass Kicking Goodness!(tm)!" 
<LI>"Thank you!! If I were female, at this point I would offer to have your baby." 
<LI>"Thanks again for crosstool. It has been a wonderful oasis in the turbulent sea of cross tool bits." 
<LI>"You have my utmost respect and awe. Your very careful work saved me untold hours of work and search &amp; read time." 
<LI>"Thank you so much for writing crosstool. Years ago, I spent ages setting up a gcc cross-compiler, and was looking at doing so again with dread (especially an unusual cygwin-&gt;Linux cross-compiler). With crosstool, I was up and running after a single, automated, overnight build -- I really didn't think it would work, as it seemed too good to be true. You are an absolute angel. Thank you." </LI></UL>
<H2><A name=download>Downloads</A></H2>
<UL>
<LI><A href="http://www.kegel.com/crosstool/crosstool-0.43/doc/crosstool-howto.html">crosstool-howto.html</A> -- read this first; this is the real doc 
<LI><A href="http://www.kegel.com/crosstool/crosstool-0.43.tar.gz">http://kegel.com/crosstool/crosstool-0.43.tar.gz</A> (tarball) 
<LI><A href="http://www.kegel.com/crosstool/crosstool-0.43">http://kegel.com/crosstool/crosstool-0.43</A> (individual files) 
<LI><A href="http://www.kegel.com/crosstool/crosstool-0.43/buildlogs">buildlogs</A> (cool handy-dandy matrix showing whether various tool/cpu combinations can build a Linux kernel, and linking to the build logs) 
<LI><A href="http://www.kegel.com/crosstool/crosstool-0.43/ChangeLog">ChangeLog</A> 
<LI><A href="http://www.kegel.com/crosstool/crosstool-0.43/README">README</A> 
<LI><A href="http://www.kegel.com/crosstool/crosstool-0.43/patches/">crosstool patch repository</A> -- patches I apply to the tools before building. Each patch starts off with links to the appropriate discussions and/or bug reports, and shows the error it fixes. (Well, most of them do.) </LI></UL>
<P><IMG style="FLOAT: right" alt="Picture of Dan Kegel" src="http://www.kegel.com/crosstool/kegel.jpg"> 
<H2><A name=author>About the author</A></H2>Dan Kegel is a software engineer currently employed by <A href="http://www.google.com/">Google</A>. He has been programming since 1978, and <A href="http://www.kegel.com/academy/">mentoring intern programmers</A> since 1994. He served on the <A href="http://www.jcp.org/jsr/detail/51.jsp">JSR-51</A> committee which helped add nonblocking I/O and file locking to the Java platform. His web site <A href="http://www.kegel.com/c10k.html">"The C10K Problem"</A> is well-known among a small circle of internet server programmers, and his essay <A href="http://www.kegel.com/linux/edu">"The Case for Linux in Universities"</A> has been translated into Spanish, Hindi, and Telugu. He maintains <A href="http://lalugs.org/">lalugs.org</A> as a service to the Los Angeles Linux community. He thanks his wife Liz Fuller for her support and patience during his periodic save-the-world quests, <A href="http://www.ixiacom.com/">Ixia</A> for sponsoring the first four months of this work, Bill Gatliff for the original script, Kaz Kojima and Daniel Jacobowitz for supplying patches on the spot to solve various problems, and the many crosstool users who have submitted bug reports, fixes, and enhancements. 
<P><SMALL><I>Last Change 7 Dec 2006<BR>The latest copy of this document can be found at <A href="http://www.kegel.com/crosstool/">kegel.com/crosstool</A><BR>Portions Copyright by Ixia, 2003<BR>Portions Copyright by Google, 2003-2006<BR>Crosstool is free software; you can redistribute it and/or modify it under the terms of the <A href="http://www.gnu.org/licenses/licenses.html#GPL">GNU General Public License as published by the Free Software Foundation</A>; either version 2 of the License, or (at your option) any later version.</I> </SMALL>
<P><A href="http://www.kegel.com/">[Return to www.kegel.com]</A> </P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1404906.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47998/" target="_blank">传诺基亚正在开发Android手机</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>Running Linux for ARM processors under QEMU</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404902.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Fri, 06 Mar 2009 12:08:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404902.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1404902.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404902.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1404902.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1404902.html</trackback:ping><description><![CDATA[QEMU is well-known as a free replacement for VMware, allowing users to run a PC within a PC. What isn't so well known about QEMU is that, in addition to emulating x86 architectures, it can emulate AMD64, Sparc, MIPS, PPC and ARM CPUs.<BR><BR>In the case of the ARM architecture, QEMU provides a convenient, if slow, environment in which development can be done for embedded systems.<BR><BR>This article describes the process involved in building a Debian/ARM server running under QEMU. It assumes that Debian is also being used as the host server.<BR><BR>Since QEMU's arm emulator has no ability to emulate either IDE or SCSI disks, it will be necessary to install the server on an NFS exported partition.<BR><BR>
<DIV class=serendipity_entry_extended><A id=extended></A>
<H3>Preparing the host server</H3><BR><BR>Firstly, install the required packages on your host server:<BR><BR>
<BLOCKQUOTE><TT><BR>host# apt-get qemu vde nfs-kernel-server debootstrap<BR></TT></BLOCKQUOTE><BR><BR><B>debootstrap</B> allows the creation of a base Debian or Ubuntu system, and is a very simple method for building chroots and virtual machines quickly.<BR><BR><A href="http://vde.sourceforge.net/">VDE</A> is a virtual network emulator, much like user mode linux's uml_net, allowing a QEMU-emulated machine to connect to the host server's network through a tap interface.<BR><BR>Make sure that your host kernel has support for the "Universal TUN/TAP device driver"; the kernel configuration option for this is named "TUN". If you're running a modularised kernel, there's a good chance that it will<BR>be named 'tun.o'.<BR><BR>Once you have a kernel with tun support, set up a tap interface for the emulated machine to communicate through. In <I>/etc/network/interfaces</I> on your host machine, add the following stanza: 
<P></P><BR><BR>
<BLOCKQUOTE><TT>auto tap0<BR>iface tap0 inet static<BR>address 10.1.6.1<BR>netmask 255.255.255.0<BR>network 10.1.6.0<BR>broadcast 10.1.6.255<BR>vde-switch vde-net</TT></BLOCKQUOTE><BR><BR>Ensure that <I>/dev/net/tun</I> is owned by group <I>vde-net</I> and that you are also a member of that group; add this to your host server's <I>/etc/group</I> file and log out and back in again, if necessary.<BR><BR>Then, bring up the interface:<BR><BR>
<BLOCKQUOTE><TT>host# ifup tap0</TT></BLOCKQUOTE><BR><BR>You'll need a partition with enough spare space on it to hold a basic Debian installation; make sure you have enough room on it to grow in the future. You can probably get away with 300Mb at the minimum. I placed my tree under <I>/nfs/share/arm/</I>.<BR><BR>Now, run debootstrap to download and install the base Debian/arm distribution, and copy a few of the files from your host system into it:<BR><BR>
<BLOCKQUOTE><TT>host# mkdir /nfs/share/arm<BR>host# debootstrap --foreign --arch arm etch /nfs/share/arm<BR>host# cd /nfs/share/arm<BR>host# cp /etc/passwd etc/passwd<BR>host# cp /etc/shadow etc/shadow<BR>host# cp /etc/group etc/group<BR>host# echo "proc /proc proc defaults 0 0" &gt; etc/fstab<BR>host# echo "10.1.6.1:/nfs/share/arm / nfs defaults 0 1" &gt;&gt; etc/fstab</TT></BLOCKQUOTE><BR><BR>debootstrap's <I>--foreign</I> option tells it to only perform the first stage of the bootstrap process, downloading and unpacking the packages. Since we're downloading Debian for a different architecture from that on which we're running on the host server, our host system would not be able to use this new system in a chroot to run the pre- and post-installation scripts.<BR><BR><BR>
<DIV class=serendipity_entry_body>QEMU is well-known as a free replacement for VMware, allowing users to run a PC within a PC. What isn't so well known about QEMU is that, in addition to emulating x86 architectures, it can emulate AMD64, Sparc, MIPS, PPC and ARM CPUs. In the case of the ARM architecture, QEMU provides a convenient, if slow, environment in which development can be done for embedded systems. This article describes the process involved in building a Debian/ARM server running under QEMU. It assumes that Debian is also being used as the host server. Since QEMU's arm emulator has no ability to emulate either IDE or SCSI disks, it will be necessary to install the server on an NFS exported partition. </DIV>
<DIV class=serendipity_entry_extended><A id=extended></A><BR><BR>We're going to use the same server that is being used as the host server for running QEMU as the NFS server for the guest server's root filesystem; an emulated system is slow enough as it is, we don't need to make things worse by having a real ethernet network in between the guest OS and its filesystem (as opposed to a virtual ethernet, in this case).<BR><BR>Share the new directory out via NFS, by adding the following entry to <I>/etc/exports</I>:<BR><BR>
<BLOCKQUOTE><TT>/nfs/share/arm 10.1.6.0/24(rw,no_root_squash,sync)</TT></BLOCKQUOTE><BR><BR>Then export the filesystem:<BR><BR>
<BLOCKQUOTE><TT>host# exportfs -a</TT></BLOCKQUOTE><BR><BR>Download a kernel for arm-linux; there's one provided in the arm-test files on the <A href="http://fabrice.bellard.free.fr/qemu/">qemu website</A> (and a copy <A href="http://iomem.com/zImage.integrator">here</A>.<BR><BR>Place the arm-linux zimage in <I>/usr/local/etc/images/zImage.arm</I>, and then create the following script as <I>/usr/local/bin/start-qemu-arm</I>:<BR><BR>
<BLOCKQUOTE><TT>#!/bin/sh<BR><BR>console="ttyAMA0" # serial console<BR>nfsserver="10.1.6.1" # address of NFS server<BR>nfsdir="/nfs/share/arm" # exported share where debian/arm is installed<BR>address="10.1.6.50" # address for guest server<BR>gateway="10.1.6.1" # default gateway<BR>netmask="255.255.255.0" # subnet mask<BR>hostname="arm.home" # hostname for guest server<BR>device="eth0" # interface that guest server will use<BR>mem=256 # memory for guest server in Mb<BR>tap="/var/run/vde/tap0.ctl" # vde tap socket<BR><BR>kernel="/usr/local/etc/images/zImage.arm" # arm kernel<BR>nfsopts="rsize=8192,wsize=8192,hard,intr,tcp,nolock" # nfs options<BR><BR>consoleopt="console=$console"<BR>nfsrootopt="nfsroot=$nfsserver:$nfsdir,$nfsopts"<BR>ipopt="ip=$address::$gateway:$netmask:$hostname:$device"<BR><BR>init=""<BR><BR>if [ "x$1" == "xsingle" ]<BR>then<BR>init="init=/bin/bash"<BR>fi<BR><BR>vdeq qemu-system-arm -sock $tap -m $mem \<BR>-kernel $kernel -nographic \<BR>-append "$consoleopt root=/dev/nfs $nfsrootopt $ipopt $init"</TT></BLOCKQUOTE><BR><BR>Adjust the parameters at the top of the script to suit your requirements.<BR><BR><BR></DIV></DIV><img src ="http://www.cnblogs.com/WuCountry/aggbug/1404902.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47998/" target="_blank">传诺基亚正在开发Android手机</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>使用 QEMU 进行系统仿真</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404886.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Fri, 06 Mar 2009 11:34:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404886.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1404886.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/06/1404886.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1404886.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1404886.html</trackback:ping><description><![CDATA[<A href="">http://www.cnblogs.com/WuCountry/admin/EditPosts.aspx?opt=1</A><BR><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD width="100%">
<H1>使用 QEMU 进行系统仿真</H1>
<P id=subtitle>机器中的机器</P><IMG class=display-img height=6 alt="" src="http://www.ibm.com/i/c.gif" width=1></TD>
<TD class=no-print width=192></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD width=10><IMG height=1 alt="" src="http://www.ibm.com/i/c.gif" width=10></TD>
<TD width="100%">
<TABLE class=no-print cellSpacing=0 cellPadding=0 width=160 align=right border=0>
<TBODY>
<TR>
<TD width=10><IMG height=1 alt="" src="http://www.ibm.com/i/c.gif" width=10></TD>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=150 border=0>
<TBODY>
<TR>
<TD class=v14-header-1-small>文档选项</TD></TR></TBODY></TABLE>
<TABLE class=v14-gray-table-border cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD class=no-padding width=150>
<TABLE cellSpacing=0 cellPadding=0 width=143 border=0>
<SCRIPT language=JavaScript type=text/javascript>
<!--
document.write('<tr valign="top"><td width="8"><img src="//www.ibm.com/i/c.gif" width="8" height="1" alt=""/></td><td width="16"><img alt="将打印机的版面设置成横向打印模式" height="16" src="//www.ibm.com/i/v14/icons/printer.gif" width="16" vspace="3" /></td><td width="122"><p><b><a class="smallplainlink" href="javascript:print()">打印本页</a></b></p></td></tr>');
//-->
</SCRIPT>

<TBODY>
<TR vAlign=top>
<TD width=8><IMG height=1 alt="" src="http://www.ibm.com/i/c.gif" width=8></TD>
<TD width=16><IMG height=16 alt=将打印机的版面设置成横向打印模式 src="http://www.ibm.com/i/v14/icons/printer.gif" width=16 vspace=3></TD>
<TD width=122>
<P><B><A class=smallplainlink href="javascript:print()" cmImpressionSent="1">打印本页</A></B></P></TD></TR><NOSCRIPT></NOSCRIPT>
<FORM name=email action=https://www.ibm.com/developerworks/secure/email-it.jsp cM1="1"><INPUT type=hidden value="QEMU 是一个面向完整 PC 系统的开源仿真器。除了仿真处理器外，QEMU 还允许仿真所有必要的子系统，如连网硬件和视频硬件。它还允许实现高级概念上的仿真（如对称多处理系统（多达 255 个 CPU）和其他处理器架构（如 ARM 和 PowerPC）。本文将研究 QEMU 及其架构，并展示了如何在 Linux 主机上仿真来宾操作系统。" name=body cM1="1" cM3 cM2="0"><INPUT type=hidden value="使用 QEMU 进行系统仿真" name=subject cM1="1" cM3 cM2="1"><INPUT type=hidden value=cn name=lang cM1="1" cM3 cM2="2">
<SCRIPT language=JavaScript type=text/javascript>
<!--
document.write('<tr valign="top"><td width="8"><img src="//www.ibm.com/i/c.gif" width="8" height="1" alt=""/></td><td width="16"><img src="//www.ibm.com/i/v14/icons/em.gif" height="16" width="16" vspace="3" alt="将此页作为电子邮件发送" /></td><td width="122"><p><a class="smallplainlink" href="javascript:document.email.submit();"><b>将此页作为电子邮件发送</b></a></p></td></tr>');
//-->
</SCRIPT>
 
<TR vAlign=top>
<TD width=8><IMG height=1 alt="" src="http://www.ibm.com/i/c.gif" width=8></TD>
<TD width=16><IMG height=16 alt=将此页作为电子邮件发送 src="http://www.ibm.com/i/v14/icons/em.gif" width=16 vspace=3></TD>
<TD width=122>
<P><A class=smallplainlink href="javascript:document.email.submit();" cmImpressionSent="1"><B><FONT color=#5c81a7 size=2>将此页作为电子邮件发送</FONT></B></A></P></TD></TR><NOSCRIPT></NOSCRIPT></FORM></TBODY></TABLE></TD></TR></TBODY></TABLE><!--START RESERVED FOR FUTURE USE INCLUDE FILES--><!-- this content will be automatically generated across all content areas --><!--END RESERVED FOR FUTURE USE INCLUDE FILES--><BR></TD></TR></TBODY></TABLE>
<P>级别： 初级</P>
<P><A href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#author" cmImpressionSent="1"><FONT color=#5c81a7>M. Tim Jones</FONT></A> (<A href="mailto:mtj@mtjones.com?subject=使用 QEMU 进行系统仿真&amp;cc=tomyoung@us.ibm.com" cmImpressionSent="1"><FONT color=#5c81a7>mtj@mtjones.com</FONT></A>), 咨询工程师, Emulex<BR></P>
<P>2007 年 10 月 22 日</P>
<BLOCKQUOTE>QEMU 是一个面向完整 PC 系统的开源仿真器。除了仿真处理器外，QEMU 还允许仿真所有必要的子系统，如连网硬件和视频硬件。它还允许实现高级概念上的仿真（如对称多处理系统（多达 255 个 CPU）和其他处理器架构（如 ARM 和 PowerPC）。本文将研究 QEMU 及其架构，并展示了如何在 Linux® 主机上仿真来宾操作系统。</BLOCKQUOTE><!--START RESERVED FOR FUTURE USE INCLUDE FILES--><!-- include java script once we verify teams wants to use this and it will work on dbcs and cyrillic characters --><!--END RESERVED FOR FUTURE USE INCLUDE FILES-->
<P><A name=N1005D><SPAN class=atitle>QEMU 是什么？</SPAN></A></P>
<P>目前，简单地将虚拟化称为一种热点技术似乎有些保守。 在 google 搜索 <I>virtualization</I> 一词可得到大约 2200 万条记录。例如，在短短的一个月内，EMC 公司宣布为 VMware 首次公开募股，Citrix Systems 宣布购买 XenSource 的计划，而新起的虚拟化创业公司随处涌现。在虚拟化产品的巨大市场上，不断出现各种新兴的小型市场。但是时下在热议有关虚拟化的首次公开募股和收购时，容易忽略一些其他的现有虚拟化技术。</P>
<P>本文所介绍的一种有趣的虚拟化应用程序 QEMU 并非目前的热门技术。QEMU 应用程序适用于各种设置。可用于来宾操作系统的虚拟化，或作为完整的机器仿真器使用，运行使用主机 CPU 或其他 CPU 架构的操作系统。</P><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%"><BR><IMG height=6 alt="" src="http://www.ibm.com/i/c.gif" width=8 border=0></TD></TR></TBODY></TABLE>
<TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
<TBODY>
<TR align=right>
<TD><IMG height=4 alt="" src="http://www.ibm.com/i/c.gif" width="100%"><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=center><IMG height=16 alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width=16 border=0><BR></TD>
<TD vAlign=top align=right><A class=fbox href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#main" cmImpressionSent="1"><B><FONT color=#5c81a7>回页首</FONT></B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
<P><A name=N1006C><SPAN class=atitle>虚拟化简介</SPAN></A></P>
<P>我们首先简要介绍一下虚拟化，阐述 QEMU 的搭建背景。</P>
<P>本文中介绍的虚拟化实际上指的是<I>平台虚拟化</I>。在物理硬件上，控制程序可能是主机操作系统或管理程序（见图 1）。在某些情况下，主机操作系统就是管理程序。来宾操作系统位于管理程序中。在某些情况下，来宾操作系统与控制程序使用相同的 CPU，而在另外一些情况下，则可能不同（比如 PowerPC 来宾操作系统在 x86 硬件上运行）。</P><BR><A name=figure1><B>图 1. 平台虚拟化的基本架构</B></A><BR><IMG height=115 alt="图 1. 平台虚拟化的基本架构" src="http://www.ibm.com/developerworks/cn/linux/l-qemu/figure1.jpg" width=290> <BR>
<P>您可以通过多种方法实现虚拟化，但是最常见的有三种。第一种称为<I>本地虚拟化（或全虚拟化）</I>。在这种虚拟化中，管理程序实现基本的隔离元素，将物理硬件与来宾操作系统相分离。这种技术首次出现于 1966 年 IBM® CP-40 虚拟机/虚拟内存操作系统中，另外 VMware ESX Server 也使用了此技术。</P>
<P>另一种流行的虚拟化技术称为<I>半虚拟化</I>。在半虚拟化中，控制程序实现了管理程序的应用程序接口（API），它将由来宾操作系统使用。Xen 和 Linux Kernel-based Virtual Machine (KVM) 都使用了半虚拟化技术。</P>
<P>第三种有用的技术称为<I>仿真</I>。仿真，顾名思义，通过模拟完整的硬件环境来虚拟化来宾平台。仿真可通过多种方法实现，即使在同一个解决方案中也是如此。通过仿真实现虚拟化的技术有 QEMU 和 Bochs。</P><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%"><BR><IMG height=6 alt="" src="http://www.ibm.com/i/c.gif" width=8 border=0></TD></TR></TBODY></TABLE>
<TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
<TBODY>
<TR align=right>
<TD><IMG height=4 alt="" src="http://www.ibm.com/i/c.gif" width="100%"><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=center><IMG height=16 alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width=16 border=0><BR></TD>
<TD vAlign=top align=right><A class=fbox href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#main" cmImpressionSent="1"><B><FONT color=#5c81a7>回页首</FONT></B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
<P><A name=N1009E><SPAN class=atitle>QEMU 架构</SPAN></A></P>
<P>我们首先了解一下 QEMU 如何实现仿真。本节将介绍 QEMU 的两种操作模式，以及 QEMU 动态翻译程序的一些有趣特点。</P>
<P><A name=N100A7><SPAN class=smalltitle><STRONG><FONT face=Arial>QEMU 基本操作</FONT></STRONG></SPAN></A></P>
<P>QEMU 支持两种操作模式：用户模式仿真和系统模式仿真。<I>用户模式仿真</I> 允许一个 CPU 构建的进程在另一个 CPU 上执行（执行主机 CPU 指令的动态翻译并相应地转换 Linux 系统调用）。<I>系统模式仿真</I> 允许对整个系统进行仿真，包括处理器和配套的外围设备。</P>
<P>在 x86 主机系统上仿真 x86 代码时，使用 <I>QEMU 加速器</I> 可以实现近似本地的性能。这让我们能够直接在主机 CPU 上执行仿真代码（在 Linux 上通过 kernel 模块执行）。</P>
<P>但是从技术角度看，QEMU 的有趣之处在于其快速、可移植的动态翻译程序。<I>动态翻译程序</I> 允许在运行时将用于目标（来宾）CPU 的指令转换为用于主机 CPU，从而实现仿真。这可以通过一种强制方法实现（将指令从一个 CPU 映射到另一个 CPU），但是情况并非总是这样简单，在某些情况下，根据所翻译的架构，可能需要使用多个指令或行为更改。</P>
<P>QEMU 实现动态翻译的方法是，首先将目标指令转换为<I>微操作</I>。这些微操作是一些编译成对象的 C 代码。然后构建核心翻译程序。它将目标指令映射到微操作以进行动态翻译。这不仅可产生高效率，而且还可以移植。</P>
<P>QEMU 的动态翻译程序还缓存了翻译后的代码块，使翻译程序的内存开销最小化。当初次使用目标代码块时，翻译该块并将其存储为<I>翻译后的代码块</I>。 QEMU 将最近使用的翻译后的代码块缓存在一个 16 MB 的块中。 QEMU 甚至可以通过在缓存中将翻译后的代码块变为无效来支持代码的自我修改。</P>
<P>要了解 QEMU 及其动态翻译程序的更多内部细节，请参阅 <A href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#resources" cmImpressionSent="1"><FONT color=#5c81a7>参考资料</FONT></A> 一节中 Fabrice Bellard（QEMU 的作者）所撰写的有趣文章。</P>
<P><A name=N100D5><SPAN class=smalltitle><STRONG><FONT face=Arial>受支持的外围设备</FONT></STRONG></SPAN></A></P>
<P>将 QEMU 作为 PC 系统仿真器使用可提供各种外围设备。需要的标准外围设备包括硬件 Video Graphics Array (VGA) 仿真器、PS/2 鼠标和键盘、集成开发环境（IDE）硬盘和 CD-ROM 接口，以及软盘仿真。另外，QEMU 包括对 NE2000 Peripheral Controller Interconnect (PCI) 网络适配器、串行端口、大量的声卡和 PCI Universal Host Controller Interface (UHCI) Universal Serial Bus (USB) 控制器（带虚拟 USB 集线器）的仿真。Processor symmetric multiprocessing (SMP) 支持也得到了对 255 个 CPU 的支持。</P>
<P>除了仿真标准 PC 或 ISA PC（不带 PCI 总线）外，QEMU 还可以仿真其他非 PC 硬件，如 ARM Versatile 基线板（使用 926E）和 Malta million instructions per second (MIPS) 板。对于各种其他平台，包括 Power Macintosh G3 (Blue &amp; White) 和 Sun-4u 平台，都能正常工作。</P><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%"><BR><IMG height=6 alt="" src="http://www.ibm.com/i/c.gif" width=8 border=0></TD></TR></TBODY></TABLE>
<TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
<TBODY>
<TR align=right>
<TD><IMG height=4 alt="" src="http://www.ibm.com/i/c.gif" width="100%"><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=center><IMG height=16 alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width=16 border=0><BR></TD>
<TD vAlign=top align=right><A class=fbox href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#main" cmImpressionSent="1"><B><FONT color=#5c81a7>回页首</FONT></B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
<P><A name=N100E1><SPAN class=atitle>构建和安装 QEMU </SPAN></A></P>
<P>构建和安装 QEMU 与使用标准的 GNU 工具一样简单。下载并打开 QEMU 发行版之后，<CODE>configure</CODE>、<CODE>make</CODE>，然后 <CODE>make install</CODE>，任务就完成了（见清单 1）。</P><BR><A name=list1><B>清单 1. 构建 QEMU 仿真器</B></A><BR>
<TABLE cellSpacing=0 cellPadding=0 width="60%" border=0>
<TBODY>
<TR>
<TD class=code-outline><PRE class=displaycode>                
$ wget http://fabrice.bellard.free.fr/qemu/qemu-0.9.0.tar.gz
$ tar xfvz qemu-0.9.0.tar.gz
$ cd qemu-0.9.0
$ ./configure
$ make
$ make install
$
</PRE></TD></TR></TBODY></TABLE><BR>
<P>此过程不仅可以为当前的目标架构创建可执行的 <CODE>qemu</CODE> 映像，而且可以为其他架构（包括 ARM、MIPS、PowerPC、68k 和 SPARC）创建一组映像。 这样，您就可以引导为不同目标架构构建的 Linux 内核。</P>
<P>如果主机操作系统和来宾操作系统运行于相同的处理器架构之上，那么您可以使用 QEMU 加速器（KQEMU）实现近似本地的性能。KQEMU 是一个驱动程序（Linux 的内核模块），允许用户模式的代码和内核代码直接在主机 CPU 上执行。构建 QEMU 加速器与构建 QEMU 本身相同（见清单 2）。</P><BR><A name=list2><B>清单 2. 构建 QEMU 加速器</B></A><BR>
<TABLE cellSpacing=0 cellPadding=0 width="60%" border=0>
<TBODY>
<TR>
<TD class=code-outline><PRE class=displaycode>                
$ http://fabrice.bellard.free.fr/qemu/kqemu-1.3.0pre11.tar.gz
$ tar xvfz kqemu-1.3.0pre11.tar.gz
$ cd kqemu-1.3.0pre11
$ ./configure
$ make
$ make install
</PRE></TD></TR></TBODY></TABLE><BR>
<P>您可以在很多操作系统，包括 Microsoft® Windows®、FreeBSD® 和 Linux 上编译和安装 KQEMU。构建 QEMU 加速器之后，使用以下命令在 Linux 中安装该加速器：</P>
<TABLE cellSpacing=0 cellPadding=0 width="60%" border=0>
<TBODY>
<TR>
<TD class=code-outline><PRE class=displaycode>$ insmod kqemu.ko
$
</PRE></TD></TR></TBODY></TABLE><BR><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%"><BR><IMG height=6 alt="" src="http://www.ibm.com/i/c.gif" width=8 border=0></TD></TR></TBODY></TABLE>
<TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
<TBODY>
<TR align=right>
<TD><IMG height=4 alt="" src="http://www.ibm.com/i/c.gif" width="100%"><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=center><IMG height=16 alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width=16 border=0><BR></TD>
<TD vAlign=top align=right><A class=fbox href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#main" cmImpressionSent="1"><B><FONT color=#5c81a7>回页首</FONT></B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
<P><A name=N10122><SPAN class=atitle>使用 QEMU </SPAN></A></P>
<P>现在考察一下使用 QEMU 虚拟化另一台带典型的桌面 GNU/Linux 环境的机器的情况。仿真另一台机器与处理新计算机类似。 第一步是安装操作系统。新计算机必须要有安装操作系统的空间，因此需要一个硬盘。</P>
<P>QEMU 提供了一条特殊的命令创建硬盘，此命令称为 <CODE>qemu-img</CODE>。此工具可以创建各种格式的映像，但最佳的格式（对于 <CODE>qemu</CODE>）称为 <CODE>qcow</CODE>（或 <CODE>qemu</CODE> 写时复制）。这种格式的优点在于磁盘映像的大小与表示映像的物理文件的大小不同。换言之，该格式允许实现更紧凑的磁盘映像。例如，一个空的 4GB 磁盘映像只需要 16KB 的空间。</P>
<P>对于 <CODE>qemu-img</CODE>，您需要提供操作类型（<CODE>create</CODE> 创建新磁盘映像）、格式（<CODE>qcow</CODE> 用于 <CODE>qemu</CODE> 映像格式）、大小和磁盘映像的名称。本例中仿真的机器用于一个在 Flash 中使用的微型 Linux 发行版。因此，将 128MB 的磁盘映像创建为：</P>
<TABLE cellSpacing=0 cellPadding=0 width="60%" border=0>
<TBODY>
<TR>
<TD class=code-outline><PRE class=displaycode>$ qemu-img create -f qcow disk.img 128M
Formating 'disk.img', fmt=qcow, size=131072 kB
$
</PRE></TD></TR></TBODY></TABLE><BR>
<P>注意，如果您计划安装通用操作系统，如 Windows、Linux 或 FreeBSD，则需要更大的磁盘空间。此操作的结果是仿真时出现一个 disk.img 文件，其形式是一个 128MB 的磁盘。</P>
<P>现在已经创建好硬盘，可以在上面安装新操作系统。出于演示的目的，我将使用一个较小的 Linux 发行版 cfLinux。cfLinux 的标准用法是作为基于 Linux 的小型嵌入式系统使用，此系统应适用网关、无线入口点、防火墙或路由器。您可以使用 <CODE>wget</CODE> 下载 ISO 格式的发行版：</P>
<TABLE cellSpacing=0 cellPadding=0 width="60%" border=0>
<TBODY>
<TR>
<TD class=code-outline><PRE class=displaycode>wget ftp://ftp.cflinux.fu/pub/cflinux/iso/cflinux-1.0.iso
</PRE></TD></TR></TBODY></TABLE><BR>
<P>ISO 映像是常见的 CD-ROM 格式（在其他地方称为 ISO 9660 文件系统）。</P>
<P>现在，您已经仿真了硬盘（disk.img）和 CD-ROM，您可以在上面安装操作系统。下一步是在硬盘上安装操作系统。简单地使用 <CODE>qemu</CODE> 即可完成此任务：</P>
<TABLE cellSpacing=0 cellPadding=0 width="60%" border=0>
<TBODY>
<TR>
<TD class=code-outline><PRE class=displaycode>$ qemu -hda disk.img -cdrom /root/cflinux-1.0.iso -boot d
$
</PRE></TD></TR></TBODY></TABLE><BR>
<P>使用 <CODE>qemu</CODE> 时，您使用 <CODE>hda</CODE> 选项指定硬盘映像，使用 <CODE>cdrom</CODE> 选项指定 cdrom（ISO 映像所在的文件）。<CODE>boot</CODE> 选项指定从 CD-ROM 引导。参数 <CODE>d</CODE> 指定从 CD-ROM 引导，其中 <CODE>a</CODE> 指定从软盘引导，<CODE>c</CODE> 指定从硬盘引导（默认），而 <CODE>n</CODE> 指定从网络引导。发出此命令后，出现一个表示已仿真机器的新 QEMU 窗口（见图 2）。</P><BR><A name=figure2><B>图 2. 准备使用 QEMU 将 cfLinux 安装到仿真磁盘上</B></A><BR><IMG height=278 alt="图 2. 准备使用 QEMU 将 cfLinux 安装到仿真磁盘上" src="http://www.ibm.com/developerworks/cn/linux/l-qemu/figure2.jpg" width=500> <BR>
<P>遵循安装指令，按照 CD-ROM 安装完成在仿真硬盘上的 ISO 安装。安装程序要求您重新启动。此时，您可以终止仿真（在 <CODE>qemu</CODE> 窗口中按 Ctrl-C）。您可以使用以下命令引导最新安装的操作系统：</P>
<TABLE cellSpacing=0 cellPadding=0 width="60%" border=0>
<TBODY>
<TR>
<TD class=code-outline><PRE class=displaycode>$ qemu -hda disk.img
$
      </PRE></TD></TR></TBODY></TABLE><BR>
<P>此命令只是说明使用 disk.img 映像文件表示的硬盘仿真标准 PC（默认选项）。Linux 映像从仿真硬盘开始引导，导致出现 QEMU 窗口，如图 3 所示。</P><BR><A name=figure3><B>图 3. 从仿真硬盘引导最新安装的 cfLinux</B></A><BR><IMG height=278 alt="图 3. 从仿真硬盘引导最新安装的 cfLinux" src="http://www.ibm.com/developerworks/cn/linux/l-qemu/figure3.jpg" width=500> <BR>
<P>这再简单不过了。实际上，您可以按照同样的顺序安装和引导任何种类的操作系统（Linux 产品发行版、Windows 或其他）。</P><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%"><BR><IMG height=6 alt="" src="http://www.ibm.com/i/c.gif" width=8 border=0></TD></TR></TBODY></TABLE>
<TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
<TBODY>
<TR align=right>
<TD><IMG height=4 alt="" src="http://www.ibm.com/i/c.gif" width="100%"><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=center><IMG height=16 alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width=16 border=0><BR></TD>
<TD vAlign=top align=right><A class=fbox href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#main" cmImpressionSent="1"><B><FONT color=#5c81a7>回页首</FONT></B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
<P><A name=N101C7><SPAN class=atitle>其他仿真器</SPAN></A></P>
<P>虽然 QEMU 是一种极好的仿真环境，但是其他环境也值得研究一下。 Wine 是 Windows API 的一个开源实现，允许您在没有 Windows 操作系统的情况下运行 Windows 程序。但是如 Wine 缩略词所表示的那样，<I>Wine 不是仿真器</I>。相反，Wine 实现了一组 API，这些 API 允许执行 x86 架构的应用程序。因此，运行在 Wine 上的应用程序可以很好地执行。</P>
<P>与 QEMU 类似的仿真器是 Bochs。Bochs 是一种机器仿真器，它不仅可以仿真 Intel® 的 i386™、i486™、Pentium®、Pentium Pro 和 Advanced Micro Devices 的 AMD64 CPU，还可以仿真常见 PC 外围设备，如磁盘、内存、显示器和网络设备。Bochs 已被用于仿真 Linux、DOS 和 Windows 95/98/XP/2000/NT® 操作系统。</P><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt="" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" width="100%"><BR><IMG height=6 alt="" src="http://www.ibm.com/i/c.gif" width=8 border=0></TD></TR></TBODY></TABLE>
<TABLE class=no-print cellSpacing=0 cellPadding=0 align=right>
<TBODY>
<TR align=right>
<TD><IMG height=4 alt="" src="http://www.ibm.com/i/c.gif" width="100%"><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=center><IMG height=16 alt="" src="http://www.ibm.com/i/v14/icons/u_bold.gif" width=16 border=0><BR></TD>
<TD vAlign=top align=right><A class=fbox href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#main" cmImpressionSent="1"><B><FONT color=#5c81a7>回页首</FONT></B></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
<P><A name=N101E0><SPAN class=atitle>结束语</SPAN></A></P>
<P>将 QEMU 作为机器仿真器使用让您能够试验各种操作系统，因为您可能没有多余的机器直接进行试验。ReactOS 就是一个这样的例子，它是一个开源的 Windows XP 兼容的操作系统（其仿真如图 4 所示）。ReactOS 的目标是与 Windows XP 实现二进制兼容，因此您可以直接在 ReactOS 上运行针对 Windows XP 构建的应用程序。请参阅 <A href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#resources" cmImpressionSent="1"><FONT color=#5c81a7>参考资料</FONT></A> 一节了解当前应用程序兼容性的细节。</P><BR><A name=figure4><B>图 4. 为 ReactOS 仿真标准 PC</B></A><BR><IMG height=375 alt="图 4. 为 ReactOS 仿真标准 PC" src="http://www.ibm.com/developerworks/cn/linux/l-qemu/figure4.jpg" width=500> <BR>
<P>您可以在 Free Operating Systems Zoo 找到 ReactOS 和很多其他操作系统的 QEMU 映像（请参阅 <A href="http://www.ibm.com/developerworks/cn/linux/l-qemu/#resources" cmImpressionSent="1"><FONT color=#5c81a7>参考资料</FONT></A> 一节了解更多细节）。这些映像包括 live CD 映像、软盘映像或硬盘映像（<CODE>qcow</CODE> 格式）。QEMU 是尝试新操作系统的一种良好方法，而且不用花时间安装。</P><BR><BR>
<P><A name=resources><SPAN class=atitle>参考资料 </SPAN></A></P><B>学习</B><BR>
<UL>
<LI>您可以参阅本文在 developerWorks 全球站点上的 <A href="http://www.ibm.com/developerworks/linux/library/l-qemu/?S_TACT=105AGX52&amp;S_CMP=cn-a-l" target=_blank cmImpressionSent="1"><FONT color=#5c81a7>英文原文</FONT></A>。<BR><BR>
<LI>查看 Fabrice Bellard 的 “<A href="http://www.usenix.org/publications/library/proceedings/usenix05/tech/freenix/full_papers/bellard/bellard.pdf" cmImpressionSent="1"><FONT color=#5c81a7>QEMU, a Fast and Portable Dynamic Translator</FONT></A>”（PDF），了解 QEMU 动态翻译的内部细节。<BR><BR>
<LI>在 “<A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/cn/linux/l-linuxvirt" cmImpressionSent="1"><FONT color=#5c81a7>虚拟 Linux</FONT></A>”（developerWorks，2006 年 12 月）中，了解其他 Linux 虚拟化选项。<BR><BR>
<LI>“<A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/cn/linux/l-linux-kvm/" cmImpressionSent="1"><FONT color=#5c81a7>探索 Linux 内核虚拟机</FONT></A>”（developerWorks，2007 年 4 月）介绍了 Linux KVM 架构和它与内核紧密集成可以改变使用 Linux 的方式的原因。<BR><BR>
<LI>在 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/cn/linux/" cmImpressionSent="1"><FONT color=#5c81a7>developerWorks Linux 专区</FONT></A> 中，查找更多面向 Linux 开发人员的资源，查看 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/cn/linux/top10/" cmImpressionSent="1"><FONT color=#5c81a7>最受欢迎的文章和教程</FONT></A>。<BR><BR>
<LI>查看 developerWorks 上所有的 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/cn/views/linux/articles.jsp?view_by=search&amp;search_by=linux+%E6%8A%80%E5%B7%A7" cmImpressionSent="1"><FONT color=#5c81a7>Linux 技巧</FONT></A> 和 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/cn/views/linux/tutorials.jsp?S_TACT=105AGX03&amp;S_CMP=ART" cmImpressionSent="1" doneOnce="true"><FONT color=#5c81a7>Linux 教程</FONT></A>。<BR><BR>
<LI>随时关注 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/offers/techbriefings/?S_TACT=105AGX52&amp;S_CMP=cn-a-l" cmImpressionSent="1"><FONT color=#5c81a7>developerWorks 技术事件和网络广播</FONT></A>。 <BR><BR></LI></UL><BR><B>获得产品和技术</B><BR>
<UL>
<LI>从 Fabrice Bellard 的 Web 站点下载 <A href="http://fabrice.bellard.free.fr/qemu/" cmImpressionSent="1"><FONT color=#996699>QEMU 开源处理器仿真器和 QEMU 加速器</FONT></A>。在该站点中，您还可以找到文档、API 和 QEMU 的当前状态。 <BR><BR>
<LI>了解更多关于 <A href="http://www.cflinux.hu/" cmImpressionSent="1"><FONT color=#5c81a7>cfLinux</FONT></A> 的信息；作者使用这个小型的发行版展示了在 QEMU 机器中安装操作系统。<BR><BR>
<LI>从 <A href="http://www.oszoo.org/wiki/index.php/Category:OS_images" cmImpressionSent="1"><FONT color=#5c81a7>Free Operating Systems Zoo</FONT></A> 获取预包装的映像，为自己节省时间。在此站点上，您将找到很多操作系统映像，从标准的 Linux 发行版到其他更稀有的操作系统（Plan 9、OpenSolaris、MINUX、ReactOS、Darwin、MenuetOS 等等）都有。下载某个磁盘映像之后，您将拥有可以开始引导的磁盘映像。<BR><BR>
<LI><A href="http://www.reactos.org/" cmImpressionSent="1"><FONT color=#5c81a7>ReactOS</FONT></A> 是一种开源的 Windows 二进制兼容的操作系统，允许执行多个 Windows 应用程序。<BR><BR>
<LI><A href="http://www.winehq.org/" cmImpressionSent="1"><FONT color=#5c81a7>Wine</FONT></A> 允许在非原生 Windows 操作系统（如 Linux）上执行 Windows 应用程序。<BR><BR>
<LI><A href="http://bochs.sourceforge.net/" cmImpressionSent="1"><FONT color=#5c81a7>Bochs</FONT></A> 与 QEMU 类似，因为它提供了完全的系统仿真。<BR><BR>
<LI><A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/offers/sek/" cmImpressionSent="1"><FONT color=#5c81a7>订购 SEK for Linux</FONT></A>，这是两张 DVD，其中包含了 IBM 在 Linux 平台上的最新试用软件，包括 DB2®、Lotus®、Rational®、Tivoli® 和 WebSphere®。<BR><BR>
<LI>使用可从 developerWorks 直接下载的 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/downloads/?S_TACT=105AGX52&amp;S_CMP=cn-a-l" cmImpressionSent="1"><FONT color=#5c81a7>IBM 试用软件</FONT></A> 构建您的下一个 Linux 开发项目。<BR><BR></LI></UL><BR><B>讨论</B><BR>
<UL>
<LI>加入 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/community?S_TACT=105AGX52&amp;S_CMP=cn-a-l" cmImpressionSent="1"><FONT color=#5c81a7>developerWorks 社区</FONT></A>，参与 <A onmouseover=linkQueryAppend(this) href="http://www.ibm.com/developerworks/spaces/?S_TACT=105AGX03&amp;S_CMP=ART" cmImpressionSent="1" doneOnce="true"><FONT color=#5c81a7>新 developerWorks 空间</FONT></A> 中的 blog、论坛、podcast 和社区主题。</LI></UL><BR></TD></TR></TBODY></TABLE><img src ="http://www.cnblogs.com/WuCountry/aggbug/1404886.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47998/" target="_blank">传诺基亚正在开发Android手机</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[译]6.1. Data Structures Featured in This Chapter 本章涉及到的数据结构</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/02/1401818.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Mon, 02 Mar 2009 14:49:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/02/1401818.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1401818.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/02/1401818.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1401818.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1401818.html</trackback:ping><description><![CDATA[<P>目录：<A href="/WuCountry/archive/2008/11/15/1333960.html">http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html</A><BR>&nbsp;<BR>[不提供插图，读者最好从网上下载源书]</P>
<P>6.1. Data Structures Featured in This Chapter 本章涉及到的数据结构<BR>Here are a few key data structure types used by the PCI layer. There are many others, but the following ones are all we need to know for our overview in this book. The first one is defined in include/linux/mod_devicetable.h, and the other two are defined in include/linux/pci.h.<BR>这里有一些PCI层会使用到的关键数据结构类型。有很多其它的数据类型，但下面的这些是本书中一直提及到的。第一个是定义在include/linux/mod_devicetable.h中，其它的两个定义在include/linux/pci.h中。</P>
<P>pci_device_id</P>
<P>Device identifier. This is not a local ID used by Linux, but an ID defined accordingly to the PCI standard. The later section "Registering a PCI NIC Device Driver" shows the ID's definition, and the later section "Example of PCI NIC Driver Registration" presents an example.<BR>设备标识。这不是一个本地的由Linux所使用的ID，而是一个根据PCI标准定义的ID。在后面的一节“注册PCI　NIC设备驱动”中会展示这个ID的定义，其后的“一个PCI　NIC设备注册的例子”一节是会有一个例子。</P>
<P>pci_dev</P>
<P>Each PCI device is assigned a pci_dev instance, just as network devices are assigned net_device instances. This is the structure used by the kernel to refer to a PCI device.<BR>每一个PCI设备就是一个指定的pci_dev实例，只有网络设备才会指定为net_device实例。这个数据结构就是内核用于引用到一个PCI设备。</P>
<P>pci_driver</P>
<P>Defines the interface between the PCI layer and the device drivers. This structure consists mostly of function pointers. All PCI devices use it. See the later section "Example of PCI NIC Driver Registration" for its definition and an example of its initialization.<BR>用于在PCI层和设备驱动之间定义接口。这个结构包括了大多数函数指针。所有的CPI设备都使用它。在后面的一节中有一个它的定义和初始化的示例。</P>
<P><BR>PCI device drivers are defined by an instance of a pci_driver structure. Here is a description of its main fields, with special attention paid to the case of NIC devices. The function pointers are initialized by the device driver to point to appropriate functions within that driver.<BR>PCI设备驱动由一个pci_driver结构的实例所定义。这里对于它的主要成员有些说明，重点关注的是NIC设备这种情况。它的函数指针由设备驱动指向相关驱动的适当函数。</P>
<P>char *name</P>
<P>Name of the driver.<BR>设备名。</P>
<P><BR>const struct pci_device_id *id_table</P>
<P>Vector of IDs the kernel will use to associate devices to this driver. The section "Example of PCI NIC Driver Registration" shows an example.<BR>一个内核会用于关联到设备驱动的向量ID。</P>
<P><BR>int (*probe)(struct pci_dev *dev, const struct pci_device_id *id)</P>
<P>Function invoked by the PCI layer when it finds a match between a device ID for which it is seeking a driver and the id_table mentioned previously. This function should enable the hardware, allocate the net_device structure, and initialize and register the new device.[*] In this function, the driver also allocates any additional data structures (e.g., buffer rings used during transmission or reception) that it may need to work properly.<BR>当PCI设备在设备ID中查找一个匹配的设备时，就调由PCI层调用这个函数。这个ID用于查找前面提到过的驱动和id_table。这个函数应该让硬件使能，分配net_device结构，并初始化和注册新的设备。在这个函数中，驱动同样会分配一些让它正常工作的额外的数据结构（例如，用于数据传输和接收的缓存区）。</P>
<P>[*] NIC registration is covered in Chapter 8.</P>
<P>void (*remove)(struct pci_dev *dev)</P>
<P>Function invoked by the PCI layer when the driver is unregistered from the kernel or when a hot-pluggable device is removed. It is the counterpart of probe and is used to clean up any data structure and state.<BR>当驱动从内核中移出，或者热插拨设备从系统中移走时，PCI层会调用这个函数。它是与探测器相对的功能，用于清除数据结构和状态。</P>
<P>Network devices use this function to release the allocated I/O ports and I/O memory, to unregister the device, and to free the net_device data structure and any other auxiliary data structure that could have been allocated by the device driver, usually in its probe function.<BR>网络设备用这个函数来释放已经分配的IO端口和IO内存，反注册设备，并释放net_device数据结构和其它的可能已经分配给设备驱动的辅助数据结构，通常是它的探测函数。</P>
<P>int (*suspend)(struct pci_dev *dev, pm_message_t state)</P>
<P>int (*resume)(struct pci_dev *dev)</P>
<P>Functions invoked by the PCI layer when the system goes into suspend mode and when it is resumed, respectively. See the later section "Power Management and Wake-on-LAN."<BR>这两个函数是系统进入挂起模式和从该模式中恢复时由PCI层调用的。</P>
<P><BR>int (*enable_wake)(struct pci_dev *dev, u32 state, int enable)</P>
<P>With this function, a driver can enable or disable the capability of the device to wake the system up by generating specific Power Management Event signals. See the later section "Power Management and Wake-on-LAN."<BR>利用这两个函数，一个驱动可以使能或者去使能设备生成特殊的电源管理事件来唤醒系统的能力。</P>
<P>struct pci_dynids dynids</P>
<P>Dynamic IDs. See the following section.<BR>动态ID。</P>
<P>See the later section "Example of PCI NIC Driver Registration" for an example of initialization of a pci_driver instance.</P>
<P>&nbsp;</P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1401818.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47996/" target="_blank">7月编程语言排行榜</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>cifs和glibc编译</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1401076.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sun, 01 Mar 2009 14:41:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1401076.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1401076.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1401076.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1401076.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1401076.html</trackback:ping><description><![CDATA[1、今天的glibc还是没有编译通过！不知道是我的虚拟机问题，还是因为版本不兼容问题；<BR><BR>2、可以直接在Linux中访问Windows的目录：<BR>（1）、Windows共享一个目录；<BR>例如共享名为：shared<BR>可访问者为：vm_user<BR>密码为：test<BR><BR>（2）、在编译Linux内核时，对网络支持cifs文件系统；<BR><BR>（3）、加载cifs.ko模块；<BR><BR>（4）、挂载文件系统：<BR>mount -t cifs //192.168.127.1/test -o username="vm_user" /mnt/host&nbsp;<BR><BR>Busybox的mount命令不行；Window下如果使用Eeveryone共享的话，Linux只能访问目录，但不能访问文件！<BR><BR>（3）、gcc编译时间太长了，近1个小时，还没有完的迹象！郁闷！<img src ="http://www.cnblogs.com/WuCountry/aggbug/1401076.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47995/" target="_blank">Google Voice 上手</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[译]Chapter 6. The PCI Layer and Network Interface Cards 第6章，PCI层和网络接口卡</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400826.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sun, 01 Mar 2009 07:06:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400826.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1400826.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400826.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1400826.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1400826.html</trackback:ping><description><![CDATA[<P>目录：<A href="/WuCountry/archive/2008/11/15/1333960.html">http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html</A><BR>&nbsp;<BR>[不提供插图，读者最好从网上下载源书]<BR>&nbsp;&nbsp; Chapter 6. The PCI Layer and Network Interface Cards 第6章，PCI层和网络接口卡<BR>Given the popularity of the PCI bus, on the x86 as well as other architectures, we will spend a few pages on it so that you can understand how PCI devices are managed by the kernel, with special emphasis on network devices. This chapter will help you find a context for the code about device registration we will see in Chapter 8. You will also learn a bit about how PCI handles some nifty kernel features such as probing and power management. For an in-depth discussion of PCI, such as device driver design, PCI bus features, and implementation details, refer to Linux Device Drivers and Understanding the Linux Kernel, as well as PCI specifications.<BR>以最流行的PCI总线为例，在x86系统上，其它体系结构也一样，我们会花几页在这个上面。这样我们可以了解PIC设备是如何被内核管理的，重点是在网络设备上。本章会帮助你发现一些在第8章中才会看到的一些关于设备注册的代码内容。你同样会学习一些关于PCI是如何处理一些俏皮的内核特性，如何监测和电源管理。为了更深入的讨论PCI，例如设备驱动设计，PCI总线特性，以及实现的细节，可以参考Linux设备驱动设计和深入理解Linux内核。</P>
<P>The PCI subsystem (also known as the PCI layer ) in the kernel provides all the generic functions that are used in common by various PCI device drivers. This subsystem takes a lot of work off the shoulders of the programmer for each individual device, lets drivers be written in a clean manner, and makes it easier for the kernel to collect and maintain information about the devices, such as accounting information and statistics.<BR>在内核中的PCI子系统，也就是众所周知的PCI层，提供了所有可以用于大多数PCI设备驱动的通用功能。这个子系统包括了很多帮助程序员开发每个独立设备的工作，让驱动的编写方式很清楚，并且让它可以更加容易的在内核中收集和维护。例如，信息统计。</P>
<P><BR>In this chapter, we will see the meaning of a few key data structures used by the PCI layer and how these structures are initialized by one common NIC device driver. I'll conclude with a few words on the PCI power management and Wake-on-LAN features.<BR>在这一章，我们会看到几个用于PCI层的关键数据结构的含义，以及这些数据结构是如何被通用的NIC设备驱动所化初始化的。我们会包括一些PCI电源管理的词汇以及局域网唤醒特性！&nbsp; <BR></P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1400826.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47995/" target="_blank">Google Voice 上手</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[译]5.11. Functions and Variables Featured in This Chapter 本章的函数，变量和特性</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400818.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sun, 01 Mar 2009 06:49:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400818.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1400818.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400818.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1400818.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1400818.html</trackback:ping><description><![CDATA[<P>目录：<A href="/WuCountry/archive/2008/11/15/1333960.html">http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html</A><BR>&nbsp;<BR>[不提供插图，读者最好从网上下载源书]<BR>&nbsp;&nbsp;&nbsp; </P>
<P>5.11. Functions and Variables Featured in This Chapter 本章的函数，变量和特性<BR>Table 5-1 summarizes the functions, macros, variables, and data structures introduced in this chapter.<BR>表5－1是本章所涉及到的一些函数，宏，变量以及数据结构。</P>
<P>Table 5-1. Functions, macros, variables, and data structures related to system </P>
<P>Functions and macros</P>
<P>initialization Name&nbsp;&nbsp; <BR>request_irq&nbsp;&nbsp;&nbsp;<BR>free_irq</P>
<P>Description &nbsp;&nbsp;&nbsp;<BR>Registers and releases, respectively, a callback handler for an IRQ line. The registration can be exclusive or shared.<BR>分别用于注册和释放在IRQ线路上的回调句柄！<BR>&nbsp;<BR>request_region</P>
<P>release_region<BR>&nbsp;Allocates and releases I/O ports and I/O memory.<BR>分配和释放IO端口和IO内存<BR>&nbsp;<BR>call_usermodehelper<BR>&nbsp;Invokes a user-space helper application.<BR>调用用户空间的帮助应用程序。<BR>&nbsp;<BR>module_param<BR>&nbsp;Macro used to define configuration parameters for modules.<BR>模块参数<BR>&nbsp;<BR>net_dev_init<BR>&nbsp;Initializes a piece of the networking code at boot time.<BR>在启动时初始化<BR>&nbsp;<BR>Global variables<BR>&nbsp;<BR>dev_boot_phase<BR>&nbsp;Boolean flag used by legacy code to enforce the execution of net_dev_init before NIC device drivers register themselves.<BR>逻辑标志位，在老的代码中用于强迫NIC设备驱动在注册net_dev_init之前来执行。</P>
<P>irq_desc<BR>&nbsp;Pointer to the vector of IRQ descriptors.<BR>打印IRQ向量的描述信息。<BR>&nbsp;<BR>Data structure<BR>&nbsp;&nbsp; <BR>struct irq_action<BR>&nbsp;Each IRQ line is defined by an instance of this structure. Among other fields, it includes a callback function.<BR>每一个IRQ线路都定义了一个这个数据结构的实例。和其它字段一起，还包括一个回调函数　。<BR>&nbsp;<BR>net_device<BR>&nbsp;Describes a network device.<BR>&nbsp;一个网络设备的描述。<BR></P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1400818.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47995/" target="_blank">Google Voice 上手</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[译]5.10. Tuning via /procs Filesystem 通过/proc文件系统来调整内核模块</title><link>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400815.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sun, 01 Mar 2009 06:40:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400815.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1400815.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/03/01/1400815.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1400815.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1400815.html</trackback:ping><description><![CDATA[<P>目录：<A href="/WuCountry/archive/2008/11/15/1333960.html">http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html</A><BR>&nbsp;<BR>[不提供插图，读者最好从网上下载源书]</P>
<P><BR>5.10. Tuning via /procs Filesystem 通过/proc文件系统来调整内核模块<BR>Figure 5-5 shows the files that can be used either to tune or to view the status of configuration parameters related to the topics covered in this chapter.<BR>图5－5显示了这些可以用于调整和查看配置状态的文件。这些配置状态参数都会在本章涉及到。</P>
<P>In /proc/sys/kernel are the files modprobe and hotplug that can change the pathnames of the two programs introduced earlier in the section "User-Space Helpers."<BR>在proc/sys/kernle中是一些模块探测文件和可以修改路径名的热插拨设备。这两个程序都已经在前面一节“用户空间助手”讲过了。</P>
<P>A few files in /proc export the values within internal data structures and configuration parameters, which are useful to track what resources were allocated by device drivers, shown earlier in the section "Basic Goals of NIC Initialization." For some of these data structures, a user-space command is provided to print their contents in a more user-friendly format. For example, lsmod lists the modules currently loaded, using /proc/modules as its source of information.<BR>在/proc中有一些文件展示了内部数据结构的值和配置参数，这些信息可以跟踪设备驱动的资源分配情况，这些在前面的章节“NIC初始化的基础全局变量”已经讲过。有些数据结构，有一个用户空间的命令提供了可以友好方式打印它们内容。例如，lsmod列出当前加载的模块，这是使用/proc/modules作为它的资源信息。</P>
<P>In /proc/net, you can find the files created by net_dev_init, via dev_proc_init and dev_mcast_init (see the earlier section "Initializing the Device Handling Layer: net_dev_init"):<BR>在proc/net/中，你要以发现一些由net_dev_init通过dev_proc_init和dev_mcast_init创建的文件，（参见。。。）</P>
<P><BR>dev</P>
<P>Displays, for each network device registered with the kernel, a few statistics about reception and transmission, such as bytes received or transmitted, number of packets, errors, etc.<BR>对于每一个注册到内核中的设备，用dev显示一些关于接收和传输的统计信息，例如接收和传输的字节数，包数，错误等。</P>
<P>dev_mcast</P>
<P>Displays, for each network device registered with the kernel, the values of a few parameters used by IP multicast.<BR>显示一些用于IP多播的参数。</P>
<P>wireless</P>
<P>Similarly to dev, for each wireless device, prints the values of a few parameters from the wireless block returned by the dev-&gt;get_wireless_stats virtual function. Note that dev-&gt;get_wireless_stats returns something only for wireless devices, because those allocate a data structure to keep those statistics (and so /proc/net/wireless will include only wireless devices).<BR>与dev很类似，对于每一个无线设备，用于打印无线设备块的一些参数，这些数据是通过dev-&gt;get_wrieless_stats虚函数返回的。注意到，dev-&gt;get_wrieless_stats只为无线设备的一些数据，因为分配的这些数据结构保留这些统计。</P>
<P>softnet_stat</P>
<P>Exports statistics about the software interrupts used by the networking code. See Chapter 12.<BR>用于暴露一些用于网络代码的软中断。参见第12章。</P>
<P>Figure 5-5. /proc files related to the routing subsystem</P>
<P><BR>There are other interesting directories, including /proc/drivers, /proc/bus, and /proc/irq, for which I refer you to Linux Device Drivers. In addition, kernel parameters are gradually being moved out of /proc and into a directory called /sys, but I won't describe the new system for lack of space.<BR>这还有其它一些有趣的目录，包括/proc/drivers，/proc/bus，以及/poc/irq，对于每一个，都推荐去看看Linux设备驱动开发一书。另外，内核参数已经慢慢的从proc中移出，并添加在一个sys目录中，因为篇愊有限，这里不就详细说明了。<BR></P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1400815.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47995/" target="_blank">Google Voice 上手</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[译]5.9. Virtual Devices 虚拟设备</title><link>http://www.cnblogs.com/WuCountry/archive/2009/02/24/1396886.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Mon, 23 Feb 2009 16:26:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/02/24/1396886.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1396886.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/02/24/1396886.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1396886.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1396886.html</trackback:ping><description><![CDATA[<P>目录：<A href="/WuCountry/archive/2008/11/15/1333960.html">http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html</A><BR>&nbsp;<BR>[不提供插图，读者最好从网上下载源书]</P>
<P>5.9. Virtual Devices 虚拟设备<BR>A virtual device is an abstraction built on top of one or more real devices. The association between virtual devices and real devices can be many-to-many, as shown by the three models in Figure 5-4. It is also possible to build virtual devices on top of other virtual devices. However, not all combinations are meaningful or are supported by the kernel.<BR>一个虚拟设备是建立在一个或者多个真实设备之上的抽象设备。在虚拟设备和真实设备之间的关联可以是多对多的，正如图5－4中所示的。它同样可能是建立在其它虚拟设备之上的。然而，并不是所有的组合都是有意义的，也并不是所有的都被内核所支持。</P>
<P><BR>Figure 5-4. Possible relationship between virtual and real devices</P>
<P>&nbsp;</P>
<P><BR>5.9.1. Examples of Virtual Devices　虚拟设备的一个例子<BR>Linux allows you to define different kinds of virtual devices. Here are a few examples:<BR>内核充许你可以定义不同类型的虚拟设备。这有几个例子：</P>
<P><BR>Bonding　绑定</P>
<P>With this feature, a virtual device bundles a group of physical devices and makes them behave as one.<BR>和这一特性一起，一个虚拟设备处理一组物理设备，并让它们一起表现得你是一个设备一样。</P>
<P><BR>802.1Q　</P>
<P>This is an IEEE standard that extends the 802.3/Ethernet header with the so-called VLAN header, allowing for the creation of Virtual LANs.<BR>这是IEEE 802.3/以太网报头也就是被称为VLAN头的报文，充许创建虚拟的LAN。</P>
<P><BR>Bridging　桥接</P>
<P>A bridge interface is a virtual representation of a bridge. Details are in Part IV.<BR>一个桥接接口是一个虚拟桥的表现。详细在第五部份讨论。</P>
<P><BR>Aliasing interfaces　别名接口</P>
<P>Originally, the main purpose for this feature was to allow a single real Ethernet interface to span several virtual interfaces (eth0:0, eth0:1, etc.), each with its own IP configuration. Now, thanks to improvements to the networking code, there is no need to define a new virtual interface to configure multiple IP addresses on the same NIC. However, there may be cases (notably routing) where having different virtual NICs on the same NIC would make life easier, perhaps allowing simpler configuration. Details are in Chapter 30.<BR>一开始，这个特性的主要目的是充许单个以太网接口去区分虚拟接口（eth0:0, eth0:1, 等），每个都有它自己的IP配置。现在，感谢那些对网络代码的实现，现在不必要去为在同一个NIC上配置多IP地址而定义一个新的虚拟配置。然而，有些情况下（很可能是路由），有不同的虚拟NIC在同一个NIC可能会让生活变得更简单，或许充许更简单的配置。在第30章有更详细的说明。</P>
<P><BR>True equalizer (TEQL)　真实均衡</P>
<P>This is a queuing discipline that can be used with Traffic Control. Its implementation requires the creation of a special device. The idea behind TEQL is a bit similar to Bonding.<BR>这里有一个队列原则，可以用于控制流量控制。这个实现需要创建一个特性的设备。这个主意是隐藏在TEQL之后的，与Bonding有点小同。</P>
<P>Tunnel interfaces　隧道接口</P>
<P>The implementation of IP-over-IP tunneling (IPIP) and the Generalized Routing Encapsulation (GRE) protocol is based on the creation of a virtual device.<BR>IPIP的实现和通用路由封装协议是基于一个虚拟设备的创建。</P>
<P>This list is not complete. Also, given the speed with which new features are included into the Linux kernel, you can expect to see new virtual devices being added to the kernel.<BR>这有一个没有完成的列表，同样，给出了添加一个新特性到Linux内核中的速度，你可以认为看到一个新虚拟设备已经添加到内核中。</P>
<P>Bonding, bridging, and 802.1Q devices are examples of the model in Figure 5-4(c). Aliasing interfaces are examples of the model in Figure 5-4(b). The model in Figure 5-4(a) can be seen as a special case of the other two.<BR>绑定，桥接，和802.1Q设备就是图5－4（c）这个模型的例子。另名接口是图5－4（b）的一个例子，而图5－4（a）的情况可以看成是除了这两个之外的特殊情况。</P>
<P>5.9.2. Interaction with the Kernel Network Stack　与内核网络栈的交互<BR>Virtual devices and real devices interact with the kernel in slightly different ways. For example, they differ with regard to the following points:<BR>虚拟设备和真实设备接口通过内核使用一些细微不同的方式来交互。例如，关于下面这些不同的细节点：</P>
<P>Initialization　初始化</P>
<P>Most virtual devices are assigned a net_device data structure, as real devices are. Often, most of the virtual device's net_device's function pointers are initialized to routines implemented as wrappers, more or less complex, around the function pointers used by the associated real devices.<BR>很多虚拟设备都被关联到一个net_device的数据结构，它就像是个真实的设备。通常，大多数虚拟设备的net_device的函数指针都使用已经实现的函数进行初始化，或多或少有些复杂，这些函数指针被相关的真实设备所使用。</P>
<P>However, not all virtual devices are assigned a net_device instance. Aliasing devices are an example; they are implemented as simple labels on the associated real device (see the section "Old-generation configuration: aliasing interfaces" in Chapter 30).<BR>然而，不是所有的虚拟设备都指定了一个net_device的实例。关联的设备是一个例子，它们以一个简单的标签关联到一个真实的设备来实现（参见第30章中的“旧方式的配置：别名接口”一节）。</P>
<P>Configuration　配置</P>
<P>It is common to provide ad hoc user-space tools to configure virtual devices, especially for the high-level fields that apply only to those devices and which could not be configured using standard tools such as ifconfig.<BR>有一个常用的方法来提供hoc用户空间的工具来配置虚拟设备，特别是为配置上层应用的字段，这些字段不能用普通的，类似ifconfig这样的工具来配置。</P>
<P>External interface　外部接口</P>
<P>Each virtual device usually exports a file, or a directory with a few files, to the /proc filesystem. How complex and detailed the information exported with those files is depends on the kind of virtual device and on the design. You will see the ones used by each virtual device listed in the section "Virtual Devices" in their associated chapters (for those devices covered in this book). Files associated with virtual devices are extra files; they do not replace the ones associated with the physical devices. Aliasing devices, which do not have their own net_device instances, are again an exception.<BR>每一个虚拟设备通常暴露一个文件，或者一个目录带少数几个文件，到/proc文件系统中。这些暴露出来的信息的详细情况的复杂程度取决与不同虚拟设备和它的设计。在虚拟设备一节中与此相关的章节中，你会看到每个虚拟设备所使用的就是一个例子。与虚拟设备相关的文件是一些额外的文件，它们不会替换与真实设备相关的文件。别名设备，这些是没有它们自己的net_device实例的，又是一个特例。</P>
<P>Transmission　传输</P>
<P>When the relationship of virtual device to real device is not one-to-one, the routine used to transmit may need to include, among other tasks, the selection of the real device to use.[*] Because QoS is enforced on a per-device basis, the multiple relationships between virtual devices and associated real devices have implications for the Traffic Control configuration.<BR>当虚拟设备与真实设备的关联关不是一对一的，根据任务和真实设备的使用，那些传输的程序须要包含进去。因为QoS强制为每个设备的基础，在虚拟设备的真实设备之间的多关联对流量控制的配置是隐式的。</P>
<P>[*] See Chapter 11 for more details on packet transmission in general, and dev_queue_xmit in particular.</P>
<P>Reception　接收</P>
<P>Because virtual devices are software objects, they do not need to engage in interactions with real resources on the system, such as registering an IRQ handler or allocating I/O ports and I/O memory. Their traffic comes secondhand from the physical devices that perform those tasks. Packet reception happens differently for different types of virtual devices. For instance, 802.1Q interfaces register an Ethertype and are passed only those packets received by the associated real devices that carry the right protocol ID.[] In contrast, bridge interfaces receive any packet that arrives from the associated devices (see Chapter 16).<BR>因为虚拟设备是软件对象，它们不必要与系统的真实资源相互交互而忙碌，例如，类似IRQ句柄的注册或者分配IO端口和IO内存。他们的流量间接来自现实这些功能的物理设备。包的接收根据不同的虚拟设备而有所不同。例如，802.1Q接口注册一个以太类型，并且它们只让那些从物理设备上来，带有正确的协议报文通过。相应的，桥接接口则是接收所有从相关设备上来的报文。</P>
<P>[] Chapter 13 discusses the demultiplexing of ingress traffic based on the protocol identifier.</P>
<P>External notifications　外部通知</P>
<P>Notifications from other kernel components about specific events taking place in the kernel[] are of interest as much to virtual devices as to real ones. Because virtual devices' logic is implemented on top of real devices, the latter have no knowledge about that logic and therefore are not able to pass on those notifications. For this reason, notifications need to go directly to the virtual devices. Let's use Bonding as an example: if one device in the bundle goes down, the algorithms used to distribute traffic among the bundle's members have to be made aware of that so that they do not select the devices that are no longer available.<BR>从其它内核组件上报上来的在内核发生的关于特殊事件的通知，对于真实设备来说，虚拟设备更有兴趣关注。因为虑设备的逻辑是由顶层的设备所实现，而后者并不知道这些逻辑，并因此不能传送这些通知。因这这个原因，需要直接通知虚拟设备。让我们以绑定类型为例，如果一个在一梱中的设备的流量开始下降，用于分发在梱中的成员的算法，应该关注这些，以便它们不用去选择那些已经无效的设备。</P>
<P>[] Chapter 4 defines notification chains and explains what kind of notifications they can be used for.</P>
<P>Unlike these software-triggered notifications, hardware-triggered notifications (e.g., PCI power management) cannot reach virtual devices directly because there is no hardware associated with virtual devices.<BR>与那些软件触发的通知，硬件触发（例如，PCI电源管理）的通知不能直接到达虚拟设备，因为没有硬件关联到虚拟设备。</P>
<P>&nbsp;</P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1396886.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47994/" target="_blank">Google号召社区力量为互联网加速</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[译]5.8. User-Space Helpers 用户空间的助手</title><link>http://www.cnblogs.com/WuCountry/archive/2009/02/21/1395592.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Sat, 21 Feb 2009 14:58:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/02/21/1395592.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1395592.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/02/21/1395592.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1395592.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1395592.html</trackback:ping><description><![CDATA[<P>目录：<A href="/WuCountry/archive/2008/11/15/1333960.html">http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html</A><BR>&nbsp;<BR>[不提供插图，读者最好从网上下载源书]</P>
<P>5.8. User-Space Helpers 用户空间的助手<BR>There are cases where it makes sense for the kernel to invoke a user-space application to handle events. Two such helpers are particularly important:<BR>我们关心，它是怎样让内核关注并调用用户空间里的应用程序来处理事件的。这有两个特别重要的助手：</P>
<P>/sbin/modprobe</P>
<P>Invoked when the kernel needs to load a module. This helper is part of the module-init-tools package.<BR>在内核要加载模块时调用。它个助手是module-init-tools工具包的一部份。</P>
<P>/sbin/hotplug</P>
<P>Invoked when the kernel detects that a new device has been plugged or unplugged from the system. Its main job is to load the correct device driver (module) based on the device identifier. Devices are identified by the bus they are plugged into (e.g., PCI) and the associated ID defined by the bus specification.[] This helper is part of the hotplug package.<BR>这个会在内核检测到有新设备被插入到系统中时来被调用。它的主要工作就是根据设备的标识来加载正确的设备驱动（模块）。设备的标识是通过它插入的总线和它所关联的总线规格来标识的。这个助手也是热插拨工具包的一部份。</P>
<P>[] See the section "Registering a PCI NIC Device Driver" in Chapter 6 for an example involving PCI.<BR>参见第6章中“注册一个PCI类型的NIC设备驱动”一节的一个调用实例！</P>
<P>The kernel provides a function named call_usermodehelper to execute such user-space helpers. The function allows the caller to pass the application a variable number of both arguments in arg[] and environment variables in env[]. For example, the first argument arg[0] tells call_usermodehelper what user-space helper to launch, and arg[1] can be used to tell the helper itself what configuration script to use (often called the user-space agent). We will see an example in the later section "/sbin/hotplug."<BR>内核提供了一个名为call_usermodehelper函数用于执行这样的用户空间的助手程序。这个函数充许调用者通过arg[]参数和env[]环境变量来向应用程序传递很多数据。例如，第一个参数arg[0]就告诉call_usermodehelper要启动用户空间中的哪个助手程序，而arg[1]可以用于告诉助手程序它自己，应该使用怎样的配置脚本（通常也叫作用户空间代理）。我们会在后面的“/sbin/hotplug”一节中看到一个例子。</P>
<P>Figure 5-3 shows how two kernel routines, request_module and kobject_hotplug, invoke call_usermodehelper to invoke /sbin/modprobe and /sbin/hotplug, respectively. It also shows examples of how arg[] and envp[] are initialized in the two cases. The following subsections go into a little more detail on each of those two user-space helpers.<BR>图5－3显示了两个内核程序，request_module 和kobject_hotplug, 是如何分别调用/sbin/modprobe 和/sbin/hotplug的。它同时也显示了在这两种情况下arg[]和evn[]是如何初始化的。下面的子章节会详细的讨论这两种情况下的用户空间的助手程序。</P>
<P><BR>Figure 5-3. Event propagation from kernel to user space</P>
<P>&nbsp;</P>
<P><BR>5.8.1. kmod　<BR>kmod is the kernel module loader that allows kernel components to request the loading of a module. The kernel provides more than one routine, but here we'll look only at request_module. This function initializes arg[1] with the name of the module to load. /sbin/modprobe uses the configuration file /etc/modprobe.conf to do various things, one of which is to see whether the module name received from the kernel is actually an alias to something else (see Figure 5-3).<BR>kmod是内核模块的加载器，它充许内核组件请求加载一个模块。内核提供了不只一个程序，但我们只会看一下request_module。这个函数初用要加载的模块名来始化arg[1]。/sbin/modprobe使用/ect/modprobe.conf这个配置文件来做一些其它的事，其中之一就是看从内核收到的要加载的模块名是否实际上与某些事关联在一起（参见图5－3）。</P>
<P>Here are two examples of events that would lead the kernel to ask /sbin/modprobe to load a module:<BR>这里有两个事件的例子，这些事件引导内核要求/sbin/modprob去加载一个模块：</P>
<P>When the administrator uses ifconfig to configure a network card whose device driver has not been loaded yetsay, for device eth0[*]the kernel sends a request to /sbin/modprobe to load the module whose name is the string "eth0". If /etc/prorobe.conf contains the entry "alias eth0 3c59x", /sbin/modprobe tries loading the module 3c59x.ko.<BR>当管理员使用ifconfig来配置一个还没有加载驱动程序的网卡时，例如eth0设备，内核发送一个请求到/sbin/modprobe来加载名为“eth0”的设备。如果/ect/prorobe.conf里包含了条“alias eth0 3c59x”的信息，/sbin/modprobe就试着加载3c59x.ko这个模块。</P>
<P>[*] Note that because the device driver has not been loaded yet, eth0 does not exist yet either.<BR>注意，因为这里设备的驱动还没有被加载，所以eth0还不存在！</P>
<P>When the administrator configures Traffic Control on a device with the IPROUTE2 package's tc command, it may refer to a queuing discipline or a classifier that is not in the kernel. In this case, the kernel sends /sbin/modprobe a request to load the relevant module.<BR>当管理员在一个设备上使用IPROUTER2软件包里的tc命令来配置网络流量控制时，这可能会涉及到队列原则和一个不在内核里的分类器。在这种情况下，内核发送一个请求给/sbin/modprobe去加载相关的模块。</P>
<P>For more details on modules and kmod, refer to Linux Device Drivers.<BR>关于kmod和模块的细节，可以参考Linux Device Drivers.</P>
<P>5.8.2. Hotplug 热插拨<BR>Hotplug was introduced into the Linux kernel to implement the popular consumer feature known as Plug and Play (PnP) . This feature allows the kernel to detect the insertion or removal of hot-pluggable devices and to notify a user-space application, giving the latter enough details to make it able to load the associated driver if needed, and to apply the associated configuration if one is present.<BR>热插拨被引入到Linux内核中去实现众所周知的流行PnP(即插即用)的用户特性。这一特性充许内核检测插入和移走的支持热插拨的设备，并且会告知用户空间的应用程序，如果有一个出现时就应用相关的配置。后面会足够详细的介绍是如何在需要时加载相关的驱动。</P>
<P>Hotplug can actually be used to take care of non-hot-pluggable devices as well, at boot time. The idea is that it does not matter whether a device was hot-plugged on a running system or if it was already plugged in at boot time; the user-space helper is notified in both cases. The user-space application decides whether the event requires any action on its part.<BR>热插拨技术实际上可以在启动时，很好的应用在非热插拨设备中。这样使用是因为它并不关注在启动时，已经插在系统中的设备是不是热插拨的；用户空间的助手程序在两种情况下都会被通知。用户空间的应用程序来决定是否要在事件上对自己的设备做出响应。</P>
<P>Linux systems, like most Unix systems, execute a set of scripts at boot time to initialize peripherals, including network devices. The syntax, names, and locations of these scripts change with different Linux distributions. (For example, distributions using the System V init model have a directory per run level in /etc/rc.d/, each one with its own configuration file indicating what to start. Other distributions are either based on the BSD model, or follow the BSD model in compatibility mode with System V.) Therefore, notifications for devices already present at boot time may be ignored because the scripts will eventually configure the associated devices.<BR>Linux系统，或者是类Unix系统，在系统启动时要执行大量的脚本来初始化外围设备，包括网络设备。这些脚本的语法，名字，以及存放的位置都会根据不同的发生版有所变化。（例如，使用System V来初始化模型的发行版，/etc/rc.d/对每个运行级上都有一个目录，每个人在启动时都有自己的配置文件来决定启动什么。其它的发行版，有基于BSD模型的，也有根据BSD模型而兼容System V的模型。）因此，发给在启动时已经出现的设备的通知可能会被忽略，因为脚本最终会配置这相关的设备。</P>
<P>When you compile the kernel modules, the object files are placed by default in the directory /lib/modules/kernel_version/, where kernel_version is, for instance, 2.6.12. In the same directory you can find two interesting files: modules.pcimap and modules.usbmap. These files contain, respectively, the PCI IDs[*] and USB IDs of the devices supported by the kernel. The same files include, for each device ID, a reference to the associated kernel module. When the user-space helper receives a notification about a hot-pluggable device being plugged, it uses these files to find out the correct device driver.<BR>当你编译内核模块时，目录文件已经放在默认的目录/lib/modules/ker_version/中，当kernel_version给定版本，例如2.6.12。在同样的目录下，你可发现两个有趣的文件：modules.pcimap和modules.usbmap。这些文件分别包括内核所支持的所有设备的PCI的ID，和USB的ID。同样的文件还包括每个设备的ID，以及它所关联到内核的模块。当用户空间的助手程序收到一个热插拨的设备被插入的通知时，它使用这些文件去查找出正确的设备驱动。</P>
<P>[*] The section "Example of PCI NIC Driver Registration" in Chapter 6 gives a brief description of a PCI device identifier.</P>
<P>The modules.xxxmap files are populated from ID vectors provided by device drivers. For example, you will see in the section "Example of PCI NIC Driver Registration" in Chapter 6 how the Vortex driver initializes its instance of pci_device_id. Because that driver is written for a PCI device, the contents of that table go into the modules.pcimap file.<BR>这个modules.xxxmap文件是板上组装的由设备驱动提供的ID向量。例如，你会在第6章中的“一个PCN　NIC设备驱动注册实例”这一节中看到，Vortex驱动是如何初始化它的一个pci_device_id实例。因这这个驱动被写成支持一个PCI设备，所以它的内容表存放在modules.pcimap文件中。</P>
<P>If you are interested in the latest code, you can find more information at <A href="http://linux-hotplug.sourceforge.net">http://linux-hotplug.sourceforge.net</A>.<BR>如果你已经对最后的代码吸引住，你可以在<A href="http://linux-hotplug.sourceforge.net">http://linux-hotplug.sourceforge.net</A>上找到更多的信息。</P>
<P>5.8.2.1. /sbin/hotplug<BR>The default user-space helper for Hotplug is the script[] /sbin/hotplug, part of the Hotplug package. This package can be configured with the files located in the default directories /etc/hotplug/ and /etc/hotplug.d/.<BR>默认的用户空间支持热插拨的助手程序在/sbin/hotplug脚本中，是热插拨软件包中的一部份。这个包可以通过在默认目录/etc/hotplug/ and /etc/hotplug.d中配置。</P>
<P>[] The administrator can write his own scripts or use the ones provided by the most common Linux distributions.</P>
<P>The kobject_hotplug function is invoked by the kernel to respond to the insertion and removal of a device, among other events. kobject_hotplug initializes arg[0] to /sbin/hotplug and arg[1] to the agent to be used: /sbin/hotplug is a simple script that delegates the processing of the event to another script (the agent) based on arg[1].<BR>内核调用kobject_hotplug函数在其它事件中来报告一个设备的插入和移除。kobject_hotplug用/sbin/hotplug来初始arg[0]，同时arg[1]以这样的方式来做代理：/sbin/hotplug是一个简单的脚本，用于代理另一个基于arg[1]脚本（代理）的进程事件。（不明白说的啥）</P>
<P>The user-space helper agents can be more or less complex based on how fancy you want the auto-configuration to be. The scripts provided with the Hotplug package try to recognize the Linux distribution and adapt the actions to their configuration file's syntax and location.<BR>用户空间的助手代码可以有更多或者更少的复杂性。这要基于你的想象力，你想自动到什么程度。这个软件包提供的脚本试着识别Linux的发行版，并适配它的配置文件的语法和位置。</P>
<P>Let's take networking, the subject of this book, as an example of hotplugging. When an NIC is added to or removed from the system, kobject_hotplug initializes arg[1] to net, leading /sbin/hotplug to execute the net.agent agent.<BR>让我们来看看网络，这也是本书的主题，做为一个热插拨的例子。当一个NIC添加到系统或者从系统中移除时，kobject_hotplug 给网络初始化arg[1]，让/sbin/hotplug去执行这个net.agent代理。</P>
<P>Unlike the other agents shown in Figure 5-3, net.agent does not represent a medium or bus type. While the net agent is used to configure a device, other agents are used to load the correct modules (device drivers) based on the device identifiers.<BR>与图5－3中所显示的其它代理不同，net.agent并不会响应一个媒体或者总线类型。当net代理被用于配置一个设备时，另一个代理就被用于根据模块的设备ID来锁定上下文。</P>
<P>net.agent is supposed to apply any configuration associated with the new device, so it needs the kernel to provide at least the device identifier. In the example shown in Figure 5-3, the device identifier is passed by the kernel through the INTERFACE environment variable.<BR>net.agent是假设可以支持任何关于新设备的配置的，所以它需要内核最少提供设备标识。在图5－3的例子中，这个设备标识是内核通过INTERFACE环境变量为传递的。</P>
<P>To be able to configure a device, it must first be created and registered with the kernel. This task is normally driven by the associated device driver, which must therefore be loaded first. For instance, adding a PCMCIA Ethernet card causes several calls to /sbin/hotplug; among them:<BR>为了可以配置一个设备，它开始必须被创建和注册到内核。这个任务通常是由相关的设备驱动来完成的，也就是说，这（设备驱动）必须是要先加载的。</P>
<P>One leading to the execution of /sbin/modprobe,[*] which will take care of loading the right module device driver. In the case of PCMCIA, the driver is loaded by the pci.agent agent (using the action ADD).<BR>可执行文件/sbin/modprobe，用于关注加载正确的设备驱动模块。在PCMCIA情况下，驱动会由pci.agent这个代理来加载（使用ADD动作）。</P>
<P>[*] Unlike /sbin/hotplug, which is a shell script, /sbin/modprobe is a binary executable file. If you want to give it a look, download the source code of the modutil package.<BR>与/sbin/hotplug不一样，这只是一个脚本，/sbin/modprob是一个二进制的可执行文件。如果你想看看它，可以下载modutil软件包。</P>
<P>One configuring the new device. This is done by the net.agent agent (again using the action ADD).<BR>一个配置新设备，这是由net.ageng代理来完成的（再次使用ADD动作）。<BR></P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1395592.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47989/" target="_blank">Twitter无处不在 魔兽世界Twitter发送器插件发布</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[转]A.3. Build the initrd image</title><link>http://www.cnblogs.com/WuCountry/archive/2009/02/20/1395187.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Fri, 20 Feb 2009 14:32:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/02/20/1395187.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1395187.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/02/20/1395187.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1395187.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1395187.html</trackback:ping><description><![CDATA[<DIV class=NAVHEADER>
<TABLE cellSpacing=0 cellPadding=0 width="100%" summary="Header navigation table" border=0>
<TBODY>
<TR>
<TH align=middle colSpan=3>EVMS User Guide</TH></TR>
<TR>
<TD vAlign=bottom align=left width="10%"><A accessKey=P href="http://www.faqs.org/docs/evms/kernsup.html">Prev</A></TD>
<TD vAlign=bottom align=middle width="80%">Appendix A. Building an init-ramdisk to use with EVMS</TD>
<TD vAlign=bottom align=right width="10%"><A accessKey=N href="http://www.faqs.org/docs/evms/setupbootloader.html">Next</A></TD></TR></TBODY></TABLE>
<HR align=left width="100%">
</DIV>
<DIV class=sect1>
<H1 class=sect1><A name=AEN3834></A>A.3. Build the initrd image</H1>
<P>The next step is to build the actual ramdisk image, which is described in the following subsections. The important thing to remember is that any program that needs to run from the initrd needs to be copied to the initrd. In addition, any shared libraries that are needed by programs that run from the initrd need to be copied to the initrd as well.</P>
<DIV class=sect2>
<H2 class=sect2><A name=createnewinitrd></A>A.3.1. Create a new, blank initrd</H2>
<P>Start by creating a new initrd image with an ext2 file system. The following example creates the initrd image at <TT class=filename>/boot/initrd-evms</TT>. You can choose to use a different file name if you wish.</P>
<P>The size of the initrd in the following example is 16 MB. You can make the initrd larger or smaller by adjusting the "count" value. The minimum size needed for all the required EVMS tools and supporting libraries is about 11 MB. If you are installing kernel modules to your initrd (see step 3-H below) or other non-EVMS programs, the size might need to be increased.</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>dd if=/dev/zero of=/boot/initrd-evms bs=1M count=16
mke2fs -F -m 0 -b 1024 /boot/initrd-evms</PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=AEN3843></A>A.3.2. Mount the initrd</H2>
<P>In order to copy all the required files to the initrd, the initrd must be mounted through a loopback device. To mount the initrd through a loopback device requires that you have loopback support compiled in your kernel (or as a kernel module). See the "Block Devices" menu in the kernel configuration for more information about loopback.</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>mkdir /mnt/initrd
mount -t ext2 -o loop /boot/initrd-evms /mnt/initrd</PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=AEN3847></A>A.3.3. Set up the basic directory structure</H2>
<P>Use the following commands to create several basic directories that are required on the initrd:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /mnt/initrd
mkdir bin dev etc lib proc sbin var
cd var
mkdir lock log</PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=AEN3851></A>A.3.4. Copy helpful utilities</H2>
<P>The script that runs in the initrd requires a few common command-line utilities, which you can create with the following commands:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /bin
cp -a bash cat echo expr grep mount sh umount /mnt/initrd/bin
cd /etc
cp fstab /mnt/initrd/etc</PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=AEN3855></A>A.3.5. Copy supporting libraries</H2>
<P>The utilities from the previous step, along with the EVMS tools, require a few common shared libraries. You can create these shared libraries with the following commands:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /lib
cp -a ld-* /mnt/initrd/lib
cp -a libc-* libc.* /mnt/initrd/lib
cp -a libdl-* libdl.* /mnt/initrd/lib
cp -a libpthread* /mnt/initrd/lib
cp -a libtermcap* /mnt/initrd/lib</PRE></FONT></TD></TR></TBODY></TABLE>
<P>It is possible that some of the utilities (bash in particular) require additional libraries. Use the <B class=command>ldd</B> command to determine if you need additional libraries copied to your initrd. For example, output from the <B class=command>ldd /bin/bash</B> command provides a list similar to the following:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>libtermcap.so.2 =&gt; /lib/libtermcap.so.2 (0x40020000)
libdl.so.2 =&gt; /lib/libdl.so.2 (0x40024000)
libc.so.6 =&gt; /lib/libc.so.6 (0x40027000)
/lib/ld-linux.so.2 =&gt; /lib/ld-linux.so.2 (0x4000000)</PRE></FONT></TD></TR></TBODY></TABLE>
<P>All libraries listed by <B class=command>ldd</B> need to be copied to the <TT class=filename>/lib</TT> directory on the initrd.</P></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=AEN3866></A>A.3.6. Copy the EVMS tools</H2>
<P>Several EVMS libraries and a couple of executables need to be copied to the initrd. First, you need to locate where the EVMS libraries were installed. By default, these libraries are installed in <TT class=filename>/lib</TT>. If you specified a different prefix or <TT class=filename>libdir</TT> when you configured EVMS, the libraries might be located in a different directory. It is important that these libraries be installed in the same location on the initrd as they are on your real system. For example, if the libraries installed in <TT class=filename>/lib</TT>, the libraries need to be copied to <TT class=filename>/lib</TT> on the initrd; If the libraries are installed in <TT class=filename>/usr/lib</TT>, they need to be copied to <TT class=filename>/usr/lib</TT> on the initrd.</P>
<P>The following example assumes the libraries are installed in <TT class=filename>/lib</TT>. Only the shared libraries (.so) need to be copied. The static versions (.a) are not needed on the initrd.</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /lib
cp -a libevms*so* /mnt/initrd/lib
cp -a libdlist*so* /mnt/initrd/lib</PRE></FONT></TD></TR></TBODY></TABLE>
<P>Next, copy the plug-in libraries to the initrd. The plug-ins are always installed in the <TT class=filename>evms</TT> subdirectory of the directory where <TT class=filename>libevms</TT> is installed.</P>
<P>Not all of the plug-ins need to be copied to the initrd. Several plug-ins are only for interfacing with the file system utilities and are not necessary at boot time. Other plug-ins are only for interfacing with clustering packages, which cannot be started until the regular boot process.</P>
<P>The following is a list of the specific plug-ins that do not need to be installed:</P>
<P></P>
<UL>
<LI>
<P>csm</P>
<LI>
<P>ext2</P>
<LI>
<P>ha</P>
<LI>
<P>jfs</P>
<LI>
<P>reiser</P>
<LI>
<P>replace</P>
<LI>
<P>rsct</P>
<LI>
<P>swap</P>
<LI>
<P>xfs</P></LI></UL>
<P>Create and change directory to <TT class=filename>/lib/evms</TT>:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>mkdir /mnt/initrd/lib/evms
cd /lib/evms</PRE></FONT></TD></TR></TBODY></TABLE>
<P>Copy the contents of the <TT class=filename>/lib/evms</TT> directory, minus the plug-ins listed earlier that do not need to be installed, to <TT class=filename>/mnt/initrd/lib/evms</TT>:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>for foo in aix bbr bsd disk dos drivelink gpt lvm md os2 s390 snapshot sparse
do
  cp -a *$foo* /mnt/initrd/lib/evms
done</PRE></FONT></TD></TR></TBODY></TABLE>
<P>Next, copy the activation program to the initrd. The full user interfaces are not needed, because the only thing the initrd does is activate the volumes. Unlike the EVMS libraries, the exact location of this program in the initrd is not important, so it can simply go in <TT class=filename>sbin</TT>:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /sbin
cp evms_activate /mnt/initrd/sbin
cp get_dev_num /mnt/initrd/sbin</PRE></FONT></TD></TR></TBODY></TABLE>
<P>Finally, if you have an <TT class=filename>/etc/evms.conf</TT> file installed, you should copy it to the initrd so that EVMS uses the correct options during activation. (However, if you have an <TT class=filename>/etc/evms.conf</TT> file but have never modified it for your system, it should still have all the default values and does not necessarily need to be installed on the initrd.)</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /etc
cp evms.conf /mnt/initrd/etc</PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=setupdiskdev></A>A.3.7. Set up disk devices</H2>
<P>The initrd needs to be set up to reflect the disk devices that are on your system. EVMS needs to find the disks in order to activate the volumes.</P>
<P>Before setting up the disk devices on the initrd, determine if you are using <TT class=filename>devfs</TT>. If you are not sure, you can quickly check for the file <TT class=filename>/dev/.devfsd</TT>. If <TT class=filename>/dev/.devfsd</TT> exists, you are running <TT class=filename>devfs</TT>. You can also check your kernel configuration in the "Filesystems" menu. If "/dev file system support" and "Automatically mount at boot" are enabled, you are running <TT class=filename>devfs</TT>.</P>
<DIV class=sect3>
<H3 class=sect3><A name=AEN3925></A>A.3.7.1. devfs users</H3>
<P>Because <TT class=filename>devfs</TT> runs automatically within the initrd, you do not need to manually copy the device files to the initrd. However, <TT class=filename>devfs</TT> does need to be mounted within the initrd for it to work properly. There are two ways to accomplish this:</P>
<P></P>
<UL>
<LI>
<P>In the kernel configuration, in the "Filesystems" menu, set the "Automatically mount at boot time" option. With this option set, <TT class=filename>devfs</TT> will be automatically mounted on <TT class=filename>/dev</TT> when the initrd is loaded.</P>
<LI>
<P>Manually mount <TT class=filename>devfs</TT> from the <B class=command>linuxrc</B> script before running <B class=command>evms_activate</B>. See <A href="http://www.faqs.org/docs/evms/x3834.html#writelinuxrc">Section A.3.9</A> for more details.</P></LI></UL></DIV>
<DIV class=sect3>
<H3 class=sect3><A name=AEN3941></A>A.3.7.2. devfsd users</H3>
<P>EVMS does not require <TT class=filename>devfs</TT> users to run <TT class=filename>devfsd</TT>. However, if you do run <TT class=filename>devfsd</TT>, you also need to run it on the initrd to ensure that all disks and segments are discovered with the same names on both the initrd and the real system. Thus, if you run <TT class=filename>devfsd</TT>, you need to copy the <TT class=filename>devfsd</TT> program and <TT class=filename>config</TT> file to the initrd, as follows:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /sbin
cp devfsd /mnt/initrd/sbin
cd /etc
cp devfsd.conf /mnt/initrd/etc</PRE></FONT></TD></TR></TBODY></TABLE>
<P>Next, examine the <TT class=filename>devfsd.conf</TT> file (the one you just copied to the ramdisk) with a text editor. First look for a line like this:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>LOOKUP.* MODLOAD</PRE></FONT></TD></TR></TBODY></TABLE>
<P>Also in the <TT class=filename>devfsd</TT> file, look for a line that begins with RESTORE. This line specifies a directory where <TT class=filename>devfsd</TT> stores changes to the <TT class=filename>/dev</TT> file system. Create this directory in your initrd. For example, if your <TT class=filename>devfsd.conf</TT> file contains the line "RESTORE /dev-state," issue the following commands to prevent error messages from being generated when <TT class=filename>devfsd</TT> starts within the initrd:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /mnt/initrd
mkdir dev-state</PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=sect3>
<H3 class=sect3><A name=AEN3961></A>A.3.7.3. Non-devfs users</H3>
<P>Because <TT class=filename>devfs</TT> is not running and mounted within the initrd, you need to manually copy the necessary device node files to the initrd. If you only have IDE or SCSI disks, the following commands should be sufficient. If you specifically know which disks are on your system, you can copy only those device files.</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /dev
cp -a hd[a-z] /mnt/initrd/dev</PRE></FONT></TD></TR></TBODY></TABLE>
<P>In addition to the disk devices, you also need a console device:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cp -a console /mnt/initrd/dev</PRE></FONT></TD></TR></TBODY></TABLE></DIV></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=copykernmods></A>A.3.8. Copy kernel modules</H2>
<P>If you have any kernel modules that need to be loaded in order for EVMS to run, those modules need to be copied to the initrd. In particular, if you build your IDE or SCSI drivers, the Device Mapper or MD/Software-RAID drivers, or any required file systems as modules, they need to be present on the initrd so they can be loaded before you run EVMS and try to mount the root file system.</P>
<P>If you build all of the necessary drivers and file systems statically into the kernel, you can skip this step. Skipping this step is the recommended approach so that you avoid any possible problems that might be caused by required modules missing from the initrd.</P>
<P>When copying the kernel modules, it is probably safest to copy the entire module directory so as not to miss any modules that might be needed on the initrd:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>mkdir /mnt/initrd/lib/modules
cd /lib/modules
cp -a x.y.z /mnt/initrd/lib/modules</PRE></FONT></TD></TR></TBODY></TABLE>
<P>x.y.z is the version of the kernel that will be running EVMS and the initrd. </P>
<P>In addition, you will need the module-loading utilities, and probably the module configuration file:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /sbin
cp modprobe /mnt/initrd/sbin
cd /etc
cp modules.conf /mnt/initrd/etc</PRE></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=writelinuxrc></A>A.3.9. Write the linuxrc script</H2>
<P>At this point, all of the necessary files, programs, and libraries should be on the initrd. The only thing remaining is the <TT class=filename>linuxrc</TT> script. When the kernel mounts the initrd, it tries to run a script called <TT class=filename>linuxrc</TT>, in the root of the initrd. This script performs all the actions necessary for the initrd, and prepares the root device so that it can be mounted when the initrd exits.</P>
<P>A sample <TT class=filename>linuxrc</TT> script is provided in the <TT class=filename>doc</TT> directory of the EVMS source package. You can use this script as a starting point.</P>
<P>Copy the <B class=command>linuxrc</B> sample to your initrd:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>cd /usr/src/evms-2.0.0/doc
cp linuxrc /mnt/initrd</PRE></FONT></TD></TR></TBODY></TABLE>
<P>Open the <TT class=filename>linuxrc</TT> sample script in your favorite text editor. The following paragraphs provide a brief explanation of what the <B class=command>linuxrc</B> does at boot time and offer suggestions for modifying the script for your system.</P>
<P></P>
<UL>
<LI>
<P>The first section tries to mount <TT class=filename>devfs</TT>. You only need to uncomment this section if you are running <TT class=filename>devfs</TT> and do not automatically mount devfs on <TT class=filename>/dev</TT> (see <A href="http://www.faqs.org/docs/evms/x3834.html#setupdiskdev">Section A.3.7</A> for more details).</P>
<LI>
<P>The next section tries to start the <TT class=filename>devfs</TT> daemon. If <TT class=filename>devfs</TT> is not running or <TT class=filename>devfsd</TT> is not present, this section is skipped.</P>
<LI>
<P>The next section mounts the <TT class=filename>proc</TT> file system. EVMS looks in the <TT class=filename>/proc</TT> file system to find the location of the Device Mapper driver. Also, later parts of the <TT class=filename>linuxrc</TT> script try to access <TT class=filename>/proc</TT> in order to properly set the root file system device.</P>
<LI>
<P>The next section loads the kernel modules. If you did not copy any kernel modules to your initrd (<A href="http://www.faqs.org/docs/evms/x3834.html#copykernmods">Section A.3.8</A>), you can leave this section commented out. If you need to load kernel modules from the initrd, this is the place to do it. Use the <B class=command>modprobe</B> command for each module that needs to be loaded. A few examples have been provided within the section.</P>
<LI>
<P>The next section is where EVMS runs and activates all of the volumes.</P>
<LI>
<P>The next section examines the kernel command line for a parameter that specifies the root volume. More information about how to set up this parameter is included in <A href="http://www.faqs.org/docs/evms/setupbootloader.html">Section A.4</A>. Device Mapper dynamically allocates all device numbers, which means it is possible that the root volume specified to LILO or GRUB might have a different number when the initrd runs than when the system was last running. In order to make sure the correct volume is mounted as root, the <TT class=filename>linuxrc</TT> script must determine what the desired root volume name is, determine the number for that device, and set that value in the appropriate file in <TT class=filename>/proc</TT>.</P>
<LI>
<P>Finally, the <TT class=filename>/proc</TT> file system can be unmounted. Also, <TT class=filename>devfs</TT> can be unmounted (but only if it was mounted at the start of the script).</P></LI></UL>
<P>When the <TT class=filename>linuxrc</TT> script completes, the kernel automatically tries to mount the root file system, and the initrd is removed from memory.</P></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=AEN4026></A>A.3.10. Unmount the initrd image</H2>
<P>The contents of the initrd should now be complete and you can unmount it.</P></DIV>
<DIV class=sect2>
<H2 class=sect2><A name=AEN4029></A>A.3.11. Compress the initrd image</H2>
<P>To conserve space, compress the initrd image:</P>
<TABLE width="100%" bgColor=#e0e0e0 border=0>
<TBODY>
<TR>
<TD><FONT color=#000000><PRE class=programlisting>gzip /boot/initrd-evms</PRE></FONT></TD></TR></TBODY></TABLE></DIV></DIV>
<DIV class=NAVFOOTER>
<HR align=left width="100%">

<TABLE cellSpacing=0 cellPadding=0 width="100%" summary="Footer navigation table" border=0>
<TBODY>
<TR>
<TD vAlign=top align=left width="33%"><A accessKey=P href="http://www.faqs.org/docs/evms/kernsup.html">Prev</A></TD>
<TD vAlign=top align=middle width="34%"><A accessKey=H href="http://www.faqs.org/docs/evms/index.html">Home</A></TD>
<TD vAlign=top align=right width="33%"><A accessKey=N href="http://www.faqs.org/docs/evms/setupbootloader.html">Next</A></TD></TR>
<TR>
<TD vAlign=top align=left width="33%">Kernel support for initrd</TD>
<TD vAlign=top align=middle width="34%"><A accessKey=U href="http://www.faqs.org/docs/evms/appxinitram.html">Up</A></TD>
<TD vAlign=top align=right width="33%">Set up the boot loader</TD></TR></TBODY></TABLE></DIV><FONT style="BACKGROUND-COLOR: #ffffff"><A href="http://www.faqs.org/docs/evms/x3834.html">http://www.faqs.org/docs/evms/x3834.html</A></FONT><img src ="http://www.cnblogs.com/WuCountry/aggbug/1395187.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47988/" target="_blank">Firefox 3.5匆忙推出漏洞多 Mozilla本月将更新</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[译]5.7. Initializing the Device Handling Layer: net_dev_init 设备处理层的初始化：net_dev_init</title><link>http://www.cnblogs.com/WuCountry/archive/2009/02/20/1395148.html</link><dc:creator>Wu.Country@侠缘</dc:creator><author>Wu.Country@侠缘</author><pubDate>Fri, 20 Feb 2009 13:01:00 GMT</pubDate><guid>http://www.cnblogs.com/WuCountry/archive/2009/02/20/1395148.html</guid><wfw:comment>http://www.cnblogs.com/WuCountry/comments/1395148.html</wfw:comment><comments>http://www.cnblogs.com/WuCountry/archive/2009/02/20/1395148.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/WuCountry/comments/commentRss/1395148.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/WuCountry/services/trackbacks/1395148.html</trackback:ping><description><![CDATA[<P>目录：<A href="/WuCountry/archive/2008/11/15/1333960.html">http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html</A><BR>&nbsp;<BR>[不提供插图，读者最好从网上下载源书]</P>
<P>5.7. Initializing the Device Handling Layer: net_dev_init<BR>设备处理层的初始化：net_dev_init</P>
<P>An important part of initialization for the networking code, including Traffic Control and per-CPU ingress queues, is performed at boot time by net_dev_init, defined in net/core/dev.c:<BR>网络代码初始化的一个很重要的部份，包括流量控制和每个CPU的入队列，都是在启动时候，由net_dev_init来完成的，它们在net/core/dev.c中定义：</P>
<P>static int _ _init net_dev_init(void)<BR>{<BR>&nbsp;&nbsp;&nbsp; ...<BR>}<BR>subsys_initcall(net_dev_init);</P>
<P><BR>See Chapter 7 for how the subsys_initcall macros ensure that net_dev_init runs before any NIC device drivers register themselves, and why this is important. You also will see why net_dev_init is tagged with the _ _init macro.<BR>参见第7章，subsys_initcall这个宏确保net_dev_init在NIC设备驱动注册他们自己之前运行，以及为什么这个很重要。你同样可以看到，为什么net_dev_init要用__init这个宏标记。</P>
<P>Let's walk through the main parts of net_dev_init:<BR>让我们看看net_dev_init的主要部份：</P>
<P>The per-CPU data structures used by the two networking software interrupts (softirqs) are initialized. In Chapter 9, we will see what a softirq is and go into detail on how the networking code uses softirqs.<BR>每个CPU的数据结构是由两个网络软件中断（软中断）初始化所使用。在第9章中，我们会看到什么是软中断以及网络代码是如何使用它们详细情况。</P>
<P>When the kernel is compiled with support for the /proc filesystem (which is the default configuration), a few files are added to /proc with dev_proc_init and dev_mcast_init. See the later section "Tuning via /proc Filesystem" for more details.<BR>当内核编译成支持/proc文件系统时（这是一个默认配置），会有一些文件和with_proc_init一起添加到/proc中。详细情况参见后面的“通过/proc文件系统调整（内核）”章节。</P>
<P>netdev_sysfs_init registers the net class with sysfs. This creates the directory /sys/class/net, under which you will find a subdirectory for each registered network device. These directories include lots of files, some of which used to be in /proc.<BR>netdev_sysfs_init通过sysfs注册网络类。这会创建一个/sys/class/net/的目录，在这个目录下，你可以发现与每一个注册的网络设备的子目录。这个目录包括话多文件，其中有一些就/proc所使用。</P>
<P>net_random_init initializes a per-CPU vector of seeds that will be used when generating random numbers with the net_random routine. net_random is used in different contexts, described later in this section.<BR>net_random_init初始化每个CPU的向量种子数，这个数会通过net_radnom例程一起用于生成随机数。net_random在不同的上下文中使用，在这一节的后面会说明。</P>
<P>The protocol-independent destination cache (DST), described in Chapter 33, is initialized with dst_init.<BR>与协议相关的目的缓存（DST）是通过dst_init初始的，这个会在第33章中说明。</P>
<P>The protocol handler vector ptype_base, used to demultiplex ingress traffic, is initialized. See Chapter 13 for more details.<BR>处理协议的向量ptype_base也被初始化，它用于多功能的入队流量管理，详细的参见第13章。</P>
<P>When the OFFLINE_SAMPLE symbol is defined, the kernel sets up a function to run at regular intervals to collect statistics about the devices' queue lengths. In this case, net_dev_init needs to create the timer that runs the function regularly. See the section "Average Queue Length and Congestion-Level Computation" in Chapter 10.<BR>当OFFLINE_SAMPLE符号被定义时，内核设置了一个函数在规则的间隙运行，用于收集与设备队列长度相关的统计。在这种情况下，net_dev_init需要创建一个计时器，用于规则的运行这个函数。参见第10章的“平均队列长度和拥塞等级运算”。</P>
<P>A callback handler is registered with the notification chain that issues notifications about CPU hotplug events. The callback used is dev_cpu_callback. Currently, the only event processed is the halting of a CPU. When this notification is received, the buffers in the CPU's ingress queue are dequeued and are passed to netif_rx. See Chapter 9 for more detail on per-CPU ingress queues.<BR>一个回调句柄被注册到通知链中，这样可以确保CPU会通知热插事件。这个回调使用的是dev_cpu_callback。目前，唯一的事件处理就是暂停CPU。当收到这个通知时，CPU里的入队列缓存队列就被清出，然后传给netif_rx。详细的参见第9章的每CPU入队列。</P>
<P>Random number generation is a support function that the kernel performs to help randomize some of its own activity. You will see in this book that many networking subsystems use randomly generated values. For instance, they often add a random component to the delay of timers, making it less likely for timers to run simultaneously and load down the CPU with background processing. Randomization can also defend against a Denial of Service (DoS) attack by someone who tries to guess the organization of certain data structures.<BR>随机数生成器是一个辅助功能，可以让内核帮助它们实现一些随机化的活动。你会从本书中看到，有很多网络子系统使用了随机生成数。例如，他们经常添加一个随机的组件到计时器中，使它不至于让计时器同时地运行，并在后台进程中分担CPU。随机还可以防止一些人使用DOS攻击来猜测组织结构和数据结构。</P>
<P>The degree to which the kernel's numbers can be considered truly random is called system entropy . It is improved through contributions by kernel components whose activity has a nondeterministic aspect, and networking often falls in this category. Currently, only a few NIC device drivers contribute to system entropy (see earlier discussion on SA_SAMPLE_RANDOM). A patch for kernel 2.4 adds a compile time option that you can use to enable or disable the contribution to system entropy by NICs. Search the Web using the keyword "SA_SAMPLE_NET_RANDOM," and you will find the current version.<BR>可以被内核数所真实信任的随机数的度，被称为系统熵（译：看原文，不知道什么意思）。这可以增加内核中那些行为有不确定特性的组件的贡献，并且一些网络经常落到这一话题中。目前，只有少数的NIC设备驱动给内核贡献了熵（参见前面所讨论的SA_SAMPLE_RANDOM）。有一个给2.4的补丁，添加了编译选项。你可以通过这些选项打开或者关闭，是否让NIC设备给内核贡献熵。从网络上搜索“SA_SAMPLE_NET_RANDOM”，你会发现最新的版本内容。</P>
<P>5.7.1. Legacy Code　遗传代码<BR>I mentioned in the previous section that the subsys_initcall macros ensure that net_dev_init is executed before any device driver has a chance to register its devices. Before the introduction of this mechanism, the order of execution used to be enforced differently, using the old-fashioned mechanism of a one-time flag.<BR>我在前面的章节中已经提到过，subsys_initcall宏用于确保net_dev_init在任何设备注册它的驱动之间被调用。在介绍这个机制之前，执行的顺序通常是强制要求不同的，在老的形式中是使用一个时间标志。</P>
<P>The global variable dev_boot_phase was used as a Boolean flag to remember whether net_dev_init had to be executed. It was initialized to 1 (i.e., net_dev_init had not been executed yet) and was cleared by net_dev_init. Each time register_netdevice was invoked by a device driver, it checked the value of dev_boot_phase and executed net_dev_init if the flag was set, indicating the function had not yet been executed.<BR>全局变量dev_boot_phase当成一个逻辑标志位，用于记住net_dev_init是否已经被执行过。它在初始化时设置为1（就是说net_dev_init还没有被执行），并由net_dev_init清零。每次register_netdevice被设备驱动调用时，它就检测dev_boot_phase这个值，关在标志被设置的时候执行net_dev_init，即指示这个函数还没有被执行过。</P>
<P>This mechanism is not needed anymore, because register_netdevice cannot be called before net_dev_init if the correct tagging is applied to key device drivers' routines, as described in Chapter 7. However, to detect wrong tagging or buggy code, net_dev_init still clears the value of dev_boot_phase, and register_netdevice uses the macro BUG_ON to make sure it is never called when dev_boot_phase is set.[*]<BR>这种机制现在并不需要了，因为当正确的标签被应用到设备驱动程序的关键字上时，register_netdevice不能在net_dev_init之前被调用，这会在第7章中讨论。然而，为了检测错误的标签，或者是代码bug，net_dev_init还是会清除dev_boot_phase的值，并register_netdevice用宏BUG_ON来确保当dev_boot_phase被设置时，这决对不会调用。</P>
<P>[*] The use of the macros BUG_ON and BUG_TRAP is a common mechanism to make sure necessary conditions are met at specific code points, and is useful when transitioning from one design to another.<BR>BUG_ON和BUG_TRAP宏的使用是一种常用的机制，用于在一些特殊的代码点上，保证一些必须的条件，而且在从一个设计人转到另一个人那里的时候特别有用。</P>
<P>&nbsp;</P><img src ="http://www.cnblogs.com/WuCountry/aggbug/1395148.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47988/" target="_blank">Firefox 3.5匆忙推出漏洞多 Mozilla本月将更新</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item></channel></rss>