mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Initial s390-tools-2.0.0 import
This commit is based on the s390-tools-1.39.0 version. Changes on top of s390-tools-1.39.0: - Add MIT license to all source files - Add LICENSE file - Transform REAMDE to README.md (markdown) - Add AUTHORS.md file - Add CONTRIBUTING.md file - Move changelog from README to CHANGELOG.md file Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/boot.h
|
||||
* Functions to handle the boot loader data.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOOT_H
|
||||
#define BOOT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "disk.h"
|
||||
#include "job.h"
|
||||
#include "zipl.h"
|
||||
|
||||
#define STAGE2_BLK_CNT_MAX 24 /* Stage 1b can load up to 24 blocks */
|
||||
#define STAGE1B_BLK_CNT_MAX 2 /* Stage 1 can load up to 2 blocks */
|
||||
|
||||
/* Boot info */
|
||||
|
||||
#define BOOT_INFO_VERSION 1
|
||||
#define BOOT_INFO_MAGIC "zIPL"
|
||||
|
||||
#define BOOT_INFO_DEV_TYPE_ECKD 0x00
|
||||
#define BOOT_INFO_DEV_TYPE_FBA 0x01
|
||||
#define BOOT_INFO_DEV_TYPE_SCSI 0x02
|
||||
|
||||
#define BOOT_INFO_BP_TYPE_IPL 0x00
|
||||
#define BOOT_INFO_BP_TYPE_DUMP 0x01
|
||||
|
||||
#ifdef __s390x__
|
||||
#define BOOT_INFO_FLAGS_ARCH 0x01
|
||||
#else
|
||||
#define BOOT_INFO_FLAGS_ARCH 0x00
|
||||
#endif
|
||||
|
||||
/* SCSI dump super block */
|
||||
|
||||
struct scsi_dump_sb {
|
||||
uint64_t magic;
|
||||
uint64_t version;
|
||||
uint64_t part_start;
|
||||
uint64_t part_size;
|
||||
uint64_t dump_offset;
|
||||
uint64_t dump_size;
|
||||
uint64_t csum_offset;
|
||||
uint64_t csum_size;
|
||||
uint64_t csum;
|
||||
} __attribute((packed));
|
||||
|
||||
#define SCSI_DUMP_SB_MAGIC 0x5a46435044554d50ULL; /* ZFCPDUMP */
|
||||
/* To avoid a csum entry of 0 a seed is used */
|
||||
#define SCSI_DUMP_SB_SEED 0x12345678
|
||||
#define SCSI_DUMP_SB_CSUM_SIZE 4096
|
||||
|
||||
/* SCSI dump parameter */
|
||||
|
||||
struct scsi_dump_param {
|
||||
uint64_t block;
|
||||
uint64_t reserved;
|
||||
} __attribute((packed));
|
||||
/* ECKD dump parameter */
|
||||
|
||||
struct eckd_dump_param {
|
||||
uint32_t start_blk;
|
||||
uint32_t end_blk;
|
||||
uint16_t blocksize;
|
||||
uint8_t num_heads;
|
||||
uint8_t bpt;
|
||||
char reserved[4];
|
||||
} __attribute((packed, may_alias));
|
||||
|
||||
/* FBA dump parameter */
|
||||
|
||||
struct fba_dump_param {
|
||||
uint64_t start_blk;
|
||||
uint64_t blockct;
|
||||
} __attribute((packed));
|
||||
|
||||
struct boot_info_bp_dump {
|
||||
union {
|
||||
struct eckd_dump_param eckd;
|
||||
struct fba_dump_param fba;
|
||||
struct scsi_dump_param scsi;
|
||||
} param;
|
||||
uint8_t unused[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* Layout of block pointer for linear devices
|
||||
* e.g. SCSI
|
||||
*/
|
||||
/* Layout of SCSI disk block pointer */
|
||||
struct linear_blockptr {
|
||||
uint64_t blockno;
|
||||
uint16_t size;
|
||||
uint16_t blockct;
|
||||
uint8_t reserved[4];
|
||||
} __attribute((packed));
|
||||
|
||||
/*
|
||||
* Layout of block pointer for cylinder/head/sector devices
|
||||
* e.g. SCSI or FBA
|
||||
*/
|
||||
/* Layout of ECKD disk block pointer */
|
||||
struct eckd_blockptr {
|
||||
uint16_t cyl;
|
||||
uint16_t head;
|
||||
uint8_t sec;
|
||||
uint16_t size;
|
||||
uint8_t blockct;
|
||||
uint8_t reserved[8];
|
||||
} __attribute((packed));
|
||||
|
||||
struct boot_info_bp_ipl {
|
||||
union {
|
||||
struct eckd_blockptr eckd;
|
||||
struct linear_blockptr lin;
|
||||
} bm_ptr;
|
||||
uint8_t unused[16];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_info {
|
||||
char magic[4];
|
||||
uint8_t version;
|
||||
uint8_t bp_type;
|
||||
uint8_t dev_type;
|
||||
uint8_t flags;
|
||||
union {
|
||||
struct boot_info_bp_dump dump;
|
||||
struct boot_info_bp_ipl ipl;
|
||||
} bp;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_ccw0 {
|
||||
uint8_t cmd;
|
||||
uint8_t address_hi;
|
||||
uint16_t address_lo;
|
||||
uint8_t flags;
|
||||
uint8_t pad;
|
||||
uint16_t count;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Boot data structures for FBA disks */
|
||||
|
||||
struct boot_fba_locread {
|
||||
struct boot_ccw0 locate;
|
||||
struct boot_ccw0 read;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_fba_locdata {
|
||||
uint8_t command;
|
||||
uint8_t dummy;
|
||||
uint16_t blockct;
|
||||
uint32_t blocknr;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_fba_stage0 {
|
||||
uint64_t psw;
|
||||
uint64_t read_ipl;
|
||||
uint64_t tic1;
|
||||
struct boot_fba_locread locread[2];
|
||||
uint64_t tic1b;
|
||||
struct boot_fba_locdata locdata[2];
|
||||
uint64_t reserved[4];
|
||||
struct boot_info boot_info;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_fba_stage1b {
|
||||
struct boot_fba_locread locread[STAGE2_BLK_CNT_MAX];
|
||||
struct boot_fba_locdata locdata[STAGE2_BLK_CNT_MAX];
|
||||
uint8_t unused[448];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Boot data structures for ECKD disks */
|
||||
|
||||
struct boot_eckd_ccw1 {
|
||||
uint8_t cmd;
|
||||
uint8_t flags;
|
||||
uint16_t count;
|
||||
uint32_t address;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_eckd_ssrt {
|
||||
struct boot_ccw0 seek;
|
||||
struct boot_ccw0 search;
|
||||
struct boot_ccw0 tic;
|
||||
struct boot_ccw0 read;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_eckd_seekarg {
|
||||
uint16_t pad;
|
||||
uint16_t cyl;
|
||||
uint16_t head;
|
||||
uint8_t sec;
|
||||
uint8_t pad2;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_eckd_cdl_stage0 {
|
||||
uint64_t psw;
|
||||
struct boot_ccw0 read;
|
||||
struct boot_ccw0 tic;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_eckd_ldl_stage0 {
|
||||
uint64_t psw;
|
||||
struct boot_ccw0 read_r0;
|
||||
struct boot_ccw0 read_r1;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_eckd_stage1 {
|
||||
struct boot_eckd_ssrt ssrt[2];
|
||||
struct boot_ccw0 tic1b;
|
||||
struct boot_eckd_seekarg seek[2];
|
||||
struct boot_info boot_info;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct boot_eckd_stage1b {
|
||||
struct boot_eckd_ssrt ssrt[STAGE2_BLK_CNT_MAX];
|
||||
struct boot_eckd_seekarg seek[STAGE2_BLK_CNT_MAX];
|
||||
uint8_t unused[64];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Stage 2 boot menu parameter structure */
|
||||
|
||||
#define BOOT_MENU_ENTRIES 62
|
||||
|
||||
struct boot_stage2_params {
|
||||
uint16_t flag;
|
||||
uint16_t timeout;
|
||||
uint16_t banner;
|
||||
uint16_t config[BOOT_MENU_ENTRIES + 1];
|
||||
uint64_t config_kdump;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/* Stage 3 bootloader parameter structure */
|
||||
|
||||
struct boot_stage3_params {
|
||||
uint64_t parm_addr;
|
||||
uint64_t initrd_addr;
|
||||
uint64_t initrd_len;
|
||||
uint64_t load_psw;
|
||||
uint64_t extra_parm;
|
||||
uint16_t flags;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define STAGE3_FLAG_SCSI 0x0001
|
||||
#define STAGE3_FLAG_KDUMP 0x0002
|
||||
|
||||
/* Tape IPL bootloader parameter structure */
|
||||
|
||||
#define BOOT_TAPE_IPL_PARAMS_OFFSET 0x200
|
||||
|
||||
struct boot_tape_ipl_params {
|
||||
uint64_t parm_addr;
|
||||
uint64_t initrd_addr;
|
||||
uint64_t load_psw;
|
||||
};
|
||||
|
||||
/* Partition parameter table for multi-volume dump */
|
||||
|
||||
struct mvdump_param {
|
||||
uint16_t devno;
|
||||
uint32_t start_blk;
|
||||
uint32_t end_blk;
|
||||
uint8_t blocksize;
|
||||
uint8_t bpt;
|
||||
uint8_t num_heads;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct mvdump_parm_table {
|
||||
uint64_t timestamp;
|
||||
uint16_t num_param;
|
||||
struct mvdump_param param[MAX_DUMP_VOLUMES];
|
||||
uint8_t ssid[MAX_DUMP_VOLUMES];
|
||||
unsigned char reserved[512 - sizeof(uint64_t) - sizeof(uint16_t) -
|
||||
(MAX_DUMP_VOLUMES * (sizeof(struct mvdump_param) + 1))];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
void boot_get_dump_info(struct boot_info *boot_info, uint8_t dev_type,
|
||||
void *param);
|
||||
void boot_get_ipl_info(struct boot_info *boot_info, uint8_t dev_type,
|
||||
disk_blockptr_t *bm_ptr, struct disk_info *info);
|
||||
|
||||
int boot_check_data(void);
|
||||
int boot_init_fba_stage0(struct boot_fba_stage0* stage0,
|
||||
disk_blockptr_t* stage2_list,
|
||||
blocknum_t stage2_count);
|
||||
int boot_get_fba_stage2(void** data, size_t* size, struct job_data* job);
|
||||
void boot_init_eckd_ldl_stage0(struct boot_eckd_ldl_stage0 *stage0);
|
||||
void boot_init_eckd_cdl_stage0(struct boot_eckd_cdl_stage0 *stage0);
|
||||
int boot_init_eckd_stage1(struct boot_eckd_stage1 *stage1,
|
||||
disk_blockptr_t *stage1b_list,
|
||||
blocknum_t stage1b_count);
|
||||
int boot_init_eckd_stage1b(struct boot_eckd_stage1b *stage1b,
|
||||
disk_blockptr_t *stage2_list,
|
||||
blocknum_t stage2_count);
|
||||
int boot_init_fba_stage1b(struct boot_fba_stage1b *stage1b,
|
||||
disk_blockptr_t *stage2_list,
|
||||
blocknum_t stage2_count);
|
||||
int boot_get_eckd_stage2(void** data, size_t* size, struct job_data* job);
|
||||
size_t get_stage3_size();
|
||||
int boot_get_stage3(void** buffer, size_t* bytecount, address_t parm_addr,
|
||||
address_t initrd_addr, size_t initrd_len,
|
||||
address_t image_addr, int extra_parm, uint16_t flags);
|
||||
int boot_get_tape_ipl(void** data, size_t* size, address_t parm_addr,
|
||||
address_t initrd_addr, address_t image_addr);
|
||||
int boot_get_tape_dump(void** data, size_t* size, uint64_t mem);
|
||||
int boot_get_eckd_dump_stage2(void** data, size_t* size, uint64_t mem);
|
||||
int boot_get_eckd_mvdump_stage2(void** data, size_t* size, uint64_t mem,
|
||||
uint8_t force, struct mvdump_parm_table);
|
||||
int boot_get_fba_dump_stage2(void** data, size_t* size, uint64_t mem);
|
||||
|
||||
#endif /* BOOT_H */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/bootmap.h
|
||||
* Functions to build the bootmap file.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOOTMAP_H
|
||||
#define BOOTMAP_H
|
||||
|
||||
#include "disk.h"
|
||||
#include "job.h"
|
||||
#include "zipl.h"
|
||||
|
||||
|
||||
int bootmap_create(struct job_data* job, disk_blockptr_t* program_table,
|
||||
disk_blockptr_t *scsi_dump_sb_blockptr,
|
||||
disk_blockptr_t** stage2_list, blocknum_t* stage2_count,
|
||||
char** device, struct disk_info** new_info);
|
||||
void bootmap_store_blockptr(void* buffer, disk_blockptr_t* ptr,
|
||||
struct disk_info* info);
|
||||
|
||||
#endif /* if not BOOTMAP_H */
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/disk.h
|
||||
* Functions to handle disk layout specific operations.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DISK_H
|
||||
#define DISK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "zipl.h"
|
||||
|
||||
|
||||
/* Type for representing disk block numbers */
|
||||
typedef uint64_t blocknum_t;
|
||||
|
||||
/* Pointer to block on a disk with cyl/head/sec layout */
|
||||
struct disk_blockptr_chs {
|
||||
int cyl;
|
||||
int head;
|
||||
int sec;
|
||||
int size;
|
||||
int blockct;
|
||||
};
|
||||
|
||||
/* Pointer to a block on a disk with linear layout */
|
||||
struct disk_blockptr_linear {
|
||||
blocknum_t block;
|
||||
int size;
|
||||
int blockct;
|
||||
};
|
||||
|
||||
/* Pointer to a block on disk */
|
||||
typedef union {
|
||||
struct disk_blockptr_chs chs;
|
||||
struct disk_blockptr_linear linear;
|
||||
} disk_blockptr_t;
|
||||
|
||||
/* Disk type identifier */
|
||||
typedef enum {
|
||||
disk_type_scsi,
|
||||
disk_type_fba,
|
||||
disk_type_diag,
|
||||
disk_type_eckd_ldl,
|
||||
disk_type_eckd_cdl,
|
||||
} disk_type_t;
|
||||
|
||||
/* from linux/hdregs.h */
|
||||
struct hd_geometry {
|
||||
unsigned char heads;
|
||||
unsigned char sectors;
|
||||
unsigned short cylinders;
|
||||
unsigned long start;
|
||||
};
|
||||
|
||||
/* Disk information source */
|
||||
typedef enum {
|
||||
source_auto,
|
||||
source_user,
|
||||
source_script
|
||||
} source_t;
|
||||
|
||||
/* targetbase definition */
|
||||
typedef enum {
|
||||
defined_as_device,
|
||||
defined_as_name
|
||||
} definition_t;
|
||||
|
||||
/* Disk information type */
|
||||
struct disk_info {
|
||||
disk_type_t type;
|
||||
dev_t device;
|
||||
dev_t partition;
|
||||
int devno;
|
||||
int partnum;
|
||||
int phy_block_size;
|
||||
int fs_block_size;
|
||||
uint64_t phy_blocks;
|
||||
struct hd_geometry geo;
|
||||
char* name;
|
||||
char* drv_name;
|
||||
source_t source;
|
||||
definition_t targetbase;
|
||||
};
|
||||
|
||||
struct job_target_data;
|
||||
|
||||
int disk_get_info(const char* device, struct job_target_data* target,
|
||||
struct disk_info** info);
|
||||
int disk_is_tape(const char* device);
|
||||
int disk_is_scsi(const char* device, struct job_target_data* target);
|
||||
int disk_get_info_from_file(const char* filename,
|
||||
struct job_target_data* target,
|
||||
struct disk_info** info);
|
||||
void disk_free_info(struct disk_info* info);
|
||||
char* disk_get_type_name(disk_type_t type);
|
||||
int disk_is_large_volume(struct disk_info* info);
|
||||
int disk_cyl_from_blocknum(blocknum_t blocknum, struct disk_info* info);
|
||||
int disk_head_from_blocknum(blocknum_t blocknum, struct disk_info* info);
|
||||
int disk_sec_from_blocknum(blocknum_t blocknum, struct disk_info* info);
|
||||
void disk_blockptr_from_blocknum(disk_blockptr_t* ptr, blocknum_t blocknum,
|
||||
struct disk_info* info);
|
||||
int disk_write_block_aligned(int fd, const void* data, size_t bytecount,
|
||||
disk_blockptr_t* block, struct disk_info* info);
|
||||
blocknum_t disk_write_block_buffer(int fd, int fd_is_basedisk,
|
||||
const void* buffer, size_t bytecount,
|
||||
disk_blockptr_t** blocklist,
|
||||
struct disk_info* info);
|
||||
void disk_print_devt(dev_t d);
|
||||
void disk_print_info(struct disk_info* info);
|
||||
int disk_is_zero_block(disk_blockptr_t* block, struct disk_info* info);
|
||||
blocknum_t disk_compact_blocklist(disk_blockptr_t* list, blocknum_t count,
|
||||
struct disk_info* info);
|
||||
blocknum_t disk_get_blocklist_from_file(const char* filename,
|
||||
disk_blockptr_t** blocklist,
|
||||
struct disk_info* pinfo);
|
||||
int disk_check_subchannel_set(int devno, dev_t device, char* dev_name);
|
||||
void disk_print_geo(struct disk_info *data);
|
||||
|
||||
#endif /* not DISK_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/error.h
|
||||
* Functions to handle error messages.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
#include "zipl.h"
|
||||
|
||||
|
||||
void error_reason(const char* fmt, ...);
|
||||
void error_text(const char* fmt, ...);
|
||||
void error_clear_reason(void);
|
||||
void error_clear_text(void);
|
||||
void error_print(void);
|
||||
|
||||
#endif /* not ERROR_H */
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/install.h
|
||||
* Functions handling the installation of the boot loader code onto disk.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INSTALL_H
|
||||
#define INSTALL_H
|
||||
|
||||
#include "disk.h"
|
||||
#include "job.h"
|
||||
#include "zipl.h"
|
||||
|
||||
|
||||
int install_bootloader(const char* device, disk_blockptr_t* program_table,
|
||||
disk_blockptr_t* scsi_dump_sb_blockptr,
|
||||
disk_blockptr_t* stage2_data, blocknum_t stage2_count,
|
||||
struct disk_info* info, struct job_data* job);
|
||||
int install_tapeloader(const char* device, const char* image,
|
||||
const char* parmline, const char* ramdisk,
|
||||
address_t image_addr, address_t parm_addr,
|
||||
address_t initrd_addr);
|
||||
int install_dump(const char* device, struct job_target_data* target,
|
||||
uint64_t mem);
|
||||
int install_mvdump(char* const device[], struct job_target_data* target,
|
||||
int device_count, uint64_t mem, uint8_t force);
|
||||
|
||||
int install_fba_stage1b(int fd, disk_blockptr_t **stage1b_list,
|
||||
blocknum_t *stage1b_count, disk_blockptr_t *stage2_list,
|
||||
blocknum_t stage2_count, struct disk_info *info);
|
||||
int install_eckd_stage1b(int fd, disk_blockptr_t **stage1b_list,
|
||||
blocknum_t *stage1b_count,
|
||||
disk_blockptr_t *stage2_list,
|
||||
blocknum_t stage2_count, struct disk_info *info);
|
||||
int rewind_tape(int fd);
|
||||
|
||||
#endif /* INSTALL_H */
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/job.h
|
||||
* Functions and data structures representing the actual 'job' that the
|
||||
* user wants us to execute.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef JOB_H
|
||||
#define JOB_H
|
||||
|
||||
#include "disk.h"
|
||||
#include "zipl.h"
|
||||
|
||||
|
||||
enum job_id {
|
||||
job_print_usage = 1,
|
||||
job_print_version = 2,
|
||||
job_ipl = 3,
|
||||
job_segment = 4,
|
||||
job_dump_partition = 5,
|
||||
job_menu = 6,
|
||||
job_ipl_tape = 7,
|
||||
job_mvdump = 8,
|
||||
};
|
||||
|
||||
struct job_target_data {
|
||||
char* bootmap_dir;
|
||||
char* targetbase;
|
||||
disk_type_t targettype;
|
||||
int targetcylinders;
|
||||
int targetheads;
|
||||
int targetsectors;
|
||||
int targetblocksize;
|
||||
blocknum_t targetoffset;
|
||||
};
|
||||
|
||||
struct job_ipl_data {
|
||||
char* image;
|
||||
char* parmline;
|
||||
char* ramdisk;
|
||||
address_t image_addr;
|
||||
address_t parm_addr;
|
||||
address_t ramdisk_addr;
|
||||
int is_kdump;
|
||||
};
|
||||
|
||||
struct job_segment_data {
|
||||
char* segment;
|
||||
address_t segment_addr;
|
||||
};
|
||||
|
||||
struct job_dump_data {
|
||||
char* device;
|
||||
char* image;
|
||||
char* parmline;
|
||||
char* ramdisk;
|
||||
address_t image_addr;
|
||||
address_t parm_addr;
|
||||
address_t ramdisk_addr;
|
||||
uint64_t mem;
|
||||
};
|
||||
|
||||
struct job_mvdump_data {
|
||||
char* device_list;
|
||||
int device_count;
|
||||
char* device[MAX_DUMP_VOLUMES];
|
||||
uint64_t mem;
|
||||
uint8_t force;
|
||||
};
|
||||
|
||||
struct job_ipl_tape_data {
|
||||
char* device;
|
||||
char* image;
|
||||
char* parmline;
|
||||
char* ramdisk;
|
||||
address_t image_addr;
|
||||
address_t parm_addr;
|
||||
address_t ramdisk_addr;
|
||||
};
|
||||
|
||||
|
||||
union job_menu_entry_data {
|
||||
struct job_ipl_data ipl;
|
||||
struct job_dump_data dump;
|
||||
};
|
||||
|
||||
struct job_menu_entry {
|
||||
int pos;
|
||||
char* name;
|
||||
enum job_id id;
|
||||
union job_menu_entry_data data;
|
||||
};
|
||||
|
||||
struct job_menu_data {
|
||||
int num;
|
||||
int default_pos;
|
||||
int prompt;
|
||||
int timeout;
|
||||
struct job_menu_entry* entry;
|
||||
};
|
||||
|
||||
struct job_data {
|
||||
enum job_id id;
|
||||
struct job_target_data target;
|
||||
char* name;
|
||||
union {
|
||||
struct job_ipl_data ipl;
|
||||
struct job_menu_data menu;
|
||||
struct job_segment_data segment;
|
||||
struct job_dump_data dump;
|
||||
struct job_ipl_tape_data ipl_tape;
|
||||
struct job_mvdump_data mvdump;
|
||||
} data;
|
||||
int noninteractive;
|
||||
int verbose;
|
||||
int add_files;
|
||||
int dry_run;
|
||||
int command_line;
|
||||
};
|
||||
|
||||
|
||||
int job_get(int argc, char* argv[], struct job_data** data);
|
||||
void job_free(struct job_data* job);
|
||||
int type_from_target(char *target, disk_type_t *type);
|
||||
int check_job_dump_images(struct job_dump_data* dump, char* name);
|
||||
|
||||
#endif /* not JOB_H */
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/misc.h
|
||||
* Miscellaneous helper functions.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zipl.h"
|
||||
|
||||
|
||||
struct misc_file_buffer {
|
||||
char* buffer;
|
||||
off_t pos;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
|
||||
void* misc_malloc(size_t size);
|
||||
int misc_asprintf(char **out, const char *fmt, ...);
|
||||
void* misc_calloc(size_t n, size_t size);
|
||||
char* misc_strdup(const char* s);
|
||||
int misc_open_exclusive(const char* filename);
|
||||
int misc_read(int fd, void* buffer, size_t count);
|
||||
int misc_read_file(const char* filename, char** buffer, size_t* size,
|
||||
int nil_terminate);
|
||||
int misc_read_special_file(const char* filename, char** buffer, size_t* size,
|
||||
int nil_terminate);
|
||||
int misc_write(int fd, const void* data, size_t count);
|
||||
int misc_pwrite(int fd, void *buf, size_t size, off_t off);
|
||||
int misc_seek(int fd, off_t off);
|
||||
int misc_get_file_buffer(const char* filename,
|
||||
struct misc_file_buffer* buffer);
|
||||
void misc_free_file_buffer(struct misc_file_buffer* file);
|
||||
int misc_get_char(struct misc_file_buffer* file, off_t readahead);
|
||||
char* misc_make_path(char* dirname, char* filename);
|
||||
int misc_temp_dev(dev_t dev, int blockdev, char** devno);
|
||||
int misc_temp_dev_from_file(char* file, char** devno);
|
||||
void misc_free_temp_dev(char* device);
|
||||
int misc_check_writable_directory(const char* directory);
|
||||
int misc_check_readable_file(const char* filename);
|
||||
int misc_check_writable_device(const char* devno, int blockdev, int chardev);
|
||||
void misc_ebcdic_to_ascii(unsigned char *from, unsigned char *to);
|
||||
void misc_ascii_to_ebcdic(unsigned char *from, unsigned char *to);
|
||||
|
||||
#define ROUNDUP(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
|
||||
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||
#endif /* not MISC_H */
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/scan.h
|
||||
* Scanner for zipl.conf configuration files
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SCAN_H
|
||||
#define SCAN_H
|
||||
|
||||
#include "zipl.h"
|
||||
|
||||
|
||||
#define SCAN_SECTION_NUM 9
|
||||
#define SCAN_KEYWORD_NUM 21
|
||||
#define SCAN_KEYWORD_ONLY_NUM 1
|
||||
#define SCAN_AUTOMENU_NAME "zipl-automatic-menu"
|
||||
|
||||
enum scan_id {
|
||||
scan_id_empty = 0,
|
||||
scan_id_section_heading = 1,
|
||||
scan_id_menu_heading = 2,
|
||||
scan_id_keyword_assignment = 3,
|
||||
scan_id_number_assignment = 4,
|
||||
scan_id_keyword_only = 5,
|
||||
};
|
||||
|
||||
enum scan_keyword_id {
|
||||
scan_keyword_default = 0,
|
||||
scan_keyword_dumpto = 1,
|
||||
scan_keyword_dumptofs = 2,
|
||||
scan_keyword_image = 3,
|
||||
scan_keyword_parameters = 4,
|
||||
scan_keyword_parmfile = 5,
|
||||
scan_keyword_ramdisk = 6,
|
||||
scan_keyword_segment = 7,
|
||||
scan_keyword_target = 8,
|
||||
scan_keyword_prompt = 9,
|
||||
scan_keyword_timeout = 10,
|
||||
scan_keyword_defaultmenu = 11,
|
||||
scan_keyword_tape = 12,
|
||||
scan_keyword_mvdump = 13,
|
||||
scan_keyword_targetbase = 14,
|
||||
scan_keyword_targettype = 15,
|
||||
scan_keyword_targetgeometry = 16,
|
||||
scan_keyword_targetblocksize = 17,
|
||||
scan_keyword_targetoffset = 18,
|
||||
scan_keyword_defaultauto = 19,
|
||||
scan_keyword_kdump = 20,
|
||||
};
|
||||
|
||||
enum scan_section_type {
|
||||
section_invalid = -1,
|
||||
section_default_auto = 0,
|
||||
section_default_menu = 1,
|
||||
section_default_section = 2,
|
||||
section_ipl = 3,
|
||||
section_segment = 4,
|
||||
section_dump = 5,
|
||||
section_dumpfs = 6,
|
||||
section_ipl_tape = 7,
|
||||
section_mvdump = 8,
|
||||
};
|
||||
|
||||
enum scan_target_type {
|
||||
target_type_invalid = -1,
|
||||
target_type_scsi = 0,
|
||||
target_type_fba = 1,
|
||||
target_type_ldl = 2,
|
||||
target_type_cdl = 3,
|
||||
};
|
||||
|
||||
enum scan_key_state {
|
||||
req, /* Keyword is required */
|
||||
opt, /* Keyword is optional */
|
||||
inv /* Keyword is invalid */
|
||||
};
|
||||
|
||||
struct scan_section_heading {
|
||||
char* name;
|
||||
};
|
||||
|
||||
struct scan_menu_heading {
|
||||
char* name;
|
||||
};
|
||||
|
||||
struct scan_keyword_assignment {
|
||||
enum scan_keyword_id keyword;
|
||||
char* value;
|
||||
};
|
||||
|
||||
struct scan_number_assignment {
|
||||
int number;
|
||||
char* value;
|
||||
};
|
||||
|
||||
struct scan_keyword_only {
|
||||
enum scan_keyword_id keyword;
|
||||
};
|
||||
|
||||
struct scan_token {
|
||||
enum scan_id id;
|
||||
int line;
|
||||
union {
|
||||
struct scan_section_heading section;
|
||||
struct scan_menu_heading menu;
|
||||
struct scan_keyword_assignment keyword;
|
||||
struct scan_number_assignment number;
|
||||
struct scan_keyword_only keyword_only;
|
||||
} content;
|
||||
};
|
||||
|
||||
/* Determines which keyword may be present in which section */
|
||||
extern enum scan_key_state scan_key_table[SCAN_SECTION_NUM][SCAN_KEYWORD_NUM];
|
||||
|
||||
|
||||
int scan_file(const char* filename, struct scan_token** array);
|
||||
void scan_free(struct scan_token* array);
|
||||
char* scan_keyword_name(enum scan_keyword_id id);
|
||||
int scan_check_defaultboot(struct scan_token* scan);
|
||||
struct scan_token* scan_build_automenu(struct scan_token* scan);
|
||||
int scan_check(struct scan_token* scan);
|
||||
int scan_find_section(struct scan_token* scan, char* name, enum scan_id type,
|
||||
int offset);
|
||||
int scan_check_section_data(char* keyword[], int* line, char* name,
|
||||
int section_line, enum scan_section_type* type);
|
||||
int scan_check_target_data(char* keyword[], int* line);
|
||||
enum scan_section_type scan_get_section_type(char* keyword[]);
|
||||
enum scan_target_type scan_get_target_type(char *type);
|
||||
|
||||
#endif /* not SCAN_H */
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/zipl.h
|
||||
* zSeries Initial Program Loader tool.
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ZIPL_H
|
||||
#define ZIPL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#define ZIPL_MAGIC "zIPL"
|
||||
#define ZIPL_MAGIC_SIZE 4
|
||||
#define DISK_LAYOUT_ID 0x00000001
|
||||
|
||||
#define ZIPL_STAGE2_LOAD_ADDRESS 0x2000
|
||||
#define ZIPL_STAGE3_ENTRY_ADDRESS 0xa050LL
|
||||
#define DEFAULT_IMAGE_ADDRESS 0x10000LL
|
||||
#define KDUMP_IMAGE_ADDRESS 0x10010LL
|
||||
#define DEFAULT_STAGE3_ADDRESS 0xa000LL
|
||||
#define MINIMUM_ADDRESS 0x10000LL
|
||||
#define ADDRESS_LIMIT 0x80000000LL
|
||||
#define ADDRESS_LIMIT_KDUMP 0x2000000UL /* HSA size: 32 MiB */
|
||||
#define UNSPECIFIED_ADDRESS -1ULL
|
||||
#define MAXIMUM_PARMLINE_SIZE 0x380
|
||||
#define MAXIMUM_PHYSICAL_BLOCKSIZE 0x1000
|
||||
|
||||
#define PSW_ADDRESS_MASK 0x000000007fffffffLL
|
||||
#define PSW_LOAD 0x0008000080000000LL
|
||||
#define PSW_DISABLED_WAIT 0x000a000000000000LL
|
||||
|
||||
#define KERNEL_HEADER_SIZE 65536
|
||||
#define BOOTMAP_FILENAME "bootmap"
|
||||
#define BOOTMAP_TEMPLATE_FILENAME "bootmap_temp.XXXXXX"
|
||||
|
||||
#define DEFAULTBOOT_SECTION "defaultboot"
|
||||
|
||||
#define ZIPL_CONF_VAR "ZIPLCONF"
|
||||
#define ZIPL_DEFAULT_CONF "/etc/zipl.conf"
|
||||
|
||||
#define MENU_DEFAULT_PROMPT 0
|
||||
#define MENU_DEFAULT_TIMEOUT 0
|
||||
|
||||
#define FSDUMP_IMAGE STRINGIFY(ZFCPDUMP_DIR) "/" STRINGIFY(ZFCPDUMP_FS_IMAGE)
|
||||
#define FSDUMP_RAMDISK STRINGIFY(ZFCPDUMP_DIR) "/" STRINGIFY(ZFCPDUMP_FS_RD)
|
||||
#define FSDUMP_PART_IMAGE STRINGIFY(ZFCPDUMP_DIR) "/" \
|
||||
STRINGIFY(ZFCPDUMP_PART_IMAGE)
|
||||
#define FSDUMP_PART_RAMDISK STRINGIFY(ZFCPDUMP_DIR) "/" \
|
||||
STRINGIFY(ZFCPDUMP_PART_RD)
|
||||
|
||||
#define MAX_DUMP_VOLUMES 32
|
||||
|
||||
/* Internal component load address type */
|
||||
typedef uint64_t address_t;
|
||||
|
||||
/* Type for address calculations */
|
||||
#define VOID_ADD(ptr, offset) ((void *) (((unsigned long) ptr) + \
|
||||
((unsigned long) offset)))
|
||||
|
||||
/* Call a function depending on the value of dry_run and return either the
|
||||
* resulting return code or 0. */
|
||||
#define DRY_RUN_FUNC(x) (dry_run ? 0 : (x))
|
||||
|
||||
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
|
||||
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
extern int verbose;
|
||||
extern int interactive;
|
||||
extern int dry_run;
|
||||
|
||||
#endif /* not ZIPL_H */
|
||||
Reference in New Issue
Block a user