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
)));
16 struct subchannel_id blk_schid
= { .one
= 1 };
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 struct subchannel_id
*schid
= (struct subchannel_id
*) 184;
26 uint32_t *zeroes
= (uint32_t *) 188;
33 void virtio_panic(const char *string
)
40 static void virtio_setup(uint64_t dev_info
)
46 bool check_devno
= false;
51 dev_no
= dev_info
& 0xffff;
52 debug_print_int("device no. ", dev_no
);
53 blk_schid
.ssid
= (dev_info
>> 16) & 0x3;
54 if (blk_schid
.ssid
!= 0) {
55 debug_print_int("ssid ", blk_schid
.ssid
);
56 if (enable_mss_facility() != 0) {
57 virtio_panic("Failed to enable mss facility\n");
62 for (i
= 0; i
< 0x10000; i
++) {
64 r
= stsch_err(blk_schid
, &schib
);
69 if (!check_devno
|| (schib
.pmcw
.dev
== dev_no
)) {
70 if (virtio_is_blk(blk_schid
)) {
79 virtio_panic("No virtio-blk device found!\n");
82 virtio_setup_block(blk_schid
);
84 if (!virtio_ipl_disk_is_valid()) {
85 virtio_panic("No valid hard disk detected.\n");
92 debug_print_int("boot reg[7] ", boot_value
);
93 virtio_setup(boot_value
);
95 zipl_load(); /* no return */
97 virtio_panic("Failed to load OS from hard disk\n");
98 return 0; /* make compiler happy */