static int zipl_run(struct scsi_blockptr *pte)

{

    struct component_header *header;

    struct component_entry *entry;

    uint8_t tmp_sec[SECTOR_SIZE];



    virtio_read(pte->blockno, tmp_sec);

    header = (struct component_header *)tmp_sec;



    if (!zipl_magic(tmp_sec)) {

        goto fail;

    }



    if (header->type != ZIPL_COMP_HEADER_IPL) {

        goto fail;

    }



    dputs("start loading images\n");



    /* Load image(s) into RAM */

    entry = (struct component_entry *)(&header[1]);

    while (entry->component_type == ZIPL_COMP_ENTRY_LOAD) {

        if (zipl_load_segment(entry) < 0) {

            goto fail;

        }



        entry++;



        if ((uint8_t*)(&entry[1]) > (tmp_sec + SECTOR_SIZE)) {

            goto fail;

        }

    }



    if (entry->component_type != ZIPL_COMP_ENTRY_EXEC) {

        goto fail;

    }



    /* should not return */

    jump_to_IPL_code(entry->load_address);



    return 0;



fail:

    sclp_print("failed running zipl\n");

    return -1;

}

static int zipl_run(struct scsi_blockptr *pte)

{

    struct component_header *header;

    struct component_entry *entry;

    uint8_t tmp_sec[SECTOR_SIZE];



    virtio_read(pte->blockno, tmp_sec);

    header = (struct component_header *)tmp_sec;



    if (!zipl_magic(tmp_sec)) {

        goto fail;

    }



    if (header->type != ZIPL_COMP_HEADER_IPL) {

        goto fail;

    }



    dputs("start loading images\n");



    

    entry = (struct component_entry *)(&header[1]);

    while (entry->component_type == ZIPL_COMP_ENTRY_LOAD) {

        if (zipl_load_segment(entry) < 0) {

            goto fail;

        }



        entry++;



        if ((uint8_t*)(&entry[1]) > (tmp_sec + SECTOR_SIZE)) {

            goto fail;

        }

    }



    if (entry->component_type != ZIPL_COMP_ENTRY_EXEC) {

        goto fail;

    }



    

    jump_to_IPL_code(entry->load_address);



    return 0;



fail:

    sclp_print("failed running zipl\n");

    return -1;

}

static int FUNC_0(struct scsi_blockptr *VAR_0)

{

    struct component_header *VAR_1;

    struct component_entry *VAR_2;

    uint8_t tmp_sec[SECTOR_SIZE];



    virtio_read(VAR_0->blockno, tmp_sec);

    VAR_1 = (struct component_header *)tmp_sec;



    if (!zipl_magic(tmp_sec)) {

        goto fail;

    }



    if (VAR_1->type != ZIPL_COMP_HEADER_IPL) {

        goto fail;

    }



    dputs("start loading images\n");



    

    VAR_2 = (struct component_entry *)(&VAR_1[1]);

    while (VAR_2->component_type == ZIPL_COMP_ENTRY_LOAD) {

        if (zipl_load_segment(VAR_2) < 0) {

            goto fail;

        }



        VAR_2++;



        if ((uint8_t*)(&VAR_2[1]) > (tmp_sec + SECTOR_SIZE)) {

            goto fail;

        }

    }



    if (VAR_2->component_type != ZIPL_COMP_ENTRY_EXEC) {

        goto fail;

    }



    

    jump_to_IPL_code(VAR_2->load_address);



    return 0;



fail:

    sclp_print("failed running zipl\n");

    return -1;

}

static int FUNC_0(struct scsi_blockptr *VAR_0)
{ struct component_header *VAR_1; struct component_entry *VAR_2; uint8_t tmp_sec[SECTOR_SIZE]; virtio_read(VAR_0->blockno, tmp_sec); VAR_1 = (struct component_header *)tmp_sec; if (!zipl_magic(tmp_sec)) { goto fail; } if (VAR_1->type != ZIPL_COMP_HEADER_IPL) { goto fail; } dputs("start loading images\n"); VAR_2 = (struct component_entry *)(&VAR_1[1]); while (VAR_2->component_type == ZIPL_COMP_ENTRY_LOAD) { if (zipl_load_segment(VAR_2) < 0) { goto fail; } VAR_2++; if ((uint8_t*)(&VAR_2[1]) > (tmp_sec + SECTOR_SIZE)) { goto fail; } } if (VAR_2->component_type != ZIPL_COMP_ENTRY_EXEC) { goto fail; } jump_to_IPL_code(VAR_2->load_address); return 0; fail:
sclp_print("failed running zipl\n"); return -1; }