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 struct cpu this_cpu_tmp = { 0 }; 37 38 /* 39 * Set a temporary empty struct cpu for the boot CPU, needed for 40 * correct interrupt handling in the setup process. 41 * smp_setup will allocate and set the permanent one. 42 */ 43 THIS_CPU = &this_cpu_tmp; 44 45 setup_args_progname(ipl_args); 46 setup_facilities(); 47 sclp_read_info(); 48 sclp_facilities_setup(); 49 sclp_console_setup(); 50 sclp_memory_setup(); 51 uv_setup(); 52 smp_setup(); 53 } 54 55 void exit(int code) 56 { 57 smp_teardown(); 58 printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1); 59 while (1) { 60 sigp(stap(), SIGP_STOP, 0, NULL); 61 } 62 } 63