2 * S390 virtio-ccw loading program
4 * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
6 * This work is licensed under the terms of the GNU GPL, version 2 or (at
7 * your option) any later version. See the COPYING file in the top-level
14 char stack
[PAGE_SIZE
* 8] __attribute__((__aligned__(PAGE_SIZE
)));
15 static SubChannelId blk_schid
= { .one
= 1 };
16 IplParameterBlock iplb
__attribute__((__aligned__(PAGE_SIZE
)));
19 * Priniciples of Operations (SA22-7832-09) chapter 17 requires that
20 * a subsystem-identification is at 184-187 and bytes 188-191 are zero
21 * after list-directed-IPL and ccw-IPL.
23 void write_subsystem_identification(void)
25 SubChannelId
*schid
= (SubChannelId
*) 184;
26 uint32_t *zeroes
= (uint32_t *) 188;
33 void panic(const char *string
)
40 static bool find_dev(Schib
*schib
, int dev_no
)
44 for (i
= 0; i
< 0x10000; i
++) {
46 r
= stsch_err(blk_schid
, schib
);
47 if ((r
== 3) || (r
== -EIO
)) {
50 if (!schib
->pmcw
.dnv
) {
53 if (!virtio_is_supported(blk_schid
)) {
56 if ((dev_no
< 0) || (schib
->pmcw
.dev
== dev_no
)) {
64 static void virtio_setup(void)
72 * We unconditionally enable mss support. In every sane configuration,
73 * this will succeed; and even if it doesn't, stsch_err() can deal
74 * with the consequences.
76 enable_mss_facility();
78 if (store_iplb(&iplb
)) {
80 case S390_IPL_TYPE_CCW
:
81 dev_no
= iplb
.ccw
.devno
;
82 debug_print_int("device no. ", dev_no
);
83 blk_schid
.ssid
= iplb
.ccw
.ssid
& 0x3;
84 debug_print_int("ssid ", blk_schid
.ssid
);
85 found
= find_dev(&schib
, dev_no
);
87 case S390_IPL_TYPE_QEMU_SCSI
:
89 VDev
*vdev
= virtio_get_device();
91 vdev
->scsi_device_selected
= true;
92 vdev
->selected_scsi_device
.channel
= iplb
.scsi
.channel
;
93 vdev
->selected_scsi_device
.target
= iplb
.scsi
.target
;
94 vdev
->selected_scsi_device
.lun
= iplb
.scsi
.lun
;
95 blk_schid
.ssid
= iplb
.scsi
.ssid
& 0x3;
96 found
= find_dev(&schib
, iplb
.scsi
.devno
);
100 panic("List-directed IPL not supported yet!\n");
103 for (ssid
= 0; ssid
< 0x3; ssid
++) {
104 blk_schid
.ssid
= ssid
;
105 found
= find_dev(&schib
, -1);
112 IPL_assert(found
, "No virtio device found");
114 virtio_setup_device(blk_schid
);
116 IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
124 zipl_load(); /* no return */
126 panic("Failed to load OS from hard disk\n");
127 return 0; /* make compiler happy */