diff --git a/zipl/include/install.h b/zipl/include/install.h index cc1f39b7..874068ef 100644 --- a/zipl/include/install.h +++ b/zipl/include/install.h @@ -58,6 +58,9 @@ struct component_footer { * in the bootmap file. Otherwise, to * phy_block_size boundary. */ + void (*set_location)(struct component_loc *location, + address_t load_address, blocknum_t count, + int block_size); }; struct program_component { @@ -109,6 +112,12 @@ static inline enum scsi_layout get_scsi_layout(unsigned char *bootblock) return scsi_layout_unknown; } +static inline struct component_footer * +component_footer_by_id(enum program_component_id id) +{ + return &component_footers[id]; +} + static inline component_type component_type_by_id(enum program_component_id id) { return component_footers[id].type; diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index 0d6df2d2..78ff73aa 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -353,6 +353,7 @@ static int add_component_file_range(struct install_set *bis, { struct program_component *pc = get_component(bis, mirror_id, comp_id, menu_idx); + struct component_footer *cf = component_footer_by_id(comp_id); struct disk_info *info = &bis->info->base[mirror_id]; struct component_loc *location = &pc->loc; disk_blockptr_t **list = &pc->list; @@ -413,13 +414,7 @@ static int add_component_file_range(struct install_set *bis, *count -= DIV_ROUND_UP(trailer, info->phy_block_size); } /* Fill in component location */ - if (component_type_by_id(comp_id) == COMPONENT_TYPE_LOAD) { - location->addr = load_address; - location->size = *count * info->phy_block_size; - } else { - location->addr = 0; - location->size = 0; - } + cf->set_location(location, load_address, *count, info->phy_block_size); /* Try to compact list */ *count = disk_compact_blocklist(*list, *count, info); write_segment_table: @@ -472,6 +467,7 @@ static int add_component_buffer_base(struct install_set *bis, void *buffer, comp_id, menu_idx); struct file_range *comp_reg = get_component_range(bis, comp_id, menu_idx); + struct component_footer *cf = component_footer_by_id(comp_id); struct disk_info *info = &bis->info->base[mirror_id]; struct component_loc *location = &pc->loc; disk_blockptr_t **list = &pc->list; @@ -506,14 +502,9 @@ static int add_component_buffer_base(struct install_set *bis, void *buffer, comp_reg->offset = offset; comp_reg->len = size; } - if (component_type_by_id(comp_id) == COMPONENT_TYPE_LOAD) { - /* Fill in component location */ - location->addr = data.load_address; - location->size = *count * info->phy_block_size; - } else { - location->addr = 0; - location->size = 0; - } + /* Fill in component location */ + cf->set_location(location, data.load_address, *count, + info->phy_block_size); /* Try to compact list */ *count = disk_compact_blocklist(*list, *count, info); write_segment_table: diff --git a/zipl/src/zipl.c b/zipl/src/zipl.c index 21f6eb0a..faf5b118 100644 --- a/zipl/src/zipl.c +++ b/zipl/src/zipl.c @@ -257,57 +257,87 @@ main(int argc, char* argv[]) return abs(rc); } +static void set_location_common(struct component_loc *location, + address_t load_address, + blocknum_t count, + int block_size) +{ + location->addr = load_address; + location->size = count * block_size; +} + +static void set_location_noop(struct component_loc *location, + __attribute__((unused)) address_t load_address, + __attribute__((unused)) blocknum_t count, + __attribute__((unused)) int block_size) +{ + location->addr = 0; + location->size = 0; +} + /** * Program Component Footers */ struct component_footer component_footers[NR_PROGRAM_COMPONENTS] = { [COMPONENT_ID_HEAP_AREA] = { .type = COMPONENT_TYPE_LOAD, - .desc = "heap area" + .desc = "heap area", + .set_location = set_location_common }, [COMPONENT_ID_STACK_AREA] = { .type = COMPONENT_TYPE_LOAD, - .desc = "stack area" + .desc = "stack area", + .set_location = set_location_common }, [COMPONENT_ID_LOADER_SIGNATURE] = { .type = COMPONENT_TYPE_SIGNATURE, - .desc = "loader signature" + .desc = "loader signature", + .set_location = set_location_noop }, [COMPONENT_ID_LOADER] = { .type = COMPONENT_TYPE_LOAD, - .desc = "internal loader" + .desc = "internal loader", + .set_location = set_location_common }, [COMPONENT_ID_PARAMETERS] = { .type = COMPONENT_TYPE_LOAD, - .desc = "parameters" + .desc = "parameters", + .set_location = set_location_common }, [COMPONENT_ID_IMAGE_SIGNATURE] = { .type = COMPONENT_TYPE_SIGNATURE, - .desc = "image signature" + .desc = "image signature", + .set_location = set_location_noop, }, [COMPONENT_ID_KERNEL_IMAGE] = { .type = COMPONENT_TYPE_LOAD, - .desc = "kernel image" + .desc = "kernel image", + .set_location = set_location_common }, [COMPONENT_ID_PARMLINE] = { .type = COMPONENT_TYPE_LOAD, - .desc = "parmline" + .desc = "parmline", + .set_location = set_location_common }, [COMPONENT_ID_RAMDISK_SIGNATURE] = { .type = COMPONENT_TYPE_SIGNATURE, - .desc = "ramdisk signature" + .desc = "ramdisk signature", + .set_location = set_location_noop }, [COMPONENT_ID_RAMDISK] = { .type = COMPONENT_TYPE_LOAD, - .desc = "initial ramdisk" + .desc = "initial ramdisk", + .set_location = set_location_common }, [COMPONENT_ID_ENVBLK] = { .type = COMPONENT_TYPE_LOAD, .desc = "environment blk", - .fs_block_aligned = 1 + .fs_block_aligned = 1, + .set_location = set_location_common }, [COMPONENT_ID_SEGMENT_FILE] = { .type = COMPONENT_TYPE_EXECUTE, - .desc = "segment file" + .desc = "segment file", + .set_location = set_location_noop } };