Skip to content

Commit f196f6a

Browse files
committed
Merge tag 's390-ccw-bios-2020-07-02' into s390-next-staging
* Source code clean-ups from Janosch # gpg: Signature made Thu 02 Jul 2020 11:56:01 AM CEST # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "[email protected]" # gpg: Good signature from "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [undefined] # gpg: aka "Thomas Huth <[email protected]>" [undefined] # gpg: aka "Thomas Huth <[email protected]>" [unknown] * tag 's390-ccw-bios-2020-07-02': pc-bios/s390: Update s390-ccw bios binaries with the latest changes pc-bios/s390-ccw: Generate and include dependency files in the Makefile pc-bios: s390x: Make u32 ptr check explicit pc-bios: s390x: Use ebcdic2ascii table pc-bios: s390x: Move panic() into header and add infinite loop pc-bios: s390x: Use PSW masks where possible and introduce PSW_MASK_SHORT_ADDR pc-bios: s390x: Rename PSW_MASK_ZMODE to PSW_MASK_64 pc-bios: s390x: Get rid of magic offsets into the lowcore pc-bios: s390x: Move sleep and yield to helper.h pc-bios: s390x: Consolidate timing functions into time.h pc-bios: s390x: cio.c cleanup and compile fix Signed-off-by: Cornelia Huck <[email protected]>
2 parents 4517536 + b71db6b commit f196f6a

19 files changed

+116
-110
lines changed

pc-bios/s390-ccw.img

0 Bytes
Binary file not shown.

pc-bios/s390-ccw/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@ s390-netboot.img:
3838
@echo "s390-netboot.img not built since roms/SLOF/ is not available."
3939
endif
4040

41+
ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS) $(LIBNETOBJS))
42+
-include $(ALL_OBJS:%.o=%.d)
43+
4144
clean:
4245
rm -f *.o *.d *.img *.elf *~ *.a

pc-bios/s390-ccw/bootmap.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,7 @@ static void print_eckd_ldl_msg(ECKD_IPL_mode_t mode)
328328
msg[0] = '2';
329329
break;
330330
default:
331-
msg[0] = vlbl->LDL_version;
332-
msg[0] &= 0x0f; /* convert EBCDIC */
333-
msg[0] |= 0x30; /* to ASCII (digit) */
331+
msg[0] = ebc2asc[vlbl->LDL_version];
334332
msg[1] = '?';
335333
break;
336334
}

pc-bios/s390-ccw/cio.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ void enable_subchannel(SubChannelId schid)
4949

5050
uint16_t cu_type(SubChannelId schid)
5151
{
52-
Ccw1 sense_id_ccw;
5352
SenseId sense_data;
54-
55-
sense_id_ccw.cmd_code = CCW_CMD_SENSE_ID;
56-
sense_id_ccw.cda = ptr2u32(&sense_data);
57-
sense_id_ccw.count = sizeof(sense_data);
58-
sense_id_ccw.flags |= CCW_FLAG_SLI;
53+
Ccw1 sense_id_ccw = {
54+
.cmd_code = CCW_CMD_SENSE_ID,
55+
.flags = CCW_FLAG_SLI,
56+
.count = sizeof(sense_data),
57+
.cda = ptr2u32(&sense_data),
58+
};
5959

6060
if (do_cio(schid, CU_TYPE_UNKNOWN, ptr2u32(&sense_id_ccw), CCW_FMT1)) {
6161
panic("Failed to run SenseID CCw\n");
@@ -67,13 +67,13 @@ uint16_t cu_type(SubChannelId schid)
6767
int basic_sense(SubChannelId schid, uint16_t cutype, void *sense_data,
6868
uint16_t data_size)
6969
{
70-
Ccw1 senseCcw;
70+
Ccw1 senseCcw = {
71+
.cmd_code = CCW_CMD_BASIC_SENSE,
72+
.count = data_size,
73+
.cda = ptr2u32(sense_data),
74+
};
7175
Irb irb;
7276

73-
senseCcw.cmd_code = CCW_CMD_BASIC_SENSE;
74-
senseCcw.cda = ptr2u32(sense_data);
75-
senseCcw.count = data_size;
76-
7777
return __do_cio(schid, ptr2u32(&senseCcw), CCW_FMT1, &irb);
7878
}
7979

@@ -314,7 +314,17 @@ static void print_irb_err(Irb *irb)
314314
*/
315315
static int __do_cio(SubChannelId schid, uint32_t ccw_addr, int fmt, Irb *irb)
316316
{
317-
CmdOrb orb = {};
317+
/*
318+
* QEMU's CIO implementation requires prefetch and 64-bit idaws. We
319+
* allow all paths.
320+
*/
321+
CmdOrb orb = {
322+
.fmt = fmt,
323+
.pfch = 1,
324+
.c64 = 1,
325+
.lpm = 0xFF,
326+
.cpa = ccw_addr,
327+
};
318328
int rc;
319329

320330
IPL_assert(fmt == 0 || fmt == 1, "Invalid ccw format");
@@ -324,12 +334,6 @@ static int __do_cio(SubChannelId schid, uint32_t ccw_addr, int fmt, Irb *irb)
324334
IPL_assert(ccw_addr <= 0xFFFFFF - 8, "Invalid ccw address");
325335
}
326336

327-
orb.fmt = fmt;
328-
orb.pfch = 1; /* QEMU's cio implementation requires prefetch */
329-
orb.c64 = 1; /* QEMU's cio implementation requires 64-bit idaws */
330-
orb.lpm = 0xFF; /* All paths allowed */
331-
orb.cpa = ccw_addr;
332-
333337
rc = ssch(schid, &orb);
334338
if (rc == 1 || rc == 2) {
335339
/* Subchannel status pending or busy. Eat status and ask for retry. */

pc-bios/s390-ccw/cio.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,17 @@ typedef struct schib {
122122
} __attribute__ ((packed, aligned(4))) Schib;
123123

124124
typedef struct subchannel_id {
125-
__u32 cssid:8;
126-
__u32:4;
127-
__u32 m:1;
128-
__u32 ssid:2;
129-
__u32 one:1;
130-
__u32 sch_no:16;
125+
union {
126+
struct {
127+
__u16 cssid:8;
128+
__u16 reserved:4;
129+
__u16 m:1;
130+
__u16 ssid:2;
131+
__u16 one:1;
132+
};
133+
__u16 sch_id;
134+
};
135+
__u16 sch_no;
131136
} __attribute__ ((packed, aligned(4))) SubChannelId;
132137

133138
struct chsc_header {

pc-bios/s390-ccw/helper.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
#define S390_CCW_HELPER_H
1515

1616
#include "s390-ccw.h"
17+
#include "s390-time.h"
1718

1819
/* Avoids compiler warnings when casting a pointer to a u32 */
1920
static inline uint32_t ptr2u32(void *ptr)
2021
{
21-
IPL_assert((uint64_t)ptr <= 0xffffffff, "ptr2u32: ptr too large");
22+
IPL_assert((uint64_t)ptr <= 0xffffffffull, "ptr2u32: ptr too large");
2223
return (uint32_t)(uint64_t)ptr;
2324
}
2425

@@ -28,4 +29,20 @@ static inline void *u32toptr(uint32_t n)
2829
return (void *)(uint64_t)n;
2930
}
3031

32+
static inline void yield(void)
33+
{
34+
asm volatile ("diag 0,0,0x44"
35+
: :
36+
: "memory", "cc");
37+
}
38+
39+
static inline void sleep(unsigned int seconds)
40+
{
41+
ulong target = get_time_seconds() + seconds;
42+
43+
while (get_time_seconds() < target) {
44+
yield();
45+
}
46+
}
47+
3148
#endif

pc-bios/s390-ccw/jump2ipl.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88

99
#include "libc.h"
1010
#include "s390-ccw.h"
11+
#include "s390-arch.h"
1112

1213
#define KERN_IMAGE_START 0x010000UL
13-
#define PSW_MASK_64 0x0000000100000000ULL
14-
#define PSW_MASK_32 0x0000000080000000ULL
15-
#define PSW_MASK_SHORTPSW 0x0008000000000000ULL
16-
#define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_32 | PSW_MASK_64)
14+
#define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_64)
1715

1816
typedef struct ResetInfo {
1917
uint64_t ipl_psw;
@@ -54,7 +52,7 @@ void jump_to_IPL_code(uint64_t address)
5452

5553
current->ipl_psw = (uint64_t) &jump_to_IPL_2;
5654
current->ipl_psw |= RESET_PSW_MASK;
57-
current->ipl_continue = address & 0x7fffffff;
55+
current->ipl_continue = address & PSW_MASK_SHORT_ADDR;
5856

5957
debug_print_int("set IPL addr to", current->ipl_continue);
6058

@@ -86,7 +84,7 @@ void jump_to_low_kernel(void)
8684

8785
/* Trying to get PSW at zero address */
8886
if (*((uint64_t *)0) & RESET_PSW_MASK) {
89-
jump_to_IPL_code((*((uint64_t *)0)) & 0x7fffffff);
87+
jump_to_IPL_code((*((uint64_t *)0)) & PSW_MASK_SHORT_ADDR);
9088
}
9189

9290
/* No other option left, so use the Linux kernel start address */

pc-bios/s390-ccw/main.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,16 @@ LowCore *lowcore; /* Yes, this *is* a pointer to address 0 */
3636
*/
3737
void write_subsystem_identification(void)
3838
{
39-
SubChannelId *schid = (SubChannelId *) 184;
40-
uint32_t *zeroes = (uint32_t *) 188;
41-
42-
*schid = blk_schid;
43-
*zeroes = 0;
39+
lowcore->subchannel_id = blk_schid.sch_id;
40+
lowcore->subchannel_nr = blk_schid.sch_no;
41+
lowcore->io_int_parm = 0;
4442
}
4543

4644
void write_iplb_location(void)
4745
{
4846
lowcore->ptr_iplb = ptr2u32(&iplb);
4947
}
5048

51-
void panic(const char *string)
52-
{
53-
sclp_print(string);
54-
disabled_wait();
55-
while (1) { }
56-
}
57-
5849
unsigned int get_loadparm_index(void)
5950
{
6051
return atoui(loadparm_str);

pc-bios/s390-ccw/menu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "libc.h"
1313
#include "s390-ccw.h"
1414
#include "sclp.h"
15+
#include "s390-time.h"
1516

1617
#define KEYCODE_NO_INP '\0'
1718
#define KEYCODE_ESCAPE '\033'

pc-bios/s390-ccw/netboot.mak

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

22
SLOF_DIR := $(SRC_PATH)/roms/SLOF
33

4-
NETOBJS := start.o sclp.o cio.o virtio.o virtio-net.o jump2ipl.o netmain.o \
5-
libnet.a libc.a
4+
NETOBJS := start.o sclp.o cio.o virtio.o virtio-net.o jump2ipl.o netmain.o
65

76
LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include
87
LIBNET_INC := -I$(SLOF_DIR)/lib/libnet
@@ -11,15 +10,16 @@ NETLDFLAGS := $(LDFLAGS) -Ttext=0x7800000
1110

1211
$(NETOBJS): QEMU_CFLAGS += $(LIBC_INC) $(LIBNET_INC)
1312

14-
s390-netboot.elf: $(NETOBJS)
15-
$(call quiet-command,$(CC) $(NETLDFLAGS) -o $@ $(NETOBJS),"BUILD","$(TARGET_DIR)$@")
13+
s390-netboot.elf: $(NETOBJS) libnet.a libc.a
14+
$(call quiet-command,$(CC) $(NETLDFLAGS) -o $@ $^,"BUILD","$(TARGET_DIR)$@")
1615

1716
s390-netboot.img: s390-netboot.elf
1817
$(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,"STRIP","$(TARGET_DIR)$@")
1918

2019
# libc files:
2120

22-
LIBC_CFLAGS := $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC)
21+
LIBC_CFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
22+
-MMD -MP -MT $@ -MF $(@:%.o=%.d)
2323

2424
CTYPE_OBJS = isdigit.o isxdigit.o toupper.o
2525
%.o : $(SLOF_DIR)/lib/libc/ctype/%.c
@@ -52,7 +52,8 @@ libc.a: $(LIBCOBJS)
5252

5353
LIBNETOBJS := args.o dhcp.o dns.o icmpv6.o ipv6.o tcp.o udp.o bootp.o \
5454
dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o pxelinux.o
55-
LIBNETCFLAGS := $(QEMU_CFLAGS) $(CFLAGS) -DDHCPARCH=0x1F $(LIBC_INC) $(LIBNET_INC)
55+
LIBNETCFLAGS = $(QEMU_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
56+
-DDHCPARCH=0x1F -MMD -MP -MT $@ -MF $(@:%.o=%.d)
5657

5758
%.o : $(SLOF_DIR)/lib/libnet/%.c
5859
$(call quiet-command,$(CC) $(LIBNETCFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)$@")

0 commit comments

Comments
 (0)