• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            我自閑庭信步,悠然自得,不亦樂乎.

                                                   ------ Keep life simple
            GMail/GTalk/MSN:huyi.zg@gmail.com

             

            2007年5月30日

            發(fā)布一個(gè)日語漢字假名轉(zhuǎn)換軟件給大家

            主要使用了微軟的WTL和IME技術(shù),相關(guān)鏈接:
            http://m.shnenglu.com/huyi/archive/2006/03/15/4207.html

            下載地址:
            http://m.shnenglu.com/Files/huyi/kanji.rar

            使用方式:
            選中不知道讀音的日文漢字(中國漢字無效),然后Ctrl+C即可。在系統(tǒng)托盤圖標(biāo)上點(diǎn)擊左鍵,可以打開關(guān)閉監(jiān)視功能。

            軟件截屏:



            2007年6月11日
            放出1.5版,改動如下:
            1.美化了界面,改進(jìn)了前一版本中顯示錯(cuò)位的問題。
            2.3秒后查詢窗口自動小時(shí)。
            3.做了部分過濾,能過濾掉許多非日文漢字的東西。
            4.左鍵默認(rèn)立即關(guān)閉窗口,右鍵定住窗口,使之不會自動消失。
            新的截圖就不放出了,總之漂亮了很多,希望大家繼續(xù)支持。

            posted @ 2007-05-30 11:03 HuYi 閱讀(12682) | 評論 (18)編輯 收藏

            2006年12月22日

            將成員函數(shù)作為std::for_each的第三個(gè)參數(shù)

            vector<Book> books;
            void CBookEditDlg::ForEachBookFunctor(Book book)
            {
            ??? ......
            }
            for_each(books.begin(), books.end(), std::bind1st(mem_fun(&CBookEditDlg::ForEachBookFunctor), this));

            關(guān)鍵點(diǎn)在于mem_fun和bind1st的使用。

            for_each的實(shí)現(xiàn)中最核心的一個(gè)調(diào)用:functor(*iterater);
            由于類非靜態(tài)成員函數(shù),必須在實(shí)例上調(diào)用:(instance->*pfn)(params);
            所以for_each無法直接使用傳過去的函數(shù)地址,函數(shù)指針的第一個(gè)參數(shù)是類的一個(gè)實(shí)例指針(this指針),所以必須想辦法把這個(gè)指針傳過去(使用std::bind1st)

            關(guān)于mem_fun的一些資料,請參考
            http://www.stlchina.org/documents/EffectiveSTL/files/item_41.html

            對于帶兩個(gè)以上參數(shù)的成員函數(shù),用stl是不能達(dá)到目的的,因?yàn)閙em_fun只能生成不帶參數(shù),或者是僅帶一個(gè)參數(shù)的函數(shù)對象(functor),bind1st和bind2st也只能對第一個(gè)或者是第二個(gè)參數(shù)進(jìn)行綁定。
            要實(shí)現(xiàn)對任意數(shù)量參數(shù)的成員函數(shù)生成functor,必須對stl進(jìn)行擴(kuò)展,所幸boost已經(jīng)做到了這點(diǎn),boost::bind和boost::mem_fn就是更加泛化的std::bind1st和std::mem_func

            ??? void ForEachClassFunctor(Class c, CTreeItem treeItem)
            ??? {
            ??? ??? treeView.InsertItem(c.name.c_str(), treeItem, NULL);
            ??? }

            ??? void ForEachBookFunctor(Book book)
            ?? ?{
            ?? ??? ?CTreeItem treeItem = treeView.InsertItem(book.name.c_str(), NULL, NULL);
            ?? ??? ?vector<Class> v;
            ?? ??? ?v.push_back(Class(0,0,"nameClass1", "titleClass1"));
            ?? ??? ?for_each(v.begin(), v.end(),
            ??????????? boost::bind(boost::mem_fn(&CBookEditDlg::ForEachClassFunctor), this, _1, treeItem));
            ?? ?}

            posted @ 2006-12-22 15:10 HuYi 閱讀(5837) | 評論 (3)編輯 收藏

            UTF-8與Unicode的相互轉(zhuǎn)換

            今天用到了Sqlite,由于它內(nèi)部是使用UTF-8編碼,所以在Windows應(yīng)用中出現(xiàn)了亂碼。
            簡單的搜索了一下,相互轉(zhuǎn)換的方法很多,我覺得比較好的,是
            http://www.vckbase.com/document/viewdoc/?id=1444

            我稍微改進(jìn)了一下:

            ??? static WCHAR* UTF82Unicode(WCHAR* pBuffer,char *pSource, int buff_size)
            ??? {
            ??? ??? int i, j, max;
            ??? ??? char* uchar = (char *)pBuffer;
            ??????? max = buff_size - 2;
            ??? ??? for(i = 0, j = 0; pSource[j] != '\0'; i += 2, j += 3)
            ??? ??? {
            ??????????? if (i > max) {
            ??????????????? break;
            ??????????? }
            ??? ??? ??? uchar[i+1] = ((pSource[j] & 0x0F) << 4) + ((pSource[j+1] >> 2) & 0x0F);
            ??? ??? ??? uchar[i] = ((pSource[j+1] & 0x03) << 6) + (pSource[j+2] & 0x3F);
            ??? ??? }
            ??????? uchar[i] = '\0';
            ??????? uchar[i+1] = '\0';
            ??????? return pBuffer;
            ??? }

            在Windows中的話,還有更簡單的方法完成轉(zhuǎn)換:
            比如從UTF-8到Unicode:
            ??? WCHAR buff[255];
            ??? MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, buff, sizeof(buff));
            ??? item.name = W2A(buff);

            argv[i]是要轉(zhuǎn)換的字節(jié)數(shù)組

            posted @ 2006-12-22 15:09 HuYi 閱讀(1868) | 評論 (1)編輯 收藏

            2006年10月14日

            關(guān)于文件操作的封裝處理

            File類本身并不持有文件句柄,它只是集中了一系列對文件的操作方法,如Create,Open等等。這些方法全部都是靜態(tài)的,也不進(jìn)行任何的安全檢測,僅僅是直接調(diào)用pspsdk來完成任務(wù),如果出現(xiàn)錯(cuò)誤,則返回負(fù)值。
            File的Open等方法可以創(chuàng)建針對指定文件讀寫的流對象FileStream,句柄由FileStream自己創(chuàng)建和持有管理,F(xiàn)ile::Open只是傳達(dá)路徑信息。
            可以把File看作是一個(gè)門面,集中了對文件的所有操作,并且不需要?jiǎng)?chuàng)建File對象就可以直接執(zhí)行這些操作。所以說File為文件的單一操作提供了快捷簡便的方式。
            除了幾個(gè)創(chuàng)建FileStream流的操作外,其他操作都不會長期占用句柄資源,遵循"句柄創(chuàng)建-執(zhí)行具體操作-釋放句柄"的步驟。

            如果需要頻繁的操作文件,則需要一個(gè)類來長期持有句柄,避免經(jīng)常性的打開和關(guān)閉文件,故此引入FileInfo類。FileInfo執(zhí)行Append等操作時(shí),都是使用事先打開的文件句柄。
            同時(shí),F(xiàn)ileInfo也可以創(chuàng)建FileStream實(shí)例,但這個(gè)時(shí)候,文件的句柄生命周期應(yīng)該由FileInfo來管理,F(xiàn)ileStream可以使用這個(gè)句柄,但不能結(jié)束其生命周期,F(xiàn)ileStream::Close()方法僅僅使這個(gè)流處于關(guān)閉(不可讀寫)狀態(tài),但并不實(shí)際關(guān)閉文件句柄。
            這種情況下,F(xiàn)ileInfo所創(chuàng)建的FileStream::Close()的行為和前面File所創(chuàng)建的FileStream::Close()行為有差異。因?yàn)镕ile并不持有句柄,所以它創(chuàng)建了FileStream對象后,句柄應(yīng)該由FileStream來管理。但FileInfo所創(chuàng)建的FileStream是使用的FileInfo所創(chuàng)建好的句柄,所以它并不對此句柄負(fù)責(zé)。

            實(shí)現(xiàn)策略:
            1.使用基于繼承的多態(tài)或基于模板的靜多態(tài)。
            2.使用函數(shù)回調(diào)。把Close做成調(diào)用函數(shù)指針,通過不同的FileStream構(gòu)造函數(shù)調(diào)用,來設(shè)置指針指向不同的Close函數(shù)實(shí)現(xiàn)。(關(guān)閉句柄或不關(guān)閉句柄)
            這兩種做法的優(yōu)劣性正在考證中,請?zhí)岢鲆庖姟?


            補(bǔ)充:File和FileInfo的關(guān)系在dotnet中也有體現(xiàn),不過他們主要是從錯(cuò)誤檢測方面考慮。
            最終的目的是要為客戶提供一個(gè)統(tǒng)一的界面,所以不能用太復(fù)雜的模板。

            經(jīng)過慎重考慮,我還是決定用虛函數(shù),放棄了模板。

            posted @ 2006-10-14 16:45 HuYi 閱讀(1124) | 評論 (0)編輯 收藏

            2006年10月13日

            為什么要用“((”取代“(”?

            在做日志接口的時(shí)候,真實(shí)的接口函數(shù)應(yīng)該是如下樣式的:
            __static_logger__.log(int level,const char* fmt, ...);
            這里使用了printf類似的技術(shù):可變參數(shù)。
            這個(gè)技術(shù)可以動態(tài)的替換字符串fmt中的內(nèi)容。
            同時(shí),這個(gè)方法可能會被重載,用于不需要可變參數(shù)的情況:
            __static_logger__.log(int level,const char* fmt);

            通常,我們還會定義一些輔助用的宏:
            #define KLOG(X) \
            ??? do { \
            ??????? KDBG::printf X; \
            ??? } while (0)

            使用的時(shí)候,必須按照下面的格式:
            KLOG((LM_ERROR, "%s\n", strerror(errno)));
            注意,使用了雙層的括號“((”

            為什么不把宏改成:
            #define KLOG(X,Y,...) \
            ??? do { \
            ??????? KDBG::log(X,Y,__VA_ARGS__); \
            ??? } while (0)s
            從而按如下的“標(biāo)準(zhǔn)形式”來使用LOG呢?
            KLOG(LM_ERROR, "%s\n", strerror(errno));


            答案是宏不能像函數(shù)那樣重載,KLOG宏只能有一個(gè),就是最后定義的那個(gè),也就是能接受的參數(shù)個(gè)數(shù)是固定的。

            posted @ 2006-10-13 13:50 HuYi 閱讀(1718) | 評論 (1)編輯 收藏

            2006年7月31日

            二環(huán)十三郎傳說中的裝備

            1.8T發(fā)動機(jī)總成?55000元
            大眾原廠MO250變速箱?20000
            1.8T半軸?3000
            BMC進(jìn)汽?2500
            運(yùn)動款寶來凸輪軸?3000
            運(yùn)動款寶來渦輪?9800
            SUPERSPRING全段排氣?9800
            尾牙?7000
            法雷奧離合器?3000
            原廠180匹電腦程序?2800
            DENSO火花塞?600
            HKS泄氣閥?2800
            4公斤回油閥?300

            SPAXJ減震器?7000
            NEUSPEED前后防傾桿?2000
            原廠前312mm后256mm剎車盤9000
            仿RS418寸輪圈?3200
            米其林PS2輪胎?10000

            自加工前后包圍?3000
            自制機(jī)頭蓋?1500
            氙氣大燈?1800
            HKS渦輪壓力表?900
            SPARCO方向盤?1800
            4MOTION檔把?1200

            posted @ 2006-07-31 18:26 HuYi 閱讀(1200) | 評論 (3)編輯 收藏

            2006年7月28日

            怎么才能成一名架構(gòu)師?

            這個(gè)題目大了點(diǎn),不適合我這種剛參加工作不久的人來回答。

            Blog很久沒有更新了,答應(yīng)了朋友寫點(diǎn)這方面的看法,就在這里表達(dá)一下自己的意見,拋磚引玉。

            架構(gòu)師也有不同的類型。我主要想討論軟件方面的架構(gòu)師。

            一是體系結(jié)構(gòu)級的,要負(fù)責(zé)產(chǎn)品的部署,硬件,網(wǎng)絡(luò)等等很多整體上的東西,這一類不僅需要扎實(shí)而廣泛的基礎(chǔ)知識,更需要經(jīng)驗(yàn),特別是在大企業(yè)工作的經(jīng)驗(yàn)。這一點(diǎn)也是在單位看了一些日本人的設(shè)計(jì),才慢慢體會到。

            二是軟件本身的架構(gòu),是我想重點(diǎn)討論的。
            軟件應(yīng)用的領(lǐng)域不同,架構(gòu)也有很大的差別,嵌入式有嵌入式的做法,電信軟件有電信軟件的做法,企業(yè)應(yīng)用有企業(yè)應(yīng)用的做法,桌面有桌面的做法。如果要全部討論,我沒有這個(gè)實(shí)力,所以只說最常見的企業(yè)應(yīng)用開發(fā)和桌面軟件開發(fā)。

            最重要的基礎(chǔ),我覺得是OO,不管實(shí)際編程設(shè)計(jì)是否是OO的,都應(yīng)該了解,具備OO的思想。強(qiáng)調(diào)一下,采用最合適的思想和手段來開發(fā)軟件,而不一定非要用OO,或者是非不用OO。我比較堅(jiān)信的一點(diǎn)是,當(dāng)代及未來的程序員,或許在實(shí)際工作中不需要用到OO,比如說搞嵌入式開發(fā),或者Linux底層方面開發(fā)的(事實(shí)上,Linux中也用到了OO,比如文件系統(tǒng)),但必須是了解OO的。

            一,萬丈高樓從地起,一力承擔(dān)靠地基

            1。敏捷軟件開發(fā)



            為什么推薦這本呢?其實(shí)是推薦這本書的前半部分。因?yàn)樗那耙话胍欢梢宰屓硕恳恍拢屓酥繭O除了封裝,繼承,多態(tài)以外,還有更多的東西,而且這本書十分容易懂。


            2。《OOP啟思錄》


            絕對的經(jīng)典,不過就比較枯燥了。全部是關(guān)于OO的理論及設(shè)計(jì)準(zhǔn)則。所以雖然非常基礎(chǔ),但并沒有作為第一步推薦的書。看這個(gè),需要對OO有了一定的了解,才能堅(jiān)持下去。

            二,順藤摸瓜,尋根究底
            初學(xué)的人常說,OO就是對象,就是封裝繼承多態(tài)。對,沒錯(cuò),但語言是怎么支持這些OO特性的呢?

            1。深度探索C++對象模型



            我們CPP粉絲有福了,本書探索了C++對OO的支持,底層對象模型實(shí)現(xiàn)等非常有價(jià)值的內(nèi)容。同樣是相對枯燥的,而且頗具難度,所以學(xué)習(xí)之前最好對C++這門語言熟悉,而且有興趣去了解它的本質(zhì)。
            對于非CPP幫派成員,看這個(gè)可能比較困難,但我也找不出其他替代的學(xué)習(xí)書籍了,知道的朋友請補(bǔ)充。

            第三,練招
            內(nèi)功基礎(chǔ)有了,就該練習(xí)劍招拳譜了。

            軟件設(shè)計(jì)的劍譜,就是設(shè)計(jì)模式,就是前人總結(jié)出來的套路,當(dāng)然你也可以自創(chuàng)。但自創(chuàng)之前,一定要多看多想,充分吸取前人的精髓。

            1,Java與模式



            國人寫的不得不推薦的一本好書(也有很多人說他太啰嗦)。我初學(xué)的時(shí)候,一上來就是Gof的傳世經(jīng)典,結(jié)果薄薄的一本冊子,花了我整整一年的時(shí)間,還覺得理解不夠。當(dāng)我看了一遍Java與模式,豁然開朗,如果先有了這個(gè),一定不會覺得設(shè)計(jì)模式那么難。

            2。設(shè)計(jì)模式:可復(fù)用面向?qū)ο筌浖幕A(chǔ)

            前面所提到的“傳世之作”,為什么那么經(jīng)典?因?yàn)榫渚湓挾际墙?jīng)典,可以說沒有一句廢話(《java與模式》就被人說成廢話連篇)。
            java與模式,我看完后就送女朋友了,而這本書,我卻保存了起來,作為手冊查,這就是我的用法。





            未完待續(xù)。。。

            posted @ 2006-07-28 00:02 HuYi 閱讀(1246) | 評論 (1)編輯 收藏

            2006年6月20日

            Linux啟動協(xié)議Ver.2.04

            ?????? THE LINUX/I386 BOOT PROTOCOL
            ?????? ----------------------------

            ????? H. Peter Anvin <hpa@zytor.com>
            ???Last update 2005-09-02

            On the i386 platform, the Linux kernel uses a rather complicated boot
            convention.? This has evolved partially due to historical aspects, as
            well as the desire in the early days to have the kernel itself be a
            bootable image, the complicated PC memory model and due to changed
            expectations in the PC industry caused by the effective demise of
            real-mode DOS as a mainstream operating system.

            Currently, four versions of the Linux/i386 boot protocol exist.

            Old kernels:?zImage/Image support only.? Some very early kernels
            ??may not even support a command line.

            Protocol 2.00:?(Kernel 1.3.73) Added bzImage and initrd support, as
            ??well as a formalized way to communicate between the
            ??boot loader and the kernel.? setup.S made relocatable,
            ??although the traditional setup area still assumed
            ??writable.

            Protocol 2.01:?(Kernel 1.3.76) Added a heap overrun warning.

            Protocol 2.02:?(Kernel 2.4.0-test3-pre3) New command line protocol.
            ??Lower the conventional memory ceiling.?No overwrite
            ??of the traditional setup area, thus making booting
            ??safe for systems which use the EBDA from SMM or 32-bit
            ??BIOS entry points.? zImage deprecated but still
            ??supported.

            Protocol 2.03:?(Kernel 2.4.18-pre1) Explicitly makes the highest possible
            ??initrd address available to the bootloader.

            Protocol 2.04:?(Kernel 2.6.14) Extend the syssize field to four bytes.


            **** MEMORY LAYOUT

            The traditional memory map for the kernel loader, used for Image or
            zImage kernels, typically looks like:

            ?|??? |
            0A0000?+------------------------+
            ?|? Reserved for BIOS? |?Do not use.? Reserved for BIOS EBDA.
            09A000?+------------------------+
            ?|? Stack/heap/cmdline? |?For use by the kernel real-mode code.
            098000?+------------------------+?
            ?|? Kernel setup?? |?The kernel real-mode code.
            090200?+------------------------+
            ?|? Kernel boot sector? |?The kernel legacy boot sector.
            090000?+------------------------+
            ?|? Protected-mode kernel |?The bulk of the kernel image.
            010000?+------------------------+
            ?|? Boot loader?? |?<- Boot sector entry point 0000:7C00
            001000?+------------------------+
            ?|? Reserved for MBR/BIOS |
            000800?+------------------------+
            ?|? Typically used by MBR |
            000600?+------------------------+
            ?|? BIOS use only? |
            000000?+------------------------+


            When using bzImage, the protected-mode kernel was relocated to
            0x100000 ("high memory"), and the kernel real-mode block (boot sector,
            setup, and stack/heap) was made relocatable to any address between
            0x10000 and end of low memory.?Unfortunately, in protocols 2.00 and
            2.01 the command line is still required to live in the 0x9XXXX memory
            range, and that memory range is still overwritten by the early kernel.
            The 2.02 protocol resolves that problem.

            It is desirable to keep the "memory ceiling" -- the highest point in
            low memory touched by the boot loader -- as low as possible, since
            some newer BIOSes have begun to allocate some rather large amounts of
            memory, called the Extended BIOS Data Area, near the top of low
            memory.? The boot loader should use the "INT 12h" BIOS call to verify
            how much low memory is available.

            Unfortunately, if INT 12h reports that the amount of memory is too
            low, there is usually nothing the boot loader can do but to report an
            error to the user.? The boot loader should therefore be designed to
            take up as little space in low memory as it reasonably can.? For
            zImage or old bzImage kernels, which need data written into the
            0x90000 segment, the boot loader should make sure not to use memory
            above the 0x9A000 point; too many BIOSes will break above that point.


            **** THE REAL-MODE KERNEL HEADER

            In the following text, and anywhere in the kernel boot sequence, "a
            sector" refers to 512 bytes.? It is independent of the actual sector
            size of the underlying medium.

            The first step in loading a Linux kernel should be to load the
            real-mode code (boot sector and setup code) and then examine the
            following header at offset 0x01f1.? The real-mode code can total up to
            32K, although the boot loader may choose to load only the first two
            sectors (1K) and then examine the bootup sector size.

            The header looks like:

            Offset?Proto?Name??Meaning
            /Size

            01F1/1?ALL(1?setup_sects?The size of the setup in sectors
            01F2/2?ALL?root_flags?If set, the root is mounted readonly
            01F4/4?2.04+(2?syssize??The size of the 32-bit code in 16-byte paras
            01F8/2?ALL?ram_size?DO NOT USE - for bootsect.S use only
            01FA/2?ALL?vid_mode?Video mode control
            01FC/2?ALL?root_dev?Default root device number
            01FE/2?ALL?boot_flag?0xAA55 magic number
            0200/2?2.00+?jump??Jump instruction
            0202/4?2.00+?header??Magic signature "HdrS"
            0206/2?2.00+?version??Boot protocol version supported
            0208/4?2.00+?realmode_swtch?Boot loader hook (see below)
            020C/2?2.00+?start_sys?The load-low segment (0x1000) (obsolete)
            020E/2?2.00+?kernel_version?Pointer to kernel version string
            0210/1?2.00+?type_of_loader?Boot loader identifier
            0211/1?2.00+?loadflags?Boot protocol option flags
            0212/2?2.00+?setup_move_size?Move to high memory size (used with hooks)
            0214/4?2.00+?code32_start?Boot loader hook (see below)
            0218/4?2.00+?ramdisk_image?initrd load address (set by boot loader)
            021C/4?2.00+?ramdisk_size?initrd size (set by boot loader)
            0220/4?2.00+?bootsect_kludge?DO NOT USE - for bootsect.S use only
            0224/2?2.01+?heap_end_ptr?Free memory after setup end
            0226/2?N/A?pad1??Unused
            0228/4?2.02+?cmd_line_ptr?32-bit pointer to the kernel command line
            022C/4?2.03+?initrd_addr_max?Highest legal initrd address

            (1) For backwards compatibility, if the setup_sects field contains 0, the
            ??? real value is 4.

            (2) For boot protocol prior to 2.04, the upper two bytes of the syssize
            ??? field are unusable, which means the size of a bzImage kernel
            ??? cannot be determined.

            If the "HdrS" (0x53726448) magic number is not found at offset 0x202,
            the boot protocol version is "old".? Loading an old kernel, the
            following parameters should be assumed:

            ?Image type = zImage
            ?initrd not supported
            ?Real-mode kernel must be located at 0x90000.

            Otherwise, the "version" field contains the protocol version,
            e.g. protocol version 2.01 will contain 0x0201 in this field.? When
            setting fields in the header, you must make sure only to set fields
            supported by the protocol version in use.

            The "kernel_version" field, if set to a nonzero value, contains a
            pointer to a null-terminated human-readable kernel version number
            string, less 0x200.? This can be used to display the kernel version to
            the user.? This value should be less than (0x200*setup_sects).? For
            example, if this value is set to 0x1c00, the kernel version number
            string can be found at offset 0x1e00 in the kernel file.? This is a
            valid value if and only if the "setup_sects" field contains the value
            14 or higher.

            Most boot loaders will simply load the kernel at its target address
            directly.? Such boot loaders do not need to worry about filling in
            most of the fields in the header.? The following fields should be
            filled out, however:

            ? vid_mode:
            ?Please see the section on SPECIAL COMMAND LINE OPTIONS.

            ? type_of_loader:
            ?If your boot loader has an assigned id (see table below), enter
            ?0xTV here, where T is an identifier for the boot loader and V is
            ?a version number.? Otherwise, enter 0xFF here.

            ?Assigned boot loader ids:
            ?0? LILO
            ?1? Loadlin
            ?2? bootsect-loader
            ?3? SYSLINUX
            ?4? EtherBoot
            ?5? ELILO
            ?7? GRuB
            ?8? U-BOOT

            ?Please contact <hpa@zytor.com> if you need a bootloader ID
            ?value assigned.

            ? loadflags, heap_end_ptr:
            ?If the protocol version is 2.01 or higher, enter the
            ?offset limit of the setup heap into heap_end_ptr and set the
            ?0x80 bit (CAN_USE_HEAP) of loadflags.? heap_end_ptr appears to
            ?be relative to the start of setup (offset 0x0200).

            ? setup_move_size:
            ?When using protocol 2.00 or 2.01, if the real mode
            ?kernel is not loaded at 0x90000, it gets moved there later in
            ?the loading sequence.? Fill in this field if you want
            ?additional data (such as the kernel command line) moved in
            ?addition to the real-mode kernel itself.

            ? ramdisk_image, ramdisk_size:
            ?If your boot loader has loaded an initial ramdisk (initrd),
            ?set ramdisk_image to the 32-bit pointer to the ramdisk data
            ?and the ramdisk_size to the size of the ramdisk data.

            ?The initrd should typically be located as high in memory as
            ?possible, as it may otherwise get overwritten by the early
            ?kernel initialization sequence.? However, it must never be
            ?located above the address specified in the initrd_addr_max
            ?field.?The initrd should be at least 4K page aligned.

            ? cmd_line_ptr:
            ?If the protocol version is 2.02 or higher, this is a 32-bit
            ?pointer to the kernel command line.? The kernel command line
            ?can be located anywhere between the end of setup and 0xA0000.
            ?Fill in this field even if your boot loader does not support a
            ?command line, in which case you can point this to an empty
            ?string (or better yet, to the string "auto".)? If this field
            ?is left at zero, the kernel will assume that your boot loader
            ?does not support the 2.02+ protocol.

            ? ramdisk_max:
            ?The maximum address that may be occupied by the initrd
            ?contents.? For boot protocols 2.02 or earlier, this field is
            ?not present, and the maximum address is 0x37FFFFFF.? (This
            ?address is defined as the address of the highest safe byte, so
            ?if your ramdisk is exactly 131072 bytes long and this field is
            ?0x37FFFFFF, you can start your ramdisk at 0x37FE0000.)


            **** THE KERNEL COMMAND LINE

            The kernel command line has become an important way for the boot
            loader to communicate with the kernel.? Some of its options are also
            relevant to the boot loader itself, see "special command line options"
            below.

            The kernel command line is a null-terminated string currently up to
            255 characters long, plus the final null.? A string that is too long
            will be automatically truncated by the kernel, a boot loader may allow
            a longer command line to be passed to permit future kernels to extend
            this limit.

            If the boot protocol version is 2.02 or later, the address of the
            kernel command line is given by the header field cmd_line_ptr (see
            above.)? This address can be anywhere between the end of the setup
            heap and 0xA0000.

            If the protocol version is *not* 2.02 or higher, the kernel
            command line is entered using the following protocol:

            ?At offset 0x0020 (word), "cmd_line_magic", enter the magic
            ?number 0xA33F.

            ?At offset 0x0022 (word), "cmd_line_offset", enter the offset
            ?of the kernel command line (relative to the start of the
            ?real-mode kernel).
            ?
            ?The kernel command line *must* be within the memory region
            ?covered by setup_move_size, so you may need to adjust this
            ?field.


            **** SAMPLE BOOT CONFIGURATION

            As a sample configuration, assume the following layout of the real
            mode segment (this is a typical, and recommended layout):

            ?0x0000-0x7FFF?Real mode kernel
            ?0x8000-0x8FFF?Stack and heap
            ?0x9000-0x90FF?Kernel command line

            Such a boot loader should enter the following fields in the header:

            ?unsigned long base_ptr;?/* base address for real-mode segment */

            ?if ( setup_sects == 0 ) {
            ??setup_sects = 4;
            ?}

            ?if ( protocol >= 0x0200 ) {
            ??type_of_loader = <type code>;
            ??if ( loading_initrd ) {
            ???ramdisk_image = <initrd_address>;
            ???ramdisk_size = <initrd_size>;
            ??}
            ??if ( protocol >= 0x0201 ) {
            ???heap_end_ptr = 0x9000 - 0x200;
            ???loadflags |= 0x80; /* CAN_USE_HEAP */
            ??}
            ??if ( protocol >= 0x0202 ) {
            ???cmd_line_ptr = base_ptr + 0x9000;
            ??} else {
            ???cmd_line_magic?= 0xA33F;
            ???cmd_line_offset = 0x9000;
            ???setup_move_size = 0x9100;
            ??}
            ?} else {
            ??/* Very old kernel */

            ??cmd_line_magic?= 0xA33F;
            ??cmd_line_offset = 0x9000;

            ??/* A very old kernel MUST have its real-mode code
            ???? loaded at 0x90000 */

            ??if ( base_ptr != 0x90000 ) {
            ???/* Copy the real-mode kernel */
            ???memcpy(0x90000, base_ptr, (setup_sects+1)*512);
            ???/* Copy the command line */
            ???memcpy(0x99000, base_ptr+0x9000, 256);

            ???base_ptr = 0x90000;?? /* Relocated */
            ??}

            ??/* It is recommended to clear memory up to the 32K mark */
            ??memset(0x90000 + (setup_sects+1)*512, 0,
            ???????? (64-(setup_sects+1))*512);
            ?}


            **** LOADING THE REST OF THE KERNEL

            The 32-bit (non-real-mode) kernel starts at offset (setup_sects+1)*512
            in the kernel file (again, if setup_sects == 0 the real value is 4.)
            It should be loaded at address 0x10000 for Image/zImage kernels and
            0x100000 for bzImage kernels.

            The kernel is a bzImage kernel if the protocol >= 2.00 and the 0x01
            bit (LOAD_HIGH) in the loadflags field is set:

            ?is_bzImage = (protocol >= 0x0200) && (loadflags & 0x01);
            ?load_address = is_bzImage ? 0x100000 : 0x10000;

            Note that Image/zImage kernels can be up to 512K in size, and thus use
            the entire 0x10000-0x90000 range of memory.? This means it is pretty
            much a requirement for these kernels to load the real-mode part at
            0x90000.? bzImage kernels allow much more flexibility.


            **** SPECIAL COMMAND LINE OPTIONS

            If the command line provided by the boot loader is entered by the
            user, the user may expect the following command line options to work.
            They should normally not be deleted from the kernel command line even
            though not all of them are actually meaningful to the kernel.? Boot
            loader authors who need additional command line options for the boot
            loader itself should get them registered in
            Documentation/kernel-parameters.txt to make sure they will not
            conflict with actual kernel options now or in the future.

            ? vga=<mode>
            ?<mode> here is either an integer (in C notation, either
            ?decimal, octal, or hexadecimal) or one of the strings
            ?"normal" (meaning 0xFFFF), "ext" (meaning 0xFFFE) or "ask"
            ?(meaning 0xFFFD).? This value should be entered into the
            ?vid_mode field, as it is used by the kernel before the command
            ?line is parsed.

            ? mem=<size>
            ?<size> is an integer in C notation optionally followed by K, M
            ?or G (meaning << 10, << 20 or << 30).? This specifies the end
            ?of memory to the kernel. This affects the possible placement
            ?of an initrd, since an initrd should be placed near end of
            ?memory.? Note that this is an option to *both* the kernel and
            ?the bootloader!

            ? initrd=<file>
            ?An initrd should be loaded.? The meaning of <file> is
            ?obviously bootloader-dependent, and some boot loaders
            ?(e.g. LILO) do not have such a command.

            In addition, some boot loaders add the following options to the
            user-specified command line:

            ? BOOT_IMAGE=<file>
            ?The boot image which was loaded.? Again, the meaning of <file>
            ?is obviously bootloader-dependent.

            ? auto
            ?The kernel was booted without explicit user intervention.

            If these options are added by the boot loader, it is highly
            recommended that they are located *first*, before the user-specified
            or configuration-specified command line.? Otherwise, "init=/bin/sh"
            gets confused by the "auto" option.


            **** RUNNING THE KERNEL

            The kernel is started by jumping to the kernel entry point, which is
            located at *segment* offset 0x20 from the start of the real mode
            kernel.? This means that if you loaded your real-mode kernel code at
            0x90000, the kernel entry point is 9020:0000.

            At entry, ds = es = ss should point to the start of the real-mode
            kernel code (0x9000 if the code is loaded at 0x90000), sp should be
            set up properly, normally pointing to the top of the heap, and
            interrupts should be disabled.? Furthermore, to guard against bugs in
            the kernel, it is recommended that the boot loader sets fs = gs = ds =
            es = ss.

            In our example from above, we would do:

            ?/* Note: in the case of the "old" kernel protocol, base_ptr must
            ??? be == 0x90000 at this point; see the previous sample code */

            ?seg = base_ptr >> 4;

            ?cli();?/* Enter with interrupts disabled! */

            ?/* Set up the real-mode kernel stack */
            ?_SS = seg;
            ?_SP = 0x9000;?/* Load SP immediately after loading SS! */

            ?_DS = _ES = _FS = _GS = seg;
            ?jmp_far(seg+0x20, 0);?/* Run the kernel */

            If your boot sector accesses a floppy drive, it is recommended to
            switch off the floppy motor before running the kernel, since the
            kernel boot leaves interrupts off and thus the motor will not be
            switched off, especially if the loaded kernel has the floppy driver as
            a demand-loaded module!


            **** ADVANCED BOOT TIME HOOKS

            If the boot loader runs in a particularly hostile environment (such as
            LOADLIN, which runs under DOS) it may be impossible to follow the
            standard memory location requirements.? Such a boot loader may use the
            following hooks that, if set, are invoked by the kernel at the
            appropriate time.? The use of these hooks should probably be
            considered an absolutely last resort!

            IMPORTANT: All the hooks are required to preserve %esp, %ebp, %esi and
            %edi across invocation.

            ? realmode_swtch:
            ?A 16-bit real mode far subroutine invoked immediately before
            ?entering protected mode.? The default routine disables NMI, so
            ?your routine should probably do so, too.

            ? code32_start:
            ?A 32-bit flat-mode routine *jumped* to immediately after the
            ?transition to protected mode, but before the kernel is
            ?uncompressed.? No segments, except CS, are set up; you should
            ?set them up to KERNEL_DS (0x18) yourself.

            ?After completing your hook, you should jump to the address
            ?that was in this field before your boot loader overwrote it.

            posted @ 2006-06-20 14:46 HuYi 閱讀(1570) | 評論 (0)編輯 收藏

            2006年5月31日

            Google為什么會被封鎖?

            很早以前就聽說過Google被封鎖的消息,因?yàn)樽约簺]有遇到過,也不太相信真會有這樣的事情,多可笑呀.

            不過自從感受到了一次sourceforge被封,就覺得在中國,或許真會發(fā)生這樣的事情.

            今天,google終于掛了,gmail也掛了,我也無語了.

            打聽了一下,全國好多地方的網(wǎng)友都訪問不了google了.

            業(yè)內(nèi)最令人鄙視的案例莫過于微軟靠捆綁IE搞跨了網(wǎng)景,微軟的這個(gè)脾氣至今還是大家鄙視它的主因.但是請注意,微軟并沒有禁止Windows用戶使用網(wǎng)景的服務(wù)!!!!

            希望中國的google事件不要成為他國的笑柄.

            http://post.baidu.com/f?kz=103530334

            僅以此貼紀(jì)念Google GMail ?GTalk




            支持Google的朋友請?jiān)谶@里簽名吧!

            希望zf早點(diǎn)把GMail和GTalk還給我們!!

            posted @ 2006-05-31 23:28 HuYi 閱讀(6298) | 評論 (13)編輯 收藏

            2006年5月26日

            這回看見好貼子就有話說了^^

                 摘要: 看了樓主的帖子 , 不由得精神 為 之一振 , 自 覺 七 經(jīng) 八脈 ...  閱讀全文

            posted @ 2006-05-26 10:37 HuYi 閱讀(1119) | 評論 (1)編輯 收藏

            僅列出標(biāo)題  下一頁

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(12)

            隨筆分類

            相冊

            收藏夾

            友情鏈接

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            国产午夜精品久久久久免费视| 中文字幕无码久久久| 久久伊人影视| 久久精品国产精品亚洲人人 | 精品久久久久久久久中文字幕| 久久人与动人物a级毛片| 久久久久噜噜噜亚洲熟女综合| 老司机国内精品久久久久| 国产精品久久久久久久| 久久99国产精品久久99果冻传媒| 国产精品视频久久| 日本精品久久久久中文字幕8| 女人香蕉久久**毛片精品| 亚洲狠狠综合久久| 久久精品国产亚洲Aⅴ蜜臀色欲| 国产免费久久精品丫丫| 久久久久国产一区二区| 亚洲七七久久精品中文国产| 狠狠综合久久AV一区二区三区| 久久婷婷激情综合色综合俺也去| 97精品久久天干天天天按摩| 久久久精品免费国产四虎| 91久久福利国产成人精品| 亚洲人成电影网站久久| 伊人久久大香线蕉av不卡 | 久久亚洲AV成人无码软件| 伊人久久大香线蕉亚洲| 激情综合色综合久久综合| 欧美日韩精品久久免费| 99久久精品午夜一区二区 | 99蜜桃臀久久久欧美精品网站| 久久av无码专区亚洲av桃花岛| 91久久精品无码一区二区毛片| 午夜精品久久久久| 狠狠色丁香久久综合五月| 亚洲精品97久久中文字幕无码| 99久久无色码中文字幕人妻| 久久综合伊人77777| 国内精品久久久人妻中文字幕| 亚洲国产成人久久综合碰| 四虎国产精品免费久久久|