Mathias Koerber
2002-Jul-11 06:46 UTC
[syslinux] help with porting patch from 1.62 to 1.75
Hello List, I have below a patch (against Syslinux-1.62), which adds a pseudo-kernel 'swap' which swaps device numbers of the boot device and the first harddisk. It was made for a system equipped with a DiskOnChip (www.msys.com) device which 'steals' the device# of teh first harddisk, This patch is used to enable the syslinux on the DoC to continue booting from the harddisk as if the DoC isn?t present. I am now looking to port this patch to Syslinux-1.75, because I will need both the MEMDISK capability and the swap capability provided by this patch. However, I am highly ignorant of low-level PC hardware etc. The problem is that ldlinux.asm has been totally rewritten between 1.62 and 1.75, so that the patch cannot just be applied to 1.75?s ldlinux.asm. At best, the patch could be applied to the current ldlinux.asm, and the only problem is the location of the into_bootsec label. But that may just be a blue-eyed oversimplification in ignorance of the PC internals, in which case some internals of the patch may have to be changed also. I would like to ask if someone here would be able to advise how this patch could be modified to work with ldlinux.adm of 1.75. The owners of this patch (Ericsson) graciously allowed me to post and discuss the patch here, with the condition that I include a disclaimer that ?there are no warranties and that in no event shall the owner of the patch (which is Ericsson) be liable for any damage.? Hereby done. All assistance with porting thispatch to syslinux-1.75 will be highly appreciated. regards Mathias # cat swapdiffs diff -u -r syslinux-1.62/ldlinux.asm syslinux-1.62-w1/ldlinux.asm --- syslinux-1.62/ldlinux.asm Wed Apr 25 02:36:14 2001 +++ syslinux-1.62-w1/ldlinux.asm Mon Jun 4 12:49:57 2001 @@ -1644,7 +1644,8 @@ ; ; Find the kernel on disk ; -get_kernel: mov byte [KernelName+11],0 ; Zero-terminate filename/extension +get_kernel: call check_for_swap + mov byte [KernelName+11],0 ; Zero-terminate filename/extension mov eax,[KernelName+8] ; Save initial extension mov [OrigKernelExt],eax .search_loop: push bx @@ -2432,6 +2433,7 @@ ; ; Okay, here we go... copy over our own boot sector and run the new one ; +into_bootsec: call vgaclearmode ; Reset video cli ; Point of no return @@ -4162,6 +4164,91 @@ linear_color db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 UsingVGA db 0 +; +; Check for magic "swap" kernel -- wingel +; +check_for_swap: + mov si,swap_name + mov di,KernelName + mov cx,11 + repe cmpsb + je is_swap + ret + +is_swap: + call crlf + mov si,swap_loading + call cwritestr + + push bx + mov ax,0201h ; read disk, 1 sector + mov bx,trackbuf + mov cx,1 ; track 0, sector 1 + xor dh,dh ; head 0 + mov dl,81h ; second hard drive + int 13h + pop bx + jnc swap_read_ok + call crlf + mov si,swap_failed + jmp abort_load +swap_read_ok: + + mov bx,[bsBytesPerSec] + mov ax,[bx+trackbuf-2] + cmp ax,0AA55h ; Boot sector signature + je swap_bootsec_ok + jmp bad_bootsec +swap_bootsec_ok: + + call crlf + mov si,swap_booting + call cwritestr + + push es + + mov ax,[413h] ; Memory size in kBytes + dec ax ; reserve 1 kByte + mov [413h],ax + mov cl,6 ; convert to paragraphs + shl ax,cl + mov es,ax + + mov ax,[4ch] ; real INT13 offset + mov [es:real_int13],ax + mov ax,[4eh] ; real INT13 segment + mov [es:real_int13+2],ax + + mov si,swap_int13 ; copy our INT13 handler + xor di,di + mov cx,swap_int13_len + repz movsb + + xor ax,ax ; install our INT 13 handler + mov [4ch],ax ; offset + mov [4eh],es ; segment + + pop es + + call crlf + + mov byte [bsDriveNumber],80h + + jmp into_bootsec + +swap_int13: + ; swap drives + cmp dl,80h + jb dont_swap + cmp dl,81h + ja dont_swap + xor dl,1h +dont_swap: + jmp far [cs:real_int13] +swap_int13_len equ $-swap_int13 + +real_int13 equ 256*3 + ; --------------------------------------------------------------------------- ------- ; Begin data section ; --------------------------------------------------------------------------- ------- @@ -4292,6 +4379,13 @@ VGAFontSize dw 16 ; Defaults to 16 byte font ScrollAttribute db 07h ; White on black (for text mode) ; +; wingel -- swap magic +; +swap_name db 'SWAP ' +swap_loading db 'Loading boot sector from hard drive...', 0 +swap_booting db 'Booting from hard drive...',0 +swap_failed db 'Failed to read boot sector from hard drive',13,10,0 +; ; Stuff for the command line; we do some trickery here with equ to avoid ; tons of zeros appended to our file and wasting space ; -- Mathias Koerber mathias at koerber.org
Mathias Koerber wrote:> Hello List, > > I have below a patch (against Syslinux-1.62), which adds > a pseudo-kernel 'swap' which swaps device numbers of > the boot device and the first harddisk. It was made > for a system equipped with a DiskOnChip (www.msys.com) > device which 'steals' the device# of teh first harddisk, > This patch is used to enable the syslinux on the DoC > to continue booting from the harddisk as if the DoC > isn?t present. >It would make more sense just to load the boot sector from the secondary drive and call it with DL=81h. SYSLINUX basically has all that code already, although I can't remember for sure if it's enabled in the SYSLINUX module. Try entering "localboot 0x81" ISOLINUX-style; I believe it should work in 1.75 SYSLINUX; if not, let me know. Note that some other boot loaders/MBRs might have a problem with booting from a non-80h hard drive. SYSLINUX won't have any trouble. -hpa