Changeset 34 for trunk/BOOTCODE/REGULAR/PARTMAIN.ASM
- Timestamp:
- Jan 13, 2013, 9:07:21 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BOOTCODE/REGULAR/PARTMAIN.ASM
r33 r34 767 767 PART_StartPartition Proc Near Uses ax dx es di 768 768 local BootPartNo:byte 769 local PhysDiskBpbIndex:word ; Index into BPB to field of phys-disk 769 770 ; Get Partition-Pointer (SI) to Partition-To-Boot (DL) 770 771 call PART_GetPartitionPointer … … 1125 1126 1126 1127 1128 ; Locate cursor for output of debug-info 1129 pusha 1130 mov ch,7 1131 mov cl,0 1132 call VideoIO_Color 1133 mov ch,6 1134 mov cl,1 1135 call VideoIO_Locate 1136 popa 1137 1127 1138 1128 1139 ; ------------------------------------------------ SPECIAL PARTITION SUPPORT … … 1130 1141 1131 1142 1132 cmp byte ptr [si+LocIPT_SystemID],08 ; I hate Microsuck NTFS check1143 ;cmp byte ptr [si+LocIPT_SystemID],08 ; I hate Microsuck NTFS check 1133 1144 mov di, offset PartitionSector ; ES:DI - Actual Boot-Record 1134 1145 1135 1146 ; Special Support Detection 1136 mov ax, word ptr es:[di+18h] 1137 cmp ax, 003Fh ; Physical Layout-Sectors... Safety check 1147 ;mov ax, word ptr es:[di+18h] 1148 ;cmp ax, 003Fh ; Physical Layout-Sectors... Safety check 1149 1150 1151 1152 ; 1153 ; At this point, SI points to IPT and SI points to the PBR from disk. 1154 ; Depending on the type of BPB used, the physical disk field is at 1155 ; different locations: 24h for old-style (OS/2) BPB's and 40h for 1156 ; FAT32 BPB's. 1157 ; The OS/2 boot-drive-letter is located at 25h in an old-style BPB, 1158 ; while the corresponding field in a FAT32 BPB is located at 41h but 1159 ; used for different purposes. 1160 ; In case of HPFS, using old-style BPB's, the boot-drive-letter needs 1161 ; to be adjusted if it is zero. 1162 ; In that case we trace the LVM-info for that partition and use the 1163 ; drive-letter defined there. 1164 ; This fixes issues #3067 and #3119. 1165 ; Adjusting the physical disk is always done but at different locations 1166 ; depending on the BPB used. 1167 ; Also, the "hidden sectors" field is adjusted to contain the absolute 1168 ; offset from the start of the disk instead of the relative offset to 1169 ; the start of the partition. 1170 ; http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/bios-parameter-block.html 1171 ; 1172 1173 1174 ; Get index of phys-disk field in BX 1175 call PART_GetFieldIndex 1176 mov PhysDiskBpbIndex,ax 1177 mov bx,ax 1178 1179 pusha 1180 call VideoIO_PrintHexWord 1181 popa 1182 1183 ; Update the phys-drive field 1184 mov al,byte ptr [si+LocIPT_Drive] 1185 mov es:[di+bx],al 1186 mov al,al 1187 1188 pusha 1189 call VideoIO_PrintHexByte 1190 popa 1191 1192 ; 1193 ; Fix hidden sectors field 1194 ; 1195 1196 ; Low word of 32-bits "hidden sectors" 1197 mov ax,[si+LocIPT_AbsoluteBegin] 1198 mov es:[di+1ch], ax 1199 ; High word of 32-bits "hidden sectors" 1200 mov ax,[si+LocIPT_AbsoluteBegin+2] 1201 mov es:[di+1eh], ax 1202 1203 1204 ; 1205 ; Check partitions to see if boot-drive-letter fixing is needed. 1206 ; FAT12/FAT16/HPFS/JFS will have the value at 25h fixed 1207 ; to the LVM-info drive-letter. (+3dh to convert to BIOS notation) 1208 ; 1209 1210 1211 ; Setup partition disk and LBA address 1212 mov dl,byte ptr [si+LocIPT_Drive] 1213 mov cx,[si+LocIPT_AbsoluteBegin+00h] 1214 mov bx,[si+LocIPT_AbsoluteBegin+02h] 1215 1216 ; AL is gonna be used to shift-in CY status. 1217 ; If the type of file-system is one of FAT12/FAT16/HPFS/JFS then 1218 ; AL will be <> 0 and the boot-drive-letter can be tested / fixed. 1219 mov al,0 1220 1221 ; When FAT12/FAT16/HPFS/JFS then boot-drive-letter can be tested 1222 ; or adjusted. 1223 call PART_IsJFS 1224 rcl al,1 1225 call PART_IsHPFS 1226 rcl al,1 1227 call PART_IsFAT 1228 rcl al,1 1229 mov ah,al 1230 1231 pusha 1232 mov al,'=' 1233 call VideoIO_PrintSingleChar 1234 mov al,ah 1235 call VideoIO_PrintHexByte 1236 mov al,'=' 1237 call VideoIO_PrintSingleChar 1238 popa 1239 1240 ; See if boot-drive-letter fix is needed depending on FS used. 1241 ; AL will be 0 for any file-system other than FAT12/FAT16/HPFS/JFS. 1242 test al,al 1243 jz bdl_ok 1244 1245 ; Check if the boot-drive-letter is non-zero. 1246 mov bx,PhysDiskBpbIndex 1247 inc bx 1248 mov al,es:[di+bx] 1249 test al,al 1250 ; Non-zero, so no fixing needed. 1251 ;jnz bdl_ok ;; Why not always fix ? (so, jnz disabled) 1252 1253 1254 ; 1255 ; Always fix boot-drive-letter on FAT12/FAT16/HPFS/JFS 1256 ; 1257 1258 ; Get the drive-letter for the partition from the LVM-info. 1259 mov dl,byte ptr [si+LocIPT_Drive] 1260 mov cx,[si+LocIPT_AbsoluteBegin+00h] 1261 mov bx,[si+LocIPT_AbsoluteBegin+02h] 1262 call LVM_GetDriveLetter 1263 ; Save the status for later use 1264 pushf 1265 ; Save drive-letter in AH 1266 mov ah,al 1267 1268 ; See if the drive-letter feature is active. 1269 ; If active, we force the drive-letter from the user. 1270 test byte ptr [si+LocIPT_Flags], Flags_DriveLetter 1271 ; Nope, it's not so we don't force the boot-drive-letter 1272 ; using field 25h. 1273 jz PSP_NoLogicalSupport 1274 1275 ; Partition index in BX 1276 mov bl,BootPartNo ; EntryNumber is straight view 1277 mov bh,0 1278 1279 ; Pointer to the user specified boot-drive 1280 ; Get it and convert to ASCII letter 1281 mov al, bptr [DriveLetters+bx] 1282 sub al,3dh ; Convert BIOS notation to ASCII drive-letter 1283 pusha 1284 mov al,'!' 1285 call VideoIO_PrintSingleChar 1286 popa 1287 PSP_NoLogicalSupport: 1288 1289 ; Drive letter is LVM obtained or user-forced. 1290 ; Save it in AH. 1291 mov ah,al 1292 pusha 1293 mov al,'+' 1294 call VideoIO_PrintSingleChar 1295 mov al,ah 1296 call VideoIO_PrintHexByte 1297 mov al,'+' 1298 call VideoIO_PrintSingleChar 1299 popa 1300 1301 ; Restore the status whether an LVM drive-letter could be obtained 1302 popf 1303 1304 1305 ; No valid LVM-info if no info found or drive-letter is zero. 1306 jnc no_valid_lvm_info 1307 test al,al 1308 jz no_valid_lvm_info 1309 1310 1311 ; 1312 ; We have found a valid drive-letter in the LVM-info. 1313 ; 1314 1315 ; Convert to BIOS notation ('C'+3dh=80h, 'D'->81h, etc.) 1316 add al,3dh 1317 1318 ; Fix the boot-drive-letter field in the BPB 1319 mov bx,PhysDiskBpbIndex 1320 inc bx 1321 mov es:[di+bx],al 1322 1323 pusha 1324 call VideoIO_PrintHexByte 1325 popa 1326 1327 jmp bdl_ok 1328 1329 1330 no_valid_lvm_info: 1331 ; HERE SHOULD COME AN ERROR POP-UP ABOUT NO BOOT-DRIVE. 1332 ; WE CONTINUE BOOTING BUT OS/2 - eCS WILL MOST PROBABLY FAIIL TO BOOT. 1333 1334 mov ah,07h 1335 mov si,offset CheckID_MBR 1336 call VideoIO_Print 1337 1338 hang: 1339 jmp hang 1340 1341 1342 bdl_ok: 1343 1344 1345 1346 ;xor ax,ax 1347 ;int 16h 1348 1349 1350 1351 1352 1353 ; Check FS-types 1354 ; Adjust fields 1355 1356 1357 1138 1358 1139 1359 … … 1173 1393 1174 1394 1175 ; Locate cursor for output of debug-info 1176 pusha 1177 mov ch,7 1178 mov cl,0 1179 call VideoIO_Color 1180 mov ch,6 1181 mov cl,1 1182 call VideoIO_Locate 1183 popa 1184 1185 1186 ; Physical disk for partition 1187 mov al,'<' 1188 call VideoIO_PrintSingleChar 1189 mov ah,byte ptr [si+LocIPT_Drive] 1190 mov al,ah 1191 call VideoIO_PrintHexByte 1192 mov al,'>' 1193 call VideoIO_PrintSingleChar 1194 1195 1196 mov al,'-' 1197 call VideoIO_PrintSingleChar 1198 ; Get BPB physical disk number 1199 mov ah, es:[di+24h] ; boot disk from BPB 1200 mov al,ah 1201 call VideoIO_PrintHexByte 1202 1203 ; We need to allways correct if this byte is zero. 1204 test ah,ah 1205 jz adjust_bpb_phys_drive 1206 1207 ; Don't adjust if below 80h (FreeDOS) 1208 cmp ah,80h 1209 jb no_adjust_bpb_phys_drive 1210 1211 ; Don't adjust if it's above 9fh (Windows FAT32) 1212 cmp ah,9fh 1213 ja no_adjust_bpb_phys_drive 1214 1215 1216 adjust_bpb_phys_drive: 1217 ; We must be booting a system that uses field 24h in the BPB 1218 ; as the physical disk number. Such systems are OS/2, eCS but also 1219 ; PC-DOS7. Adjust the physical drive in the BPB to allow booting from 1220 ; secundary disk. 1221 mov ah, [si+LocIPT_Drive] ; Physical disk in BIOS notation 1222 mov es:[di+24h], ah ; Write to BPB in memory 1223 1224 1225 no_adjust_bpb_phys_drive: 1226 mov al,':' 1227 call VideoIO_PrintSingleChar 1228 mov al,ah 1229 call VideoIO_PrintHexByte ; print corrected value 1395 1396 1397 1230 1398 1231 1399 … … 1240 1408 ; 1241 1409 1242 mov al,'-' 1243 call VideoIO_PrintSingleChar 1244 1245 1246 ; Low word of 32-bits "hidden sectors" 1247 mov cx,[di+1ch] 1248 mov ax,[si+LocIPT_AbsoluteBegin] 1249 mov es:[di+1ch], ax 1250 ; High word of 32-bits "hidden sectors" 1251 mov bx,[di+1eh] 1252 mov dx,[si+LocIPT_AbsoluteBegin+2] 1253 mov es:[di+1eh], dx 1254 1255 push dx 1256 push ax 1257 mov ax,cx 1258 mov dx,bx 1259 call VideoIO_PrintHexDWord ; print on-disk value 1260 mov al,':' 1261 call VideoIO_PrintSingleChar 1262 pop ax 1263 pop dx 1264 call VideoIO_PrintHexDWord ; print corrected value 1410 1265 1411 1266 1412 … … 1291 1437 ; 1292 1438 1293 ; See if the drive-letter feature is active 1294 test byte ptr [si+LocIPT_Flags], Flags_DriveLetter 1295 ; Nope, it's not so we don't force the boot-drive using field 25h 1296 jz PSP_NoLogicalSupport 1297 1298 ; Pointer to the user specified boot-drive 1299 mov bl,BootPartNo ; EntryNumber is straight view 1300 mov bh,0 1301 1302 ; Get it and store it in the in-ram BPB 1303 mov al, bptr [DriveLetters+bx] 1304 mov bptr es:[di+25h], al ; Write Drive Letter (OS/2 only) 1305 1306 1307 ; ------------------------------------------- COPY BOOT-RECORD TO STARTBASE 1308 PSP_NoLogicalSupport: 1439 1309 1440 1310 1441 … … 1317 1448 ; replace it with information found in LVM DLAT info. 1318 1449 ; 1319 ; For primary partitions this information is stored in the last 1320 ; sector of track0; for all four partition entries should they 1321 ; all be primary ones. 1322 ; 1323 ; LVM DLAT info for logical partitions is stored in the sector 1324 ; preceding the start of the partition. 1325 ; 1326 ; Because the LVM info of a logical partition is the easiest to find, 1327 ; we do that first. The LVM info for primary partitions is located 1328 ; dependent on the geometry in use, so we use a special locater 1329 ; call for that. Also, since the LVM info for primaries contains 1330 ; info on all 4 entries, we need the partition index to obtain the 1331 ; correct drive-letter. 1332 ; 1333 1334 ; See if this is a primary partition 1335 ; CY will be set if it is and AL will contain the 0-based 1336 ; index in the P-table. 1337 ; If it's a logical partition, CY will be clear and AL 1338 ; will be set to 0ffh indicating an invalid index. 1339 mov dl,byte ptr [si+LocIPT_Drive] 1340 mov cx,[si+LocIPT_AbsoluteBegin+00h] 1341 mov bx,[si+LocIPT_AbsoluteBegin+02h] 1342 call PART_IsPrimaryPartition 1343 1344 ; Save the index in DL and whether it's PRI or LOG in DH 1345 mov dl,al ; Save PTE-index 1346 mov al,0 1347 rcl al,1 ; CY if primary 1348 mov dh,al ; Save PRI or LOG 1349 1350 ; Save PRI/LOG indicator for later use 1351 push dx 1352 1353 ; Load *possible* LVM sector 1354 ; This load is only valid if the partition is logical, in which case 1355 ; the LVM sector is below the start of the partition. 1356 ; If primary, the LVM sector is at a location that 1357 ; DriveIO_LoadMasterLVMSector will find out. 1358 1359 ; Physical disk and absolute start of partition 1360 mov dl,bptr [si+LocIPT_Drive] 1361 mov cx,[si+LocIPT_AbsoluteBegin+00h] 1362 mov bx,[si+LocIPT_AbsoluteBegin+02h] 1363 1364 ; Adjust for logical LVM-sector 1365 sub cx,1 1366 sbb bx,0 1367 1368 ; Load the LVM sector 1369 push si 1370 push di 1371 mov si,offset [LVMSector] 1372 mov di,ds 1373 call DriveIO_LoadSectorLBA 1374 pop di 1375 pop si 1376 1377 1378 ; Restore PRI/LOG partition indicator and index 1379 pop dx 1380 1381 ; Test PRI or not 1382 test dh,dh 1383 ; It's not a PRI so we can use the previously loaded LVM sector 1384 jz is_not_pri 1385 1386 ; It's a PRI so we use the special locator function. 1387 ; This locator takes care of extended eCS geometry should that be used 1388 pusha 1389 mov dl,byte ptr [si+LocIPT_Drive] 1390 call DriveIO_LoadMasterLVMSector 1391 popa 1392 1393 1394 is_not_pri: 1395 1396 1397 ; 1398 ; At this stage the LVM-info sector has been loaded at [LVMSector]. 1399 ; From here we look for an LVM entry for the partition. 1400 ; If one is found, based on it's LBA-start, it's driveletter is used 1401 ; in case byte 25h is zero. 1402 ; 1403 1404 1405 ; Search for the partition in the LVM info. 1406 ; If found, CY is set and SI points to LVM entry. 1407 push si 1408 mov dl,bptr [si+LocIPT_Drive] 1409 mov ax,[si+LocIPT_AbsoluteBegin+00h] 1410 mov dx,[si+LocIPT_AbsoluteBegin+02h] 1411 mov si,offset [LVMSector] 1412 call LVM_SearchForPartition 1413 mov bx,si ; BX now points to LVM entry 1414 mov dx,0 ; Setup null driveletter 1415 pop si 1416 1417 ; Oops, no valid LVM record was used so we have a null driveletter. 1418 jnc null_lvm_dl 1419 1420 ; 1421 ; At this point BX points to the LVM-entry related to the 1422 ; partition, whether it was a logical or a primary one. 1423 ; We get the drive-letter and convert it ('C'=80h etc) 1424 ; and put it in DH for later use. 1425 ; 1426 mov dh,[bx+LocLVM_VolumeLetter] 1427 ; Don't convert if zero 1428 test dh,dh 1429 jz null_lvm_dl 1430 add dh,3dh 1431 null_lvm_dl: 1432 1433 1434 ; Check for HPFS partition 1435 mov dl,bptr [si+LocIPT_Drive] 1436 mov cx,[si+LocIPT_AbsoluteBegin+00h] 1437 mov bx,[si+LocIPT_AbsoluteBegin+02h] 1438 call PART_IsHPFS 1439 1440 ; Save HPFS indicator 1441 mov ah,al 1442 push ax 1443 1444 mov al,'-' 1445 call VideoIO_PrintSingleChar 1446 mov al,ah 1447 call VideoIO_PrintHexByte 1448 mov al,'/' 1449 call VideoIO_PrintSingleChar 1450 1451 ; JFS 1452 call PART_IsJFS 1453 call VideoIO_PrintHexByte 1454 mov al,'/' 1455 call VideoIO_PrintSingleChar 1456 1457 ; BOOTMGR 1458 call PART_IsWinBMGR 1459 call VideoIO_PrintHexByte 1460 mov al,'/' 1461 call VideoIO_PrintSingleChar 1462 1463 ; FAT32 1464 call PART_IsFAT32 1465 call VideoIO_PrintHexByte 1466 mov al,'-' 1467 call VideoIO_PrintSingleChar 1468 1469 mov al,es:[di+25h] 1470 call VideoIO_PrintHexByte 1471 1472 ; Restore and test HPFS indicator 1473 pop ax 1474 test ah,ah 1475 jz no_hpfs 1476 1477 1478 ; See if HPFS BPB needs fixing, which is the case when it's zero. 1479 mov al,es:[di+25h] 1480 test al,al 1481 jnz hpfs_no_fix_needed 1482 1483 ; Oops we have a zero-byte where the drive-letter should 1484 ; be in BIOS notation. 1485 ; Lets use the LVM value which is still stored in DH. 1486 ; Note that this fix is in-ram only, it does not correct the BPB 1487 ; on disk. That's the user's responsibility by using SYSINSTX. 1488 mov es:[di+25h], dh ; Put value from LVM in the BPB in memory. 1489 1490 1491 hpfs_no_fix_needed: 1492 no_hpfs: 1493 1494 mov al,':' 1495 call VideoIO_PrintSingleChar 1496 mov al,es:[di+25h] 1497 call VideoIO_PrintHexByte ; print possibly corrected 25h 1498 1499 mov al,'-' 1500 call VideoIO_PrintSingleChar 1501 mov al,dh 1502 test al,al 1503 jnz dl_not_null 1504 mov al,'*'+3dh 1505 dl_not_null: 1506 sub al,3dh 1507 call VideoIO_PrintSingleChar ; print drive-letter 1450 1451 1452 1453 1454 1455 ; <<<< KNIP >>>> LVM STUFF 1456 1457 1458 1459 1508 1460 1509 1461 … … 1511 1463 ; Here we copy the prepared partition boot-record to 7C00h 1512 1464 ; to give it control later on. 1465 ; 1513 1466 push si 1514 1467 mov ax, StartBaseSeg … … 1528 1481 ; call DEBUG_Dump2 1529 1482 ENDIF 1530 1531 1483 1532 1484 … … 1670 1622 ; Out 1671 1623 ; --- 1672 ; AX = 0 if not, 1 if it is HPFS1673 ; CY = Set if HPFS, clear if not1674 ; 1675 PART_IsHPFS Proc Near Uses bx cx dx si di ds es 1624 ; CY = Set if HPFS partition, clear if not 1625 ; 1626 PART_IsHPFS Proc Near Uses ax bx cx dx si di ds es 1627 1676 1628 ; Load specified LBA sector (BX:CX) from the disk in DL 1677 1629 mov di,ds … … 1679 1631 call DriveIO_LoadSectorLBA 1680 1632 1681 ; Check for 'HPFS' string as offset 36h in BPB 1682 mov ax, word ptr [si+36h] ; 'HP' 1683 mov dx, word ptr [si+38h] ; 'FS' 1684 xor ax, 'PH' ; Leaves zero in AX if 'HP' 1685 xor dx, 'SF' ; Leaves zero in DX if 'FS' 1686 or ax,dx ; Leaves zero in AX if partition is HPFS 1687 1688 ; Assume not HPFS, so clear AX,CY (ZF is set above) 1689 mov ax,0 1633 ; Point to location of 'HPFS ' identifier. 1634 add si,36h 1635 1636 ; DL holds equality status 1637 xor dl,dl 1638 cld 1639 1640 ; Load letter into AL, xor with letter will result 0 if the same. 1641 ; Then or to DL. 1642 ; If at the end of the sequence DL is zero, the signature is present. 1643 lodsb 1644 xor al,'H' 1645 or dl,al 1646 lodsb 1647 xor al,'P' 1648 or dl,al 1649 lodsb 1650 xor al,'F' 1651 or dl,al 1652 lodsb 1653 xor al,'S' 1654 or dl,al 1655 lodsb 1656 xor al,' ' 1657 or dl,al 1658 lodsb 1659 xor al,' ' 1660 or dl,al 1661 lodsb 1662 xor al,' ' 1663 or dl,al 1664 lodsb 1665 xor al,' ' 1666 or dl,al 1667 1668 ; Assume not present 1690 1669 clc 1691 1670 jnz PART_IsHPFS_exit 1692 1671 1693 ; Is HPFS, so indicate in AX, and set CY (ZF is set above) 1694 mov ax,1 1672 ; JFS signature found 1695 1673 stc 1696 1674 … … 1701 1679 1702 1680 ; 1703 ; ########################### ##1681 ; ########################### 1704 1682 ; # Is this a JFS partition # 1705 ; ########################### ##1683 ; ########################### 1706 1684 ; 1707 1685 ; In … … 1712 1690 ; Out 1713 1691 ; --- 1714 ; AX = 0 if not, 1 if JFS partition1715 1692 ; CY = Set if JFS partition, clear if not 1716 1693 ; 1717 PART_IsJFS Proc Near Uses bx cx dx si di ds es1694 PART_IsJFS Proc Near Uses ax bx cx dx si di ds es 1718 1695 1719 1696 ; Load specified LBA sector (BX:CX) from the disk in DL … … 1722 1699 call DriveIO_LoadSectorLBA 1723 1700 1724 ; Point to location of ' FAT32' identifier.1701 ; Point to location of 'JFS ' identifier. 1725 1702 add si,36h 1726 1703 … … 1741 1718 xor al,'S' 1742 1719 or dl,al 1720 lodsb 1721 xor al,' ' 1722 or dl,al 1723 lodsb 1724 xor al,' ' 1725 or dl,al 1726 lodsb 1727 xor al,' ' 1728 or dl,al 1729 lodsb 1730 xor al,' ' 1731 or dl,al 1732 lodsb 1733 xor al,' ' 1734 or dl,al 1743 1735 1744 1736 ; Assume not present 1745 mov ax,01746 1737 clc 1747 1738 jnz PART_IsJFS_exit 1748 1739 1749 1740 ; JFS signature found 1750 mov ax,11751 1741 stc 1752 1742 … … 1755 1745 PART_IsJFS Endp 1756 1746 1757 ; 1758 ; ############################# 1759 ; # Is this a FAT32 partition # 1760 ; ############################# 1747 1748 1749 ; 1750 ; ###################################### 1751 ; # Is this a FAT12 or FAT16 partition # 1752 ; ###################################### 1761 1753 ; 1762 1754 ; In … … 1767 1759 ; Out 1768 1760 ; --- 1769 ; AX = 0 if not, 1 if FAT32 partition 1770 ; CY = Set if FAT32 partition, clear if not 1771 ; 1772 PART_IsFAT32 Proc Near Uses bx cx dx si di ds es 1761 ; CY = Set if FAT12 or FAT16 partition, clear if not 1762 ; 1763 ; This can be a FAT12 or FAT16 partition. 1764 ; When OS/2 formats volume with FAT it does not use the FAT16 identifier, 1765 ; but uses the FAT identifier. 1766 ; 1767 PART_IsFAT Proc Near Uses ax bx cx dx si di ds es 1768 1769 ; First see if this is a FAT32 partition. 1770 ; If it is, exit with NC indicating not FAT12 or FAT16. 1771 call PART_IsFAT32 1772 cmc 1773 jnc PART_IsFAT_exit 1773 1774 1774 1775 ; Load specified LBA sector (BX:CX) from the disk in DL … … 1777 1778 call DriveIO_LoadSectorLBA 1778 1779 1779 ; Point to location of 'FAT 32' identifier.1780 add si, 52h1780 ; Point to location of 'FAT ' identifier. 1781 add si,36h 1781 1782 1782 1783 ; DL holds equality status … … 1797 1798 or dl,al 1798 1799 lodsb 1799 xor al,'3' 1800 or dl,al 1801 lodsb 1802 xor al,'2' 1800 1801 ; Since OS/2 formats FAT volumes with an identifier of 'FAT ', 1802 ; and others with 'FAT16 ', we skip two bytes for comparison. 1803 ; The rest must be spaces however. 1804 ; xor al,' ' 1805 ; or dl,al 1806 lodsb 1807 ; xor al,' ' 1808 ; or dl,al 1809 1810 lodsb 1811 xor al,' ' 1812 or dl,al 1813 lodsb 1814 xor al,' ' 1815 or dl,al 1816 lodsb 1817 xor al,' ' 1803 1818 or dl,al 1804 1819 1805 1820 ; Assume not present 1806 mov ax,01807 1821 clc 1808 jnz PART_IsFAT32_exit 1809 1810 ; FAT32 signature found 1811 mov ax,1 1822 jnz PART_IsFAT_exit 1823 1824 ; FAT signature found 1812 1825 stc 1813 1826 1814 PART_IsFAT 32_exit:1827 PART_IsFAT_exit: 1815 1828 ret 1816 PART_IsFAT32 Endp 1817 1818 1819 1820 ; 1821 ; ############################################################## 1822 ; # Does this partition have the Windows BootManager installed # 1823 ; ############################################################## 1829 PART_IsFAT Endp 1830 1831 1832 ; 1833 ; ############################# 1834 ; # Is this a FAT32 partition # 1835 ; ############################# 1824 1836 ; 1825 1837 ; In … … 1830 1842 ; Out 1831 1843 ; --- 1832 ; AX = 0 if not, 1 if BOOTMGR signature found 1833 ; CY = Set if BOOTMGR found, clear if not 1834 ; 1835 PART_IsWinBMGR Proc Near Uses bx cx dx si di ds es 1844 ; CY = Set if FAT32 partition, clear if not 1845 ; 1846 PART_IsFAT32 Proc Near Uses ax bx cx dx si di ds es 1836 1847 1837 1848 ; Load specified LBA sector (BX:CX) from the disk in DL … … 1840 1851 call DriveIO_LoadSectorLBA 1841 1852 1842 ; Point to location of ' BOOTMGR' signature.1843 add si, 169h1853 ; Point to location of 'FAT32 ' identifier. 1854 add si,52h 1844 1855 1845 1856 ; DL holds equality status … … 1851 1862 ; If at the end of the sequence DL is zero, the signature is present. 1852 1863 lodsb 1864 xor al,'F' 1865 or dl,al 1866 lodsb 1867 xor al,'A' 1868 or dl,al 1869 lodsb 1870 xor al,'T' 1871 or dl,al 1872 lodsb 1873 xor al,'3' 1874 or dl,al 1875 lodsb 1876 xor al,'2' 1877 or dl,al 1878 lodsb 1879 xor al,' ' 1880 or dl,al 1881 lodsb 1882 xor al,' ' 1883 or dl,al 1884 lodsb 1885 xor al,' ' 1886 or dl,al 1887 1888 ; Assume not present 1889 clc 1890 jnz PART_IsFAT32_exit 1891 1892 ; FAT32 signature found 1893 stc 1894 1895 PART_IsFAT32_exit: 1896 ret 1897 PART_IsFAT32 Endp 1898 1899 1900 1901 ; 1902 ; ############################################################## 1903 ; # Does this partition have the Windows BootManager installed # 1904 ; ############################################################## 1905 ; 1906 ; In 1907 ; -- 1908 ; DL = Physical Disk 1909 ; BX:CX = LBA sector 1910 ; 1911 ; Out 1912 ; --- 1913 ; CY = Set if BOOTMGR found, clear if not 1914 ; 1915 PART_IsWinBMGR Proc Near Uses ax bx cx dx si di ds es 1916 1917 ; Load specified LBA sector (BX:CX) from the disk in DL 1918 mov di,ds 1919 mov si,offset [TmpSector] 1920 call DriveIO_LoadSectorLBA 1921 1922 ; Point to location of 'BOOTMGR' signature. 1923 add si,169h 1924 1925 ; DL holds equality status 1926 xor dl,dl 1927 cld 1928 1929 ; Load letter into AL, xor with letter will result 0 if the same. 1930 ; Then or to DL. 1931 ; If at the end of the sequence DL is zero, the signature is present. 1932 lodsb 1853 1933 xor al,'B' 1854 1934 or dl,al … … 1873 1953 1874 1954 ; Assume not present 1875 mov ax,01876 1955 clc 1877 1956 jnz PART_IsWinBMGR_exit 1878 1957 1879 1958 ; BOOTMGR signature found 1880 mov ax,11881 1959 stc 1882 1960 … … 1884 1962 ret 1885 1963 PART_IsWinBMGR Endp 1964 1965 1966 ; 1967 ; ########################################################## 1968 ; # Get the offset of the phys-disk field in the PBR (BPB) # 1969 ; ########################################################## 1970 ; 1971 ; In 1972 ; -- 1973 ; DS:SI = IPT 1974 ; 1975 ; Out 1976 ; --- 1977 ; AX = Index in PBR for phys-disk field 1978 ; 1979 PART_GetFieldIndex Proc Near uses bx cx dx 1980 ; Check for FAT32 partition 1981 mov dl,bptr [si+LocIPT_Drive] 1982 mov cx,[si+LocIPT_AbsoluteBegin+00h] 1983 mov bx,[si+LocIPT_AbsoluteBegin+02h] 1984 call PART_IsFAT32 1985 mov ax,24h ; Offset in old-style BPB 1986 jnc PART_GetFieldIndex_exit 1987 mov ax,40h ; Offset in FAT32 BPB 1988 PART_GetFieldIndex_exit: 1989 ret 1990 PART_GetFieldIndex EndP
Note:
See TracChangeset
for help on using the changeset viewer.