xref: /kvm-unit-tests/lib/s390x/io.c (revision 2c96b77ec9d3b1fcec7525174e23a6240ee05949)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * s390x io implementation
4  *
5  * Copyright (c) 2017 Red Hat Inc
6  *
7  * Authors:
8  *  Thomas Huth <thuth@redhat.com>
9  *  David Hildenbrand <david@redhat.com>
10  */
11 #include <libcflat.h>
12 #include <argv.h>
13 #include <asm/spinlock.h>
14 #include <asm/facility.h>
15 #include <asm/sigp.h>
16 #include "sclp.h"
17 #include "uv.h"
18 #include "smp.h"
19 
20 extern char ipl_args[];
21 uint64_t stfl_doublewords[NB_STFL_DOUBLEWORDS];
22 
23 static struct spinlock lock;
24 
25 void setup(void);
26 
27 void puts(const char *s)
28 {
29 	spin_lock(&lock);
30 	sclp_print(s);
31 	spin_unlock(&lock);
32 }
33 
34 void setup(void)
35 {
36 	setup_args_progname(ipl_args);
37 	setup_facilities();
38 	sclp_read_info();
39 	sclp_facilities_setup();
40 	sclp_console_setup();
41 	sclp_memory_setup();
42 	uv_setup();
43 	smp_setup();
44 }
45 
46 void exit(int code)
47 {
48 	smp_teardown();
49 	printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
50 	while (1) {
51 		sigp(stap(), SIGP_STOP, 0, NULL);
52 	}
53 }
54