wok diff BootProg/stuff/bootex.asm @ rev 25564
Up memtest (6.20)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu May 11 15:58:49 2023 +0000 (2023-05-11) |
parents | f40d97a52c42 |
children | 64471e67874e |
line diff
1.1 --- a/BootProg/stuff/bootex.asm Mon Apr 03 16:35:42 2023 +0000 1.2 +++ b/BootProg/stuff/bootex.asm Thu May 11 15:58:49 2023 +0000 1.3 @@ -82,6 +82,9 @@ 1.4 ReadRetry equ 1 ; +8 bytes 1.5 SectorOf512Bytes equ 0 ; -11 bytes 1.6 CheckAttrib equ 0 ; +18 bytes 1.7 +WaitForKey equ 0 ; +5 bytes 1.8 +TfatSupport equ 1 ; +10 bytes 1.9 +CheckLBAsupport equ 0 ; +11/21 bytes 1.10 1.11 [BITS 16] 1.12 [CPU 386] 1.13 @@ -117,11 +120,11 @@ 1.14 bpbVolumeSerial DD 0 ; 0x64 volume serial number 1.15 bpbFSVersionMinor DB 0 ; 0x68 1.16 bpbFSVersionMajor DB 0 ; 0x69 1.17 -bpbVolumeStateFlags DW 0 ; 0x6A 1.18 +bpbVolumeStateFlags DW 0 ; 0x6A bit0 = fat used, bit1 = dirty, bit2 = media error 1.19 bpbSectorSizeBits DB 0 ; 0x6C sector size as (1 << n) 1.20 bpbSectorPerClusterBits DB 0 ; 0x6D sector per cluster as (1 << n) 1.21 -bpbNumberOfFATs DB 0 ; 0x6E always 1 1.22 -bpbDriveNumber DB 0 ; 0x6F alaways 0x80 1.23 +bpbNumberOfFATs DB 0 ; 0x6E always 1 or 2 (Tfat case) 1.24 +bpbDriveNumber DB 0 ; 0x6F always 0x80 1.25 bpbAllocatedPercent DB 0 ; 0x70 percentage of allocated space 1.26 1.27 ;;;;;;;;;;;;;;;;;;; 1.28 @@ -170,7 +173,21 @@ 1.29 push word main 1.30 retf 1.31 1.32 +%if CheckLBAsupport != 0 1.33 +%macro BootFileName 0 1.34 main: 1.35 + mov ah, 41h ; clobbers AX, BX, CX, DH 1.36 + mov bx, 55AAh 1.37 + int 13h 1.38 + jc ReadError 1.39 +; xor bx, 0AA55h 1.40 +; jnz ReadError 1.41 +; shr cx, 1 ; function 42h support ? 1.42 +; jnc ReadError 1.43 + xor cx, cx 1.44 +%else 1.45 +main: 1.46 +%endif 1.47 push cs 1.48 pop ds 1.49 1.50 @@ -205,46 +222,45 @@ 1.51 FindNameCycle: 1.52 pusha 1.53 1.54 +%if NullEntryCheck != 0 1.55 + xor ax, ax 1.56 + or al, [es:di] 1.57 + je FindNameFailed 1.58 + %define curtag al 1.59 + %define chktag al 1.60 +%else 1.61 + %define curtag byte [es:di] 1.62 + %define chktag ax 1.63 +%endif 1.64 + cmp curtag, 0c0h ; EXFAT_ENTRY_FILE_INFO ? 1.65 + jne NotFileInfo 1.66 + 1.67 + mov bl, 32 1.68 +CopyInfo: 1.69 + mov [bx], al 1.70 + dec bx 1.71 + mov al, [es:di+bx] 1.72 + jnz CopyInfo ; keep BIOS boot drive number 1.73 + 1.74 +NotFileInfo: 1.75 %if CheckAttrib != 0 1.76 Attributes equ 0Bh ; 1 byte 1.77 - cmp byte [es:di], 85h ; EXFAT_ENTRY_FILE ? 1.78 + cmp curtag, 85h ; EXFAT_ENTRY_FILE ? 1.79 jne NotEntryFile 1.80 mov al, [es:di+Attributes] 1.81 mov [ProgramName+NameLength+1], al 1.82 NotEntryFile: 1.83 %endif 1.84 -%if NullEntryCheck != 0 1.85 - xor ax, ax 1.86 - or al, [es:di] 1.87 - je FindNameFailed 1.88 - cmp al, 0c0h ; EXFAT_ENTRY_FILE_INFO ? 1.89 -%else 1.90 - cmp byte [es:di], 0c0h ; EXFAT_ENTRY_FILE_INFO ? 1.91 -%endif 1.92 - jne NotFileInfo 1.93 - 1.94 - mov bl, 31 1.95 -CopyInfo: 1.96 - mov al, [es:di+bx] 1.97 - mov [bx], al 1.98 - dec bx 1.99 - jnz CopyInfo ; keep BIOS boot drive number 1.100 - 1.101 -NotFileInfo: 1.102 -%if NullEntryCheck != 0 1.103 - mov al, 0c1h ; EXFAT_ENTRY_FILE_NAME ? 1.104 -%else 1.105 - mov ax, 0c1h ; EXFAT_ENTRY_FILE_NAME ? 1.106 -%endif 1.107 + mov chktag, 0c1h ; EXFAT_ENTRY_FILE_NAME ? 1.108 mov cx, NameLength+1 1.109 mov si, ProgramName ; ds:si -> program name 1.110 CheckName: 1.111 scasw ; compare UTF-16 1.112 lodsb ; with ASCII 1.113 loope CheckName 1.114 -%if CheckAttrib != 0 1.115 VolumeLabel equ 8 1.116 SubDirectory equ 10h 1.117 +%if CheckAttrib != 0 1.118 jnz SkipFindName 1.119 test byte [si], VolumeLabel+SubDirectory 1.120 SkipFindName: 1.121 @@ -370,6 +386,9 @@ 1.122 ;; All done, transfer control to the program now ;; 1.123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.124 retf 1.125 +%if CheckLBAsupport != 0 1.126 +%endm 1.127 +%endif 1.128 1.129 ;;;;;;;;;;;;;;;;;;;;;;;;;; 1.130 ;; Error Messaging Code ;; 1.131 @@ -385,11 +404,11 @@ 1.132 int 10h 1.133 cmp al, "." 1.134 jne PutStr 1.135 - 1.136 +%if WaitForKey != 0 1.137 cbw 1.138 int 16h ; wait for a key... 1.139 int 19h ; bootstrap 1.140 - 1.141 +%endif 1.142 Stop: 1.143 hlt 1.144 jmp short Stop 1.145 @@ -398,6 +417,7 @@ 1.146 ;; Reads a exFAT cluster ;; 1.147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.148 ;; Input: EDX:EAX = LBA ;; 1.149 +;; EBX = 0 ;; 1.150 ;; CX = sector cnt ;; 1.151 ;; ESI = cluster no ;; 1.152 ;; ES:0 -> buffer adrs ;; 1.153 @@ -406,7 +426,6 @@ 1.154 ;; ESI = cluster no ;; 1.155 ;; EBP = bytes/sector;; 1.156 ;; Keep: EDI = 0 ;; 1.157 -;; EBX = 0 ;; 1.158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.159 1.160 ReadCluster: 1.161 @@ -418,9 +437,11 @@ 1.162 mul ebx ; edx:eax = 0 1.163 %if SectorOf512Bytes != 0 1.164 mov al, 128 1.165 +%define SectorPerClusterBits [bx(bpbSectorPerClusterBits)] 1.166 %else 1.167 mov ah, 40h 1.168 mov cx, [bx(bpbSectorSizeBits)] 1.169 +%define SectorPerClusterBits ch 1.170 rol ax, cl ; eax=# of exFAT entries per sector 1.171 %endif 1.172 lea edi, [esi-2] ; edi=cluster #-2 1.173 @@ -431,15 +452,17 @@ 1.174 1.175 cdq 1.176 add eax, [bx(bpbFatSectorStart)] ; sector # relative to exFAT 1.177 +%if TfatSupport 1.178 + test byte [bx(bpbVolumeStateFlags)], 1 1.179 + jz UseFat0 1.180 + add eax, [bx(bpbFatSectorCount)] 1.181 +UseFat0: 1.182 +%endif 1.183 call ReadSectorFAT ; read 1 exFAT sector, keep edx=0, set C 1.184 1.185 mov esi, [es:si] ; esi=next cluster # 1.186 1.187 -%if SectorOf512Bytes != 0 1.188 - mov dl, [bx(bpbSectorPerClusterBits)] 1.189 -%else 1.190 - mov dl, ch 1.191 -%endif 1.192 + mov dl, SectorPerClusterBits 1.193 xor ecx, ecx 1.194 bts ecx, edx ; 10000h max (32MB cluster) 1.195 xchg eax, edi ; get cluster #-2 1.196 @@ -455,12 +478,12 @@ 1.197 ;; Reads a sector using BIOS Int 13h ;; 1.198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.199 ;; Input: EDX:EAX = LBA ;; 1.200 +;; EBX = 0 ;; 1.201 ;; ES:0 -> buffer address ;; 1.202 ;; Output: EBP = bytes/sector ;; 1.203 ;; Keep: ESI = cluster ;; 1.204 ;; EDI = FAT sector or 0 ;; 1.205 ;; ECX = sector count ;; 1.206 -;; EBX = 0 ;; 1.207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.208 1.209 %if SectorOf512Bytes != 0 1.210 @@ -503,6 +526,7 @@ 1.211 %endif 1.212 %endif 1.213 1.214 +ReadError: 1.215 call Error 1.216 db "Read error." 1.217 1.218 @@ -515,6 +539,10 @@ 1.219 popad ; real registers 1.220 ret 1.221 1.222 +%if CheckLBAsupport != 0 1.223 + BootFileName 1.224 +%endif 1.225 + 1.226 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.227 ;; Fill free space with zeroes ;; 1.228 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;