日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

FreeBSD啟動(dòng)扇區(qū)代碼分析( 三 )


# Whatever we decided to use, now store it into the fake
# partition entry that lives in the data space above us.
#
main.2:
movb %dl,_FAKE(%bp) # Save drive number
callw putn # To new line
pushw %dx # Save drive number以上第一句把FreeBSD啟動(dòng)分區(qū)的代碼保存到_FAKE(%bp)(bp-0)處,也就是說(shuō),上圖(二)的bp處保存的是FreeBSD啟動(dòng)分區(qū)的代碼(_FAKE=0) ?!癱allw putn一句在屏幕上打印“回車(chē)和“換行,“pushw %dx一句把啟動(dòng)分區(qū)的值壓入堆棧 。#
# Start out with a pointer to the 4th byte of the first table entry
# so that after 4 iterations it's beyond the end of the sector.
# and beyond a 256 byte boundary and has overflowed 8 bits (see next comment).
# (remember that the table starts 2 bytes earlier than you would expect
# as the bootable flag is after it in the block)
#
movw $(partbl 0x4),%bx # Partition table ( 4)
xorw %dx,%dx # Item number以上代碼首先把%bx指向分區(qū)表partbl的的第四個(gè)字節(jié),這里存放的是分區(qū)類(lèi)型,如82表示Linux Native分區(qū)83表示Linux Swap 分區(qū),有關(guān)分區(qū)表的細(xì)節(jié)請(qǐng)?jiān)斠?jiàn)本文的尾部 。然后dx清零,此后,dx將作為遍歷磁盤(pán)分區(qū)的列舉代號(hào)使用 。啟動(dòng)分區(qū)代碼dl的原來(lái)的值在上面已經(jīng)壓入了堆棧保存 。#
# Loop around on the partition table, printing values until we
# pass a 256 byte boundary. The end of loop test is at main.5.
#
main.3:
movb %ch,-0x4(%bx) # Zero active flag (ch == 0)
btw %dx,_FLAGS(%bp) # Entry enabled?
jnc main.5 # No上面首先使得第一個(gè)分區(qū)的活動(dòng)標(biāo)志為0,標(biāo)志它不為活動(dòng)標(biāo)志,因?yàn)閏h的值為0 。至于第二句“btw %dx,_FLAGS(%bp)中的_FLAGS(%bp)是上面我們說(shuō)到的“手動(dòng)指定我們實(shí)際安裝FreeBSD的分區(qū)代碼 。其中的bit 0x20我們?cè)谏厦嬉呀?jīng)提到過(guò) 。_FLAGS(%bp)中的其他位表示是否我們需要檢查相應(yīng)的磁盤(pán)分區(qū) 。缺省情況下,我們需要檢查所有的磁盤(pán)分區(qū) 。檢查磁盤(pán)分區(qū)看是否有可以啟動(dòng)的磁盤(pán)分區(qū),例如,可能磁盤(pán)上的某個(gè)分區(qū)為WindowsXP或者是Linux等 。如果我們沒(méi)有改變?cè)诖疟P(pán)上該處的值,則相應(yīng)的bit位的值為0,表示所有的分區(qū)都要檢查(因?yàn)榇藭r(shí)_FLAGS(%bp)中的值為0),否則,只針對(duì)FLAGS(%bp)中相應(yīng)的bit位未被設(shè)置為1的分區(qū)進(jìn)行檢查 。大家知道,F(xiàn)reeBSD Manager啟動(dòng)時(shí)可能出現(xiàn)以下的提示:F1FreeBSD
F2??
F3BSD
F4??
DefaultF1其中,上面的提示中出現(xiàn)了令人討厭的“??,為了避免出現(xiàn)“??的提示,我們可以設(shè)置相應(yīng)的第一分區(qū)和第四分區(qū)不檢查,就需要正確設(shè)置_FLAGS(%bp)中的bit位 。設(shè)置好后,屏幕可能出現(xiàn)以下的提示:F1FreeBSD
F2BSD
DefaultF1
#
# If any of the entries in the table are
# the same as the 'type' in the slice table entry,
# then this is an empty or non bootable partition. Skip it.
#
movb (%bx),%al # Load type
movw $tables,%di # Lookup tables
movb $TBL0SZ,%cl # Number of entries
repne # Exclude
scasb # partition?
je main.5 # Yes我們從上面已經(jīng)知道起始(%bx)指向的是MBR中分區(qū)信息1(16字節(jié))的位置(見(jiàn)圖(三)),以上代碼在“忽略的分區(qū)類(lèi)型$tables中查找看是否本分區(qū)是不可啟動(dòng)的或者不合法的分區(qū) 。不可啟動(dòng)的或者不合法的分區(qū)類(lèi)型有3($TBL0SZ=3)個(gè),它們是“0x0, 0x5, 0xf,見(jiàn)下面的$tables處 。如果是不可啟動(dòng)的或者不合法的分區(qū)類(lèi)型則跳轉(zhuǎn)到main.5,進(jìn)行下一輪循環(huán) 。#
# Now scan the table of known types
#
movb $TBL1SZ,%cl # Number of entries
repne # Known
scasb # type?
jne main.4 # No
#
# If it matches get the matching element in the
# next array. if it doesn't, we are already
# pointing at its first element which points to a "?".
#
addw $TBL1SZ,%di # Adjust

推薦閱讀