wok rev 25450
BootProg: avoid divide errors
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Sep 14 18:33:54 2022 +0000 (2022-09-14) |
parents | 6023b31d568c |
children | 5b1ba413bf58 |
files | BootProg/stuff/boot16.asm BootProg/stuff/boot32.asm BootProg/stuff/bootex.asm diggerjs/receipt nareto/receipt |
line diff
1.1 --- a/BootProg/stuff/boot16.asm Mon Sep 12 16:35:46 2022 +0000 1.2 +++ b/BootProg/stuff/boot16.asm Wed Sep 14 18:33:54 2022 +0000 1.3 @@ -83,6 +83,12 @@ 1.4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.5 1.6 %define bx(label) bx+label-boot 1.7 +%define si(label) si+label-boot 1.8 +NullEntryCheck equ 1 ; +3 bytes 1.9 +ReadRetry equ 1 ; +9 bytes 1.10 +LBAsupport equ 1 ; +16 bytes 1.11 +Over2GB equ 1 ; +5 bytes 1.12 +GeometryCheck equ 1 ; +18 bytes 1.13 1.14 [BITS 16] 1.15 [CPU 8086] 1.16 @@ -98,6 +104,7 @@ 1.17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.18 1.19 boot: 1.20 +DriveNumber: 1.21 jmp short start ; MS-DOS/Windows checks for this jump 1.22 nop 1.23 bsOemName DB "BootProg" ; 0x03 1.24 @@ -161,14 +168,14 @@ 1.25 mov si, 7C00h 1.26 xor di, di 1.27 mov ds, di 1.28 - mov [si], dx ; store BIOS boot drive number 1.29 + push es 1.30 + mov [si(DriveNumber)], dx ; store BIOS boot drive number 1.31 rep movsw ; move 512 bytes (+ 12) 1.32 1.33 ;;;;;;;;;;;;;;;;;;;;;; 1.34 ;; Jump to the copy ;; 1.35 ;;;;;;;;;;;;;;;;;;;;;; 1.36 1.37 - push es 1.38 mov cl, byte main 1.39 push cx 1.40 retf 1.41 @@ -189,13 +196,16 @@ 1.42 ;; for current BIOS ;; 1.43 ;;;;;;;;;;;;;;;;;;;;;;;;;; 1.44 1.45 +%if GeometryCheck != 0 1.46 mov ah, 8 1.47 int 13h ; may destroy SI,BP, and DS registers 1.48 +%endif 1.49 ; update AX,BL,CX,DX,DI, and ES registers 1.50 push cs 1.51 pop ds 1.52 xor bx, bx 1.53 1.54 +%if GeometryCheck != 0 1.55 and cx, byte 3Fh 1.56 cmp [bx(bpbSectorsPerTrack)], cx 1.57 jne BadParams ; verify updated and validity 1.58 @@ -203,6 +213,7 @@ 1.59 inc ax 1.60 mov [bpbHeadsPerCylinder], ax 1.61 BadParams: 1.62 +%endif 1.63 1.64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.65 ;; Load FAT (FAT12: 6KB max, FAT16: 128KB max) ;; 1.66 @@ -255,9 +266,13 @@ 1.67 repe cmpsb 1.68 pop di 1.69 je FindNameFound 1.70 +%if NullEntryCheck != 0 1.71 scasb 1.72 je FindNameFailed ; end of root directory (NULL entry found) 1.73 add di, byte 31 1.74 +%else 1.75 + add di, byte 32 1.76 +%endif 1.77 dec word [bx(bpbRootEntries)] 1.78 jnz FindNameCycle ; next root entry 1.79 1.80 @@ -289,35 +304,49 @@ 1.81 ;; CH = 0 ;; 1.82 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.83 1.84 +FAT12 equ 1 1.85 +FAT16 equ 1 1.86 push di ; up to 2 * 635K / BytesPerCluster bytes 1.87 +%if FAT12 == 1 1.88 mov cl, 12 1.89 +%endif 1.90 ClusterLoop: 1.91 mov [di], si 1.92 1.93 + add si, si ; si = cluster * 2 1.94 +%if FAT16 == 1 1.95 mov ax, es ; ax = FAT segment = ImageLoadSeg 1.96 - add si, si ; si = cluster * 2 1.97 jnc First64k 1.98 mov ah, (1000h+ImageLoadSeg)>>8 ; adjust segment for 2nd part of FAT16 1.99 First64k: 1.100 mov dx, 0FFF8h 1.101 +%else 1.102 + mov dx, 0FF8h 1.103 +%endif 1.104 1.105 +%if FAT12 == 1 && FAT16 == 1 1.106 cmp [bx(bpbSectorsPerFAT)], cx ; 1..12 = FAT12, 16..256 = FAT16 1.107 ja ReadClusterFat16 1.108 - 1.109 mov dh, 0Fh 1.110 +%endif 1.111 +%if FAT12 == 1 1.112 add si, [di] 1.113 shr si, 1 ; si = cluster * 3 / 2 1.114 - 1.115 +%endif 1.116 +%if FAT16 == 1 1.117 ReadClusterFat16: 1.118 push ds 1.119 mov ds, ax 1.120 lodsw ; ax = next cluster 1.121 pop ds 1.122 +%else 1.123 + lodsw ; ax = next cluster 1.124 +%endif 1.125 +%if FAT12 == 1 1.126 jnc ReadClusterEven 1.127 - 1.128 rol ax, cl 1.129 - 1.130 ReadClusterEven: 1.131 +%endif 1.132 scasw ; di += 2 1.133 and ah, dh ; mask cluster value 1.134 cmp ax, dx 1.135 @@ -464,31 +493,41 @@ 1.136 push di 1.137 push cx 1.138 1.139 +%if LBAsupport != 0 1.140 push bx 1.141 push bx 1.142 +%endif 1.143 push dx ; 32-bit LBA: up to 2TB 1.144 push ax 1.145 push es 1.146 +%if ReadRetry != 0 || LBAsupport != 0 1.147 + mov di, 16 ; packet size byte = 16, reserved byte = 0 1.148 +%endif 1.149 +%if LBAsupport != 0 1.150 push bx 1.151 inc bx ; sector count word = 1 1.152 push bx 1.153 dec bx 1.154 - mov di, 16 ; packet size byte = 16, reserved byte = 0 1.155 push di 1.156 +%endif 1.157 1.158 +%if Over2GB != 0 1.159 xchg ax, cx ; save low LBA 1.160 xchg ax, dx ; get high LBA 1.161 cwd ; clear dx (LBA offset <2TB) 1.162 - div word [bx(bpbSectorsPerTrack)] ; up to 8GB disks 1.163 + idiv word [bx(bpbSectorsPerTrack)] ; up to 8GB disks 1.164 1.165 xchg ax, cx ; restore low LBA, save high LBA / SPT 1.166 - div word [bx(bpbSectorsPerTrack)] 1.167 +%else 1.168 + xor cx, cx ; up to 2GB disks otherwise divide error interrupt ! 1.169 +%endif 1.170 + idiv word [bx(bpbSectorsPerTrack)] 1.171 ; ax = LBA / SPT 1.172 ; dx = LBA % SPT = sector - 1 1.173 inc dx 1.174 1.175 xchg cx, dx ; restore high LBA / SPT, save sector no. 1.176 - div word [bx(bpbHeadsPerCylinder)] 1.177 + idiv word [bx(bpbHeadsPerCylinder)] 1.178 ; ax = (LBA / SPT) / HPC = cylinder 1.179 ; dx = (LBA / SPT) % HPC = head 1.180 mov ch, al 1.181 @@ -501,41 +540,54 @@ 1.182 ; dh = head no. 1.183 1.184 ReadSectorRetry: 1.185 - mov dl, [bx] 1.186 + mov dl, [bx(DriveNumber)] 1.187 ; dl = drive no. 1.188 + mov si, sp 1.189 +%if LBAsupport != 0 1.190 mov ah, 42h ; ah = 42h = extended read function no. 1.191 - mov si, sp 1.192 int 13h ; extended read sectors (DL, DS:SI) 1.193 jnc ReadSectorNextSegment 1.194 +%endif 1.195 1.196 mov ax, 201h ; al = sector count = 1 1.197 ; ah = 2 = read function no. 1.198 int 13h ; read sectors (AL, CX, DX, ES:BX) 1.199 1.200 jnc ReadSectorNextSegment 1.201 +%if ReadRetry != 0 1.202 cbw ; ah = 0 = reset function 1.203 int 13h ; reset drive (DL) 1.204 1.205 dec di 1.206 jnz ReadSectorRetry ; extra attempt 1.207 +%endif 1.208 1.209 call Error 1.210 db "Read error." 1.211 1.212 ReadSectorNextSegment: 1.213 1.214 +%if LBAsupport != 0 1.215 pop ax ; al = 16 1.216 mul byte [bx(bpbBytesPerSector)+1] ; = (bpbBytesPerSector/256)*16 1.217 pop cx ; sector count = 1 1.218 pop bx 1.219 add [si+6], ax ; adjust segment for next sector 1.220 +%else 1.221 + mov al, 16 1.222 + mul byte [bx(bpbBytesPerSector)+1] ; = (bpbBytesPerSector/256)*16 1.223 + add [si], ax ; adjust segment for next sector 1.224 +%endif 1.225 pop es ; es:0 updated 1.226 pop ax 1.227 pop dx 1.228 +%if LBAsupport != 0 1.229 pop di 1.230 pop di 1.231 - 1.232 add ax, cx ; adjust LBA for next sector 1.233 +%else 1.234 + add ax, 1 ; adjust LBA for next sector 1.235 +%endif 1.236 1.237 pop cx ; cluster sectors to read 1.238 pop di ; file sectors to read 1.239 @@ -543,7 +595,7 @@ 1.240 loopne ReadSectorNext ; until cluster sector count or file sector count is reached 1.241 pop si 1.242 mov ax, bx ; clear ax 1.243 - mov dx, [bx] ; pass the BIOS boot drive to Run or Error 1.244 + mov dx, [bx(DriveNumber)] ; pass the BIOS boot drive to Run or Error 1.245 1.246 ret 1.247 1.248 @@ -581,7 +633,7 @@ 1.249 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.250 1.251 ProgramName db "STARTUP BIN" ; name and extension each must be 1.252 - ; padded with spaces (11 bytes total) 1.253 + times (510-($-$$)) db ' ' ; padded with spaces (11 bytes total) 1.254 1.255 ;;;;;;;;;;;;;;;;;;;;;;;;;; 1.256 ;; End of the sector ID ;;
2.1 --- a/BootProg/stuff/boot32.asm Mon Sep 12 16:35:46 2022 +0000 2.2 +++ b/BootProg/stuff/boot32.asm Wed Sep 14 18:33:54 2022 +0000 2.3 @@ -185,7 +185,6 @@ 2.4 xor di, di 2.5 mov ds, di 2.6 push es 2.7 - push byte main 2.8 mov [si(DriveNumber)], dx ; store BIOS boot drive number 2.9 rep movsw 2.10 2.11 @@ -193,6 +192,7 @@ 2.12 ;; Jump to the copy ;; 2.13 ;;;;;;;;;;;;;;;;;;;;;; 2.14 2.15 + push byte main 2.16 retf 2.17 2.18 main: 2.19 @@ -440,20 +440,19 @@ 2.20 idiv word [bx(bpbSectorsPerTrack)] ; up to 8GB disks, avoid divide error 2.21 2.22 xchg ax, cx ; restore low LBA, save high LBA / SPT 2.23 - div word [bx(bpbSectorsPerTrack)] 2.24 %else 2.25 ; Busybox mkdosfs creates fat32 for floppies. 2.26 ; Floppies may support CHS only. 2.27 cwd ; clear dx (LBA offset <16MB) 2.28 + xor cx, cx ; high LBA / SPT = 0 2.29 +%endif 2.30 idiv word [bx(bpbSectorsPerTrack)] 2.31 - xor cx, cx 2.32 -%endif 2.33 ; ax = LBA / SPT 2.34 ; dx = LBA % SPT = sector - 1 2.35 inc dx 2.36 2.37 xchg cx, dx ; restore high LBA / SPT, save sector no. 2.38 - div word [bx(bpbHeadsPerCylinder)] 2.39 + idiv word [bx(bpbHeadsPerCylinder)] 2.40 ; ax = (LBA / SPT) / HPC = cylinder 2.41 ; dx = (LBA / SPT) % HPC = head 2.42
3.1 --- a/BootProg/stuff/bootex.asm Mon Sep 12 16:35:46 2022 +0000 3.2 +++ b/BootProg/stuff/bootex.asm Wed Sep 14 18:33:54 2022 +0000 3.3 @@ -77,6 +77,9 @@ 3.4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.5 3.6 %define bx(label) bx+label-boot 3.7 +%define si(label) si+label-boot 3.8 +NullEntryCheck equ 1 ; +3 bytes 3.9 +ReadRetry equ 1 ; +8 bytes 3.10 3.11 [BITS 16] 3.12 [CPU 386] 3.13 @@ -92,6 +95,7 @@ 3.14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.15 3.16 boot: 3.17 +DriveNumber: 3.18 jmp short start ; Windows checks for this jump 3.19 nop 3.20 bsOemName DB "EXFAT " ; 0x03 3.21 @@ -154,13 +158,14 @@ 3.22 mov si, 7C00h 3.23 xor di, di 3.24 mov ds, di 3.25 + push es 3.26 + mov [si(DriveNumber)], dx ; store BIOS boot drive number 3.27 rep movsw ; move 512 bytes (+ 12) 3.28 3.29 ;;;;;;;;;;;;;;;;;;;;;; 3.30 ;; Jump to the copy ;; 3.31 ;;;;;;;;;;;;;;;;;;;;;; 3.32 3.33 - push es 3.34 push word main 3.35 retf 3.36 3.37 @@ -169,7 +174,6 @@ 3.38 pop ds 3.39 3.40 xor ebx, ebx 3.41 - mov [bx], dl ; store BIOS boot drive number 3.42 3.43 mov esi, [bx(bpbRootDirCluster)] ; esi=cluster # of root dir 3.44 3.45 @@ -194,16 +198,20 @@ 3.46 ;; dword [bx+FileSize] file size ;; 3.47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3.48 3.49 -CurNameSize equ 3 3.50 -StartCluster equ 14h 3.51 -FileSize equ 18h 3.52 +CurNameSize equ 3 ; 1 byte 3.53 +StartCluster equ 14h ; 4 bytes 3.54 +FileSize equ 18h ; 8 bytes 3.55 3.56 FindNameCycle: 3.57 pusha 3.58 3.59 +%if NullEntryCheck != 0 3.60 xor ax, ax 3.61 or al, [es:di] 3.62 je FindNameFailed 3.63 +%else 3.64 + movzx ax, byte [es:di] 3.65 +%endif 3.66 3.67 cmp al, 0c0h ; EXFAT_ENTRY_FILE_INFO ? 3.68 jne NotFileInfo 3.69 @@ -213,7 +221,7 @@ 3.70 mov al, [es:di+bx] 3.71 mov [bx], al 3.72 dec bx 3.73 - jnz CopyInfo ; keep BIOS boot drive number 3.74 + jnz CopyInfo ; keep BIOS boot drive number 3.75 3.76 NotFileInfo: 3.77 mov al, 0c1h ; EXFAT_ENTRY_FILE_NAME ? 3.78 @@ -232,7 +240,7 @@ 3.79 popf ; restore carry="not last sector" flag 3.80 jc RootDirReadContinue ; continue to the next root dir cluster 3.81 FindNameFailed: ; end of root directory (dir end reached) 3.82 - mov dl, [bx] ; restore BIOS boot drive number 3.83 + mov dx, [bx(DriveNumber)] ; restore BIOS boot drive number 3.84 call Error 3.85 db "File not found." 3.86 FindNameFound: 3.87 @@ -250,9 +258,9 @@ 3.88 add di, bp ; adjust segment for next sector 3.89 mov es, di ; es:0 updated 3.90 call ReadCluster ; read one more sector of the boot file 3.91 - sub [bx+FileSize], ebp 3.92 + sub [bx+FileSize], ebp ; max FileSize is < 640KB : check low 32 bits only 3.93 ja FileReadContinue 3.94 - mov dl, [bx] ; restore BIOS boot drive number 3.95 + mov dx, [bx(DriveNumber)] ; restore BIOS boot drive number 3.96 xor ax, ax 3.97 pop bp 3.98 3.99 @@ -354,10 +362,9 @@ 3.100 loop ReadSectorC 3.101 3.102 mul ebx ; edx:eax = 0 3.103 - mov cl, [bx(bpbSectorSizeBits)] 3.104 - dec cx 3.105 - stc 3.106 - rcl eax, cl ; eax=# of exFAT entries per sector 3.107 + mov cl,-2 3.108 + add cl, [bx(bpbSectorSizeBits)] 3.109 + bts ax, cx ; eax=# of exFAT entries per sector 3.110 lea edi, [esi-2] ; edi=cluster #-2 3.111 xchg eax, esi 3.112 div esi ; eax=FAT sector #, edx=entry # in sector 3.113 @@ -365,15 +372,14 @@ 3.114 imul si, dx, byte 4 ; si=entry # offset in sector 3.115 3.116 cdq 3.117 - add eax, [bx(bpbFatSectorStart)] ; sector # relative to exFAT 3.118 - call ReadSectorC ; read 1 exFAT sector 3.119 + add eax, [bx(bpbFatSectorStart)] ; sector # relative to FAT32 3.120 + call ReadSectorC ; read 1 FAT32 sector 3.121 3.122 mov esi, [es:si] ; esi=next cluster # 3.123 3.124 - inc dx 3.125 - mov cl, [bx(bpbSectorPerClusterBits)] 3.126 - shl edx, cl ; 10000h max (32MB cluster) 3.127 - mov ecx, edx 3.128 + mov dl, [bx(bpbSectorPerClusterBits)] 3.129 + xor cx, cx 3.130 + bts ecx, edx ; 10000h max (32MB cluster) 3.131 xchg eax, edi ; get cluster #-2 3.132 mul ecx 3.133 3.134 @@ -407,19 +413,25 @@ 3.135 push es 3.136 push bx 3.137 push bp ; sector count word = 1 3.138 +%if ReadRetry != 0 3.139 mov cx, 16 3.140 push cx ; packet size byte = 16, reserved byte = 0 3.141 ReadSectorRetry: 3.142 +%else 3.143 + push byte 16 3.144 +%endif 3.145 mov si, sp 3.146 mov ah, 42h ; ah = 42h = extended read function no. 3.147 - mov dl, [bx] ; restore BIOS boot drive number 3.148 + mov dl, [bx(DriveNumber)] ; restore BIOS boot drive number 3.149 int 13h ; extended read sectors (DL, DS:SI) 3.150 3.151 jnc ReadSuccess 3.152 3.153 +%if ReadRetry != 0 3.154 xor ax, ax 3.155 int 13h ; reset drive (DL) 3.156 loop ReadSectorRetry ; up to 16 retries 3.157 +%endif 3.158 3.159 call Error 3.160 db "Read error."
4.1 --- a/diggerjs/receipt Mon Sep 12 16:35:46 2022 +0000 4.2 +++ b/diggerjs/receipt Wed Sep 14 18:33:54 2022 +0000 4.3 @@ -9,7 +9,8 @@ 4.4 SOURCE="digger.js" 4.5 TARBALL="$SOURCE-$VERSION.zip" 4.6 WEB_SITE="http://www.heise.de/software/download/digger.js/8148" 4.7 -WGET_URL="https://www.tikkel.de/download/$TARBALL" 4.8 +#WGET_URL="https://www.tikkel.de/download/$TARBALL" 4.9 +WGET_URL="https://download.tuxfamily.org/slitaz/sources/packages-cooking/${TARBALL:0:1}/$TARBALL" 4.10 4.11 # What is the latest version available today? 4.12 current_version()
5.1 --- a/nareto/receipt Mon Sep 12 16:35:46 2022 +0000 5.2 +++ b/nareto/receipt Wed Sep 14 18:33:54 2022 +0000 5.3 @@ -8,7 +8,7 @@ 5.4 LICENSE="GPL2" 5.5 TARBALL="$PACKAGE-$VERSION.tar.gz" 5.6 WEB_SITE="https://web.archive.org/web/20131008041555/http://www.nareto.org/" 5.7 -WGET_URL="${WEB_SITE}srcs/$TARBALL" 5.8 +WGET_URL="https://download.tuxfamily.org/slitaz/sources/packages-cooking/${TARBALL:0:1}/$TARBALL" 5.9 CONFIG_FILES="/etc/nagios" 5.10 BUGS="s/oreon/centreon/" 5.11