Changeset 32 for trunk/BOOTCODE/REGULAR/DRIVEIO.ASM
- Timestamp:
- Jan 13, 2013, 8:46:36 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BOOTCODE/REGULAR/DRIVEIO.ASM
r31 r32 62 62 xor bx, bx 63 63 64 ; Changed from 5 to calculated 64 ; Changed from 5 to calculated value (not here, see compat. issue below) 65 65 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter" 66 mov cx, (MBR_BackUpMBR - Configuration) / 2 ; Size of the ab-configuration 67 ; TASM does not evaluate expression above corrrectly. 68 ; Listing shows correct opcode but generated opcode has imm. word byteswapped. 69 ; Casting to byte also does not work (overflow). 70 ; So we swap back here -- must be removed in JWasm version !! 71 xchg ch,cl 66 ; Size of the ab-configuration in 512 byte sectors 67 ;mov cx, (MBR_BackUpMBR - Configuration) / 200h 68 69 ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum. 70 ; AB v1.0.8 *should* stores a 7 sector configuration with a 71 ; 7 sector checksum. 72 ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8 73 ; config as corrupted, while this is not the case. 74 ; So, for compatibility reasons, in v1.0.8, the checksum stored is over 75 ; 5 sectors, to be compatible with v1.07. 76 ; This may change (be corrected) in future versions ! 77 mov cx,5 72 78 73 79 mov dx, [CFG_CheckConfig] … … 83 89 mov cx, 0037h 84 90 85 ; Changed from 5 to calculated 91 ; Changed from 5 to calculated value 86 92 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter" 87 mov ax, (MBR_BackUpMBR - Configuration) / 2 ; sizeof(ab-configuration) to write 88 ; TASM does not evaluate expression above corrrectly. 89 ; Listing shows correct opcode but generated opcode has imm. word byteswapped. 90 ; Casting to byte also does not work (overflow). 91 ; So we swap back here -- must be removed in JWasm version !! 92 xchg ah,al 93 ; Size of the ab-configuration in 512 byte sectors 94 mov al, (MBR_BackUpMBR - Configuration) / 200h 93 95 mov ah,03h 94 96 … … 250 252 ; Dump drive 251 253 mov si,offset drive 252 call AuxIO_Print254 ; call AuxIO_Print 253 255 xchg al,dl 254 call AuxIO_TeletypeHexByte255 call AuxIO_TeletypeNL256 ; call AuxIO_TeletypeHexByte 257 ; call AuxIO_TeletypeNL 256 258 xchg dl,al 257 259 258 260 ; Dump SPT 259 261 mov si,offset spt_used 260 call AuxIO_Print262 ; call AuxIO_Print 261 263 push dx 262 264 push bx … … 271 273 ;mov [ts],ax 272 274 273 call AuxIO_TeletypeHexWord274 call AuxIO_TeletypeNL275 ; call AuxIO_TeletypeHexWord 276 ; call AuxIO_TeletypeNL 275 277 pop bx 276 278 pop dx … … 281 283 mov dx,word ptr [ExtendedAbsPos+02] 282 284 mov ax,word ptr [ExtendedAbsPos+00] 283 call AuxIO_TeletypeHexDWord284 call AuxIO_TeletypeNL285 ; call AuxIO_TeletypeHexDWord 286 ; call AuxIO_TeletypeNL 285 287 pop dx 286 288 … … 293 295 294 296 mov ax, word ptr[bx] 295 call AuxIO_TeletypeHexWord296 call AuxIO_TeletypeNL297 ; call AuxIO_TeletypeHexWord 298 ; call AuxIO_TeletypeNL 297 299 mov al,[ExtendedAbsPosSet] ; if true -> 1st sector of extpart (EBR), not logpart(BPB) 298 call AuxIO_TeletypeHexByte299 call AuxIO_TeletypeNL300 ; call AuxIO_TeletypeHexByte 301 ; call AuxIO_TeletypeNL 300 302 ; mov si,offset PartitionSector 301 303 ; call AuxIO_DumpSector … … 304 306 ; LBA 305 307 mov si,offset before_lvm_adjust 306 call AuxIO_Print308 ; call AuxIO_Print 307 309 308 310 xchg dx,bx 309 call AuxIO_TeletypeHexDWord310 call AuxIO_TeletypeNL311 ; call AuxIO_TeletypeHexDWord 312 ; call AuxIO_TeletypeNL 311 313 xchg bx,dx 312 314 popa … … 322 324 pusha 323 325 mov si,offset before_lvm_adjust_log 324 call AuxIO_Print326 ; call AuxIO_Print 325 327 ; LBA 326 328 xchg dx,bx 327 call AuxIO_TeletypeHexDWord328 call AuxIO_TeletypeNL329 ; call AuxIO_TeletypeHexDWord 330 ; call AuxIO_TeletypeNL 329 331 xchg bx,dx 330 332 popa … … 349 351 pusha 350 352 mov si,offset after_lvm_adjust_log 351 call AuxIO_Print353 ; call AuxIO_Print 352 354 ; LBA 353 355 xchg dx,bx 354 call AuxIO_TeletypeHexDWord355 call AuxIO_TeletypeNL356 ; call AuxIO_TeletypeHexDWord 357 ; call AuxIO_TeletypeNL 356 358 xchg bx,dx 357 359 popa … … 432 434 pusha 433 435 mov si,offset after_lvm_adjust 434 call AuxIO_Print436 ; call AuxIO_Print 435 437 ; LBA 436 438 xchg dx,bx 437 call AuxIO_TeletypeHexDWord438 call AuxIO_TeletypeNL439 ; call AuxIO_TeletypeHexDWord 440 ; call AuxIO_TeletypeNL 439 441 xchg bx,dx 440 442 popa … … 583 585 pushf 584 586 pusha 585 call AuxIO_TeletypeNL587 ; call AuxIO_TeletypeNL 586 588 mov si,offset db_curlvmsec 587 call AuxIO_Print589 ; call AuxIO_Print 588 590 mov dx,bx 589 call AuxIO_TeletypeHexDWord590 call AuxIO_TeletypeNL591 ; call AuxIO_TeletypeHexDWord 592 ; call AuxIO_TeletypeNL 591 593 mov si,offset LVMSector 592 call AuxIO_DumpSector593 call AuxIO_TeletypeNL594 ; call AuxIO_DumpSector 595 ; call AuxIO_TeletypeNL 594 596 popa 595 597 popf … … 733 735 DriveIO_LoadSector EndP 734 736 737 738 739 ; 740 ; ############################################################ 741 ; # Load a specified sector from a disk using LBA addressing # 742 ; ############################################################ 743 ; 744 ; In 745 ; -- 746 ; DL = Physical Disk 747 ; BX:CX = LBA sector 748 ; DI:SI = Target buffer 749 ; 750 ; Out 751 ; --- 752 ; AX = Error code 753 ; 754 DriveIO_LoadSectorLBA Proc Near Uses bx cx dx si di ds es 755 ; Get one sector 756 mov cs:[DriveIO_DAP_NumBlocks], 1 757 758 ; Setup buffer address 759 mov wptr cs:[DriveIO_DAP_Transfer+0], si 760 mov wptr cs:[DriveIO_DAP_Transfer+2], di 761 762 ; Setup LBA address of requested sector 763 mov wptr cs:[DriveIO_DAP_Absolute+0], cx 764 mov wptr cs:[DriveIO_DAP_Absolute+2], bx 765 mov wptr cs:[DriveIO_DAP_Absolute+4], 0 766 mov wptr cs:[DriveIO_DAP_Absolute+6], 0 767 768 ; Address of packet 769 mov si, offset DriveIO_DAP 770 771 ; Do the extended read 772 mov ah, 42h 773 int 13h 774 775 ; Looking goot so far 776 jnc DriveIO_LoadSectorLBA_succes1 777 778 ; AH should not be zero, if it is then set to undefined and set carry 779 test ah,ah 780 jnz DriveIO_LoadSectorLBA_error1 781 mov ah, 0bbh ; Undefined error 782 DriveIO_LoadSectorLBA_error1: 783 stc 784 jmp DriveIO_LoadSectorLBA_exit 785 786 ; AL should be zero, if not then set to undefined and set carry 787 DriveIO_LoadSectorLBA_succes1: 788 test ah,ah 789 jz DriveIO_LoadSectorLBA_exit 790 stc 791 jmp DriveIO_LoadSectorLBA_exit 792 793 ; Return to caller 794 DriveIO_LoadSectorLBA_exit: 795 ret 796 DriveIO_LoadSectorLBA EndP 797 798 799 800 735 801 ; ######################################################################### 736 802 ; Routine: Writes DS:SI to a specified sector … … 796 862 ; See if a LVM-sector is valid. 797 863 ; In : si, pointer to sector 798 ; Out : ZF=true, not valid; ZF=false, valid864 ; Out : CY if valid LVM sector, NC if not 799 865 DriveIO_LVMSectorValid Proc Near 800 pusha 801 802 call LVM_CheckSectorSignature 803 mov al,0 804 rcl al,1 ; Move CY to AL.0 805 call AuxIO_TeletypeHexByte 806 call AuxIO_TeletypeNL 807 or al,al ; Zero if not a valid sector 808 jz DriveIO_LVMSectorValid_End ; Not a valid sector 809 810 call LVM_CheckSectorCRC 811 stc 812 mov al,0 813 rcl al,1 ; Move CY to AL.0 814 call AuxIO_TeletypeHexByte 815 call AuxIO_TeletypeNL 816 or al,al ; Zero if not a valid sector 817 818 DriveIO_LVMSectorValid_End: 819 820 popa 821 ret 866 pusha 867 868 call LVM_CheckSectorSignature 869 ; NC if no signature found 870 jnc DriveIO_LVMSectorValid_End 871 872 call LVM_CheckSectorCRC 873 ; Force valid !!! 874 stc 875 876 DriveIO_LVMSectorValid_End: 877 popa 878 ret 822 879 DriveIO_LVMSectorValid EndP 823 880 … … 838 895 ; This is also the case when no valid master LVM-sector can be found. 839 896 ; 840 ; Return ZF=true if not found, ZF=false when valid master LVM-sector found. 897 ; Return CF when valid master LVM sector found, NC if not. 898 ; Loads sector at [LVMSector] ! 841 899 DriveIO_LoadMasterLVMSector Proc Near 842 pusha 843 844 mov si,offset db_lmlvm 845 ;call AuxIO_Print 846 847 mov al,dl 848 ;call AuxIO_TeletypeHexByte 849 ;call AuxIO_TeletypeNL 850 851 852 ; Loop over the sector-translation table, 853 ; process the first three values from high (255) to low (bios spt, most likely 63) 854 mov cx,3 855 DriveIO_LoadMasterLVMSector_NextTry: 856 mov bx,offset secs_per_track_table ; sector translation table that corresponds with IsHugeDrive 857 mov si, offset LVMSector ; space to load the master LVM-sector 858 mov [DriveIO_DAP_NumBlocks],1 ; number of sectors to read 859 mov wptr [DriveIO_DAP_Transfer+0],si ; low part of transfer address 860 mov ax, ds 861 mov wptr [DriveIO_DAP_Transfer+2],ax ; high part of transfer address 862 mov ax,cx ; use the counter... 863 dec ax ; as an index into the table 864 xlatb ; translate to number of sectors 865 dec al ; LBA is zero-based, so adjust 900 pusha 901 902 mov si,offset db_lmlvm 903 ;call AuxIO_Print 904 905 ; Physical disk 906 ; mov al,'<' 907 ; call VideoIO_PrintSingleChar 908 ; mov al,dl 909 ; call VideoIO_PrintHexByte 910 ; mov al,'>' 911 ; call VideoIO_PrintSingleChar 912 913 ;call AuxIO_TeletypeHexByte 914 ;call AuxIO_TeletypeNL 915 916 917 ; Loop over the sector-translation table, 918 ; process the first three values from high (255) to low (bios spt, most likely 63) 919 mov cx,3 920 DriveIO_LoadMasterLVMSector_NextTry: 921 ; Number of sectors to read 922 mov [DriveIO_DAP_NumBlocks],1 923 924 ; Setup destination address 925 mov si, offset LVMSector 926 mov wptr [DriveIO_DAP_Transfer+0],si 927 mov ax, ds 928 mov wptr [DriveIO_DAP_Transfer+2],ax 929 930 ; Get the sector-number of the next possible LVM sector (255,127,63) 931 ; using the translation table and the counter as the index 932 mov bx,offset secs_per_track_table 933 mov ax,cx 934 dec ax 935 xlatb 936 dec al 937 938 ; 939 ; AX now contains the LBA address of the sector 940 ; that could be an LVM sector. 941 ; This is all in track0 so the address will not exceed 64kiB sectors. 942 ; 943 944 ; push ax 945 ; push ax 946 ; mov al,'$' 947 ; call VideoIO_PrintSingleChar 948 ; pop ax 949 ; call VideoIO_PrintHexByte 950 ; mov al,'$' 951 ; call VideoIO_PrintSingleChar 952 ; pop ax 866 953 867 954 IFDEF AuxDebug … … 871 958 ENDIF 872 959 873 mov wptr [DriveIO_DAP_Absolute+0],ax ; LBA low ;874 mov wptr [DriveIO_DAP_Absolute+2],00h ; LBA high875 mov si, offset DriveIO_DAP ; address request packet876 mov ah, 42h877 int 13h ; do the i/o878 jc DriveIO_LoadMasterLVMSector_NotFound ; oops, there was an error879 880 IFDEF AuxDebug 881 ; Dump title 882 mov si,offset db_masterlvm 883 ;call AuxIO_Print884 885 ; Dumsector886 mov si, offset LVMSector887 ;call AuxIO_DumpSector 888 ;call AuxIO_TeletypeNL 889 ENDIF 890 ; See is this is a valid LVM-sector 891 call DriveIO_LVMSectorValid 892 893 IFDEF AuxDebug 894 pushf 895 ;call AuxIO_TeletypeNL 896 popf 897 ENDIF 898 ; Yep, we found the master LVM-sector 899 jnz DriveIO_LoadMasterLVMSector_Found 900 ; Try next location901 loop DriveIO_LoadMasterLVMSector_NextTry902 903 ; No master LVM-sector found, set ZF=true904 DriveIO_LoadMasterLVMSector_NotFound: 905 xor ax,ax906 907 ; Jump here with ZF=false if found 908 DriveIO_LoadMasterLVMSector_Found:909 910 popa911 ret960 ; Setup the requested LBA sector number 961 mov wptr [DriveIO_DAP_Absolute+0],ax ; LBA low 962 mov wptr [DriveIO_DAP_Absolute+2],00h ; LBA high 963 mov si, offset DriveIO_DAP ; address request packet 964 mov ah, 42h 965 int 13h ; do the i/o 966 cmc ; Complement carry so we can exit imm. on error 967 jnc DriveIO_LoadMasterLVMSector_End ; oops, return with NC 968 969 970 mov si,offset LVMSector 971 972 ; See if this is a valid LVM-sector 973 call DriveIO_LVMSectorValid 974 975 ; pushf 976 ; mov ah,0 977 ; rcl ah,1 978 ; mov al,'|' 979 ; call VideoIO_PrintSingleChar 980 ; mov al,ah 981 ; call VideoIO_PrintHexByte 982 ; mov al,'|' 983 ; call VideoIO_PrintSingleChar 984 ; popf 985 986 987 ; Yep, we found the master LVM-sector 988 jc DriveIO_LoadMasterLVMSector_Found 989 ; Try next location 990 loop DriveIO_LoadMasterLVMSector_NextTry 991 992 ; No master LVM-sector found, set CF=false 993 clc 994 995 DriveIO_LoadMasterLVMSector_Found: 996 DriveIO_LoadMasterLVMSector_End: 997 popa 998 ret 912 999 DriveIO_LoadMasterLVMSector Endp 913 1000
Note:
See TracChangeset
for help on using the changeset viewer.