RAM 6.0 BUX II Series Guía de usuario Pagina 71

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 189
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 70
3 Porting a BSP to Custom Hardware
3.2 Getting a Minimal Kernel Running
63
3
Console Output Routines
In addition to the LED routines described above, it may also be helpful to have a
polled-mode serial output routine. The first step in producing this routine is to
create a more basic routine, possibly called something such as outConsole( ), that
does unformatted polled-mode serial output. This does not allow numbers to be
displayed easily, but it does allow diagnostic output. The prototype of
outConsole( ) is as follows:
STATUS outConsole
(
char *buffer, /* buffer passed to routine */
int nchars, /* length of buffer */
int outarg /* arbitrary arg passed from fmt routine */
)
This routine disables all interrupts; use polled mode output for the serial device
until all characters have been printed, then reset the interrupt mask to the previous
value.
Once the outConsole( ) routine is created with the prototype specified above, it is
possible to create a kprintf( ) routine to allow formatted output. The source code
is similar to the following:
int kprintf
(
const char * fmt, /* format string to write */
... /* optional arguments to format string */
)
{
va_list vaList; /* traverses argument list */
int nChars;
va_start (vaList, fmt);
nChars = fioFormatV (fmt, vaList, outConsole, 1);
va_end (vaList);
return (nChars);
}
NOTE: This suggested source code for kprintf( ) assumes that formatted I/O is
configured into the system. However, this may not be the case for your system.
When you are ready to finalize your BSP, the kprintf( ) routine should be
surrounded by #ifdef INCLUDE_STDIO and #endif /* INCLUDE_STDIO */
statements to avoid pulling in the formatted I/O module unexpectedly. As an
alternative, you can write a kprintf( ) routine without calling fioFormatV( ).
However, the non-standard I/O implementation requires more development
effort.
Vista de pagina 70
1 2 ... 66 67 68 69 70 71 72 73 74 75 76 ... 188 189

Comentarios a estos manuales

Sin comentarios