Changeset d65b2da in rtems


Ignore:
Timestamp:
Nov 18, 2008, 11:28:53 AM (11 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.9
Children:
eb32e3a
Parents:
2fafea2
Message:

libchip/serial/ns16550.c: Transmit the character in the polled write
function within a critical section for printk() compatibility.

Location:
c/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/ChangeLog

    r2fafea2 rd65b2da  
     12008-11-13      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * libchip/serial/ns16550.c: Transmit the character in the polled write
     4        function within a critical section for printk() compatibility.
     5
    162008-09-10      Ralf Corsépius <ralf.corsepius@rtems.org>
    27
  • c/src/libchip/serial/ns16550.c

    r2fafea2 rd65b2da  
    184184}
    185185
    186 /*
    187  *  ns16550_write_polled
    188  */
    189 
    190 NS16550_STATIC void ns16550_write_polled(
    191   int   minor,
    192   char  cChar
    193 )
    194 {
    195   uint32_t                pNS16550;
    196   unsigned char           ucLineStatus;
    197   getRegister_f           getReg;
    198   setRegister_f           setReg;
    199 
    200   pNS16550 = Console_Port_Tbl[minor].ulCtrlPort1;
    201   getReg   = Console_Port_Tbl[minor].getRegister;
    202   setReg   = Console_Port_Tbl[minor].setRegister;
    203 
    204   /*
    205    * wait for transmitter holding register to be empty
    206    */
    207   ucLineStatus = (*getReg)(pNS16550, NS16550_LINE_STATUS);
    208   while ((ucLineStatus & SP_LSR_THOLD) == 0) {
    209     /*
    210      * Yield while we wait
    211      */
    212 #if 0
    213      if(_System_state_Is_up(_System_state_Get())) {
    214        rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
    215      }
    216 #endif
    217      ucLineStatus = (*getReg)(pNS16550, NS16550_LINE_STATUS);
    218   }
    219 
    220   /*
    221    * transmit character
    222    */
    223   (*setReg)(pNS16550, NS16550_TRANSMIT_BUFFER, cChar);
     186/**
     187 * @brief Polled write for NS16550.
     188 */
     189NS16550_STATIC void ns16550_write_polled( int minor, char c)
     190{
     191  uint32_t port = Console_Port_Tbl [minor].ulCtrlPort1;
     192  getRegister_f get = Console_Port_Tbl [minor].getRegister;
     193  setRegister_f set = Console_Port_Tbl [minor].setRegister;
     194  uint32_t status;
     195  rtems_interrupt_level level;
     196
     197  while (1) {
     198    /* Try to transmit the character in a critical section */
     199    rtems_interrupt_disable( level);
     200
     201    /* Read the transmitter holding register and check it */
     202    status = get( port, NS16550_LINE_STATUS);
     203    if ((status & SP_LSR_THOLD) != 0) {
     204      /* Transmit character */
     205      set( port, NS16550_TRANSMIT_BUFFER, c);
     206
     207      /* Finished */
     208      rtems_interrupt_enable( level);
     209      break;
     210    } else {
     211      rtems_interrupt_enable( level);
     212    }
     213
     214    /* Wait for transmitter holding register to be empty */
     215    do {
     216      status = get( port, NS16550_LINE_STATUS);
     217    } while ((status & SP_LSR_THOLD) == 0);
     218  }
    224219}
    225220
Note: See TracChangeset for help on using the changeset viewer.