Changeset 9151ec6 in rtems for c/src/libchip


Ignore:
Timestamp:
Nov 18, 2008, 9:20:18 AM (11 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, master
Children:
d11ea4eb
Parents:
1e0f03b5
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/libchip/serial/ns16550.c

    r1e0f03b5 r9151ec6  
    197197}
    198198
    199 /*
    200  *  ns16550_write_polled
    201  */
    202 
    203 NS16550_STATIC void ns16550_write_polled(
    204   int   minor,
    205   char  cChar
    206 )
    207 {
    208   uint32_t                pNS16550;
    209   unsigned char           ucLineStatus;
    210   getRegister_f           getReg;
    211   setRegister_f           setReg;
    212 
    213   pNS16550 = Console_Port_Tbl[minor].ulCtrlPort1;
    214   getReg   = Console_Port_Tbl[minor].getRegister;
    215   setReg   = Console_Port_Tbl[minor].setRegister;
    216 
    217   /*
    218    * wait for transmitter holding register to be empty
    219    */
    220   ucLineStatus = (*getReg)(pNS16550, NS16550_LINE_STATUS);
    221   while ((ucLineStatus & SP_LSR_THOLD) == 0) {
    222     /*
    223      * Yield while we wait
    224      */
    225 #if 0
    226      if(_System_state_Is_up(_System_state_Get())) {
    227        rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
    228      }
    229 #endif
    230      ucLineStatus = (*getReg)(pNS16550, NS16550_LINE_STATUS);
    231   }
    232 
    233   /*
    234    * transmit character
    235    */
    236   (*setReg)(pNS16550, NS16550_TRANSMIT_BUFFER, cChar);
     199/**
     200 * @brief Polled write for NS16550.
     201 */
     202NS16550_STATIC void ns16550_write_polled( int minor, char c)
     203{
     204  uint32_t port = Console_Port_Tbl [minor].ulCtrlPort1;
     205  getRegister_f get = Console_Port_Tbl [minor].getRegister;
     206  setRegister_f set = Console_Port_Tbl [minor].setRegister;
     207  uint32_t status;
     208  rtems_interrupt_level level;
     209
     210  while (1) {
     211    /* Try to transmit the character in a critical section */
     212    rtems_interrupt_disable( level);
     213
     214    /* Read the transmitter holding register and check it */
     215    status = get( port, NS16550_LINE_STATUS);
     216    if ((status & SP_LSR_THOLD) != 0) {
     217      /* Transmit character */
     218      set( port, NS16550_TRANSMIT_BUFFER, c);
     219
     220      /* Finished */
     221      rtems_interrupt_enable( level);
     222      break;
     223    } else {
     224      rtems_interrupt_enable( level);
     225    }
     226
     227    /* Wait for transmitter holding register to be empty */
     228    do {
     229      status = get( port, NS16550_LINE_STATUS);
     230    } while ((status & SP_LSR_THOLD) == 0);
     231  }
    237232}
    238233
Note: See TracChangeset for help on using the changeset viewer.