New API calls el_torito_set_full_load(), el_torito_get_full_load()

This commit is contained in:
Thomas Schmitt 2016-11-13 10:05:18 +01:00
parent c51efce8d1
commit dc6cd946ba
3 changed files with 72 additions and 2 deletions

View File

@ -113,9 +113,24 @@ void el_torito_set_load_size(ElToritoBootImage *bootimg, short sectors)
/* API */ /* API */
int el_torito_get_load_size(ElToritoBootImage *bootimg) int el_torito_get_load_size(ElToritoBootImage *bootimg)
{ {
return (int) bootimg->load_size; return (int) bootimg->load_size;
} }
/* API */
void el_torito_set_full_load(ElToritoBootImage *bootimg, int mode)
{
if (bootimg->type != 0)
return;
bootimg->load_size_full= !!mode;
}
/* API */
int el_torito_get_full_load(ElToritoBootImage *bootimg)
{
return bootimg->load_size_full;
}
/** /**
* Marks the specified boot image as not bootable * Marks the specified boot image as not bootable
*/ */
@ -513,6 +528,7 @@ int create_image(IsoImage *image, const char *image_path,
boot->partition_type = partition_type; boot->partition_type = partition_type;
boot->load_seg = 0; boot->load_seg = 0;
boot->load_size = load_sectors; boot->load_size = load_sectors;
boot->load_size_full = 0;
boot->platform_id = 0; /* 80x86 */ boot->platform_id = 0; /* 80x86 */
memset(boot->id_string, 0, sizeof(boot->id_string)); memset(boot->id_string, 0, sizeof(boot->id_string));
memset(boot->selection_crit, 0, sizeof(boot->selection_crit)); memset(boot->selection_crit, 0, sizeof(boot->selection_crit));
@ -887,6 +903,32 @@ write_section_header(uint8_t *buf, Ecma119Image *t, int idx, int num_entries)
sizeof(e->id_string)); sizeof(e->id_string));
} }
static int
write_section_load_size(struct el_torito_boot_image *img,
struct el_torito_section_entry *se,
uint16_t load_size, off_t full_byte_size, int flag)
{
uint16_t size;
off_t blocks;
size= load_size;
if(img->type == 0 && img->load_size_full) {
blocks= ((full_byte_size + 2047) / 2048) * 4;
if (blocks > 65535) {
if (img->platform_id == 0xef)
size= 0;
else
size= 65535;
} else if(blocks <= 0) {
size= 1;
} else {
size= blocks;
}
}
iso_lsb(se->sec_count, size, 2);
return(1);
}
/** /**
* Write one section entry. * Write one section entry.
* Usable for the Default Entry * Usable for the Default Entry
@ -930,6 +972,8 @@ int write_section_entry(uint8_t *buf, Ecma119Image *t, int idx)
return ISO_BOOT_IMAGE_NOT_VALID; return ISO_BOOT_IMAGE_NOT_VALID;
} }
/* >>> check for non-automatic load size */;
if (t->boot_intvl_size[idx] > 65535) { if (t->boot_intvl_size[idx] > 65535) {
if (img->platform_id == 0xef) if (img->platform_id == 0xef)
iso_lsb(se->sec_count, 0, 2); iso_lsb(se->sec_count, 0, 2);
@ -946,6 +990,9 @@ int write_section_entry(uint8_t *buf, Ecma119Image *t, int idx)
iso_lsb(se->block, t->boot_intvl_start[idx], 4); iso_lsb(se->block, t->boot_intvl_start[idx], 4);
} else if (mode == 2) { } else if (mode == 2) {
app_idx = t->boot_appended_idx[idx]; app_idx = t->boot_appended_idx[idx];
/* >>> check for non-automatic load size */;
if (t->appended_part_size[app_idx] * 4 > 65535) { if (t->appended_part_size[app_idx] * 4 > 65535) {
if (img->platform_id == 0xef) if (img->platform_id == 0xef)
iso_lsb(se->sec_count, 0, 2); iso_lsb(se->sec_count, 0, 2);
@ -956,7 +1003,8 @@ int write_section_entry(uint8_t *buf, Ecma119Image *t, int idx)
} }
iso_lsb(se->block, t->appended_part_start[app_idx], 4); iso_lsb(se->block, t->appended_part_start[app_idx], 4);
} else { } else {
iso_lsb(se->sec_count, img->load_size, 2); write_section_load_size(img, se, (uint16_t) img->load_size,
(off_t) t->bootsrc[idx]->sections[0].size, 0);
iso_lsb(se->block, t->bootsrc[idx]->sections[0].block, 4); iso_lsb(se->block, t->bootsrc[idx]->sections[0].block, 4);
} }

View File

@ -3836,6 +3836,26 @@ void el_torito_set_load_size(ElToritoBootImage *bootimg, short sectors);
*/ */
int el_torito_get_load_size(ElToritoBootImage *bootimg); int el_torito_get_load_size(ElToritoBootImage *bootimg);
/**
* State that the load size shall be the size of the boot image automatically.
* This overrides el_torito_set_load_size().
* @param bootimg
* The image to to manipulate
* @param mode
* 0= use value of el_torito_set_load_size()
* 1= determine value from boot image
*/
void el_torito_set_full_load(ElToritoBootImage *bootimg, int mode);
/**
* Inquire the setting of el_torito_set_full_load().
* @param bootimg
* The image to inquire
* @return
* The mode set with el_torito_set_full_load().
*/
int el_torito_get_full_load(ElToritoBootImage *bootimg);
/** /**
* Marks the specified boot image as not bootable * Marks the specified boot image as not bootable
* *

View File

@ -5,6 +5,7 @@ aaip_xinfo_func;
el_torito_get_bootable; el_torito_get_bootable;
el_torito_get_boot_media_type; el_torito_get_boot_media_type;
el_torito_get_boot_platform_id; el_torito_get_boot_platform_id;
el_torito_get_full_load;
el_torito_get_id_string; el_torito_get_id_string;
el_torito_get_isolinux_options; el_torito_get_isolinux_options;
el_torito_get_load_seg; el_torito_get_load_seg;
@ -13,6 +14,7 @@ el_torito_get_selection_crit;
el_torito_patch_isolinux_image; el_torito_patch_isolinux_image;
el_torito_seems_boot_info_table; el_torito_seems_boot_info_table;
el_torito_set_boot_platform_id; el_torito_set_boot_platform_id;
el_torito_set_full_load;
el_torito_set_id_string; el_torito_set_id_string;
el_torito_set_isolinux_options; el_torito_set_isolinux_options;
el_torito_set_load_seg; el_torito_set_load_seg;