11e95c7ccSAndrew Jones /* 21e95c7ccSAndrew Jones * Each architecture must implement puts() and exit(). 31e95c7ccSAndrew Jones * 41e95c7ccSAndrew Jones * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com> 51e95c7ccSAndrew Jones * 61e95c7ccSAndrew Jones * This work is licensed under the terms of the GNU LGPL, version 2. 71e95c7ccSAndrew Jones */ 81e95c7ccSAndrew Jones #include <libcflat.h> 9e65bcc62SAndrew Jones #include <asm/spinlock.h> 102f9ce69eSAndrew Jones #include <asm/rtas.h> 114ff26ec5SThomas Huth #include <asm/setup.h> 124ff26ec5SThomas Huth #include "io.h" 13e65bcc62SAndrew Jones 14e65bcc62SAndrew Jones extern void halt(int code); 15e65bcc62SAndrew Jones 16e65bcc62SAndrew Jones static struct spinlock print_lock; 171e95c7ccSAndrew Jones 181e95c7ccSAndrew Jones void io_init(void) 191e95c7ccSAndrew Jones { 202f9ce69eSAndrew Jones rtas_init(); 211e95c7ccSAndrew Jones } 221e95c7ccSAndrew Jones 23e65bcc62SAndrew Jones void puts(const char *s) 241e95c7ccSAndrew Jones { 25e65bcc62SAndrew Jones spin_lock(&print_lock); 26e65bcc62SAndrew Jones while (*s) 27e65bcc62SAndrew Jones putchar(*s++); 28e65bcc62SAndrew Jones spin_unlock(&print_lock); 291e95c7ccSAndrew Jones } 301e95c7ccSAndrew Jones 31e65bcc62SAndrew Jones void exit(int code) 321e95c7ccSAndrew Jones { 33f5a87330SAndrew Jones // FIXME: change this print-exit/rtas-poweroff to chr_testdev_exit(), 34f5a87330SAndrew Jones // maybe by plugging chr-testdev into a spapr-vty. 35f5a87330SAndrew Jones printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1); 36f5a87330SAndrew Jones rtas_power_off(); 37e65bcc62SAndrew Jones halt(code); 38*96d79976SAndre Przywara __builtin_unreachable(); 391e95c7ccSAndrew Jones } 40