]>
git.proxmox.com Git - mirror_qemu.git/blob - pc-bios/s390-ccw/netmain.c
2 * S390 virtio-ccw network boot loading program
4 * Copyright 2017 Thomas Huth, Red Hat Inc.
6 * Based on the S390 virtio-ccw loading program (main.c)
7 * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
9 * This code is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
28 char stack
[PAGE_SIZE
* 8] __attribute__((aligned(PAGE_SIZE
)));
29 IplParameterBlock iplb
__attribute__((aligned(PAGE_SIZE
)));
31 static SubChannelId net_schid
= { .one
= 1 };
32 static uint64_t dest_timer
;
34 static uint64_t get_timer_ms(void)
38 asm volatile(" stck %0 " : : "Q"(clk
) : "memory");
40 /* Bit 51 is incremented each microsecond */
41 return (clk
>> (63 - 51)) / 1000;
44 void set_timer(int val
)
46 dest_timer
= get_timer_ms() + val
;
51 return dest_timer
- get_timer_ms();
54 int get_sec_ticks(void)
56 return 1000; /* number of ticks in 1 second */
59 void panic(const char *string
)
67 static bool find_net_dev(Schib
*schib
, int dev_no
)
71 for (i
= 0; i
< 0x10000; i
++) {
73 r
= stsch_err(net_schid
, schib
);
74 if (r
== 3 || r
== -EIO
) {
77 if (!schib
->pmcw
.dnv
) {
80 if (!virtio_is_supported(net_schid
)) {
83 if (virtio_get_device_type() != VIRTIO_ID_NET
) {
86 if (dev_no
< 0 || schib
->pmcw
.dev
== dev_no
) {
94 static void virtio_setup(void)
102 * We unconditionally enable mss support. In every sane configuration,
103 * this will succeed; and even if it doesn't, stsch_err() can deal
104 * with the consequences.
106 enable_mss_facility();
108 if (store_iplb(&iplb
)) {
109 IPL_assert(iplb
.pbt
== S390_IPL_TYPE_CCW
, "IPL_TYPE_CCW expected");
110 dev_no
= iplb
.ccw
.devno
;
111 debug_print_int("device no. ", dev_no
);
112 net_schid
.ssid
= iplb
.ccw
.ssid
& 0x3;
113 debug_print_int("ssid ", net_schid
.ssid
);
114 found
= find_net_dev(&schib
, dev_no
);
116 for (ssid
= 0; ssid
< 0x3; ssid
++) {
117 net_schid
.ssid
= ssid
;
118 found
= find_net_dev(&schib
, -1);
125 IPL_assert(found
, "No virtio net device found");
131 sclp_print("Network boot starting...\n");
135 panic("Failed to load OS from network\n");