pc-bios/s390-ccw: fix sparse warnings
[qemu.git] / pc-bios / s390-ccw / main.c
blob6f707bbcd44c9429572ce03584a91caca74fe4d2
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"
12 #include "virtio.h"
14 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
15 uint64_t boot_value;
16 static 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;
28 *schid = blk_schid;
29 *zeroes = 0;
33 void virtio_panic(const char *string)
35 sclp_print(string);
36 disabled_wait();
37 while (1) { }
40 static void virtio_setup(uint64_t dev_info)
42 struct schib schib;
43 int i;
44 int r;
45 bool found = false;
46 bool check_devno = false;
47 uint16_t dev_no = -1;
49 if (dev_info != -1) {
50 check_devno = true;
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++) {
63 blk_schid.sch_no = i;
64 r = stsch_err(blk_schid, &schib);
65 if (r == 3) {
66 break;
68 if (schib.pmcw.dnv) {
69 if (!check_devno || (schib.pmcw.dev == dev_no)) {
70 if (virtio_is_blk(blk_schid)) {
71 found = true;
72 break;
78 if (!found) {
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");
89 int main(void)
91 sclp_setup();
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 */