#ifndef hal_arch_io_h #define hal_arch_io_h /* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file hal/arch/io.h * \brief Architecture dependent basic input output services. * \ingroup hal_arch * * The services in this file offer the added value that they should depend of * almost nothing in order to work, enabling use from debugger or fatal error * state. */ /** * Basic output, output a single char. * \param c the char to output * * \note Actually implemented as macro. */ void arch_io_write_char (char c); /** * Basic output, output a null terminated string. * \param s the string to output * * \note Actually implemented as macro. */ void arch_io_write_string (const char *s); /** * Basic output, output a text buffer. * \param text text buffer start address * \param text_size number of characters to output * * \note Actually implemented as macro. */ void arch_io_write (const char *text, uint text_size); #if defined (ECOS) && ECOS # include # define arch_io_write_char diag_write_char # define arch_io_write_string diag_write_string # define arch_io_write(text, text_size) do { \ const char *iter_ = (text); \ const char *end_ = iter_ + (text_size); \ for (; iter_ != end_; iter_++) \ { \ arch_io_write_char (*iter_); \ } \ } while (0) #else /* !(defined (ECOS) && ECOS) */ # include # include # define arch_io_write_char(c) do { \ char c_ = (c); \ arch_io_write (&c_, 1); \ } while (0) # define arch_io_write_string(s) do { \ const char *s_ = (s); \ uint size_ = strlen (s_); \ arch_io_write (s_, size_); \ } while (0) # define arch_io_write(text, text_size) do { \ write (1, (text), (text_size)); \ } while (0) #endif /* !(defined (ECOS) && ECOS) */ #endif /* hal_arch_io_h */