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>
This commit is contained in:
Eduard Shishkin
2023-03-17 16:23:41 +01:00
committed by Jan Höppner
parent 94e0b644a7
commit 917d611883
10 changed files with 52 additions and 50 deletions
+15 -5
View File
@@ -195,15 +195,25 @@ struct boot_info_bp_dump {
uint8_t unused[16];
} __packed;
/* This represents on-disk pointer to a block on disk */
union disk_blockptr {
struct eckd_blockptr_legacy eckd_legacy;
struct eckd_blockptr eckd;
struct linear_blockptr linear;
};
struct boot_info_bp_ipl {
union {
struct eckd_blockptr_legacy eckd_legacy;
struct eckd_blockptr eckd;
struct linear_blockptr lin;
} bm_ptr;
union disk_blockptr bm_ptr;
uint8_t unused[16];
} __packed;
struct disk_program_table {
uint32_t magic;
uint32_t version;
uint64_t unused;
union disk_blockptr component_table[0];
} __packed;
struct boot_info {
char magic[4];
uint8_t version;
+3 -3
View File
@@ -29,10 +29,10 @@ int is_zero_block(void *data)
return blockptr->cyl || blockptr->head || blockptr->sec;
}
void * load_direct(disk_blockptr_t *data, struct subchannel_id subchannel_id,
void *load_addr)
void *load_direct(union disk_blockptr *data, struct subchannel_id subchannel_id,
void *load_addr)
{
struct eckd_blockptr_legacy *blockptr = &data->eckd;
struct eckd_blockptr_legacy *blockptr = &data->eckd_legacy;
struct ccw1 *ccws;
unsigned long record_size;
struct seek_arg seek_addr;
+1 -1
View File
@@ -25,7 +25,7 @@ int is_zero_block(void *data) {
return blockptr->blockno;
}
void *load_direct(disk_blockptr_t *data, struct subchannel_id subchannel_id,
void *load_direct(union disk_blockptr *data, struct subchannel_id subchannel_id,
void *load_addr)
{
struct linear_blockptr *blockptr = &data->linear;
+8 -9
View File
@@ -18,7 +18,7 @@
#include "boot/loaders_layout.h"
#include "stage2.h"
static int is_null_descriptor(disk_blockptr_t *address)
static int is_null_descriptor(union disk_blockptr *address)
{
unsigned long long *value = (unsigned long long *)address;
@@ -28,13 +28,12 @@ static int is_null_descriptor(disk_blockptr_t *address)
static void *load_blocklist(struct component_entry *descriptor_address,
struct subchannel_id subchannel_id, void *load_address)
{
disk_blockptr_t *indirect_blocks, *indirect_blockspace,
*start_addr;
union disk_blockptr *indirect_blocks, *indirect_blockspace, *start_addr;
unsigned long length;
long long nr_descr;
/* start address to load first indirect blocks */
start_addr = (disk_blockptr_t *)&descriptor_address->data;
start_addr = (union disk_blockptr *)&descriptor_address->data;
/* get a free page to store indirect blocks in */
indirect_blockspace = (void *)get_zeroed_page();
@@ -90,7 +89,7 @@ void __noreturn start(void)
struct subchannel_id subchannel_id;
void *load_address;
struct component_entry *entry;
disk_blockptr_t *blockptr;
union disk_blockptr *blockptr;
uint64_t load_psw;
void *load_page;
int config_nr;
@@ -106,14 +105,14 @@ void __noreturn start(void)
set_device(subchannel_id, ENABLED);
load_page = (void *)get_zeroed_page();
load_address = (disk_blockptr_t *) load_page;
load_address = (union disk_blockptr *) load_page;
/* load blockpointer list to load address */
load_direct((disk_blockptr_t *)&stage2_descr, subchannel_id,
load_direct((union disk_blockptr *)&stage2_descr, subchannel_id,
load_address);
blockptr = (disk_blockptr_t *)(load_address +
sizeof(disk_blockptr_t));
blockptr = (union disk_blockptr *)(load_address +
sizeof(union disk_blockptr));
load_direct(&blockptr[config_nr], subchannel_id, load_address);
+2 -6
View File
@@ -26,16 +26,12 @@
#include "cio.h"
#include "error.h"
typedef union {
struct eckd_blockptr_legacy eckd;
struct linear_blockptr linear;
} disk_blockptr_t;
struct stage2_descr {
uint8_t reserved[16];
} __packed __aligned(8);
void *load_direct(disk_blockptr_t *, struct subchannel_id , void *);
void *load_direct(union disk_blockptr *data, struct subchannel_id sid,
void *load_addr);
int extract_length(void *);
int is_zero_block(void *);
void kdump_stage2(unsigned long);
+1
View File
@@ -21,6 +21,7 @@
#define BOOTMAP_HEADER_VERSION 1
#define PROGRAM_TABLE_BLOCK_SIZE 512
#define SIGNATURE_MAGIC "~Module signature appended~\n"
#define PKCS7_FORMAT 0x01
+1 -1
View File
@@ -38,7 +38,7 @@ struct disk_blockptr_linear {
int blockct;
};
/* Pointer to a block on disk */
/* This represents in-memory pointer to a block on disk */
typedef union {
struct disk_blockptr_chs chs;
struct disk_blockptr_linear linear;
+21
View File
@@ -35,6 +35,14 @@ enum program_component_id {
NR_PROGRAM_COMPONENTS
};
/* Types of SCSI disk layouts */
enum scsi_layout {
scsi_layout_pcbios,
scsi_layout_sun,
scsi_layout_sgi,
scsi_layout_unknown
};
struct component_loc {
address_t addr;
size_t size;
@@ -76,6 +84,19 @@ struct install_set {
extern struct component_footer component_footers[NR_PROGRAM_COMPONENTS];
/* Determine SCSI disk layout from the specified BOOTBLOCK. */
static inline enum scsi_layout get_scsi_layout(unsigned char *bootblock)
{
if ((bootblock[510] == 0x55) && (bootblock[511] == 0xaa))
return scsi_layout_pcbios;
else if ((bootblock[508] == 0xda) && (bootblock[509] == 0xbe))
return scsi_layout_sun;
else if ((bootblock[0] == 0x0b) && (bootblock[1] == 0xe5) &&
(bootblock[2] == 0xa9) && (bootblock[3] == 0x41))
return scsi_layout_sgi;
return scsi_layout_unknown;
}
static inline component_type component_type_by_id(enum program_component_id id)
{
return component_footers[id].type;
-2
View File
@@ -119,8 +119,6 @@ void bootmap_store_blockptr(void *buffer, disk_blockptr_t *ptr,
}
}
#define PROGRAM_TABLE_BLOCK_SIZE 512
/* Calculate the maximum number of entries in the program table. INFO
* specifies the type of disk. */
static int
-23
View File
@@ -45,32 +45,9 @@ static inline unsigned long blk_cnt(int size, struct disk_info *info)
return (size + info->phy_block_size - 1) / info->phy_block_size;
}
/* Types of SCSI disk layouts */
enum scsi_layout {
scsi_layout_pcbios,
scsi_layout_sun,
scsi_layout_sgi,
scsi_layout_unknown
};
/* From linux/fs.h */
#define BLKFLSBUF _IO(0x12, 97)
/* Determine SCSI disk layout from the specified BOOTBLOCK. */
static enum scsi_layout
get_scsi_layout(unsigned char* bootblock)
{
if ((bootblock[510] == 0x55) && (bootblock[511] == 0xaa))
return scsi_layout_pcbios;
else if ((bootblock[508] == 0xda) && (bootblock[509] == 0xbe))
return scsi_layout_sun;
else if ((bootblock[0] == 0x0b) && (bootblock[1] == 0xe5) &&
(bootblock[2] == 0xa9) && (bootblock[3] == 0x41))
return scsi_layout_sgi;
return scsi_layout_unknown;
}
static int
overwrite_partition_start(int fd, struct disk_info* info, int mv_dump_magic);