Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:08

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  * This routine polls to see if a packet has arrived.  If one
0006  * has it informs the executive. It uses a Classic API Timer
0007  */
0008 
0009 /*
0010  *  COPYRIGHT (c) 1989-2008, 2016.
0011  *  On-Line Applications Research Corporation (OAR).
0012  *
0013  * Redistribution and use in source and binary forms, with or without
0014  * modification, are permitted provided that the following conditions
0015  * are met:
0016  * 1. Redistributions of source code must retain the above copyright
0017  *    notice, this list of conditions and the following disclaimer.
0018  * 2. Redistributions in binary form must reproduce the above copyright
0019  *    notice, this list of conditions and the following disclaimer in the
0020  *    documentation and/or other materials provided with the distribution.
0021  *
0022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0023  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0025  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0026  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0027  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0028  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0029  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0030  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0032  * POSSIBILITY OF SUCH DAMAGE.
0033  */
0034 
0035 #include <rtems/score/sysstate.h>
0036 #include <rtems/score/watchdogimpl.h>
0037 
0038 #include "shm_driver.h"
0039 
0040 static void Shm_Poll_Set_timer( Watchdog_Control *the_watchdog )
0041 {
0042   Per_CPU_Control  *cpu;
0043   ISR_lock_Context  lock_context;
0044 
0045   cpu = _Watchdog_Get_CPU( the_watchdog );
0046   _ISR_lock_ISR_disable( &lock_context );
0047   _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
0048   _Watchdog_Insert(
0049     &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ],
0050     the_watchdog,
0051     cpu->Watchdog.ticks + 1
0052   );
0053   _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
0054   _ISR_lock_ISR_enable( &lock_context );
0055 }
0056 
0057 static void Shm_Poll_TSR( Watchdog_Control *the_watchdog )
0058 {
0059   uint32_t tmpfront;
0060 
0061   /*
0062    *  This should NEVER happen but just in case.
0063    */
0064   if (!_System_state_Is_up(_System_state_Get()))
0065     return;
0066 
0067   tmpfront = Shm_Local_receive_queue->front;
0068   if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list ) {
0069     rtems_multiprocessing_announce();
0070     Shm_Interrupt_count++;
0071   }
0072 
0073   Shm_Poll_Set_timer( the_watchdog );
0074 }
0075 
0076 static Watchdog_Control Shm_Poll_Watchdog = WATCHDOG_INITIALIZER(
0077   Shm_Poll_TSR
0078 );
0079 
0080 void Shm_install_timer(void)
0081 {
0082   Shm_Poll_Set_timer( &Shm_Poll_Watchdog );
0083 }