Something went wrong on our end
-
Ezekiel Dohmen authoredEzekiel Dohmen authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
rcguserCommon.c 3.13 KiB
/// @file rcguserCommon.c
/// @brief File contains routines for user app startup
#include "print_io_info.h"
#include "controller.h"
#include "findSharedMemory.h"
#include "util/printl.h"
#include <stddef.h>
#include <stdio.h>
// **********************************************************************************************
// Capture SIGHALT from ControlC
void
intHandler( int signal)
{
(void) signal;
pLocalEpics->epicsInput.vmeReset = 1;
printl( "Received exit signal, exiting...\n" );
}
// **********************************************************************************************
int
attach_shared_memory( char* sysname )
{
char shm_name[ 64 ];
// epics shm used to communicate with model's EPICS process
sprintf( shm_name, "%s", sysname );
_epics_shm = (volatile char*) findSharedMemory( sysname );
if ( _epics_shm == NULL )
{
printl( "mbuf_allocate_area() failed; ret = %p\n", _epics_shm );
return -1;
}
printl( "EPICSM at %p\n", _epics_shm );
// testpoint config shm used to control testpoints from awgtpman
sprintf( shm_name, "%s%s", sysname, SHMEM_TESTPOINT_SUFFIX );
_tp_shm = (volatile TESTPOINT_CFG *) findSharedMemory( sysname );
if ( _tp_shm == NULL )
{
printl( "mbuf_allocate_area(tp) failed; ret = %p\n", _tp_shm );
return -1;
}
printl( "TPSM at %p\n", _tp_shm );
// awg data shm used to stream data from awgtpman
sprintf( shm_name, "%s%s", sysname, SHMEM_AWG_SUFFIX );
_awg_shm = (volatile AWG_DATA *) findSharedMemory( sysname );
if ( _awg_shm == NULL )
{
printl( "mbuf_allocate_area(awg) failed; ret = %p\n", _awg_shm );
return -1;
}
printl( "AWGSM at %p\n", _awg_shm );
// ipc_shm used to communicate with IOP
_ipc_shm = (char*)findSharedMemory( "ipc" );
if ( _ipc_shm == NULL )
{
printl( "mbuf_allocate_area(ipc) failed; ret = %p\n", _ipc_shm );
return -1;
}
printl( "IPC at %p\n", _ipc_shm );
ioMemData = (volatile IO_MEM_DATA*)( ( (char*)_ipc_shm ) + 0x4000 );
printl("IOMEM at %p size 0x%lx\n", ioMemData, sizeof( IO_MEM_DATA ) );
printl( "%d PCI cards found\n", ioMemData->totalCards );
// DAQ is via shared memory
sprintf( shm_name, "%s_daq", sysname );
_daq_shm = (char*) findSharedMemory( shm_name );
if ( _daq_shm == NULL )
{
printl( "mbuf_allocate_area() failed; ret = %p\n", _daq_shm );
return -1;
}
printl( "DAQSM at %p\n", _daq_shm );
daqPtr = (struct rmIpcStr*)_daq_shm;
// shmipc is used to send SHMEM IPC data between processes on same computer
_shmipc_shm = (char*) findSharedMemory( "shmipc" );
if ( _shmipc_shm == NULL )
{
printl( "mbuf_allocate_area() failed; ret = %p\n", _shmipc_shm );
return -1;
}
// Open new IO shared memory in support of no hardware I/O
_io_shm = (char*) findSharedMemory( "virtual_io_space" );
if ( _io_shm == NULL )
{
printl( "mbuf_allocate_area() failed; ret = %p\n", _io_shm );
return -1;
}
ioMemDataIop = (volatile IO_MEM_DATA_IOP*)( ( (char*)_io_shm ) );
return 0;
}