1 /* 2 * (c) 2017 Adam Lackorzynski <adam@l4re.org> 3 * 4 * This file is part of L4Re and distributed under the terms of the 5 * GNU General Public License 2. 6 * Please see the COPYING-GPL-2 file for details. 7 */ 8 #pragma once 9 10 #include <l4/sys/vcon> 11 12 #include <stdlib.h> 13 #include <string.h> 14 15 // Very simple print, used for early (error) reporting vcon_print(char const * text)16inline void vcon_print(char const *text) 17 { 18 L4::Cap<L4::Vcon>(L4_BASE_LOG_CAP)->write(text, strlen(text)); 19 } 20 early_chksys(l4_msgtag_t const & t,char const * text)21inline long early_chksys(l4_msgtag_t const &t, char const *text) 22 { 23 if (t.has_error() || t.label() < 0) 24 { 25 vcon_print(text); 26 exit(1); 27 } 28 29 return t.label(); 30 } 31 32 template<typename T> 33 inline early_chkcap(T cap,char const * text)34T early_chkcap(T cap, char const *text) 35 { 36 if (!cap) 37 { 38 vcon_print(text); 39 exit(1); 40 } 41 42 return cap; 43 } 44