xref: /kvm-unit-tests/lib/s390x/io.c (revision fdab948bc134fb9989a8265380a55e809879418e)
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 "smp.h"
18 
19 extern char ipl_args[];
20 uint64_t stfl_doublewords[NB_STFL_DOUBLEWORDS];
21 
22 static struct spinlock lock;
23 
24 void setup(void);
25 
26 void puts(const char *s)
27 {
28 	spin_lock(&lock);
29 	sclp_print(s);
30 	spin_unlock(&lock);
31 }
32 
33 void setup(void)
34 {
35 	setup_args_progname(ipl_args);
36 	setup_facilities();
37 	sclp_read_info();
38 	sclp_facilities_setup();
39 	sclp_console_setup();
40 	sclp_memory_setup();
41 	smp_setup();
42 }
43 
44 void exit(int code)
45 {
46 	smp_teardown();
47 	printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
48 	while (1) {
49 		sigp(stap(), SIGP_STOP, 0, NULL);
50 	}
51 }
52