• <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日

            發布一個日語漢字假名轉換軟件給大家

            主要使用了微軟的WTL和IME技術,相關鏈接:
            http://www.shnenglu.com/huyi/archive/2006/03/15/4207.html

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

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

            軟件截屏:



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

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

            2006年12月22日

            將成員函數作為std::for_each的第三個參數

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

            關鍵點在于mem_fun和bind1st的使用。

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

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

            對于帶兩個以上參數的成員函數,用stl是不能達到目的的,因為mem_fun只能生成不帶參數,或者是僅帶一個參數的函數對象(functor),bind1st和bind2st也只能對第一個或者是第二個參數進行綁定。
            要實現對任意數量參數的成員函數生成functor,必須對stl進行擴展,所幸boost已經做到了這點,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 閱讀(5823) | 評論 (3)編輯 收藏

            UTF-8與Unicode的相互轉換

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

            我稍微改進了一下:

            ??? 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中的話,還有更簡單的方法完成轉換:
            比如從UTF-8到Unicode:
            ??? WCHAR buff[255];
            ??? MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, buff, sizeof(buff));
            ??? item.name = W2A(buff);

            argv[i]是要轉換的字節數組

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

            2006年10月14日

            關于文件操作的封裝處理

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

            如果需要頻繁的操作文件,則需要一個類來長期持有句柄,避免經常性的打開和關閉文件,故此引入FileInfo類。FileInfo執行Append等操作時,都是使用事先打開的文件句柄。
            同時,FileInfo也可以創建FileStream實例,但這個時候,文件的句柄生命周期應該由FileInfo來管理,FileStream可以使用這個句柄,但不能結束其生命周期,FileStream::Close()方法僅僅使這個流處于關閉(不可讀寫)狀態,但并不實際關閉文件句柄。
            這種情況下,FileInfo所創建的FileStream::Close()的行為和前面File所創建的FileStream::Close()行為有差異。因為File并不持有句柄,所以它創建了FileStream對象后,句柄應該由FileStream來管理。但FileInfo所創建的FileStream是使用的FileInfo所創建好的句柄,所以它并不對此句柄負責。

            實現策略:
            1.使用基于繼承的多態或基于模板的靜多態。
            2.使用函數回調。把Close做成調用函數指針,通過不同的FileStream構造函數調用,來設置指針指向不同的Close函數實現。(關閉句柄或不關閉句柄)
            這兩種做法的優劣性正在考證中,請提出意見。


            補充:File和FileInfo的關系在dotnet中也有體現,不過他們主要是從錯誤檢測方面考慮。
            最終的目的是要為客戶提供一個統一的界面,所以不能用太復雜的模板。

            經過慎重考慮,我還是決定用虛函數,放棄了模板。

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

            2006年10月13日

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

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

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

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

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


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

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

            2006年7月31日

            二環十三郎傳說中的裝備

            1.8T發動機總成?55000元
            大眾原廠MO250變速箱?20000
            1.8T半軸?3000
            BMC進汽?2500
            運動款寶來凸輪軸?3000
            運動款寶來渦輪?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
            自制機頭蓋?1500
            氙氣大燈?1800
            HKS渦輪壓力表?900
            SPARCO方向盤?1800
            4MOTION檔把?1200

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

            2006年7月28日

            怎么才能成一名架構師?

            這個題目大了點,不適合我這種剛參加工作不久的人來回答。

            Blog很久沒有更新了,答應了朋友寫點這方面的看法,就在這里表達一下自己的意見,拋磚引玉。

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

            一是體系結構級的,要負責產品的部署,硬件,網絡等等很多整體上的東西,這一類不僅需要扎實而廣泛的基礎知識,更需要經驗,特別是在大企業工作的經驗。這一點也是在單位看了一些日本人的設計,才慢慢體會到。

            二是軟件本身的架構,是我想重點討論的。
            軟件應用的領域不同,架構也有很大的差別,嵌入式有嵌入式的做法,電信軟件有電信軟件的做法,企業應用有企業應用的做法,桌面有桌面的做法。如果要全部討論,我沒有這個實力,所以只說最常見的企業應用開發和桌面軟件開發。

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

            一,萬丈高樓從地起,一力承擔靠地基

            1。敏捷軟件開發



            為什么推薦這本呢?其實是推薦這本書的前半部分。因為它的前一半一定可以讓人耳目一新,讓人知道OO除了封裝,繼承,多態以外,還有更多的東西,而且這本書十分容易懂。


            2。《OOP啟思錄》


            絕對的經典,不過就比較枯燥了。全部是關于OO的理論及設計準則。所以雖然非常基礎,但并沒有作為第一步推薦的書。看這個,需要對OO有了一定的了解,才能堅持下去。

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

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



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

            第三,練招
            內功基礎有了,就該練習劍招拳譜了。

            軟件設計的劍譜,就是設計模式,就是前人總結出來的套路,當然你也可以自創。但自創之前,一定要多看多想,充分吸取前人的精髓。

            1,Java與模式



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

            2。設計模式:可復用面向對象軟件的基礎

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





            未完待續。。。

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

            2006年6月20日

            Linux啟動協議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 閱讀(1564) | 評論 (0)編輯 收藏

            2006年5月31日

            Google為什么會被封鎖?

            很早以前就聽說過Google被封鎖的消息,因為自己沒有遇到過,也不太相信真會有這樣的事情,多可笑呀.

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

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

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

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

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

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

            僅以此貼紀念Google GMail ?GTalk




            支持Google的朋友請在這里簽名吧!

            希望zf早點把GMail和GTalk還給我們!!

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

            2006年5月26日

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

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

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

            僅列出標題  下一頁

            導航

            統計

            常用鏈接

            留言簿(12)

            隨筆分類

            相冊

            收藏夾

            友情鏈接

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            色偷偷888欧美精品久久久| 中文国产成人精品久久不卡| 色综合久久88色综合天天| 99久久精品免费| 亚洲精品美女久久久久99| 国产成人久久激情91| 亚洲欧洲久久久精品| 久久国产色AV免费观看| 久久精品国产第一区二区| 亚洲av日韩精品久久久久久a | 东京热TOKYO综合久久精品| 久久99久久99小草精品免视看| 国产精品成人久久久久久久| 无码人妻久久一区二区三区免费| 国内精品久久久久久久涩爱| 久久久老熟女一区二区三区| 久久丝袜精品中文字幕| 久久综合欧美成人| 久久久无码人妻精品无码| 久久国产AVJUST麻豆| 久久se精品一区精品二区国产 | 性做久久久久久久久| 精品久久久久久国产| 久久亚洲精品无码AV红樱桃| 亚洲第一永久AV网站久久精品男人的天堂AV | 伊人久久大香线蕉av一区| 久久久91人妻无码精品蜜桃HD | 亚洲欧美另类日本久久国产真实乱对白| 精品无码久久久久久尤物| 亚洲狠狠婷婷综合久久久久| 中文字幕日本人妻久久久免费 | 99久久国产宗和精品1上映| 久久久久亚洲爆乳少妇无| 久久精品免费大片国产大片| 91精品国产综合久久香蕉| 久久精品国内一区二区三区 | 亚洲精品美女久久久久99小说| 91久久成人免费| 久久精品国产精品亚洲人人 | 久久精品免费一区二区| 思思久久99热只有频精品66|