Ignore:
Timestamp:
Apr 26, 2017, 2:14:33 PM (7 years ago)
Author:
alain
Message:

Modify the boot_info_t struct to describe external peripherals in all clusters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bootloader_tsar/boot_tty_driver.c

    r1 r6  
    1 ///////////////////////////////////////////////////////////////////////////////////
    2 // File     : boot_tty_driver.c
    3 // Date     : 18/01/2017
    4 // Author   : Alain Greiner / Vu Son
    5 // Copyright (c) UPMC-LIP6
    6 ///////////////////////////////////////////////////////////////////////////////////
     1/*
     2 * boot_tty_driver.c - TSAR bootloader TTY driver implementation.
     3 *
     4 * Authors :   Alain Greiner / Vu Son  (2016)
     5 *
     6 * Copyright (c) UPMC Sorbonne Universites
     7 *
     8 * This file is part of ALMOS-MKH.
     9 *
     10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
     11 * under the terms of the GNU General Public License as published by
     12 * the Free Software Foundation; version 2.0 of the License.
     13 *
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
     15 * WITHOUT ANY WARRANTY; without even the implied warranty of
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     17 * General Public License for more details.
     18 *
     19 * You should have received a copy of the GNU General Public License
     20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
     21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
     22 */
    723
    824#include <boot_config.h>
     
    1127#include <boot_utils.h>
    1228
    13 #ifndef SEG_TTY_BASE
    14 # error "The SEG_TTY_BASE value should be defined in the 'boot_config.h' file"
     29#ifndef SEG_TXT_BASE
     30# error "The SEG_TXT_BASE value should be defined in the 'hard_config.h' file"
    1531#endif
    1632
    17 #ifndef IO_CXY
    18 # error "The IO_CXY value should be defined in the 'boot_config.h' file"
     33#ifndef X_IO 
     34# error "The X_IO value should be defined in the 'hard_config.h' file"
     35#endif
     36
     37#ifndef Y_IO 
     38# error "The Y_IO value should be defined in the 'hard_config.h' file"
     39#endif
     40
     41#ifndef Y_WIDTH
     42# error "The Y_WIDTH value should be defined in the 'hard_config.h' file"
    1943#endif
    2044
    2145
    22 /****************************************************************************
    23  *                            Internal functions.                           *
    24  ****************************************************************************/
    25 
    26 /****************************************************************************
    27  * This function returns the value of the a TTY register.                   *
    28  * @ reg    : TTY register to be read.                                      *
    29  * @ returns the value stored in 'reg'.                                     *
    30  ****************************************************************************/
     46/////////////////////////////////////////////////////////////////////////////
     47// This function returns the value contained in a TTY0 register.
     48// @ reg    : register to be read.
     49// @ returns the value stored in 'reg'.
     50/////////////////////////////////////////////////////////////////////////////
    3151static uint32_t boot_tty_get_register( uint32_t reg )
    3252{
    33     cxy_t      cxy = IO_CXY;
    34     uint32_t * ptr = (uint32_t *)SEG_TTY_BASE + reg;
     53    cxy_t      cxy = (X_IO << Y_WIDTH) + Y_IO;
     54    uint32_t * ptr = (uint32_t *)SEG_TXT_BASE + reg;
    3555   
    3656    return boot_remote_lw( XPTR( cxy , ptr ) );
     
    3858} // boot_tty_get_register()
    3959
    40 /****************************************************************************
    41  * This function sets a new value to a TTY register.                        *
    42  * @ reg    : TTY register to be configured.                                *
    43  * @ val    : new value to be written to 'reg'.                             *
    44  ****************************************************************************/
     60/////////////////////////////////////////////////////////////////////////////
     61// This function sets a new value to a TTY0 register.
     62// @ reg    : register to be configured.
     63// @ val    : new value to be written to 'reg'.
     64/////////////////////////////////////////////////////////////////////////////
    4565static void boot_tty_set_register( uint32_t reg,
    4666                                   uint32_t val )
    4767{
    48     cxy_t      cxy = IO_CXY;
    49     uint32_t * ptr = (uint32_t *)SEG_TTY_BASE + reg;
     68    cxy_t      cxy = (X_IO << Y_WIDTH) + Y_IO;
     69    uint32_t * ptr = (uint32_t *)SEG_TXT_BASE + reg;
    5070
    5171    boot_remote_sw( XPTR( cxy , ptr ) , val );
     
    5373} // boot_tty_set_register()
    5474
    55 /****************************************************************************
    56  *                           Driver API functions.                          *
    57  ****************************************************************************/
    58 
     75//////////////////////////////////
    5976int boot_tty_write( char    * buf,
    6077                    uint32_t  nbytes )
    6178{
    62     uint32_t nb_printed;    /* Iterator for printing loop.              */
    63     uint32_t nb_test;       /* Iterator for retry loop.                 */
    64     uint32_t error;         /* Used to detect if an error occurs.       */
     79    uint32_t nb_printed;
     80    uint32_t nb_test;
     81    uint32_t error;
    6582
    66     /* Printing to the boot TTY terminal. */
     83    // Print nbytes to TTY0 terminal
    6784    for (nb_printed = 0; nb_printed < nbytes; nb_printed++)
    6885    {
    69         // Polling the TTY driver status.
    70         if ((boot_tty_get_register(TTY_STATUS) & TTY_WRITE_BUSY))
     86        // Poll the TTY0 status.
     87        if ((boot_tty_get_register(TTY_STATUS_REG) & TTY_STATUS_TX_FULL))
    7188        {
    72             // TTY_WRITE_BUSY bit of TTY_STATUS register is set, keeps polling.
    7389            error = 1;
    7490            for (nb_test = 0; nb_test < 10000; nb_test++)
    75                 if ((boot_tty_get_register(TTY_STATUS) & TTY_WRITE_BUSY) == 0)
     91            {
     92                if ((boot_tty_get_register(TTY_STATUS_REG) & TTY_STATUS_TX_FULL) == 0)
    7693                {
    7794                    error = 0;
    7895                    break;
    7996                }
     97            }
    8098
    81             // Reporting an error if the TTY_WRITE_BUSY bit is still set after
    82             // 10000 retries.
    83             if (error)
    84                 return -1;
     99            // Report error after 10000 retries.
     100            if (error) return -1;
    85101        }
    86102
    87         // Writing a character to the boot TTY terminal.
     103        // Write one character to TTY0 terminal.
    88104        // Special treatment for a newline: Carriage Return before Line Feed.
    89         if (buf[nb_printed] == '\n')
    90             boot_tty_set_register(TTY_WRITE, (uint32_t)'\r');
    91         boot_tty_set_register(TTY_WRITE, (uint32_t)buf[nb_printed]);
     105        if (buf[nb_printed] == '\n') boot_tty_set_register(TTY_WRITE_REG , (uint32_t)'\r');
     106        boot_tty_set_register(TTY_WRITE_REG , (uint32_t)buf[nb_printed]);
    92107    }
    93108
Note: See TracChangeset for help on using the changeset viewer.