1    /*
     2     * Copyright (c) 2013, Texas Instruments Incorporated
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions
     7     * are met:
     8     *
     9     * *  Redistributions of source code must retain the above copyright
    10     *    notice, this list of conditions and the following disclaimer.
    11     *
    12     * *  Redistributions in binary form must reproduce the above copyright
    13     *    notice, this list of conditions and the following disclaimer in the
    14     *    documentation and/or other materials provided with the distribution.
    15     *
    16     * *  Neither the name of Texas Instruments Incorporated nor the names of
    17     *    its contributors may be used to endorse or promote products derived
    18     *    from this software without specific prior written permission.
    19     *
    20     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    22     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    23     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    27     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    28     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    29     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    30     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31     */
    32    
    33    /*
    34     *  ======== SysStd.xdc ========
    35     *  SMP aware SysStd replacement
    36     */
    37    
    38    package ti.sysbios.smp;
    39    
    40    /*!
    41     *  ======== SysStd ========
    42     *  Implementation of `{@link xdc.runtime.ISystemSupport}` using ANSI C Standard Library
    43     *
    44     *  This implementation provides a fully functional implementation of
    45     *  all methods specified by `ISystemSupport`. As with all
    46     *  `ISystemSupport` modules, this module is the back-end for the
    47     *  `{@link xdc.runtime.System}` module.
    48     *
    49     *  This implementation relies on the target's runtime support libraries
    50     *  (i.e. `fflush()` and `putchar()`). Therefore the  functions are re-entrant
    51     *  (thread-safe) if the underlying rts library is re-entrant.
    52     */
    53    @CustomHeader
    54    module SysStd inherits xdc.runtime.ISystemSupport {
    55        /*!
    56         *  ======== abort ========
    57         *  Backend for `{@link xdc.runtime.System#abort()}`
    58         *
    59         *  This abort function writes the string via `putchar()`
    60         *  and flushes via `fflush()` to `stdout`.
    61         *
    62         *  @see xdc.runtime.ISystemSupport#abort
    63         */
    64        override Void abort(CString str);
    65    
    66        /*!
    67         *  ======== exit ========
    68         *  Backend for `{@link xdc.runtime.System#exit()}`
    69         *
    70         *  This exit function flushes via `fflush()` to `stdout`.
    71         *
    72         *  @see xdc.runtime.ISystemSupport#exit
    73         */
    74        override Void exit(Int stat);
    75    
    76        /*!
    77         *  ======== flush ========
    78         *  Backend for `{@link xdc.runtime.System#flush()}`
    79         *
    80         *  This flush function flushes via `fflush()` to `stdout`.
    81         *
    82         *  @see xdc.runtime.ISystemSupport#flush
    83         */
    84        override Void flush();
    85    
    86        /*!
    87         *  ======== putch ========
    88         *  Backend for `{@link xdc.runtime.System#printf()}` and `{@link xdc.runtime.System#putch()}`
    89         *
    90         *  This function outputs the character via `putchar()`.
    91         *
    92         *  @see xdc.runtime.ISystemSupport#putch
    93         */
    94        override Void putch(Char ch);
    95    
    96        /*!
    97         *  ======== ready ========
    98         *  Test if character output can proceed
    99         *
   100         *  This always returns TRUE.
   101         *
   102         *  @see xdc.runtime.ISystemSupport#ready
   103         */
   104        override Bool ready();
   105    
   106    internal:
   107    
   108        struct LineBuffer {
   109            UInt outidx;    /* index within outbuf to next Char to write */
   110            Char outbuf[256];
   111        }
   112    
   113        struct Module_State {
   114            LineBuffer lineBuffers[];
   115        };
   116    
   117    }