noisII & FPGA
This commit is contained in:
parent
8b502754ed
commit
c663f73fea
37
FPGA_nios/.gitignore
vendored
37
FPGA_nios/.gitignore
vendored
@ -1,37 +0,0 @@
|
||||
# Eclipse project files
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# Build output
|
||||
Debug/
|
||||
Release/
|
||||
*.o
|
||||
*.elf
|
||||
*.bin
|
||||
*.hex
|
||||
*.srec
|
||||
*.map
|
||||
*.lst
|
||||
*.d
|
||||
|
||||
# Other generated files
|
||||
*.log
|
||||
*.tmp
|
||||
*.swp
|
||||
*.bak
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.user
|
||||
|
||||
# Eclipse metadata
|
||||
.metadata/
|
||||
|
||||
# OS-specific files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Other
|
||||
*.lst
|
||||
*.pt
|
@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<buildSystem id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701">
|
||||
<storageModule id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701" moduleId="org.eclipse.cdt.core.settings"/>
|
||||
</buildSystem>
|
||||
<cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701">
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701" name="Nios II" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701." name="/" resourcePath="">
|
||||
<toolChain id="altera.nios2.mingw.gcc4.290101512" name="MinGW Nios II GCC4" superClass="altera.nios2.mingw.gcc4">
|
||||
<targetPlatform id="altera.nios2.mingw.gcc4.747578136" name="Nios II" superClass="altera.nios2.mingw.gcc4"/>
|
||||
<builder arguments="make" buildPath="${workspace_loc://hit_pat}" command="wsl" id="altera.tool.gnu.builder.mingw.2134947271" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="altera.tool.gnu.builder.mingw"/>
|
||||
<tool id="altera.tool.gnu.c.compiler.mingw.1991127973" name="Nios II GCC C Compiler" superClass="altera.tool.gnu.c.compiler.mingw">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1507505746" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="altera.tool.gnu.cpp.compiler.mingw.2042376380" name="Nios II GCC C++ Compiler" superClass="altera.tool.gnu.cpp.compiler.mingw">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1433459345" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="altera.tool.gnu.archiver.mingw.590231873" name="Nios II GCC Archiver" superClass="altera.tool.gnu.archiver.mingw"/>
|
||||
<tool id="altera.tool.gnu.c.linker.mingw.261882629" name="Nios II GCC C Linker" superClass="altera.tool.gnu.c.linker.mingw"/>
|
||||
<tool id="altera.tool.gnu.assembler.mingw.1805628172" name="Nios II GCC Assembler" superClass="altera.tool.gnu.assembler.mingw">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1447125446" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701" moduleId="org.eclipse.cdt.core.settings" name="Nios II">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings">
|
||||
<externalSettings containerId="hit_pat_bsp;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier"/>
|
||||
</storageModule>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="hit_pat.null.665199943" name="hit_pat"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701.;altera.tool.gnu.c.compiler.mingw.1991127973;cdt.managedbuild.tool.gnu.c.compiler.input.1507505746">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.463028701.;altera.tool.gnu.cpp.compiler.mingw.2042376380;cdt.managedbuild.tool.gnu.cpp.compiler.input.1433459345">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||
<buildTargets>
|
||||
<target name="mem_init_install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>wsl</buildCommand>
|
||||
<buildArguments>make</buildArguments>
|
||||
<buildTarget>mem_init_install</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>false</runAllBuilders>
|
||||
</target>
|
||||
<target name="mem_init_generate" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>wsl</buildCommand>
|
||||
<buildArguments>make</buildArguments>
|
||||
<buildTarget>mem_init_generate</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>false</runAllBuilders>
|
||||
</target>
|
||||
<target name="help" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>wsl</buildCommand>
|
||||
<buildArguments>make</buildArguments>
|
||||
<buildTarget>help</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>false</runAllBuilders>
|
||||
</target>
|
||||
</buildTargets>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Nios II">
|
||||
<resource resourceType="PROJECT" workspacePath="/hit_pat"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
</cproject>
|
@ -1,131 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script creates the simple_socket_server application in this directory.
|
||||
|
||||
|
||||
BSP_DIR=../hit_pat_bsp
|
||||
QUARTUS_PROJECT_DIR=../../
|
||||
NIOS2_APP_GEN_ARGS="--elf-name hit_pat.elf --set OBJDUMP_INCLUDE_SOURCE 1 --src-files alt_error_handler.c iniche_init.c led.c network_utilities.c simple_socket_server.c tse_my_system.c"
|
||||
|
||||
# If script is launched from Windows through Windows Subsystem for Linux (WSL).
|
||||
# The adjust-path macro converts absolute windows
|
||||
# paths into unix style paths (Example: c:/dir -> /c/dir). This will ensure
|
||||
# paths are readable.
|
||||
uname=$(uname -r)
|
||||
if [[ $uname =~ "Microsoft" ]]; then
|
||||
_IS_WSL=1
|
||||
windows_exe=.exe
|
||||
fi
|
||||
|
||||
adjust_path() {
|
||||
if [ "${_IS_WSL}" = "1" ] && [[ ! $1 =~ ^\/mnt\/* ]]; then
|
||||
echo "$(wslpath -u "$1")"
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# First, check to see if $SOPC_KIT_NIOS2 environmental variable is set.
|
||||
# This variable is required for the command line tools to execute correctly.
|
||||
if [ -z "${SOPC_KIT_NIOS2}" ]
|
||||
then
|
||||
echo Required \$SOPC_KIT_NIOS2 Environmental Variable is not set!
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Also make sure that the APP has not been created already. Check for
|
||||
# existence of Makefile in the app directory
|
||||
if [ -f ./Makefile ]
|
||||
then
|
||||
echo Application has already been created! Delete Makefile if you want to create a new application makefile
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# We are selecting ucosii_net bsp because it supports this application.
|
||||
# Check to see if the ucosii_net has already been generated by checking for
|
||||
# existence of the public.mk file. If not, we need to run
|
||||
# create-this-bsp file to generate the bsp.
|
||||
if [ ! -f ${BSP_DIR}/public.mk ]; then
|
||||
# Since BSP doesn't exist, create the BSP
|
||||
# Pass any command line arguments passed to this script to the BSP.
|
||||
pushd "$(adjust_path ${BSP_DIR})" >> /dev/null
|
||||
./create-this-bsp "$@" || {
|
||||
echo "create-this-bsp failed"
|
||||
exit 1
|
||||
}
|
||||
popd >> /dev/null
|
||||
fi
|
||||
|
||||
|
||||
# Don't run make if create-this-app script is called with --no-make arg
|
||||
SKIP_MAKE=
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
--no-make)
|
||||
SKIP_MAKE=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
# Now we also need to go copy the sources for this application to the
|
||||
# local directory.
|
||||
find "${SOPC_KIT_NIOS2}/examples/software/simple_socket_server/" -name '*.c' -or -name '*.h' -or -name 'hostfs*' | xargs -i cp -L {} ./ || {
|
||||
echo "failed during copying example source files"
|
||||
exit 1
|
||||
}
|
||||
|
||||
find "${SOPC_KIT_NIOS2}/examples/software/simple_socket_server/" -name 'readme.txt' -or -name 'Readme.txt' | xargs -i cp -L {} ./ || {
|
||||
echo "failed copying readme file"
|
||||
}
|
||||
|
||||
if [ -d "${SOPC_KIT_NIOS2}/examples/software/simple_socket_server/system" ]
|
||||
then
|
||||
cp -RL "${SOPC_KIT_NIOS2}/examples/software/simple_socket_server/system" . || {
|
||||
echo "failed during copying project support files"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
chmod -R +w . || {
|
||||
echo "failed during changing file permissions"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cmd="nios2-app-generate-makefile$windows_exe --bsp-dir ${BSP_DIR} --set QUARTUS_PROJECT_DIR=${QUARTUS_PROJECT_DIR} ${NIOS2_APP_GEN_ARGS}"
|
||||
|
||||
echo "create-this-app: Running \"${cmd}\""
|
||||
$cmd || {
|
||||
echo "nios2-app-generate-makefile failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -z "$SKIP_MAKE" ]; then
|
||||
cmd="make"
|
||||
|
||||
echo "create-this-app: Running \"$cmd\""
|
||||
$cmd || {
|
||||
echo "make failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo
|
||||
echo "To download and run the application:"
|
||||
echo " 1. Make sure the board is connected to the system."
|
||||
echo " 2. Run 'nios2-configure-sof <SOF_FILE_PATH>' to configure the FPGA with the hardware design."
|
||||
echo " 3. If you have a stdio device, run 'nios2-terminal' in a different shell."
|
||||
echo " 4. Run 'make download-elf' from the application directory."
|
||||
echo
|
||||
echo "To debug the application:"
|
||||
echo " Import the project into Nios II Software Build Tools for Eclipse."
|
||||
echo " Refer to Nios II Software Build Tools for Eclipse Documentation for more information."
|
||||
echo
|
||||
echo -e ""
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
File diff suppressed because it is too large
Load Diff
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* control.h
|
||||
*
|
||||
* Created on: Aug 14, 2017
|
||||
* Author: mdziewiecki
|
||||
*/
|
||||
|
||||
#ifndef CONTROL_H_
|
||||
#define CONTROL_H_
|
||||
|
||||
//**************************
|
||||
|
||||
#include "dev_commands.h"
|
||||
|
||||
//**************************
|
||||
|
||||
#define CONTROL_TASK_PRIORITY 10
|
||||
#define CONTROL_STACK_SIZE (6144+8192)
|
||||
|
||||
#define CONTROL_MAX_DATA_LENGTH 16 //maximum command data length in WORDS (16-bit)
|
||||
#define CONTROL_TIMEOUT 1000 //timeout to get command data in unknown time units
|
||||
|
||||
#define CONTROL_PORT 4000
|
||||
#define DATA_PORT 4001
|
||||
|
||||
#define CONTROL_SWAP_BYTES 1 //playing around endianness in PC communication
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short marker; //must be 0x5555
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
} command_header;
|
||||
|
||||
//Initialize control task
|
||||
void control_init();
|
||||
|
||||
|
||||
#endif /* CONTROL_H_ */
|
@ -1,136 +0,0 @@
|
||||
#ifndef DEV_COMMANDS_H
|
||||
#define DEV_COMMANDS_H
|
||||
|
||||
//This file is derived from v.1 version and it's great if it's kept compatible
|
||||
//All sizes are in HALF-WORDS (16-bit)!
|
||||
|
||||
#define COMMAND_PING 0x0001
|
||||
//L: 0
|
||||
//D: []
|
||||
//Return the same
|
||||
|
||||
#define COMMAND_DEBUG_LED_OFF 0x0010
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Turn off LED 0
|
||||
|
||||
#define COMMAND_DEBUG_LED_ON 0x0011
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Turn on LED 0
|
||||
|
||||
// ***DEVICE CONTROL***
|
||||
|
||||
#define COMMAND_LEDS_DISABLE 0x0110
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Disable LED4 blinking. Other LEDs must be explicitly switched off
|
||||
|
||||
#define COMMAND_LEDS_ENABLE 0x0111
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Enable LED4 blinking
|
||||
|
||||
// ***TRIGGER SETTING***
|
||||
|
||||
#define COMMAND_TRIGGER_DISABLE 0x0210
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Disable trigger generation in master mode
|
||||
|
||||
#define COMMAND_TRIGGER_ENABLE 0x0211
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Enable trigger generation in master mode
|
||||
|
||||
#define COMMAND_TRIGGER_SET_SLAVE 0x0220
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Set trigger to slave mode
|
||||
|
||||
#define COMMAND_TRIGGER_SET_MASTER 0x0221
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Set trigger to master mode
|
||||
|
||||
#define COMMAND_TRIGGER_SET_PERIOD 0x0230
|
||||
//L: 1 L: 0
|
||||
//D: [Period_ticks] D: []
|
||||
//Set trigger period for master mode in timer ticks
|
||||
|
||||
#define COMMAND_TRIGGER_SET_TINT 0x0240
|
||||
//L: 1 L: 0
|
||||
//D: [Tint_ticks] D: []
|
||||
//Set integration time in timer ticks
|
||||
|
||||
#define COMMAND_SET_GAIN 0x0250
|
||||
//L: 1 L:0
|
||||
//D: [gain] D: []
|
||||
|
||||
#define COMMAND_TRIGGER_SET_MASTER_DELAY 0x0260
|
||||
//L: 1 L: 0
|
||||
//D: [Tdelay_ticks] D: []
|
||||
//Set trigger delay time in timer ticks for master mode.
|
||||
|
||||
#define COMMAND_TRIGGER_SET_SLAVE_DELAY 0x0270
|
||||
//L: 1 L: 0
|
||||
//D: [Tdelay_ticks] D: []
|
||||
//Set trigger delay time in timer ticks for slave mode.
|
||||
|
||||
|
||||
// ***DAQ CONTROL***
|
||||
|
||||
#define COMMAND_DAQ_DISABLE 0x0310
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Disable sending data
|
||||
|
||||
#define COMMAND_DAQ_ENABLE 0x0311
|
||||
//L: 0
|
||||
//D: [];
|
||||
//Enable sending data
|
||||
|
||||
#define COMMAND_DAQ_RESET_COUNTERS 0x0321
|
||||
//L: 0
|
||||
//D: []
|
||||
//Reset synchronization counters
|
||||
|
||||
#define COMMAND_DAQ_FLUSH_DATA 0x0322
|
||||
//L: 0
|
||||
//D: []
|
||||
//Send all remaining data over data socket
|
||||
|
||||
#define COMMAND_DAQ_CONFIG_PEER 0x0331
|
||||
//L: 5 L: 0
|
||||
//D: [ip ip ip ip port] D: []
|
||||
//Set connection settings (peer IP and port) for data transfer
|
||||
//Warning: IP is sent as 4 shorts with MSB=0!
|
||||
|
||||
// ***SLOW CONTROL***
|
||||
|
||||
#define COMMAND_SLOWCTRL_SNAPSHOT 0x0410
|
||||
//L: 0 L: 10
|
||||
//D:[] D: [(Readout of 5 ADC channels as 32-bit integers)]
|
||||
//Slow control snapshot - read all channels of ADC
|
||||
|
||||
|
||||
// ***DATA TRANSFER - SOCKET 1!!!!***
|
||||
|
||||
#define COMMAND_DATA_TRANSFER 0x8000
|
||||
//(no incoming packet) L: 64*5*2 + 6
|
||||
//(no incoming packet) D: [Read out single frame]
|
||||
|
||||
|
||||
// *** SET_CLUSTER_THRESHOLD *** //
|
||||
#define COMMAND_SET_CLUSTER_THRESHOLD 0x4001
|
||||
//L: 1
|
||||
#define COMMAND_SET_CLUSTER_SIZE 0x4002
|
||||
//L: 1
|
||||
#define COMMAND_SET_CALIBRATION_FACTOR 0x4003
|
||||
//L: 2* 16bit
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DEV_COMMANDS_H
|
@ -1,49 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. All use of this software and documentation is *
|
||||
* subject to the License Agreement located at the end of this file below. *
|
||||
******************************************************************************
|
||||
* Date - October 24, 2006 *
|
||||
* Module - network_utilities.h *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __NETWORK_UTILITIES_H__
|
||||
#define __NETWORK_UTILITIES_H__
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
error_t get_board_mac_addr(unsigned char mac_addr[6]);
|
||||
|
||||
#endif /*__NETWORK_UTILITIES_H__ */
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* sensor.h
|
||||
*
|
||||
* Created on: Aug 19, 2019
|
||||
* Author: mdziewiecki
|
||||
*/
|
||||
|
||||
#ifndef SENSOR_H_
|
||||
#define SENSOR_H_
|
||||
|
||||
//SENSOR_INTERFACE_BASE - this is the base address of the interface
|
||||
|
||||
//byte offsets for registers
|
||||
#define SENSOR_REG_COMMAND 0 //8 bits
|
||||
#define SENSOR_REG_STATUS 1 //8 bits
|
||||
#define SENSOR_REG_SENSORCLK 2 //16 bits, 6 used divider for producing sensor clock ('4' MHz)
|
||||
#define SESNOR_REG_ADCCNV 3 //8 bits, 6 used time of conversion pulse in ADC clocks, should be > 500 ns
|
||||
#define SENSOR_REG_DELAY 4 //16 bits, 12 used reset signal delay in 50 MHz clocks
|
||||
#define SENSOR_REG_SHUTTER 6 //16 bits, 12 used sensor reset ('shutter') time in sensor clocks
|
||||
#define SENSOR_REG_SERSPEED 8 //8 bits synchro baudrate, 50 for 1 Mbps
|
||||
#define SENSOR_REG_HEADER_ANYDATA 9 //8 bits any data transmitted with SMA state (8 bits SMA + 8 bits anydata)
|
||||
#define SENSOR_REG_HEADER_CMD 10 //16 bits command field of the command header transmitted in packet
|
||||
#define SENSOR_REG_CLUSTER_THRESHOLD 12 //8 bits the threshold for cluster locate, range 0~255
|
||||
#define SENSOR_REG_CLUSTER_SIZE 13 //8 bits the size for clluster locate, range 0~255
|
||||
#define SENSOR_REG_IN_ALGO_THRESHOLD 14 //8 bits the threshold inside Linear Regression, range 0~255
|
||||
#define SENSOR_REG_RESERVED 15 //8 bits not used
|
||||
|
||||
//CSR bitmasks
|
||||
#define SENSOR_CSR_EN_BITMASK 0x01 //enable operation
|
||||
#define SENSOR_CSR_GAIN_BITMASK 0x02 //gain selection
|
||||
#define SENSOR_CSR_ADCK_BITMASK 0x04 //ADC clock divider on/off
|
||||
#define SENSOR_CSR_RESET_BITMASK 0x08 //Reset all logic
|
||||
|
||||
//Status bitmasks
|
||||
#define SENSOR_STATUS_SEND 0x01 //Sending over Avalon-ST
|
||||
#define SENSOR_STATUS_TRG_WAITING 0x02 //The trigger came and is being delayed now
|
||||
#define SENSOR_STATUS_RESET_ACTIVE 0x04 //The RESET signal for the sensor is active now
|
||||
#define SENSOR_STATUS_ADC_ACTIVE 0x08 //The ADC is converting data (signal high over all 64 channels) or just finished and waits for reset high
|
||||
#define SESNOR_STATUS_ADC_FINISHED 0x10 //The ADC waits for reset high
|
||||
#define SESNOR_STATUS_TX_ACTIVE 0x20 //Sync port is sending
|
||||
#define SESNOR_STATUS_RX_ACTIVE 0x40 //Sync port is receiving
|
||||
|
||||
|
||||
//Register access functions/macros
|
||||
void sensor_command_bit(alt_u32 base, alt_u8 bitmask, alt_u8 state);
|
||||
#define sensor_command(base, val) IOWR_8DIRECT(base, SENSOR_REG_COMMAND, val)
|
||||
#define sensor_set_enable(base, val) sensor_command_bit(base, SENSOR_CSR_EN_BITMASK, val);
|
||||
#define sensor_set_gain(base, val) sensor_command_bit(base, SENSOR_CSR_GAIN_BITMASK, val);
|
||||
#define sensor_set_adck(base, val) sensor_command_bit(base, SENSOR_CSR_ADCK_BITMASK, val);
|
||||
#define sensor_reset(base) { sensor_command_bit(base,SENSOR_CSR_RESET_BITMASK,1); sensor_command_bit(base,SENSOR_CSR_RESET_BITMASK,0); }
|
||||
#define sensor_set_sensorclk(base, val) IOWR_8DIRECT(base, SENSOR_REG_SENSORCLK, val)
|
||||
#define sensor_set_adccnv(base, val) IOWR_8DIRECT(base, SESNOR_REG_ADCCNV, val)
|
||||
#define sensor_set_delay(base, val) IOWR_16DIRECT(base, SENSOR_REG_DELAY, val)
|
||||
#define sensor_set_shutter(base, val) IOWR_16DIRECT(base, SENSOR_REG_SHUTTER, val)
|
||||
#define sensor_set_serspeed(base, val) IOWR_8DIRECT(base, SENSOR_REG_SERSPEED, val)
|
||||
#define sensor_set_header_anydata(base, val) IOWR_8DIRECT(base, SENSOR_REG_HEADER_ANYDATA, val)
|
||||
#define sensor_set_header_cmd(base, val) IOWR_16DIRECT(base, SENSOR_REG_HEADER_CMD, val)
|
||||
#define sensor_set_cluster_threshold(base, val) IOWR_8DIRECT(base, SENSOR_REG_CLUSTER_THRESHOLD, val)
|
||||
#define sensor_set_cluster_size(base, val) IOWR_8DIRECT(base, SENSOR_REG_CLUSTER_SIZE, val)
|
||||
#define sensor_set_in_algo_threshold(base, val) IOWR_8DIRECT(base, SENSOR_REG_IN_ALGO_THRESHOLD, val)
|
||||
|
||||
//write calibration factor: CALIBRATION_RAM_BASE
|
||||
#define calibration_ram_set_factor(base, channelID, val) IOWR_16DIRECT(base, channelID*2, val)
|
||||
|
||||
void sensor_preconfigure(alt_u32 base);
|
||||
|
||||
#endif /* SENSOR_H_ */
|
@ -1,144 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. All use of this software and documentation is *
|
||||
* subject to the License Agreement located at the end of this file below. *
|
||||
******************************************************************************* *
|
||||
* Date - October 24, 2006 *
|
||||
* Module - simple_socket_server.h *
|
||||
* EXTENSIVELY REWRITTEN by M.D. 2019 * *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
SO THIS IS HOW IT WORKS:
|
||||
|
||||
User can use up to NR_CHANNELS sockets.
|
||||
First, ethernet_init() must be called from any task.
|
||||
It will start a special 'listener' thread which is responsible for serving connection requests.
|
||||
Then:
|
||||
For each 'channel' (a placeholder for one socket), user may call ethernet_listen() to start listening on a specified port.
|
||||
After that, ethernet_read() and ethernet_write() can be used. These functions are non-blocking and return 0 if no client is connected.
|
||||
User can explicitly close connection to a client by calling ethernet_close();
|
||||
If another connection request comes when a client is already connected, the old client will be disconnected in favor of the new one.
|
||||
It means, that only one client can be connected to one channel at a given time.
|
||||
This weird behaviour is implemented to enable easy killing 'hanging' connections.
|
||||
Channel re-configuration (i.e. repeated calls of ethernet_listen() for the same channel) is not allowed.
|
||||
VERY IMPORTANT:
|
||||
All the above functions (excluding ethernet_init()) must be called from a socket-compatible thread (created with TK_NEWTASK).
|
||||
All ethernet_* calls are served directly in user's task. Ethernet_init() can be called from any thread after hardware configuration.
|
||||
*/
|
||||
|
||||
/* Validate supported Software components specified on system library properties page.
|
||||
*/
|
||||
#ifndef __SOCKET_SERVER_H__
|
||||
#define __SOCKET_SERVER_H__
|
||||
|
||||
#if !defined (ALT_INICHE)
|
||||
#error The Simple Socket Server example requires the
|
||||
#error NicheStack TCP/IP Stack Software Component. Please see the Nichestack
|
||||
#error Tutorial for details on Nichestack TCP/IP Stack - Nios II Edition,
|
||||
#error including notes on migrating applications from lwIP to NicheStack.
|
||||
#endif
|
||||
|
||||
#ifndef __ucosii__
|
||||
#error This Simple Socket Server example requires
|
||||
#error the MicroC/OS-II Intellectual Property Software Component.
|
||||
#endif
|
||||
|
||||
#if defined (ALT_LWIP)
|
||||
#error The Simple Socket Server example requires the
|
||||
#error NicheStack TCP/IP Stack Software Component, and no longer works
|
||||
#error with the lwIP networking stack. Please see the Altera Nichstack
|
||||
#error Tutorial for details on Nichestack TCP/IP Stack - Nios II Edition,
|
||||
#error including notes on migrating applications from lwIP to NicheStack.
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Task Priorities:
|
||||
* MicroC/OS-II only allows one task (thread) per priority number.
|
||||
*/
|
||||
#define SS_LISTENER_TASK_PRIORITY 9 //Also, another priority just below this one will be reserved for mutex
|
||||
#define SS_LISTENER_STACK_SIZE (6144+8192)
|
||||
|
||||
#define NR_CHANNELS 1 //number of listening sockets - as in Wiznet
|
||||
//Each socket listens on its own port and is able to open one "talking" connection at a time
|
||||
//If a new connection request comes, the old one gets preempted. This allows us killing dead connections.
|
||||
|
||||
|
||||
/*
|
||||
* If DHCP will not be used, select valid static _BASE_ IP addresses here:
|
||||
* The contents of DIPSW[3:0] will be added to the last byte of the IP.
|
||||
* DIPSW[4] is used to enable/disable DHCP.
|
||||
*/
|
||||
#define IPADDR0 10
|
||||
#define IPADDR1 0
|
||||
#define IPADDR2 7
|
||||
#define IPADDR3 16
|
||||
|
||||
#define GWADDR0 10
|
||||
#define GWADDR1 0
|
||||
#define GWADDR2 7
|
||||
#define GWADDR3 1
|
||||
|
||||
#define MSKADDR0 255
|
||||
#define MSKADDR1 255
|
||||
#define MSKADDR2 255
|
||||
#define MSKADDR3 0
|
||||
|
||||
|
||||
/*
|
||||
* Here we structure to manage sss communication for a single connection
|
||||
*/
|
||||
typedef struct SS_SOCKET
|
||||
{
|
||||
enum { FREE, LISTENING, CONNECTED} state;
|
||||
int fd_listen;
|
||||
int fd_conn;
|
||||
int listenport;
|
||||
} SSConn;
|
||||
|
||||
// *** User's interface ***
|
||||
|
||||
int ethernet_init();
|
||||
/*REMARK: All the below functions can be used ONLY:
|
||||
1: After ethernet_init();
|
||||
2: From a task created by TK_NEWTASK. */
|
||||
int ethernet_listen(int channel, int port); //Remark: Once we listen on a port, we can not change it
|
||||
int ethernet_write(int channel, int size, unsigned char* data);
|
||||
int ethernet_read(int channel, int size, unsigned char* data); //Non-blocking. Returns the number of characters read.
|
||||
int ethernet_close(int channel);
|
||||
|
||||
#endif /* __SOCKET_SERVER_H__ */
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* udpgen.h
|
||||
*
|
||||
* Created on: Aug 7, 2019
|
||||
* Author: mdziewiecki
|
||||
*/
|
||||
|
||||
#ifndef UDPGEN_H_
|
||||
#define UDPGEN_H_
|
||||
|
||||
//UDP_GENERATOR_0_BASE
|
||||
|
||||
//byte offsets for registers
|
||||
#define UDPGEN_REG_CSR 0 //16 bits 8 bits command + 8 bits status
|
||||
#define UDPGEN_REG_SIZE 2 //16 bits payload size in words
|
||||
#define UDPGEN_REG_SRCIP 4 //32 bits source IP, last octet first
|
||||
#define UDPGEN_REG_DSTIP 8 //32 bits destination IP. last octet first
|
||||
#define UDPGEN_REG_DSTPORT 12 //16 bits destination port
|
||||
#define UDPGEN_REG_SRCPORT 14 //16 bits source port
|
||||
#define UDPGEN_REG_DSTMAC 16 //2*32 bits destination MAC, last octet first
|
||||
#define UDPGEN_REG_RES1 24 //32 bits reserved
|
||||
#define UDPGEN_REG_RES2 28 //32 bits reserved
|
||||
|
||||
//csr bitmasks
|
||||
#define UDPGEN_CSR_EN_BITMASK 0x0001
|
||||
|
||||
|
||||
//Register access macros
|
||||
void udpgen_command_bit(alt_u32 base, alt_u8 bitmask, alt_u8 state);
|
||||
#define udpgen_command(base, val) IOWR_8DIRECT(base, UDPGEN_REG_CSR, val)
|
||||
#define udpgen_set_size(base, val) IOWR_16DIRECT(base, UDPGEN_REG_SIZE, val)
|
||||
#define udpgen_set_srcip(base, val) IOWR_32DIRECT(base, UDPGEN_REG_SRCIP, val)
|
||||
#define udpgen_set_dstip(base, val) IOWR_32DIRECT(base, UDPGEN_REG_DSTIP, val)
|
||||
#define udpgen_set_srcip_a(base, val) { for(int i = 0; i < 4; i++) IOWR_8DIRECT(base, UDPGEN_REG_SRCIP+i, val[3-i]); }
|
||||
#define udpgen_set_dstip_a(base, val) { for(int i = 0; i < 4; i++) IOWR_8DIRECT(base, UDPGEN_REG_DSTIP+i, val[3-i]); }
|
||||
#define udpgen_set_srcport(base, val) IOWR_16DIRECT(base, UDPGEN_REG_SRCPORT, val)
|
||||
#define udpgen_set_dstport(base, val) IOWR_16DIRECT(base, UDPGEN_REG_DSTPORT, val)
|
||||
#define udpgen_set_dstmac_a(base, val) { for(int i = 0; i < 6; i++) IOWR_8DIRECT(base, UDPGEN_REG_DSTMAC+i, val[5-i]); }
|
||||
|
||||
#define udpgen_status(base) IORD_16DIRECT(base, UDPGEN_REG_CSR)
|
||||
#define udpgen_get_size(base, val) IORD_16DIRECT(base, UDPGEN_REG_SIZE)
|
||||
#define udpgen_get_srcip(base, val) IORD_32DIRECT(base, UDPGEN_REG_SRCIP)
|
||||
#define udpgen_get_dstip(base, val) IORD_32DIRECT(base, UDPGEN_REG_DSTIP)
|
||||
#define udpgen_get_srcport(base, val) IORD_16DIRECT(base, UDPGEN_REG_SRCPORT)
|
||||
#define udpgen_get_dstport(base, val) IORD_16DIRECT(base, UDPGEN_REG_DSTPORT)
|
||||
#define udpgen_get_dstmac(base, val) { for(int i = 0; i < 6; i++) val[i] = IORD_8DIRECT(base, UDPGEN_REG_DSTMAC+i); }
|
||||
|
||||
|
||||
//******************************************************
|
||||
|
||||
void udpgen_test(alt_u32 base);
|
||||
|
||||
|
||||
#endif /* UDPGEN_H_ */
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* utils.h
|
||||
*
|
||||
* Created on: Jul 31, 2019
|
||||
* Author: mdziewiecki
|
||||
* Various utils for various purposes
|
||||
* Mainly wrappers on hardware
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef UTILS_H_
|
||||
#define UTILS_H_
|
||||
|
||||
//Swap opdd/even bytes in a bunch of data to align endianness of shorts
|
||||
void swap_bytes(unsigned char* array, int size_bytes);
|
||||
void swap_quad(unsigned char* array, int size_bytes);
|
||||
|
||||
void reload_fpga(); //trigger FPGA reload
|
||||
|
||||
#define TRIGGER_MASTER 1
|
||||
#define TRIGGER_SLAVE 0
|
||||
void masterslave(alt_u8 master); //set trigger system to master or slave operation
|
||||
void master_clock_period(alt_u32 period); //set period of the master frame timer
|
||||
void master_clock_enable(alt_u8 en); //enable/disable pulse generation
|
||||
|
||||
void led_set(alt_u8 led_nr);
|
||||
void led_clear(alt_u8 led_nr);
|
||||
void led_toggle(alt_u8 led_nr);
|
||||
void led4_blink_enable(alt_u8 en);
|
||||
|
||||
void set_delay(alt_u8 master, alt_u16 value);
|
||||
|
||||
#endif /* UTILS_H_ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
set_global_assignment -name SEARCH_PATH $::quartus(qip_path)
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simPackage>
|
||||
<file path="hdl_sim/q_sys_calibration_ram.dat" type="DAT" initParamName="INIT_FILE" memoryPath="calibration_ram" />
|
||||
<file path="hdl_sim/q_sys_descriptor_memory.dat" type="DAT" initParamName="INIT_FILE" memoryPath="descriptor_memory" />
|
||||
<file path="hdl_sim/onchip_flash.dat" type="DAT" initParamName="INIT_FILENAME" memoryPath="onchip_flash" />
|
||||
<file path="q_sys_calibration_ram.hex" type="HEX" initParamName="INIT_FILE" memoryPath="calibration_ram" />
|
||||
<file path="q_sys_descriptor_memory.hex" type="HEX" initParamName="INIT_FILE" memoryPath="descriptor_memory" />
|
||||
<file path="ext_flash.hex" type="HEX" memoryPath="ext_flash" />
|
||||
<file path="onchip_flash.hex" type="HEX" initParamName="INIT_FILENAME" memoryPath="onchip_flash" />
|
||||
</simPackage>
|
@ -1,2 +0,0 @@
|
||||
S00600002D454C3B
|
||||
S70500000000FA
|
@ -1,101 +0,0 @@
|
||||
Readme - Simple Socket Server Software Example
|
||||
|
||||
DESCRIPTION:
|
||||
A Simple Socket Server that controls development board LEDs.
|
||||
|
||||
This software application may be targeted for TSE design having RGMII interface
|
||||
media between Ethernet MAC and Ethernet Phy.
|
||||
|
||||
RGMII (Reduced Gigabit Media Independent Interface) is intended to be an
|
||||
alternative to GMII. The principle objective of RGMII is to reduce the number
|
||||
of pins from 22 (GMII) down to 12 in a cost-effective manner. RGMII interface
|
||||
require a 1.5 to 2ns delay (90 degree phase shift) on the transmitted clock
|
||||
over the data bus. This timing requirement can be achieved through a PCB trace
|
||||
delay, or optionally of introducing the delay on-chip at the physical layer
|
||||
transceiver chip. This example software include a configuration file to enable
|
||||
the on-chip delay method.
|
||||
|
||||
Requirements:
|
||||
-RTOS Type - MicroC/OS-II
|
||||
-Software Component - NicheStack TCP/IP Stack - Nios II Edition
|
||||
-Period System Timer - SYS_CLK_TIMER
|
||||
|
||||
PERIPHERALS USED:
|
||||
This example exercises the following peripherals:
|
||||
- Ethernet MAC
|
||||
- PIO, 8-bit output (named "led_pio" in SOPC Builder)
|
||||
- PIO, 16-bit output (named "seven_seg_pio" in SOPC Builder) (optional)
|
||||
- STDOUT device (UART or JTAG UART)
|
||||
|
||||
SOFTWARE SOURCE FILES:
|
||||
This example includes the following software source files:
|
||||
|
||||
- iniche_init.c: Contains main() and SSSInitialTask() to initialize NicheStack
|
||||
and then create the other tasks once network has been properly initialized.
|
||||
Tasks which will use sockets, such as the SSSSimpleSocketServerTask() in this
|
||||
example, must be created with TK_NEWTASK. All other tasks can be created by directly
|
||||
calling the MicroC/OS-II API to create a task, i.e. OSTaskCreateExt().
|
||||
|
||||
- simple_socket_server.c: Implementation of a simple_socket_server including all necessary sockets
|
||||
calls to handle a single socket connection & process received commands.
|
||||
|
||||
- network_utilities.c: Contains MAC address and IP address routines to
|
||||
manage addressing. These are used by NicheStack during initialization, but are
|
||||
implementation-specific (you set your MAC address to whatever you want.. or read
|
||||
it from your own special non-volatile memory.
|
||||
|
||||
- network_utilities.h: Contains prototype for function get_board_mac_addr().
|
||||
|
||||
- led.c: Contains tasks to manage board LED commands and update LED displays.
|
||||
LEDManagementTask interprets commands, and toggles the row of 8 LEDS or signals the
|
||||
LED7SegLightshowTask in response to commands received from the host running telnet.
|
||||
The LEDManagementTask reads data from a MicroC/OS-II SSSLEDCommandQ Queue which
|
||||
receives its data from the SSSSimpleSocketServerTask. LED7SegLightshowTask controls the
|
||||
7-segment display.
|
||||
|
||||
- simple_socket_server.h: Definitions for the entire example application.
|
||||
|
||||
- alt_error_handler.h: Definitions for 3 error handlers, one each for MicroC-OS/II, Network,
|
||||
and Simple Socket Server Application.
|
||||
|
||||
- alt_error_handler.c: Implementation for 3 error handlers, one each for MicroC-OS/II,
|
||||
Network, and Simple Socket Server Application.
|
||||
|
||||
- tse_my_system.c: Allow customization of tse_mac_device[] structure through global array initialization.
|
||||
If using marvell phy, this can be set to RGMII mode in this file. Other Phys will operate in one mode or
|
||||
the other depending on thier implementation in driver file altera_avalon_tse.c.
|
||||
|
||||
BOARD/HOST REQUIREMENTS:
|
||||
Must contain a supported phy, and use a quartus project that uses tse and msgdma.
|
||||
|
||||
This example requires an Ethernet cable connected to the development board's
|
||||
RJ-45 jack, and a JTAG connection with the development board. If the host
|
||||
communication settings are changed from JTAG UART (default) to use a
|
||||
conventional UART, a serial cable between board DB-9 connector and the host is
|
||||
required.
|
||||
|
||||
If DHCP is available (and enabled in the Software component configuration page, from
|
||||
the BSP properties configuration), NicheStack TCP/IP Stack will attempt
|
||||
to obtain an IP address from a DHCP server. Otherwise, a static IP address (defined in
|
||||
Simple_Socket_Server.h) will be assigned after a DHCP timeout.
|
||||
|
||||
ADDITIONAL INFORMATION:
|
||||
|
||||
This is an example socket server using NicheStack TCP/IP Stack on MicroC/OS-II. The server
|
||||
implements simple commands to control board LEDs through a separate MicroC/OS-II
|
||||
task. It is in no way a complete implementation of a telnet server.
|
||||
|
||||
A good introduction to sockets programming is the book "Unix Network Programming" by
|
||||
Richard Stevens. Additionally, the text "Sockets in C", by Donahoo & Calvert, is a concise
|
||||
& inexpensive text for getting started with sockets programming.
|
||||
|
||||
This example will not run on the Instruction Set Simulator (ISS).
|
||||
|
||||
Once the simple socket server example is running and has obtained an IP address (shown
|
||||
in the terminal window of Nios II Software Build Tools for Eclipse),
|
||||
you can connect to it over a network by typing the
|
||||
following command in a command shell on a development host:
|
||||
|
||||
telnet <ip address> 30
|
||||
|
||||
This command will try to connect to the Simple Socket Server using port 30.
|
@ -1,390 +0,0 @@
|
||||
/*
|
||||
* control.c
|
||||
*
|
||||
* Created on: Aug 14, 2017
|
||||
* Author: mdziewiecki
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* MicroC/OS-II definitions */
|
||||
#include "includes.h"
|
||||
|
||||
#include <system.h>
|
||||
#include <io.h>
|
||||
|
||||
/* Nichestack definitions */
|
||||
#include "ipport.h"
|
||||
#include "tcpport.h"
|
||||
#include "libport.h"
|
||||
#include "osport.h"
|
||||
|
||||
#include "socket_server.h"
|
||||
#include "control.h"
|
||||
#include "sensor.h"
|
||||
#include "udpgen.h"
|
||||
#include "utils.h"
|
||||
|
||||
// ****************************
|
||||
|
||||
extern NET nets[MAXNETS]; /* pointers to the static network structs */
|
||||
|
||||
// ****************************
|
||||
|
||||
void control_delay()
|
||||
{
|
||||
TK_SLEEP(1);
|
||||
}
|
||||
|
||||
|
||||
// ****************************
|
||||
|
||||
//simple reply
|
||||
void control_pong(command_header* header)
|
||||
{
|
||||
command_header tmp;
|
||||
tmp = *header;
|
||||
swap_bytes((char*)(void*)(&tmp), sizeof(tmp));
|
||||
ethernet_write(0, sizeof(command_header), (unsigned char*)(header));
|
||||
}
|
||||
|
||||
void control_process_snapshot()
|
||||
{
|
||||
command_header header = {.marker = 0x5555, .command = COMMAND_SLOWCTRL_SNAPSHOT,
|
||||
.length = 0}; //SLOWCTRL_ADC_CHANNEL_COUNT * sizeof(SLOWCTRL_ADC_DATA_TYPE) / sizeof(unsigned short)};
|
||||
swap_bytes((char*)(void*)(&header), sizeof(header));
|
||||
ethernet_write(0, sizeof(command_header), (unsigned char*)(&header));
|
||||
//ethernet_write(0, SLOWCTRL_ADC_CHANNEL_COUNT*sizeof(SLOWCTRL_ADC_DATA_TYPE), (unsigned char*)slowctrl_adc_buffer);
|
||||
}
|
||||
|
||||
//helper for the one below
|
||||
int check_arp(struct arptabent * arp_entry, ip_addr ip)
|
||||
{
|
||||
if (arp_entry->t_pro_addr != ip)
|
||||
return 0; //bad IP
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
if (arp_entry->t_phy_addr[i] != 0)
|
||||
return 1; //non-zero MAC
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void control_process_config_peer(unsigned short* data)
|
||||
{
|
||||
ip_addr ip = 0;
|
||||
ip_addr srcip = 0;
|
||||
int i;
|
||||
command_header header = {.marker = 0x5555, .command = COMMAND_DAQ_CONFIG_PEER, .length = 0};
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
ip = (ip << 8) | (unsigned char)(data[3-i] & 0x00FF);
|
||||
|
||||
//daq_configure_peer_addr(ip, data[4]);
|
||||
|
||||
printf("Querying ARP for %d.%d.%d.%d ...\n",data[0],data[1],data[2],data[3]);
|
||||
|
||||
struct arptabent * arp_entry = find_oldest_arp(ip);
|
||||
|
||||
int pingseq = 0;
|
||||
while (!check_arp(arp_entry, ip)) //big loop for pinging 10 times
|
||||
{
|
||||
printf("ARP entry could not be found, pinging!\n");
|
||||
//ping the peer to ARP it.
|
||||
icmpEcho(ip, NULL, 8, pingseq++);
|
||||
|
||||
for (int i = 0; (i < 5) && (!check_arp(arp_entry, ip)); i++) //small loop for waiting 5 times after each ping
|
||||
{
|
||||
TK_SLEEP(10);
|
||||
arp_entry = find_oldest_arp(ip);
|
||||
}
|
||||
|
||||
if (pingseq > 10)
|
||||
{
|
||||
printf("Could not resolve MAC! The result below is random!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Peer MAC is %02x %02x %02x %02x %02x %02x\n",
|
||||
arp_entry->t_phy_addr[0], arp_entry->t_phy_addr[1], arp_entry->t_phy_addr[2],
|
||||
arp_entry->t_phy_addr[3], arp_entry->t_phy_addr[4], arp_entry->t_phy_addr[5]);
|
||||
|
||||
srcip = nets[0]->n_ipaddr;
|
||||
swap_quad((unsigned char*)(void*)(&srcip), 4); //UDP generator needs such a format
|
||||
swap_quad((unsigned char*)(void*)(&ip), 4);
|
||||
|
||||
//set up udpgen with correct values
|
||||
udpgen_set_size(UDP_GENERATOR_BASE, 167); //sensor_interface.v:39
|
||||
udpgen_set_srcip(UDP_GENERATOR_BASE, srcip);
|
||||
udpgen_set_dstip(UDP_GENERATOR_BASE, ip);
|
||||
udpgen_set_srcport(UDP_GENERATOR_BASE, DATA_PORT);
|
||||
udpgen_set_dstport(UDP_GENERATOR_BASE, data[4]);
|
||||
udpgen_set_dstmac_a(UDP_GENERATOR_BASE, arp_entry->t_phy_addr);
|
||||
|
||||
swap_bytes((unsigned char*)(void*)(&header), sizeof(header));
|
||||
ethernet_write(0, sizeof(command_header), (unsigned char*)(&header));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ****************************
|
||||
|
||||
//Receive command header. Return (without loosing data!) if number of received bytes is insufficient.
|
||||
unsigned char control_get_header(command_header** result)
|
||||
{
|
||||
static command_header header;
|
||||
static unsigned int bytes_received = 0;
|
||||
|
||||
bytes_received += ethernet_read(0, sizeof(command_header)-bytes_received, (unsigned char*)(&header) + bytes_received);
|
||||
|
||||
if (bytes_received < sizeof(command_header))
|
||||
return 0;
|
||||
|
||||
swap_bytes((unsigned char*)(void*)(&header),sizeof(header)); //if the header is complete, swap bytes and return it
|
||||
*result = &header;
|
||||
bytes_received = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Receive command data. Return (without loosing data!) if number of received bytes is insufficient.
|
||||
//Expected data length is given in words!
|
||||
unsigned char control_get_data(unsigned short expected_length, unsigned short** data)
|
||||
{
|
||||
static unsigned short packet_data[CONTROL_MAX_DATA_LENGTH];
|
||||
static unsigned int bytes_received = 0;
|
||||
|
||||
bytes_received += ethernet_read(0, 2*expected_length - bytes_received, (unsigned char*)(&packet_data) + bytes_received);
|
||||
|
||||
if (bytes_received < (2*expected_length))
|
||||
return 0;
|
||||
|
||||
*data = packet_data;
|
||||
bytes_received = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ****************************
|
||||
|
||||
void control_step()
|
||||
{
|
||||
command_header* header;
|
||||
unsigned short* data;
|
||||
unsigned int loop_ctr = 0;
|
||||
|
||||
|
||||
//get header - at this moment this is blocking!
|
||||
while (!control_get_header(&header))
|
||||
{
|
||||
control_delay();
|
||||
|
||||
if (++loop_ctr > CONTROL_TIMEOUT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//check start marker
|
||||
if (header->marker != 0x5555)
|
||||
return;
|
||||
|
||||
|
||||
//get packet data - at this moment this is blocking!
|
||||
while (!control_get_data(header->length, &data))
|
||||
{
|
||||
control_delay();
|
||||
|
||||
if (++loop_ctr > CONTROL_TIMEOUT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
//swap data bytes
|
||||
swap_bytes((unsigned char*)(void*)data, header->length*2);
|
||||
|
||||
switch(header->command)
|
||||
{
|
||||
case COMMAND_PING:
|
||||
printf("COMMAND_PING\n");
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_DEBUG_LED_OFF:
|
||||
printf("COMMAND_DEBUG_LED_OFF\n");
|
||||
led_clear(0);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_DEBUG_LED_ON:
|
||||
printf("COMMAND_DEBUG_LED_ON\n");
|
||||
led_set(0);
|
||||
control_pong(header);
|
||||
break;
|
||||
|
||||
case COMMAND_LEDS_DISABLE:
|
||||
printf("COMMAND_LEDS_DISABLE\n");
|
||||
led4_blink_enable(0);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_LEDS_ENABLE:
|
||||
printf("COMMAND_LEDS_ENABLE\n");
|
||||
led4_blink_enable(1);
|
||||
control_pong(header);
|
||||
break;
|
||||
|
||||
case COMMAND_TRIGGER_DISABLE:
|
||||
printf("COMMAND_TRIGGER_DISABLE\n");
|
||||
master_clock_enable(0);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_TRIGGER_ENABLE:
|
||||
printf("COMMAND_TRIGGER_ENABLE\n");
|
||||
master_clock_enable(1);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_TRIGGER_SET_SLAVE:
|
||||
printf("COMMAND_TRIGGER_SET_SLAVE\n");
|
||||
masterslave(TRIGGER_SLAVE);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_TRIGGER_SET_MASTER:
|
||||
printf("COMMAND_TRIGGER_SET_MASTER\n");
|
||||
masterslave(TRIGGER_MASTER);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_TRIGGER_SET_PERIOD:
|
||||
printf("COMMAND_TRIGGER_SET_PERIOD: %d\n", data[0]);
|
||||
master_clock_period((alt_u32)data[0]); //we set only 16 lsbs!
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_TRIGGER_SET_TINT:
|
||||
printf("COMMAND_TRIGGER_SET_TINT: %d\n", data[0]);
|
||||
sensor_set_shutter(SENSOR_INTERFACE_BASE, data[0]);
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_SET_GAIN:
|
||||
printf("COMMAND_SET_GAIN: %d\n", data[0]);
|
||||
sensor_set_gain(SENSOR_INTERFACE_BASE, data[0]);
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_TRIGGER_SET_MASTER_DELAY:
|
||||
printf("COMMAND_TRIGGER_SET_MASTER_DELAY: %d\n", data[0]);
|
||||
set_delay(TRIGGER_MASTER, data[0]);
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_TRIGGER_SET_SLAVE_DELAY:
|
||||
printf("COMMAND_TRIGGER_SET_SLAVE_DELAY: %d\n", data[0]);
|
||||
set_delay(TRIGGER_SLAVE, data[0]);
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
|
||||
case COMMAND_DAQ_DISABLE:
|
||||
printf("COMMAND_DAQ_DISABLE\n");
|
||||
sensor_set_enable(SENSOR_INTERFACE_BASE, 0);
|
||||
udpgen_command_bit(UDP_GENERATOR_BASE, UDPGEN_CSR_EN_BITMASK,0);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_DAQ_ENABLE:
|
||||
printf("COMMAND_DAQ_ENABLE\n");
|
||||
udpgen_command_bit(UDP_GENERATOR_BASE, UDPGEN_CSR_EN_BITMASK,1);
|
||||
sensor_set_enable(SENSOR_INTERFACE_BASE, 1);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_DAQ_RESET_COUNTERS:
|
||||
printf("COMMAND_DAQ_RESET_COUNTERS\n");
|
||||
sensor_reset(SENSOR_INTERFACE_BASE);
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_DAQ_FLUSH_DATA:
|
||||
printf("COMMAND_DAQ_FLUSH_DATA\n");
|
||||
//nothing
|
||||
control_pong(header);
|
||||
break;
|
||||
case COMMAND_DAQ_CONFIG_PEER:
|
||||
printf("COMMAND_DAQ_CONFIG_PEER\n");
|
||||
control_process_config_peer(data);
|
||||
break;
|
||||
|
||||
case COMMAND_SLOWCTRL_SNAPSHOT:
|
||||
printf("COMMAND_SLOWCTRL_SNAPSHOT\n");
|
||||
control_process_snapshot();
|
||||
break;
|
||||
|
||||
case COMMAND_SET_CLUSTER_THRESHOLD:
|
||||
printf("COMMAND_SET_CLUSTER_THRESHOLD: %d\n", data[0]);
|
||||
sensor_set_cluster_threshold(SENSOR_INTERFACE_BASE,data[0]);
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
|
||||
case COMMAND_SET_CLUSTER_SIZE:
|
||||
printf("COMMAND_SET_CLUSTER_SIZE: %d\n", data[0]);
|
||||
sensor_set_cluster_size(SENSOR_INTERFACE_BASE,data[0]);
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
|
||||
case COMMAND_SET_CALIBRATION_FACTOR: //data[i] is 16 bit unsigned short; calibration factor is 16 bit
|
||||
if (header->length>=2){
|
||||
calibration_ram_set_factor(CALIBRATION_RAM_BASE,data[0],data[1]); //i is channelID
|
||||
printf("COMMAND_SET_CALIBRATION_FACTOR ChannelIP%d : %d\n", data[0],data[1]);
|
||||
}else{
|
||||
printf("COMMAND_SET_CALIBRATION_FACTOR length: %d\n", header->length);
|
||||
}
|
||||
header->length = 0;
|
||||
control_pong(header);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ******************** The task *****************
|
||||
|
||||
TK_OBJECT(to_controltask);
|
||||
TK_ENTRY(ControlTask);
|
||||
|
||||
struct inet_taskinfo controltask =
|
||||
{
|
||||
&to_controltask,
|
||||
"Control thread",
|
||||
ControlTask,
|
||||
CONTROL_TASK_PRIORITY,
|
||||
CONTROL_STACK_SIZE,
|
||||
};
|
||||
|
||||
|
||||
void ControlTask(void* param)
|
||||
{
|
||||
printf ("::: Control task started ::: \n");
|
||||
ethernet_listen(0, CONTROL_PORT);
|
||||
|
||||
sensor_preconfigure(SENSOR_INTERFACE_BASE);
|
||||
|
||||
//initial calibration factor here
|
||||
printf("Initiate Calibration Factor 1 to 320 from channel1 to channel320 \n");
|
||||
|
||||
|
||||
for (alt_u32 i = 0; i < 320; i++) {
|
||||
//pow(2,13)=8192. represent calibration factor 1; range[0.00012,8)
|
||||
//default calibration factor is 1.
|
||||
calibration_ram_set_factor(CALIBRATION_RAM_BASE,i,8192); //i is channelID
|
||||
}
|
||||
|
||||
while(1)
|
||||
control_step();
|
||||
}
|
||||
|
||||
void control_init()
|
||||
{
|
||||
TK_NEWTASK(&controltask);
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. All use of this software and documentation is *
|
||||
* subject to the License Agreement located at the end of this file below. *
|
||||
******************************************************************************* *
|
||||
* Date - October 24, 2006 *
|
||||
* Module - iniche_init.c *
|
||||
* * *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* NicheStack TCP/IP stack initialization and Operating System Start in main()
|
||||
* for Simple Socket Server (SSS) example.
|
||||
*
|
||||
* This example demonstrates the use of MicroC/OS-II running on NIOS II.
|
||||
* In addition it is to serve as a good starting point for designs using
|
||||
* MicroC/OS-II and Altera NicheStack TCP/IP Stack - NIOS II Edition.
|
||||
*
|
||||
* Please refer to the Altera NicheStack Tutorial documentation for details on
|
||||
* this software example, as well as details on how to configure the NicheStack
|
||||
* TCP/IP networking stack and MicroC/OS-II Real-Time Operating System.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* MicroC/OS-II definitions */
|
||||
#include "includes.h"
|
||||
|
||||
/* Simple Socket Server definitions */
|
||||
#include "socket_server.h"
|
||||
#include "control.h"
|
||||
//#include "alt_error_handler.h"
|
||||
|
||||
|
||||
/* Nichestack definitions */
|
||||
#include "ipport.h"
|
||||
#include "libport.h"
|
||||
#include "osport.h"
|
||||
|
||||
#define SS_INITIAL_TASK_PRIORITY 5
|
||||
/* Definition of task stack for the initial task which will initialize the NicheStack
|
||||
* TCP/IP Stack and then initialize the rest of the Simple Socket Server example tasks.
|
||||
*/
|
||||
OS_STK InitialTaskStk[APP_STACK_SIZE];
|
||||
|
||||
/* InitialTask will initialize the NicheStack
|
||||
* TCP/IP Stack and then initialize the rest of the Simple Socket Server example
|
||||
* RTOS structures and tasks.
|
||||
*/
|
||||
void InitialTask(void *task_data)
|
||||
{
|
||||
INT8U error_code;
|
||||
|
||||
/*
|
||||
* Initialize Altera NicheStack TCP/IP Stack - Nios II Edition specific code.
|
||||
* NicheStack is initialized from a task, so that RTOS will have started, and
|
||||
* I/O drivers are available. Two tasks are created:
|
||||
* "Inet main" task with priority 2
|
||||
* "clock tick" task with priority 3
|
||||
*/
|
||||
|
||||
alt_iniche_init();
|
||||
netmain();
|
||||
|
||||
/* Wait for the network stack to be ready before proceeding.
|
||||
* iniche_net_ready indicates that TCP/IP stack is ready, and IP address is obtained.
|
||||
*/
|
||||
while (!iniche_net_ready){
|
||||
TK_SLEEP(1);
|
||||
}
|
||||
|
||||
/* Now that the stack is running, perform the application initialization steps */
|
||||
|
||||
/* Application Specific Task Launching Code Block Begin */
|
||||
|
||||
printf("\nSocket Server starting up\n");
|
||||
|
||||
/* Create tasks */
|
||||
ethernet_init();
|
||||
control_init();
|
||||
//TK_NEWTASK(&ssconntask);
|
||||
|
||||
/* Application Specific Task Launching Code Block End */
|
||||
|
||||
/*This task is deleted because there is no need for it to run again */
|
||||
error_code = OSTaskDel(OS_PRIO_SELF);
|
||||
//alt_uCOSIIErrorHandler(error_code, 0);
|
||||
|
||||
while (1); /* Correct Program Flow should never get here */
|
||||
}
|
||||
|
||||
/* Main creates a single task, SSSInitialTask, and starts task scheduler.
|
||||
*/
|
||||
|
||||
int main (int argc, char* argv[], char* envp[])
|
||||
{
|
||||
|
||||
INT8U error_code;
|
||||
|
||||
/* Clear the RTOS timer */
|
||||
OSTimeSet(0);
|
||||
|
||||
/* SSSInitialTask will initialize the NicheStack
|
||||
* TCP/IP Stack and then initialize the rest of the Simple Socket Server example
|
||||
* RTOS structures and tasks.
|
||||
*/
|
||||
error_code = OSTaskCreateExt(InitialTask,
|
||||
NULL,
|
||||
(void *)&InitialTaskStk[APP_STACK_SIZE],
|
||||
SS_INITIAL_TASK_PRIORITY,
|
||||
SS_INITIAL_TASK_PRIORITY,
|
||||
InitialTaskStk,
|
||||
APP_STACK_SIZE,
|
||||
NULL,
|
||||
0);
|
||||
//alt_uCOSIIErrorHandler(error_code, 0);
|
||||
|
||||
/*
|
||||
* As with all MicroC/OS-II designs, once the initial thread(s) and
|
||||
* associated RTOS resources are declared, we start the RTOS. That's it!
|
||||
*/
|
||||
OSStart();
|
||||
|
||||
|
||||
|
||||
while(1); /* Correct Program Flow never gets here. */
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
@ -1,456 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. All use of this software and documentation is *
|
||||
* subject to the License Agreement located at the end of this file below. *
|
||||
******************************************************************************
|
||||
* Date - October 24, 2006 *
|
||||
* Module - network_utilities.c *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include <alt_types.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/alt_flash.h>
|
||||
#include "includes.h"
|
||||
#include "io.h"
|
||||
#include <alt_iniche_dev.h>
|
||||
|
||||
#include "ipport.h"
|
||||
#include "tcpport.h"
|
||||
#include "network_utilities.h"
|
||||
|
||||
#include <altera_avalon_pio_regs.h>
|
||||
#include <socket_server.h>
|
||||
|
||||
#define IP4_ADDR(ipaddr, a,b,c,d) ipaddr = \
|
||||
htonl((((alt_u32)(a & 0xff) << 24) | ((alt_u32)(b & 0xff) << 16) | \
|
||||
((alt_u32)(c & 0xff) << 8) | (alt_u32)(d & 0xff)))
|
||||
|
||||
error_t generate_mac_addr(unsigned char mac_addr[6]);
|
||||
|
||||
/*
|
||||
* get_mac_addr
|
||||
*
|
||||
* Read the MAC address in a board specific way. Prompt user to enter serial
|
||||
* number to generate MAC address if failed to read from flash.
|
||||
*
|
||||
*/
|
||||
int get_mac_addr(NET net, unsigned char mac_addr[6])
|
||||
{
|
||||
error_t error = 0;
|
||||
|
||||
error = get_board_mac_addr(mac_addr);
|
||||
|
||||
if(error)
|
||||
{
|
||||
/* Failed read MAC address from flash, prompt user to enter serial
|
||||
number to generate MAC address. */
|
||||
error = generate_mac_addr(mac_addr);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_ip_addr()
|
||||
*
|
||||
* This routine is called by InterNiche to obtain an IP address for the
|
||||
* specified network adapter. Like the MAC address, obtaining an IP address is
|
||||
* very system-dependant and therefore this function is exported for the
|
||||
* developer to control.
|
||||
*
|
||||
* In our system, we are either attempting DHCP auto-negotiation of IP address,
|
||||
* or we are setting our own static IP, Gateway, and Subnet Mask addresses our
|
||||
* self. This routine is where that happens.
|
||||
*/
|
||||
int get_ip_addr(alt_iniche_dev *p_dev,
|
||||
ip_addr* ipaddr,
|
||||
ip_addr* netmask,
|
||||
ip_addr* gw,
|
||||
int* use_dhcp)
|
||||
{
|
||||
|
||||
alt_u32 sw_state = ~(IORD_ALTERA_AVALON_PIO_DATA(BUTTON_PIO_BASE));
|
||||
|
||||
printf("Input state: 0x%08lx\n", sw_state);
|
||||
|
||||
/*if (sw_state & 0x100)
|
||||
{
|
||||
*use_dhcp = 1;
|
||||
IP4_ADDR(*ipaddr, 0, 0, 0, 0);
|
||||
IP4_ADDR(*gw, 0, 0, 0, 0);
|
||||
IP4_ADDR(*netmask, 0, 0, 0, 0);
|
||||
printf("DHCP enabled.\n");
|
||||
}
|
||||
else
|
||||
{*/
|
||||
*use_dhcp = 0;
|
||||
IP4_ADDR(*ipaddr, IPADDR0, IPADDR1, IPADDR2, IPADDR3+((sw_state>>4)&0x0F));
|
||||
IP4_ADDR(*gw, GWADDR0, GWADDR1, GWADDR2, GWADDR3);
|
||||
IP4_ADDR(*netmask, MSKADDR0, MSKADDR1, MSKADDR2, MSKADDR3);
|
||||
printf("DHCP disabled.\n");
|
||||
printf("Static IP Address is %d.%d.%d.%d\n",
|
||||
ip4_addr1(*ipaddr),
|
||||
ip4_addr2(*ipaddr),
|
||||
ip4_addr3(*ipaddr),
|
||||
ip4_addr4(*ipaddr));
|
||||
//}
|
||||
|
||||
|
||||
/* Non-standard API: return 1 for success */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FindLastFlashSectorOffset(
|
||||
alt_u32 *pLastFlashSectorOffset);
|
||||
|
||||
alt_u32 last_flash_sector_offset;
|
||||
alt_u32 last_flash_sector;
|
||||
|
||||
/*
|
||||
* get_serial_number
|
||||
*
|
||||
* Prompt user to enter 9-digit serial number.
|
||||
*
|
||||
*/
|
||||
alt_u32 get_serial_number (void)
|
||||
{
|
||||
alt_u32 ser_num = 0;
|
||||
char serial_number[9];
|
||||
int i = 0;
|
||||
|
||||
while(!ser_num)
|
||||
{
|
||||
printf("Please enter your 9-digit serial number. This is printed on a \n");
|
||||
printf("label under your Nios dev. board. The first 3 digits of the \n");
|
||||
printf("label are ASJ and the serial number follows this.\n -->");
|
||||
|
||||
for(i=0; i<9; i++)
|
||||
{
|
||||
serial_number[i] = getchar();
|
||||
putchar(serial_number[i]);
|
||||
|
||||
/* Handle backspaces. How civilized. */
|
||||
if ((serial_number[i] == 0x08) && (i >= 0))
|
||||
{
|
||||
i--;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
for(i=0; i<9; i++)
|
||||
{
|
||||
if (isdigit(serial_number[i]))
|
||||
{
|
||||
ser_num *= 10;
|
||||
ser_num += serial_number[i] - '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
ser_num = 0;
|
||||
printf("Serial number only contains decimal digits and is non-zero\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ser_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* generate_and_store_mac_addr()
|
||||
*
|
||||
* This routine is called when, upon program initialization, we discover
|
||||
* that there is no valid network settings (including MAC address) programmed
|
||||
* into flash memory at the last flash sector. If it is not safe to use the
|
||||
* contents of this last sector of flash, the user is prompted to
|
||||
* enter the serial number at the console. A MAC address is then
|
||||
* generated using 0xFF followed by the last 2 bytes of the serial number
|
||||
* appended to Altera's Vendor ID, an assigned MAC address range with the first
|
||||
* 3 bytes of 00:07:ED. For example, if the Nios Development Board serial
|
||||
* number is 040800017, the corresponding ethernet number generated will be
|
||||
* 00:07:ED:FF:8F:11.
|
||||
*
|
||||
* It should be noted that this number, while unique, will likely differ from
|
||||
* the also unique (but now lost forever) MAC address programmed into the
|
||||
* development board on the production line.
|
||||
*
|
||||
* As we are erasing the entire flash sector, we'll re-program it with not
|
||||
* only the MAC address, but static IP, subnet, gateway, and "Use DHCP"
|
||||
* sections. These fail-safe static settings are compatible with previous
|
||||
* Nios Ethernet designs, and allow the "factory-safe" design to behave
|
||||
* as expected if the last flash sector is erased.
|
||||
*/
|
||||
error_t generate_and_store_mac_addr()
|
||||
{
|
||||
error_t error = -1;
|
||||
alt_u32 ser_num = 0;
|
||||
char flash_content[32];
|
||||
alt_flash_fd* flash_handle;
|
||||
|
||||
printf("Can't read the MAC address from your board (this probably means\n");
|
||||
printf("that your flash was erased). We will assign you a MAC address and\n");
|
||||
printf("static network settings\n\n");
|
||||
|
||||
ser_num = get_serial_number();
|
||||
|
||||
if (ser_num)
|
||||
{
|
||||
/* This says the image is safe */
|
||||
flash_content[0] = 0xfe;
|
||||
flash_content[1] = 0x5a;
|
||||
flash_content[2] = 0x0;
|
||||
flash_content[3] = 0x0;
|
||||
|
||||
/* This is the Altera Vendor ID */
|
||||
flash_content[4] = 0x0;
|
||||
flash_content[5] = 0x7;
|
||||
flash_content[6] = 0xed;
|
||||
|
||||
/* Reserverd Board identifier for erase boards */
|
||||
flash_content[7] = 0xFF;
|
||||
flash_content[8] = (ser_num & 0xff00) >> 8;
|
||||
flash_content[9] = ser_num & 0xff;
|
||||
|
||||
/* Then comes a 16-bit "flags" field */
|
||||
flash_content[10] = 0xFF;
|
||||
flash_content[11] = 0xFF;
|
||||
|
||||
/* Then comes the static IP address */
|
||||
flash_content[12] = IPADDR0;
|
||||
flash_content[13] = IPADDR1;
|
||||
flash_content[14] = IPADDR2;
|
||||
flash_content[15] = IPADDR3;
|
||||
|
||||
/* Then comes the static nameserver address */
|
||||
flash_content[16] = 0xFF;
|
||||
flash_content[17] = 0xFF;
|
||||
flash_content[18] = 0xFF;
|
||||
flash_content[19] = 0xFF;
|
||||
|
||||
/* Then comes the static subnet mask */
|
||||
flash_content[20] = MSKADDR0;
|
||||
flash_content[21] = MSKADDR1;
|
||||
flash_content[22] = MSKADDR2;
|
||||
flash_content[23] = MSKADDR3;
|
||||
|
||||
/* Then comes the static gateway address */
|
||||
flash_content[24] = GWADDR0;
|
||||
flash_content[25] = GWADDR1;
|
||||
flash_content[26] = GWADDR2;
|
||||
flash_content[27] = GWADDR3;
|
||||
|
||||
/* And finally whether to use DHCP - set all bits to be safe */
|
||||
flash_content[28] = 0xFF;
|
||||
flash_content[29] = 0xFF;
|
||||
flash_content[30] = 0xFF;
|
||||
flash_content[31] = 0xFF;
|
||||
|
||||
/* Write the MAC address to flash */
|
||||
flash_handle = alt_flash_open_dev(EXT_FLASH_AVL_MEM_NAME);
|
||||
if (flash_handle)
|
||||
{
|
||||
alt_write_flash(flash_handle,
|
||||
last_flash_sector_offset,
|
||||
flash_content,
|
||||
32);
|
||||
alt_flash_close_dev(flash_handle);
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* generate_mac_addr()
|
||||
*
|
||||
* This routine is called when failed to read MAC address from flash (i.e: no
|
||||
* flash on the board). The user is prompted to enter the serial number at the
|
||||
* console. A MAC address is then generated using 0xFF followed by the last 2
|
||||
* bytes of the serial number appended to Altera's Vendor ID, an assigned MAC
|
||||
* address range with the first 3 bytes of 00:07:ED. For example, if the Nios
|
||||
* Development Board serial number is 040800017, the corresponding ethernet
|
||||
* number generated will be 00:07:ED:FF:8F:11.
|
||||
*
|
||||
*/
|
||||
error_t generate_mac_addr(unsigned char mac_addr[6])
|
||||
{
|
||||
error_t error = -1;
|
||||
alt_u32 ser_num = 0;
|
||||
|
||||
printf("\nCan't read the MAC address from your board. We will assign you\n");
|
||||
printf("a MAC address.\n\n");
|
||||
|
||||
ser_num = get_serial_number();
|
||||
|
||||
if (ser_num)
|
||||
{
|
||||
/* This is the Altera Vendor ID */
|
||||
mac_addr[0] = 0x0;
|
||||
mac_addr[1] = 0x7;
|
||||
mac_addr[2] = 0xed;
|
||||
|
||||
/* Reserverd Board identifier */
|
||||
mac_addr[3] = 0xFF;
|
||||
mac_addr[4] = (ser_num & 0xff00) >> 8;
|
||||
mac_addr[5] = ser_num & 0xff;
|
||||
|
||||
printf("Your Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac_addr[0],
|
||||
mac_addr[1],
|
||||
mac_addr[2],
|
||||
mac_addr[3],
|
||||
mac_addr[4],
|
||||
mac_addr[5]);
|
||||
|
||||
error = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_board_mac_addr
|
||||
*
|
||||
* Read the MAC address in a board specific way
|
||||
*
|
||||
*/
|
||||
error_t get_board_mac_addr(unsigned char mac_addr[6])
|
||||
{
|
||||
error_t error = 0;
|
||||
alt_u32 signature;
|
||||
|
||||
/* Get the flash sector with the MAC address. */
|
||||
error = FindLastFlashSectorOffset(&last_flash_sector_offset);
|
||||
if (!error)
|
||||
last_flash_sector = EXT_FLASH_AVL_MEM_BASE + last_flash_sector_offset;
|
||||
|
||||
/* This last_flash_sector region of flash is examined to see if
|
||||
* valid network settings are present, indicated by a signature of 0x00005afe at
|
||||
* the first address of the last flash sector. This hex value is chosen as the
|
||||
* signature since it looks like the english word "SAFE", meaning that it is
|
||||
* safe to use these network address values.
|
||||
*/
|
||||
if (!error)
|
||||
{
|
||||
signature = IORD_32DIRECT(last_flash_sector, 0);
|
||||
if (signature != 0x00005afe)
|
||||
{
|
||||
error = generate_and_store_mac_addr();
|
||||
}
|
||||
}
|
||||
|
||||
if (!error)
|
||||
{
|
||||
mac_addr[0] = IORD_8DIRECT(last_flash_sector, 4);
|
||||
mac_addr[1] = IORD_8DIRECT(last_flash_sector, 5);
|
||||
mac_addr[2] = IORD_8DIRECT(last_flash_sector, 6);
|
||||
mac_addr[3] = IORD_8DIRECT(last_flash_sector, 7);
|
||||
mac_addr[4] = IORD_8DIRECT(last_flash_sector, 8);
|
||||
mac_addr[5] = IORD_8DIRECT(last_flash_sector, 9);
|
||||
|
||||
printf("Your Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac_addr[0],
|
||||
mac_addr[1],
|
||||
mac_addr[2],
|
||||
mac_addr[3],
|
||||
mac_addr[4],
|
||||
mac_addr[5]);
|
||||
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Flash service functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_flash.h"
|
||||
#include "sys/alt_flash_dev.h"
|
||||
|
||||
/*
|
||||
* FindLastFlashSectorOffset
|
||||
*
|
||||
* <-- pLastFlashSectorOffset Offset of last sector in flash.
|
||||
*
|
||||
* This function finds the offset to the last sector in flash and returns it
|
||||
* in pLastFlashSectorOffset.
|
||||
*/
|
||||
|
||||
int FindLastFlashSectorOffset(
|
||||
alt_u32 *pLastFlashSectorOffset)
|
||||
{
|
||||
alt_flash_fd *fd;
|
||||
flash_region *regions;
|
||||
int numRegions;
|
||||
flash_region *pLastRegion;
|
||||
int lastFlashSectorOffset;
|
||||
int n;
|
||||
int error = 0;
|
||||
|
||||
/* Open the flash device. */
|
||||
fd = alt_flash_open_dev(EXT_FLASH_AVL_MEM_NAME);
|
||||
if (fd <= 0)
|
||||
error = -1;
|
||||
|
||||
/* Get the flash info. */
|
||||
if (!error)
|
||||
error = alt_get_flash_info(fd, ®ions, &numRegions);
|
||||
|
||||
/* Find the last flash sector. */
|
||||
if (!error)
|
||||
{
|
||||
pLastRegion = &(regions[0]);
|
||||
for (n = 1; n < numRegions; n++)
|
||||
{
|
||||
if (regions[n].offset > pLastRegion->offset)
|
||||
pLastRegion = &(regions[n]);
|
||||
}
|
||||
lastFlashSectorOffset = pLastRegion->offset
|
||||
+ pLastRegion->region_size
|
||||
- pLastRegion->block_size;
|
||||
}
|
||||
|
||||
/* Return results. */
|
||||
if (!error)
|
||||
*pLastFlashSectorOffset = lastFlashSectorOffset;
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* sensor.c
|
||||
*
|
||||
* Created on: Aug 19, 2019
|
||||
* Author: mdziewiecki
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "includes.h"
|
||||
#include <system.h>
|
||||
#include <io.h>
|
||||
#include <altera_msgdma.h>
|
||||
|
||||
/* Nichestack definitions */
|
||||
#include "ipport.h"
|
||||
#include "libport.h"
|
||||
#include "osport.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "dev_commands.h"
|
||||
#include "sensor.h"
|
||||
|
||||
|
||||
void sensor_command_bit(alt_u32 base, alt_u8 bitmask, alt_u8 state)
|
||||
{
|
||||
alt_u8 tmp = IORD_8DIRECT(base, SENSOR_REG_COMMAND);
|
||||
if (state)
|
||||
tmp |= bitmask;
|
||||
else
|
||||
tmp &= ~bitmask;
|
||||
IOWR_8DIRECT(base, SENSOR_REG_COMMAND, tmp);
|
||||
}
|
||||
|
||||
|
||||
void sensor_preconfigure(alt_u32 base)
|
||||
{
|
||||
printf(" *** Preconfiguring sensor module... \n");
|
||||
|
||||
sensor_command(base, 0); //disable
|
||||
sensor_set_sensorclk(base, 6); //sensor clock - 3.57 MHz
|
||||
sensor_set_adccnv(base, 31); //conversion delay - default
|
||||
sensor_set_delay(base, 1); //trigger delay - default
|
||||
sensor_set_shutter(base, 100); //integration time - dummy default
|
||||
sensor_set_serspeed(base, 50); //synchro serial port - 1 Mbps
|
||||
sensor_set_header_anydata(base, 0x00); //should be 0
|
||||
sensor_set_header_cmd(base, COMMAND_DATA_TRANSFER); //command header, must be this one
|
||||
sensor_command(base, 1); //enable, gain low, SCLK full
|
||||
|
||||
sensor_set_cluster_threshold(base, 10); //default cluster threshold 10
|
||||
sensor_set_cluster_size(base, 4); //default cluster size 4
|
||||
sensor_set_in_algo_threshold(base, 4); //default algo threshold 4
|
||||
|
||||
}
|
@ -1,332 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. All use of this software and documentation is *
|
||||
* subject to the License Agreement located at the end of this file below. *
|
||||
*******************************************************************************
|
||||
* Date - October 24, 2006 *
|
||||
* Module - simple_socket_server.c *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Simple Socket Server (SSS) example.
|
||||
*
|
||||
* This example demonstrates the use of MicroC/OS-II running on NIOS II.
|
||||
* In addition it is to serve as a good starting point for designs using
|
||||
* MicroC/OS-II and Altera NicheStack TCP/IP Stack - NIOS II Edition.
|
||||
*
|
||||
* -Known Issues
|
||||
* None.
|
||||
*
|
||||
* Please refer to the Altera NicheStack Tutorial documentation for details on this
|
||||
* software example, as well as details on how to configure the NicheStack TCP/IP
|
||||
* networking stack and MicroC/OS-II Real-Time Operating System.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* MicroC/OS-II definitions */
|
||||
#include "includes.h"
|
||||
|
||||
/* Simple Socket Server definitions */
|
||||
#include "socket_server.h"
|
||||
//#include "alt_error_handler.h"
|
||||
|
||||
/* Nichestack definitions */
|
||||
#include "ipport.h"
|
||||
#include "tcpport.h"
|
||||
#include "libport.h"
|
||||
#include "osport.h"
|
||||
|
||||
|
||||
static OS_EVENT *mutex;
|
||||
|
||||
static SSConn connections[NR_CHANNELS];
|
||||
|
||||
TK_OBJECT(to_sslistenertask);
|
||||
TK_ENTRY(SSListenerTask);
|
||||
|
||||
struct inet_taskinfo sslistenertask =
|
||||
{
|
||||
&to_sslistenertask,
|
||||
"socket server listener",
|
||||
SSListenerTask,
|
||||
SS_LISTENER_TASK_PRIORITY,
|
||||
SS_LISTENER_STACK_SIZE,
|
||||
};
|
||||
|
||||
// ********************************************************
|
||||
|
||||
|
||||
|
||||
void ss_reset_connection(SSConn* conn) //called e.g. after closing a socket
|
||||
{
|
||||
conn->fd_conn = -1;
|
||||
conn->state = LISTENING;
|
||||
return;
|
||||
}
|
||||
|
||||
void ss_initialize_connection(SSConn* conn) //called only at initialization
|
||||
{
|
||||
conn->fd_conn = -1;
|
||||
conn->fd_listen = -1;
|
||||
conn->listenport = -1;
|
||||
conn->state = FREE;
|
||||
return;
|
||||
}
|
||||
|
||||
void ss_handle_accept(SSConn* conn)
|
||||
{
|
||||
int socket;
|
||||
int len;
|
||||
struct sockaddr_in incoming_addr;
|
||||
|
||||
INT8U err;
|
||||
OSMutexPend(mutex, 0, &err);
|
||||
|
||||
len = sizeof(incoming_addr);
|
||||
|
||||
//Close old connection if needed
|
||||
if ((conn)->fd_conn != -1)
|
||||
{
|
||||
printf("[ss_handle_accept] closing old connection\n");
|
||||
close(conn->fd_conn);
|
||||
ss_reset_connection(conn);
|
||||
}
|
||||
|
||||
if((socket=accept(conn->fd_listen,(struct sockaddr*)&incoming_addr,&len))<0)
|
||||
{
|
||||
//alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE,
|
||||
// "[ss_handle_accept] accept failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
(conn)->fd_conn = socket;
|
||||
(conn)->state = CONNECTED;
|
||||
printf("[ss_handle_accept] accepted connection request from %s\n",
|
||||
inet_ntoa(incoming_addr.sin_addr));
|
||||
}
|
||||
|
||||
OSMutexPost(mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Listener Task()
|
||||
*/
|
||||
void SSListenerTask(void* param)
|
||||
{
|
||||
|
||||
int max_socket = 0;
|
||||
BSD_TIMEVAL_T timeout;
|
||||
|
||||
INT8U err;
|
||||
OSMutexPend(mutex, 0, &err); //wrap initialization in a mutex - just in case...
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 100000;
|
||||
|
||||
fd_set readfds; //set of descriptors
|
||||
|
||||
for (int ch = 0; ch < NR_CHANNELS; ch++)
|
||||
if ((connections[ch].fd_listen = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
//printf("Errot initializing socket #%d!\n", ch);
|
||||
//alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE,"[sss_task] Socket creation failed");
|
||||
}
|
||||
|
||||
//Binding etc. is done by ethernet_listen()
|
||||
|
||||
OSMutexPost(mutex);
|
||||
|
||||
//Now run in loop to handle incoming requests on all listening ports
|
||||
while(1)
|
||||
{
|
||||
FD_ZERO(&readfds);
|
||||
|
||||
for (int ch = 0; ch < NR_CHANNELS; ch++)
|
||||
if (connections[ch].listenport >= 0)
|
||||
{
|
||||
FD_SET(connections[ch].fd_listen, &readfds);
|
||||
if (connections[ch].fd_listen >= max_socket)
|
||||
max_socket = connections[ch].fd_listen+1;
|
||||
}
|
||||
|
||||
if (max_socket == 0)
|
||||
TK_SLEEP(10); //just sleep a bit if nothing to do
|
||||
else
|
||||
{
|
||||
select(max_socket, &readfds, NULL, NULL, &timeout); //we must timeout from time to time to find newly set-up channels
|
||||
|
||||
for (int ch = 0; ch < NR_CHANNELS; ch++)
|
||||
if (FD_ISSET(connections[ch].fd_listen, &readfds))
|
||||
ss_handle_accept(&(connections[ch]));
|
||||
}
|
||||
} /* while(1) */
|
||||
|
||||
//never come here
|
||||
}
|
||||
|
||||
|
||||
// ****************** User interface ********************
|
||||
|
||||
int ethernet_init()
|
||||
{
|
||||
INT8U err;
|
||||
mutex = OSMutexCreate(SS_LISTENER_TASK_PRIORITY-1, &err);
|
||||
|
||||
|
||||
for (int ch = 0; ch < NR_CHANNELS; ch++)
|
||||
ss_initialize_connection(&(connections[ch]));
|
||||
|
||||
TK_NEWTASK(&sslistenertask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ethernet_listen(int channel, int port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
|
||||
INT8U err;
|
||||
OSMutexPend(mutex, 0, &err);
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
addr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
if (bind(connections[channel].fd_listen,(struct sockaddr *)&addr,sizeof(addr)) < 0)
|
||||
{
|
||||
//alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE,"[sss_task] Bind failed");
|
||||
OSMutexPost(mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (listen(connections[channel].fd_listen,1) < 0)
|
||||
{
|
||||
//alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE,"[sss_task] Listen failed");
|
||||
OSMutexPost(mutex);
|
||||
return -2;
|
||||
}
|
||||
|
||||
ss_reset_connection(&(connections[channel]));
|
||||
connections[channel].listenport = port;
|
||||
printf("[sss_task] Simple Socket Server listening on port %d\n", port);
|
||||
|
||||
OSMutexPost(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ethernet_write(int channel, int size, unsigned char* data)
|
||||
{
|
||||
int result;
|
||||
|
||||
INT8U err;
|
||||
OSMutexPend(mutex, 0, &err);
|
||||
|
||||
if (connections[channel].fd_conn == -1) //socket is closed or channel unconfigured
|
||||
{
|
||||
OSMutexPost(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = (int)send(connections[channel].fd_conn, data, size, 0);
|
||||
if (result == -1)
|
||||
{
|
||||
printf("[ethernet_write] closing connection due to error\n");
|
||||
close(connections[channel].fd_conn); //close connection on error
|
||||
ss_reset_connection(&(connections[channel]));
|
||||
result = 0;
|
||||
}
|
||||
|
||||
OSMutexPost(mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
int ethernet_read(int channel, int size, unsigned char* data)
|
||||
{
|
||||
fd_set readfds; //set of descriptors
|
||||
int max_socket;
|
||||
BSD_TIMEVAL_T timeout;
|
||||
int result;
|
||||
|
||||
INT8U err;
|
||||
OSMutexPend(mutex, 0, &err);
|
||||
|
||||
if (connections[channel].fd_conn == -1) //socket is closed or channel unconfigured
|
||||
{
|
||||
OSMutexPost(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//prepare call parameters
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(connections[channel].fd_conn, &readfds);
|
||||
max_socket = connections[channel].fd_conn+1;
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
//check for data
|
||||
if (select(max_socket, &readfds, NULL, NULL, &timeout))
|
||||
if (FD_ISSET(connections[channel].fd_conn, &readfds))
|
||||
{
|
||||
result = (int)recv(connections[channel].fd_conn, data, size, 0);
|
||||
if (result == -1)
|
||||
{
|
||||
printf("[ethernet_read] closing connection due to error\n");
|
||||
close(connections[channel].fd_conn); //close connection on error
|
||||
ss_reset_connection(&(connections[channel]));
|
||||
result = 0;
|
||||
}
|
||||
OSMutexPost(mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
OSMutexPost(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ethernet_close(int channel)
|
||||
{
|
||||
INT8U err;
|
||||
OSMutexPend(mutex, 0, &err);
|
||||
|
||||
close(connections[channel].fd_conn);
|
||||
ss_reset_connection(&(connections[channel]));
|
||||
|
||||
OSMutexPost(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
@ -1,12 +0,0 @@
|
||||
#ifdef ALT_INICHE
|
||||
#include "ipport.h"
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "altera_avalon_tse.h"
|
||||
#include "altera_avalon_tse_system_info.h"
|
||||
|
||||
alt_tse_system_info tse_mac_device[MAXNETS] = {
|
||||
TSE_SYSTEM_EXT_MEM_NO_SHARED_FIFO(ETH_TSE, 0, MSGDMA_TX, MSGDMA_RX, TSE_PHY_AUTO_ADDRESS, &marvell_cfg_rgmii, DESCRIPTOR_MEMORY)
|
||||
|
||||
};
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* udpgen.c
|
||||
*
|
||||
* Created on: Aug 7, 2019
|
||||
* Author: mdziewiecki
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "includes.h"
|
||||
#include <system.h>
|
||||
#include <io.h>
|
||||
#include <altera_msgdma.h>
|
||||
|
||||
/* Nichestack definitions */
|
||||
#include "ipport.h"
|
||||
#include "libport.h"
|
||||
#include "osport.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#include "udpgen.h"
|
||||
|
||||
//*******************************************************************
|
||||
|
||||
|
||||
void udpgen_command_bit(alt_u32 base, alt_u8 bitmask, alt_u8 state)
|
||||
{
|
||||
alt_u8 tmp = IORD_8DIRECT(base, UDPGEN_REG_CSR);
|
||||
if (state)
|
||||
tmp |= bitmask;
|
||||
else
|
||||
tmp &= ~bitmask;
|
||||
IOWR_8DIRECT(base, UDPGEN_REG_CSR, tmp);
|
||||
}
|
||||
|
||||
void udpgen_test(alt_u32 base)
|
||||
{
|
||||
printf (" *** Setting up UDP generator... \n");
|
||||
|
||||
unsigned char dstmac[] = {0x18, 0xd6, 0xc7, 0x05, 0xaa, 0x63};
|
||||
unsigned char srcip[] = {10,0,7,17};
|
||||
unsigned char dstip[] = {10,0,7,1};
|
||||
|
||||
udpgen_command(UDP_GENERATOR_BASE, 0x01);
|
||||
udpgen_set_size(UDP_GENERATOR_BASE, 16);
|
||||
udpgen_set_srcip_a(UDP_GENERATOR_BASE, srcip);
|
||||
udpgen_set_dstip_a(UDP_GENERATOR_BASE, dstip);
|
||||
udpgen_set_srcport(UDP_GENERATOR_BASE, 4096);
|
||||
udpgen_set_dstport(UDP_GENERATOR_BASE, 4097);
|
||||
udpgen_set_dstmac_a(UDP_GENERATOR_BASE, dstmac);
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
* utils.c
|
||||
*
|
||||
* Created on: Jul 31, 2019
|
||||
* Author: mdziewiecki
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "includes.h"
|
||||
#include <system.h>
|
||||
#include <io.h>
|
||||
|
||||
/* Nichestack definitions */
|
||||
#include "ipport.h"
|
||||
#include "libport.h"
|
||||
#include "osport.h"
|
||||
|
||||
#include "altera_avalon_pio_regs.h"
|
||||
#include "altera_avalon_timer_regs.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "sensor.h"
|
||||
|
||||
alt_u16 delays[2];
|
||||
alt_u8 mastermode;
|
||||
|
||||
//******************************************************
|
||||
|
||||
//Swap odd/even bytes in a bunch of data to align endianness of shorts
|
||||
void swap_bytes(unsigned char* array, int size_bytes)
|
||||
{
|
||||
for (int i = 0; i < size_bytes; i+= 2)
|
||||
{
|
||||
unsigned char tmp = array[i];
|
||||
array[i] = array[i+1];
|
||||
array[i+1] = tmp;
|
||||
}
|
||||
}
|
||||
//The same, but four-byte-wise
|
||||
void swap_quad(unsigned char* array, int size_bytes)
|
||||
{
|
||||
unsigned char buf[4];
|
||||
|
||||
for (int i = 0; i < size_bytes; i+= 4)
|
||||
{
|
||||
memcpy(buf, array+i, 4);
|
||||
for (int j = 0; j < 4; j++)
|
||||
array[i+j] = buf[3-j];
|
||||
}
|
||||
}
|
||||
|
||||
//trigger FPGA reload
|
||||
void reload_fpga()
|
||||
{
|
||||
printf("$$$$ RECONFIGURING FPGA!!! $$$$\n");
|
||||
//TK_SLEEP(100); //let it print the message before dying
|
||||
//IOWR(DUAL_BOOT_BASE, 0, 0x1);
|
||||
printf("*** DISABLED! ***\n");
|
||||
}
|
||||
|
||||
void masterslave(alt_u8 master)
|
||||
{
|
||||
if (master)
|
||||
IOWR_ALTERA_AVALON_PIO_SET_BITS(OUTPUT_PIO_BASE, 0x80);
|
||||
else
|
||||
IOWR_ALTERA_AVALON_PIO_CLEAR_BITS(OUTPUT_PIO_BASE, 0x80);
|
||||
mastermode = master;
|
||||
set_delay(mastermode, delays[mastermode]); //update sensor delay setting
|
||||
}
|
||||
|
||||
void master_clock_period(alt_u32 period)
|
||||
{
|
||||
//set period
|
||||
IOWR_ALTERA_AVALON_TIMER_PERIODL(FRAME_TIMER_BASE, (alt_u16)(period & 0xFFFF));
|
||||
IOWR_ALTERA_AVALON_TIMER_PERIODH(FRAME_TIMER_BASE, (alt_u16)((period>>16) & 0xFFFF));
|
||||
//start timer in continuous mode
|
||||
//IOWR_ALTERA_AVALON_TIMER_CONTROL(FRAME_TIMER_BASE,
|
||||
// ALTERA_AVALON_TIMER_CONTROL_CONT_MSK);
|
||||
}
|
||||
|
||||
void master_clock_enable(alt_u8 en)
|
||||
{
|
||||
alt_u16 tmp = 0; // = IORD_ALTERA_AVALON_TIMER_CONTROL(FRAME_TIMER_BASE);
|
||||
|
||||
if (en)
|
||||
tmp |= ALTERA_AVALON_TIMER_CONTROL_START_MSK | ALTERA_AVALON_TIMER_CONTROL_CONT_MSK;
|
||||
else
|
||||
tmp |= ALTERA_AVALON_TIMER_CONTROL_STOP_MSK;
|
||||
|
||||
IOWR_ALTERA_AVALON_TIMER_CONTROL(FRAME_TIMER_BASE,tmp);
|
||||
}
|
||||
|
||||
void led_set(alt_u8 led_nr)
|
||||
{
|
||||
if (led_nr > 4)
|
||||
return;
|
||||
IOWR_ALTERA_AVALON_PIO_SET_BITS(OUTPUT_PIO_BASE, 1<<led_nr);
|
||||
}
|
||||
|
||||
void led_clear(alt_u8 led_nr)
|
||||
{
|
||||
if (led_nr > 4)
|
||||
return;
|
||||
IOWR_ALTERA_AVALON_PIO_CLEAR_BITS(OUTPUT_PIO_BASE, 1<<led_nr);
|
||||
}
|
||||
|
||||
void led_toggle(alt_u8 led_nr)
|
||||
{
|
||||
if (led_nr > 4)
|
||||
return;
|
||||
alt_u32 tmp = IORD_ALTERA_AVALON_PIO_DATA(OUTPUT_PIO_BASE);
|
||||
tmp ^= (1<<led_nr);
|
||||
IOWR_ALTERA_AVALON_PIO_DATA(OUTPUT_PIO_BASE, 1<<led_nr);
|
||||
}
|
||||
|
||||
void led4_blink_enable(alt_u8 en)
|
||||
{
|
||||
if (en)
|
||||
IOWR_ALTERA_AVALON_PIO_CLEAR_BITS(OUTPUT_PIO_BASE, 1<<5);
|
||||
else
|
||||
IOWR_ALTERA_AVALON_PIO_SET_BITS(OUTPUT_PIO_BASE, 1<<5);
|
||||
}
|
||||
|
||||
void set_delay(alt_u8 master, alt_u16 value)
|
||||
{
|
||||
delays[master] = value;
|
||||
if (master == mastermode)
|
||||
sensor_set_delay(SENSOR_INTERFACE_BASE, value); //update sensor setting only if right mode
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<buildSystem id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402">
|
||||
<storageModule id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402" moduleId="org.eclipse.cdt.core.settings"/>
|
||||
</buildSystem>
|
||||
<cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402">
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402" name="Nios II" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402." name="/" resourcePath="">
|
||||
<toolChain id="altera.nios2.mingw.gcc4.227679741" name="MinGW Nios II GCC4" superClass="altera.nios2.mingw.gcc4">
|
||||
<targetPlatform id="altera.nios2.mingw.gcc4.1312510757" name="Nios II" superClass="altera.nios2.mingw.gcc4"/>
|
||||
<builder arguments="make" buildPath="${workspace_loc://hit_pat_bsp}" command="wsl" id="altera.tool.gnu.builder.mingw.163976787" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="altera.tool.gnu.builder.mingw"/>
|
||||
<tool id="altera.tool.gnu.c.compiler.mingw.915216031" name="Nios II GCC C Compiler" superClass="altera.tool.gnu.c.compiler.mingw">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.599954381" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="altera.tool.gnu.cpp.compiler.mingw.1740577271" name="Nios II GCC C++ Compiler" superClass="altera.tool.gnu.cpp.compiler.mingw">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2008249437" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="altera.tool.gnu.archiver.mingw.329269306" name="Nios II GCC Archiver" superClass="altera.tool.gnu.archiver.mingw"/>
|
||||
<tool id="altera.tool.gnu.c.linker.mingw.1482216224" name="Nios II GCC C Linker" superClass="altera.tool.gnu.c.linker.mingw"/>
|
||||
<tool id="altera.tool.gnu.assembler.mingw.335293919" name="Nios II GCC Assembler" superClass="altera.tool.gnu.assembler.mingw">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1673781415" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402" moduleId="org.eclipse.cdt.core.settings" name="Nios II">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="hit_pat_bsp.null.544219125" name="hit_pat_bsp"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402.;altera.tool.gnu.cpp.compiler.mingw.1740577271;cdt.managedbuild.tool.gnu.cpp.compiler.input.2008249437">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1277902402.;altera.tool.gnu.c.compiler.mingw.915216031;cdt.managedbuild.tool.gnu.c.compiler.input.599954381">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Nios II">
|
||||
<resource resourceType="PROJECT" workspacePath="/hit_pat_bsp"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
</cproject>
|
@ -1,54 +0,0 @@
|
||||
#ifndef __ALT_TYPES_H__
|
||||
#define __ALT_TYPES_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Don't declare these typedefs if this file is included by assembly source.
|
||||
*/
|
||||
#ifndef ALT_ASM_SRC
|
||||
typedef signed char alt_8;
|
||||
typedef unsigned char alt_u8;
|
||||
typedef signed short alt_16;
|
||||
typedef unsigned short alt_u16;
|
||||
typedef signed long alt_32;
|
||||
typedef unsigned long alt_u32;
|
||||
typedef long long alt_64;
|
||||
typedef unsigned long long alt_u64;
|
||||
#endif
|
||||
|
||||
#define ALT_INLINE __inline__
|
||||
#define ALT_ALWAYS_INLINE __attribute__ ((always_inline))
|
||||
#define ALT_WEAK __attribute__((weak))
|
||||
|
||||
#endif /* __ALT_TYPES_H__ */
|
@ -1,80 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Support for the Nios II internal interrupt controller.
|
||||
*/
|
||||
|
||||
#ifndef __ALT_NIOS2_GEN2_IRQ_H__
|
||||
#define __ALT_NIOS2_GEN2_IRQ_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The macro ALTERA_NIOS2_GEN2_IRQ_INSTANCE is used by the alt_irq_init()
|
||||
* function in the auto-generated file alt_sys_init.c to create an
|
||||
* instance of this interrupt controller device driver state if this
|
||||
* module contains an interrupt controller.
|
||||
* Only one instance of a Nios II is allowed so this macro is just empty.
|
||||
*/
|
||||
|
||||
#define ALTERA_NIOS2_GEN2_IRQ_INSTANCE(name, state)
|
||||
|
||||
/*
|
||||
* altera_nios2_gen2_irq_init() is called by the auto-generated function
|
||||
* alt_irq_init() once for the Nios II if it contains an interrupt controller.
|
||||
* The altera_nios2_gen2_irq_init() routine is called using the
|
||||
* ALTERA_NIOS2_GEN2_IRQ_INIT macro given below.
|
||||
*
|
||||
* This function initializes the internal interrupt controller
|
||||
* so is not called if the Nios II contains an external interrupt
|
||||
* controller port (because the internal interrupt controller
|
||||
* is removed if this port is present).
|
||||
*/
|
||||
|
||||
extern void altera_nios2_gen2_irq_init( void );
|
||||
|
||||
/*
|
||||
* The macro ALTERA_NIOS2_GEN2_IRQ_INIT is used by the alt_irq_init() routine
|
||||
* in the auto-generated file alt_sys_init.c to initialize an instance
|
||||
* of the interrupt controller device driver state.
|
||||
*/
|
||||
|
||||
#define ALTERA_NIOS2_GEN2_IRQ_INIT(name, state) altera_nios2_gen2_irq_init()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ALT_NIOS2_ULTRA_IRQ_H__ */
|
||||
|
@ -1,65 +0,0 @@
|
||||
#ifndef __INCLUDES_H__
|
||||
#define __INCLUDES_H__
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* uC/OS-II
|
||||
* The Real-Time Kernel
|
||||
*
|
||||
* (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
|
||||
* All Rights Reserved
|
||||
*
|
||||
* MASTER INCLUDE FILE
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "os_cpu.h"
|
||||
#include "os_cfg.h"
|
||||
#include "ucos_ii.h"
|
||||
|
||||
#ifdef ONT_GLOBALS
|
||||
#define ONT_EXT
|
||||
#else
|
||||
#define ONT_EXT extern
|
||||
#endif
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* DATA TYPES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char TaskName[30];
|
||||
INT16U TaskCtr;
|
||||
INT16U TaskExecTime;
|
||||
INT32U TaskTotExecTime;
|
||||
} TASK_USER_DATA;
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* VARIABLES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
ONT_EXT TASK_USER_DATA TaskUserData[10];
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* FUNCTION PROTOTYPES
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
void DispTaskStat(INT8U id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __INCLUDES_H__ */
|
||||
|
@ -1,81 +0,0 @@
|
||||
#ifndef __IO_H__
|
||||
#define __IO_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/* IO Header file for Nios II Toolchain */
|
||||
|
||||
#include "alt_types.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef SYSTEM_BUS_WIDTH
|
||||
#define SYSTEM_BUS_WIDTH 32
|
||||
#endif
|
||||
|
||||
/* Dynamic bus access functions */
|
||||
|
||||
#define __IO_CALC_ADDRESS_DYNAMIC(BASE, OFFSET) \
|
||||
((void *)(((alt_u8*)BASE) + (OFFSET)))
|
||||
|
||||
#define IORD_32DIRECT(BASE, OFFSET) \
|
||||
__builtin_ldwio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)))
|
||||
#define IORD_16DIRECT(BASE, OFFSET) \
|
||||
__builtin_ldhuio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)))
|
||||
#define IORD_8DIRECT(BASE, OFFSET) \
|
||||
__builtin_ldbuio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)))
|
||||
|
||||
#define IOWR_32DIRECT(BASE, OFFSET, DATA) \
|
||||
__builtin_stwio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)), (DATA))
|
||||
#define IOWR_16DIRECT(BASE, OFFSET, DATA) \
|
||||
__builtin_sthio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)), (DATA))
|
||||
#define IOWR_8DIRECT(BASE, OFFSET, DATA) \
|
||||
__builtin_stbio (__IO_CALC_ADDRESS_DYNAMIC ((BASE), (OFFSET)), (DATA))
|
||||
|
||||
/* Native bus access functions */
|
||||
|
||||
#define __IO_CALC_ADDRESS_NATIVE(BASE, REGNUM) \
|
||||
((void *)(((alt_u8*)BASE) + ((REGNUM) * (SYSTEM_BUS_WIDTH/8))))
|
||||
|
||||
#define IORD(BASE, REGNUM) \
|
||||
__builtin_ldwio (__IO_CALC_ADDRESS_NATIVE ((BASE), (REGNUM)))
|
||||
#define IOWR(BASE, REGNUM, DATA) \
|
||||
__builtin_stwio (__IO_CALC_ADDRESS_NATIVE ((BASE), (REGNUM)), (DATA))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __IO_H__ */
|
@ -1,300 +0,0 @@
|
||||
#ifndef __NIOS2_H__
|
||||
#define __NIOS2_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This header provides processor specific macros for accessing the Nios2
|
||||
* control registers.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Number of available IRQs in internal interrupt controller.
|
||||
*/
|
||||
#define NIOS2_NIRQ 32
|
||||
|
||||
/*
|
||||
* Macros for accessing select Nios II general-purpose registers.
|
||||
*/
|
||||
|
||||
/* ET (Exception Temporary) register */
|
||||
#define NIOS2_READ_ET(et) \
|
||||
do { __asm ("mov %0, et" : "=r" (et) ); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_ET(et) \
|
||||
do { __asm volatile ("mov et, %z0" : : "rM" (et)); } while (0)
|
||||
|
||||
/* SP (Stack Pointer) register */
|
||||
#define NIOS2_READ_SP(sp) \
|
||||
do { __asm ("mov %0, sp" : "=r" (sp) ); } while (0)
|
||||
|
||||
/*
|
||||
* Macros for useful processor instructions.
|
||||
*/
|
||||
#define NIOS2_BREAK() \
|
||||
do { __asm volatile ("break"); } while (0)
|
||||
|
||||
#define NIOS2_REPORT_STACK_OVERFLOW() \
|
||||
do { __asm volatile("break 3"); } while (0)
|
||||
|
||||
/*
|
||||
* Macros for accessing Nios II control registers.
|
||||
*/
|
||||
#define NIOS2_READ_STATUS(dest) \
|
||||
do { dest = __builtin_rdctl(0); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_STATUS(src) \
|
||||
do { __builtin_wrctl(0, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_ESTATUS(dest) \
|
||||
do { dest = __builtin_rdctl(1); } while (0)
|
||||
|
||||
#define NIOS2_READ_BSTATUS(dest) \
|
||||
do { dest = __builtin_rdctl(2); } while (0)
|
||||
|
||||
#define NIOS2_READ_IENABLE(dest) \
|
||||
do { dest = __builtin_rdctl(3); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_IENABLE(src) \
|
||||
do { __builtin_wrctl(3, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_IPENDING(dest) \
|
||||
do { dest = __builtin_rdctl(4); } while (0)
|
||||
|
||||
#define NIOS2_READ_CPUID(dest) \
|
||||
do { dest = __builtin_rdctl(5); } while (0)
|
||||
|
||||
#define NIOS2_READ_EXCEPTION(dest) \
|
||||
do { dest = __builtin_rdctl(7); } while (0)
|
||||
|
||||
#define NIOS2_READ_PTEADDR(dest) \
|
||||
do { dest = __builtin_rdctl(8); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_PTEADDR(src) \
|
||||
do { __builtin_wrctl(8, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_TLBACC(dest) \
|
||||
do { dest = __builtin_rdctl(9); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_TLBACC(src) \
|
||||
do { __builtin_wrctl(9, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_TLBMISC(dest) \
|
||||
do { dest = __builtin_rdctl(10); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_TLBMISC(src) \
|
||||
do { __builtin_wrctl(10, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_ECCINJ(dest) \
|
||||
do { dest = __builtin_rdctl(11); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_ECCINJ(src) \
|
||||
do { __builtin_wrctl(11, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_BADADDR(dest) \
|
||||
do { dest = __builtin_rdctl(12); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_CONFIG(src) \
|
||||
do { __builtin_wrctl(13, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_CONFIG(dest) \
|
||||
do { dest = __builtin_rdctl(13); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_MPUBASE(src) \
|
||||
do { __builtin_wrctl(14, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_MPUBASE(dest) \
|
||||
do { dest = __builtin_rdctl(14); } while (0)
|
||||
|
||||
#define NIOS2_WRITE_MPUACC(src) \
|
||||
do { __builtin_wrctl(15, src); } while (0)
|
||||
|
||||
#define NIOS2_READ_MPUACC(dest) \
|
||||
do { dest = __builtin_rdctl(15); } while (0)
|
||||
|
||||
/*
|
||||
* Nios II control registers that are always present
|
||||
*/
|
||||
#define NIOS2_STATUS status
|
||||
#define NIOS2_ESTATUS estatus
|
||||
#define NIOS2_BSTATUS bstatus
|
||||
#define NIOS2_IENABLE ienable
|
||||
#define NIOS2_IPENDING ipending
|
||||
#define NIOS2_CPUID cpuid
|
||||
|
||||
/*
|
||||
* Bit masks & offsets for Nios II control registers.
|
||||
* The presence and size of a field is sometimes dependent on the Nios II
|
||||
* configuration. Bit masks for every possible field and the maximum size of
|
||||
* that field are defined.
|
||||
*
|
||||
* All bit-masks are expressed relative to the position
|
||||
* of the data with a register. To read data that is LSB-
|
||||
* aligned, the register read data should be masked, then
|
||||
* right-shifted by the designated "OFST" macro value. The
|
||||
* opposite should be used for register writes when starting
|
||||
* with LSB-aligned data.
|
||||
*/
|
||||
|
||||
/* STATUS, ESTATUS, BSTATUS, and SSTATUS registers */
|
||||
#define NIOS2_STATUS_PIE_MSK (0x00000001)
|
||||
#define NIOS2_STATUS_PIE_OFST (0)
|
||||
#define NIOS2_STATUS_U_MSK (0x00000002)
|
||||
#define NIOS2_STATUS_U_OFST (1)
|
||||
#define NIOS2_STATUS_EH_MSK (0x00000004)
|
||||
#define NIOS2_STATUS_EH_OFST (2)
|
||||
#define NIOS2_STATUS_IH_MSK (0x00000008)
|
||||
#define NIOS2_STATUS_IH_OFST (3)
|
||||
#define NIOS2_STATUS_IL_MSK (0x000003f0)
|
||||
#define NIOS2_STATUS_IL_OFST (4)
|
||||
#define NIOS2_STATUS_CRS_MSK (0x0000fc00)
|
||||
#define NIOS2_STATUS_CRS_OFST (10)
|
||||
#define NIOS2_STATUS_PRS_MSK (0x003f0000)
|
||||
#define NIOS2_STATUS_PRS_OFST (16)
|
||||
#define NIOS2_STATUS_NMI_MSK (0x00400000)
|
||||
#define NIOS2_STATUS_NMI_OFST (22)
|
||||
#define NIOS2_STATUS_RSIE_MSK (0x00800000)
|
||||
#define NIOS2_STATUS_RSIE_OFST (23)
|
||||
#define NIOS2_STATUS_SRS_MSK (0x80000000)
|
||||
#define NIOS2_STATUS_SRS_OFST (31)
|
||||
|
||||
/* EXCEPTION register */
|
||||
#define NIOS2_EXCEPTION_REG_CAUSE_MASK (0x0000007c)
|
||||
#define NIOS2_EXCEPTION_REG_CAUSE_OFST (2)
|
||||
#define NIOS2_EXCEPTION_REG_ECCFTL_MASK (0x80000000)
|
||||
#define NIOS2_EXCEPTION_REG_ECCFTL_OFST (31)
|
||||
|
||||
/* PTEADDR (Page Table Entry Address) register */
|
||||
#define NIOS2_PTEADDR_REG_VPN_OFST 2
|
||||
#define NIOS2_PTEADDR_REG_VPN_MASK 0x3ffffc
|
||||
#define NIOS2_PTEADDR_REG_PTBASE_OFST 22
|
||||
#define NIOS2_PTEADDR_REG_PTBASE_MASK 0xffc00000
|
||||
|
||||
/* TLBACC (TLB Access) register */
|
||||
#define NIOS2_TLBACC_REG_PFN_OFST 0
|
||||
#define NIOS2_TLBACC_REG_PFN_MASK 0xfffff
|
||||
#define NIOS2_TLBACC_REG_G_OFST 20
|
||||
#define NIOS2_TLBACC_REG_G_MASK 0x100000
|
||||
#define NIOS2_TLBACC_REG_X_OFST 21
|
||||
#define NIOS2_TLBACC_REG_X_MASK 0x200000
|
||||
#define NIOS2_TLBACC_REG_W_OFST 22
|
||||
#define NIOS2_TLBACC_REG_W_MASK 0x400000
|
||||
#define NIOS2_TLBACC_REG_R_OFST 23
|
||||
#define NIOS2_TLBACC_REG_R_MASK 0x800000
|
||||
#define NIOS2_TLBACC_REG_C_OFST 24
|
||||
#define NIOS2_TLBACC_REG_C_MASK 0x1000000
|
||||
#define NIOS2_TLBACC_REG_IG_OFST 25
|
||||
#define NIOS2_TLBACC_REG_IG_MASK 0xfe000000
|
||||
|
||||
/* TLBMISC (TLB Miscellaneous) register */
|
||||
#define NIOS2_TLBMISC_REG_D_OFST 0
|
||||
#define NIOS2_TLBMISC_REG_D_MASK 0x1
|
||||
#define NIOS2_TLBMISC_REG_PERM_OFST 1
|
||||
#define NIOS2_TLBMISC_REG_PERM_MASK 0x2
|
||||
#define NIOS2_TLBMISC_REG_BAD_OFST 2
|
||||
#define NIOS2_TLBMISC_REG_BAD_MASK 0x4
|
||||
#define NIOS2_TLBMISC_REG_DBL_OFST 3
|
||||
#define NIOS2_TLBMISC_REG_DBL_MASK 0x8
|
||||
#define NIOS2_TLBMISC_REG_PID_OFST 4
|
||||
#define NIOS2_TLBMISC_REG_PID_MASK 0x3fff0
|
||||
#define NIOS2_TLBMISC_REG_WE_OFST 18
|
||||
#define NIOS2_TLBMISC_REG_WE_MASK 0x40000
|
||||
#define NIOS2_TLBMISC_REG_RD_OFST 19
|
||||
#define NIOS2_TLBMISC_REG_RD_MASK 0x80000
|
||||
#define NIOS2_TLBMISC_REG_WAY_OFST 20
|
||||
#define NIOS2_TLBMISC_REG_WAY_MASK 0xf00000
|
||||
#define NIOS2_TLBMISC_REG_EE_OFST 24
|
||||
#define NIOS2_TLBMISC_REG_EE_MASK 0x1000000
|
||||
|
||||
/* ECCINJ (ECC Inject) register */
|
||||
#define NIOS2_ECCINJ_REG_RF_OFST 0
|
||||
#define NIOS2_ECCINJ_REG_RF_MASK 0x3
|
||||
#define NIOS2_ECCINJ_REG_ICTAG_OFST 2
|
||||
#define NIOS2_ECCINJ_REG_ICTAG_MASK 0xc
|
||||
#define NIOS2_ECCINJ_REG_ICDAT_OFST 4
|
||||
#define NIOS2_ECCINJ_REG_ICDAT_MASK 0x30
|
||||
#define NIOS2_ECCINJ_REG_DCTAG_OFST 6
|
||||
#define NIOS2_ECCINJ_REG_DCTAG_MASK 0xc0
|
||||
#define NIOS2_ECCINJ_REG_DCDAT_OFST 8
|
||||
#define NIOS2_ECCINJ_REG_DCDAT_MASK 0x300
|
||||
#define NIOS2_ECCINJ_REG_TLB_OFST 10
|
||||
#define NIOS2_ECCINJ_REG_TLB_MASK 0xc00
|
||||
#define NIOS2_ECCINJ_REG_DTCM0_OFST 12
|
||||
#define NIOS2_ECCINJ_REG_DTCM0_MASK 0x3000
|
||||
#define NIOS2_ECCINJ_REG_DTCM1_OFST 14
|
||||
#define NIOS2_ECCINJ_REG_DTCM1_MASK 0xc000
|
||||
#define NIOS2_ECCINJ_REG_DTCM2_OFST 16
|
||||
#define NIOS2_ECCINJ_REG_DTCM2_MASK 0x30000
|
||||
#define NIOS2_ECCINJ_REG_DTCM3_OFST 18
|
||||
#define NIOS2_ECCINJ_REG_DTCM3_MASK 0xc0000
|
||||
|
||||
/* CONFIG register */
|
||||
#define NIOS2_CONFIG_REG_PE_MASK (0x00000001)
|
||||
#define NIOS2_CONFIG_REG_PE_OFST (0)
|
||||
#define NIOS2_CONFIG_REG_ANI_MASK (0x00000002)
|
||||
#define NIOS2_CONFIG_REG_ANI_OFST (1)
|
||||
#define NIOS2_CONFIG_REG_ECCEN_MASK (0x00000004)
|
||||
#define NIOS2_CONFIG_REG_ECCEN_OFST (2)
|
||||
#define NIOS2_CONFIG_REG_ECCEXC_MASK (0x00000008)
|
||||
#define NIOS2_CONFIG_REG_ECCEXC_OFST (3)
|
||||
|
||||
/* MPUBASE (MPU Base Address) Register */
|
||||
#define NIOS2_MPUBASE_D_MASK (0x00000001)
|
||||
#define NIOS2_MPUBASE_D_OFST (0)
|
||||
#define NIOS2_MPUBASE_INDEX_MASK (0x0000003e)
|
||||
#define NIOS2_MPUBASE_INDEX_OFST (1)
|
||||
#define NIOS2_MPUBASE_BASE_ADDR_MASK (0xffffffc0)
|
||||
#define NIOS2_MPUBASE_BASE_ADDR_OFST (6)
|
||||
|
||||
/* MPUACC (MPU Access) Register */
|
||||
#define NIOS2_MPUACC_LIMIT_MASK (0xffffffc0)
|
||||
#define NIOS2_MPUACC_LIMIT_OFST (6)
|
||||
#define NIOS2_MPUACC_MASK_MASK (0xffffffc0)
|
||||
#define NIOS2_MPUACC_MASK_OFST (6)
|
||||
#define NIOS2_MPUACC_C_MASK (0x00000020)
|
||||
#define NIOS2_MPUACC_C_OFST (5)
|
||||
#define NIOS2_MPUACC_PERM_MASK (0x0000001c)
|
||||
#define NIOS2_MPUACC_PERM_OFST (2)
|
||||
#define NIOS2_MPUACC_RD_MASK (0x00000002)
|
||||
#define NIOS2_MPUACC_RD_OFST (1)
|
||||
#define NIOS2_MPUACC_WR_MASK (0x00000001)
|
||||
#define NIOS2_MPUACC_WR_OFST (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __NIOS2_H__ */
|
@ -1,145 +0,0 @@
|
||||
#ifndef __OS_CPU_H__
|
||||
#define __OS_CPU_H__
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* uC/OS-II
|
||||
* The Real-Time Kernel
|
||||
*
|
||||
* (c) Copyright 1992-1999, Jean J. Labrosse, Weston, FL
|
||||
* All Rights Reserved
|
||||
*
|
||||
* 80x86/80x88 Specific code
|
||||
* LARGE MEMORY MODEL
|
||||
*
|
||||
* Borland C/C++ V4.51
|
||||
*
|
||||
* File : OS_CPU.H
|
||||
* By : IS (modified from version by Jean J. Labrosse)
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003-5 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "sys/alt_irq.h"
|
||||
|
||||
#ifdef OS_CPU_GLOBALS
|
||||
#define OS_CPU_EXT
|
||||
#else
|
||||
#define OS_CPU_EXT extern
|
||||
#endif
|
||||
|
||||
/*****************************************************************************************
|
||||
/ REVISION HISTORY
|
||||
/
|
||||
*****************************************************************************************/
|
||||
|
||||
/*****************************************************************************************
|
||||
/ DATA TYPES
|
||||
/ (Compiler Specific)
|
||||
*****************************************************************************************/
|
||||
|
||||
/* This is the definition for Nios32. */
|
||||
typedef unsigned char BOOLEAN;
|
||||
typedef unsigned char INT8U; /* Unsigned 8 bit quantity */
|
||||
typedef signed char INT8S; /* Signed 8 bit quantity */
|
||||
typedef unsigned short INT16U; /* Unsigned 16 bit quantity */
|
||||
typedef signed short INT16S; /* Signed 16 bit quantity */
|
||||
typedef unsigned long INT32U; /* Unsigned 32 bit quantity */
|
||||
typedef signed long INT32S; /* Signed 32 bit quantity */
|
||||
typedef float FP32; /* Single precision floating point */
|
||||
typedef double FP64; /* Double precision floating point */
|
||||
typedef unsigned int OS_STK; /* Each stack entry is 32-bits */
|
||||
|
||||
/****************************************************************************
|
||||
* Nios2 Miscellaneous defines
|
||||
****************************************************************************/
|
||||
|
||||
#define OS_STK_GROWTH 1 /* Stack grows from HIGH to LOW memory */
|
||||
#define OS_TASK_SW OSCtxSw
|
||||
|
||||
/******************************************************************************************
|
||||
* Disable and Enable Interrupts - 2 methods
|
||||
*
|
||||
* Method #1: Disable/Enable interrupts using simple instructions. After critical
|
||||
* section, interrupts will be enabled even if they were disabled before
|
||||
* entering the critical section.
|
||||
*
|
||||
* Method #2: Disable/Enable interrupts by preserving the state of interrupts. In
|
||||
* other words, if interrupts were disabled before entering the critical
|
||||
* section, they will be disabled when leaving the critical section.
|
||||
*
|
||||
* Method #3: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you
|
||||
* would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
|
||||
* disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to
|
||||
* disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr'
|
||||
* into the CPU's status register.
|
||||
*
|
||||
*****************************************************************************************/
|
||||
|
||||
#define OS_CRITICAL_METHOD 3
|
||||
|
||||
#if OS_CRITICAL_METHOD == 1
|
||||
#error OS_CRITICAL_METHOD == 1 not supported, please use method 3 instead.
|
||||
#endif
|
||||
|
||||
#if OS_CRITICAL_METHOD == 2
|
||||
#error OS_CRITICAL_METHOD == 2 not supported, please use method 3 instead.
|
||||
#endif
|
||||
|
||||
#if OS_CRITICAL_METHOD == 3
|
||||
#define OS_CPU_SR alt_irq_context
|
||||
#define OS_ENTER_CRITICAL() \
|
||||
cpu_sr = alt_irq_disable_all ()
|
||||
#define OS_EXIT_CRITICAL() \
|
||||
alt_irq_enable_all (cpu_sr);
|
||||
#endif
|
||||
|
||||
/* Prototypes */
|
||||
void OSStartHighRdy(void);
|
||||
void OSCtxSw(void);
|
||||
void OSIntCtxSw(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __OS_CPU_H__ */
|
||||
|
||||
|
||||
|
@ -1,101 +0,0 @@
|
||||
#ifndef __ALT_PRIV_ALARM_H__
|
||||
#define __ALT_PRIV_ALARM_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* This header provides the internal defenitions required by the public
|
||||
* interface alt_alarm.h. These variables and structures are not guaranteed to
|
||||
* exist in future implementations of the HAL.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* "alt_alarm_s" is a structure type used to maintain lists of alarm callback
|
||||
* functions.
|
||||
*/
|
||||
|
||||
struct alt_alarm_s
|
||||
{
|
||||
alt_llist llist; /* linked list */
|
||||
alt_u32 time; /* time in system ticks of the callback */
|
||||
alt_u32 (*callback) (void* context); /* callback function. The return
|
||||
* value is the period for the next callback; where
|
||||
* zero indicates that the alarm should be removed
|
||||
* from the list.
|
||||
*/
|
||||
alt_u8 rollover; /* set when desired alarm time + current time causes
|
||||
overflow, to prevent premature alarm */
|
||||
void* context; /* Argument for the callback */
|
||||
};
|
||||
|
||||
/*
|
||||
* "_alt_tick_rate" is a global variable used to store the system clock rate
|
||||
* in ticks per second. This is initialised to zero, which coresponds to there
|
||||
* being no system clock available.
|
||||
*
|
||||
* It is then set to it's final value by the system clock driver through a call
|
||||
* to alt_sysclk_init().
|
||||
*/
|
||||
|
||||
extern alt_u32 _alt_tick_rate;
|
||||
|
||||
/*
|
||||
* "_alt_nticks" is a global variable which records the elapsed number of
|
||||
* system clock ticks since the last call to settimeofday() or since reset if
|
||||
* settimeofday() has not been called.
|
||||
*/
|
||||
|
||||
extern volatile alt_u32 _alt_nticks;
|
||||
|
||||
/* The list of registered alarms. */
|
||||
|
||||
extern alt_llist alt_alarm_list;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_PRIV_ALARM_H__ */
|
@ -1,35 +0,0 @@
|
||||
#ifndef __ALT_BUSY_SLEEP_H
|
||||
#define __ALT_BUSY_SLEEP_H
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The function alt_busy_sleep provides a busy loop implementation of usleep.
|
||||
* This is used to provide usleep for the standalone HAL, or when the timer is
|
||||
* unavailable in uC/OS-II.
|
||||
*/
|
||||
|
||||
extern unsigned int alt_busy_sleep (unsigned int us);
|
||||
|
||||
#endif /* __ALT_BUSY_SLEEP_H */
|
@ -1,77 +0,0 @@
|
||||
#ifndef __ALT_DEV_LLIST_H__
|
||||
#define __ALT_DEV_LLIST_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_llist.h"
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* This header provides the internal defenitions required to control file
|
||||
* access. These variables and functions are not guaranteed to exist in
|
||||
* future implementations of the HAL.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The alt_dev_llist is an internal structure used to form a common base
|
||||
* class for all device types. The use of this structure allows common code
|
||||
* to be used to manipulate the various device lists.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
alt_llist llist;
|
||||
const char* name;
|
||||
} alt_dev_llist;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
extern int alt_dev_llist_insert (alt_dev_llist* dev, alt_llist* list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_DEV_LLIST_H__ */
|
@ -1,39 +0,0 @@
|
||||
#ifndef __ALT_EXCEPTION_HANDLER_REGISTRY_H__
|
||||
#define __ALT_EXCEPTION_HANDLER_REGISTRY_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
#include "sys/alt_exceptions.h"
|
||||
|
||||
/* Function pointer to exception callback routine */
|
||||
extern alt_exception_result (*alt_instruction_exception_handler)
|
||||
(alt_exception_cause, alt_u32, alt_u32);
|
||||
|
||||
#endif /* __ALT_EXCEPTION_HANDLER_REGISTRY_H__ */
|
@ -1,179 +0,0 @@
|
||||
#ifndef __ALT_FILE_H__
|
||||
#define __ALT_FILE_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_dev.h"
|
||||
#include "sys/alt_llist.h"
|
||||
#include "os/alt_sem.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* This header provides the internal defenitions required to control file
|
||||
* access. These variables and functions are not guaranteed to exist in
|
||||
* future implementations of the HAL.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The function alt_find_dev() is used to search the device list "list" to
|
||||
* locate a device named "name". If a match is found, then a pointer to the
|
||||
* device is returned, otherwise NULL is returned.
|
||||
*/
|
||||
|
||||
extern alt_dev* alt_find_dev (const char* name, alt_llist* list);
|
||||
|
||||
/*
|
||||
* alt_find_file() is used to search the list of registered file systems to
|
||||
* find the filesystem that the file named "name" belongs to. If a match is
|
||||
* found, then a pointer to the filesystems alt_dev structure is returned,
|
||||
* otherwise NULL is returned.
|
||||
*
|
||||
* Note that a match does not indicate that the file exists, only that a
|
||||
* filesystem exists that is registered for a partition that could contain
|
||||
* the file. The filesystems open() function would need to be called in order
|
||||
* to determine if the file exists.
|
||||
*/
|
||||
|
||||
extern alt_dev* alt_find_file (const char* name);
|
||||
|
||||
/*
|
||||
* alt_get_fd() is used to allocate a file descriptor for the device or
|
||||
* filesystem "dev". A negative return value indicates an error, otherwise the
|
||||
* return value is the index of the file descriptor within the file descriptor
|
||||
* pool.
|
||||
*/
|
||||
|
||||
extern int alt_get_fd (alt_dev* dev);
|
||||
|
||||
/*
|
||||
* alt_release_fd() is called to free the file descriptor with index "fd".
|
||||
*/
|
||||
|
||||
extern void alt_release_fd (int fd);
|
||||
|
||||
/*
|
||||
* alt_fd_lock() is called by ioctl() to mark the file descriptor "fd" as
|
||||
* being open for exclusive access. Subsequent calls to open() for the device
|
||||
* associated with "fd" will fail. A device is unlocked by either calling
|
||||
* close() for "fd", or by an alternate call to ioctl() (see ioctl.c for
|
||||
* details).
|
||||
*/
|
||||
|
||||
extern int alt_fd_lock (alt_fd* fd);
|
||||
|
||||
/*
|
||||
* alt_fd_unlock() is called by ioctl() to unlock a descriptor previously
|
||||
* locked by a call to alt_fd_lock().
|
||||
*/
|
||||
|
||||
extern int alt_fd_unlock (alt_fd* fd);
|
||||
|
||||
/*
|
||||
* "alt_fd_list" is the pool of file descriptors.
|
||||
*/
|
||||
|
||||
extern alt_fd alt_fd_list[];
|
||||
|
||||
/*
|
||||
* flags used by alt_fd.
|
||||
*
|
||||
* ALT_FD_EXCL is used to mark a file descriptor as locked for exclusive
|
||||
* access, i.e. further calls to open() for the associated device should
|
||||
* fail.
|
||||
*
|
||||
* ALT_FD_DEV marks a dile descriptor as belonging to a device as oposed to a
|
||||
* filesystem.
|
||||
*/
|
||||
|
||||
#define ALT_FD_EXCL 0x80000000
|
||||
#define ALT_FD_DEV 0x40000000
|
||||
|
||||
#define ALT_FD_FLAGS_MASK (ALT_FD_EXCL | ALT_FD_DEV)
|
||||
|
||||
/*
|
||||
* "alt_dev_list" is the head of the linked list of registered devices.
|
||||
*/
|
||||
|
||||
extern alt_llist alt_dev_list;
|
||||
|
||||
/*
|
||||
* "alt_fs_list" is the head of the linked list of registered filesystems.
|
||||
*/
|
||||
|
||||
extern alt_llist alt_fs_list;
|
||||
|
||||
/*
|
||||
* "alt_fd_list_lock" is a semaphore used to ensure that access to the pool
|
||||
* of file descriptors is thread safe.
|
||||
*/
|
||||
|
||||
ALT_EXTERN_SEM(alt_fd_list_lock)
|
||||
|
||||
/*
|
||||
* "alt_max_fd" is a 'high water mark'. It indicates the highest file
|
||||
* descriptor allocated. Use of this can save searching the entire pool
|
||||
* for active file descriptors, which helps avoid contention on access
|
||||
* to the file descriptor pool.
|
||||
*/
|
||||
|
||||
extern alt_32 alt_max_fd;
|
||||
|
||||
/*
|
||||
* alt_io_redirect() is called at startup to redirect stdout, stdin, and
|
||||
* stderr to the devices named in the input arguments. By default these streams
|
||||
* are directed at /dev/null, and are then redirected using this function once
|
||||
* all of the devices have been registered within the system.
|
||||
*/
|
||||
|
||||
extern void alt_io_redirect(const char* stdout_dev,
|
||||
const char* stdin_dev,
|
||||
const char* stderr_dev);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_FILE_H__ */
|
@ -1,39 +0,0 @@
|
||||
#ifndef __ALT_IIC_ISR_REGISTER_H_
|
||||
#define __ALT_IIC_ISR_REGISTER_H_
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
#include "alt_types.h"
|
||||
#include "sys/alt_irq.h"
|
||||
|
||||
extern int alt_iic_isr_register(alt_u32 ic_id, alt_u32 irq, alt_isr_func isr,
|
||||
void *isr_context, void *flags);
|
||||
|
||||
#endif /* __ALT_IIC_ISR_REGISTER_H_ */
|
@ -1,59 +0,0 @@
|
||||
#ifndef __ALT_IRQ_TABLE_H__
|
||||
#define __ALT_IRQ_TABLE_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Definition of a table describing each interrupt handler. The index into
|
||||
* the array is the interrupt id associated with the handler.
|
||||
*
|
||||
* When an interrupt occurs, the associated handler is called with
|
||||
* the argument stored in the context member.
|
||||
*
|
||||
* The table is physically created in alt_irq_handler.c
|
||||
*/
|
||||
extern struct ALT_IRQ_HANDLER
|
||||
{
|
||||
#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
|
||||
void (*handler)(void*);
|
||||
#else
|
||||
void (*handler)(void*, alt_u32);
|
||||
#endif
|
||||
void *context;
|
||||
} alt_irq[ALT_NIRQ];
|
||||
|
||||
#endif
|
@ -1,158 +0,0 @@
|
||||
#ifndef __ALT_LEGACY_IRQ_H__
|
||||
#define __ALT_LEGACY_IRQ_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file provides prototypes and inline implementations of certain routines
|
||||
* used by the legacy interrupt API. Do not include this in your driver or
|
||||
* application source files, use "sys/alt_irq.h" instead to access the proper
|
||||
* public API.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "system.h"
|
||||
|
||||
#ifndef NIOS2_EIC_PRESENT
|
||||
|
||||
#include "nios2.h"
|
||||
#include "alt_types.h"
|
||||
|
||||
#include "sys/alt_irq.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* alt_irq_register() can be used to register an interrupt handler. If the
|
||||
* function is succesful, then the requested interrupt will be enabled upon
|
||||
* return.
|
||||
*/
|
||||
extern int alt_irq_register (alt_u32 id,
|
||||
void* context,
|
||||
alt_isr_func handler);
|
||||
|
||||
/*
|
||||
* alt_irq_disable() disables the individual interrupt indicated by "id".
|
||||
*/
|
||||
static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_disable (alt_u32 id)
|
||||
{
|
||||
alt_irq_context status;
|
||||
extern volatile alt_u32 alt_irq_active;
|
||||
|
||||
status = alt_irq_disable_all ();
|
||||
|
||||
alt_irq_active &= ~(1 << id);
|
||||
NIOS2_WRITE_IENABLE (alt_irq_active);
|
||||
|
||||
alt_irq_enable_all(status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_irq_enable() enables the individual interrupt indicated by "id".
|
||||
*/
|
||||
static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_enable (alt_u32 id)
|
||||
{
|
||||
alt_irq_context status;
|
||||
extern volatile alt_u32 alt_irq_active;
|
||||
|
||||
status = alt_irq_disable_all ();
|
||||
|
||||
alt_irq_active |= (1 << id);
|
||||
NIOS2_WRITE_IENABLE (alt_irq_active);
|
||||
|
||||
alt_irq_enable_all(status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef ALT_EXCEPTION_STACK
|
||||
/*
|
||||
* alt_irq_initerruptable() should only be called from within an ISR. It is used
|
||||
* to allow higer priority interrupts to interrupt the current ISR. The input
|
||||
* argument, "priority", is the priority, i.e. interrupt number of the current
|
||||
* interrupt.
|
||||
*
|
||||
* If this function is called, then the ISR is required to make a call to
|
||||
* alt_irq_non_interruptible() before returning. The input argument to
|
||||
* alt_irq_non_interruptible() is the return value from alt_irq_interruptible().
|
||||
*
|
||||
* Care should be taken when using this pair of functions, since they increasing
|
||||
* the system overhead associated with interrupt handling.
|
||||
*
|
||||
* If you are using an exception stack then nested interrupts won't work, so
|
||||
* these functions are not available in that case.
|
||||
*/
|
||||
static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_irq_interruptible (alt_u32 priority)
|
||||
{
|
||||
extern volatile alt_u32 alt_priority_mask;
|
||||
extern volatile alt_u32 alt_irq_active;
|
||||
|
||||
alt_u32 old_priority;
|
||||
|
||||
old_priority = alt_priority_mask;
|
||||
alt_priority_mask = (1 << priority) - 1;
|
||||
|
||||
NIOS2_WRITE_IENABLE (alt_irq_active & alt_priority_mask);
|
||||
|
||||
NIOS2_WRITE_STATUS (1);
|
||||
|
||||
return old_priority;
|
||||
}
|
||||
|
||||
/*
|
||||
* See Comments above for alt_irq_interruptible() for an explanation of the use of this
|
||||
* function.
|
||||
*/
|
||||
static ALT_INLINE void ALT_ALWAYS_INLINE alt_irq_non_interruptible (alt_u32 mask)
|
||||
{
|
||||
extern volatile alt_u32 alt_priority_mask;
|
||||
extern volatile alt_u32 alt_irq_active;
|
||||
|
||||
NIOS2_WRITE_STATUS (0);
|
||||
|
||||
alt_priority_mask = mask;
|
||||
|
||||
NIOS2_WRITE_IENABLE (mask & alt_irq_active);
|
||||
}
|
||||
#endif /* ALT_EXCEPTION_STACK */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NIOS2_EIC_PRESENT */
|
||||
|
||||
#endif /* __ALT_LEGACY_IRQ_H__ */
|
@ -1,77 +0,0 @@
|
||||
#ifndef __ALT_NO_ERROR_H__
|
||||
#define __ALT_NO_ERROR_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* alt_no_error() is a dummy function used by alt_sem.h and alt_flag.h. It
|
||||
* substitutes for functions that have a return code by creating a function
|
||||
* that always returns zero.
|
||||
*
|
||||
* This may seem a little obscure, but what happens is that the compiler can
|
||||
* then optomise away the call to this function, and any code written which
|
||||
* handles the error path (i.e. non zero return values).
|
||||
*
|
||||
* This allows code to be written which correctly use the uC/OS-II semaphore
|
||||
* and flag utilities, without the use of those utilities impacting on
|
||||
* excutables built for a single threaded HAL environment.
|
||||
*
|
||||
* This function is considered to be part of the internal implementation of
|
||||
* the HAL, and should not be called directly by application code or device
|
||||
* drivers. It is not guaranteed to be preserved in future versions of the
|
||||
* HAL.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int ALT_ALWAYS_INLINE alt_no_error (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_NO_ERROR_H__ */
|
@ -1,47 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
#ifndef NIOS2_GMON_DATA_H
|
||||
#define NIOS2_GMON_DATA_H
|
||||
|
||||
#define GMON_DATA_SIG 0
|
||||
#define GMON_DATA_WORDS 1
|
||||
#define GMON_DATA_PROFILE_DATA 2
|
||||
#define GMON_DATA_PROFILE_LOWPC 3
|
||||
#define GMON_DATA_PROFILE_HIGHPC 4
|
||||
#define GMON_DATA_PROFILE_BUCKET 5
|
||||
#define GMON_DATA_PROFILE_RATE 6
|
||||
#define GMON_DATA_MCOUNT_START 7
|
||||
#define GMON_DATA_MCOUNT_LIMIT 8
|
||||
|
||||
#define GMON_DATA_SIZE 9
|
||||
|
||||
extern unsigned int alt_gmon_data[GMON_DATA_SIZE];
|
||||
|
||||
#endif
|
@ -1,126 +0,0 @@
|
||||
#ifndef __ALT_ALARM_H__
|
||||
#define __ALT_ALARM_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "alt_llist.h"
|
||||
#include "alt_types.h"
|
||||
|
||||
#include "priv/alt_alarm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* "alt_alarm" is a structure type used by applications to register an alarm
|
||||
* callback function. An instance of this type must be passed as an input
|
||||
* argument to alt_alarm_start(). The user is not responsible for initialising
|
||||
* the contents of the instance. This is done by alt_alarm_start().
|
||||
*/
|
||||
|
||||
typedef struct alt_alarm_s alt_alarm;
|
||||
|
||||
/*
|
||||
* alt_alarm_start() can be called by an application/driver in order to register
|
||||
* a function for periodic callback at the system clock frequency. Be aware that
|
||||
* this callback is likely to occur in interrupt context.
|
||||
*/
|
||||
|
||||
extern int alt_alarm_start (alt_alarm* the_alarm,
|
||||
alt_u32 nticks,
|
||||
alt_u32 (*callback) (void* context),
|
||||
void* context);
|
||||
|
||||
/*
|
||||
* alt_alarm_stop() is used to unregister a callback. Alternatively the callback
|
||||
* can return zero to unregister.
|
||||
*/
|
||||
|
||||
extern void alt_alarm_stop (alt_alarm* the_alarm);
|
||||
|
||||
/*
|
||||
* Obtain the system clock rate in ticks/s.
|
||||
*/
|
||||
|
||||
static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_ticks_per_second (void)
|
||||
{
|
||||
return _alt_tick_rate;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_sysclk_init() is intended to be only used by the system clock driver
|
||||
* in order to initialise the value of the clock frequency.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int ALT_ALWAYS_INLINE alt_sysclk_init (alt_u32 nticks)
|
||||
{
|
||||
if (! _alt_tick_rate)
|
||||
{
|
||||
_alt_tick_rate = nticks;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_nticks() returns the elapsed number of system clock ticks since reset.
|
||||
*/
|
||||
|
||||
static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_nticks (void)
|
||||
{
|
||||
return _alt_nticks;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_tick() should only be called by the system clock driver. This is used
|
||||
* to notify the system that the system timer period has expired.
|
||||
*/
|
||||
|
||||
extern void alt_tick (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_ALARM_H__ */
|
@ -1,117 +0,0 @@
|
||||
#ifndef __ALT_CACHE_H__
|
||||
#define __ALT_CACHE_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003, 2007 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* alt_cache.h defines the processor specific functions for manipulating the
|
||||
* cache.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* alt_icache_flush() is called to flush the instruction cache for a memory
|
||||
* region of length "len" bytes, starting at address "start".
|
||||
*/
|
||||
|
||||
extern void alt_icache_flush (void* start, alt_u32 len);
|
||||
|
||||
/*
|
||||
* alt_dcache_flush() is called to flush the data cache for a memory
|
||||
* region of length "len" bytes, starting at address "start".
|
||||
* Any dirty lines in the data cache are written back to memory.
|
||||
*/
|
||||
|
||||
extern void alt_dcache_flush (void* start, alt_u32 len);
|
||||
|
||||
/*
|
||||
* alt_dcache_flush() is called to flush the data cache for a memory
|
||||
* region of length "len" bytes, starting at address "start".
|
||||
* Any dirty lines in the data cache are NOT written back to memory.
|
||||
*/
|
||||
|
||||
extern void alt_dcache_flush_no_writeback (void* start, alt_u32 len);
|
||||
|
||||
/*
|
||||
* Flush the entire instruction cache.
|
||||
*/
|
||||
|
||||
extern void alt_icache_flush_all (void);
|
||||
|
||||
/*
|
||||
* Flush the entire data cache.
|
||||
*/
|
||||
|
||||
extern void alt_dcache_flush_all (void);
|
||||
|
||||
/*
|
||||
* Allocate a block of uncached memory.
|
||||
*/
|
||||
|
||||
extern volatile void* alt_uncached_malloc (size_t size);
|
||||
|
||||
/*
|
||||
* Free a block of uncached memory.
|
||||
*/
|
||||
|
||||
extern void alt_uncached_free (volatile void* ptr);
|
||||
|
||||
/*
|
||||
* Convert a pointer to a block of cached memory, into a block of
|
||||
* uncached memory.
|
||||
*/
|
||||
|
||||
extern volatile void* alt_remap_uncached (void* ptr, alt_u32 len);
|
||||
|
||||
/*
|
||||
* Convert a pointer to a block of uncached memory, into a block of
|
||||
* cached memory.
|
||||
*/
|
||||
|
||||
extern void* alt_remap_cached (volatile void* ptr, alt_u32 len);
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_CACHE_H__ */
|
@ -1,45 +0,0 @@
|
||||
#ifndef __ALT_DEBUG_H__
|
||||
#define __ALT_DEBUG_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* The ALT_DEVUG_ASSERT macro can be used to generate a debugger break
|
||||
* from within software. The break is generated if "condition" evaluates to
|
||||
* false.
|
||||
*/
|
||||
|
||||
#define ALT_DEBUG_ASSERT(condition) if (!condition) \
|
||||
{ \
|
||||
__asm__ volatile ("break"); \
|
||||
}
|
||||
|
||||
#endif /* __ALT_DEBUG_H__ */
|
@ -1,115 +0,0 @@
|
||||
#ifndef __ALT_DEV_H__
|
||||
#define __ALT_DEV_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "system.h"
|
||||
#include "sys/alt_llist.h"
|
||||
#include "priv/alt_dev_llist.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The value ALT_IRQ_NOT_CONNECTED is used to represent an unconnected
|
||||
* interrupt line. It cannot evaluate to a valid interrupt number.
|
||||
*/
|
||||
|
||||
#define ALT_IRQ_NOT_CONNECTED (-1)
|
||||
|
||||
typedef struct alt_dev_s alt_dev;
|
||||
|
||||
struct stat;
|
||||
|
||||
/*
|
||||
* The file descriptor structure definition.
|
||||
*/
|
||||
|
||||
typedef struct alt_fd_s
|
||||
{
|
||||
alt_dev* dev;
|
||||
alt_u8* priv;
|
||||
int fd_flags;
|
||||
} alt_fd;
|
||||
|
||||
/*
|
||||
* The device structure definition.
|
||||
*/
|
||||
|
||||
struct alt_dev_s {
|
||||
alt_llist llist; /* for internal use */
|
||||
const char* name;
|
||||
int (*open) (alt_fd* fd, const char* name, int flags, int mode);
|
||||
int (*close) (alt_fd* fd);
|
||||
int (*read) (alt_fd* fd, char* ptr, int len);
|
||||
int (*write) (alt_fd* fd, const char* ptr, int len);
|
||||
int (*lseek) (alt_fd* fd, int ptr, int dir);
|
||||
int (*fstat) (alt_fd* fd, struct stat* buf);
|
||||
int (*ioctl) (alt_fd* fd, int req, void* arg);
|
||||
};
|
||||
|
||||
/*
|
||||
* Functions used to register device for access through the C standard
|
||||
* library.
|
||||
*
|
||||
* The only difference between alt_dev_reg() and alt_fs_reg() is the
|
||||
* interpretation that open() places on the device name. In the case of
|
||||
* alt_dev_reg the device is assumed to be a particular character device,
|
||||
* and so there must be an exact match in the name for open to succeed.
|
||||
* In the case of alt_fs_reg() the name of the device is treated as the
|
||||
* mount point for a directory, and so any call to open() where the name
|
||||
* is the root of the device filename will succeed.
|
||||
*/
|
||||
|
||||
extern int alt_fs_reg (alt_dev* dev);
|
||||
|
||||
static ALT_INLINE int alt_dev_reg (alt_dev* dev)
|
||||
{
|
||||
extern alt_llist alt_dev_list;
|
||||
|
||||
return alt_dev_llist_insert ((alt_dev_llist*) dev, &alt_dev_list);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_DEV_H__ */
|
@ -1,226 +0,0 @@
|
||||
#ifndef __ALT_DMA_H__
|
||||
#define __ALT_DMA_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004-2005 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_dma_dev.h"
|
||||
#include "alt_types.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* This header contains the application side interface for accessing DMA
|
||||
* resources. See alt_dma_dev.h for the dma device driver interface.
|
||||
*
|
||||
* The interface model treats a DMA transaction as being composed of two
|
||||
* halves (read and write).
|
||||
*
|
||||
* The application can supply data for transmit using an "alt_dma_txchan"
|
||||
* descriptor. Alternatively an "alt_dma_rxchan" descriptor can be used to
|
||||
* receive data.
|
||||
*/
|
||||
|
||||
/*
|
||||
* alt_dma_txchan_open() is used to obtain an "alt_dma_txchan" descriptor for
|
||||
* a DMA transmit device. The name is the name of the associated physical
|
||||
* device (e.g. "/dev/dma_0").
|
||||
*
|
||||
* The return value will be NULL on failure, and non-NULL otherwise.
|
||||
*/
|
||||
|
||||
extern alt_dma_txchan alt_dma_txchan_open (const char* name);
|
||||
|
||||
/*
|
||||
* alt_dma_txchan_close() is provided so that an application can notify the
|
||||
* system that it has finished with a given DMA transmit channel. This is only
|
||||
* provided for completness.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_txchan_close (alt_dma_txchan dma)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_dma_txchan_send() posts a transmit request to a DMA transmit channel.
|
||||
* The input arguments are:
|
||||
*
|
||||
* dma: the channel to use.
|
||||
* from: a pointer to the start of the data to send.
|
||||
* length: the length of the data to send in bytes.
|
||||
* done: callback function that will be called once the data has been sent.
|
||||
* handle: opaque value passed to "done".
|
||||
*
|
||||
* The return value will be negative if the request cannot be posted, and
|
||||
* zero otherwise.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_txchan_send (alt_dma_txchan dma,
|
||||
const void* from,
|
||||
alt_u32 length,
|
||||
alt_txchan_done* done,
|
||||
void* handle)
|
||||
{
|
||||
return dma ? dma->dma_send (dma,
|
||||
from,
|
||||
length,
|
||||
done,
|
||||
handle) : -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_dma_txchan_space() returns the number of tranmit requests that can be
|
||||
* posted to the specified DMA transmit channel.
|
||||
*
|
||||
* A negative value indicates that the value could not be determined.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_txchan_space (alt_dma_txchan dma)
|
||||
{
|
||||
return dma ? dma->space (dma) : -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_dma_txchan_ioctl() can be used to perform device specific I/O
|
||||
* operations on the indicated DMA transmit channel. For example some drivers
|
||||
* support options to control the width of the transfer operations. See
|
||||
* alt_dma_dev.h for the list of generic requests.
|
||||
*
|
||||
* A negative return value indicates failure, otherwise the interpretation
|
||||
* of the return value is request specific.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_txchan_ioctl (alt_dma_txchan dma,
|
||||
int req,
|
||||
void* arg)
|
||||
{
|
||||
return dma ? dma->ioctl (dma, req, arg) : -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_dma_rxchan_open() is used to obtain an "alt_dma_rxchan" descriptor for
|
||||
* a DMA receive channel. The name is the name of the associated physical
|
||||
* device (e.g. "/dev/dma_0").
|
||||
*
|
||||
* The return value will be NULL on failure, and non-NULL otherwise.
|
||||
*/
|
||||
|
||||
extern alt_dma_rxchan alt_dma_rxchan_open (const char* dev);
|
||||
|
||||
/*
|
||||
* alt_dma_rxchan_close() is provided so that an application can notify the
|
||||
* system that it has finished with a given DMA receive channel. This is only
|
||||
* provided for completness.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_rxchan_close (alt_dma_rxchan dma)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* alt_dma_rxchan_prepare() posts a receive request to a DMA receive channel.
|
||||
*
|
||||
* The input arguments are:
|
||||
*
|
||||
* dma: the channel to use.
|
||||
* data: a pointer to the location that data is to be received to.
|
||||
* len: the maximum length of the data to receive.
|
||||
* done: callback function that will be called once the data has been
|
||||
* received.
|
||||
* handle: opaque value passed to "done".
|
||||
*
|
||||
* The return value will be negative if the request cannot be posted, and
|
||||
* zero otherwise.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_rxchan_prepare (alt_dma_rxchan dma,
|
||||
void* data,
|
||||
alt_u32 len,
|
||||
alt_rxchan_done* done,
|
||||
void* handle)
|
||||
{
|
||||
return dma ? dma->prepare (dma, data, len, done, handle) : -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_dma_rxchan_ioctl() can be used to perform device specific I/O
|
||||
* operations on the indicated DMA receive channel. For example some drivers
|
||||
* support options to control the width of the transfer operations. See
|
||||
* alt_dma_dev.h for the list of generic requests.
|
||||
*
|
||||
* A negative return value indicates failure, otherwise the interpretation
|
||||
* of the return value is request specific.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_rxchan_ioctl (alt_dma_rxchan dma,
|
||||
int req,
|
||||
void* arg)
|
||||
{
|
||||
return dma ? dma->ioctl (dma, req, arg) : -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_dma_rxchan_depth() returns the depth of the receive FIFO used to store
|
||||
* receive requests.
|
||||
*/
|
||||
|
||||
static ALT_INLINE alt_u32 alt_dma_rxchan_depth(alt_dma_rxchan dma)
|
||||
{
|
||||
return dma->depth;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ALT_DMA_H__ */
|
@ -1,200 +0,0 @@
|
||||
#ifndef __ALT_DMA_DEV_H__
|
||||
#define __ALT_DMA_DEV_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004-2005 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "priv/alt_dev_llist.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* This header contains the device driver interface for accessing DMA
|
||||
* resources. See alt_dma.h for the DMA application side interface.
|
||||
*
|
||||
* The interface model treats a DMA transaction as being composed of two
|
||||
* halves (read and write).
|
||||
*
|
||||
* An "alt_dma_txchan_dev" is used to describe the device associated with a
|
||||
* DMA transmit channel. An "alt_dma_rxchan_dev" is used to describe the
|
||||
* device associated with a DMA receive channel.
|
||||
*/
|
||||
|
||||
/*
|
||||
* List of generic ioctl requests that may be supported by a DMA device.
|
||||
*
|
||||
* ALT_DMA_RX_ONLY_ON: This causes a DMA channel to operate in a mode
|
||||
* where only the receiver is under software control.
|
||||
* The other side reads continously from a single
|
||||
* location. The address to read is the argument to
|
||||
* this request.
|
||||
* ALT_DMA_RX_ONLY_OFF: Return to the default mode where both the receive
|
||||
* and transmit sides of the DMA can be under software
|
||||
* control.
|
||||
* ALT_DMA_TX_ONLY_ON: This causes a DMA channel to operate in a mode
|
||||
* where only the transmitter is under software control.
|
||||
* The other side writes continously to a single
|
||||
* location. The address to write to is the argument to
|
||||
* this request.
|
||||
* ALT_DMA_TX_ONLY_OFF: Return to the default mode where both the receive
|
||||
* and transmit sides of the DMA can be under software
|
||||
* control.
|
||||
* ALT_DMA_SET_MODE_8: Transfer data in units of 8 bits.
|
||||
* ALT_DMA_SET_MODE_16: Transfer data in units of 16 bits.
|
||||
* ALT_DMA_SET_MODE_32: Transfer data in units of 32 bits.
|
||||
* ALT_DMA_SET_MODE_64: Transfer data in units of 64 bits.
|
||||
* ALT_DMA_SET_MODE_128: Transfer data in units of 128 bits.
|
||||
* ALT_DMA_GET_MODE: Get the current transfer mode.
|
||||
*
|
||||
* The use of the macros: ALT_DMA_TX_STREAM_ON, ALT_DMA_TX_STREAM_OFF
|
||||
* ALT_DMA_RX_STREAM_OFF and ALT_DMA_RX_STREAM_ON are depreciated. You should
|
||||
* instead use the macros: ALT_DMA_RX_ONLY_ON, ALT_DMA_RX_ONLY_OFF,
|
||||
* ALT_DMA_TX_ONLY_ON and ALT_DMA_TX_ONLY_OFF.
|
||||
*/
|
||||
|
||||
#define ALT_DMA_TX_STREAM_ON (0x1)
|
||||
#define ALT_DMA_TX_STREAM_OFF (0x2)
|
||||
#define ALT_DMA_RX_STREAM_ON (0x3)
|
||||
#define ALT_DMA_RX_STREAM_OFF (0x4)
|
||||
#define ALT_DMA_SET_MODE_8 (0x5)
|
||||
#define ALT_DMA_SET_MODE_16 (0x6)
|
||||
#define ALT_DMA_SET_MODE_32 (0x7)
|
||||
#define ALT_DMA_SET_MODE_64 (0x8)
|
||||
#define ALT_DMA_SET_MODE_128 (0x9)
|
||||
#define ALT_DMA_GET_MODE (0xa)
|
||||
|
||||
#define ALT_DMA_RX_ONLY_ON ALT_DMA_TX_STREAM_ON
|
||||
#define ALT_DMA_RX_ONLY_OFF ALT_DMA_TX_STREAM_OFF
|
||||
#define ALT_DMA_TX_ONLY_ON ALT_DMA_RX_STREAM_ON
|
||||
#define ALT_DMA_TX_ONLY_OFF ALT_DMA_RX_STREAM_OFF
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct alt_dma_txchan_dev_s alt_dma_txchan_dev;
|
||||
typedef struct alt_dma_rxchan_dev_s alt_dma_rxchan_dev;
|
||||
|
||||
typedef alt_dma_txchan_dev* alt_dma_txchan;
|
||||
typedef alt_dma_rxchan_dev* alt_dma_rxchan;
|
||||
|
||||
typedef void (alt_txchan_done)(void* handle);
|
||||
typedef void (alt_rxchan_done)(void* handle, void* data);
|
||||
|
||||
/*
|
||||
* devices that provide a DMA transmit channel are required to provide an
|
||||
* instance of the "alt_dma_txchan_dev" structure.
|
||||
*/
|
||||
|
||||
struct alt_dma_txchan_dev_s {
|
||||
alt_llist llist; /* for internal use */
|
||||
const char* name; /* name of the device instance
|
||||
* (e.g. "/dev/dma_0").
|
||||
*/
|
||||
int (*space) (alt_dma_txchan dma); /* returns the maximum number of
|
||||
* transmit requests that can be posted
|
||||
*/
|
||||
int (*dma_send) (alt_dma_txchan dma,
|
||||
const void* from,
|
||||
alt_u32 len,
|
||||
alt_txchan_done* done,
|
||||
void* handle); /* post a transmit request */
|
||||
int (*ioctl) (alt_dma_txchan dma, int req, void* arg); /* perform device
|
||||
* specific I/O control.
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* devices that provide a DMA receive channel are required to provide an
|
||||
* instance of the "alt_dma_rxchan_dev" structure.
|
||||
*/
|
||||
|
||||
struct alt_dma_rxchan_dev_s {
|
||||
alt_llist list; /* for internal use */
|
||||
const char* name; /* name of the device instance
|
||||
* (e.g. "/dev/dma_0").
|
||||
*/
|
||||
alt_u32 depth; /* maximum number of receive requests that
|
||||
* can be posted.
|
||||
*/
|
||||
int (*prepare) (alt_dma_rxchan dma,
|
||||
void* data,
|
||||
alt_u32 len,
|
||||
alt_rxchan_done* done,
|
||||
void* handle); /* post a receive request */
|
||||
int (*ioctl) (alt_dma_rxchan dma, int req, void* arg); /* perform device
|
||||
* specific I/O control.
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Register a DMA transmit channel with the system.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_txchan_reg (alt_dma_txchan_dev* dev)
|
||||
{
|
||||
extern alt_llist alt_dma_txchan_list;
|
||||
|
||||
return alt_dev_llist_insert((alt_dev_llist*) dev, &alt_dma_txchan_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a DMA receive channel with the system.
|
||||
*/
|
||||
|
||||
static ALT_INLINE int alt_dma_rxchan_reg (alt_dma_rxchan_dev* dev)
|
||||
{
|
||||
extern alt_llist alt_dma_rxchan_list;
|
||||
|
||||
return alt_dev_llist_insert((alt_dev_llist*) dev, &alt_dma_rxchan_list);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ALT_DMA_DEV_H__ */
|
@ -1,168 +0,0 @@
|
||||
#ifndef __ALT_DRIVER_H__
|
||||
#define __ALT_DRIVER_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Macros used to access a driver without HAL file descriptors.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ALT_MODULE_CLASS
|
||||
*
|
||||
* This macro returns the module class name for the specified module instance.
|
||||
* It uses information in the system.h file.
|
||||
* Neither the instance name or class name are quoted (so that they can
|
||||
* be used with other pre-processor macros).
|
||||
*
|
||||
* Example:
|
||||
* Assume the design has an instance of an altera_avalon_uart called uart1.
|
||||
* Calling ALT_MODULE_CLASS(uart1) returns altera_avalon_uart.
|
||||
*/
|
||||
|
||||
#define ALT_MODULE_CLASS(instance) ALT_MODULE_CLASS_ ## instance
|
||||
|
||||
|
||||
/*
|
||||
* ALT_DRIVER_FUNC_NAME
|
||||
*
|
||||
* --> instance Instance name.
|
||||
* --> func Function name.
|
||||
*
|
||||
* This macro returns the device driver function name of the specified
|
||||
* module instance for the specified function name.
|
||||
*
|
||||
* Example:
|
||||
* Assume the design has an instance of an altera_avalon_uart called uart1.
|
||||
* Calling ALT_DRIVER_FUNC_NAME(uart1, write) returns
|
||||
* altera_avalon_uart_write.
|
||||
*/
|
||||
|
||||
#define ALT_DRIVER_FUNC_NAME(instance, func) \
|
||||
ALT_DRIVER_FUNC_NAME1(ALT_MODULE_CLASS(instance), func)
|
||||
#define ALT_DRIVER_FUNC_NAME1(module_class, func) \
|
||||
ALT_DRIVER_FUNC_NAME2(module_class, func)
|
||||
#define ALT_DRIVER_FUNC_NAME2(module_class, func) \
|
||||
module_class ## _ ## func
|
||||
|
||||
/*
|
||||
* ALT_DRIVER_STATE_STRUCT
|
||||
*
|
||||
* --> instance Instance name.
|
||||
*
|
||||
* This macro returns the device driver state type name of the specified
|
||||
* module instance.
|
||||
*
|
||||
* Example:
|
||||
* Assume the design has an instance of an altera_avalon_uart called uart1.
|
||||
* Calling ALT_DRIVER_STATE_STRUCT(uart1) returns:
|
||||
* struct altera_avalon_uart_state_s
|
||||
*
|
||||
* Note that the ALT_DRIVER_FUNC_NAME macro is used even though "state" isn't
|
||||
* really a function but it does match the required naming convention.
|
||||
*/
|
||||
#define ALT_DRIVER_STATE_STRUCT(instance) \
|
||||
struct ALT_DRIVER_FUNC_NAME(instance, state_s)
|
||||
|
||||
/*
|
||||
* ALT_DRIVER_STATE
|
||||
*
|
||||
* --> instance Instance name.
|
||||
*
|
||||
* This macro returns the device driver state name of the specified
|
||||
* module instance.
|
||||
*
|
||||
* Example:
|
||||
* Assume the design has an instance of an altera_avalon_uart called uart1.
|
||||
* Calling ALT_DRIVER_STATE(uart1) returns uart1.
|
||||
*/
|
||||
#define ALT_DRIVER_STATE(instance) instance
|
||||
|
||||
/*
|
||||
* ALT_DRIVER_WRITE
|
||||
*
|
||||
* --> instance Instance name.
|
||||
* --> buffer Write buffer.
|
||||
* --> len Length of write buffer data.
|
||||
* --> flags Control flags (e.g. O_NONBLOCK)
|
||||
*
|
||||
* This macro calls the "write" function of the specified driver instance.
|
||||
*/
|
||||
|
||||
#define ALT_DRIVER_WRITE_EXTERNS(instance) \
|
||||
extern ALT_DRIVER_STATE_STRUCT(instance) ALT_DRIVER_STATE(instance); \
|
||||
extern int ALT_DRIVER_FUNC_NAME(instance, write) \
|
||||
(ALT_DRIVER_STATE_STRUCT(instance) *, const char *, int, int);
|
||||
|
||||
#define ALT_DRIVER_WRITE(instance, buffer, len, flags) \
|
||||
ALT_DRIVER_FUNC_NAME(instance, write)(&ALT_DRIVER_STATE(instance), buffer, len, flags)
|
||||
|
||||
|
||||
/*
|
||||
* ALT_DRIVER_READ
|
||||
*
|
||||
* --> instance Instance name.
|
||||
* <-- buffer Read buffer.
|
||||
* --> len Length of read buffer.
|
||||
* --> flags Control flags (e.g. O_NONBLOCK)
|
||||
*
|
||||
* This macro calls the "read" function of the specified driver instance.
|
||||
*/
|
||||
|
||||
#define ALT_DRIVER_READ_EXTERNS(instance) \
|
||||
extern ALT_DRIVER_STATE_STRUCT(instance) ALT_DRIVER_STATE(instance); \
|
||||
extern int ALT_DRIVER_FUNC_NAME(instance, read) \
|
||||
(ALT_DRIVER_STATE_STRUCT(instance) *, const char *, int, int);
|
||||
|
||||
#define ALT_DRIVER_READ(instance, buffer, len, flags) \
|
||||
ALT_DRIVER_FUNC_NAME(instance, read)(&ALT_DRIVER_STATE(instance), buffer, len, flags)
|
||||
|
||||
/*
|
||||
* ALT_DRIVER_IOCTL
|
||||
*
|
||||
* --> instance Instance name.
|
||||
* --> req ioctl request (e.g. TIOCSTIMEOUT)
|
||||
* --> arg Optional argument (void*)
|
||||
*
|
||||
* This macro calls the "ioctl" function of the specified driver instance
|
||||
*/
|
||||
|
||||
#define ALT_DRIVER_IOCTL_EXTERNS(instance) \
|
||||
extern ALT_DRIVER_STATE_STRUCT(instance) ALT_DRIVER_STATE(instance); \
|
||||
extern int ALT_DRIVER_FUNC_NAME(instance, ioctl) \
|
||||
(ALT_DRIVER_STATE_STRUCT(instance) *, int, void*);
|
||||
|
||||
#define ALT_DRIVER_IOCTL(instance, req, arg) \
|
||||
ALT_DRIVER_FUNC_NAME(instance, ioctl)(&ALT_DRIVER_STATE(instance), req, arg)
|
||||
|
||||
#endif /* __ALT_DRIVER_H__ */
|
@ -1,87 +0,0 @@
|
||||
#ifndef __ALT_ERRNO_H__
|
||||
#define __ALT_ERRNO_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* errno is defined in <errno.h> so that it uses the thread local version
|
||||
* stored in the location pointed to by "_impure_ptr". This means that the
|
||||
* accesses to errno within the HAL library can cause the entirety of
|
||||
* of the structure pointed to by "_impure_ptr" to be added to the
|
||||
* users application. This can be undesirable in very small footprint systems.
|
||||
*
|
||||
* To avoid this happening, the HAL uses the macro ALT_ERRNO, defined below,
|
||||
* to access errno, rather than accessing it directly. This macro will only
|
||||
* use the thread local version if some other code has already caused it to be
|
||||
* included into the system, otherwise it will use the global errno value.
|
||||
*
|
||||
* This causes a slight increases in code size where errno is accessed, but
|
||||
* can lead to significant overall benefits in very small systems. The
|
||||
* increase is inconsequential when compared to the size of the structure
|
||||
* pointed to by _impure_ptr.
|
||||
*
|
||||
* Note that this macro accesses __errno() using an externally declared
|
||||
* function pointer (alt_errno). This is done so that the function call uses the
|
||||
* subroutine call instruction via a register rather than an immediate address.
|
||||
* This is important in the case that the code has been linked for a high
|
||||
* address, but __errno() is not being used. In this case the weak linkage
|
||||
* would have resulted in the instruction: "call 0" which would fail to link.
|
||||
*/
|
||||
|
||||
extern int* (*alt_errno) (void);
|
||||
|
||||
/* Must define this so that values such as EBADFD are defined in errno.h. */
|
||||
#define __LINUX_ERRNO_EXTENSIONS__
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
#undef errno
|
||||
|
||||
extern int errno;
|
||||
|
||||
static ALT_INLINE int* alt_get_errno(void)
|
||||
{
|
||||
return ((alt_errno) ? alt_errno() : &errno);
|
||||
}
|
||||
|
||||
#define ALT_ERRNO *alt_get_errno()
|
||||
|
||||
#endif /* __ALT_ERRNO_H__ */
|
@ -1,166 +0,0 @@
|
||||
#ifndef __ALT_EXCEPTIONS_H__
|
||||
#define __ALT_EXCEPTIONS_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
#include "alt_types.h"
|
||||
#include "system.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* This file defines instruction-generated exception handling and registry
|
||||
* API, exception type enumeration, and handler return value enumeration for
|
||||
* Nios II.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following enumeration describes the value in the CPU EXCEPTION
|
||||
* register CAUSE bit field.
|
||||
*/
|
||||
enum alt_exception_cause_e {
|
||||
/*
|
||||
* This value is passed to an exception handler's cause argument if
|
||||
* "extra exceptions" information (EXECPTION) register is not
|
||||
* present in the processor hardware configuration.
|
||||
*/
|
||||
NIOS2_EXCEPTION_CAUSE_NOT_PRESENT = -1,
|
||||
|
||||
/*
|
||||
* Real values
|
||||
*/
|
||||
NIOS2_EXCEPTION_RESET = 0,
|
||||
NIOS2_EXCEPTION_CPU_ONLY_RESET_REQUEST = 1,
|
||||
NIOS2_EXCEPTION_INTERRUPT = 2,
|
||||
NIOS2_EXCEPTION_TRAP_INST = 3,
|
||||
NIOS2_EXCEPTION_UNIMPLEMENTED_INST = 4,
|
||||
NIOS2_EXCEPTION_ILLEGAL_INST = 5,
|
||||
NIOS2_EXCEPTION_MISALIGNED_DATA_ADDR = 6,
|
||||
NIOS2_EXCEPTION_MISALIGNED_TARGET_PC = 7,
|
||||
NIOS2_EXCEPTION_DIVISION_ERROR = 8,
|
||||
NIOS2_EXCEPTION_SUPERVISOR_ONLY_INST_ADDR = 9,
|
||||
NIOS2_EXCEPTION_SUPERVISOR_ONLY_INST = 10,
|
||||
NIOS2_EXCEPTION_SUPERVISOR_ONLY_DATA_ADDR = 11,
|
||||
NIOS2_EXCEPTION_TLB_MISS = 12,
|
||||
NIOS2_EXCEPTION_TLB_EXECUTE_PERM_VIOLATION = 13,
|
||||
NIOS2_EXCEPTION_TLB_READ_PERM_VIOLATION = 14,
|
||||
NIOS2_EXCEPTION_TLB_WRITE_PERM_VIOLATION = 15,
|
||||
NIOS2_EXCEPTION_MPU_INST_REGION_VIOLATION = 16,
|
||||
NIOS2_EXCEPTION_MPU_DATA_REGION_VIOLATION = 17,
|
||||
NIOS2_EXCEPTION_ECC_TLB_ERR = 18,
|
||||
NIOS2_EXCEPTION_ECC_FETCH_ERR = 19,
|
||||
NIOS2_EXCEPTION_ECC_REGISTER_FILE_ERR = 20,
|
||||
NIOS2_EXCEPTION_ECC_DATA_ERR = 21,
|
||||
NIOS2_EXCEPTION_ECC_DATA_CACHE_WRITEBACK_ERR = 22
|
||||
};
|
||||
typedef enum alt_exception_cause_e alt_exception_cause;
|
||||
|
||||
/*
|
||||
* These define valid return values for a user-defined instruction-generated
|
||||
* exception handler. The handler should return one of these to indicate
|
||||
* whether to re-issue the instruction that triggered the exception, or to
|
||||
* skip it.
|
||||
*/
|
||||
enum alt_exception_result_e {
|
||||
NIOS2_EXCEPTION_RETURN_REISSUE_INST = 0,
|
||||
NIOS2_EXCEPTION_RETURN_SKIP_INST = 1
|
||||
};
|
||||
typedef enum alt_exception_result_e alt_exception_result;
|
||||
|
||||
/*
|
||||
* alt_instruction_exception_register() can be used to register an exception
|
||||
* handler for instruction-generated exceptions that are not handled by the
|
||||
* built-in exception handler (i.e. for interrupts).
|
||||
*
|
||||
* The registry API is optionally enabled through the "Enable
|
||||
* Instruction-related Exception API" HAL BSP setting, which will
|
||||
* define the macro below.
|
||||
*/
|
||||
#ifdef ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API
|
||||
void alt_instruction_exception_register (
|
||||
alt_exception_result (*exception_handler)(
|
||||
alt_exception_cause cause,
|
||||
alt_u32 exception_pc,
|
||||
alt_u32 bad_addr) );
|
||||
#endif /*ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API */
|
||||
|
||||
/*
|
||||
* alt_exception_cause_generated_bad_addr() indicates whether a particular
|
||||
* exception cause value was from an exception-type that generated a valid
|
||||
* address in the BADADDR register. The contents of BADADDR is passed to
|
||||
* a user-registered exception handler in all cases, whether valid or not.
|
||||
* This routine should be called to validate the bad_addr argument to
|
||||
* your exception handler.
|
||||
*
|
||||
* Note that this routine will return false (0) for causes
|
||||
* NIOS2_EXCEPTION_TLB_MISS and NIOS2_EXCEPTION_ECC_TLB_ERR.
|
||||
* You must read the TLBMISC.D field to determine if BADADDR
|
||||
* is valid for these (valid if TLBMISC.D = 1).
|
||||
*/
|
||||
int alt_exception_cause_generated_bad_addr(alt_exception_cause cause);
|
||||
|
||||
/*
|
||||
* alt_ecc_fatal_exception_register() is called to register a handler to
|
||||
* service likely fatal ECC error exceptions. Likely the handler will
|
||||
* assume that correct execution of the running software is not possible
|
||||
* and re-initialize the processor (e.g. jump to reset address).
|
||||
*
|
||||
* Passing null (0x0) in the handler argument will disable a previously-
|
||||
* registered handler.
|
||||
*
|
||||
* Note that if no handler is registered, just normal exception processing
|
||||
* occurs on a likely fatal ECC exception and the exception processing
|
||||
* code might trigger an infinite exception loop.
|
||||
*
|
||||
* Note that the handler isn't a C function: it must be written in
|
||||
* assembly-code because it doesn't support C language calling conventions
|
||||
* and it can't return.
|
||||
*
|
||||
* The handler code must be carefully written to avoid triggering
|
||||
* another fatal ECC exception and creating an infinite exception loop.
|
||||
* The handler must avoid reading registers in case the fatal ECC
|
||||
* error is a register file ECC error.
|
||||
* If a data cache is present, the handler must avoid instructions that
|
||||
* access the data cache in case the fatal ECC error is a data cache
|
||||
* related ECC error. This includes cacheable load, cacheable store,
|
||||
* non-cacheable store (because it looks in the data cache to update the
|
||||
* data cache if it hits), and all data cache management instructions except
|
||||
* for INITD.
|
||||
*/
|
||||
void alt_ecc_fatal_exception_register(alt_u32 handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ALT_EXCEPTIONS_H__ */
|
@ -1,181 +0,0 @@
|
||||
#ifndef __ALT_FLASH_H__
|
||||
#define __ALT_FLASH_H__
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* Alt_flash.h - User interface for flash code *
|
||||
* *
|
||||
* Use this interface to avoid being exposed to the internals of the device *
|
||||
* driver architecture. If you chose to use the flash driver internal *
|
||||
* structures we don't guarantee not to change them *
|
||||
* *
|
||||
* Author PRR *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "alt_types.h"
|
||||
#include "alt_flash_types.h"
|
||||
#include "alt_flash_dev.h"
|
||||
#include "sys/alt_cache.h"
|
||||
|
||||
alt_flash_fd* alt_flash_open_dev(const char* name);
|
||||
void alt_flash_close_dev(alt_flash_fd* fd );
|
||||
|
||||
/*
|
||||
* alt_flash_lock
|
||||
*
|
||||
* Locks the range of the memory sectors, which
|
||||
* protected from write and erase.
|
||||
*
|
||||
*/
|
||||
static __inline__ int __attribute__ ((always_inline)) alt_lock_flash(
|
||||
alt_flash_fd* fd, alt_u32 sectors_to_lock)
|
||||
{
|
||||
return fd->lock( fd, sectors_to_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_write_flash
|
||||
*
|
||||
* Program a buffer into flash.
|
||||
*
|
||||
* This routine erases all the affected erase blocks (if necessary)
|
||||
* and then programs the data. However it does not read the data out first
|
||||
* and preserve and none overwritten data, because this would require very
|
||||
* large buffers on the target. If you need
|
||||
* that functionality use the functions below.
|
||||
*/
|
||||
static __inline__ int __attribute__ ((always_inline)) alt_write_flash(
|
||||
alt_flash_fd* fd,
|
||||
int offset,
|
||||
const void* src_addr,
|
||||
int length )
|
||||
{
|
||||
return fd->write( fd, offset, src_addr, length );
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_read_flash
|
||||
*
|
||||
* Read a block of flash for most flashes this is just memcpy
|
||||
* it's here for completeness in case we need it for some serial flash device
|
||||
*
|
||||
*/
|
||||
static __inline__ int __attribute__ ((always_inline)) alt_read_flash(
|
||||
alt_flash_fd* fd, int offset,
|
||||
void* dest_addr, int length )
|
||||
{
|
||||
return fd->read( fd, offset, dest_addr, length );
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_get_flash_info
|
||||
*
|
||||
* Return the information on the flash sectors.
|
||||
*
|
||||
*/
|
||||
static __inline__ int __attribute__ ((always_inline)) alt_get_flash_info(
|
||||
alt_flash_fd* fd, flash_region** info,
|
||||
int* number_of_regions)
|
||||
{
|
||||
return fd->get_info( fd, info, number_of_regions);
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_erase_flash_block
|
||||
*
|
||||
* Erase a particular erase block, pass in the offset to the start of
|
||||
* the block and it's size
|
||||
*/
|
||||
static __inline__ int __attribute__ ((always_inline)) alt_erase_flash_block(
|
||||
alt_flash_fd* fd, int offset, int length)
|
||||
{
|
||||
int ret_code;
|
||||
ret_code = fd->erase_block( fd, offset );
|
||||
|
||||
/* remove dcache_flush call for FB330552
|
||||
if(!ret_code)
|
||||
alt_dcache_flush((alt_u8*)fd->base_addr + offset, length);
|
||||
*/
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_write_flash_block
|
||||
*
|
||||
* Write a particular flash block, block_offset is the offset
|
||||
* (from the base of flash) to start of the block
|
||||
* data_offset is the offset (from the base of flash)
|
||||
* where you wish to start programming
|
||||
*
|
||||
* NB this function DOES NOT check that you are only writing a single
|
||||
* block of data as that would slow down this function.
|
||||
*
|
||||
* Use alt_write_flash if you want that level of error checking.
|
||||
*/
|
||||
|
||||
static __inline__ int __attribute__ ((always_inline)) alt_write_flash_block(
|
||||
alt_flash_fd* fd, int block_offset,
|
||||
int data_offset,
|
||||
const void *data, int length)
|
||||
{
|
||||
|
||||
int ret_code;
|
||||
ret_code = fd->write_block( fd, block_offset, data_offset, data, length );
|
||||
|
||||
/* remove dcache_flush call for FB330552
|
||||
if(!ret_code)
|
||||
alt_dcache_flush((alt_u8*)fd->base_addr + data_offset, length);
|
||||
*/
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_FLASH_H__ */
|
@ -1,100 +0,0 @@
|
||||
#ifndef __ALT_FLASH_DEV_H__
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* Alt_flash_dev.h - Generic Flash device interfaces *
|
||||
* *
|
||||
* Author PRR *
|
||||
* *
|
||||
******************************************************************************/
|
||||
#define __ALT_FLASH_DEV_H__
|
||||
|
||||
#include "alt_flash_types.h"
|
||||
#include "sys/alt_llist.h"
|
||||
#include "priv/alt_dev_llist.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
typedef struct alt_flash_dev alt_flash_dev;
|
||||
typedef alt_flash_dev alt_flash_fd;
|
||||
|
||||
static ALT_INLINE int alt_flash_device_register( alt_flash_fd* fd)
|
||||
{
|
||||
extern alt_llist alt_flash_dev_list;
|
||||
|
||||
return alt_dev_llist_insert ((alt_dev_llist*) fd, &alt_flash_dev_list);
|
||||
}
|
||||
|
||||
typedef alt_flash_dev* (*alt_flash_open)(alt_flash_dev* flash,
|
||||
const char* name );
|
||||
typedef int (*alt_flash_close)(alt_flash_dev* flash_info);
|
||||
|
||||
typedef int (*alt_flash_write)( alt_flash_dev* flash, int offset,
|
||||
const void* src_addr, int length );
|
||||
|
||||
typedef int (*alt_flash_get_flash_info)( alt_flash_dev* flash, flash_region** info,
|
||||
int* number_of_regions);
|
||||
typedef int (*alt_flash_write_block)( alt_flash_dev* flash, int block_offset,
|
||||
int data_offset, const void* data,
|
||||
int length);
|
||||
typedef int (*alt_flash_erase_block)( alt_flash_dev* flash, int offset);
|
||||
typedef int (*alt_flash_read)(alt_flash_dev* flash, int offset,
|
||||
void* dest_addr, int length );
|
||||
typedef int (*alt_flash_lock)(alt_flash_dev* flash, alt_u32 sectors_to_lock);
|
||||
|
||||
struct alt_flash_dev
|
||||
{
|
||||
alt_llist llist;
|
||||
const char* name;
|
||||
alt_flash_open open;
|
||||
alt_flash_close close;
|
||||
alt_flash_write write;
|
||||
alt_flash_read read;
|
||||
alt_flash_get_flash_info get_info;
|
||||
alt_flash_erase_block erase_block;
|
||||
alt_flash_write_block write_block;
|
||||
void* base_addr;
|
||||
int length;
|
||||
int number_of_regions;
|
||||
flash_region region_info[ALT_MAX_NUMBER_OF_FLASH_REGIONS];
|
||||
alt_flash_lock lock;
|
||||
};
|
||||
|
||||
#endif /* __ALT_FLASH_DEV_H__ */
|
@ -1,64 +0,0 @@
|
||||
#ifndef __ALT_FLASH_TYPES_H__
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* Alt_flash_types.h - Some generic types and defines used by the flash code *
|
||||
* *
|
||||
* Author PRR *
|
||||
* *
|
||||
******************************************************************************/
|
||||
#define __ALT_FLASH_TYPES_H__
|
||||
|
||||
#ifndef ALT_MAX_NUMBER_OF_FLASH_REGIONS
|
||||
#define ALT_MAX_NUMBER_OF_FLASH_REGIONS 8
|
||||
#endif /* ALT_MAX_NUMBER_OF_FLASH_REGIONS */
|
||||
|
||||
/*
|
||||
* Description of a single Erase region
|
||||
*/
|
||||
typedef struct flash_region
|
||||
{
|
||||
int offset;
|
||||
int region_size;
|
||||
int number_of_blocks;
|
||||
int block_size;
|
||||
}flash_region;
|
||||
|
||||
#endif /* __ALT_FLASH_TYPES_H__ */
|
@ -1,245 +0,0 @@
|
||||
#ifndef __ALT_IRQ_H__
|
||||
#define __ALT_IRQ_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* alt_irq.h is the Nios II specific implementation of the interrupt controller
|
||||
* interface.
|
||||
*
|
||||
* Nios II includes optional support for an external interrupt controller.
|
||||
* When an external controller is present, the "Enhanced" interrupt API
|
||||
* must be used to manage individual interrupts. The enhanced API also
|
||||
* supports the processor's internal interrupt controller. Certain API
|
||||
* members are accessible from either the "legacy" or "enhanced" interrpt
|
||||
* API.
|
||||
*
|
||||
* Regardless of which API is in use, this file should be included by
|
||||
* application code and device drivers that register ISRs or manage interrpts.
|
||||
*/
|
||||
#include <errno.h>
|
||||
|
||||
#include "nios2.h"
|
||||
#include "alt_types.h"
|
||||
#include "system.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Macros used by alt_irq_enabled
|
||||
*/
|
||||
#define ALT_IRQ_ENABLED 1
|
||||
#define ALT_IRQ_DISABLED 0
|
||||
|
||||
/*
|
||||
* Number of available interrupts in internal interrupt controller.
|
||||
*/
|
||||
#define ALT_NIRQ NIOS2_NIRQ
|
||||
|
||||
/*
|
||||
* Used by alt_irq_disable_all() and alt_irq_enable_all().
|
||||
*/
|
||||
typedef int alt_irq_context;
|
||||
|
||||
/* ISR Prototype */
|
||||
#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
|
||||
typedef void (*alt_isr_func)(void* isr_context);
|
||||
#else
|
||||
typedef void (*alt_isr_func)(void* isr_context, alt_u32 id);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following protypes and routines are supported by both
|
||||
* the enhanced and legacy interrupt APIs
|
||||
*/
|
||||
|
||||
/*
|
||||
* alt_irq_enabled can be called to determine if the processor's global
|
||||
* interrupt enable is asserted. The return value is zero if interrupts
|
||||
* are disabled, and non-zero otherwise.
|
||||
*
|
||||
* Whether the internal or external interrupt controller is present,
|
||||
* individual interrupts may still be disabled. Use the other API to query
|
||||
* a specific interrupt.
|
||||
*/
|
||||
static ALT_INLINE int ALT_ALWAYS_INLINE alt_irq_enabled (void)
|
||||
{
|
||||
int status;
|
||||
|
||||
NIOS2_READ_STATUS (status);
|
||||
|
||||
return status & NIOS2_STATUS_PIE_MSK;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_irq_disable_all()
|
||||
*
|
||||
* This routine inhibits all interrupts by negating the status register PIE
|
||||
* bit. It returns the previous contents of the CPU status register (IRQ
|
||||
* context) which can be used to restore the status register PIE bit to its
|
||||
* state before this routine was called.
|
||||
*/
|
||||
static ALT_INLINE alt_irq_context ALT_ALWAYS_INLINE
|
||||
alt_irq_disable_all (void)
|
||||
{
|
||||
alt_irq_context context;
|
||||
|
||||
NIOS2_READ_STATUS (context);
|
||||
|
||||
NIOS2_WRITE_STATUS (context & ~NIOS2_STATUS_PIE_MSK);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_irq_enable_all()
|
||||
*
|
||||
* Enable all interrupts that were previously disabled by alt_irq_disable_all()
|
||||
*
|
||||
* This routine accepts a context to restore the CPU status register PIE bit
|
||||
* to the state prior to a call to alt_irq_disable_all().
|
||||
|
||||
* In the case of nested calls to alt_irq_disable_all()/alt_irq_enable_all(),
|
||||
* this means that alt_irq_enable_all() does not necessarily re-enable
|
||||
* interrupts.
|
||||
*
|
||||
* This routine will perform a read-modify-write sequence to restore only
|
||||
* status.PIE if the processor is configured with options that add additional
|
||||
* writeable status register bits. These include the MMU, MPU, the enhanced
|
||||
* interrupt controller port, and shadow registers. Otherwise, as a performance
|
||||
* enhancement, status is overwritten with the prior context.
|
||||
*/
|
||||
static ALT_INLINE void ALT_ALWAYS_INLINE
|
||||
alt_irq_enable_all (alt_irq_context context)
|
||||
{
|
||||
#if (NIOS2_NUM_OF_SHADOW_REG_SETS > 0) || (defined NIOS2_EIC_PRESENT) || \
|
||||
(defined NIOS2_MMU_PRESENT) || (defined NIOS2_MPU_PRESENT)
|
||||
alt_irq_context status;
|
||||
|
||||
NIOS2_READ_STATUS (status);
|
||||
|
||||
status &= ~NIOS2_STATUS_PIE_MSK;
|
||||
status |= (context & NIOS2_STATUS_PIE_MSK);
|
||||
|
||||
NIOS2_WRITE_STATUS (status);
|
||||
#else
|
||||
NIOS2_WRITE_STATUS (context);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* The function alt_irq_init() is defined within the auto-generated file
|
||||
* alt_sys_init.c. This function calls the initilization macros for all
|
||||
* interrupt controllers in the system at config time, before any other
|
||||
* non-interrupt controller driver is initialized.
|
||||
*
|
||||
* The "base" parameter is ignored and only present for backwards-compatibility.
|
||||
* It is recommended that NULL is passed in for the "base" parameter.
|
||||
*/
|
||||
extern void alt_irq_init (const void* base);
|
||||
|
||||
/*
|
||||
* alt_irq_cpu_enable_interrupts() enables the CPU to start taking interrupts.
|
||||
*/
|
||||
static ALT_INLINE void ALT_ALWAYS_INLINE
|
||||
alt_irq_cpu_enable_interrupts (void)
|
||||
{
|
||||
NIOS2_WRITE_STATUS(NIOS2_STATUS_PIE_MSK
|
||||
#if defined(NIOS2_EIC_PRESENT) && (NIOS2_NUM_OF_SHADOW_REG_SETS > 0)
|
||||
| NIOS2_STATUS_RSIE_MSK
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes for the enhanced interrupt API.
|
||||
*/
|
||||
#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
|
||||
/*
|
||||
* alt_ic_isr_register() can be used to register an interrupt handler. If the
|
||||
* function is succesful, then the requested interrupt will be enabled upon
|
||||
* return.
|
||||
*/
|
||||
extern int alt_ic_isr_register(alt_u32 ic_id,
|
||||
alt_u32 irq,
|
||||
alt_isr_func isr,
|
||||
void *isr_context,
|
||||
void *flags);
|
||||
|
||||
/*
|
||||
* alt_ic_irq_enable() and alt_ic_irq_disable() enable/disable a specific
|
||||
* interrupt by using IRQ port and interrupt controller instance.
|
||||
*/
|
||||
int alt_ic_irq_enable (alt_u32 ic_id, alt_u32 irq);
|
||||
int alt_ic_irq_disable(alt_u32 ic_id, alt_u32 irq);
|
||||
|
||||
/*
|
||||
* alt_ic_irq_enabled() indicates whether a specific interrupt, as
|
||||
* specified by IRQ port and interrupt controller instance is enabled.
|
||||
*/
|
||||
alt_u32 alt_ic_irq_enabled(alt_u32 ic_id, alt_u32 irq);
|
||||
|
||||
#else
|
||||
/*
|
||||
* Prototypes for the legacy interrupt API.
|
||||
*/
|
||||
#include "priv/alt_legacy_irq.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* alt_irq_pending() returns a bit list of the current pending interrupts.
|
||||
* This is used by alt_irq_handler() to determine which registered interrupt
|
||||
* handlers should be called.
|
||||
*
|
||||
* This routine is only available for the Nios II internal interrupt
|
||||
* controller.
|
||||
*/
|
||||
#ifndef NIOS2_EIC_PRESENT
|
||||
static ALT_INLINE alt_u32 ALT_ALWAYS_INLINE alt_irq_pending (void)
|
||||
{
|
||||
alt_u32 active;
|
||||
|
||||
NIOS2_READ_IPENDING (active);
|
||||
|
||||
return active;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ALT_IRQ_H__ */
|
@ -1,39 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file pulls in the IRQ entry assembler and C code, which is only
|
||||
* required if there are any interruptes in the system.
|
||||
*/
|
||||
|
||||
__asm__( "\n\t.globl alt_irq_entry" );
|
||||
|
||||
__asm__( "\n\t.globl alt_irq_handler" );
|
||||
|
@ -1,77 +0,0 @@
|
||||
#ifndef __ALT_LICENSE_REMINDER_UCOSII_H__
|
||||
#define __ALT_LICENSE_REMINDER_UCOSII_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define ALT_LICENSE_REMINDER_UCOSII_STRING \
|
||||
"============== Software License Reminder ===============\n" \
|
||||
"\n" \
|
||||
"uC/OS-II is provided in source form for FREE evaluation,\n" \
|
||||
"for educational use, or for peaceful research. If you\n" \
|
||||
"plan on using uC/OS-II in a commercial product you need\n" \
|
||||
"to contact Micrium to properly license its use in your\n" \
|
||||
"product. Micrium provides ALL the source code on the\n" \
|
||||
"Altera distribution for your convenience and to help you\n" \
|
||||
"experience uC/OS-II. The fact that the source is provided\n" \
|
||||
"does NOT mean that you can use it without paying a\n" \
|
||||
"licensing fee. Please help us continue to provide the\n" \
|
||||
"Embedded community with the finest software available.\n" \
|
||||
"Your honesty is greatly appreciated.\n" \
|
||||
"\n" \
|
||||
"Please contact:\n" \
|
||||
"\n" \
|
||||
"M I C R I U M\n" \
|
||||
"949 Crestview Circle\n" \
|
||||
"Weston, FL 33327-1848\n" \
|
||||
"U.S.A.\n" \
|
||||
"\n" \
|
||||
"Phone : +1 954 217 2036\n" \
|
||||
"FAX : +1 954 217 2037\n" \
|
||||
"WEB : www.micrium.com\n" \
|
||||
"E-mail: Sales@Micrium.com\n" \
|
||||
"\n" \
|
||||
"========================================================\n"
|
||||
|
||||
#define alt_license_reminder_ucosii() puts(ALT_LICENSE_REMINDER_UCOSII_STRING)
|
||||
|
||||
|
||||
#endif /* __ALT_LICENSE_REMINDER_UCOSII_H__ */
|
||||
|
@ -1,123 +0,0 @@
|
||||
#ifndef __ALT_LIST_H__
|
||||
#define __ALT_LIST_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* alt_llist.h defines structures and functions for use in manipulating linked
|
||||
* lists. A list is considered to be constructed from a chain of objects of
|
||||
* type alt_llist, with one object being defined to be the head element.
|
||||
*
|
||||
* A list is considered to be empty if it only contains the head element.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* alt_llist is the structure used to represent an element within a linked
|
||||
* list.
|
||||
*/
|
||||
|
||||
typedef struct alt_llist_s alt_llist;
|
||||
|
||||
struct alt_llist_s {
|
||||
alt_llist* next; /* Pointer to the next element in the list. */
|
||||
alt_llist* previous; /* Pointer to the previous element in the list. */
|
||||
};
|
||||
|
||||
/*
|
||||
* ALT_LLIST_HEAD is a macro that can be used to create the head of a new
|
||||
* linked list. This is named "head". The head element is initialised to
|
||||
* represent an empty list.
|
||||
*/
|
||||
|
||||
#define ALT_LLIST_HEAD(head) alt_llist head = {&head, &head}
|
||||
|
||||
/*
|
||||
* ALT_LLIST_ENTRY is a macro used to define an uninitialised linked list
|
||||
* entry. This is used to reserve space in structure initialisation for
|
||||
* structures that inherit form alt_llist.
|
||||
*/
|
||||
|
||||
#define ALT_LLIST_ENTRY {0, 0}
|
||||
|
||||
/*
|
||||
* alt_llist_insert() insert adds the linked list entry "entry" as the
|
||||
* first entry in the linked list "list". "list" is the list head element.
|
||||
*/
|
||||
|
||||
static ALT_INLINE void ALT_ALWAYS_INLINE alt_llist_insert(alt_llist* list,
|
||||
alt_llist* entry)
|
||||
{
|
||||
entry->previous = list;
|
||||
entry->next = list->next;
|
||||
|
||||
list->next->previous = entry;
|
||||
list->next = entry;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_llist_remove() is called to remove an element from a linked list. The
|
||||
* input argument is the element to remove.
|
||||
*/
|
||||
|
||||
static ALT_INLINE void ALT_ALWAYS_INLINE alt_llist_remove(alt_llist* entry)
|
||||
{
|
||||
entry->next->previous = entry->previous;
|
||||
entry->previous->next = entry->next;
|
||||
|
||||
/*
|
||||
* Set the entry to point to itself, so that any further calls to
|
||||
* alt_llist_remove() are harmless.
|
||||
*/
|
||||
|
||||
entry->previous = entry;
|
||||
entry->next = entry;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_LLIST_H__ */
|
@ -1,78 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2005 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* This macro is used to load code/data from its load address to its
|
||||
* execution address for a given section. The section name is the input
|
||||
* argument. Note that a leading '.' is assumed in the name. For example
|
||||
* to load the section .onchip_ram, use:
|
||||
*
|
||||
* ALT_LOAD_SECTION_BY_NAME(onchip_ram);
|
||||
*
|
||||
* This requires that the apropriate linker symbols have been generated
|
||||
* for the section in question. This will be the case if you are using the
|
||||
* default linker script.
|
||||
*/
|
||||
|
||||
#define ALT_LOAD_SECTION_BY_NAME(name) \
|
||||
{ \
|
||||
extern void _alt_partition_##name##_start; \
|
||||
extern void _alt_partition_##name##_end; \
|
||||
extern void _alt_partition_##name##_load_addr; \
|
||||
\
|
||||
alt_load_section(&_alt_partition_##name##_load_addr, \
|
||||
&_alt_partition_##name##_start, \
|
||||
&_alt_partition_##name##_end); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Function used to load an individual section from flash to RAM.
|
||||
*
|
||||
* There is an implicit assumption here that the linker script will ensure
|
||||
* that all sections are word aligned.
|
||||
*
|
||||
*/
|
||||
|
||||
static void ALT_INLINE alt_load_section (alt_u32* from,
|
||||
alt_u32* to,
|
||||
alt_u32* end)
|
||||
{
|
||||
if (to != from)
|
||||
{
|
||||
while( to != end )
|
||||
{
|
||||
*to++ = *from++;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,354 +0,0 @@
|
||||
/* alt_log_printf.h
|
||||
*
|
||||
* ALT_LOG is designed to provide extra logging/debugging messages from HAL
|
||||
* through a different port than stdout. It is enabled by the ALT_LOG_ENABLE
|
||||
* define, which needs to supplied at compile time. When logging is turned off,
|
||||
* code size is unaffected. Thus, this should be transparent to the user
|
||||
* when it is not actively turned on, and should not affect projects in any way.
|
||||
*
|
||||
* There are macros sprinkled within different components, such as the jtag uart
|
||||
* and timer, in the HAL code. They are always named ALT_LOG_<name>, and can be
|
||||
* safely ignored if ALT_LOG is turned off.
|
||||
*
|
||||
* To turn on ALT_LOG, ALT_LOG_ENABLE must be defined, and ALT_LOG_PORT_TYPE and
|
||||
* ALT_LOG_PORT_BASE must be set in system.h. This is done through editing
|
||||
* <project>.ptf, by editing the alt_log_port_type & alt_log_port_base settings.
|
||||
* See the documentation html file for examples.
|
||||
*
|
||||
* When it is turned on, it will output extra HAL messages to a port specified
|
||||
* in system.h. This can be a UART or JTAG UART port. By default it will
|
||||
* output boot messages, detailing every step of the boot process.
|
||||
*
|
||||
* Extra logging is designed to be enabled by flags, which are defined in
|
||||
* alt_log_printf.c. The default value is that all flags are off, so only the
|
||||
* boot up logging messages show up. ALT_LOG_FLAGS can be set to enable certain
|
||||
* groupings of flags, and that grouping is done in this file. Each flag can
|
||||
* also be overridden with a -D at compile time.
|
||||
*
|
||||
* This header file includes the necessary prototypes for using the alt_log
|
||||
* functions. It also contains all the macros that are used to remove the code
|
||||
* from alt log is turned off. Also, the macros in other HAL files are defined
|
||||
* here at the bottom. These macros all call some C function that is in
|
||||
* alt_log_printf.c.
|
||||
*
|
||||
* The logging has functions for printing in C (ALT_LOG_PRINTF) and in assembly
|
||||
* (ALT_LOG_PUTS). This was needed because the assembly printing occurs before
|
||||
* the device is initialized. The assembly function corrupts register R4-R7,
|
||||
* which are not used in the normal boot process. For this reason, do not call
|
||||
* the assembly function in C.
|
||||
*
|
||||
* author: gkwan
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ALT_LOG_PRINTF_H__
|
||||
#define __ALT_LOG_PRINTF_H__
|
||||
|
||||
#include <system.h>
|
||||
|
||||
/* Global switch to turn on logging functions */
|
||||
#ifdef ALT_LOG_ENABLE
|
||||
|
||||
/* ALT_LOG_PORT_TYPE values as defined in system.h. They are defined as
|
||||
* numbers here first becasue the C preprocessor does not handle string
|
||||
* comparisons. */
|
||||
#define ALTERA_AVALON_JTAG_UART 1
|
||||
#define ALTERA_AVALON_UART 0
|
||||
|
||||
/* If this .h file is included by an assembly file, skip over include files
|
||||
* that won't compile in assembly. */
|
||||
#ifndef ALT_ASM_SRC
|
||||
#include <stdarg.h>
|
||||
#include "sys/alt_alarm.h"
|
||||
#include "sys/alt_dev.h"
|
||||
#ifdef __ALTERA_AVALON_JTAG_UART
|
||||
#include "altera_avalon_jtag_uart.h"
|
||||
#endif
|
||||
#endif /* ALT_ASM_SRC */
|
||||
|
||||
/* These are included for the port register offsets and masks, needed
|
||||
* to write to the port. Only include if the port type is set correctly,
|
||||
* otherwise error. If alt_log is turned on and the port to output to is
|
||||
* incorrect or does not exist, then should exit. */
|
||||
#if ALT_LOG_PORT_TYPE == ALTERA_AVALON_JTAG_UART
|
||||
#ifdef __ALTERA_AVALON_JTAG_UART
|
||||
#include <altera_avalon_jtag_uart_regs.h>
|
||||
#else
|
||||
#error ALT_LOG: JTAG_UART port chosen, but no JTAG_UART in system.
|
||||
#endif
|
||||
#elif ALT_LOG_PORT_TYPE == ALTERA_AVALON_UART
|
||||
#ifdef __ALTERA_AVALON_UART
|
||||
#include <altera_avalon_uart_regs.h>
|
||||
#else
|
||||
#error ALT_LOG: UART Port chosen, but no UART in system.
|
||||
#endif
|
||||
#else
|
||||
#error ALT_LOG: alt_log_port_type declaration invalid!
|
||||
#endif
|
||||
|
||||
/* ALT_LOG_ENABLE turns on the basic printing function */
|
||||
#define ALT_LOG_PRINTF(...) do {alt_log_printf_proc(__VA_ARGS__);} while (0)
|
||||
|
||||
/* Assembly macro for printing in assembly, calls tx_log_str
|
||||
* which is in alt_log_macro.S.
|
||||
* If alt_log_boot_on_flag is 0, skips the printing */
|
||||
#define ALT_LOG_PUTS(str) movhi r4, %hiadj(alt_log_boot_on_flag) ; \
|
||||
addi r4, r4, %lo(alt_log_boot_on_flag) ; \
|
||||
ldwio r5, 0(r4) ; \
|
||||
beq r0, r5, 0f ; \
|
||||
movhi r4, %hiadj(str) ; \
|
||||
addi r4, r4, %lo(str) ; \
|
||||
call tx_log_str ; \
|
||||
0:
|
||||
|
||||
/* These defines are here to faciliate the use of one output function
|
||||
* (alt_log_txchar) to print to both the JTAG UART or the UART. Depending
|
||||
* on the port type, the status register, read mask, and output register
|
||||
* are set to the appropriate value for the port. */
|
||||
#if ALT_LOG_PORT_TYPE == ALTERA_AVALON_JTAG_UART
|
||||
#define ALT_LOG_PRINT_REG_RD IORD_ALTERA_AVALON_JTAG_UART_CONTROL
|
||||
#define ALT_LOG_PRINT_MSK ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK
|
||||
#define ALT_LOG_PRINT_TXDATA_WR IOWR_ALTERA_AVALON_JTAG_UART_DATA
|
||||
#define ALT_LOG_PRINT_REG_OFFSET (ALTERA_AVALON_JTAG_UART_CONTROL_REG*0x4)
|
||||
#define ALT_LOG_PRINT_TXDATA_REG_OFFSET (ALTERA_AVALON_JTAG_UART_DATA_REG*0x4)
|
||||
#elif ALT_LOG_PORT_TYPE == ALTERA_AVALON_UART
|
||||
#define ALT_LOG_PRINT_REG_RD IORD_ALTERA_AVALON_UART_STATUS
|
||||
#define ALT_LOG_PRINT_MSK ALTERA_AVALON_UART_STATUS_TRDY_MSK
|
||||
#define ALT_LOG_PRINT_TXDATA_WR IOWR_ALTERA_AVALON_UART_TXDATA
|
||||
#define ALT_LOG_PRINT_REG_OFFSET (ALTERA_AVALON_UART_STATUS_REG*0x4)
|
||||
#define ALT_LOG_PRINT_TXDATA_REG_OFFSET (ALTERA_AVALON_UART_TXDATA_REG*0x4)
|
||||
#endif /* ALT_LOG_PORT */
|
||||
|
||||
/* Grouping of flags via ALT_LOG_FLAGS. Each specific flag can be set via
|
||||
* -D at compile time, or else they'll be set to a default value according
|
||||
* to ALT_LOG_FLAGS. ALT_LOG_FLAGS = 0 or not set is the default, where
|
||||
* only the boot messages will be printed. As ALT_LOG_FLAGS increase, they
|
||||
* increase in intrusiveness to the program, and will affect performance.
|
||||
*
|
||||
* Flag Level 1 - turns on system clock and JTAG UART startup status
|
||||
* 2 - turns on write echo and JTAG_UART alarm (periodic report)
|
||||
* 3 - turns on JTAG UART ISR logging - will slow performance
|
||||
* significantly.
|
||||
* -1 - All logging output is off, but if ALT_LOG_ENABLE is
|
||||
* defined all logging function is built and code size
|
||||
* remains constant
|
||||
*
|
||||
* Flag settings - 1 = on, 0 = off. */
|
||||
|
||||
/* This flag turns on "boot" messages for printing. This includes messages
|
||||
* during crt0.S, then alt_main, and finally alt_exit. */
|
||||
#ifndef ALT_LOG_BOOT_ON_FLAG_SETTING
|
||||
#if ALT_LOG_FLAGS == 1
|
||||
#define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 2
|
||||
#define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 3
|
||||
#define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == -1 /* silent mode */
|
||||
#define ALT_LOG_BOOT_ON_FLAG_SETTING 0x0
|
||||
#else /* default setting */
|
||||
#define ALT_LOG_BOOT_ON_FLAG_SETTING 0x1
|
||||
#endif
|
||||
#endif /* ALT_LOG_BOOT_ON_FLAG_SETTING */
|
||||
|
||||
#ifndef ALT_LOG_SYS_CLK_ON_FLAG_SETTING
|
||||
#if ALT_LOG_FLAGS == 1
|
||||
#define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 2
|
||||
#define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 3
|
||||
#define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == -1 /* silent mode */
|
||||
#define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x0
|
||||
#else /* default setting */
|
||||
#define ALT_LOG_SYS_CLK_ON_FLAG_SETTING 0x0
|
||||
#endif
|
||||
#endif /* ALT_LOG_SYS_CLK_ON_FLAG_SETTING */
|
||||
|
||||
#ifndef ALT_LOG_WRITE_ON_FLAG_SETTING
|
||||
#if ALT_LOG_FLAGS == 1
|
||||
#define ALT_LOG_WRITE_ON_FLAG_SETTING 0x0
|
||||
#elif ALT_LOG_FLAGS == 2
|
||||
#define ALT_LOG_WRITE_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 3
|
||||
#define ALT_LOG_WRITE_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == -1 /* silent mode */
|
||||
#define ALT_LOG_WRITE_ON_FLAG_SETTING 0x0
|
||||
#else /* default setting */
|
||||
#define ALT_LOG_WRITE_ON_FLAG_SETTING 0x0
|
||||
#endif
|
||||
#endif /* ALT_LOG_WRITE_ON_FLAG_SETTING */
|
||||
|
||||
#ifndef ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING
|
||||
#ifndef __ALTERA_AVALON_JTAG_UART
|
||||
#define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0
|
||||
#elif ALT_LOG_FLAGS == 1
|
||||
#define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0
|
||||
#elif ALT_LOG_FLAGS == 2
|
||||
#define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 3
|
||||
#define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == -1 /* silent mode */
|
||||
#define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0
|
||||
#else /* default setting */
|
||||
#define ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING 0x0
|
||||
#endif
|
||||
#endif /* ALT_LOG_JTAG_UART_ALARM_ON_FLAG_SETTING */
|
||||
|
||||
#ifndef ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING
|
||||
#ifndef __ALTERA_AVALON_JTAG_UART
|
||||
#define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x0
|
||||
#elif ALT_LOG_FLAGS == 1
|
||||
#define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 2
|
||||
#define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == 3
|
||||
#define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == -1 /* silent mode */
|
||||
#define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x0
|
||||
#else /* default setting */
|
||||
#define ALT_LOG_JTAG_UART_STARTUP_INFO_ON_FLAG_SETTING 0x0
|
||||
#endif
|
||||
#endif /* ALT_LOG_JTAG_UART_STARTUP_INFO_FLAG_SETTING */
|
||||
|
||||
#ifndef ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING
|
||||
#ifndef __ALTERA_AVALON_JTAG_UART
|
||||
#define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0
|
||||
#elif ALT_LOG_FLAGS == 1
|
||||
#define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0
|
||||
#elif ALT_LOG_FLAGS == 2
|
||||
#define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0
|
||||
#elif ALT_LOG_FLAGS == 3
|
||||
#define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x1
|
||||
#elif ALT_LOG_FLAGS == -1 /* silent mode */
|
||||
#define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0
|
||||
#else /* default setting */
|
||||
#define ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING 0x0
|
||||
#endif
|
||||
#endif /* ALT_LOG_JTAG_UART_ISR_ON_FLAG_SETTING */
|
||||
|
||||
#ifndef ALT_ASM_SRC
|
||||
/* Function Prototypes */
|
||||
void alt_log_txchar(int c,char *uartBase);
|
||||
void alt_log_private_printf(const char *fmt,int base,va_list args);
|
||||
void alt_log_repchar(char c,int r,int base);
|
||||
int alt_log_printf_proc(const char *fmt, ... );
|
||||
void alt_log_system_clock();
|
||||
#ifdef __ALTERA_AVALON_JTAG_UART
|
||||
alt_u32 altera_avalon_jtag_uart_report_log(void * context);
|
||||
void alt_log_jtag_uart_startup_info(altera_avalon_jtag_uart_state* dev, int base);
|
||||
void alt_log_jtag_uart_print_control_reg(altera_avalon_jtag_uart_state* dev, \
|
||||
int base, const char* header);
|
||||
void alt_log_jtag_uart_isr_proc(int base, altera_avalon_jtag_uart_state* dev);
|
||||
#endif
|
||||
void alt_log_write(const void *ptr, size_t len);
|
||||
|
||||
/* extern all global variables */
|
||||
/* CASE:368514 - The boot message flag is linked into the sdata section
|
||||
* because if it is zero, it would otherwise be placed in the bss section.
|
||||
* alt_log examines this variable before the BSS is cleared in the boot-up
|
||||
* process.
|
||||
*/
|
||||
extern volatile alt_u32 alt_log_boot_on_flag __attribute__ ((section (".sdata")));
|
||||
extern volatile alt_u8 alt_log_write_on_flag;
|
||||
extern volatile alt_u8 alt_log_sys_clk_on_flag;
|
||||
extern volatile alt_u8 alt_log_jtag_uart_alarm_on_flag;
|
||||
extern volatile alt_u8 alt_log_jtag_uart_isr_on_flag;
|
||||
extern volatile alt_u8 alt_log_jtag_uart_startup_info_on_flag;
|
||||
extern volatile int alt_log_sys_clk_count;
|
||||
extern volatile int alt_system_clock_in_sec;
|
||||
extern alt_alarm alt_log_jtag_uart_alarm_1;
|
||||
#endif /* ALT_ASM_SRC */
|
||||
|
||||
|
||||
/* Below are the MACRO defines used in various HAL files. They check
|
||||
* if their specific flag is turned on; if it is, then it executes its
|
||||
* code.
|
||||
*
|
||||
* To keep this file reasonable, most of these macros calls functions,
|
||||
* which are defined in alt_log_printf.c. Look there for implementation
|
||||
* details. */
|
||||
|
||||
/* Boot Messages Logging */
|
||||
#define ALT_LOG_PRINT_BOOT(...) \
|
||||
do { if (alt_log_boot_on_flag==1) {ALT_LOG_PRINTF(__VA_ARGS__);} \
|
||||
} while (0)
|
||||
|
||||
/* JTAG UART Logging */
|
||||
/* number of ticks before alarm runs logging function */
|
||||
#ifndef ALT_LOG_JTAG_UART_TICKS_DIVISOR
|
||||
#define ALT_LOG_JTAG_UART_TICKS_DIVISOR 10
|
||||
#endif
|
||||
#ifndef ALT_LOG_JTAG_UART_TICKS
|
||||
#define ALT_LOG_JTAG_UART_TICKS \
|
||||
(alt_ticks_per_second()/ALT_LOG_JTAG_UART_TICKS_DIVISOR)
|
||||
#endif
|
||||
|
||||
/* if there's a JTAG UART defined, then enable these macros */
|
||||
#ifdef __ALTERA_AVALON_JTAG_UART
|
||||
|
||||
/* Macro in altera_avalon_jtag_uart.c, to register the alarm function.
|
||||
* Also, the startup register info is also printed here, as this is
|
||||
* called within the device driver initialization. */
|
||||
#define ALT_LOG_JTAG_UART_ALARM_REGISTER(dev, base) \
|
||||
do { if (alt_log_jtag_uart_alarm_on_flag==1) { \
|
||||
alt_alarm_start(&alt_log_jtag_uart_alarm_1, \
|
||||
ALT_LOG_JTAG_UART_TICKS, &altera_avalon_jtag_uart_report_log,\
|
||||
dev);} \
|
||||
if (alt_log_jtag_uart_startup_info_on_flag==1) {\
|
||||
alt_log_jtag_uart_startup_info(dev, base);} \
|
||||
} while (0)
|
||||
|
||||
/* JTAG UART IRQ Logging (when buffer is empty)
|
||||
* Inserted in the ISR in altera_avalon_jtag_uart.c */
|
||||
#define ALT_LOG_JTAG_UART_ISR_FUNCTION(base, dev) \
|
||||
do { alt_log_jtag_uart_isr_proc(base, dev); } while (0)
|
||||
/* else, define macros to nothing. Or else the jtag_uart specific types
|
||||
* will throw compiler errors */
|
||||
#else
|
||||
#define ALT_LOG_JTAG_UART_ALARM_REGISTER(dev, base)
|
||||
#define ALT_LOG_JTAG_UART_ISR_FUNCTION(base, dev)
|
||||
#endif
|
||||
|
||||
/* System clock logging
|
||||
* How often (in seconds) the system clock logging prints.
|
||||
* The default value is every 1 second */
|
||||
#ifndef ALT_LOG_SYS_CLK_INTERVAL_MULTIPLIER
|
||||
#define ALT_LOG_SYS_CLK_INTERVAL_MULTIPLIER 1
|
||||
#endif
|
||||
#ifndef ALT_LOG_SYS_CLK_INTERVAL
|
||||
#define ALT_LOG_SYS_CLK_INTERVAL \
|
||||
(alt_ticks_per_second()*ALT_LOG_SYS_CLK_INTERVAL_MULTIPLIER)
|
||||
#endif
|
||||
|
||||
/* System clock logging - prints a message every interval (set above)
|
||||
* to show that the system clock is alive.
|
||||
* This macro is used in altera_avalon_timer_sc.c */
|
||||
#define ALT_LOG_SYS_CLK_HEARTBEAT() \
|
||||
do { alt_log_system_clock(); } while (0)
|
||||
|
||||
/* alt_write_logging - echos a message every time write() is called,
|
||||
* displays the first ALT_LOG_WRITE_ECHO_LEN characters.
|
||||
* This macro is used in alt_write.c */
|
||||
#ifndef ALT_LOG_WRITE_ECHO_LEN
|
||||
#define ALT_LOG_WRITE_ECHO_LEN 15
|
||||
#endif
|
||||
|
||||
#define ALT_LOG_WRITE_FUNCTION(ptr,len) \
|
||||
do { alt_log_write(ptr,len); } while (0)
|
||||
|
||||
#else /* ALT_LOG_ENABLE not defined */
|
||||
|
||||
/* logging is off, set all relevant macros to null */
|
||||
#define ALT_LOG_PRINT_BOOT(...)
|
||||
#define ALT_LOG_PRINTF(...)
|
||||
#define ALT_LOG_JTAG_UART_ISR_FUNCTION(base, dev)
|
||||
#define ALT_LOG_JTAG_UART_ALARM_REGISTER(dev, base)
|
||||
#define ALT_LOG_SYS_CLK_HEARTBEAT()
|
||||
#define ALT_LOG_PUTS(str)
|
||||
#define ALT_LOG_WRITE_FUNCTION(ptr,len)
|
||||
|
||||
#endif /* ALT_LOG_ENABLE */
|
||||
|
||||
#endif /* __ALT_LOG_PRINTF_H__ */
|
||||
|
@ -1,71 +0,0 @@
|
||||
#ifndef __ALT_SET_ARGS_H__
|
||||
#define __ALT_SET_ARGS_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The function alt_set_args() is provided in order to define the input
|
||||
* arguments to main(). If this function is not called before main() then the
|
||||
* argument list passed to main() will be empty.
|
||||
*
|
||||
* It is expected that this function will only be used by the ihost/iclient
|
||||
* utility.
|
||||
*/
|
||||
|
||||
static inline void alt_set_args (int argc, char** argv, char** envp)
|
||||
{
|
||||
extern int alt_argc;
|
||||
extern char** alt_argv;
|
||||
extern char** alt_envp;
|
||||
|
||||
alt_argc = argc;
|
||||
alt_argv = argv;
|
||||
alt_envp = envp;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_SET_ARGS_H__ */
|
@ -1,91 +0,0 @@
|
||||
#ifndef __ALT_SIM_H__
|
||||
#define __ALT_SIM_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
#include "system.h"
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* Instructions that might mean something special to a simulator.
|
||||
* These have no special effect on real hardware (they are just nops).
|
||||
*/
|
||||
#define ALT_SIM_FAIL() \
|
||||
do { __asm volatile ("cmpltui r0, r0, 0xabc1"); } while (0)
|
||||
|
||||
#define ALT_SIM_PASS() \
|
||||
do { __asm volatile ("cmpltui r0, r0, 0xabc2"); } while (0)
|
||||
|
||||
#define ALT_SIM_IN_TOP_OF_HOT_LOOP() \
|
||||
do { __asm volatile ("cmpltui r0, r0, 0xabc3"); } while (0)
|
||||
|
||||
/*
|
||||
* Routine called on exit.
|
||||
*/
|
||||
static ALT_INLINE ALT_ALWAYS_INLINE void alt_sim_halt(int exit_code)
|
||||
{
|
||||
register int r2 asm ("r2") = exit_code;
|
||||
|
||||
#if defined(NIOS2_HAS_DEBUG_STUB) && (defined(ALT_BREAK_ON_EXIT) || defined(ALT_PROVIDE_GMON))
|
||||
|
||||
register int r3 asm ("r3") = (1 << 2);
|
||||
|
||||
#ifdef ALT_PROVIDE_GMON
|
||||
extern unsigned int alt_gmon_data[];
|
||||
register int r4 asm ("r4") = (int)alt_gmon_data;
|
||||
r3 |= (1 << 4);
|
||||
#define ALT_GMON_DATA ,"r"(r4)
|
||||
#else
|
||||
#define ALT_GMON_DATA
|
||||
#endif /* ALT_PROVIDE_GMON */
|
||||
|
||||
if (r2) {
|
||||
ALT_SIM_FAIL();
|
||||
} else {
|
||||
ALT_SIM_PASS();
|
||||
}
|
||||
|
||||
__asm__ volatile ("\n0:\n\taddi %0,%0, -1\n\tbgt %0,zero,0b" : : "r" (ALT_CPU_FREQ/100) ); /* Delay for >30ms */
|
||||
|
||||
__asm__ volatile ("break 2" : : "r"(r2), "r"(r3) ALT_GMON_DATA );
|
||||
|
||||
#else /* !DEBUG_STUB */
|
||||
if (r2) {
|
||||
ALT_SIM_FAIL();
|
||||
} else {
|
||||
ALT_SIM_PASS();
|
||||
}
|
||||
#endif /* DEBUG_STUB */
|
||||
}
|
||||
|
||||
#define ALT_SIM_HALT(exit_code) \
|
||||
alt_sim_halt(exit_code)
|
||||
|
||||
#endif /* __ALT_SIM_H__ */
|
@ -1,126 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __ALT_STACK_H__
|
||||
#define __ALT_STACK_H__
|
||||
|
||||
/*
|
||||
* alt_stack.h is the nios2 specific implementation of functions used by the
|
||||
* stack overflow code.
|
||||
*/
|
||||
|
||||
#include "nios2.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
extern char * alt_stack_limit_value;
|
||||
|
||||
#ifdef ALT_EXCEPTION_STACK
|
||||
extern char __alt_exception_stack_pointer[]; /* set by the linker */
|
||||
#endif /* ALT_EXCEPTION_STACK */
|
||||
|
||||
|
||||
/*
|
||||
* alt_stack_limit can be called to determine the current value of the stack
|
||||
* limit register.
|
||||
*/
|
||||
|
||||
static ALT_INLINE char * ALT_ALWAYS_INLINE alt_stack_limit (void)
|
||||
{
|
||||
char * limit;
|
||||
NIOS2_READ_ET(limit);
|
||||
|
||||
return limit;
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_stack_pointer can be called to determine the current value of the stack
|
||||
* pointer register.
|
||||
*/
|
||||
|
||||
static ALT_INLINE char * ALT_ALWAYS_INLINE alt_stack_pointer (void)
|
||||
{
|
||||
char * pointer;
|
||||
NIOS2_READ_SP(pointer);
|
||||
|
||||
return pointer;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ALT_EXCEPTION_STACK
|
||||
|
||||
/*
|
||||
* alt_exception_stack_pointer returns the normal stack pointer from
|
||||
* where it is stored on the exception stack (uppermost 4 bytes). This
|
||||
* is really only useful during exception processing, and is only
|
||||
* available if a separate exception stack has been configured.
|
||||
*/
|
||||
|
||||
static ALT_INLINE char * ALT_ALWAYS_INLINE alt_exception_stack_pointer (void)
|
||||
{
|
||||
return (char *) *(alt_u32 *)(__alt_exception_stack_pointer - sizeof(alt_u32));
|
||||
}
|
||||
|
||||
#endif /* ALT_EXCEPTION_STACK */
|
||||
|
||||
|
||||
/*
|
||||
* alt_set_stack_limit can be called to update the current value of the stack
|
||||
* limit register.
|
||||
*/
|
||||
|
||||
static ALT_INLINE void ALT_ALWAYS_INLINE alt_set_stack_limit (char * limit)
|
||||
{
|
||||
alt_stack_limit_value = limit;
|
||||
NIOS2_WRITE_ET(limit);
|
||||
}
|
||||
|
||||
/*
|
||||
* alt_report_stack_overflow reports that a stack overflow happened.
|
||||
*/
|
||||
|
||||
static ALT_INLINE void ALT_ALWAYS_INLINE alt_report_stack_overflow (void)
|
||||
{
|
||||
NIOS2_REPORT_STACK_OVERFLOW();
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ALT_STACK_H__ */
|
||||
|
@ -1,66 +0,0 @@
|
||||
#ifndef __ALT_STDIO_H__
|
||||
#define __ALT_STDIO_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2015 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Definitions for ALT stdio routines.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int alt_getchar();
|
||||
int alt_putchar(int c);
|
||||
int alt_putstr(const char* str);
|
||||
void alt_printf(const char *fmt, ...);
|
||||
#ifdef ALT_SEMIHOSTING
|
||||
int alt_putcharbuf(int c);
|
||||
int alt_putstrbuf(const char* str);
|
||||
int alt_putbufflush();
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_STDIO_H__ */
|
@ -1,62 +0,0 @@
|
||||
#ifndef __ALT_SYS_INIT_H__
|
||||
#define __ALT_SYS_INIT_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The function alt_sys_init() is defined within the auto-generated file:
|
||||
* alt_sys_init.c. This function calls the initilisation macros for all
|
||||
* devices, file systems, and software components within the system.
|
||||
*
|
||||
* The list of initilisation macros to use is constructed using the PTF and
|
||||
* STF files associated with the system.
|
||||
*/
|
||||
|
||||
extern void alt_sys_init (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_SYS_INIT_H__ */
|
@ -1,100 +0,0 @@
|
||||
#ifndef __ALT_SYS_WRAPPERS_H__
|
||||
#define __ALT_SYS_WRAPPERS_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file provides the prototypes for the HAL 'UNIX style functions. The
|
||||
* names of these functions are defined in alt_syscall.h. THese are defined to
|
||||
* be the standard names when running the standalone HAL, e.g. open(), close()
|
||||
* etc., but the names may be redefined as a part of an operating system port
|
||||
* in order to avoid name clashes.
|
||||
*/
|
||||
|
||||
#include "os/alt_syscall.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/times.h>
|
||||
|
||||
extern int ALT_CLOSE (int __fd);
|
||||
extern int ALT_EXECVE (const char *__path,
|
||||
char * const __argv[],
|
||||
char * const __envp[]);
|
||||
extern void ALT_EXIT (int __status);
|
||||
extern int ALT_FSTAT (int file, struct stat *st);
|
||||
extern int ALT_FCNTL (int file, int cmd, ...);
|
||||
extern pid_t ALT_FORK (void);
|
||||
extern pid_t ALT_GETPID (void);
|
||||
|
||||
#if defined (__GNUC__) && __GNUC__ >= 4
|
||||
extern int ALT_GETTIMEOFDAY (struct timeval *ptimeval,
|
||||
void *ptimezone);
|
||||
#else
|
||||
extern int ALT_GETTIMEOFDAY (struct timeval *ptimeval,
|
||||
struct timezone *ptimezone);
|
||||
#endif
|
||||
|
||||
extern int ALT_IOCTL (int file, int req, void* arg);
|
||||
extern int ALT_ISATTY (int file);
|
||||
extern int ALT_KILL (int pid, int sig);
|
||||
extern int ALT_LINK (const char *existing, const char *new);
|
||||
extern off_t ALT_LSEEK (int file, off_t ptr, int dir);
|
||||
extern int ALT_OPEN (const char* file, int flags, ...);
|
||||
extern int ALT_READ (int file, void *ptr, size_t len);
|
||||
extern int ALT_RENAME (char *existing, char *new);
|
||||
extern void* ALT_SBRK (ptrdiff_t incr);
|
||||
extern int ALT_SETTIMEOFDAY (const struct timeval *t,
|
||||
const struct timezone *tz);
|
||||
extern int ALT_STAT (const char *file, struct stat *st);
|
||||
extern clock_t ALT_TIMES (struct tms *buf);
|
||||
extern int ALT_UNLINK (const char *name);
|
||||
|
||||
#if defined (__GNUC__) && __GNUC__ >= 4
|
||||
int ALT_USLEEP (useconds_t us);
|
||||
#else
|
||||
unsigned int ALT_USLEEP (unsigned int us);
|
||||
#endif
|
||||
|
||||
extern int ALT_WAIT (int *status);
|
||||
extern int ALT_WRITE (int file, const void *ptr, size_t len);
|
||||
|
||||
|
||||
extern char** ALT_ENVIRON;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* __ALT_SYS_WRAPPERS_H__ */
|
@ -1,60 +0,0 @@
|
||||
#ifndef __ALT_TIMESTAMP_H__
|
||||
#define __ALT_TIMESTAMP_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "alt_types.h"
|
||||
#include "altera_avalon_timer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern int alt_timestamp_start (void);
|
||||
|
||||
extern alt_timestamp_type alt_timestamp (void);
|
||||
|
||||
extern alt_u32 alt_timestamp_freq (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ALT_TIMESTAMP_H__ */
|
@ -1,75 +0,0 @@
|
||||
#ifndef __WARNING_H__
|
||||
#define __WARNING_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* alt_warning.h provides macro definitions that can be used to generate link
|
||||
* time warnings.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The symbol "__alt_invalid" is used to force a link error. There should be
|
||||
* no corresponding implementation of this function.
|
||||
*/
|
||||
|
||||
extern void __alt_invalid (void);
|
||||
|
||||
#define ALT_LINK_WARNING(symbol, msg) \
|
||||
__asm__(".ifndef __evoke_link_warning_" #symbol \
|
||||
"\n\t .section .gnu.warning." #symbol \
|
||||
"\n__evoke_link_warning_" #symbol ":\n\t .string \x22" msg "\x22 \n\t .previous" \
|
||||
"\n .endif");
|
||||
|
||||
/* A canned warning for sysdeps/stub functions. */
|
||||
|
||||
#define ALT_STUB_WARNING(name) \
|
||||
ALT_LINK_WARNING (name, \
|
||||
"warning: " #name " is not implemented and will always fail")
|
||||
|
||||
#define ALT_OBSOLETE_FUNCTION_WARNING(name) \
|
||||
ALT_LINK_WARNING (name, \
|
||||
"warning: " #name " is a deprecated function")
|
||||
|
||||
#define ALT_LINK_ERROR(msg) \
|
||||
ALT_LINK_WARNING (__alt_invalid, msg); \
|
||||
__alt_invalid()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __WARNING_H__ */
|
@ -1,90 +0,0 @@
|
||||
#ifndef __IOCTL_H__
|
||||
#define __IOCTL_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* The ioctl() system call be used to initiate a variety of control operations
|
||||
* on a file descriptor. For the most part this simply translates to a call to
|
||||
* the ioctl() function of the associated device driver (TIOCEXCL and
|
||||
* TIOCNXCL are notable exceptions - see ioctl.c for details).
|
||||
*
|
||||
* The interpretation of the ioctl requests are therefore device specific.
|
||||
*
|
||||
* This function is equivalent to the standard Posix ioctl() call.
|
||||
*/
|
||||
|
||||
extern int ioctl (int fd, int req, void* arg);
|
||||
|
||||
/*
|
||||
* list of ioctl calls handled by the system ioctl implementation.
|
||||
*/
|
||||
|
||||
#define TIOCEXCL 0x740d /* exclusive use of the device */
|
||||
#define TIOCNXCL 0x740e /* allow multiple use of the device */
|
||||
|
||||
/*
|
||||
* ioctl calls which can be handled by device drivers.
|
||||
*/
|
||||
|
||||
#define TIOCOUTQ 0x7472 /* get output queue size */
|
||||
#define TIOCMGET 0x741d /* get termios flags */
|
||||
#define TIOCMSET 0x741a /* set termios flags */
|
||||
|
||||
/*
|
||||
* ioctl calls specific to JTAG UART.
|
||||
*/
|
||||
|
||||
#define TIOCSTIMEOUT 0x6a01 /* Set Timeout before assuming no host present */
|
||||
#define TIOCGCONNECTED 0x6a02 /* Get indication of whether host is connected */
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __IOCTL_H__ */
|
@ -1,181 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This is the termios.h file provided with newlib. The only modification has
|
||||
* been to the baud rate macro definitions, and an increase in the size of the
|
||||
* termios structure to accomodate this.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SYS_TERMIOS_H
|
||||
# define _SYS_TERMIOS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
# define _XCGETA (('x'<<8)|1)
|
||||
# define _XCSETA (('x'<<8)|2)
|
||||
# define _XCSETAW (('x'<<8)|3)
|
||||
# define _XCSETAF (('x'<<8)|4)
|
||||
# define _TCSBRK (('T'<<8)|5)
|
||||
# define _TCFLSH (('T'<<8)|7)
|
||||
# define _TCXONC (('T'<<8)|6)
|
||||
|
||||
# define TCOOFF 0
|
||||
# define TCOON 1
|
||||
# define TCIOFF 2
|
||||
# define TCION 3
|
||||
|
||||
# define TCIFLUSH 0
|
||||
# define TCOFLUSH 1
|
||||
# define TCIOFLUSH 2
|
||||
|
||||
# define NCCS 13
|
||||
|
||||
# define TCSAFLUSH _XCSETAF
|
||||
# define TCSANOW _XCSETA
|
||||
# define TCSADRAIN _XCSETAW
|
||||
# define TCSADFLUSH _XCSETAF
|
||||
|
||||
# define IGNBRK 000001
|
||||
# define BRKINT 000002
|
||||
# define IGNPAR 000004
|
||||
# define INPCK 000020
|
||||
# define ISTRIP 000040
|
||||
# define INLCR 000100
|
||||
# define IGNCR 000200
|
||||
# define ICRNL 000400
|
||||
# define IXON 002000
|
||||
# define IXOFF 010000
|
||||
|
||||
# define OPOST 000001
|
||||
# define OCRNL 000004
|
||||
# define ONLCR 000010
|
||||
# define ONOCR 000020
|
||||
# define TAB3 014000
|
||||
|
||||
# define CLOCAL 004000
|
||||
# define CREAD 000200
|
||||
# define CSIZE 000060
|
||||
# define CS5 0
|
||||
# define CS6 020
|
||||
# define CS7 040
|
||||
# define CS8 060
|
||||
# define CSTOPB 000100
|
||||
# define HUPCL 002000
|
||||
# define PARENB 000400
|
||||
# define PAODD 001000
|
||||
|
||||
#define CCTS_OFLOW 010000
|
||||
#define CRTS_IFLOW 020000
|
||||
#define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW)
|
||||
|
||||
# define ECHO 0000010
|
||||
# define ECHOE 0000020
|
||||
# define ECHOK 0000040
|
||||
# define ECHONL 0000100
|
||||
# define ICANON 0000002
|
||||
# define IEXTEN 0000400 /* anybody know *what* this does?! */
|
||||
# define ISIG 0000001
|
||||
# define NOFLSH 0000200
|
||||
# define TOSTOP 0001000
|
||||
|
||||
# define VEOF 4 /* also VMIN -- thanks, AT&T */
|
||||
# define VEOL 5 /* also VTIME -- thanks again */
|
||||
# define VERASE 2
|
||||
# define VINTR 0
|
||||
# define VKILL 3
|
||||
# define VMIN 4 /* also VEOF */
|
||||
# define VQUIT 1
|
||||
# define VSUSP 10
|
||||
# define VTIME 5 /* also VEOL */
|
||||
# define VSTART 11
|
||||
# define VSTOP 12
|
||||
|
||||
# define B0 0
|
||||
# define B50 50
|
||||
# define B75 75
|
||||
# define B110 110
|
||||
# define B134 134
|
||||
# define B150 150
|
||||
# define B200 200
|
||||
# define B300 300
|
||||
# define B600 600
|
||||
# define B1200 1200
|
||||
# define B1800 1800
|
||||
# define B2400 2400
|
||||
# define B4800 4800
|
||||
# define B9600 9600
|
||||
# define B19200 19200
|
||||
# define B38400 38400
|
||||
# define B57600 57600
|
||||
# define B115200 115200
|
||||
|
||||
typedef unsigned char cc_t;
|
||||
typedef unsigned short tcflag_t;
|
||||
typedef unsigned long speed_t;
|
||||
|
||||
struct termios {
|
||||
tcflag_t c_iflag;
|
||||
tcflag_t c_oflag;
|
||||
tcflag_t c_cflag;
|
||||
tcflag_t c_lflag;
|
||||
char c_line;
|
||||
cc_t c_cc[NCCS];
|
||||
speed_t c_ispeed;
|
||||
speed_t c_ospeed;
|
||||
};
|
||||
|
||||
# ifndef _NO_MACROS
|
||||
|
||||
# define cfgetospeed(tp) ((tp)->c_ospeed)
|
||||
# define cfgetispeed(tp) ((tp)->c_ispeed)
|
||||
# define cfsetospeed(tp,s) (((tp)->c_ospeed = (s)), 0)
|
||||
# define cfsetispeed(tp,s) (((tp)->c_ispeed = (s)), 0)
|
||||
# define tcdrain(fd) _ioctl (fd, _TCSBRK, 1)
|
||||
# endif /* _NO_MACROS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_TERMIOS_H */
|
||||
|
@ -1,112 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "sys/alt_alarm.h"
|
||||
#include "sys/alt_irq.h"
|
||||
|
||||
/*
|
||||
* alt_alarm_start is called to register an alarm with the system. The
|
||||
* "alarm" structure passed as an input argument does not need to be
|
||||
* initialised by the user. This is done within this function.
|
||||
*
|
||||
* The remaining input arguments are:
|
||||
*
|
||||
* nticks - The time to elapse until the alarm executes. This is specified in
|
||||
* system clock ticks.
|
||||
* callback - The function to run when the indicated time has elapsed.
|
||||
* context - An opaque value, passed to the callback function.
|
||||
*
|
||||
* Care should be taken when defining the callback function since it is
|
||||
* likely to execute in interrupt context. In particular, this mean that
|
||||
* library calls like printf() should not be made, since they can result in
|
||||
* deadlock.
|
||||
*
|
||||
* The interval to be used for the next callback is the return
|
||||
* value from the callback function. A return value of zero indicates that the
|
||||
* alarm should be unregistered.
|
||||
*
|
||||
* alt_alarm_start() will fail if the timer facility has not been enabled
|
||||
* (i.e. there is no system clock). Failure is indicated by a negative return
|
||||
* value.
|
||||
*/
|
||||
|
||||
int alt_alarm_start (alt_alarm* alarm, alt_u32 nticks,
|
||||
alt_u32 (*callback) (void* context),
|
||||
void* context)
|
||||
{
|
||||
alt_irq_context irq_context;
|
||||
alt_u32 current_nticks = 0;
|
||||
|
||||
if (alt_ticks_per_second ())
|
||||
{
|
||||
if (alarm)
|
||||
{
|
||||
alarm->callback = callback;
|
||||
alarm->context = context;
|
||||
|
||||
irq_context = alt_irq_disable_all ();
|
||||
|
||||
current_nticks = alt_nticks();
|
||||
|
||||
alarm->time = nticks + current_nticks + 1;
|
||||
|
||||
/*
|
||||
* If the desired alarm time causes a roll-over, set the rollover
|
||||
* flag. This will prevent the subsequent tick event from causing
|
||||
* an alarm too early.
|
||||
*/
|
||||
if(alarm->time < current_nticks)
|
||||
{
|
||||
alarm->rollover = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
alarm->rollover = 0;
|
||||
}
|
||||
|
||||
alt_llist_insert (&alt_alarm_list, &alarm->llist);
|
||||
alt_irq_enable_all (irq_context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2004 Altera Corporation, San Jose, California, USA.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ------------
|
||||
*
|
||||
* Altera does not recommend, suggest or require that this reference design
|
||||
* file be used in conjunction or combination with any other product.
|
||||
*
|
||||
* alt_busy_sleep.c - Microsecond delay routine which uses a calibrated busy
|
||||
* loop to perform the delay. This is used to implement
|
||||
* usleep for both uC/OS-II and the standalone HAL.
|
||||
*
|
||||
* Author PRR
|
||||
*
|
||||
* Calibrated delay with no timer required
|
||||
*
|
||||
* The ASM instructions in the routine are equivalent to
|
||||
*
|
||||
* for (i=0;i<us*(ALT_CPU_FREQ/3);i++);
|
||||
*
|
||||
* and takes three cycles each time around the loop
|
||||
*
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "alt_types.h"
|
||||
|
||||
#include "priv/alt_busy_sleep.h"
|
||||
|
||||
unsigned int alt_busy_sleep (unsigned int us)
|
||||
{
|
||||
/*
|
||||
* Only delay if ALT_SIM_OPTIMIZE is not defined; i.e., if software
|
||||
* is built targetting ModelSim RTL simulation, the delay will be
|
||||
* skipped to speed up simulation.
|
||||
*/
|
||||
#ifndef ALT_SIM_OPTIMIZE
|
||||
int i;
|
||||
int big_loops;
|
||||
alt_u32 cycles_per_loop;
|
||||
|
||||
if (!strcmp(NIOS2_CPU_IMPLEMENTATION,"tiny"))
|
||||
{
|
||||
cycles_per_loop = 9;
|
||||
}
|
||||
else
|
||||
{
|
||||
cycles_per_loop = 3;
|
||||
}
|
||||
|
||||
|
||||
big_loops = us / (INT_MAX/
|
||||
(ALT_CPU_FREQ/(cycles_per_loop * 1000000)));
|
||||
|
||||
if (big_loops)
|
||||
{
|
||||
for(i=0;i<big_loops;i++)
|
||||
{
|
||||
/*
|
||||
* Do NOT Try to single step the asm statement below
|
||||
* (single step will never return)
|
||||
* Step out of this function or set a breakpoint after the asm statements
|
||||
*/
|
||||
__asm__ volatile (
|
||||
"\n0:"
|
||||
"\n\taddi %0,%0, -1"
|
||||
"\n\tbne %0,zero,0b"
|
||||
"\n1:"
|
||||
"\n\t.pushsection .debug_alt_sim_info"
|
||||
"\n\t.int 4, 0, 0b, 1b"
|
||||
"\n\t.popsection"
|
||||
:: "r" (INT_MAX));
|
||||
us -= (INT_MAX/(ALT_CPU_FREQ/
|
||||
(cycles_per_loop * 1000000)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Do NOT Try to single step the asm statement below
|
||||
* (single step will never return)
|
||||
* Step out of this function or set a breakpoint after the asm statements
|
||||
*/
|
||||
__asm__ volatile (
|
||||
"\n0:"
|
||||
"\n\taddi %0,%0, -1"
|
||||
"\n\tbne %0,zero,0b"
|
||||
"\n1:"
|
||||
"\n\t.pushsection .debug_alt_sim_info"
|
||||
"\n\t.int 4, 0, 0b, 1b"
|
||||
"\n\t.popsection"
|
||||
:: "r" (us*(ALT_CPU_FREQ/(cycles_per_loop * 1000000))));
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Do NOT Try to single step the asm statement below
|
||||
* (single step will never return)
|
||||
* Step out of this function or set a breakpoint after the asm statements
|
||||
*/
|
||||
__asm__ volatile (
|
||||
"\n0:"
|
||||
"\n\taddi %0,%0, -1"
|
||||
"\n\tbgt %0,zero,0b"
|
||||
"\n1:"
|
||||
"\n\t.pushsection .debug_alt_sim_info"
|
||||
"\n\t.int 4, 0, 0b, 1b"
|
||||
"\n\t.popsection"
|
||||
:: "r" (us*(ALT_CPU_FREQ/(cycles_per_loop * 1000000))));
|
||||
}
|
||||
#endif /* #ifndef ALT_SIM_OPTIMIZE */
|
||||
return 0;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sys/alt_errno.h"
|
||||
#include "sys/alt_warning.h"
|
||||
#include "priv/alt_file.h"
|
||||
#include "os/alt_syscall.h"
|
||||
|
||||
#ifdef ALT_USE_DIRECT_DRIVERS
|
||||
|
||||
int ALT_CLOSE (int fildes)
|
||||
{
|
||||
/* Generate a link time warning, should this function ever be called. */
|
||||
|
||||
ALT_STUB_WARNING(close);
|
||||
|
||||
/* Indicate an error */
|
||||
|
||||
ALT_ERRNO = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else /* !ALT_USE_DIRECT_DRIVERS */
|
||||
|
||||
/*
|
||||
* close() is called by an application to release a file descriptor. If the
|
||||
* associated file system/device has a close() callback function registered
|
||||
* then this called. The file descriptor is then marked as free.
|
||||
*
|
||||
* ALT_CLOSE is mapped onto the close() system call in alt_syscall.h
|
||||
*/
|
||||
|
||||
int ALT_CLOSE (int fildes)
|
||||
{
|
||||
alt_fd* fd;
|
||||
int rval;
|
||||
|
||||
/*
|
||||
* A common error case is that when the file descriptor was created, the call
|
||||
* to open() failed resulting in a negative file descriptor. This is trapped
|
||||
* below so that we don't try and process an invalid file descriptor.
|
||||
*/
|
||||
|
||||
fd = (fildes < 0) ? NULL : &alt_fd_list[fildes];
|
||||
|
||||
if (fd)
|
||||
{
|
||||
/*
|
||||
* If the associated file system/device has a close function, call it so
|
||||
* that any necessary cleanup code can run.
|
||||
*/
|
||||
|
||||
rval = (fd->dev->close) ? fd->dev->close(fd) : 0;
|
||||
|
||||
/* Free the file descriptor structure and return. */
|
||||
|
||||
alt_release_fd (fildes);
|
||||
if (rval < 0)
|
||||
{
|
||||
ALT_ERRNO = -rval;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ALT_ERRNO = EBADFD;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ALT_USE_DIRECT_DRIVERS */
|
@ -1,70 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003-2005 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "nios2.h"
|
||||
#include "system.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
#include "sys/alt_cache.h"
|
||||
|
||||
#define ALT_FLUSH_DATA(i) __asm__ volatile ("flushda (%0)" :: "r" (i));
|
||||
|
||||
/*
|
||||
* alt_dcache_flush() is called to flush the data cache for a memory
|
||||
* region of length "len" bytes, starting at address "start".
|
||||
*
|
||||
* Any dirty lines in the data cache are written back to memory.
|
||||
*/
|
||||
|
||||
void alt_dcache_flush (void* start, alt_u32 len)
|
||||
{
|
||||
#if NIOS2_DCACHE_SIZE > 0
|
||||
|
||||
char* i;
|
||||
char* end = ((char*) start) + len;
|
||||
|
||||
for (i = start; i < end; i+= NIOS2_DCACHE_LINE_SIZE)
|
||||
{
|
||||
ALT_FLUSH_DATA(i);
|
||||
}
|
||||
|
||||
/*
|
||||
* For an unaligned flush request, we've got one more line left.
|
||||
* Note that this is dependent on NIOS2_DCACHE_LINE_SIZE to be a
|
||||
* multiple of 2 (which it always is).
|
||||
*/
|
||||
|
||||
if (((alt_u32) start) & (NIOS2_DCACHE_LINE_SIZE - 1))
|
||||
{
|
||||
ALT_FLUSH_DATA(i);
|
||||
}
|
||||
|
||||
#endif /* NIOS2_DCACHE_SIZE > 0 */
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003-2005 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "nios2.h"
|
||||
#include "system.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
#include "sys/alt_cache.h"
|
||||
|
||||
/*
|
||||
* alt_dcache_flush_all() is called to flush the entire data cache.
|
||||
*/
|
||||
|
||||
void alt_dcache_flush_all (void)
|
||||
{
|
||||
#if NIOS2_DCACHE_SIZE > 0
|
||||
char* i;
|
||||
|
||||
for (i = (char*) 0; i < (char*) NIOS2_DCACHE_SIZE; i+= NIOS2_DCACHE_LINE_SIZE)
|
||||
{
|
||||
__asm__ volatile ("flushd (%0)" :: "r" (i));
|
||||
}
|
||||
#endif /* NIOS2_DCACHE_SIZE > 0 */
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2007 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "nios2.h"
|
||||
#include "system.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
#include "sys/alt_cache.h"
|
||||
|
||||
#define ALT_FLUSH_DATA_NO_WRITEBACK(i) \
|
||||
__asm__ volatile ("initda (%0)" :: "r" (i));
|
||||
|
||||
/*
|
||||
* alt_dcache_flush_no_writeback() is called to flush the data cache for a
|
||||
* memory region of length "len" bytes, starting at address "start".
|
||||
*
|
||||
* Any dirty lines in the data cache are NOT written back to memory.
|
||||
* Make sure you really want this behavior. If you aren't 100% sure,
|
||||
* use the alt_dcache_flush() routine instead.
|
||||
*/
|
||||
|
||||
void alt_dcache_flush_no_writeback (void* start, alt_u32 len)
|
||||
{
|
||||
char* i;
|
||||
char* end = ((char*) start) + len;
|
||||
|
||||
for (i = start; i < end; i+= NIOS2_DCACHE_LINE_SIZE)
|
||||
{
|
||||
ALT_FLUSH_DATA_NO_WRITEBACK(i);
|
||||
}
|
||||
|
||||
/*
|
||||
* For an unaligned flush request, we've got one more line left.
|
||||
* Note that this is dependent on NIOS2_DCACHE_LINE_SIZE to be a
|
||||
* multiple of 2 (which it always is).
|
||||
*/
|
||||
|
||||
if (((alt_u32) start) & (NIOS2_DCACHE_LINE_SIZE - 1))
|
||||
{
|
||||
ALT_FLUSH_DATA_NO_WRITEBACK(i);
|
||||
}
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "sys/alt_dev.h"
|
||||
#include "priv/alt_file.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
/*
|
||||
* This file contains the data constructs used to control access to device and
|
||||
* filesytems.
|
||||
*/
|
||||
|
||||
/*
|
||||
* "alt_fs_list" is the head of a linked list of registered filesystems. It is
|
||||
* initialised as an empty list. New entries can be added using the
|
||||
* alt_fs_reg() function.
|
||||
*/
|
||||
|
||||
ALT_LLIST_HEAD(alt_fs_list);
|
||||
|
||||
|
||||
/*
|
||||
* "alt_dev_list" is the head of a linked list of registered devices. It is
|
||||
* configured at startup to include a single device, "alt_dev_null". This
|
||||
* device is discussed below.
|
||||
*/
|
||||
|
||||
extern alt_dev alt_dev_null; /* forward declaration */
|
||||
|
||||
alt_llist alt_dev_list = {&alt_dev_null.llist, &alt_dev_null.llist};
|
||||
|
||||
/*
|
||||
* alt_dev_null_write() is the implementation of the write() function used
|
||||
* by the alt_dev_null device. It simple discards all data passed to it, and
|
||||
* indicates that the data has been successfully transmitted.
|
||||
*/
|
||||
|
||||
static int alt_dev_null_write (alt_fd* fd, const char* ptr, int len)
|
||||
{
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* "alt_dev_null" is used to allow output to be redirected to nowhere. It is
|
||||
* the only device registered before the call to alt_sys_init(). At startup
|
||||
* stin, stdout & stderr are all directed towards this device so that library
|
||||
* calls like printf() will be safe but inefectual.
|
||||
*/
|
||||
|
||||
alt_dev alt_dev_null = {
|
||||
{
|
||||
&alt_dev_list,
|
||||
&alt_dev_list
|
||||
},
|
||||
"/dev/null",
|
||||
NULL, /* open */
|
||||
NULL, /* close */
|
||||
NULL, /* write */
|
||||
alt_dev_null_write, /* write */
|
||||
NULL, /* lseek */
|
||||
NULL, /* fstat */
|
||||
NULL /* ioctl */
|
||||
};
|
||||
|
||||
/*
|
||||
* "alt_fd_list_lock" is a semaphore used to control access to the file
|
||||
* descriptor list. This is used to ensure that access to the list is thread
|
||||
* safe.
|
||||
*/
|
||||
|
||||
ALT_SEM(alt_fd_list_lock)
|
||||
|
||||
/*
|
||||
* "alt_max_fd" is used to make access to the file descriptor list more
|
||||
* efficent. It is set to be the value of the highest allocated file
|
||||
* descriptor. This saves having to search the entire pool of unallocated
|
||||
* file descriptors when looking for a match.
|
||||
*/
|
||||
|
||||
alt_32 alt_max_fd = -1;
|
||||
|
||||
/*
|
||||
* "alt_fd_list" is the file descriptor pool. The first three entries in the
|
||||
* array are configured as standard in, standard out, and standard error. These
|
||||
* are all initialised so that accesses are directed to the alt_dev_null
|
||||
* device. The remaining file descriptors are initialised as unallocated.
|
||||
*
|
||||
* The maximum number of file descriptors within the system is specified by the
|
||||
* user defined macro "ALT_MAX_FD". This is defined in "system.h", which is
|
||||
* auto-genereated using the projects PTF and STF files.
|
||||
*/
|
||||
|
||||
alt_fd alt_fd_list[ALT_MAX_FD] =
|
||||
{
|
||||
{
|
||||
&alt_dev_null, /* standard in */
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
&alt_dev_null, /* standard out */
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
&alt_dev_null, /* standard error */
|
||||
0,
|
||||
0
|
||||
}
|
||||
/* all other elements are set to zero */
|
||||
};
|
@ -1,59 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "priv/alt_dev_llist.h"
|
||||
#include "sys/alt_errno.h"
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
int alt_dev_llist_insert (alt_dev_llist* dev, alt_llist* list)
|
||||
{
|
||||
/*
|
||||
* check that the device exists, and that it has a valid name.
|
||||
*/
|
||||
|
||||
if (!dev || !dev->name)
|
||||
{
|
||||
ALT_ERRNO = EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* register the device.
|
||||
*/
|
||||
|
||||
alt_llist_insert(list, &dev->llist);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_dma.h"
|
||||
#include "sys/alt_errno.h"
|
||||
#include "priv/alt_file.h"
|
||||
|
||||
/*
|
||||
* The list of registered DMA receive channels.
|
||||
*/
|
||||
|
||||
ALT_LLIST_HEAD(alt_dma_rxchan_list);
|
||||
|
||||
/*
|
||||
* alt_dma_txchan_open() is used to obtain an "alt_dma_txchan" descriptor for
|
||||
* a DMA transmit device. The name is the name of the associated physical
|
||||
* device (e.g. "/dev/dma_0").
|
||||
*
|
||||
* The return value will be NULL on failure, and non-NULL otherwise.
|
||||
*/
|
||||
|
||||
alt_dma_rxchan alt_dma_rxchan_open (const char* name)
|
||||
{
|
||||
alt_dma_rxchan dev;
|
||||
|
||||
dev = (alt_dma_rxchan) alt_find_dev (name, &alt_dma_rxchan_list);
|
||||
|
||||
if (!dev)
|
||||
{
|
||||
ALT_ERRNO = ENODEV;
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_dma.h"
|
||||
#include "sys/alt_errno.h"
|
||||
#include "priv/alt_file.h"
|
||||
|
||||
/*
|
||||
* The list of registered receive channels.
|
||||
*/
|
||||
|
||||
ALT_LLIST_HEAD(alt_dma_txchan_list);
|
||||
|
||||
/*
|
||||
* alt_dma_txchan_open() is used to obtain an "alt_dma_txchan" descriptor for
|
||||
* a DMA transmit device. The name is the name of the associated physical
|
||||
* device (e.g. "/dev/dma_0").
|
||||
*
|
||||
* The return value will be NULL on failure, and non-NULL otherwise.
|
||||
*/
|
||||
|
||||
alt_dma_txchan alt_dma_txchan_open (const char* name)
|
||||
{
|
||||
alt_dma_txchan dev;
|
||||
|
||||
dev = (alt_dma_txchan) alt_find_dev (name, &alt_dma_txchan_list);
|
||||
|
||||
if (!dev)
|
||||
{
|
||||
ALT_ERRNO = ENODEV;
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT IT DIRECTLY. *
|
||||
* *
|
||||
* Overriding HAL Functions *
|
||||
* *
|
||||
* To provide your own implementation of a HAL function, include the file in *
|
||||
* your Nios II IDE application project. When building the executable, the *
|
||||
* Nios II IDE finds your function first, and uses it in place of the HAL *
|
||||
* version. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
typedef void (*constructor) (void);
|
||||
extern constructor __CTOR_LIST__[];
|
||||
extern constructor __CTOR_END__[];
|
||||
|
||||
/*
|
||||
* Run the C++ static constructors.
|
||||
*/
|
||||
|
||||
void _do_ctors(void)
|
||||
{
|
||||
constructor* ctor;
|
||||
|
||||
for (ctor = &__CTOR_END__[-1]; ctor >= __CTOR_LIST__; ctor--)
|
||||
(*ctor) ();
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT IT DIRECTLY. *
|
||||
* *
|
||||
* Overriding HAL Functions *
|
||||
* *
|
||||
* To provide your own implementation of a HAL function, include the file in *
|
||||
* your Nios II IDE application project. When building the executable, the *
|
||||
* Nios II IDE finds your function first, and uses it in place of the HAL *
|
||||
* version. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
typedef void (*destructor) (void);
|
||||
extern destructor __DTOR_LIST__[];
|
||||
extern destructor __DTOR_END__[];
|
||||
|
||||
/*
|
||||
* Run the C++ static destructors.
|
||||
*/
|
||||
|
||||
void _do_dtors(void)
|
||||
{
|
||||
destructor* dtor;
|
||||
|
||||
for (dtor = &__DTOR_END__[-1]; dtor >= __DTOR_LIST__; dtor--)
|
||||
(*dtor) ();
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2013 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This is the code called at the beginning of the exception handler
|
||||
* to detect a likely fatal ECC error exception and then jump to
|
||||
* user-provided code to handle it.
|
||||
*
|
||||
* This code is pulled in from a .globl in alt_ecc_fatal_exception.c.
|
||||
* This scheme is used so that if a handler is never registered, then this
|
||||
* code will not appear in the generated executable, thereby improving
|
||||
* code footprint.
|
||||
*
|
||||
* This code is located in its own section that the linker script
|
||||
* explicitly mentions and ensures it gets linked at the beginning
|
||||
* of the exception handler.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pull in the exception handler register save code.
|
||||
*/
|
||||
.globl alt_exception
|
||||
|
||||
.section .exceptions.entry.ecc_fatal, "xa"
|
||||
|
||||
/*
|
||||
* This might be handling an unrecoverable ECC error exception
|
||||
* in the register file and/or data cache.
|
||||
* Must avoid reading registers or performing load/store instructions
|
||||
* before this is determined because they could trigger another
|
||||
* unrecoverable ECC error exception and create an infinite loop.
|
||||
*
|
||||
* The EXCEPTION register is always present when ECC is present.
|
||||
* Bit 31 of this register indicates that there was an unrecoverable
|
||||
* ECC error exception in the register file and/or data cache.
|
||||
* Test this (using blt to check sign bit) to determine if this is
|
||||
* what we are dealing with. Otherwise, just do normal processing.
|
||||
*
|
||||
* Jump to an application-provided routine to handle this condition.
|
||||
* Pass in the return address in the et register in case this code
|
||||
* can clean up the ECC error and then return here (unlikely).
|
||||
*
|
||||
* Runtime stack checking can't be enabled when ECC is present
|
||||
* because they both want to use the et register.
|
||||
*/
|
||||
rdctl et, exception
|
||||
bge et, r0, alt_exception_not_ecc_fatal /* Not ECCFTL if bit 31 is 0 */
|
||||
|
||||
/*
|
||||
* Load ECC fatal handler pointer into et register.
|
||||
* Using a ldwio is safe because it completely bypasses the data cache.
|
||||
*/
|
||||
movhi et, %hi(alt_exception_ecc_fatal_handler)
|
||||
ori et, et, %lo(alt_exception_ecc_fatal_handler)
|
||||
ldwio et, 0(et)
|
||||
|
||||
/*
|
||||
* If ECC fatal handler pointer is not 0, assume a handler
|
||||
* has been provided by the application.
|
||||
*/
|
||||
beq et, r0, alt_exception_not_ecc_fatal
|
||||
|
||||
/*
|
||||
* The et register contains the address of the ECC fatal handler.
|
||||
* Jump to this address to invoke the handler.
|
||||
*/
|
||||
jmp et
|
||||
|
||||
/*
|
||||
* An ECC fatal handler can jump to this label if it able
|
||||
* to recover from the fatal error (rare) and wants to continue
|
||||
* with normal exception processing.
|
||||
*/
|
||||
.globl alt_exception_not_ecc_fatal
|
||||
alt_exception_not_ecc_fatal:
|
@ -1,75 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2013 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
#include "io.h"
|
||||
#include "sys/alt_exceptions.h"
|
||||
#include "sys/alt_cache.h"
|
||||
|
||||
/*
|
||||
* This file implements support for calling a user-registered handler
|
||||
* when a likely fatal ECC error exception occurs.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global variable containing address to jump to when likely fatal
|
||||
* ECC error exception occurs.
|
||||
*/
|
||||
alt_u32 alt_exception_ecc_fatal_handler = 0x0;
|
||||
|
||||
/*
|
||||
* Pull in the exception entry assembly code. This will not be linked in
|
||||
* unless this object is linked into the executable (i.e. only if
|
||||
* alt_ecc_fatal_exception_register() is called).
|
||||
*/
|
||||
__asm__( "\n\t.globl alt_exception" );
|
||||
|
||||
/*
|
||||
* alt_ecc_fatal_exception_register() is called to register a handler to
|
||||
* service likely fatal ECC error exceptions.
|
||||
*
|
||||
* Passing null (0x0) in the handler argument will disable a previously-
|
||||
* registered handler.
|
||||
*
|
||||
* Note that if no handler is registered, just normal exception processing
|
||||
* occurs on a likely fatal ECC exception and the exception processing
|
||||
* code might trigger an infinite exception loop.
|
||||
*/
|
||||
void
|
||||
alt_ecc_fatal_exception_register(alt_u32 handler)
|
||||
{
|
||||
alt_exception_ecc_fatal_handler = handler;
|
||||
|
||||
/*
|
||||
* Flush this from the cache. Required because the exception handler uses ldwio
|
||||
* to read this value to avoid trigger another data cache ECC error exception.
|
||||
*/
|
||||
alt_dcache_flush(&alt_exception_ecc_fatal_handler, sizeof(alt_exception_ecc_fatal_handler));
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "os/alt_syscall.h"
|
||||
|
||||
/*
|
||||
* These are the environment variables passed to the C code. By default there
|
||||
* are no variables registered. An application can manipulate this list using
|
||||
* getenv() and setenv().
|
||||
*/
|
||||
|
||||
char *__env[1] = { 0 };
|
||||
char **ALT_ENVIRON = __env;
|
@ -1,44 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file defines the alt_errno global variable. See comments in
|
||||
* alt_errno.h for the use of this variable.
|
||||
*/
|
||||
|
||||
|
||||
#include "sys/alt_errno.h"
|
||||
#include "alt_types.h"
|
||||
|
||||
extern int ALT_WEAK *__errno (void);
|
||||
|
||||
int* (*alt_errno) (void) = __errno;
|
@ -1,402 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003-2008 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
/*
|
||||
* This is the exception entry point code, which saves all the caller saved
|
||||
* registers and then handles the appropriate exception. It should be pulled
|
||||
* in using a .globl from all the exception handler routines. This scheme is
|
||||
* used so that if an interrupt is never registered, then this code will not
|
||||
* appear in the generated executable, thereby improving code footprint.
|
||||
*
|
||||
* If an external interrpt controller (EIC) is present, it will supply an
|
||||
* interrupt vector address to the processor when an interrupt occurs. For
|
||||
* The Altera Vectored Interrupt Controller (VIC) driver will establish a
|
||||
* vector table and the processor will jump directly to the appropriate
|
||||
* table entry, funnel routine, and then user ISR. This will bypass this code
|
||||
* in entirety. This code might still be linked into a system with an EIC,
|
||||
* but would then be used only for non-interrupt exceptions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Explicitly allow the use of r1 (the assembler temporary register)
|
||||
* within this code. This register is normally reserved for the use of
|
||||
* the assembler.
|
||||
*/
|
||||
.set noat
|
||||
|
||||
/*
|
||||
* The top and bottom of the exception stack.
|
||||
*/
|
||||
#ifdef ALT_EXCEPTION_STACK
|
||||
.globl __alt_exception_stack_pointer
|
||||
|
||||
#ifdef ALT_STACK_CHECK
|
||||
.globl __alt_exception_stack_limit
|
||||
|
||||
/*
|
||||
* Store the value of the stack limit after interrupt somewhere.
|
||||
*/
|
||||
.globl alt_exception_old_stack_limit
|
||||
#endif /* ALT_STACK_CHECK */
|
||||
#endif /* ALT_EXCEPTION_STACK */
|
||||
|
||||
/*
|
||||
* The code at alt_exception is located at the Nios II exception
|
||||
* handler address.
|
||||
*/
|
||||
.section .exceptions.entry.label, "xa"
|
||||
.globl alt_exception
|
||||
.type alt_exception, @function
|
||||
alt_exception:
|
||||
|
||||
/*
|
||||
* The code for detecting a likely fatal ECC exception is
|
||||
* linked here before the normal exception handler code if required.
|
||||
* This is handled by the linker script and putting that code
|
||||
* in the .exceptions.entry.ecc_fatal section.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Now start the normal exception handler code.
|
||||
*/
|
||||
.section .exceptions.entry, "xa"
|
||||
|
||||
#ifdef ALT_EXCEPTION_STACK
|
||||
#ifdef ALT_STACK_CHECK
|
||||
/*
|
||||
* When runtime stack checking is enabled, the et register
|
||||
* contains the stack limit. Save this in memory before
|
||||
* overwriting the et register.
|
||||
*/
|
||||
stw et, %gprel(alt_exception_old_stack_limit)(gp)
|
||||
#endif /* ALT_STACK_CHECK */
|
||||
|
||||
/*
|
||||
* Switch to the exception stack and save the current stack pointer
|
||||
* in memory. Uses the et register as a scratch register.
|
||||
*/
|
||||
movhi et, %hi(__alt_exception_stack_pointer - 80)
|
||||
ori et, et, %lo(__alt_exception_stack_pointer - 80)
|
||||
stw sp, 76(et)
|
||||
mov sp, et
|
||||
|
||||
#ifdef ALT_STACK_CHECK
|
||||
/*
|
||||
* Restore the stack limit from memory to the et register.
|
||||
*/
|
||||
movhi et, %hi(__alt_exception_stack_limit)
|
||||
ori et, et, %lo(__alt_exception_stack_limit)
|
||||
stw et, %gprel(alt_stack_limit_value)(gp)
|
||||
#endif /* ALT_STACK_CHECK */
|
||||
|
||||
#else /* ALT_EXCEPTION_STACK disabled */
|
||||
/*
|
||||
* Reserve space on normal stack for registers about to be pushed.
|
||||
*/
|
||||
addi sp, sp, -76
|
||||
|
||||
#ifdef ALT_STACK_CHECK
|
||||
/* Ensure stack didn't just overflow. */
|
||||
bltu sp, et, .Lstack_overflow
|
||||
#endif /* ALT_STACK_CHECK */
|
||||
|
||||
#endif /* ALT_EXCEPTION_STACK */
|
||||
|
||||
/*
|
||||
* Process an exception. For all exceptions we must preserve all
|
||||
* caller saved registers on the stack (See the Nios II ABI
|
||||
* documentation for details).
|
||||
*
|
||||
* Leave a gap in the stack frame at 4(sp) for the muldiv handler to
|
||||
* store zero into.
|
||||
*/
|
||||
stw ra, 0(sp)
|
||||
stw r1, 8(sp)
|
||||
stw r2, 12(sp)
|
||||
stw r3, 16(sp)
|
||||
stw r4, 20(sp)
|
||||
stw r5, 24(sp)
|
||||
stw r6, 28(sp)
|
||||
stw r7, 32(sp)
|
||||
rdctl r5, estatus /* Read early to avoid usage stall */
|
||||
stw r8, 36(sp)
|
||||
stw r9, 40(sp)
|
||||
stw r10, 44(sp)
|
||||
stw r11, 48(sp)
|
||||
stw r12, 52(sp)
|
||||
stw r13, 56(sp)
|
||||
stw r14, 60(sp)
|
||||
stw r15, 64(sp)
|
||||
|
||||
/*
|
||||
* ea-4 contains the address of the instruction being executed
|
||||
* when the exception occured. For interrupt exceptions, we will
|
||||
* will be re-issue the isntruction. Store it in 72(sp)
|
||||
*/
|
||||
stw r5, 68(sp) /* estatus */
|
||||
addi r15, ea, -4 /* instruction that caused exception */
|
||||
stw r15, 72(sp)
|
||||
|
||||
/*
|
||||
* The interrupt testing code (.exceptions.irqtest) will be
|
||||
* linked here. If the Internal Interrupt Controller (IIC) is
|
||||
* present (an EIC is not present), the presense of an interrupt
|
||||
* is determined by examining CPU control registers or an interrupt
|
||||
* custom instruction, if present.
|
||||
*
|
||||
* If the IIC is used and an interrupt is active, the code linked
|
||||
* here will call the HAL IRQ handler (alt_irq_handler()) which
|
||||
* successively calls registered interrupt handler(s) until no
|
||||
* interrupts remain pending. It then jumps to .exceptions.exit. If
|
||||
* there is no interrupt then it continues to .exception.notirq, below.
|
||||
*/
|
||||
|
||||
.section .exceptions.notirq, "xa"
|
||||
|
||||
/*
|
||||
* Prepare to service unimplemtned instructions or traps,
|
||||
* each of which is optionally inked into section .exceptions.soft,
|
||||
* which will preceed .exceptions.unknown below.
|
||||
*
|
||||
* Unlike interrupts, we want to skip the exception-causing instructon
|
||||
* upon completion, so we write ea (address of instruction *after*
|
||||
* the one where the exception occured) into 72(sp). The actual
|
||||
* instruction that caused the exception is written in r2, which these
|
||||
* handlers will utilize.
|
||||
*/
|
||||
stw ea, 72(sp) /* EA is PC+4 so will skip over instruction causing exception */
|
||||
|
||||
#ifdef NIOS2_CDX_PRESENT
|
||||
mov.n r4, ea /* EA contains PC+4 of instruction that caused the exception */
|
||||
subi.n r4, r4, 4 /* Calculate PC */
|
||||
ldhu.n r2, 0(r4) /* Load least-significant 16 bits of instruction */
|
||||
andi r5, r2, 0x7 /* Mask off all bits except the 3 most-significant bits of OP field */
|
||||
|
||||
/*
|
||||
* These instructions compare the MSB 3 bits of OP to 0x1, 0x3, and 0x5
|
||||
* which is where all the 16-bit instructions live.
|
||||
*/
|
||||
subi.n r5, r5, 1
|
||||
beqz.n r5, .Lunknown_16bit
|
||||
subi.n r5, r5, 2
|
||||
beqz.n r5, .Lunknown_16bit
|
||||
subi.n r5, r5, 2
|
||||
beqz.n r5, .Lunknown_16bit
|
||||
|
||||
.Lunknown_32bit:
|
||||
stw ea, 72(sp) /* EA is PC+4 so will skip over instruction causing exception */
|
||||
|
||||
/* Load most-significant 16 bits of instruction */
|
||||
ldhu.n r3, 2(r4)
|
||||
slli.n r3, r3, 16
|
||||
or.n r2, r2, r3 /* 32-bit instruction value that caused exception */
|
||||
br.n .Lunknown_inst_loaded
|
||||
|
||||
.Lunknown_16bit:
|
||||
addi.n r4, r4, 2 /* Need PC+2 to skip over instruction causing exception */
|
||||
stw r4, 72(sp)
|
||||
|
||||
#else /* CDX is not Enabled and all instructions are 32bits */
|
||||
ldw r2, -4(ea) /* Instruction value that caused exception */
|
||||
#endif
|
||||
|
||||
.Lunknown_inst_loaded:
|
||||
|
||||
/*
|
||||
* Other exception handling code, if enabled, will be linked here.
|
||||
* This includes unimplemted (multiply/divide) instruction support
|
||||
* (a BSP generaton option), and a trap handler (that would typically
|
||||
* be augmented with user-specific code). These are not linked in by
|
||||
* default.
|
||||
*/
|
||||
|
||||
/*
|
||||
* In the context of linker sections, "unknown" are all exceptions
|
||||
* not handled by the built-in handlers above (interupt, and trap or
|
||||
* unimplemented instruction decoding, if enabled).
|
||||
*
|
||||
* Advanced exception types can be serviced by registering a handler.
|
||||
* To do so, enable the "Enable Instruction-related Exception API" HAL
|
||||
* BSP setting. If this setting is disabled, this handler code will
|
||||
* either break (if the debug core is present) or enter an infinite
|
||||
* loop because we don't how how to handle the exception.
|
||||
*/
|
||||
.section .exceptions.unknown
|
||||
#ifdef ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API
|
||||
/*
|
||||
* The C-based HAL routine alt_instruction_exception_entry() will
|
||||
* attempt to service the exception by calling a user-registered
|
||||
* exception handler using alt_instruction_exception_register().
|
||||
* If no handler was registered it will either break (if the
|
||||
* debugger is present) or go into an infinite loop since the
|
||||
* handling behavior is undefined; in that case we will not return here.
|
||||
*/
|
||||
|
||||
/* Load exception-causing address as first argument (r4) */
|
||||
addi r4, ea, -4
|
||||
|
||||
/* Call the instruction-exception entry */
|
||||
call alt_instruction_exception_entry
|
||||
|
||||
/*
|
||||
* If alt_instruction_exception_entry() returned, the exception was
|
||||
* serviced by a user-registered routine. Its return code (now in r2)
|
||||
* indicates whether to re-issue or skip the exception-causing
|
||||
* instruction
|
||||
*
|
||||
* Return code was 0: Skip. The instruction after the exception is
|
||||
* already stored in 72(sp).
|
||||
*/
|
||||
bne r2, r0, .Lexception_exit
|
||||
|
||||
/*
|
||||
* Otherwise, modify 72(sp) to re-issue the instruction that caused the
|
||||
* exception.
|
||||
*/
|
||||
addi r15, ea, -4 /* instruction that caused exception */
|
||||
stw r15, 72(sp)
|
||||
|
||||
#else /* ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API disabled */
|
||||
|
||||
/*
|
||||
* We got here because an instruction-related exception occured, but the
|
||||
* handler API was not compiled in. We do not presume to know how to
|
||||
* handle it. If the debugger is present, break, otherwise hang.
|
||||
*
|
||||
* If you get here then one of the following could have happened:
|
||||
*
|
||||
* - An instruction-generated exception occured, and the processor
|
||||
* does not have the extra exceptions feature enabled, or you
|
||||
* have not registered a handler using
|
||||
* alt_instruction_exception_register()
|
||||
*
|
||||
* Some examples of instruction-generated exceptions and why they
|
||||
* might occur:
|
||||
*
|
||||
* - Your program could have been compiled for a full-featured
|
||||
* Nios II core, but it is running on a smaller core, and
|
||||
* instruction emulation has been disabled by defining
|
||||
* ALT_NO_INSTRUCTION_EMULATION.
|
||||
*
|
||||
* You can work around the problem by re-enabling instruction
|
||||
* emulation, or you can figure out why your program is being
|
||||
* compiled for a system other than the one that it is running on.
|
||||
*
|
||||
* - Your program has executed a trap instruction, but has not
|
||||
* implemented a handler for this instruction.
|
||||
*
|
||||
* - Your program has executed an illegal instruction (one which is
|
||||
* not defined in the instruction set).
|
||||
*
|
||||
* - Your processor includes an MMU or MPU, and you have enabled it
|
||||
* before registering an exception handler to service exceptions it
|
||||
* generates.
|
||||
*
|
||||
* The problem could also be hardware related:
|
||||
* - If your hardware is broken and is generating spurious interrupts
|
||||
* (a peripheral which negates its interrupt output before its
|
||||
* interrupt handler has been executed will cause spurious
|
||||
* interrupts)
|
||||
*/
|
||||
alt_exception_unknown:
|
||||
#ifdef NIOS2_HAS_DEBUG_STUB
|
||||
/*
|
||||
* Either tell the user now (if there is a debugger attached) or go into
|
||||
* the debug monitor which will loop until a debugger is attached.
|
||||
*/
|
||||
break
|
||||
#else /* NIOS2_HAS_DEBUG_STUB disabled */
|
||||
/*
|
||||
* If there is no debug stub, an infinite loop is more useful.
|
||||
*/
|
||||
br alt_exception_unknown
|
||||
#endif /* NIOS2_HAS_DEBUG_STUB */
|
||||
#endif /* ALT_INCLUDE_INSTRUCTION_RELATED_EXCEPTION_API */
|
||||
|
||||
.section .exceptions.exit.label
|
||||
.Lexception_exit:
|
||||
|
||||
.section .exceptions.exit, "xa"
|
||||
|
||||
/*
|
||||
* Restore the saved registers, so that all general purpose registers
|
||||
* have been restored to their state at the time the interrupt occured.
|
||||
*/
|
||||
|
||||
ldw r5, 68(sp)
|
||||
ldw ea, 72(sp) /* This becomes the PC once eret is executed */
|
||||
ldw ra, 0(sp)
|
||||
|
||||
wrctl estatus, r5
|
||||
|
||||
ldw r1, 8(sp)
|
||||
ldw r2, 12(sp)
|
||||
ldw r3, 16(sp)
|
||||
ldw r4, 20(sp)
|
||||
ldw r5, 24(sp)
|
||||
ldw r6, 28(sp)
|
||||
ldw r7, 32(sp)
|
||||
|
||||
#if defined(ALT_EXCEPTION_STACK) && defined(ALT_STACK_CHECK)
|
||||
ldw et, %gprel(alt_exception_old_stack_limit)(gp)
|
||||
#endif
|
||||
|
||||
ldw r8, 36(sp)
|
||||
ldw r9, 40(sp)
|
||||
ldw r10, 44(sp)
|
||||
ldw r11, 48(sp)
|
||||
ldw r12, 52(sp)
|
||||
ldw r13, 56(sp)
|
||||
ldw r14, 60(sp)
|
||||
ldw r15, 64(sp)
|
||||
|
||||
#ifdef ALT_EXCEPTION_STACK
|
||||
#ifdef ALT_STACK_CHECK
|
||||
stw et, %gprel(alt_stack_limit_value)(gp)
|
||||
stw zero, %gprel(alt_exception_old_stack_limit)(gp)
|
||||
#endif /* ALT_STACK_CHECK */
|
||||
ldw sp, 76(sp)
|
||||
#else /* ALT_EXCEPTION_STACK disabled */
|
||||
addi sp, sp, 76
|
||||
#endif /* ALT_EXCEPTION_STACK */
|
||||
|
||||
/*
|
||||
* Return to the interrupted instruction.
|
||||
*/
|
||||
|
||||
eret
|
||||
|
||||
#ifdef ALT_STACK_CHECK
|
||||
.Lstack_overflow:
|
||||
break 3
|
||||
#endif /* ALT_STACK_CHECK */
|
||||
|
@ -1,583 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003-2005 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This is the software multiply/divide handler for Nios2.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Provide a label which can be used to pull this file in.
|
||||
*/
|
||||
|
||||
.section .exceptions.start
|
||||
.globl alt_exception_muldiv
|
||||
alt_exception_muldiv:
|
||||
|
||||
/*
|
||||
* Pull in the entry/exit code.
|
||||
*/
|
||||
.globl alt_exception
|
||||
|
||||
|
||||
.section .exceptions.soft, "xa"
|
||||
|
||||
|
||||
/* INSTRUCTION EMULATION
|
||||
* ---------------------
|
||||
*
|
||||
* Nios II processors generate exceptions for unimplemented instructions.
|
||||
* The routines below emulate these instructions. Depending on the
|
||||
* processor core, the only instructions that might need to be emulated
|
||||
* are div, divu, mul, muli, mulxss, mulxsu, and mulxuu.
|
||||
*
|
||||
* The emulations match the instructions, except for the following
|
||||
* limitations:
|
||||
*
|
||||
* 1) The emulation routines do not emulate the use of the exception
|
||||
* temporary register (et) as a source operand because the exception
|
||||
* handler already has modified it.
|
||||
*
|
||||
* 2) The routines do not emulate the use of the stack pointer (sp) or the
|
||||
* exception return address register (ea) as a destination because
|
||||
* modifying these registers crashes the exception handler or the
|
||||
* interrupted routine.
|
||||
*
|
||||
* 3) To save code size, the routines do not emulate the use of the
|
||||
* breakpoint registers (ba and bt) as operands.
|
||||
*
|
||||
* Detailed Design
|
||||
* ---------------
|
||||
*
|
||||
* The emulation routines expect the contents of integer registers r0-r31
|
||||
* to be on the stack at addresses sp, 4(sp), 8(sp), ... 124(sp). The
|
||||
* routines retrieve source operands from the stack and modify the
|
||||
* destination register's value on the stack prior to the end of the
|
||||
* exception handler. Then all registers except the destination register
|
||||
* are restored to their previous values.
|
||||
*
|
||||
* The instruction that causes the exception is found at address -4(ea).
|
||||
* The instruction's OP and OPX fields identify the operation to be
|
||||
* performed.
|
||||
*
|
||||
* One instruction, muli, is an I-type instruction that is identified by
|
||||
* an OP field of 0x24.
|
||||
*
|
||||
* muli AAAAA,BBBBB,IIIIIIIIIIIIIIII,-0x24-
|
||||
* 27 22 6 0 <-- LSB of field
|
||||
*
|
||||
* The remaining emulated instructions are R-type and have an OP field
|
||||
* of 0x3a. Their OPX fields identify them.
|
||||
*
|
||||
* R-type AAAAA,BBBBB,CCCCC,XXXXXX,NNNNN,-0x3a-
|
||||
* 27 22 17 11 6 0 <-- LSB of field
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Split the instruction into its fields. We need 4*A, 4*B, and 4*C as
|
||||
* offsets to the stack pointer for access to the stored register values.
|
||||
*/
|
||||
/* r2 = AAAAA,BBBBB,IIIIIIIIIIIIIIII,PPPPPP */
|
||||
roli r3, r2, 7 /* r3 = BBB,IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BB */
|
||||
roli r4, r3, 3 /* r4 = IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB */
|
||||
roli r6, r4, 2 /* r6 = IIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB,II */
|
||||
srai r4, r4, 16 /* r4 = (sign-extended) IMM16 */
|
||||
xori r6, r6, 0x42 /* r6 = CCC,XXXXXX,NNNNN,PPPPPP,AAAAA,bBBBB,cC */
|
||||
roli r7, r6, 5 /* r7 = XXXX,NNNNN,PPPPPP,AAAAA,bBBBB,cCCCC,XX */
|
||||
andi r5, r2, 0x3f /* r5 = 00000000000000000000000000,PPPPPP */
|
||||
xori r3, r3, 0x40
|
||||
andi r3, r3, 0x7c /* r3 = 0000000000000000000000000,aAAAA,00 */
|
||||
andi r6, r6, 0x7c /* r6 = 0000000000000000000000000,bBBBB,00 */
|
||||
andi r7, r7, 0x7c /* r7 = 0000000000000000000000000,cCCCC,00 */
|
||||
|
||||
/* Now either
|
||||
* r5 = OP
|
||||
* r3 = 4*(A^16)
|
||||
* r4 = IMM16 (sign extended)
|
||||
* r6 = 4*(B^16)
|
||||
* r7 = 4*(C^16)
|
||||
* or
|
||||
* r5 = OP
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Save everything on the stack to make it easy for the emulation routines
|
||||
* to retrieve the source register operands. The exception entry code has
|
||||
* already saved some of this so we don't need to do it all again.
|
||||
*/
|
||||
|
||||
addi sp, sp, -60
|
||||
stw zero, 64(sp) /* Save zero on stack to avoid special case for r0. */
|
||||
/* Register at and r2-r15 have already been saved. */
|
||||
|
||||
stw r16, 0(sp)
|
||||
stw r17, 4(sp)
|
||||
stw r18, 8(sp)
|
||||
stw r19, 12(sp)
|
||||
stw r20, 16(sp)
|
||||
stw r21, 20(sp)
|
||||
stw r22, 24(sp)
|
||||
stw r23, 28(sp)
|
||||
/* et @ 32 - Has already been changed.*/
|
||||
/* bt @ 36 - Usually isn't an operand. */
|
||||
stw gp, 40(sp)
|
||||
stw sp, 44(sp)
|
||||
stw fp, 48(sp)
|
||||
/* ea @ 52 - Don't bother to save - it's already been changed */
|
||||
/* ba @ 56 - Breakpoint register usually isn't an operand */
|
||||
/* ra @ 60 - Has already been saved */
|
||||
|
||||
|
||||
/*
|
||||
* Prepare for either multiplication or division loop.
|
||||
* They both loop 32 times.
|
||||
*/
|
||||
movi r14, 32
|
||||
|
||||
|
||||
/*
|
||||
* Get the operands.
|
||||
*
|
||||
* It is necessary to check for muli because it uses an I-type instruction
|
||||
* format, while the other instructions are have an R-type format.
|
||||
*/
|
||||
add r3, r3, sp /* r3 = address of A-operand. */
|
||||
ldw r3, 0(r3) /* r3 = A-operand. */
|
||||
movi r15, 0x24 /* muli opcode (I-type instruction format) */
|
||||
beq r5, r15, .Lmul_immed /* muli doesn't use the B register as a source */
|
||||
|
||||
add r6, r6, sp /* r6 = address of B-operand. */
|
||||
ldw r6, 0(r6) /* r6 = B-operand. */
|
||||
/* r4 = SSSSSSSSSSSSSSSS,-----IMM16------ */
|
||||
/* IMM16 not needed, align OPX portion */
|
||||
/* r4 = SSSSSSSSSSSSSSSS,CCCCC,-OPX--,00000 */
|
||||
srli r4, r4, 5 /* r4 = 00000,SSSSSSSSSSSSSSSS,CCCCC,-OPX-- */
|
||||
andi r4, r4, 0x3f /* r4 = 00000000000000000000000000,-OPX-- */
|
||||
|
||||
/* Now
|
||||
* r5 = OP
|
||||
* r3 = src1
|
||||
* r6 = src2
|
||||
* r4 = OPX (no longer can be muli)
|
||||
* r7 = 4*(C^16)
|
||||
* r14 = loop counter
|
||||
*/
|
||||
|
||||
/* ILLEGAL-INSTRUCTION EXCEPTION
|
||||
* -----------------------------
|
||||
*
|
||||
* This code is for Nios II cores that generate exceptions when attempting
|
||||
* to execute illegal instructions. Nios II cores that support an
|
||||
* illegal-instruction exception are identified by the presence of the
|
||||
* macro definition NIOS2_HAS_ILLEGAL_INSTRUCTION_EXCEPTION in system.h .
|
||||
*
|
||||
* Remember that illegal instructions are different than unimplemented
|
||||
* instructions. Illegal instructions are instruction encodings that
|
||||
* have not been defined by the Nios II ISA. Unimplemented instructions
|
||||
* are legal instructions that must be emulated by some Nios II cores.
|
||||
*
|
||||
* If we get here, all instructions except multiplies and divides
|
||||
* are illegal.
|
||||
*
|
||||
* This code assumes that OP is not muli (because muli was tested above).
|
||||
* All other multiplies and divides are legal. Anything else is illegal.
|
||||
*/
|
||||
|
||||
movi r8, 0x3a /* OP for R-type mul* and div* */
|
||||
bne r5, r8, .Lnot_muldiv
|
||||
|
||||
/* r15 already is 0x24 */ /* OPX of divu */
|
||||
beq r4, r15, .Ldivide
|
||||
|
||||
movi r15,0x27 /* OPX of mul */
|
||||
beq r4, r15, .Lmultiply
|
||||
|
||||
movi r15,0x07 /* OPX of mulxuu */
|
||||
beq r4, r15, .Lmultiply
|
||||
|
||||
movi r15,0x17 /* OPX of mulxsu */
|
||||
beq r4, r15, .Lmultiply
|
||||
|
||||
movi r15,0x1f /* OPX of mulxss */
|
||||
beq r4, r15, .Lmultiply
|
||||
|
||||
movi r15,0x25 /* OPX of div */
|
||||
bne r4, r15, .Lnot_muldiv
|
||||
|
||||
|
||||
/* DIVISION
|
||||
*
|
||||
* Divide an unsigned dividend by an unsigned divisor using
|
||||
* a shift-and-subtract algorithm. The example below shows
|
||||
* 43 div 7 = 6 for 8-bit integers. This classic algorithm uses a
|
||||
* single register to store both the dividend and the quotient,
|
||||
* allowing both values to be shifted with a single instruction.
|
||||
*
|
||||
* remainder dividend:quotient
|
||||
* --------- -----------------
|
||||
* initialize 00000000 00101011:
|
||||
* shift 00000000 0101011:_
|
||||
* remainder >= divisor? no 00000000 0101011:0
|
||||
* shift 00000000 101011:0_
|
||||
* remainder >= divisor? no 00000000 101011:00
|
||||
* shift 00000001 01011:00_
|
||||
* remainder >= divisor? no 00000001 01011:000
|
||||
* shift 00000010 1011:000_
|
||||
* remainder >= divisor? no 00000010 1011:0000
|
||||
* shift 00000101 011:0000_
|
||||
* remainder >= divisor? no 00000101 011:00000
|
||||
* shift 00001010 11:00000_
|
||||
* remainder >= divisor? yes 00001010 11:000001
|
||||
* remainder -= divisor - 00000111
|
||||
* ----------
|
||||
* 00000011 11:000001
|
||||
* shift 00000111 1:000001_
|
||||
* remainder >= divisor? yes 00000111 1:0000011
|
||||
* remainder -= divisor - 00000111
|
||||
* ----------
|
||||
* 00000000 1:0000011
|
||||
* shift 00000001 :0000011_
|
||||
* remainder >= divisor? no 00000001 :00000110
|
||||
*
|
||||
* The quotient is 00000110.
|
||||
*/
|
||||
|
||||
.Ldivide:
|
||||
/*
|
||||
* Prepare for division by assuming the result
|
||||
* is unsigned, and storing its "sign" as 0.
|
||||
*/
|
||||
movi r17, 0
|
||||
|
||||
|
||||
/* Which division opcode? */
|
||||
xori r15, r4, 0x25 /* OPX of div */
|
||||
bne r15, zero, .Lunsigned_division
|
||||
|
||||
|
||||
/*
|
||||
* OPX is div. Determine and store the sign of the quotient.
|
||||
* Then take the absolute value of both operands.
|
||||
*/
|
||||
xor r17, r3, r6 /* MSB contains sign of quotient */
|
||||
bge r3, zero, 0f
|
||||
sub r3, zero, r3 /* -r3 */
|
||||
0:
|
||||
bge r6, zero, 0f
|
||||
sub r6, zero, r6 /* -r6 */
|
||||
0:
|
||||
|
||||
|
||||
.Lunsigned_division:
|
||||
/* Initialize the unsigned-division loop. */
|
||||
movi r13, 0 /* remainder = 0 */
|
||||
|
||||
/* Now
|
||||
* r3 = dividend : quotient
|
||||
* r4 = 0x25 for div, 0x24 for divu
|
||||
* r6 = divisor
|
||||
* r13 = remainder
|
||||
* r14 = loop counter (already initialized to 32)
|
||||
* r17 = MSB contains sign of quotient
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* for (count = 32; count > 0; --count)
|
||||
* {
|
||||
*/
|
||||
.Ldivide_loop:
|
||||
|
||||
/*
|
||||
* Division:
|
||||
*
|
||||
* (remainder:dividend:quotient) <<= 1;
|
||||
*/
|
||||
slli r13, r13, 1
|
||||
cmplt r15, r3, zero /* r15 = MSB of r3 */
|
||||
or r13, r13, r15
|
||||
slli r3, r3, 1
|
||||
|
||||
|
||||
/*
|
||||
* if (remainder >= divisor)
|
||||
* {
|
||||
* set LSB of quotient
|
||||
* remainder -= divisor;
|
||||
* }
|
||||
*/
|
||||
bltu r13, r6, .Ldiv_skip
|
||||
ori r3, r3, 1
|
||||
sub r13, r13, r6
|
||||
.Ldiv_skip:
|
||||
|
||||
/*
|
||||
* }
|
||||
*/
|
||||
subi r14, r14, 1
|
||||
bne r14, zero, .Ldivide_loop
|
||||
|
||||
mov r9, r3
|
||||
|
||||
|
||||
/* Now
|
||||
* r9 = quotient
|
||||
* r4 = 0x25 for div, 0x24 for divu
|
||||
* r7 = 4*(C^16)
|
||||
* r17 = MSB contains sign of quotient
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Conditionally negate signed quotient. If quotient is unsigned,
|
||||
* the sign already is initialized to 0.
|
||||
*/
|
||||
bge r17, zero, .Lstore_result
|
||||
sub r9, zero, r9 /* -r9 */
|
||||
|
||||
br .Lstore_result
|
||||
|
||||
|
||||
|
||||
|
||||
/* MULTIPLICATION
|
||||
*
|
||||
* A "product" is the number that one gets by summing a "multiplicand"
|
||||
* several times. The "multiplier" specifies the number of copies of the
|
||||
* multiplicand that are summed.
|
||||
*
|
||||
* Actual multiplication algorithms don't use repeated addition, however.
|
||||
* Shift-and-add algorithms get the same answer as repeated addition, and
|
||||
* they are faster. To compute the lower half of a product (pppp below)
|
||||
* one shifts the product left before adding in each of the partial products
|
||||
* (a * mmmm) through (d * mmmm).
|
||||
*
|
||||
* To compute the upper half of a product (PPPP below), one adds in the
|
||||
* partial products (d * mmmm) through (a * mmmm), each time following the
|
||||
* add by a right shift of the product.
|
||||
*
|
||||
* mmmm
|
||||
* * abcd
|
||||
* ------
|
||||
* #### = d * mmmm
|
||||
* #### = c * mmmm
|
||||
* #### = b * mmmm
|
||||
* #### = a * mmmm
|
||||
* --------
|
||||
* PPPPpppp
|
||||
*
|
||||
* The example above shows 4 partial products. Computing actual Nios II
|
||||
* products requires 32 partials.
|
||||
*
|
||||
* It is possible to compute the result of mulxsu from the result of mulxuu
|
||||
* because the only difference between the results of these two opcodes is
|
||||
* the value of the partial product associated with the sign bit of rA.
|
||||
*
|
||||
* mulxsu = mulxuu - ((rA < 0) ? rB : 0);
|
||||
*
|
||||
* It is possible to compute the result of mulxss from the result of mulxsu
|
||||
* because the only difference between the results of these two opcodes is
|
||||
* the value of the partial product associated with the sign bit of rB.
|
||||
*
|
||||
* mulxss = mulxsu - ((rB < 0) ? rA : 0);
|
||||
*
|
||||
*/
|
||||
|
||||
.Lmul_immed:
|
||||
/* Opcode is muli. Change it into mul for remainder of algorithm. */
|
||||
mov r7, r6 /* Field B is dest register, not field C. */
|
||||
mov r6, r4 /* Field IMM16 is src2, not field B. */
|
||||
movi r4, 0x27 /* OPX of mul is 0x27 */
|
||||
|
||||
.Lmultiply:
|
||||
/* Initialize the multiplication loop. */
|
||||
movi r9, 0 /* mul_product = 0 */
|
||||
movi r10, 0 /* mulxuu_product = 0 */
|
||||
mov r11, r6 /* save original multiplier for mulxsu and mulxss */
|
||||
mov r12, r6 /* mulxuu_multiplier (will be shifted) */
|
||||
movi r16, 1 /* used to create "rori B,A,1" from "ror B,A,r16" */
|
||||
|
||||
/* Now
|
||||
* r3 = multiplicand
|
||||
* r6 = mul_multiplier
|
||||
* r7 = 4 * dest_register (used later as offset to sp)
|
||||
* r9 = mul_product
|
||||
* r10 = mulxuu_product
|
||||
* r11 = original multiplier
|
||||
* r12 = mulxuu_multiplier
|
||||
* r14 = loop counter (already initialized)
|
||||
* r15 = temp
|
||||
* r16 = 1
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* for (count = 32; count > 0; --count)
|
||||
* {
|
||||
*/
|
||||
.Lmultiply_loop:
|
||||
|
||||
/*
|
||||
* mul_product <<= 1;
|
||||
* lsb = multiplier & 1;
|
||||
*/
|
||||
slli r9, r9, 1
|
||||
andi r15, r12, 1
|
||||
|
||||
/*
|
||||
* if (lsb == 1)
|
||||
* {
|
||||
* mulxuu_product += multiplicand;
|
||||
* }
|
||||
*/
|
||||
beq r15, zero, .Lmulx_skip
|
||||
add r10, r10, r3
|
||||
cmpltu r15, r10, r3 /* Save the carry from the MSB of mulxuu_product. */
|
||||
ror r15, r15, r16 /* r15 = 0x80000000 on carry, or else 0x00000000 */
|
||||
.Lmulx_skip:
|
||||
|
||||
/*
|
||||
* if (MSB of mul_multiplier == 1)
|
||||
* {
|
||||
* mul_product += multiplicand;
|
||||
* }
|
||||
*/
|
||||
bge r6, zero, .Lmul_skip
|
||||
add r9, r9, r3
|
||||
.Lmul_skip:
|
||||
|
||||
/*
|
||||
* mulxuu_product >>= 1; logical shift
|
||||
* mul_multiplier <<= 1; done with MSB
|
||||
* mulx_multiplier >>= 1; done with LSB
|
||||
*/
|
||||
srli r10, r10, 1
|
||||
or r10, r10, r15 /* OR in the saved carry bit. */
|
||||
slli r6, r6, 1
|
||||
srli r12, r12, 1
|
||||
|
||||
|
||||
/*
|
||||
* }
|
||||
*/
|
||||
subi r14, r14, 1
|
||||
bne r14, zero, .Lmultiply_loop
|
||||
|
||||
|
||||
/*
|
||||
* Multiply emulation loop done.
|
||||
*/
|
||||
|
||||
/* Now
|
||||
* r3 = multiplicand
|
||||
* r4 = OPX
|
||||
* r7 = 4 * dest_register (used later as offset to sp)
|
||||
* r9 = mul_product
|
||||
* r10 = mulxuu_product
|
||||
* r11 = original multiplier
|
||||
* r15 = temp
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Select/compute the result based on OPX.
|
||||
*/
|
||||
|
||||
|
||||
/* OPX == mul? Then store. */
|
||||
xori r15, r4, 0x27
|
||||
beq r15, zero, .Lstore_result
|
||||
|
||||
/* It's one of the mulx.. opcodes. Move over the result. */
|
||||
mov r9, r10
|
||||
|
||||
/* OPX == mulxuu? Then store. */
|
||||
xori r15, r4, 0x07
|
||||
beq r15, zero, .Lstore_result
|
||||
|
||||
/* Compute mulxsu
|
||||
*
|
||||
* mulxsu = mulxuu - ((rA < 0) ? rB : 0);
|
||||
*/
|
||||
bge r3, zero, .Lmulxsu_skip
|
||||
sub r9, r9, r11
|
||||
.Lmulxsu_skip:
|
||||
|
||||
/* OPX == mulxsu? Then store. */
|
||||
xori r15, r4, 0x17
|
||||
beq r15, zero, .Lstore_result
|
||||
|
||||
/* Compute mulxss
|
||||
*
|
||||
* mulxss = mulxsu - ((rB < 0) ? rA : 0);
|
||||
*/
|
||||
bge r11, zero, .Lmulxss_skip
|
||||
sub r9, r9, r3
|
||||
.Lmulxss_skip:
|
||||
/* At this point, assume that OPX is mulxss, so store */
|
||||
|
||||
|
||||
.Lstore_result:
|
||||
add r7, r7, sp
|
||||
stw r9, 0(r7)
|
||||
|
||||
ldw r16, 0(sp)
|
||||
ldw r17, 4(sp)
|
||||
ldw r18, 8(sp)
|
||||
ldw r19, 12(sp)
|
||||
ldw r20, 16(sp)
|
||||
ldw r21, 20(sp)
|
||||
ldw r22, 24(sp)
|
||||
ldw r23, 28(sp)
|
||||
|
||||
/* bt @ 32 - Breakpoint register usually isn't an operand. */
|
||||
/* et @ 36 - Don't corrupt et. */
|
||||
/* gp @ 40 - Don't corrupt gp. */
|
||||
/* sp @ 44 - Don't corrupt sp. */
|
||||
ldw fp, 48(sp)
|
||||
/* ea @ 52 - Don't corrupt ea. */
|
||||
/* ba @ 56 - Breakpoint register usually isn't an operand. */
|
||||
|
||||
addi sp, sp, 60
|
||||
|
||||
br .Lexception_exit
|
||||
|
||||
|
||||
.Lnot_muldiv:
|
||||
|
||||
addi sp, sp, 60
|
||||
|
||||
|
||||
.section .exceptions.exit.label
|
||||
.Lexception_exit:
|
||||
|
@ -1,95 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2003-2005 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This is the trap exception handler for Nios2.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Provide a label which can be used to pull this file in.
|
||||
*/
|
||||
|
||||
.section .exceptions.start
|
||||
.globl alt_exception_trap
|
||||
alt_exception_trap:
|
||||
|
||||
/*
|
||||
* Pull in the entry/exit code.
|
||||
*/
|
||||
.globl alt_exception
|
||||
|
||||
.section .exceptions.soft, "xa"
|
||||
|
||||
.Ltrap_handler:
|
||||
|
||||
/*
|
||||
* Did a trap instruction cause the exception?
|
||||
*
|
||||
* The instruction which the exception occurred on has been loaded
|
||||
* into r2 by code in alt_exception_entry.S
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ALT_CPU_CPU_ARCH_NIOS2_R2
|
||||
movhi r3,0xb41d /* upper half of trap opcode */
|
||||
ori r3,r3,0x0020 /* lower half of trap opcode */
|
||||
beq r2,r3,.Lis_trap
|
||||
#ifdef NIOS2_CDX_PRESENT
|
||||
mov r3,r2
|
||||
andhi r3,r3,0xffff
|
||||
ori r3,r3,0xd009 /* trap.n opcode */
|
||||
beq r2,r3,.Lis_trap
|
||||
#endif
|
||||
br .Lnot_trap
|
||||
#else
|
||||
movhi r3,0x003b /* upper half of trap opcode */
|
||||
ori r3,r3,0x683a /* lower half of trap opcode */
|
||||
bne r2,r3,.Lnot_trap
|
||||
#endif
|
||||
|
||||
.Lis_trap:
|
||||
/*
|
||||
* There is no trap handler defined here, and so executing a trap
|
||||
* instruction causes a software break. If you provide a trap handler,
|
||||
* then you must replace the break instruction below with your handler.
|
||||
* Your handler must preserve ea and the usual callee saved registers.
|
||||
*/
|
||||
|
||||
break
|
||||
|
||||
br .Lexception_exit
|
||||
|
||||
.Lnot_trap:
|
||||
|
||||
|
||||
.section .exceptions.exit.label
|
||||
.Lexception_exit:
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_errno.h"
|
||||
#include "sys/alt_warning.h"
|
||||
#include "os/alt_syscall.h"
|
||||
|
||||
/*
|
||||
* execve() is used by newlib to launch new processes. This is unsupported in
|
||||
* the HAL environment. However a "do-nothing" implementation is still
|
||||
* provied for newlib compatability.
|
||||
*
|
||||
* ALT_EXECVE is mapped onto the execve() system call in alt_syscall.h
|
||||
*/
|
||||
|
||||
int ALT_EXECVE (char *name, char ** argv, char** env)
|
||||
{
|
||||
/* Generate a link time warning, should this function ever be called. */
|
||||
|
||||
ALT_STUB_WARNING(execve);
|
||||
|
||||
/* Indicate an error */
|
||||
|
||||
ALT_ERRNO = ENOSYS;
|
||||
return -1;
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "sys/alt_irq.h"
|
||||
#include "sys/alt_sim.h"
|
||||
#include "os/alt_hooks.h"
|
||||
#include "os/alt_syscall.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
#include "sys/alt_log_printf.h"
|
||||
/*
|
||||
* _exit() is called by exit() in order to terminate the current process.
|
||||
* Typically this is called when main() completes. It should never return.
|
||||
* Since there is nowhere to go once this process completes, this
|
||||
* implementation simply blocks forever.
|
||||
*
|
||||
* Note that interrupts are not disabled so that execution outside of this
|
||||
* thread is allowed to continue.
|
||||
*
|
||||
* ALT_EXIT is mapped onto the _exit() system call in alt_syscall.h
|
||||
*/
|
||||
|
||||
void ALT_EXIT (int exit_code)
|
||||
{
|
||||
/* ALT_LOG - please see HAL/inc/alt_log_printf.h for details */
|
||||
ALT_LOG_PRINT_BOOT("[alt_exit.c] Entering _exit() function.\r\n");
|
||||
ALT_LOG_PRINT_BOOT("[alt_exit.c] Exit code from main was %d.\r\n",exit_code);
|
||||
/* Stop all other threads */
|
||||
|
||||
ALT_LOG_PRINT_BOOT("[alt_exit.c] Calling ALT_OS_STOP().\r\n");
|
||||
ALT_OS_STOP();
|
||||
|
||||
/* Provide notification to the simulator that we've stopped */
|
||||
|
||||
ALT_LOG_PRINT_BOOT("[alt_exit.c] Calling ALT_SIM_HALT().\r\n");
|
||||
ALT_SIM_HALT(exit_code);
|
||||
|
||||
/* spin forever, since there's no where to go back to */
|
||||
|
||||
ALT_LOG_PRINT_BOOT("[alt_exit.c] Spinning forever.\r\n");
|
||||
while (1);
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "sys/alt_errno.h"
|
||||
#include "priv/alt_file.h"
|
||||
#include "alt_types.h"
|
||||
#include "os/alt_syscall.h"
|
||||
|
||||
#define ALT_FCNTL_FLAGS_MASK ((alt_u32) (O_APPEND | O_NONBLOCK))
|
||||
|
||||
/*
|
||||
* fcntl() is a limited implementation of the standard fcntl() system call.
|
||||
* It can be used to change the state of the flags associated with an open
|
||||
* file descriptor. Normally these flags are set during the call to
|
||||
* open(). It is anticipated that the main use of this function will be to
|
||||
* change the state of a device from blocking to non-blocking (where this is
|
||||
* supported).
|
||||
*
|
||||
* The input argument "fd" is the file descriptor to be manipulated. "cmd"
|
||||
* is the command to execute. This can be either F_GETFL (return the
|
||||
* current value of the flags) or F_SETFL (set the value of the flags).
|
||||
*
|
||||
* If "cmd" is F_SETFL then the argument "arg" is the new value of flags,
|
||||
* otherwise "arg" is ignored. Only the flags: O_APPEND and O_NONBLOCK
|
||||
* can be updated by a call to fcntl(). All other flags remain
|
||||
* unchanged.
|
||||
*
|
||||
* ALT_FCNTL is mapped onto the fcntl() system call in alt_syscall.h
|
||||
*/
|
||||
|
||||
int ALT_FCNTL (int file, int cmd, ...)
|
||||
{
|
||||
alt_fd* fd;
|
||||
long flags;
|
||||
va_list argp;
|
||||
|
||||
/*
|
||||
* A common error case is that when the file descriptor was created, the call
|
||||
* to open() failed resulting in a negative file descriptor. This is trapped
|
||||
* below so that we don't try and process an invalid file descriptor.
|
||||
*/
|
||||
|
||||
fd = (file < 0) ? NULL : &alt_fd_list[file];
|
||||
|
||||
if (fd)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case F_GETFL:
|
||||
return fd->fd_flags & ~((alt_u32) ALT_FD_FLAGS_MASK);
|
||||
case F_SETFL:
|
||||
va_start(argp, cmd);
|
||||
flags = va_arg(argp, long);
|
||||
fd->fd_flags &= ~ALT_FCNTL_FLAGS_MASK;
|
||||
fd->fd_flags |= (flags & ALT_FCNTL_FLAGS_MASK);
|
||||
va_end(argp);
|
||||
return 0;
|
||||
default:
|
||||
ALT_ERRNO = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ALT_ERRNO = EBADFD;
|
||||
return -1;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "priv/alt_file.h"
|
||||
|
||||
/*
|
||||
* alt_fd_lock() is called as a consequence of an ioctl call to gain exclusive
|
||||
* access to a device, i.e.:
|
||||
*
|
||||
* ioctl (fd, TIOCEXCL, NULL);
|
||||
*
|
||||
* If there are no other open file descriptors which reference the same
|
||||
* device, then alt_fd_lock() will grant the lock. Further calls to open()
|
||||
* for this device will fail until the lock is released.
|
||||
*
|
||||
* This is done by calling close() for this file descriptor, or by calling:
|
||||
*
|
||||
* ioctl (fd, TIOCNXCL, NULL);
|
||||
*
|
||||
* The return value is zero for success, or negative in the case of failure.
|
||||
*/
|
||||
|
||||
int alt_fd_lock (alt_fd* fd)
|
||||
{
|
||||
int i;
|
||||
int rc = 0;
|
||||
|
||||
ALT_SEM_PEND(alt_fd_list_lock, 0);
|
||||
|
||||
for (i = 0; i < alt_max_fd; i++)
|
||||
{
|
||||
if ((&alt_fd_list[i] != fd) && (alt_fd_list[i].dev == fd->dev))
|
||||
{
|
||||
rc = -EACCES;
|
||||
goto alt_fd_lock_exit;
|
||||
}
|
||||
}
|
||||
fd->fd_flags |= ALT_FD_EXCL;
|
||||
|
||||
alt_fd_lock_exit:
|
||||
|
||||
ALT_SEM_POST(alt_fd_list_lock);
|
||||
return rc;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "priv/alt_file.h"
|
||||
|
||||
/*
|
||||
* alt_fd_unlock() is the inverse of alt_fd_lock(). It is called as a
|
||||
* consequence of a TIOCNXCL ioctl request, e.g:
|
||||
*
|
||||
* ioctl (fd, TIOCNXCL, NULL);
|
||||
*
|
||||
* It enables multiple file descriptors to exist for the same device. This
|
||||
* is normally the case, but it may have been disabled by a previous call to
|
||||
* alt_fd_lock().
|
||||
*
|
||||
* Return zero on sucess, and a negative value on failure.
|
||||
*
|
||||
* The current implementation always succeeds.
|
||||
*/
|
||||
|
||||
int alt_fd_unlock (alt_fd* fd)
|
||||
{
|
||||
fd->fd_flags &= ~ALT_FD_EXCL;
|
||||
return 0;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a *
|
||||
* copy of this software and associated documentation files (the "Software"), *
|
||||
* to deal in the Software without restriction, including without limitation *
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
||||
* and/or sell copies of the Software, and to permit persons to whom the *
|
||||
* Software is furnished to do so, subject to the following conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in *
|
||||
* all copies or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
||||
* DEALINGS IN THE SOFTWARE. *
|
||||
* *
|
||||
* This agreement shall be governed in all respects by the laws of the State *
|
||||
* of California and by the laws of the United States of America. *
|
||||
* *
|
||||
* Altera does not recommend, suggest or require that this reference design *
|
||||
* file be used in conjunction or combination with any other product. *
|
||||
******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sys/alt_dev.h"
|
||||
#include "priv/alt_file.h"
|
||||
|
||||
#include "alt_types.h"
|
||||
|
||||
/*
|
||||
* alt_find_dev() is used by open() in order to locate a previously registered
|
||||
* device with the name "name". The input argument "llist" is a pointer to the
|
||||
* head of the device list to search.
|
||||
*
|
||||
* The return value is a pointer to the matching device, or NULL if there is
|
||||
* no match.
|
||||
*
|
||||
* "name" must be an exact match for the devices registered name for a match to
|
||||
* be found.
|
||||
*/
|
||||
|
||||
alt_dev* alt_find_dev(const char* name, alt_llist* llist)
|
||||
{
|
||||
alt_dev* next = (alt_dev*) llist->next;
|
||||
alt_32 len;
|
||||
|
||||
len = strlen(name) + 1;
|
||||
|
||||
/*
|
||||
* Check each list entry in turn, until a match is found, or we reach the
|
||||
* end of the list (i.e. next winds up pointing back to the list head).
|
||||
*/
|
||||
|
||||
while (next != (alt_dev*) llist)
|
||||
{
|
||||
|
||||
/*
|
||||
* memcmp() is used here rather than strcmp() in order to reduce the size
|
||||
* of the executable.
|
||||
*/
|
||||
|
||||
if (!memcmp (next->name, name, len))
|
||||
{
|
||||
/* match found */
|
||||
|
||||
return next;
|
||||
}
|
||||
next = (alt_dev*) next->llist.next;
|
||||
}
|
||||
|
||||
/* No match found */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user