Lösung ADD und FFT
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
#ifndef __ALT_ALARM_H__
|
||||
#define __ALT_ALARM_H__
|
||||
|
||||
/******************************************************************************
|
||||
* *
|
||||
* License Agreement *
|
||||
* *
|
||||
* Copyright (c) 2017,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_u64 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__ */
|
||||
@@ -0,0 +1,117 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,45 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,115 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,226 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,200 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,168 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,87 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,166 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,181 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,100 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,64 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,245 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,39 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* 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" );
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#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__ */
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,78 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
/* 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__ */
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,91 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,126 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* 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__ */
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,62 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,100 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,60 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,75 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,90 @@
|
||||
#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__ */
|
||||
@@ -0,0 +1,181 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
* 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 */
|
||||
|
||||
Reference in New Issue
Block a user