]>
Commit | Line | Data |
---|---|---|
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" | |
12 | ||
92f2ca38 | 13 | char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); |
ff151f4e | 14 | uint64_t boot_value; |
92f2ca38 AG |
15 | |
16 | void virtio_panic(const char *string) | |
17 | { | |
18 | sclp_print(string); | |
7f61cbc1 | 19 | disabled_wait(); |
92f2ca38 AG |
20 | while (1) { } |
21 | } | |
22 | ||
ff151f4e | 23 | static void virtio_setup(uint64_t dev_info) |
92f2ca38 | 24 | { |
5d739a47 | 25 | struct subchannel_id blk_schid = { .one = 1 }; |
22d67ab5 | 26 | struct schib schib; |
92f2ca38 AG |
27 | int i; |
28 | int r; | |
29 | bool found = false; | |
ff151f4e DD |
30 | bool check_devno = false; |
31 | uint16_t dev_no = -1; | |
92f2ca38 | 32 | |
ff151f4e DD |
33 | if (dev_info != -1) { |
34 | check_devno = true; | |
35 | dev_no = dev_info & 0xffff; | |
36 | debug_print_int("device no. ", dev_no); | |
c8cda874 DD |
37 | blk_schid.ssid = (dev_info >> 16) & 0x3; |
38 | if (blk_schid.ssid != 0) { | |
39 | debug_print_int("ssid ", blk_schid.ssid); | |
40 | if (enable_mss_facility() != 0) { | |
41 | virtio_panic("Failed to enable mss facility\n"); | |
42 | } | |
43 | } | |
ff151f4e DD |
44 | } |
45 | ||
92f2ca38 AG |
46 | for (i = 0; i < 0x10000; i++) { |
47 | blk_schid.sch_no = i; | |
22d67ab5 CH |
48 | r = stsch_err(blk_schid, &schib); |
49 | if (r == 3) { | |
50 | break; | |
51 | } | |
52 | if (schib.pmcw.dnv) { | |
ff151f4e DD |
53 | if (!check_devno || (schib.pmcw.dev == dev_no)) { |
54 | if (virtio_is_blk(blk_schid)) { | |
55 | found = true; | |
56 | break; | |
57 | } | |
92f2ca38 AG |
58 | } |
59 | } | |
60 | } | |
61 | ||
62 | if (!found) { | |
63 | virtio_panic("No virtio-blk device found!\n"); | |
64 | } | |
65 | ||
66 | virtio_setup_block(blk_schid); | |
67 | } | |
68 | ||
69 | int main(void) | |
70 | { | |
71 | sclp_setup(); | |
ff151f4e DD |
72 | debug_print_int("boot reg[7] ", boot_value); |
73 | virtio_setup(boot_value); | |
74 | ||
92f2ca38 AG |
75 | if (zipl_load() < 0) |
76 | sclp_print("Failed to load OS from hard disk\n"); | |
7f61cbc1 | 77 | disabled_wait(); |
92f2ca38 AG |
78 | while (1) { } |
79 | } |