static int zipl_load_segment(struct component_entry *entry)

{

    const int max_entries = (SECTOR_SIZE / sizeof(struct scsi_blockptr));

    struct scsi_blockptr *bprs = (void*)sec;

    const int bprs_size = sizeof(sec);

    uint64_t blockno;

    long address;

    int i;



    blockno = entry->data.blockno;

    address = entry->load_address;



    debug_print_int("loading segment at block", blockno);

    debug_print_int("addr", address);



    do {

        memset(bprs, FREE_SPACE_FILLER, bprs_size);

        if (virtio_read(blockno, (uint8_t *)bprs)) {

            debug_print_int("failed reading bprs at", blockno);

            goto fail;

        }



        for (i = 0;; i++) {

            u64 *cur_desc = (void*)&bprs[i];



            blockno = bprs[i].blockno;

            if (!blockno)

                break;



            /* we need the updated blockno for the next indirect entry in the

               chain, but don't want to advance address */

            if (i == (max_entries - 1))

                break;



            if (bprs[i].blockct == 0 && unused_space(&bprs[i + 1],

                sizeof(struct scsi_blockptr))) {

                /* This is a "continue" pointer.

                 * This ptr is the last one in the current script section.

                 * I.e. the next ptr must point to the unused memory area.

                 * The blockno is not zero, so the upper loop must continue

                 * reading next section of BPRS.

                 */

                break;

            }

            address = virtio_load_direct(cur_desc[0], cur_desc[1], 0,

                                         (void*)address);

            if (address == -1)

                goto fail;

        }

    } while (blockno);



    return 0;



fail:

    sclp_print("failed loading segment\n");

    return -1;

}

static int zipl_load_segment(struct component_entry *entry)

{

    const int max_entries = (SECTOR_SIZE / sizeof(struct scsi_blockptr));

    struct scsi_blockptr *bprs = (void*)sec;

    const int bprs_size = sizeof(sec);

    uint64_t blockno;

    long address;

    int i;



    blockno = entry->data.blockno;

    address = entry->load_address;



    debug_print_int("loading segment at block", blockno);

    debug_print_int("addr", address);



    do {

        memset(bprs, FREE_SPACE_FILLER, bprs_size);

        if (virtio_read(blockno, (uint8_t *)bprs)) {

            debug_print_int("failed reading bprs at", blockno);

            goto fail;

        }



        for (i = 0;; i++) {

            u64 *cur_desc = (void*)&bprs[i];



            blockno = bprs[i].blockno;

            if (!blockno)

                break;



            



            if (i == (max_entries - 1))

                break;



            if (bprs[i].blockct == 0 && unused_space(&bprs[i + 1],

                sizeof(struct scsi_blockptr))) {

                











                break;

            }

            address = virtio_load_direct(cur_desc[0], cur_desc[1], 0,

                                         (void*)address);

            if (address == -1)

                goto fail;

        }

    } while (blockno);



    return 0;



fail:

    sclp_print("failed loading segment\n");

    return -1;

}

static int FUNC_0(struct component_entry *VAR_0)

{

    const int VAR_1 = (SECTOR_SIZE / sizeof(struct scsi_blockptr));

    struct scsi_blockptr *VAR_2 = (void*)sec;

    const int VAR_3 = sizeof(sec);

    uint64_t blockno;

    long VAR_4;

    int VAR_5;



    blockno = VAR_0->data.blockno;

    VAR_4 = VAR_0->load_address;



    debug_print_int("loading segment at block", blockno);

    debug_print_int("addr", VAR_4);



    do {

        memset(VAR_2, FREE_SPACE_FILLER, VAR_3);

        if (virtio_read(blockno, (uint8_t *)VAR_2)) {

            debug_print_int("failed reading VAR_2 at", blockno);

            goto fail;

        }



        for (VAR_5 = 0;; VAR_5++) {

            u64 *cur_desc = (void*)&VAR_2[VAR_5];



            blockno = VAR_2[VAR_5].blockno;

            if (!blockno)

                break;



            



            if (VAR_5 == (VAR_1 - 1))

                break;



            if (VAR_2[VAR_5].blockct == 0 && unused_space(&VAR_2[VAR_5 + 1],

                sizeof(struct scsi_blockptr))) {

                











                break;

            }

            VAR_4 = virtio_load_direct(cur_desc[0], cur_desc[1], 0,

                                         (void*)VAR_4);

            if (VAR_4 == -1)

                goto fail;

        }

    } while (blockno);



    return 0;



fail:

    sclp_print("failed loading segment\n");

    return -1;

}

static int FUNC_0(struct component_entry *VAR_0)
{ const int VAR_1 = (SECTOR_SIZE / sizeof(struct scsi_blockptr)); struct scsi_blockptr *VAR_2 = (void*)sec; const int VAR_3 = sizeof(sec); uint64_t blockno; long VAR_4; int VAR_5; blockno = VAR_0->data.blockno; VAR_4 = VAR_0->load_address; debug_print_int("loading segment at block", blockno); debug_print_int("addr", VAR_4); do { memset(VAR_2, FREE_SPACE_FILLER, VAR_3); if (virtio_read(blockno, (uint8_t *)VAR_2)) { debug_print_int("failed reading VAR_2 at", blockno); goto fail; } for (VAR_5 = 0;; VAR_5++) { u64 *cur_desc = (void*)&VAR_2[VAR_5]; blockno = VAR_2[VAR_5].blockno; if (!blockno)
break; if (VAR_5 == (VAR_1 - 1))
break; if (VAR_2[VAR_5].blockct == 0 && unused_space(&VAR_2[VAR_5 + 1],
sizeof(struct scsi_blockptr))) { break; } VAR_4 = virtio_load_direct(cur_desc[0], cur_desc[1], 0,
(void*)VAR_4); if (VAR_4 == -1)
goto fail; } } while (blockno); return 0; fail:
sclp_print("failed loading segment\n"); return -1; }