[syslinux] isolinux needing mkisofs
David Bond
daveb123 at hotmail.com
Wed Dec 8 20:37:03 PST 2004
Below is a unified diff of a slightly modify patch. It will inspect the
boot info table to see if it has been initialized by an external program.
If so it will not try to alter it. If not it will assume sector 16 for the
PVD and 17 for the BVD and go from there. Per you previous note this should
allow for the highest chance of successful boot. Below that is the C code
for the checksum generation program.
David
-- isolinux.asm.org 2004-08-04 02:16:53.000000000 -0400
+++ isolinux.asm 2004-12-08 08:03:09.000000000 -0500
@@ -244,7 +244,7 @@
; -boot-info-table option
bi_pvd: dd 0xdeadbeef ; LBA of primary
volume descriptor
bi_file: dd 0xdeadbeef ; LBA of boot file
-bi_length: dd 0xdeadbeef ; Length of boot file
+bi_length: dd size_of_code ; Length of boot file
;DEB
bi_csum: dd 0xdeadbeef ; Checksum of boot file
bi_reserved: times 10 dd 0xdeadbeef ; Reserved
@@ -280,14 +280,6 @@
loop .loop
mov [FirstSecSum],edi
- ; Set up boot file sizes
- mov eax,[bi_length]
- sub eax,SECTORSIZE-3
- shr eax,2 ; bytes->dwords
- mov [ImageDwords],eax ; boot file dwords
- add eax,(2047 >> 2)
- shr eax,9 ; dwords->sectors
- mov [ImageSectors],ax ; boot file sectors
mov [DriveNo],dl
%ifdef DEBUG_MESSAGES
@@ -324,8 +316,71 @@
; clear on the fact that it must all be loaded.) Therefore,
; we load it ourselves, and *bleep* the BIOS.
+;DEB -- Patch to have code actually insert values for bi_file and bi_length
if none specified
+ mov eax, dword [bi_pvd] ;DEB
+ cmp eax, 0xdeadbeef ;DEB Was this image made by
mkisofs or something else?
+ jne mkisofsimg ;DEB This is a mkisofs image
go do normal stuff
+ ;DEB Otherwise assume single
session cd
+ ;DEB and hope we're right
+%ifdef DEBUG_MESSAGES
+ mov si,nobootinf_msg ;DEB Boot Info table not
pre-filled
+ call writemsg ;DEB Inform user Boot info
table not initialized
+%endif
+ mov eax, 16 ;DEB
+ mov dword [bi_pvd], eax ;DEB PVD is at 0x16 on
single session CD
+ ;DEB
+ mov bx, trackbuf ;DEB
+ mov eax, 17 ;DEB BRV is at 0x17 on
single session CD
+ call getonesec ;DEB Retrieve Boot Record
Volume into trackbuf
+
+ mov eax, dword [trackbuf+47h] ;DEB EAX is now address of
Boot Catalog
+ ;DEB if this is a single
session CD
+
+%ifdef DEBUG_MESSAGES
+ mov si,bcat_msg ;DEB Write sector address of
boot cat
+ call writemsg ;DEB
+ call writehex8 ;DEB
+ call crlf ;DEB
+%endif
+
+ mov bx, trackbuf ;DEB
+ call getonesec ;DEB get the Boot Catalog
into trackbuf
+
+ mov eax, dword [trackbuf+28h] ;DEB put RBA sector address
in EAX
+ mov dword [bi_file], eax ;DEB Put RBA address into
bi_file variable
+
+%ifdef DEBUG_MESSAGES
+ mov si,rba_msg ;DEB write out RBA sector
address
+ call writemsg ;DEB
+ call writehex8 ;DEB
+ call crlf ;DEB
+%endif
+
+%ifdef DEBUG_MESSAGES
+ mov si,imgsz_msg ;DEB write out image size
+ call writemsg ;DEB
+ mov eax, dword [bi_length] ;DEB
+ call writehex8 ;DEB
+ call crlf ;DEB
+%endif ;DEB
+
+mkisofsimg:
+;DEB -- we now return you to your regularly scheduled programing :)
+
+
+ ; Set up boot file sizes
+ mov eax,[bi_length]
+ sub eax,SECTORSIZE-3
+ shr eax,2 ; bytes->dwords
+ mov [ImageDwords],eax ; boot file dwords
+ add eax,(2047 >> 2)
+ shr eax,9 ; dwords->sectors
+ mov [ImageSectors],ax ; boot file sectors
+
+
mov eax,[bi_file] ; Address of code to load
inc eax ; Don't reload bootstrap
code
+
%ifdef DEBUG_MESSAGES
mov si,offset_msg
call writemsg
@@ -759,6 +814,12 @@
ondrive_str: db ', drive ', 0
nothing_msg: db 'Failed to locate CD-ROM device; boot failed.', CR, LF, 0
checkerr_msg: db 'Image checksum error, sorry...', CR, LF, 0
+nobootinf_msg db 'Boot info table empty', CR, LF, 0 ;DEB debug
msg
+bcat_msg db 'BCAT@', 0 ;DEB debug
msg
+rba_msg db 'RBA@', 0 ;DEB
debug msg
+imgsz_msg db 'IMGSZ=', 0 ;DEB debug
msg
+
+
err_bootfailed db CR, LF, 'Boot failed: press a key to retry...'
bailmsg equ err_bootfailed
@@ -1713,6 +1774,8 @@
boot_image_len equ $-boot_image
ldlinux_end equ $
+size_of_code equ ldlinux_end-bootsec ;DEB Used to calculate
bi_length
+
;
; Put the getcbuf right after the code, aligned on a sector boundary
;
#include <stdio.h>
#include <stdlib.h>
#define BUFFSZ 16*1024 //BUFFSZ must be a multiple of 4
#define INTSZ sizeof(int) //Has to be 4 and will be checked later
#define CKSUMPOS 0x14 //Position of checksum field in isolinux.bin
file header
int main(int argc, char **argv)
{
FILE *fh;
char FBuff[BUFFSZ];
unsigned int CheckSum,*IPtr,Items,x;
if (INTSZ!=4)
{fprintf(stderr,"\n\nInteger size is not 32 bits\nPlease recompile
with appropriate modifications\n\n");exit(1);}
if (argc!=2)
{fprintf(stderr,"\n\nUsage %s <isolinux.bin>\nPatches a isolinux.bin
file to place proper checksum in header info\n\n",argv[0]);exit(1);}
if ((fh=fopen(argv[1],"r+"))==NULL)
{fprintf(stderr,"\n\nError opening isolinux.bin file named:
%s\n\n",argv[1]);exit(1);}
//Skip first 64 bytes of data at front of file
x=16;
IPtr=(unsigned int *)&(FBuff[64]);
CheckSum=0;
while (Items=fread(FBuff,INTSZ,BUFFSZ/INTSZ,fh))
{
for(;x<Items;x++,IPtr++)
CheckSum+=*IPtr;
//Use all bytes of data on 2nd and subsequent passes
x=0;
IPtr=(unsigned int*)FBuff;
}
if (fseek(fh,CKSUMPOS,SEEK_SET))
{fprintf(stderr,"\n\nError updating file, ABORTING\n\n");exit(1);}
if ( fwrite(&CheckSum,INTSZ,1,fh) !=1 )
{fprintf(stderr,"\n\nError writing new checksum info to
file\n\n");exit(1);}
printf("Checksum field of file %s updated to 0x%08X\n",argv[1],CheckSum);
fclose(fh);
}
More information about the Syslinux
mailing list