Files
s390-tools/zipl/boot/eckd2.c
Eduard Shishkin 917d611883 zipl: add/move some definitions to header files
Make the listed changes which are needed to re-use some definitions
by the new zipl-debug(8) tool introduced by the next patch in the
series:

. Add definitions to boot_defs.h:
   . a named union disk_bloclkptr (instead of the anonymous one);
   . a named structure disk_program_table;
. Remove a 'typedef union disk_blockptr_t' from boot/stage2.h
  (cleanup), use the named union in boot_defs.h instead;
. Move the definition of scsi_layout types and the function
  get_scsi_layout() from install.c to install.h;
. Move definition of PROGRAM_TABLE_BLOCK_SIZE from bootmap.c to
  bootmap.h

Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-07-04 15:41:02 +02:00

102 lines
2.4 KiB
C

/*
* zipl - zSeries Initial Program Loader tool
*
* Subroutines for ECKD disks
*
* Copyright IBM Corp. 2013, 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include "eckd.h"
#include "boot/s390.h"
#include "stage2.h"
int extract_length(void *data)
{
struct eckd_blockptr_legacy *blockptr =
(struct eckd_blockptr_legacy *)data;
return blockptr->size * (blockptr->blockct + 1);
}
int is_zero_block(void *data)
{
struct eckd_blockptr_legacy *blockptr =
(struct eckd_blockptr_legacy *)data;
return blockptr->cyl || blockptr->head || blockptr->sec;
}
void *load_direct(union disk_blockptr *data, struct subchannel_id subchannel_id,
void *load_addr)
{
struct eckd_blockptr_legacy *blockptr = &data->eckd_legacy;
struct ccw1 *ccws;
unsigned long record_size;
struct seek_arg seek_addr;
struct chr_t search_arg;
int record_number;
struct irb *irb;
struct orb orb;
int i = 3;
irb = (struct irb *)&S390_lowcore.irb;
memset(irb, 0, sizeof(struct irb));
memset(&orb, 0, sizeof(struct orb));
memset(&seek_addr, 0, sizeof(struct ch_t));
memset(&search_arg, 0, sizeof(struct chr_t));
ccws = (struct ccw1 *)get_zeroed_page();
/* initialise SEEK, SEARCH and TIC CCW*/
ccws[0].cmd_code = DASD_ECKD_CCW_SEEK;
ccws[0].flags = CCW_FLAG_CC | CCW_FLAG_SLI;
ccws[0].count = 6;
seek_addr.ch.cyl = blockptr->cyl;
seek_addr.ch.head = blockptr->head;
ccws[0].cda = (uint32_t) (unsigned long) &seek_addr;
record_number = blockptr->blockct;
record_size = blockptr->size;
ccws[1].cmd_code = DASD_ECKD_CCW_SEARCH;
ccws[1].flags = CCW_FLAG_CC | CCW_FLAG_SLI;
ccws[1].count = 5;
search_arg.cyl = blockptr->cyl;
search_arg.head = blockptr->head;
search_arg.record = blockptr->sec;
ccws[1].cda = (uint32_t) (unsigned long) &search_arg;
ccws[2].cmd_code = DASD_ECKD_CCW_TIC;
ccws[2].flags = 0;
ccws[2].count = 0;
ccws[2].cda = (uint32_t) (unsigned long) &ccws[1];
/* initialise READ CCWs */
while (1) {
ccws[i].cmd_code = DASD_ECKD_CCW_READ_MT;
ccws[i].flags = CCW_FLAG_SLI;
ccws[i].count = record_size;
ccws[i].cda = (uint32_t) (unsigned long) load_addr;
record_number--;
load_addr += record_size;
i++;
if (record_number >= 0)
ccws[i-1].flags |= CCW_FLAG_CC;
else
break;
}
orb.fmt = 1;
orb.cpa = (uint32_t) (unsigned long) ccws;
start_io(subchannel_id, irb, &orb, 1);
free_page((unsigned long)ccws);
return load_addr;
}