s390-bios: Decouple channel i/o logic from virtio

Create a separate library for channel i/o related code. This decouples
channel i/o operations from virtio and allows us to make use of them for
the real dasd boot path.

Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1554388475-18329-6-git-send-email-jjherne@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Jason J. Herne 2019-04-04 10:34:24 -04:00 committed by Thomas Huth
parent d96c5db77f
commit 120d04103e
8 changed files with 53 additions and 28 deletions

View File

@ -10,7 +10,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw)
.PHONY : all clean build-all .PHONY : all clean build-all
OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
virtio.o virtio-scsi.o virtio-blkdev.o libc.o virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o
QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS))
QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float

44
pc-bios/s390-ccw/cio.c Normal file
View File

@ -0,0 +1,44 @@
/*
* S390 Channel I/O
*
* Copyright (c) 2013 Alexander Graf <agraf@suse.de>
* Copyright (c) 2019 IBM Corp.
*
* Author(s): Jason J. Herne <jjherne@us.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or (at
* your option) any later version. See the COPYING file in the top-level
* directory.
*/
#include "libc.h"
#include "s390-ccw.h"
#include "cio.h"
static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
int enable_mss_facility(void)
{
int ret;
ChscAreaSda *sda_area = (ChscAreaSda *) chsc_page;
memset(sda_area, 0, PAGE_SIZE);
sda_area->request.length = 0x0400;
sda_area->request.code = 0x0031;
sda_area->operation_code = 0x2;
ret = chsc(sda_area);
if ((ret == 0) && (sda_area->response.code == 0x0001)) {
return 0;
}
return -EIO;
}
void enable_subchannel(SubChannelId schid)
{
Schib schib;
stsch_err(schid, &schib);
schib.pmcw.ena = 1;
msch(schid, &schib);
}

View File

@ -213,6 +213,9 @@ typedef struct irb {
__u32 emw[8]; __u32 emw[8];
} __attribute__ ((packed, aligned(4))) Irb; } __attribute__ ((packed, aligned(4))) Irb;
int enable_mss_facility(void);
void enable_subchannel(SubChannelId schid);
/* /*
* Some S390 specific IO instructions as inline * Some S390 specific IO instructions as inline
*/ */

View File

@ -10,6 +10,7 @@
#include "libc.h" #include "libc.h"
#include "s390-ccw.h" #include "s390-ccw.h"
#include "cio.h"
#include "virtio.h" #include "virtio.h"
char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));

View File

@ -1,7 +1,7 @@
SLOF_DIR := $(SRC_PATH)/roms/SLOF SLOF_DIR := $(SRC_PATH)/roms/SLOF
NETOBJS := start.o sclp.o virtio.o virtio-net.o jump2ipl.o netmain.o \ NETOBJS := start.o sclp.o cio.o virtio.o virtio-net.o jump2ipl.o netmain.o \
libnet.a libc.a libnet.a libc.a
LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include

View File

@ -33,6 +33,7 @@
#include <pxelinux.h> #include <pxelinux.h>
#include "s390-ccw.h" #include "s390-ccw.h"
#include "cio.h"
#include "virtio.h" #include "virtio.h"
#define DEFAULT_BOOT_RETRIES 10 #define DEFAULT_BOOT_RETRIES 10

View File

@ -72,7 +72,6 @@ unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
bool virtio_is_supported(SubChannelId schid); bool virtio_is_supported(SubChannelId schid);
void virtio_blk_setup_device(SubChannelId schid); void virtio_blk_setup_device(SubChannelId schid);
int virtio_read(ulong sector, void *load_addr); int virtio_read(ulong sector, void *load_addr);
int enable_mss_facility(void);
u64 get_clock(void); u64 get_clock(void);
ulong get_second(void); ulong get_second(void);

View File

@ -10,6 +10,7 @@
#include "libc.h" #include "libc.h"
#include "s390-ccw.h" #include "s390-ccw.h"
#include "cio.h"
#include "virtio.h" #include "virtio.h"
#include "virtio-scsi.h" #include "virtio-scsi.h"
#include "bswap.h" #include "bswap.h"
@ -20,8 +21,6 @@ static VRing block[VIRTIO_MAX_VQS];
static char ring_area[VIRTIO_RING_SIZE * VIRTIO_MAX_VQS] static char ring_area[VIRTIO_RING_SIZE * VIRTIO_MAX_VQS]
__attribute__((__aligned__(PAGE_SIZE))); __attribute__((__aligned__(PAGE_SIZE)));
static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
static VDev vdev = { static VDev vdev = {
.nr_vqs = 1, .nr_vqs = 1,
.vrings = block, .vrings = block,
@ -94,14 +93,9 @@ static int run_ccw(VDev *vdev, int cmd, void *ptr, int len)
{ {
Ccw1 ccw = {}; Ccw1 ccw = {};
CmdOrb orb = {}; CmdOrb orb = {};
Schib schib;
int r; int r;
/* start command processing */ enable_subchannel(vdev->schid);
stsch_err(vdev->schid, &schib);
/* enable the subchannel for IPL device */
schib.pmcw.ena = 1;
msch(vdev->schid, &schib);
/* start subchannel command */ /* start subchannel command */
orb.fmt = 1; orb.fmt = 1;
@ -343,20 +337,3 @@ bool virtio_is_supported(SubChannelId schid)
} }
return false; return false;
} }
int enable_mss_facility(void)
{
int ret;
ChscAreaSda *sda_area = (ChscAreaSda *) chsc_page;
memset(sda_area, 0, PAGE_SIZE);
sda_area->request.length = 0x0400;
sda_area->request.code = 0x0031;
sda_area->operation_code = 0x2;
ret = chsc(sda_area);
if ((ret == 0) && (sda_area->response.code == 0x0001)) {
return 0;
}
return -EIO;
}