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 "sclp.h" 18 19 extern char ipl_args[]; 20 uint8_t stfl_bytes[NR_STFL_BYTES] __attribute__((aligned(8))); 21 22 static struct spinlock lock; 23 24 void puts(const char *s) 25 { 26 spin_lock(&lock); 27 sclp_print(s); 28 spin_unlock(&lock); 29 } 30 31 static void sigp_stop() 32 { 33 register unsigned long status asm ("1") = 0; 34 register unsigned long cpu asm ("2") = 0; 35 36 asm volatile( 37 " sigp %0,%1,0(%2)\n" 38 : "+d" (status) : "d" (cpu), "d" (5) : "cc"); 39 } 40 41 void setup() 42 { 43 setup_args_progname(ipl_args); 44 setup_facilities(); 45 sclp_setup(); 46 } 47 48 void exit(int code) 49 { 50 printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1); 51 sigp_stop(); 52 } 53