]>
git.proxmox.com Git - mirror_qemu.git/blob - pc-bios/s390-ccw/main.c
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
14 char stack
[PAGE_SIZE
* 8] __attribute__((__aligned__(PAGE_SIZE
)));
15 static SubChannelId blk_schid
= { .one
= 1 };
16 IplParameterBlock iplb
__attribute__((__aligned__(PAGE_SIZE
)));
17 static char loadparm
[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
19 const unsigned char ebc2asc
[256] =
20 /* 0123456789abcdef0123456789abcdef */
21 "................................" /* 1F */
22 "................................" /* 3F */
23 " ...........<(+|&.........!$*);." /* 5F first.chr.here.is.real.space */
24 "-/.........,%_>?.........`:#@'=\""/* 7F */
25 ".abcdefghi.......jklmnopqr......" /* 9F */
26 "..stuvwxyz......................" /* BF */
27 ".ABCDEFGHI.......JKLMNOPQR......" /* DF */
28 "..STUVWXYZ......0123456789......";/* FF */
31 * Priniciples of Operations (SA22-7832-09) chapter 17 requires that
32 * a subsystem-identification is at 184-187 and bytes 188-191 are zero
33 * after list-directed-IPL and ccw-IPL.
35 void write_subsystem_identification(void)
37 SubChannelId
*schid
= (SubChannelId
*) 184;
38 uint32_t *zeroes
= (uint32_t *) 188;
44 void panic(const char *string
)
51 unsigned int get_loadparm_index(void)
53 const char *lp
= loadparm
;
57 for (i
= 0; i
< 8; i
++) {
60 if (c
< '0' || c
> '9') {
71 static bool find_dev(Schib
*schib
, int dev_no
)
75 for (i
= 0; i
< 0x10000; i
++) {
77 r
= stsch_err(blk_schid
, schib
);
78 if ((r
== 3) || (r
== -EIO
)) {
81 if (!schib
->pmcw
.dnv
) {
84 if (!virtio_is_supported(blk_schid
)) {
87 /* Skip net devices since no IPLB is created and therefore no
88 * no network bootloader has been loaded
90 if (virtio_get_device_type() == VIRTIO_ID_NET
&& dev_no
< 0) {
93 if ((dev_no
< 0) || (schib
->pmcw
.dev
== dev_no
)) {
101 static void virtio_setup(void)
107 char ldp
[] = "LOADPARM=[________]\n";
108 VDev
*vdev
= virtio_get_device();
111 * We unconditionally enable mss support. In every sane configuration,
112 * this will succeed; and even if it doesn't, stsch_err() can deal
113 * with the consequences.
115 enable_mss_facility();
117 sclp_get_loadparm_ascii(loadparm
);
118 memcpy(ldp
+ 10, loadparm
, 8);
121 if (store_iplb(&iplb
)) {
123 case S390_IPL_TYPE_CCW
:
124 dev_no
= iplb
.ccw
.devno
;
125 debug_print_int("device no. ", dev_no
);
126 blk_schid
.ssid
= iplb
.ccw
.ssid
& 0x3;
127 debug_print_int("ssid ", blk_schid
.ssid
);
128 found
= find_dev(&schib
, dev_no
);
130 case S390_IPL_TYPE_QEMU_SCSI
:
131 vdev
->scsi_device_selected
= true;
132 vdev
->selected_scsi_device
.channel
= iplb
.scsi
.channel
;
133 vdev
->selected_scsi_device
.target
= iplb
.scsi
.target
;
134 vdev
->selected_scsi_device
.lun
= iplb
.scsi
.lun
;
135 blk_schid
.ssid
= iplb
.scsi
.ssid
& 0x3;
136 found
= find_dev(&schib
, iplb
.scsi
.devno
);
139 panic("List-directed IPL not supported yet!\n");
142 for (ssid
= 0; ssid
< 0x3; ssid
++) {
143 blk_schid
.ssid
= ssid
;
144 found
= find_dev(&schib
, -1);
151 IPL_assert(found
, "No virtio device found");
153 if (virtio_get_device_type() == VIRTIO_ID_NET
) {
154 sclp_print("Network boot device detected\n");
155 vdev
->netboot_start_addr
= iplb
.ccw
.netboot_start_addr
;
157 virtio_setup_device(blk_schid
);
159 IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detected");
168 zipl_load(); /* no return */
170 panic("Failed to load OS from hard disk\n");
171 return 0; /* make compiler happy */