mk9660: add -E option to create EFI boot entry
This commit is contained in:
parent
4bfa18a5d1
commit
2cfbc3c1cb
5 changed files with 67 additions and 31 deletions
|
@ -18,6 +18,10 @@ dump9660, mk9660 \- create an ISO-9660 CD image
|
||||||
.I bootfile
|
.I bootfile
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
.B -E
|
||||||
|
.I bootfile
|
||||||
|
]
|
||||||
|
[
|
||||||
.B -p
|
.B -p
|
||||||
.I proto
|
.I proto
|
||||||
]
|
]
|
||||||
|
@ -193,6 +197,17 @@ boot block.
|
||||||
This gives the program in the boot block full (ATA) LBA access
|
This gives the program in the boot block full (ATA) LBA access
|
||||||
to the CD filesystem, not just the initial blocks that would fit on a floppy.
|
to the CD filesystem, not just the initial blocks that would fit on a floppy.
|
||||||
.PP
|
.PP
|
||||||
|
In addition to
|
||||||
|
.B -b
|
||||||
|
and
|
||||||
|
.B -B
|
||||||
|
a boot entry for UEFI systems can be created with the
|
||||||
|
.B -E
|
||||||
|
option and with
|
||||||
|
.I bootfile
|
||||||
|
pointing to a FAT image containing the contents of
|
||||||
|
the efi system partition.
|
||||||
|
.PP
|
||||||
The
|
The
|
||||||
.B -D
|
.B -D
|
||||||
flag creates immense amounts of debugging output
|
flag creates immense amounts of debugging output
|
||||||
|
|
|
@ -149,23 +149,16 @@ enum {
|
||||||
Emusectsz = 512, /* bytes per emulated sector */
|
Emusectsz = 512, /* bytes per emulated sector */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static void
|
||||||
Cupdatebootcat(Cdimg *cd)
|
Caddbootentry(Cdimg *cd, Direc *bootrec, int bios)
|
||||||
{
|
{
|
||||||
uvlong o;
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if(cd->bootdirec == nil)
|
|
||||||
return;
|
|
||||||
|
|
||||||
o = Cwoffset(cd);
|
|
||||||
Cwseek(cd, cd->bootimageptr);
|
|
||||||
Cputc(cd, 0x88);
|
Cputc(cd, 0x88);
|
||||||
|
|
||||||
if(cd->flags & CDbootnoemu)
|
if(cd->flags & CDbootnoemu)
|
||||||
Cputc(cd, 0); /* no disk emulation */
|
Cputc(cd, 0); /* no disk emulation */
|
||||||
else
|
else
|
||||||
switch(cd->bootdirec->length){
|
switch(bootrec->length){
|
||||||
default:
|
default:
|
||||||
fprint(2, "warning: boot image is not 1.44MB or 2.88MB; "
|
fprint(2, "warning: boot image is not 1.44MB or 2.88MB; "
|
||||||
"pretending 1.44MB\n");
|
"pretending 1.44MB\n");
|
||||||
|
@ -183,28 +176,53 @@ Cupdatebootcat(Cdimg *cd)
|
||||||
|
|
||||||
n = 1;
|
n = 1;
|
||||||
if(cd->flags & CDbootnoemu){
|
if(cd->flags & CDbootnoemu){
|
||||||
n = (cd->bootdirec->length + Emusectsz - 1) / Emusectsz;
|
n = (bootrec->length + Emusectsz - 1) / Emusectsz;
|
||||||
if(n > 4){
|
if(bios && n > 4){
|
||||||
fprint(2, "warning: boot image too big; "
|
fprint(2, "warning: boot image too big; "
|
||||||
"will only load the first 2K\n");
|
"will only load the first 2K\n");
|
||||||
n = 4;
|
n = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cputnl(cd, n, 2); /* Emusectsz-byte sector count for load */
|
Cputnl(cd, n, 2); /* Emusectsz-byte sector count for load */
|
||||||
Cputnl(cd, cd->bootdirec->block, 4); /* ptr to disk image */
|
Cputnl(cd, bootrec->block, 4); /* ptr to disk image */
|
||||||
Cwseek(cd, o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
findbootimage(Cdimg *cd, Direc *root)
|
Cupdatebootcat(Cdimg *cd, Direc *root)
|
||||||
{
|
{
|
||||||
Direc *d;
|
Direc *bootrec;
|
||||||
|
uvlong o;
|
||||||
|
|
||||||
d = walkdirec(root, cd->bootimage);
|
bootrec = nil;
|
||||||
if(d == nil){
|
if(cd->bootimage)
|
||||||
|
bootrec = walkdirec(root, cd->bootimage);
|
||||||
|
else if(cd->efibootimage)
|
||||||
|
bootrec = walkdirec(root, cd->efibootimage);
|
||||||
|
if(bootrec == nil){
|
||||||
fprint(2, "warning: did not encounter boot image\n");
|
fprint(2, "warning: did not encounter boot image\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cd->bootdirec = d;
|
o = Cwoffset(cd);
|
||||||
|
|
||||||
|
Cwseek(cd, cd->bootimageptr);
|
||||||
|
Caddbootentry(cd, bootrec, cd->bootimage != nil);
|
||||||
|
|
||||||
|
bootrec = nil;
|
||||||
|
if(cd->efibootimage && cd->bootimage){
|
||||||
|
bootrec = walkdirec(root, cd->efibootimage);
|
||||||
|
if(bootrec == nil)
|
||||||
|
fprint(2, "warning: did not encounter efi boot image\n");
|
||||||
|
}
|
||||||
|
if(bootrec != nil) {
|
||||||
|
Crepeat(cd, 0, 20); /* Unused */
|
||||||
|
Cputc(cd, 0x91);
|
||||||
|
Cputc(cd, 0xef); /* platform id */
|
||||||
|
Cputnl(cd, 1, 2); /* num entries */
|
||||||
|
Crepeat(cd, 0, 28); /* ID string */
|
||||||
|
Caddbootentry(cd, bootrec, 0);
|
||||||
|
Crepeat(cd, 0, 20); /* vendor unique selection criteria. */
|
||||||
|
}
|
||||||
|
|
||||||
|
Cwseek(cd, o);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ createcd(char *file, Cdinfo info)
|
||||||
Cputisopvd(cd, info);
|
Cputisopvd(cd, info);
|
||||||
if(info.flags & CDbootable){
|
if(info.flags & CDbootable){
|
||||||
cd->bootimage = info.bootimage;
|
cd->bootimage = info.bootimage;
|
||||||
|
cd->efibootimage = info.efibootimage;
|
||||||
cd->flags |= info.flags & (CDbootable|CDbootnoemu);
|
cd->flags |= info.flags & (CDbootable|CDbootnoemu);
|
||||||
Cputbootvol(cd);
|
Cputbootvol(cd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
if(mk9660)
|
if(mk9660)
|
||||||
fprint(2, "usage: disk/mk9660 [-D:] [-9cjr] [-b bootfile] [-o offset blocksize] [-p proto] [-s src] cdimage\n");
|
fprint(2, "usage: disk/mk9660 [-D:] [-9cjr] [-[EBb] bootfile] [-o offset blocksize] [-p proto] [-s src] cdimage\n");
|
||||||
else
|
else
|
||||||
fprint(2, "usage: disk/dump9660 [-D:] [-9cjr] [-m maxsize] [-n now] [-p proto] [-s src] cdimage\n");
|
fprint(2, "usage: disk/dump9660 [-D:] [-9cjr] [-m maxsize] [-n now] [-p proto] [-s src] cdimage\n");
|
||||||
exits("usage");
|
exits("usage");
|
||||||
|
@ -86,6 +86,14 @@ main(int argc, char **argv)
|
||||||
info.flags |= CDbootable;
|
info.flags |= CDbootable;
|
||||||
info.bootimage = EARGF(usage());
|
info.bootimage = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
/* efi fat image */
|
||||||
|
if(!mk9660)
|
||||||
|
usage();
|
||||||
|
info.flags |= CDbootable;
|
||||||
|
info.flags |= CDbootnoemu;
|
||||||
|
info.efibootimage = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
info.flags |= CDconform;
|
info.flags |= CDconform;
|
||||||
break;
|
break;
|
||||||
|
@ -204,10 +212,8 @@ main(int argc, char **argv)
|
||||||
Cwseek(cd, (vlong)cd->nextblock * Blocksize);
|
Cwseek(cd, (vlong)cd->nextblock * Blocksize);
|
||||||
writefiles(dump, cd, &iroot);
|
writefiles(dump, cd, &iroot);
|
||||||
|
|
||||||
if(cd->bootimage){
|
if(cd->bootimage || cd->efibootimage)
|
||||||
findbootimage(cd, &iroot);
|
Cupdatebootcat(cd, &iroot);
|
||||||
Cupdatebootcat(cd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create Joliet tree */
|
/* create Joliet tree */
|
||||||
if(cd->flags & CDjoliet)
|
if(cd->flags & CDjoliet)
|
||||||
|
|
|
@ -114,8 +114,8 @@ struct Cdimg {
|
||||||
uvlong bootcatptr;
|
uvlong bootcatptr;
|
||||||
ulong bootcatblock;
|
ulong bootcatblock;
|
||||||
uvlong bootimageptr;
|
uvlong bootimageptr;
|
||||||
Direc *bootdirec;
|
|
||||||
char *bootimage;
|
char *bootimage;
|
||||||
|
char *efibootimage;
|
||||||
|
|
||||||
Biobuf brd;
|
Biobuf brd;
|
||||||
Biobuf bwr;
|
Biobuf bwr;
|
||||||
|
@ -157,12 +157,9 @@ struct Cdinfo {
|
||||||
char *preparer;
|
char *preparer;
|
||||||
char *application;
|
char *application;
|
||||||
char *bootimage;
|
char *bootimage;
|
||||||
|
char *efibootimage;
|
||||||
};
|
};
|
||||||
|
|
||||||
//enum {
|
|
||||||
// Blocklen = 2048, /* unused */
|
|
||||||
//};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a doubly binary tree.
|
* This is a doubly binary tree.
|
||||||
* We have a tree keyed on the MD5 values
|
* We have a tree keyed on the MD5 values
|
||||||
|
@ -293,8 +290,7 @@ enum { /* CputrripNM flag types */
|
||||||
void Cputbootvol(Cdimg*);
|
void Cputbootvol(Cdimg*);
|
||||||
void Cputbootcat(Cdimg*);
|
void Cputbootcat(Cdimg*);
|
||||||
void Cupdatebootvol(Cdimg*);
|
void Cupdatebootvol(Cdimg*);
|
||||||
void Cupdatebootcat(Cdimg*);
|
void Cupdatebootcat(Cdimg*, Direc*);
|
||||||
void findbootimage(Cdimg*, Direc*);
|
|
||||||
|
|
||||||
/* cdrdwr.c */
|
/* cdrdwr.c */
|
||||||
Cdimg *createcd(char*, Cdinfo);
|
Cdimg *createcd(char*, Cdinfo);
|
||||||
|
|
Loading…
Reference in a new issue