# HG changeset patch # User Pascal Bellard # Date 1663180434 0 # Node ID 62d43c1b8453f5f1e44b8942a9e4bb5b23160214 # Parent 6023b31d568cada6e018f0a2472acb6a1e7b5771 BootProg: avoid divide errors diff -r 6023b31d568c -r 62d43c1b8453 BootProg/stuff/boot16.asm --- a/BootProg/stuff/boot16.asm Mon Sep 12 16:35:46 2022 +0000 +++ b/BootProg/stuff/boot16.asm Wed Sep 14 18:33:54 2022 +0000 @@ -83,6 +83,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %define bx(label) bx+label-boot +%define si(label) si+label-boot +NullEntryCheck equ 1 ; +3 bytes +ReadRetry equ 1 ; +9 bytes +LBAsupport equ 1 ; +16 bytes +Over2GB equ 1 ; +5 bytes +GeometryCheck equ 1 ; +18 bytes [BITS 16] [CPU 8086] @@ -98,6 +104,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; boot: +DriveNumber: jmp short start ; MS-DOS/Windows checks for this jump nop bsOemName DB "BootProg" ; 0x03 @@ -161,14 +168,14 @@ mov si, 7C00h xor di, di mov ds, di - mov [si], dx ; store BIOS boot drive number + push es + mov [si(DriveNumber)], dx ; store BIOS boot drive number rep movsw ; move 512 bytes (+ 12) ;;;;;;;;;;;;;;;;;;;;;; ;; Jump to the copy ;; ;;;;;;;;;;;;;;;;;;;;;; - push es mov cl, byte main push cx retf @@ -189,13 +196,16 @@ ;; for current BIOS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;; +%if GeometryCheck != 0 mov ah, 8 int 13h ; may destroy SI,BP, and DS registers +%endif ; update AX,BL,CX,DX,DI, and ES registers push cs pop ds xor bx, bx +%if GeometryCheck != 0 and cx, byte 3Fh cmp [bx(bpbSectorsPerTrack)], cx jne BadParams ; verify updated and validity @@ -203,6 +213,7 @@ inc ax mov [bpbHeadsPerCylinder], ax BadParams: +%endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Load FAT (FAT12: 6KB max, FAT16: 128KB max) ;; @@ -255,9 +266,13 @@ repe cmpsb pop di je FindNameFound +%if NullEntryCheck != 0 scasb je FindNameFailed ; end of root directory (NULL entry found) add di, byte 31 +%else + add di, byte 32 +%endif dec word [bx(bpbRootEntries)] jnz FindNameCycle ; next root entry @@ -289,35 +304,49 @@ ;; CH = 0 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +FAT12 equ 1 +FAT16 equ 1 push di ; up to 2 * 635K / BytesPerCluster bytes +%if FAT12 == 1 mov cl, 12 +%endif ClusterLoop: mov [di], si + add si, si ; si = cluster * 2 +%if FAT16 == 1 mov ax, es ; ax = FAT segment = ImageLoadSeg - add si, si ; si = cluster * 2 jnc First64k mov ah, (1000h+ImageLoadSeg)>>8 ; adjust segment for 2nd part of FAT16 First64k: mov dx, 0FFF8h +%else + mov dx, 0FF8h +%endif +%if FAT12 == 1 && FAT16 == 1 cmp [bx(bpbSectorsPerFAT)], cx ; 1..12 = FAT12, 16..256 = FAT16 ja ReadClusterFat16 - mov dh, 0Fh +%endif +%if FAT12 == 1 add si, [di] shr si, 1 ; si = cluster * 3 / 2 - +%endif +%if FAT16 == 1 ReadClusterFat16: push ds mov ds, ax lodsw ; ax = next cluster pop ds +%else + lodsw ; ax = next cluster +%endif +%if FAT12 == 1 jnc ReadClusterEven - rol ax, cl - ReadClusterEven: +%endif scasw ; di += 2 and ah, dh ; mask cluster value cmp ax, dx @@ -464,31 +493,41 @@ push di push cx +%if LBAsupport != 0 push bx push bx +%endif push dx ; 32-bit LBA: up to 2TB push ax push es +%if ReadRetry != 0 || LBAsupport != 0 + mov di, 16 ; packet size byte = 16, reserved byte = 0 +%endif +%if LBAsupport != 0 push bx inc bx ; sector count word = 1 push bx dec bx - mov di, 16 ; packet size byte = 16, reserved byte = 0 push di +%endif +%if Over2GB != 0 xchg ax, cx ; save low LBA xchg ax, dx ; get high LBA cwd ; clear dx (LBA offset <2TB) - div word [bx(bpbSectorsPerTrack)] ; up to 8GB disks + idiv word [bx(bpbSectorsPerTrack)] ; up to 8GB disks xchg ax, cx ; restore low LBA, save high LBA / SPT - div word [bx(bpbSectorsPerTrack)] +%else + xor cx, cx ; up to 2GB disks otherwise divide error interrupt ! +%endif + idiv word [bx(bpbSectorsPerTrack)] ; ax = LBA / SPT ; dx = LBA % SPT = sector - 1 inc dx xchg cx, dx ; restore high LBA / SPT, save sector no. - div word [bx(bpbHeadsPerCylinder)] + idiv word [bx(bpbHeadsPerCylinder)] ; ax = (LBA / SPT) / HPC = cylinder ; dx = (LBA / SPT) % HPC = head mov ch, al @@ -501,41 +540,54 @@ ; dh = head no. ReadSectorRetry: - mov dl, [bx] + mov dl, [bx(DriveNumber)] ; dl = drive no. + mov si, sp +%if LBAsupport != 0 mov ah, 42h ; ah = 42h = extended read function no. - mov si, sp int 13h ; extended read sectors (DL, DS:SI) jnc ReadSectorNextSegment +%endif mov ax, 201h ; al = sector count = 1 ; ah = 2 = read function no. int 13h ; read sectors (AL, CX, DX, ES:BX) jnc ReadSectorNextSegment +%if ReadRetry != 0 cbw ; ah = 0 = reset function int 13h ; reset drive (DL) dec di jnz ReadSectorRetry ; extra attempt +%endif call Error db "Read error." ReadSectorNextSegment: +%if LBAsupport != 0 pop ax ; al = 16 mul byte [bx(bpbBytesPerSector)+1] ; = (bpbBytesPerSector/256)*16 pop cx ; sector count = 1 pop bx add [si+6], ax ; adjust segment for next sector +%else + mov al, 16 + mul byte [bx(bpbBytesPerSector)+1] ; = (bpbBytesPerSector/256)*16 + add [si], ax ; adjust segment for next sector +%endif pop es ; es:0 updated pop ax pop dx +%if LBAsupport != 0 pop di pop di - add ax, cx ; adjust LBA for next sector +%else + add ax, 1 ; adjust LBA for next sector +%endif pop cx ; cluster sectors to read pop di ; file sectors to read @@ -543,7 +595,7 @@ loopne ReadSectorNext ; until cluster sector count or file sector count is reached pop si mov ax, bx ; clear ax - mov dx, [bx] ; pass the BIOS boot drive to Run or Error + mov dx, [bx(DriveNumber)] ; pass the BIOS boot drive to Run or Error ret @@ -581,7 +633,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ProgramName db "STARTUP BIN" ; name and extension each must be - ; padded with spaces (11 bytes total) + times (510-($-$$)) db ' ' ; padded with spaces (11 bytes total) ;;;;;;;;;;;;;;;;;;;;;;;;;; ;; End of the sector ID ;; diff -r 6023b31d568c -r 62d43c1b8453 BootProg/stuff/boot32.asm --- a/BootProg/stuff/boot32.asm Mon Sep 12 16:35:46 2022 +0000 +++ b/BootProg/stuff/boot32.asm Wed Sep 14 18:33:54 2022 +0000 @@ -185,7 +185,6 @@ xor di, di mov ds, di push es - push byte main mov [si(DriveNumber)], dx ; store BIOS boot drive number rep movsw @@ -193,6 +192,7 @@ ;; Jump to the copy ;; ;;;;;;;;;;;;;;;;;;;;;; + push byte main retf main: @@ -440,20 +440,19 @@ idiv word [bx(bpbSectorsPerTrack)] ; up to 8GB disks, avoid divide error xchg ax, cx ; restore low LBA, save high LBA / SPT - div word [bx(bpbSectorsPerTrack)] %else ; Busybox mkdosfs creates fat32 for floppies. ; Floppies may support CHS only. cwd ; clear dx (LBA offset <16MB) + xor cx, cx ; high LBA / SPT = 0 +%endif idiv word [bx(bpbSectorsPerTrack)] - xor cx, cx -%endif ; ax = LBA / SPT ; dx = LBA % SPT = sector - 1 inc dx xchg cx, dx ; restore high LBA / SPT, save sector no. - div word [bx(bpbHeadsPerCylinder)] + idiv word [bx(bpbHeadsPerCylinder)] ; ax = (LBA / SPT) / HPC = cylinder ; dx = (LBA / SPT) % HPC = head diff -r 6023b31d568c -r 62d43c1b8453 BootProg/stuff/bootex.asm --- a/BootProg/stuff/bootex.asm Mon Sep 12 16:35:46 2022 +0000 +++ b/BootProg/stuff/bootex.asm Wed Sep 14 18:33:54 2022 +0000 @@ -77,6 +77,9 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %define bx(label) bx+label-boot +%define si(label) si+label-boot +NullEntryCheck equ 1 ; +3 bytes +ReadRetry equ 1 ; +8 bytes [BITS 16] [CPU 386] @@ -92,6 +95,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; boot: +DriveNumber: jmp short start ; Windows checks for this jump nop bsOemName DB "EXFAT " ; 0x03 @@ -154,13 +158,14 @@ mov si, 7C00h xor di, di mov ds, di + push es + mov [si(DriveNumber)], dx ; store BIOS boot drive number rep movsw ; move 512 bytes (+ 12) ;;;;;;;;;;;;;;;;;;;;;; ;; Jump to the copy ;; ;;;;;;;;;;;;;;;;;;;;;; - push es push word main retf @@ -169,7 +174,6 @@ pop ds xor ebx, ebx - mov [bx], dl ; store BIOS boot drive number mov esi, [bx(bpbRootDirCluster)] ; esi=cluster # of root dir @@ -194,16 +198,20 @@ ;; dword [bx+FileSize] file size ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CurNameSize equ 3 -StartCluster equ 14h -FileSize equ 18h +CurNameSize equ 3 ; 1 byte +StartCluster equ 14h ; 4 bytes +FileSize equ 18h ; 8 bytes FindNameCycle: pusha +%if NullEntryCheck != 0 xor ax, ax or al, [es:di] je FindNameFailed +%else + movzx ax, byte [es:di] +%endif cmp al, 0c0h ; EXFAT_ENTRY_FILE_INFO ? jne NotFileInfo @@ -213,7 +221,7 @@ mov al, [es:di+bx] mov [bx], al dec bx - jnz CopyInfo ; keep BIOS boot drive number + jnz CopyInfo ; keep BIOS boot drive number NotFileInfo: mov al, 0c1h ; EXFAT_ENTRY_FILE_NAME ? @@ -232,7 +240,7 @@ popf ; restore carry="not last sector" flag jc RootDirReadContinue ; continue to the next root dir cluster FindNameFailed: ; end of root directory (dir end reached) - mov dl, [bx] ; restore BIOS boot drive number + mov dx, [bx(DriveNumber)] ; restore BIOS boot drive number call Error db "File not found." FindNameFound: @@ -250,9 +258,9 @@ add di, bp ; adjust segment for next sector mov es, di ; es:0 updated call ReadCluster ; read one more sector of the boot file - sub [bx+FileSize], ebp + sub [bx+FileSize], ebp ; max FileSize is < 640KB : check low 32 bits only ja FileReadContinue - mov dl, [bx] ; restore BIOS boot drive number + mov dx, [bx(DriveNumber)] ; restore BIOS boot drive number xor ax, ax pop bp @@ -354,10 +362,9 @@ loop ReadSectorC mul ebx ; edx:eax = 0 - mov cl, [bx(bpbSectorSizeBits)] - dec cx - stc - rcl eax, cl ; eax=# of exFAT entries per sector + mov cl,-2 + add cl, [bx(bpbSectorSizeBits)] + bts ax, cx ; eax=# of exFAT entries per sector lea edi, [esi-2] ; edi=cluster #-2 xchg eax, esi div esi ; eax=FAT sector #, edx=entry # in sector @@ -365,15 +372,14 @@ imul si, dx, byte 4 ; si=entry # offset in sector cdq - add eax, [bx(bpbFatSectorStart)] ; sector # relative to exFAT - call ReadSectorC ; read 1 exFAT sector + add eax, [bx(bpbFatSectorStart)] ; sector # relative to FAT32 + call ReadSectorC ; read 1 FAT32 sector mov esi, [es:si] ; esi=next cluster # - inc dx - mov cl, [bx(bpbSectorPerClusterBits)] - shl edx, cl ; 10000h max (32MB cluster) - mov ecx, edx + mov dl, [bx(bpbSectorPerClusterBits)] + xor cx, cx + bts ecx, edx ; 10000h max (32MB cluster) xchg eax, edi ; get cluster #-2 mul ecx @@ -407,19 +413,25 @@ push es push bx push bp ; sector count word = 1 +%if ReadRetry != 0 mov cx, 16 push cx ; packet size byte = 16, reserved byte = 0 ReadSectorRetry: +%else + push byte 16 +%endif mov si, sp mov ah, 42h ; ah = 42h = extended read function no. - mov dl, [bx] ; restore BIOS boot drive number + mov dl, [bx(DriveNumber)] ; restore BIOS boot drive number int 13h ; extended read sectors (DL, DS:SI) jnc ReadSuccess +%if ReadRetry != 0 xor ax, ax int 13h ; reset drive (DL) loop ReadSectorRetry ; up to 16 retries +%endif call Error db "Read error." diff -r 6023b31d568c -r 62d43c1b8453 diggerjs/receipt --- a/diggerjs/receipt Mon Sep 12 16:35:46 2022 +0000 +++ b/diggerjs/receipt Wed Sep 14 18:33:54 2022 +0000 @@ -9,7 +9,8 @@ SOURCE="digger.js" TARBALL="$SOURCE-$VERSION.zip" WEB_SITE="http://www.heise.de/software/download/digger.js/8148" -WGET_URL="https://www.tikkel.de/download/$TARBALL" +#WGET_URL="https://www.tikkel.de/download/$TARBALL" +WGET_URL="https://download.tuxfamily.org/slitaz/sources/packages-cooking/${TARBALL:0:1}/$TARBALL" # What is the latest version available today? current_version() diff -r 6023b31d568c -r 62d43c1b8453 nareto/receipt --- a/nareto/receipt Mon Sep 12 16:35:46 2022 +0000 +++ b/nareto/receipt Wed Sep 14 18:33:54 2022 +0000 @@ -8,7 +8,7 @@ LICENSE="GPL2" TARBALL="$PACKAGE-$VERSION.tar.gz" WEB_SITE="https://web.archive.org/web/20131008041555/http://www.nareto.org/" -WGET_URL="${WEB_SITE}srcs/$TARBALL" +WGET_URL="https://download.tuxfamily.org/slitaz/sources/packages-cooking/${TARBALL:0:1}/$TARBALL" CONFIG_FILES="/etc/nagios" BUGS="s/oreon/centreon/"