S390: Make IPL reset address dynamic

We can have different load addresses for different blobs we boot with.
Make the reset IP dynamic, so that we can handle things more flexibly.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: IPL: Support ELF firmware

Our firmware blob is always a raw file that we load at a fixed address today.
Support loading an ELF blob instead that we can map high up in memory.

This way we don't have to be so conscious about size constraints.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: IPL: Use different firmware for different machines

We have a virtio-s390 and a virtio-ccw machine in QEMU. Both use vastly
different ways to do I/O. Having the same firmware blob for both doesn't
really make any sense.

Instead, let's parametrize the firmware file name, so that we can have
different blobs for different machines.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add start assembly

We want to write most of our code in C, so add a small assembly
stub that jumps straight into C code for us to continue booting.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add main program

This C file is the main driving piece of the s390 ccw firmware. It
provides a search for a workable block device, sets it as the default
to boot off of and boots from it.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add sclp output

In order to communicate with the user, we need an I/O mechanism that he
can read. Implement SCLP ASCII support, which happens to be the default
in the s390 ccw machine.

This file is missing read support for now. It can only print messages.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add virtio device drivers

In order to boot, we need to be able to access a virtio-blk device through
the CCW bus. Implement support for this.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add glue header

Like all great programs, we have to call between different functions in
different object files. And all of them need a common ground of defines.

Provide a file that provides these defines.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add bootmap interpreter

On s390, there is an architected boot map format that we can read to
boot a certain entry off the disk. Implement a simple reader for this
that always boots the first (default) entry.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add Makefile

This patch adds a makefile, so we can build our ccw firmware. Also
add the resulting binaries to .gitignore, so that nobody is annoyed
they might be in the tree.

Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: replace while loop with a disabled wait on s390 bios

dont waste cpu power on an error condition. Lets stop the guest
with a disabled wait.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: build s390-ccw rom on s3900 system by default

Lets build the s390-ccw rom if on s390. Also fix the separate build
folder case.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: Take care of the elf->img transition

We have to call strip with s390-ccw.elf as input and
s390-ccw.img as output

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: Fix compile warning in s390 ccw virtio code

Lets fix this gcc warning:

virtio.c: In function ‘vring_send_buf’:
virtio.c:125:35: error: operation on ‘vr->next_idx’ may be undefined
[-Werror=sequence-point]

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: Detect devices with stsch.

stsch is the canonical way to detect devices. As a bonus, we can
abort the loop if we get cc 3, and we need to check only the valid
devices (dnv set).

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: Enhance drain_irqs().

- Use tpi + tsch to get interrupts.
- Return an error if the irb indicates problems.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: Rudimentary error checking.

Try to handle at least some of the errors that may happen.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
s390-ccw.img: Get queue config from host.

Ask the host about the configuration instead of guessing it.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
S390: ccw firmware: Add compiled blob

Now that we have all the source code ready, add a compiled blob into
the QEMU source tree, so that people without access to an s390 compiler
can run the s390-ccw firmware.

Signed-off-by: Alexander Graf <agraf@suse.de>
S390: CCW: Use new, working firmware by default

Since we now have working firmware for s390-ccw in the tree, we can
default to it on our s390-ccw machine, rendering it more useful.

Signed-off-by: Alexander Graf <agraf@suse.de>