800*320工程文件+初始demo提交

This commit is contained in:
2024-03-07 16:46:43 +08:00
parent 33e6eb45b3
commit 70ec3005bb
3306 changed files with 3374364 additions and 2563 deletions

View File

@ -0,0 +1,49 @@
/* --------------------------------------------------------------------
**
** Synopsys DesignWare AMBA Software Driver Kit and
** documentation (hereinafter, "Software") is an Unsupported
** proprietary work of Synopsys, Inc. unless otherwise expressly
** agreed to in writing between Synopsys and you.
**
** The Software IS NOT an item of Licensed Software or Licensed
** Product under any End User Software License Agreement or Agreement
** for Licensed Product with Synopsys or any supplement thereto. You
** are permitted to use and redistribute this Software in source and
** binary forms, with or without modification, provided that
** redistributions of source code must retain this notice. You may not
** view, use, disclose, copy or distribute this file or any information
** contained herein except pursuant to this license grant from Synopsys.
** If you do not agree with this notice, including the disclaimer
** below, then you are not authorized to use the Software.
**
** THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
** BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL
** SYNOPSYS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
** OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
** DAMAGE.
**
** --------------------------------------------------------------------
*/
#ifndef FR_COMMON_H
#define FR_COMMON_H
#include <stdarg.h> // variable-length argument support
#include <stddef.h> // standard definitions
#include <inttypes.h> // defined-width data types
#include "drv_common_list.h" // linked list macros
#include "drv_common_types.h" // custom data type definitions
#include "drv_common_io.h" // low-level I/O
#include "drv_common_bitops.h" // bit-manipulation macros
#include "drv_common_errno.h" // error codes
#include "drv_common_dbc.h" // assertion macros
#endif // FR_COMMON_H

View File

@ -0,0 +1,212 @@
/* --------------------------------------------------------------------
**
** Synopsys DesignWare AMBA Software Driver Kit and
** documentation (hereinafter, "Software") is an Unsupported
** proprietary work of Synopsys, Inc. unless otherwise expressly
** agreed to in writing between Synopsys and you.
**
** The Software IS NOT an item of Licensed Software or Licensed
** Product under any End User Software License Agreement or Agreement
** for Licensed Product with Synopsys or any supplement thereto. You
** are permitted to use and redistribute this Software in source and
** binary forms, with or without modification, provided that
** redistributions of source code must retain this notice. You may not
** view, use, disclose, copy or distribute this file or any information
** contained herein except pursuant to this license grant from Synopsys.
** If you do not agree with this notice, including the disclaimer
** below, then you are not authorized to use the Software.
**
** THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
** BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL
** SYNOPSYS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
** OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
** DAMAGE.
**
** --------------------------------------------------------------------
*/
#ifndef FR_COMMON_BITOPS_H
#define FR_COMMON_BITOPS_H
#ifdef __cplusplus
extern "C" { // allow C++ to use these headers
#endif
/****h* include.bitops
* NAME
* FR_common_bitops.h -- bit manipulation macros
* DESCRIPTION
* This set of macros accesses data using a width/shift parameter.
* This assumes that constants bfoXXX and bfwXXX are defined,
* where XXX is the value specified in the parameter.
* + bfoXXX is the offset of the lowest bit.
* + bfwXXX is the number of bits to be accessed.
***/
/****d* include.bitops/FR_BITS
* DESCRIPTION
* Constant definitions for various bits of a 32-bit word.
* SOURCE
*/
#define FR_BIT0 0x00000001
#define FR_BIT1 0x00000002
#define FR_BIT2 0x00000004
#define FR_BIT3 0x00000008
#define FR_BIT4 0x00000010
#define FR_BIT5 0x00000020
#define FR_BIT6 0x00000040
#define FR_BIT7 0x00000080
#define FR_BIT8 0x00000100
#define FR_BIT9 0x00000200
#define FR_BIT10 0x00000400
#define FR_BIT11 0x00000800
#define FR_BIT12 0x00001000
#define FR_BIT13 0x00002000
#define FR_BIT14 0x00004000
#define FR_BIT15 0x00008000
#define FR_BIT16 0x00010000
#define FR_BIT17 0x00020000
#define FR_BIT18 0x00040000
#define FR_BIT19 0x00080000
#define FR_BIT20 0x00100000
#define FR_BIT21 0x00200000
#define FR_BIT22 0x00400000
#define FR_BIT23 0x00800000
#define FR_BIT24 0x01000000
#define FR_BIT25 0x02000000
#define FR_BIT26 0x04000000
#define FR_BIT27 0x08000000
#define FR_BIT28 0x10000000
#define FR_BIT29 0x20000000
#define FR_BIT30 0x40000000
#define FR_BIT31 0x80000000
#define FR_BITS_ALL 0xFFFFFFFF
/*****/
/****d* include.bitops/FR_BIT_WIDTH
* DESCRIPTION
* Returns the width of the specified bit-field.
* ARGUMENTS
* __bfws a width/shift pair
* SOURCE
*/
#define FR_BIT_WIDTH(__bfws) ((uint32_t) (bfw ## __bfws))
/*****/
/****d* include.bitops/FR_BIT_OFFSET
* DESCRIPTION
* Returns the offset of the specified bit-field.
* ARGUMENTS
* __bfws a width/shift pair
* SOURCE
*/
#define FR_BIT_OFFSET(__bfws) ((uint32_t) (bfo ## __bfws))
/*****/
/****d* include.bitops/FR_BIT_MASK
* DESCRIPTION
* Returns a mask with the bits to be addressed set and all others
* cleared.
* ARGUMENTS
* __bfws a width/shift pair
* SOURCE
*/
#define FR_BIT_MASK(__bfws) ((uint32_t) (((bfw ## __bfws) == 32) ? \
0xFFFFFFFF : ((1U << (bfw ## __bfws)) - 1)) << (bfo ## __bfws))
/*****/
/****d* include.bitops/FR_BIT_CLEAR
* DESCRIPTION
* Clear the specified bits.
* ARGUMENTS
* __datum the word of data to be modified
* __bfws a width/shift pair
* SOURCE
*/
#define FR_BIT_CLEAR(__datum, __bfws) \
((__datum) = ((uint32_t) (__datum) & ~FR_BIT_MASK(__bfws)))
/*****/
/****d* include.bitops/FR_BIT_GET_UNSHIFTED
* DESCRIPTION
* Returns the relevant bits masked from the data word, still at their
* original offset.
* ARGUMENTS
* __datum the word of data to be accessed
* __bfws a width/shift pair
* SOURCE
*/
#define FR_BIT_GET_UNSHIFTED(__datum, __bfws) \
((uint32_t) ((__datum) & FR_BIT_MASK(__bfws)))
/*****/
/****d* include.bitops/FR_BIT_GET
* DESCRIPTION
* Returns the relevant bits masked from the data word shifted to bit
* zero (i.e. access the specifed bits from a word of data as an
* integer value).
* ARGUMENTS
* __datum the word of data to be accessed
* __bfws a width/shift pair
* SOURCE
*/
#define FR_BIT_GET(__datum, __bfws) \
((uint32_t) (((__datum) & FR_BIT_MASK(__bfws)) >> \
(bfo ## __bfws)))
/*****/
/****d* include.bitops/FR_BIT_SET
* DESCRIPTION
* Place the specified value into the specified bits of a word of data
* (first the data is read, and the non-specified bits are re-written).
* ARGUMENTS
* __datum the word of data to be accessed
* __bfws a width/shift pair
* __val the data value to be shifted into the specified bits
* SOURCE
*/
#define FR_BIT_SET(__datum, __bfws, __val) \
((__datum) = ((uint32_t) (__datum) & ~FR_BIT_MASK(__bfws)) | \
((__val << (bfo ## __bfws)) & FR_BIT_MASK(__bfws)))
/*****/
/****d* include.bitops/FR_BIT_SET_NOREAD
* DESCRIPTION
* Place the specified value into the specified bits of a word of data
* without reading first - for sensitive interrupt type registers
* ARGUMENTS
* __datum the word of data to be accessed
* __bfws a width/shift pair
* __val the data value to be shifted into the specified bits
* SOURCE
*/
#define FR_BIT_SET_NOREAD(__datum, __bfws, __val) \
((uint32_t) ((__datum) = (((__val) << (bfo ## __bfws)) & \
FR_BIT_MASK(__bfws))))
/*****/
/****d* include.bitops/FR_BIT_BUILD
* DESCRIPTION
* Shift the specified value into the desired bits.
* ARGUMENTS
* __bfws a width/shift pair
* __val the data value to be shifted into the specified bits
* SOURCE
*/
#define FR_BIT_BUILD(__bfws, __val) \
((uint32_t) (((__val) << (bfo ## __bfws)) & FR_BIT_MASK(__bfws)))
/*****/
#ifdef __cplusplus
}
#endif
#endif // FR_COMMON_BITOPS_H

View File

@ -0,0 +1,47 @@
#ifndef FR_COMMON_DBC_H
#define FR_COMMON_DBC_H
#ifdef __cplusplus
extern "C" { // allow C++ to use these headers
#endif
// FR_NASSERT macro disables all contract validations
// (assertions, preconditions, postconditions, and invariants).
#ifndef FR_NASSERT
// callback invoked in case of assertion failure
extern void onAssert__(char const *file, unsigned line);
#define FR_DEFINE_THIS_FILE static const char THIS_FILE__[] = __FILE__
#define FR_ASSERT(test_) \
if (test_) { \
} \
else onAssert__(THIS_FILE__, __LINE__)
#define FR_REQUIRE(test_) FR_ASSERT(test_)
#define FR_ENSURE(test_) FR_ASSERT(test_)
#define FR_INVARIANT(test_) FR_ASSERT(test_)
#define FR_ALLEGE(test_) FR_ASSERT(test_)
#else // FR_NASSERT
#define FR_DEFINE_THIS_FILE extern const char THIS_FILE__[]
#define FR_ASSERT(test_)
#define FR_REQUIRE(test_)
#define FR_ENSURE(test_)
#define FR_INVARIANT(test_)
#define FR_ALLEGE(test_) \
if(test_) { \
} \
else
#endif // FR_NASSERT
#ifdef __cplusplus
}
#endif
#endif // FR_COMMON_DBC_H

View File

@ -0,0 +1,21 @@
#ifndef FR_COMMON_ERRNO_H
#define FR_COMMON_ERRNO_H
#define FR_EPERM 1 // operation not permitted
#define FR_EIO 5 // I/O error
#define FR_ENXIO 6 // no such device or address
#define FR_ENOMEM 12 // out of memory
#define FR_EACCES 13 // permission denied
#define FR_EBUSY 16 // device or resource busy
#define FR_ENODEV 19 // no such device
#define FR_EINVAL 22 // invalid argument
#define FR_ENOSPC 28 // no space left on device
#define FR_ENOSYS 38 // function not implemented/supported
#define FR_ECHRNG 44 // channel number out of range
#define FR_ENODATA 61 // no data available
#define FR_ETIME 62 // timer expired
#define FR_EPROTO 71 // protocol error
#endif // FR_COMMON_ERRNO_H

View File

@ -0,0 +1,183 @@
/* --------------------------------------------------------------------
**
** Synopsys DesignWare AMBA Software Driver Kit and
** documentation (hereinafter, "Software") is an Unsupported
** proprietary work of Synopsys, Inc. unless otherwise expressly
** agreed to in writing between Synopsys and you.
**
** The Software IS NOT an item of Licensed Software or Licensed
** Product under any End User Software License Agreement or Agreement
** for Licensed Product with Synopsys or any supplement thereto. You
** are permitted to use and redistribute this Software in source and
** binary forms, with or without modification, provided that
** redistributions of source code must retain this notice. You may not
** view, use, disclose, copy or distribute this file or any information
** contained herein except pursuant to this license grant from Synopsys.
** If you do not agree with this notice, including the disclaimer
** below, then you are not authorized to use the Software.
**
** THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
** BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL
** SYNOPSYS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
** OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
** DAMAGE.
**
** --------------------------------------------------------------------
*/
#ifndef FR_COMMON_IO_H
#define FR_COMMON_IO_H
#ifdef __cplusplus
extern "C" { // allow C++ to use these headers
#endif
// The following macros all perform 32-bit reads/writes for varying data
// bus widths. For example, FR_OUT32_8 writes a 32-bit word in 8-bit
// chunks.
#define FR_OUT32_32P(v,p) FR_OUT32_32(v, &(p))
#define FR_OUT32_16P(v,p) FR_OUT32_16(v, &(p))
#define FR_OUT32_8P(v,p) FR_OUT32_8(v, &(p))
#define FR_IN32_32P(p) FR_IN32_32(&(p))
#define FR_IN32_16P(p) FR_IN32_16(&(p))
#define FR_IN32_8P(p) FR_IN32_8(&(p))
// The following macros perform 8-, 16- and 32-bit read/writes for
// various data bus widths. These macros rely on a 'dev' structure of
// type dw_device, which has a 'data_width' member to determine the data
// bus width.
#define FR_OUT32P(v,p) FR_OUT32(v, &(p))
#define FR_OUT16P(v,p) FR_OUT16(v, &(p))
#define FR_OUT8P(v,p) FR_OUT8(v, &(p))
#define FR_IN32P(p) FR_IN32(&(p))
#define FR_IN16P(p) FR_IN16(&(p))
#define FR_IN8P(p) FR_IN8(&(p))
// The following macros perform 32-bit read/writes. These macros rely
// on a 'dev' structure of type dw_device, which has a 'data_width'
// member to determine the data bus width. They always read/write a
// 32-bit word, taking the data bus width into account.
#define FR_OUTP(v,p) FR_OUT(v, &(##p))
#define FR_INP(p) FR_IN(&(p))
// The default behaviour is to check individual devices' bus data
// widths. This assumes the presence of a 'dev' structure of type
// dw_device which has a 'data_width' member. If this member contains
// an illegal value, reads/writes default to 8-bit accesses.
//
// If all device data bus widths are the same (i.e. a single APB bus),
// and APB_DATA_WIDTH is defined, we can define all the IN/OUT macros
// for the correct data width.
// 32-bit data bus. All macros can be defined to use their respective
// data read/write widths.
#define FR_OUT(v,p) FR_OUT32_32(v,p)
#define FR_IN(p) FR_IN32_32(p)
#define FR_OUT32(v,p) FR_OUT32_32(v,p)
#define FR_OUT16(v,p) FR_OUT16_16(v,p)
#define FR_OUT8(v,p) FR_OUT8_8(v,p)
#define FR_IN32(p) FR_IN32_32(p)
#define FR_IN16(p) FR_IN16_16(p)
#define FR_IN8(p) FR_IN8_8(p)
// The default endianness is little endian.
// the following macro performs a 32-bit write
#define FR_OUT32_32(v,p) \
do { \
*((volatile uint32_t *) (p)) = (v); \
} while(0)
// the following macro performs two 16-bit writes
#define FR_OUT32_16(v,p) \
do { \
volatile uint16_t *ptr16; \
uint16_t v16; \
ptr16 = (uint16_t *) (p); \
v16 = (uint16_t) ((v) & 0x0000ffff); \
*ptr16 = v16; \
v16 = (uint16_t) (((v) & 0xffff0000) >> 16);\
*(ptr16 + 1) = v16; \
} while (0)
// the following macro performs two 8-bit writes
#define FR_OUT32_8(v,p) \
do { \
volatile uint8_t *ptr8; \
uint8_t v8; \
ptr8 = (uint8_t *) (p); \
v8 = (uint8_t) ((v) & 0x000000ff); \
*ptr8 = v8; \
v8 = (uint8_t) (((v) & 0x0000ff00) >> 8); \
*(ptr8 + 1) = v8; \
v8 = (uint8_t) (((v) & 0x00ff0000) >> 16); \
*(ptr8 + 2) = v8; \
v8 = (uint8_t) (((v) & 0xff000000) >> 24); \
*(ptr8 + 3) = v8; \
} while(0)
// the following macro performs 16-bit writes
#define FR_OUT16_16(v,p) \
do { \
*((volatile uint16_t *) (p)) = (uint16_t) (v); \
} while(0)
// the following macro performs two 8-bit writes
#define FR_OUT16_8(v,p) \
do { \
volatile uint8_t *ptr8; \
uint16_t v8; \
ptr8 = (uint8_t *) (p); \
v8 = (uint8_t) ((v) & 0x00ff); \
*ptr8 = v8; \
v8 = (uint8_t) (((v) & 0xff00) >> 8); \
*(ptr8 + 1) = v8; \
} while(0)
// the following macro performs an 8-bit write
#define FR_OUT8_8(v,p) \
do { \
*((volatile uint8_t *) (p)) = (uint8_t) (v); \
} while(0)
// the following macro performs a 32-bit reads
#define FR_IN32_32(p) *((uint32_t *) (p))
// the following macro performs two 16-bit reads
#define FR_IN32_16(p) ((uint32_t) *((uint16_t *) (p)) \
| (*((uint16_t *) (p) + 1) << 16))
// the following macro performs 8-bit reads
#define FR_IN32_8(p) ((uint32_t) (*((uint8_t *) (p))) \
| (*((uint8_t *) (p) + 1) << 8) \
| (*((uint8_t *) (p) + 2) << 16) \
| (*((uint8_t *) (p) + 3) << 24))
// the following macro performs a 16-bit read
#define FR_IN16_16(p) ((uint16_t) *((volatile uint16_t *) (p)))
// the following macro performs two 8-bit reads
#define FR_IN16_8(p) ((uint16_t) (*((volatile uint8_t *) (p)) \
| (*((volatile uint8_t *) (p) + 1) << 8)))
// the following macro performs an 8-bit read
#define FR_IN8_8(p) ((uint8_t) *((volatile uint8_t *) (p)))
#ifdef __cplusplus
}
#endif
#endif // FR_COMMON_IO_H

View File

@ -0,0 +1,274 @@
/* --------------------------------------------------------------------
**
** Synopsys DesignWare AMBA Software Driver Kit and
** documentation (hereinafter, "Software") is an Unsupported
** proprietary work of Synopsys, Inc. unless otherwise expressly
** agreed to in writing between Synopsys and you.
**
** The Software IS NOT an item of Licensed Software or Licensed
** Product under any End User Software License Agreement or Agreement
** for Licensed Product with Synopsys or any supplement thereto. You
** are permitted to use and redistribute this Software in source and
** binary forms, with or without modification, provided that
** redistributions of source code must retain this notice. You may not
** view, use, disclose, copy or distribute this file or any information
** contained herein except pursuant to this license grant from Synopsys.
** If you do not agree with this notice, including the disclaimer
** below, then you are not authorized to use the Software.
**
** THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
** BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL
** SYNOPSYS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
** OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
** DAMAGE.
**
** --------------------------------------------------------------------
*/
#ifndef DRV_COMMON_LIST_H
#define DRV_COMMON_LIST_H
#ifdef __cplusplus
extern "C" { // allow C++ to use these headers
#endif
// INLINE definition for the ARM C compiler
#define INLINE __inline
/****h* include.list
* NAME
* fr_list.h -- simple double linked list implementation
* DESCRIPTION
* Some of the internal functions ("__fr_xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
***/
/****is* include.fr_list_head
* DESCRIPTION
* This is the structure used for managing linked lists.
* SOURCE
*/
struct fr_list_head {
struct fr_list_head *next, *prev;
};
/*****/
#define FR_LIST_HEAD_INIT(name) { &(name), &(name) }
#define FR_LIST_HEAD(name) \
struct fr_list_head name = FR_LIST_HEAD_INIT(name)
#define FR_INIT_LIST_HEAD(ptr) \
do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/****if* include.list/__fr_list_add
* DESCRIPTION
* Insert a new entry between two known consecutive entries.
* This is only for internal list manipulation where we know
* the prev/next entries already!
* ARGUMENTS
* new element to insert
* prev previous entry
* next next entry
* SOURCE
*/
static INLINE void __fr_list_add(struct fr_list_head * new, struct
fr_list_head *prev, struct fr_list_head * next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
/*****/
/****f* include.list/fr_list_add
* DESCRIPTION
* Insert a new entry after the specified head.
* This is good for implementing stacks.
* ARGUMENTS
* new new entry to be added
* head list head to add it after
* SOURCE
*/
static INLINE void fr_list_add(struct fr_list_head *new, struct
fr_list_head *head)
{
__fr_list_add(new, head, head->next);
}
/*****/
/****f* include.list/fr_list_add_tail
* DESCRIPTION
* Insert a new entry before the specified head.
* This is useful for implementing queues.
* ARGUMENTS
* new new entry to be added
* head list head to add it before
* SOURCE
*/
static INLINE void fr_list_add_tail(struct fr_list_head *new, struct
fr_list_head *head)
{
__fr_list_add(new, head->prev, head);
}
/*****/
/****if* include.list/__fr_list_del
* DESCRIPTION
* Delete a list entry by making the prev/next entries point to each
* other. This is only for internal list manipulation where we know
* the prev/next entries already!
* ARGUMENTS
* prev previous entry
* next next entry
* SOURCE
*/
static INLINE void __fr_list_del(struct fr_list_head * prev, struct
fr_list_head * next)
{
next->prev = prev;
prev->next = next;
}
/*****/
/****f* include.list/fr_list_del
* DESCRIPTION
* Deletes entry from list.
* ARGUMENTS
* entry the element to delete from the list
* NOTES
* list_empty on entry does not return true after this, the entry
* is in an undefined state.
* SOURCE
*/
static INLINE void fr_list_del(struct fr_list_head *entry)
{
__fr_list_del(entry->prev, entry->next);
}
/*****/
/****f* include.list/fr_list_del_init
* DESCRIPTION
* Deletes entry from list and reinitializes it.
* ARGUMENTS
* entry the element to delete from the list
* SOURCE
*/
static INLINE void fr_list_del_init(struct fr_list_head *entry)
{
__fr_list_del(entry->prev, entry->next);
FR_INIT_LIST_HEAD(entry);
}
/*****/
/****f* include.list/fr_list_empty
* DESCRIPTION
* Tests whether a list is empty.
* ARGUMENTS
* head the list to test
* SOURCE
*/
static INLINE int fr_list_empty(struct fr_list_head *head)
{
return head->next == head;
}
/*****/
/****f* include.list/fr_list_splice
* DESCRIPTION
* Join two lists.
* ARGUMENTS
* list the new list to add
* head the place to add it in the first list
* SOURCE
*/
static INLINE void fr_list_splice(struct fr_list_head *list, struct
fr_list_head *head)
{
struct fr_list_head *first = list->next;
if (first != list) {
struct fr_list_head *last = list->prev;
struct fr_list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
}
/*****/
/****d* include.list/fr_list_entry
* DESCRIPTION
* Get the struct for this entry.
* ARGUMENTS
* ptr the &struct fr_list_head pointer
* type the type of the struct this is embedded in
* member the name of the list_struct within the struct
* SOURCE
*/
#define FR_LIST_ENTRY(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
/*****/
/****d* include.list/fr_list_for_each
* DESCRIPTION
* Iterate over a list.
* ARGUMENTS
* pos the &struct fr_list_head to use as a loop counter
* head the head for your list
* SOURCE
*/
#define FR_LIST_FOR_EACH(pos, head) \
for(pos = (head)->next; pos != (head); pos = pos->next)
/*****/
/****d* include.list/fr_list_for_each_safe
* SYNOPSIS
* list_for_each_safe(pos, head)
* DESCRIPTION
* Iterate over a list safe against removal of list entry.
* ARGUMENTS
* pos the &struct fr_list_head to use as a loop counter
* n another &struct fr_list_head to use as temporary storage
* head the head for your list
* SOURCE
*/
#define FR_LIST_FOR_EACH_SAFE(pos, n, head) \
for(pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
/*****/
/****d* include.list/fr_list_for_each_prev
* DESCRIPTION
* Iterate over a list in reverse order.
* ARGUMENTS
* pos the &struct fr_list_head to use as a loop counter
* head the head for your list
* SOURCE
*/
#define FR_LIST_FOR_EACH_PREV(pos, head) \
for(pos = (head)->prev; pos != (head); pos = pos->prev)
/*****/
#ifdef __cplusplus
}
#endif
#endif // DRV_COMMON_LIST_H

View File

@ -0,0 +1,139 @@
#ifndef FR_COMMON_TYPES_H
#define FR_COMMON_TYPES_H
#ifdef __cplusplus
extern "C" { // allow C++ to use these headers
#endif
#ifndef TRUE
#define TRUE (1)
#endif // TRUE
#ifndef true
#define true TRUE
#endif // true
#ifndef FALSE
#define FALSE (0)
#endif // FALSE
#ifndef false
#define false FALSE
#endif // false
#ifndef EOF
#define EOF (-1)
#endif // EOF
//#ifndef __STDBOOL_H__
//typedef unsigned char bool;
//#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
/****d* include.types/dw_state
* NAME
* dw_state
* DESCRIPTION
* This is a generic data type used for 1-bit wide bitfields which have
* a "set/clear" property. This is used when modifying registers
* within a peripheral's memory map.
* SOURCE
*/
enum fr_state {
Fr_err = -1,
Fr_clear = 0,
Fr_set = 1
};
/*****/
#if 1
enum fr_channel_t {
FR_CHANNEL_0,
FR_CHANNEL_1,
FR_CHANNEL_MAX,
};
#endif
/****d* include.types/dw_callback
* DESCRIPTION
* This is a generic data type used for handling callback functions
* with each driver.
* ARGUMENTS
* dev -- device handle
* eCode -- event/error code
* NOTES
* The usage of the eCode argument is typically negative for an error
* code and positive for an event code.
* SOURCE
*/
typedef void (*fr_callback)(enum fr_channel_t channel, int32_t eCode);
/*****/
/****d* include.data/dw_dma_mode
* DESCRIPTION
* This is the data type used for enabling software or hardware
* handshaking for DMA transfers. Using software handshaking changes
* how an interrupt handler processes Rx full and Tx empty interrupts.
* Any DesignWare peripheral which supports DMA transfers has API
* function which match those listed below.
* SEE ALSO
* dw_*_setDmaTxMode(), dw_*_setDmaRxMode(), dw_*_getDmaTxMode(),
* dw_*_getDmaRxMode(), dw_*_setDmaTxNotifier(),
* dw_*_setDmaTxNotifier()
* SOURCE
*/
enum fr_dma_mode {
Fr_dma_none, // DMA is not being used
Fr_dma_sw_handshake, // DMA using software handshaking
Fr_dma_hw_handshake // DMA using hardware handshaking
};
/****d* include.types/dw_dma_notifier_func
* DESCRIPTION
* This is the data type used for specifying DMA notifier functions.
* These are needed when software handshaking is used with peripheral
* DMA transfers in order to inform the DMA controller when data is
* ready to be sent/received.
* ARGUMENTS
* dev -- DMA device handle
* channel -- associated channel number
* single -- single or burst transfer?
* last -- is this the last block?
* NOTES
* The single and last arguments are only necessary when the peripheral
* involved is also acting as the flow controller.
* SOURCE
*/
#ifdef CFG_DMA
typedef void (*fr_dma_notifier_func)(enum fr_i2c_channel_t channel, unsigned
channel, bool single, bool last);
/*****/
/*****/
/****s* include.api/dw_dma_notify
* DESCRIPTION
* This is the data structure used to store a DMA notifier function
* and its related arguments.
* SOURCE
*/
struct fr_dma_config {
enum dw_dma_mode mode;
dw_dma_notifier_func notifier;
struct dw_device *dmac;
unsigned channel;
};
/*****/
#endif
#ifdef __cplusplus
}
#endif
#endif // FR_COMMON_TYPES_H