1    /*
     2     * Copyright (c) 2016, 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     *  ======== SysUart.xdc ========
    35     *  UART based SysStd replacement
    36     */
    37    
    38    /*!
    39     *  ======== SysUart ========
    40     *  Implementation of `{@link xdc.runtime.ISystemSupport}` using
    41     *  ANSI C Standard Library
    42     *
    43     *  This implementation provides a fully functional implementation of
    44     *  all methods specified by `ISystemSupport`. As with all
    45     *  `ISystemSupport` modules, this module is the back-end for the
    46     *  `{@link xdc.runtime.System}` module.
    47     *
    48     *  This implementation relies on the target's runtime support libraries
    49     *  (i.e. `fflush()` and `putchar()`). Therefore the  functions are re-entrant
    50     *  (thread-safe) if the underlying rts library is re-entrant.
    51     */
    52    @ModuleStartup
    53    module SysUart inherits xdc.runtime.ISystemSupport {
    54    
    55        /*!
    56         *  UART peripheral base address.
    57         *
    58         *  These enumerations are the base addresses of the different
    59         *  UART peripherals.
    60         */
    61        enum Uart {
    62            Uart0 = 0x42300000,    /*! UART0 Base Address */
    63            Uart1 = 0x40A00000,    /*! UART1 Base Address */
    64            Uart2 = 0x02800000,    /*! UART2 Base Address */
    65            Uart3 = 0x02810000,    /*! UART3 Base Address */
    66            Uart4 = 0x02820000     /*! UART4 Base Address */
    67        };
    68    
    69        config Ptr uartBaseAddr;
    70    
    71        /*!
    72         *  ======== abort ========
    73         *  Backend for `{@link xdc.runtime.System#abort()}`
    74         *
    75         *  This abort function writes the string via `putchar()`
    76         *  and flushes via `fflush()` to `stdout`.
    77         *
    78         *  @see xdc.runtime.ISystemSupport#abort
    79         */
    80        override Void abort(CString str);
    81    
    82        /*!
    83         *  ======== exit ========
    84         *  Backend for `{@link xdc.runtime.System#exit()}`
    85         *
    86         *  This exit function flushes via `fflush()` to `stdout`.
    87         *
    88         *  @see xdc.runtime.ISystemSupport#exit
    89         */
    90        override Void exit(Int stat);
    91    
    92        /*!
    93         *  ======== flush ========
    94         *  Backend for `{@link xdc.runtime.System#flush()}`
    95         *
    96         *  This flush function flushes via `fflush()` to `stdout`.
    97         *
    98         *  @see xdc.runtime.ISystemSupport#flush
    99         */
   100        override Void flush();
   101    
   102        /*!
   103         *  ======== putch ========
   104         *  Backend for `{@link xdc.runtime.System#printf()}` and `{@link xdc.runtime.System#putch()}`
   105         *
   106         *  This function outputs the character via `putchar()`.
   107         *
   108         *  @see xdc.runtime.ISystemSupport#putch
   109         */
   110        override Void putch(Char ch);
   111    
   112        /*!
   113         *  ======== ready ========
   114         *  Test if character output can proceed
   115         *
   116         *  This always returns TRUE.
   117         *
   118         *  @see xdc.runtime.ISystemSupport#ready
   119         */
   120        override Bool ready();
   121    }