s390-ccw.img: Detect devices with stsch.
[qemu.git] / pc-bios / s390-ccw / main.c
blobfd40fa582a4a39792bd92a612eb8be6963461346
1 /*
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
8 * directory.
9 */
11 #include "s390-ccw.h"
13 struct subchannel_id blk_schid;
14 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
16 void virtio_panic(const char *string)
18 sclp_print(string);
19 disabled_wait();
20 while (1) { }
23 static void virtio_setup(void)
25 struct schib schib;
26 int i;
27 int r;
28 bool found = false;
30 blk_schid.one = 1;
32 for (i = 0; i < 0x10000; i++) {
33 blk_schid.sch_no = i;
34 r = stsch_err(blk_schid, &schib);
35 if (r == 3) {
36 break;
38 if (schib.pmcw.dnv) {
39 if (virtio_is_blk(blk_schid)) {
40 found = true;
41 break;
46 if (!found) {
47 virtio_panic("No virtio-blk device found!\n");
50 virtio_setup_block(blk_schid);
53 int main(void)
55 sclp_setup();
56 virtio_setup();
57 if (zipl_load() < 0)
58 sclp_print("Failed to load OS from hard disk\n");
59 disabled_wait();
60 while (1) { }