xref: /kvm-unit-tests/lib/s390x/io.c (revision 6ca8c283190847bd2ff648232f98f70e4e6d3d0d)
1 /*
2  * s390x io implementation
3  *
4  * Copyright (c) 2017 Red Hat Inc
5  *
6  * Authors:
7  *  Thomas Huth <thuth@redhat.com>
8  *  David Hildenbrand <david@redhat.com>
9  *
10  * This code is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Library General Public License version 2.
12  */
13 #include <libcflat.h>
14 #include <argv.h>
15 #include <asm/spinlock.h>
16 #include <asm/facility.h>
17 #include <asm/sigp.h>
18 #include "sclp.h"
19 
20 extern char ipl_args[];
21 uint8_t stfl_bytes[NR_STFL_BYTES] __attribute__((aligned(8)));
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_console_setup();
39 	sclp_memory_setup();
40 }
41 
42 void exit(int code)
43 {
44 	printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1);
45 	while (1) {
46 		sigp_stop();
47 	}
48 }
49