2 * QEMU s390-ccw firmware - jump to IPL code
4 * This work is licensed under the terms of the GNU GPL, version 2 or (at
5 * your option) any later version. See the COPYING file in the top-level
11 #include "s390-arch.h"
13 #define KERN_IMAGE_START 0x010000UL
14 #define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_64)
16 static uint64_t *reset_psw = 0, save_psw, ipl_continue;
18 static void jump_to_IPL_addr(void)
20 __attribute__((noreturn)) void (*ipl)(void) = (void *)ipl_continue;
22 /* Restore reset PSW */
23 *reset_psw = save_psw;
26 /* should not return */
29 void jump_to_IPL_code(uint64_t address)
31 /* store the subsystem information _after_ the bootmap was loaded */
32 write_subsystem_identification();
33 write_iplb_location();
35 /* prevent unknown IPL types in the guest */
36 if (iplb.pbt == S390_IPL_TYPE_QEMU_SCSI) {
37 iplb.pbt = S390_IPL_TYPE_CCW;
42 * The IPL PSW is at address 0. We also must not overwrite the
43 * content of non-BIOS memory after we loaded the guest, so we
44 * save the original content and restore it in jump_to_IPL_2.
46 save_psw = *reset_psw;
47 *reset_psw = (uint64_t) &jump_to_IPL_addr;
48 *reset_psw |= RESET_PSW_MASK;
49 ipl_continue = address;
50 debug_print_int("set IPL addr to", ipl_continue);
52 /* Ensure the guest output starts fresh */
57 * We use the load normal reset to keep r15 unchanged. jump_to_IPL_2
58 * can then use r15 as its stack pointer.
60 asm volatile("lghi 1,1\n\t"
63 panic("\n! IPL returns !\n");
66 void jump_to_low_kernel(void)
69 * If it looks like a Linux binary, i.e. there is the "S390EP" magic from
70 * arch/s390/kernel/head.S here, then let's jump to the well-known Linux
71 * kernel start address (when jumping to the PSW-at-zero address instead,
72 * the kernel startup code fails when we booted from a network device).
74 if (!memcmp((char *)0x10008, "S390EP", 6)) {
75 jump_to_IPL_code(KERN_IMAGE_START);
78 /* Trying to get PSW at zero address */
79 if (*((uint64_t *)0) & RESET_PSW_MASK) {
80 jump_to_IPL_code((*((uint64_t *)0)) & PSW_MASK_SHORT_ADDR);
83 /* No other option left, so use the Linux kernel start address */
84 jump_to_IPL_code(KERN_IMAGE_START);