]> git.proxmox.com Git - qemu.git/blob - pc-bios/s390-ccw/main.c
s390-ccw.img: Detect devices with stsch.
[qemu.git] / pc-bios / s390-ccw / main.c
1 /*
2 * S390 virtio-ccw loading program
3 *
4 * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
5 *
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 */
10
11 #include "s390-ccw.h"
12
13 struct subchannel_id blk_schid;
14 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
15
16 void virtio_panic(const char *string)
17 {
18 sclp_print(string);
19 disabled_wait();
20 while (1) { }
21 }
22
23 static void virtio_setup(void)
24 {
25 struct schib schib;
26 int i;
27 int r;
28 bool found = false;
29
30 blk_schid.one = 1;
31
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;
37 }
38 if (schib.pmcw.dnv) {
39 if (virtio_is_blk(blk_schid)) {
40 found = true;
41 break;
42 }
43 }
44 }
45
46 if (!found) {
47 virtio_panic("No virtio-blk device found!\n");
48 }
49
50 virtio_setup_block(blk_schid);
51 }
52
53 int main(void)
54 {
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) { }
61 }