2013-04-22 23:01:49 +04:00
|
|
|
/*
|
|
|
|
* S390 CCW boot loader
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 Alexander Graf <agraf@suse.de>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef S390_CCW_H
|
|
|
|
#define S390_CCW_H
|
|
|
|
|
|
|
|
/* #define DEBUG */
|
|
|
|
|
2024-10-20 04:29:36 +03:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-04-22 23:01:49 +04:00
|
|
|
typedef unsigned char u8;
|
|
|
|
typedef unsigned short u16;
|
|
|
|
typedef unsigned int u32;
|
|
|
|
typedef unsigned long long u64;
|
|
|
|
|
|
|
|
#define true 1
|
|
|
|
#define false 0
|
|
|
|
#define PAGE_SIZE 4096
|
|
|
|
|
2014-05-19 22:05:40 +04:00
|
|
|
#define EIO 1
|
|
|
|
#define EBUSY 2
|
2020-08-05 18:41:08 +03:00
|
|
|
#define ENODEV 3
|
|
|
|
|
2017-05-10 18:53:54 +03:00
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
#ifndef MIN_NON_ZERO
|
|
|
|
#define MIN_NON_ZERO(a, b) ((a) == 0 ? (b) : \
|
|
|
|
((b) == 0 ? (a) : (MIN(a, b))))
|
|
|
|
#endif
|
2013-04-22 23:01:49 +04:00
|
|
|
|
2017-07-12 15:49:49 +03:00
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
|
|
|
|
2013-04-22 23:01:49 +04:00
|
|
|
#include "cio.h"
|
2015-07-31 17:04:51 +03:00
|
|
|
#include "iplb.h"
|
2013-04-22 23:01:49 +04:00
|
|
|
|
2013-04-23 05:23:02 +04:00
|
|
|
/* start.s */
|
2020-06-24 10:52:22 +03:00
|
|
|
void disabled_wait(void) __attribute__ ((__noreturn__));
|
2015-06-19 16:40:45 +03:00
|
|
|
void consume_sclp_int(void);
|
2019-04-04 17:34:27 +03:00
|
|
|
void consume_io_int(void);
|
2013-04-23 05:23:02 +04:00
|
|
|
|
2013-04-22 23:01:49 +04:00
|
|
|
/* main.c */
|
2014-07-01 14:17:41 +04:00
|
|
|
void write_subsystem_identification(void);
|
2020-03-04 14:42:31 +03:00
|
|
|
void write_iplb_location(void);
|
2017-01-16 18:45:49 +03:00
|
|
|
unsigned int get_loadparm_index(void);
|
2022-07-04 14:18:52 +03:00
|
|
|
void main(void);
|
2013-04-22 23:01:49 +04:00
|
|
|
|
2016-11-30 22:22:07 +03:00
|
|
|
/* sclp.c */
|
2013-04-22 23:01:49 +04:00
|
|
|
void sclp_print(const char *string);
|
2018-02-23 18:43:17 +03:00
|
|
|
void sclp_set_write_mask(uint32_t receive_mask, uint32_t send_mask);
|
2013-04-22 23:01:49 +04:00
|
|
|
void sclp_setup(void);
|
2016-11-30 22:22:07 +03:00
|
|
|
void sclp_get_loadparm_ascii(char *loadparm);
|
2018-02-23 18:43:16 +03:00
|
|
|
int sclp_read(char *str, size_t count);
|
2013-04-22 23:01:49 +04:00
|
|
|
|
|
|
|
/* virtio.c */
|
2023-05-10 17:39:25 +03:00
|
|
|
unsigned long virtio_load_direct(unsigned long rec_list1, unsigned long rec_list2,
|
|
|
|
unsigned long subchan_id, void *load_addr);
|
2015-10-26 18:55:16 +03:00
|
|
|
bool virtio_is_supported(SubChannelId schid);
|
2020-07-28 15:30:14 +03:00
|
|
|
int virtio_blk_setup_device(SubChannelId schid);
|
2023-05-10 17:39:25 +03:00
|
|
|
int virtio_read(unsigned long sector, void *load_addr);
|
2013-04-22 23:01:49 +04:00
|
|
|
|
|
|
|
/* bootmap.c */
|
2014-05-19 22:11:07 +04:00
|
|
|
void zipl_load(void);
|
2013-04-22 23:01:49 +04:00
|
|
|
|
2018-04-20 12:30:42 +03:00
|
|
|
/* jump2ipl.c */
|
2020-10-06 12:42:48 +03:00
|
|
|
void write_reset_psw(uint64_t psw);
|
2018-04-20 12:30:42 +03:00
|
|
|
void jump_to_IPL_code(uint64_t address);
|
|
|
|
void jump_to_low_kernel(void);
|
|
|
|
|
2018-02-23 18:43:13 +03:00
|
|
|
/* menu.c */
|
|
|
|
void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout);
|
2018-02-23 18:43:14 +03:00
|
|
|
int menu_get_zipl_boot_index(const char *menu_data);
|
|
|
|
bool menu_is_enabled_zipl(void);
|
2018-04-16 19:56:10 +03:00
|
|
|
int menu_get_enum_boot_index(bool *valid_entries);
|
2018-02-23 18:43:19 +03:00
|
|
|
bool menu_is_enabled_enum(void);
|
2018-02-23 18:43:13 +03:00
|
|
|
|
2018-04-16 19:56:07 +03:00
|
|
|
#define MAX_BOOT_ENTRIES 31
|
|
|
|
|
2021-05-02 14:49:20 +03:00
|
|
|
__attribute__ ((__noreturn__))
|
2020-06-24 10:52:22 +03:00
|
|
|
static inline void panic(const char *string)
|
|
|
|
{
|
2024-10-20 04:29:36 +03:00
|
|
|
printf("ERROR: %s\n ", string);
|
2020-06-24 10:52:22 +03:00
|
|
|
disabled_wait();
|
|
|
|
}
|
|
|
|
|
2013-04-22 23:01:49 +04:00
|
|
|
static inline void fill_hex(char *out, unsigned char val)
|
|
|
|
{
|
|
|
|
const char hex[] = "0123456789abcdef";
|
|
|
|
|
|
|
|
out[0] = hex[(val >> 4) & 0xf];
|
|
|
|
out[1] = hex[val & 0xf];
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:11:55 +04:00
|
|
|
static inline void fill_hex_val(char *out, void *ptr, unsigned size)
|
2013-04-22 23:01:49 +04:00
|
|
|
{
|
2014-05-19 22:11:55 +04:00
|
|
|
unsigned char *value = ptr;
|
2013-04-22 23:01:49 +04:00
|
|
|
unsigned int i;
|
|
|
|
|
2014-05-19 22:11:55 +04:00
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
fill_hex(&out[i*2], value[i]);
|
2013-04-22 23:01:49 +04:00
|
|
|
}
|
2014-05-19 22:11:55 +04:00
|
|
|
}
|
|
|
|
|
2013-04-22 23:01:49 +04:00
|
|
|
static inline void debug_print_int(const char *desc, u64 addr)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2024-10-20 04:29:36 +03:00
|
|
|
printf("%s 0x%X\n", desc, addr);
|
2013-04-22 23:01:49 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void debug_print_addr(const char *desc, void *p)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
debug_print_int(desc, (unsigned int)(unsigned long)p);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************
|
|
|
|
* Hypercall functions *
|
|
|
|
***********************************************/
|
|
|
|
|
2014-05-19 22:05:40 +04:00
|
|
|
#define KVM_S390_VIRTIO_NOTIFY 0
|
|
|
|
#define KVM_S390_VIRTIO_RESET 1
|
|
|
|
#define KVM_S390_VIRTIO_SET_STATUS 2
|
2013-04-22 23:01:49 +04:00
|
|
|
#define KVM_S390_VIRTIO_CCW_NOTIFY 3
|
|
|
|
|
2014-05-19 22:10:27 +04:00
|
|
|
#define MAX_SECTOR_SIZE 4096
|
2013-04-22 23:01:49 +04:00
|
|
|
|
2015-10-27 11:49:27 +03:00
|
|
|
static inline void IPL_assert(bool term, const char *message)
|
|
|
|
{
|
|
|
|
if (!term) {
|
2024-10-20 04:29:36 +03:00
|
|
|
panic(message); /* no return */
|
2015-10-27 11:49:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void IPL_check(bool term, const char *message)
|
|
|
|
{
|
|
|
|
if (!term) {
|
2024-10-20 04:29:36 +03:00
|
|
|
printf("WARNING: %s\n", message);
|
2015-10-27 11:49:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-18 14:45:10 +03:00
|
|
|
extern const unsigned char ebc2asc[256];
|
|
|
|
static inline void ebcdic_to_ascii(const char *src,
|
|
|
|
char *dst,
|
|
|
|
unsigned int size)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
unsigned c = src[i];
|
|
|
|
dst[i] = ebc2asc[c];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-22 23:01:49 +04:00
|
|
|
#endif /* S390_CCW_H */
|