Commit cf016be7 authored by dan.eichel's avatar dan.eichel
Browse files

initial version 1.0

parents
#Makefile at top of application tree
TOP = .
include $(TOP)/configure/CONFIG
DIRS := configure src
include $(TOP)/configure/RULES_TOP
#CONFIG
include $(TOP)/configure/CONFIG_APP
# Add any changes to make definitions here
#CROSS_COMPILER_TARGET_ARCHS =
# Use this when your IOC and the host use different paths
# to access the application. Typically this will be
# used with the Microsoft FTP server or with NFS mounts. Use
# is indicated by failure of the cdCommands script on
# vxWorks. You must rebuild in the iocBoot directory
# before this takes effect.
#IOCS_APPL_TOP = <the top of the application as seen by the IOC>
# CONFIG_APP
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH)
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
CONFIG=$(EPICS_BASE)/configure
include $(CONFIG)/CONFIG
INSTALL_LOCATION = $(TOP)
ifdef INSTALL_LOCATION_APP
INSTALL_LOCATION = $(INSTALL_LOCATION_APP)
endif
ifdef T_A
-include $(TOP)/configure/O.$(T_A)/CONFIG_APP_INCLUDE
endif
# dbst based database optimization (default: NO)
DB_OPT = NO
############## Start BSP Specific Additions ##################
# Debug FLAGS needed for bsp specific code
USR_CFLAGS_vxWorks-68040 += -DHAVE_MVME162
USR_CFLAGS_vxWorks-ppc603 += -DHAVE_MVME2100
USR_CFLAGS_vxWorks-ppc604_long += -DHAVE_MVME2400
# VxWorks include directory paths
USR_INCLUDES_vxWorks += -I $(VX_DIR)/target/config/all
USR_INCLUDES_vxWorks += -I $(VX_DIR)/target/config
############## End BSP Specific Additions ##################
# Makefile
TOP=..
include $(TOP)/configure/CONFIG
# Set the following to NO to disable consistency checking of
# the support applications defined in $(TOP)/configure/RELEASE
CHECK_RELEASE = YES
TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
include $(TOP)/configure/RULES
#RELEASE Location of external products
# Run "gnumake clean uninstall install" in the application
# top directory each time this file is changed.
#
# NOTE: The build does not check dependancies on files
# external to this application. Thus you should run
# "gnumake clean uninstall install" in the top directory
# each time EPICS_BASE, SNCSEQ, or any other external
# module defined in the RELEASE file is rebuilt.
#TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
# If you don't want to install into $(TOP) then
# define INSTALL_LOCATION_APP here
#INSTALL_LOCATION_APP=<fullpathname>
#If using the sequencer, point SNCSEQ at its top directory:
#SNCSEQ=$(EPICS_BASE)/../modules/soft/seq
# EPICS_BASE usually appears last so other apps can override stuff:
EPICS_BASE=/opt/Epics/R3.14.10/base/3-14-10-0-1
#Capfast users may need the following definitions
#CAPFAST_TEMPLATES=
#SCH2EDIF_PATH=
#CONFIG
include $(EPICS_BASE)/configure/RULES
# Library should be rebuilt because LIBOBJS may have changed.
$(LIBNAME): ../Makefile
#RULES.ioc
include $(EPICS_BASE)/configure/RULES.ioc
#RULES_DIRS
include $(EPICS_BASE)/configure/RULES_DIRS
#RULES_TOP
include $(EPICS_BASE)/configure/RULES_TOP
TOP = ..
include $(TOP)/configure/CONFIG_APP
#-----------------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
INC += VMEtas.h
LIBRARY_IOC = VMEtas
LIB_SRCS_DEFAULT = VMEtas_nop.c
LIB_SRCS_vxWorks = VMEtas_vxWorks.c
ifeq ($(T_A),RTEMS-mvme2100)
LIB_SRCS_RTEMS = VMEtas_RTEMS-UniverseII.c
endif
ifeq ($(T_A),RTEMS-mvme5500)
LIB_SRCS_RTEMS = VMEtas_RTEMS-UniverseII.c
endif
include $(TOP)/configure/RULES
#-----------------------------------------------
# ADD RULES AFTER THIS LINE
/*+*********************************************************************
*
* File: VMEtas.h
*
* Descr.: test and set a VME byte addr
*
* Author(s): Dan Eichel
*
* Copyright (c) 2010 by Berliner Elektronenspeicherring-Gesellschaft
* fuer Synchrotronstrahlung m.b.H.,
* Berlin, Germany
*
*********************************************************************-*/
#ifndef INCVMEtash
#define INCVMEtash
extern int VMEtas(unsigned char *addr);
#endif /* ifndef INCVMEtash */
/*+*********************************************************************
*
* File: VMEtas_RTEMS-UniverseII.c
*
* Descr.: test and set a VME byte addr
*
* Author(s): Dan Eichel
*
* Copyright (c) 2010 by Berliner Elektronenspeicherring-Gesellschaft
* fuer Synchrotronstrahlung m.b.H.,
* Berlin, Germany
*
*********************************************************************-*/
/*----------------------------------------------------*/
/* History */
/*----------------------------------------------------*/
/*
Version 1.0:
testest only for MVME2100 boards. The BSP for the MVME5500 CPUs
seems to be buggy, so that no RTEMS Application can be executed
on such IOCs. Different RTEMS versions from 4.9.0 until 4.9.4 with
several BSP patches were tried, but none worked, so the behavior on
this kind of IOCs is untested! (Date 2010-11-11)
*/
/*----------------------------------------------------*/
/* General Comments */
/*----------------------------------------------------*/
/*
The ppc handles data as big endian but all pci memory mapped registers / IO
space are handled as little endian. So we have to reverse the byte order for
accessing such memory parts.
bosi_test_and_set - test and set a location across the VMEbus utilizing RMW
This routine performs a test-and-set (TAS) instruction on the specified
address, which must be on a different VME board. This function emulates the
TAS function known from the mc68000 processors. For compatibility with the old
motorola CPUs only the highest bit in the adressed byte will be affected.
Unfortunally in this special mode the Universe II can only access adresses
they are four byte aligned, so we have to program the 32bit mask register
to access the right byte. (cf. Universe II User Manual, Chapter 3.4.5.1
Read-Modify-Write, Page 79 for detailed description)
NOTE: bosi_test_and_set can only test-and-set locations across the VMEbus,
local addresses may be tested but never set.
RETURNS: TRUE if the value had not been set but is now
FALSE if the value was already set. */
#include <rtems.h> /* rtems_interrupt_disable */
#include <stdio.h> /* FILE * */
#include <bsp/vmeUniverse.h> /* register offsets and constants */
#include <bsp.h> /* PCI_DRAM_OFFSET */
#include "VMEtas.h"
int VMEtas(unsigned char *addr)
{
int state;
rtems_interrupt_level level;
/* due to the four byte alignment, the position of the target byte may vary */
/* with respect to the ppc endianness the mask's byte order is reversed */
unsigned long mask = 0x80000000 >> ((unsigned long) addr & 0x3) * 8;
unsigned long register dummy;
/* Lock interrupts so that issuing RMW are atomic */
rtems_interrupt_disable(level);
*(unsigned long *) ((unsigned long) vmeUniverse0BaseAddr + UNIV_REGOFF_SCYC_EN) = mask;
*(unsigned long *) ((unsigned long) vmeUniverse0BaseAddr + UNIV_REGOFF_SCYC_CMP) = 0x0;
*(unsigned long *) ((unsigned long) vmeUniverse0BaseAddr + UNIV_REGOFF_SCYC_SWP) = 0x80808080;
/* Convert RMW address into the PCI address space and write it into
the UniverseII's UNIV_REGOFF_SCYC_ADDR register with respect
of the PPCs endianness */
__asm__ volatile ("stwbrx %1,0,%2"
: "=r" (dummy)
: "r" ((unsigned long) addr + PCI_DRAM_OFFSET),
"r" ((unsigned long) vmeUniverse0BaseAddr + UNIV_REGOFF_SCYC_ADDR)
);
/* generate a RMW cycle, triggerd be the next read access on addr */
*(unsigned long *) ((unsigned long) vmeUniverse0BaseAddr + UNIV_REGOFF_SCYC_CTL) =
UNIV_SCYC_CTL_SCYC_RMW << 24;
/* perform RMW to try and set TAS location */
state = *addr;
__asm__ volatile ("sync");
*(unsigned long *) ((unsigned long) vmeUniverse0BaseAddr + UNIV_REGOFF_SCYC_CTL) = 0; /* Disable RMW cycle */
rtems_interrupt_enable(level);
/* return TAS test result */
return (state & 0x80) ? (0) : (1);
}
/*+*********************************************************************
*
* File: VMEtas_nop.c
*
* Descr.: test and set a VME byte addr
*
* Author(s): Dan Eichel
*
* Copyright (c) 2010 by Berliner Elektronenspeicherring-Gesellschaft
* fuer Synchrotronstrahlung m.b.H.,
* Berlin, Germany
*
*********************************************************************-*/
#include <stdio.h>
#include "VMEtas.h"
int VMEtas(unsigned char *addr)
{
printf("WARNING: VMEtas() not implemented for this arch!\n");
return 1; /* always true */
}
/*+*********************************************************************
*
* File: VMEtas_vxWorks.c
*
* Descr.: test and set a VME byte addr
*
* Author(s): Dan Eichel
*
* Copyright (c) 2010 by Berliner Elektronenspeicherring-Gesellschaft
* fuer Synchrotronstrahlung m.b.H.,
* Berlin, Germany
*
*********************************************************************-*/
#include <sysLib.h>
#include "VMEtas.h"
int VMEtas(unsigned char *addr)
{
return (0 == sysBusTas((char *)addr));
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment