]> Git Repo - qemu.git/blame - pc-bios/s390-ccw/main.c
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
[qemu.git] / pc-bios / s390-ccw / main.c
CommitLineData
92f2ca38
AG
1/*
2 * S390 virtio-ccw loading program
3 *
4 * Copyright (c) 2013 Alexander Graf <[email protected]>
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"
60612d5c 12#include "virtio.h"
92f2ca38 13
92f2ca38 14char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
2be9d292 15char ring_area[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
ff151f4e 16uint64_t boot_value;
f17a8430 17static struct subchannel_id blk_schid = { .one = 1 };
f2879a5c
CB
18
19/*
20 * Priniciples of Operations (SA22-7832-09) chapter 17 requires that
21 * a subsystem-identification is at 184-187 and bytes 188-191 are zero
22 * after list-directed-IPL and ccw-IPL.
23 */
24void write_subsystem_identification(void)
25{
26 struct subchannel_id *schid = (struct subchannel_id *) 184;
27 uint32_t *zeroes = (uint32_t *) 188;
28
29 *schid = blk_schid;
30 *zeroes = 0;
31}
32
92f2ca38
AG
33
34void virtio_panic(const char *string)
35{
36 sclp_print(string);
7f61cbc1 37 disabled_wait();
92f2ca38
AG
38 while (1) { }
39}
40
ff151f4e 41static void virtio_setup(uint64_t dev_info)
92f2ca38 42{
22d67ab5 43 struct schib schib;
92f2ca38
AG
44 int i;
45 int r;
46 bool found = false;
ff151f4e
DD
47 bool check_devno = false;
48 uint16_t dev_no = -1;
92f2ca38 49
ff151f4e
DD
50 if (dev_info != -1) {
51 check_devno = true;
52 dev_no = dev_info & 0xffff;
53 debug_print_int("device no. ", dev_no);
c8cda874
DD
54 blk_schid.ssid = (dev_info >> 16) & 0x3;
55 if (blk_schid.ssid != 0) {
56 debug_print_int("ssid ", blk_schid.ssid);
57 if (enable_mss_facility() != 0) {
58 virtio_panic("Failed to enable mss facility\n");
59 }
60 }
ff151f4e
DD
61 }
62
92f2ca38
AG
63 for (i = 0; i < 0x10000; i++) {
64 blk_schid.sch_no = i;
22d67ab5
CH
65 r = stsch_err(blk_schid, &schib);
66 if (r == 3) {
67 break;
68 }
69 if (schib.pmcw.dnv) {
ff151f4e
DD
70 if (!check_devno || (schib.pmcw.dev == dev_no)) {
71 if (virtio_is_blk(blk_schid)) {
72 found = true;
73 break;
74 }
92f2ca38
AG
75 }
76 }
77 }
78
79 if (!found) {
80 virtio_panic("No virtio-blk device found!\n");
81 }
82
83 virtio_setup_block(blk_schid);
60612d5c
ED
84
85 if (!virtio_ipl_disk_is_valid()) {
86 virtio_panic("No valid hard disk detected.\n");
87 }
92f2ca38
AG
88}
89
90int main(void)
91{
92 sclp_setup();
ff151f4e
DD
93 debug_print_int("boot reg[7] ", boot_value);
94 virtio_setup(boot_value);
95
60612d5c
ED
96 zipl_load(); /* no return */
97
98 virtio_panic("Failed to load OS from hard disk\n");
99 return 0; /* make compiler happy */
92f2ca38 100}
This page took 0.128607 seconds and 4 git commands to generate.