[PATCH] bsps/sparc: Add and use <grlib-impl.h>
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Nov 26 14:46:05 UTC 2018
Reduce copy and paste.
---
bsps/sparc/headers.am | 1 +
bsps/sparc/include/grlib-impl.h | 70 +++++++++++++++++++++++++++++
bsps/sparc/shared/1553/gr1553bc.c | 35 +--------------
bsps/sparc/shared/1553/gr1553bm.c | 36 +--------------
bsps/sparc/shared/1553/gr1553rt.c | 13 +-----
bsps/sparc/shared/amba/ahbstat.c | 24 ++++------
bsps/sparc/shared/can/grcan.c | 26 +----------
bsps/sparc/shared/can/occan.c | 12 +----
bsps/sparc/shared/net/greth.c | 10 +----
bsps/sparc/shared/pci/gr_701.c | 11 +----
bsps/sparc/shared/pci/gr_cpci_gr740.c | 11 +----
bsps/sparc/shared/pci/gr_leon4_n2x.c | 11 +----
bsps/sparc/shared/pci/gr_rasta_adcdac.c | 11 +----
bsps/sparc/shared/pci/gr_rasta_io.c | 11 +----
bsps/sparc/shared/pci/gr_rasta_spw_router.c | 11 +----
bsps/sparc/shared/pci/gr_rasta_tmtc.c | 11 +----
bsps/sparc/shared/pci/gr_tmtc_1553.c | 11 +----
bsps/sparc/shared/pci/grpci2.c | 32 +------------
bsps/sparc/shared/pci/grpci2dma.c | 34 +-------------
bsps/sparc/shared/spw/grspw_pkt.c | 35 +--------------
bsps/sparc/shared/spw/grspw_router.c | 53 +---------------------
bsps/sparc/shared/spw/spwtdp.c | 33 +-------------
bsps/sparc/shared/tmtc/grtc.c | 15 +------
bsps/sparc/shared/tmtc/grtm.c | 10 +----
24 files changed, 105 insertions(+), 422 deletions(-)
create mode 100644 bsps/sparc/include/grlib-impl.h
diff --git a/bsps/sparc/headers.am b/bsps/sparc/headers.am
index 4c6efb86ce..e09251613d 100644
--- a/bsps/sparc/headers.am
+++ b/bsps/sparc/headers.am
@@ -3,6 +3,7 @@
include_HEADERS =
include_HEADERS += ../../../../../bsps/sparc/include/ambapp.h
include_HEADERS += ../../../../../bsps/sparc/include/ambapp_ids.h
+include_HEADERS += ../../../../../bsps/sparc/include/grlib-impl.h
include_HEADERS += ../../../../../bsps/sparc/include/grlib.h
include_bspdir = $(includedir)/bsp
diff --git a/bsps/sparc/include/grlib-impl.h b/bsps/sparc/include/grlib-impl.h
new file mode 100644
index 0000000000..0bdf21ea9e
--- /dev/null
+++ b/bsps/sparc/include/grlib-impl.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2017 Cobham Gaisler AB
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef GRLIB_IMPL_H
+#define GRLIB_IMPL_H
+
+#include <rtems/score/cpuopts.h>
+
+/*
+ * Use interrupt lock primitives compatible with SMP defined in RTEMS 4.11.99
+ * and higher.
+ */
+#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
+
+#include <rtems/score/isrlock.h>
+
+/* map via rtems_interrupt_lock_* API: */
+#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
+#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
+#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
+#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
+#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
+#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
+#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
+#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#define SPIN_FREE(lock) rtems_interrupt_lock_destroy(lock)
+
+/* turn on/off local CPU's interrupt to ensure HW timing - not SMP safe. */
+#define IRQ_LOCAL_DECLARE(_level) rtems_interrupt_level _level
+#define IRQ_LOCAL_DISABLE(_level) rtems_interrupt_local_disable(_level)
+#define IRQ_LOCAL_ENABLE(_level) rtems_interrupt_local_enable(_level)
+
+#else
+
+#ifdef RTEMS_SMP
+#error SMP mode not compatible with these interrupt lock primitives
+#endif
+
+/* maintain single-core compatibility with older versions of RTEMS: */
+#define SPIN_DECLARE(name)
+#define SPIN_INIT(lock, name)
+#define SPIN_LOCK(lock, level)
+#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
+#define SPIN_UNLOCK(lock, level)
+#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
+#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
+#define SPIN_ISR_IRQFLAGS(k)
+#define SPIN_FREE(lock)
+
+/* turn on/off local CPU's interrupt to ensure HW timing - not SMP safe. */
+#define IRQ_LOCAL_DECLARE(_level) rtems_interrupt_level _level
+#define IRQ_LOCAL_DISABLE(_level) rtems_interrupt_disable(_level)
+#define IRQ_LOCAL_ENABLE(_level) rtems_interrupt_enable(_level)
+
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRLIB_IMPL_H */
diff --git a/bsps/sparc/shared/1553/gr1553bc.c b/bsps/sparc/shared/1553/gr1553bc.c
index 3b967d0f37..a7dd890cbf 100644
--- a/bsps/sparc/shared/1553/gr1553bc.c
+++ b/bsps/sparc/shared/1553/gr1553bc.c
@@ -17,40 +17,7 @@
#include <bsp/gr1553b.h>
#include <bsp/gr1553bc.h>
-/* Use interrupt lock privmitives compatible with SMP defined in
- * RTEMS 4.11.99 and higher.
- */
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-#define SPIN_FREE(lock) rtems_interrupt_lock_destroy(lock)
-
-#else
-
-/* maintain single-core compatibility with older versions of RTEMS: */
-#define SPIN_DECLARE(name)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
-#define SPIN_ISR_IRQFLAGS(k)
-#define SPIN_FREE(lock)
-
-#ifdef RTEMS_SMP
-#error SMP mode not compatible with these interrupt lock primitives
-#endif
-
-#endif
+#include <grlib-impl.h>
#define GR1553BC_WRITE_MEM(adr, val) *(volatile uint32_t *)(adr) = (uint32_t)(val)
#define GR1553BC_READ_MEM(adr) (*(volatile uint32_t *)(adr))
diff --git a/bsps/sparc/shared/1553/gr1553bm.c b/bsps/sparc/shared/1553/gr1553bm.c
index d63983bda9..d9fc9d0dda 100644
--- a/bsps/sparc/shared/1553/gr1553bm.c
+++ b/bsps/sparc/shared/1553/gr1553bm.c
@@ -16,6 +16,7 @@
#include <bsp/gr1553b.h>
#include <bsp/gr1553bm.h>
+#include <grlib-impl.h>
#define GR1553BM_WRITE_MEM(adr, val) *(volatile uint32_t *)(adr) = (uint32_t)(val)
#define GR1553BM_READ_MEM(adr) (*(volatile uint32_t *)(adr))
@@ -23,41 +24,6 @@
#define GR1553BM_WRITE_REG(adr, val) *(volatile uint32_t *)(adr) = (uint32_t)(val)
#define GR1553BM_READ_REG(adr) (*(volatile uint32_t *)(adr))
-/* Use interrupt lock privmitives compatible with SMP defined in
- * RTEMS 4.11.99 and higher.
- */
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-#define SPIN_FREE(lock) rtems_interrupt_lock_destroy(lock)
-
-#else
-
-/* maintain single-core compatibility with older versions of RTEMS: */
-#define SPIN_DECLARE(name)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
-#define SPIN_ISR_IRQFLAGS(k)
-#define SPIN_FREE(lock)
-
-#ifdef RTEMS_SMP
-#error SMP mode not compatible with these interrupt lock primitives
-#endif
-
-#endif
-
struct gr1553bm_priv {
struct drvmgr_dev **pdev;
struct gr1553b_regs *regs;
diff --git a/bsps/sparc/shared/1553/gr1553rt.c b/bsps/sparc/shared/1553/gr1553rt.c
index 932e8494f1..db928d0f1c 100644
--- a/bsps/sparc/shared/1553/gr1553rt.c
+++ b/bsps/sparc/shared/1553/gr1553rt.c
@@ -19,23 +19,14 @@
#include <drvmgr/drvmgr.h>
#include <drvmgr/ambapp_bus.h>
+#include <grlib-impl.h>
+
#define GR1553RT_WRITE_MEM(adr, val) *(volatile uint32_t *)(adr) = (uint32_t)(val)
#define GR1553RT_READ_MEM(adr) (*(volatile uint32_t *)(adr))
#define GR1553RT_WRITE_REG(adr, val) *(volatile uint32_t *)(adr) = (uint32_t)(val)
#define GR1553RT_READ_REG(adr) (*(volatile uint32_t *)(adr))
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-#define SPIN_FREE(lock) rtems_interrupt_lock_destroy(lock)
-
/* Software representation of one hardware descriptor */
struct gr1553rt_sw_bd {
unsigned short this_next;/* Next entry or this entry. 0xffff: no next */
diff --git a/bsps/sparc/shared/amba/ahbstat.c b/bsps/sparc/shared/amba/ahbstat.c
index e624301975..a769fb3b66 100644
--- a/bsps/sparc/shared/amba/ahbstat.c
+++ b/bsps/sparc/shared/amba/ahbstat.c
@@ -17,13 +17,7 @@
#include <bsp/ahbstat.h>
-#define SPIN_IRQ_DECLARE(name) RTEMS_INTERRUPT_LOCK_DECLARE(, name)
-#define SPIN_IRQ_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_IRQ_LOCK(lock, ctx) rtems_interrupt_lock_acquire(lock, &(ctx))
-#define SPIN_IRQ_UNLOCK(lock, ctx) rtems_interrupt_lock_release(lock, &(ctx))
-#define SPIN_IRQ_LOCK_ISR(lock, ctx) rtems_interrupt_lock_acquire_isr(lock, &(ctx))
-#define SPIN_IRQ_UNLOCK_ISR(lock, ctx) rtems_interrupt_lock_release_isr(lock, &(ctx))
-#define SPIN_IRQ_CTX rtems_interrupt_lock_context
+#include <grlib-impl.h>
#define REG_WRITE(addr, val) (*(volatile uint32_t *)(addr) = (uint32_t)(val))
#define REG_READ(addr) (*(volatile uint32_t *)(addr))
@@ -74,7 +68,7 @@ struct ahbstat_priv {
uint32_t last_status;
uint32_t last_address;
/* Spin-lock ISR protection */
- SPIN_IRQ_DECLARE(devlock);
+ SPIN_DECLARE(devlock);
};
static int ahbstat_init2(struct drvmgr_dev *dev);
@@ -137,7 +131,7 @@ static int ahbstat_init2(struct drvmgr_dev *dev)
* Initialize spinlock for AHBSTAT Device. It is used to protect user
* API calls involivng priv structure from updates in ISR.
*/
- SPIN_IRQ_INIT(&priv->devlock, priv->devname);
+ SPIN_INIT(&priv->devlock, priv->devname);
/* Initialize hardware */
REG_WRITE(&priv->regs->status, 0);
@@ -153,7 +147,7 @@ void ahbstat_isr(void *arg)
struct ahbstat_priv *priv = arg;
uint32_t fadr, status;
int rc;
- SPIN_IRQ_CTX lock_context;
+ SPIN_ISR_IRQFLAGS(lock_context);
/* Get hardware status */
status = REG_READ(&priv->regs->status);
@@ -165,10 +159,10 @@ void ahbstat_isr(void *arg)
/* Get Failing address */
fadr = REG_READ(&priv->regs->failing);
- SPIN_IRQ_LOCK_ISR(&priv->devlock, lock_context);
+ SPIN_LOCK(&priv->devlock, lock_context);
priv->last_status = status;
priv->last_address = fadr;
- SPIN_IRQ_UNLOCK_ISR(&priv->devlock, lock_context);
+ SPIN_UNLOCK(&priv->devlock, lock_context);
/* Let user handle error, default to print the error and reenable HW
*
@@ -211,7 +205,7 @@ int ahbstat_last_error(int minor, uint32_t *status, uint32_t *address)
struct ahbstat_priv *priv;
uint32_t last_status;
uint32_t last_address;
- SPIN_IRQ_CTX lock_context;
+ SPIN_IRQFLAGS(lock_context);
if (drvmgr_get_dev(&ahbstat_drv_info.general, minor, &dev)) {
return -1;
@@ -219,10 +213,10 @@ int ahbstat_last_error(int minor, uint32_t *status, uint32_t *address)
priv = (struct ahbstat_priv *)dev->priv;
/* Read information cached by ISR */
- SPIN_IRQ_LOCK(&priv->devlock, lock_context);
+ SPIN_LOCK_IRQ(&priv->devlock, lock_context);
last_status = REG_READ(&priv->last_status);
last_address = REG_READ(&priv->last_address);
- SPIN_IRQ_UNLOCK(&priv->devlock, lock_context);
+ SPIN_UNLOCK_IRQ(&priv->devlock, lock_context);
*status = last_status;
*address = last_address;
diff --git a/bsps/sparc/shared/can/grcan.c b/bsps/sparc/shared/can/grcan.c
index da236ef7cc..bf093a40b3 100644
--- a/bsps/sparc/shared/can/grcan.c
+++ b/bsps/sparc/shared/can/grcan.c
@@ -22,31 +22,7 @@
#include <drvmgr/ambapp_bus.h>
#include <ambapp.h>
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-/* Spin locks mapped via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-
-#else
-
-/* maintain compatibility with older versions of RTEMS: */
-#define SPIN_DECLARE(name)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
-#define SPIN_ISR_IRQFLAGS(k)
-
-#endif
+#include <grlib-impl.h>
/* Maximum number of GRCAN devices supported by driver */
#define GRCAN_COUNT_MAX 8
diff --git a/bsps/sparc/shared/can/occan.c b/bsps/sparc/shared/can/occan.c
index 2c0e49a2d5..042869b8c9 100644
--- a/bsps/sparc/shared/can/occan.c
+++ b/bsps/sparc/shared/can/occan.c
@@ -20,6 +20,8 @@
#include <drvmgr/ambapp_bus.h>
#include <bsp/occan.h>
+#include <grlib-impl.h>
+
/* RTEMS -> ERRNO decoding table
rtems_assoc_t errno_assoc[] = {
@@ -71,16 +73,6 @@ rtems_assoc_t errno_assoc[] = {
#define DBG(fmt, vargs...)
#endif
-/* Spin locks mapped via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-
/* fifo interface */
typedef struct {
int cnt;
diff --git a/bsps/sparc/shared/net/greth.c b/bsps/sparc/shared/net/greth.c
index 649ae9df24..c505e94be3 100644
--- a/bsps/sparc/shared/net/greth.c
+++ b/bsps/sparc/shared/net/greth.c
@@ -43,15 +43,7 @@
#include <netinet/in.h>
#include <netinet/if_ether.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
#ifdef malloc
#undef malloc
diff --git a/bsps/sparc/shared/pci/gr_701.c b/bsps/sparc/shared/pci/gr_701.c
index 2350e58b51..4c22cc51ea 100644
--- a/bsps/sparc/shared/pci/gr_701.c
+++ b/bsps/sparc/shared/pci/gr_701.c
@@ -23,7 +23,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <pci/access.h>
@@ -38,15 +37,7 @@
#include <bsp/gr_701.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/* Offset from 0x80000000 (dual bus version) */
#define AHB1_BASE_ADDR 0x80000000
diff --git a/bsps/sparc/shared/pci/gr_cpci_gr740.c b/bsps/sparc/shared/pci/gr_cpci_gr740.c
index 9b4fbfa3b2..d093973850 100644
--- a/bsps/sparc/shared/pci/gr_cpci_gr740.c
+++ b/bsps/sparc/shared/pci/gr_cpci_gr740.c
@@ -33,7 +33,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <ambapp.h>
@@ -46,15 +45,7 @@
#include <bsp/gr_cpci_gr740.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/* Determines which PCI address the AHB masters on the GR740 board will
* access when accessing the AHB to PCI window, it should be set so that the
diff --git a/bsps/sparc/shared/pci/gr_leon4_n2x.c b/bsps/sparc/shared/pci/gr_leon4_n2x.c
index c97c0b8cf5..e0f12cb6f6 100644
--- a/bsps/sparc/shared/pci/gr_leon4_n2x.c
+++ b/bsps/sparc/shared/pci/gr_leon4_n2x.c
@@ -32,7 +32,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <ambapp.h>
@@ -45,15 +44,7 @@
#include <bsp/gr_leon4_n2x.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/* Determines which PCI address the AHB masters on the LEON-N2X board will
* access when accessing the AHB to PCI window, it should be set so that the
diff --git a/bsps/sparc/shared/pci/gr_rasta_adcdac.c b/bsps/sparc/shared/pci/gr_rasta_adcdac.c
index 4bd00730e1..5d26887ce2 100644
--- a/bsps/sparc/shared/pci/gr_rasta_adcdac.c
+++ b/bsps/sparc/shared/pci/gr_rasta_adcdac.c
@@ -23,7 +23,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <ambapp.h>
@@ -36,15 +35,7 @@
#include <bsp/gr_rasta_adcdac.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/*#define DEBUG 1*/
diff --git a/bsps/sparc/shared/pci/gr_rasta_io.c b/bsps/sparc/shared/pci/gr_rasta_io.c
index 02c8b5b572..904f926923 100644
--- a/bsps/sparc/shared/pci/gr_rasta_io.c
+++ b/bsps/sparc/shared/pci/gr_rasta_io.c
@@ -23,7 +23,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <ambapp.h>
@@ -36,15 +35,7 @@
#include <bsp/gr_rasta_io.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/* Determines which PCI address the AHB masters will access, it should be
* set so that the masters can access the CPU RAM. Default is base of CPU RAM,
diff --git a/bsps/sparc/shared/pci/gr_rasta_spw_router.c b/bsps/sparc/shared/pci/gr_rasta_spw_router.c
index 194d0a9b99..7b911c5231 100644
--- a/bsps/sparc/shared/pci/gr_rasta_spw_router.c
+++ b/bsps/sparc/shared/pci/gr_rasta_spw_router.c
@@ -21,7 +21,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <ambapp.h>
@@ -33,15 +32,7 @@
#include <bsp/genirq.h>
#include <bsp/gr_rasta_spw_router.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/* Determines which PCI address the AHB masters will access, it should be
* set so that the masters can access the CPU RAM. Default is base of CPU RAM,
diff --git a/bsps/sparc/shared/pci/gr_rasta_tmtc.c b/bsps/sparc/shared/pci/gr_rasta_tmtc.c
index 7f49d1de1d..40f64fe7e2 100644
--- a/bsps/sparc/shared/pci/gr_rasta_tmtc.c
+++ b/bsps/sparc/shared/pci/gr_rasta_tmtc.c
@@ -23,7 +23,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <ambapp.h>
@@ -36,15 +35,7 @@
#include <bsp/gr_rasta_tmtc.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/* Determines which PCI address the AHB masters will access, it should be
* set so that the masters can access the CPU RAM. Default is base of CPU RAM,
diff --git a/bsps/sparc/shared/pci/gr_tmtc_1553.c b/bsps/sparc/shared/pci/gr_tmtc_1553.c
index 4bbdaffb84..b2a478cc5c 100644
--- a/bsps/sparc/shared/pci/gr_tmtc_1553.c
+++ b/bsps/sparc/shared/pci/gr_tmtc_1553.c
@@ -23,7 +23,6 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-#include <rtems/score/isrlock.h> /* spin-lock */
#include <pci.h>
#include <pci/access.h>
@@ -37,15 +36,7 @@
#include <bsp/gr_tmtc_1553.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/*#define DEBUG 1 */
diff --git a/bsps/sparc/shared/pci/grpci2.c b/bsps/sparc/shared/pci/grpci2.c
index 69aa938d97..2b141f68ba 100644
--- a/bsps/sparc/shared/pci/grpci2.c
+++ b/bsps/sparc/shared/pci/grpci2.c
@@ -43,37 +43,7 @@
#include <drvmgr/pci_bus.h>
#include <bsp/grpci2.h>
-/* Use interrupt lock privmitives compatible with SMP defined in
- * RTEMS 4.11.99 and higher.
- */
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-
-#else
-
-/* maintain single-core compatibility with older versions of RTEMS: */
-#define SPIN_DECLARE(name)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
-#define SPIN_ISR_IRQFLAGS(k)
-
-#ifdef RTEMS_SMP
-#error SMP mode not compatible with these interrupt lock primitives
-#endif
-#endif
+#include <grlib-impl.h>
/* If defined to 1 - byte twisting is enabled by default */
#define DEFAULT_BT_ENABLED 0
diff --git a/bsps/sparc/shared/pci/grpci2dma.c b/bsps/sparc/shared/pci/grpci2dma.c
index d5f1f9942f..ad89128d88 100644
--- a/bsps/sparc/shared/pci/grpci2dma.c
+++ b/bsps/sparc/shared/pci/grpci2dma.c
@@ -18,40 +18,10 @@
#include <bsp.h>
#include <bsp/grpci2dma.h>
+#include <grlib-impl.h>
+
/* This driver has been prepared for SMP operation
*/
-/* Use interrupt lock privmitives compatible with SMP defined in
- * RTEMS 4.11.99 and higher.
- */
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-
-#else
-
-/* maintain single-core compatibility with older versions of RTEMS: */
-#define SPIN_DECLARE(name)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
-#define SPIN_ISR_IRQFLAGS(k)
-
-#ifdef RTEMS_SMP
-#error SMP mode not compatible with these interrupt lock primitives
-#endif
-
-#endif
/*#define STATIC*/
#define STATIC static
diff --git a/bsps/sparc/shared/spw/grspw_pkt.c b/bsps/sparc/shared/spw/grspw_pkt.c
index c109a25a6b..2f6dbdecfc 100644
--- a/bsps/sparc/shared/spw/grspw_pkt.c
+++ b/bsps/sparc/shared/spw/grspw_pkt.c
@@ -28,40 +28,7 @@
#include <drvmgr/ambapp_bus.h>
#include <bsp/grspw_pkt.h>
-/* Use interrupt lock privmitives compatible with SMP defined in
- * RTEMS 4.11.99 and higher.
- */
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-#include <rtems/score/isrlock.h> /* spin-lock */
-
-/* map via ISR lock: */
-#define SPIN_DECLARE(lock) ISR_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) _ISR_lock_Initialize(lock, name)
-#define SPIN_LOCK(lock, level) _ISR_lock_Acquire_inline(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) _ISR_lock_ISR_disable_and_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) _ISR_lock_Release_inline(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) _ISR_lock_Release_and_ISR_enable(lock, &level)
-#define SPIN_IRQFLAGS(k) ISR_lock_Context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-
-#else
-
-/* maintain single-core compatibility with older versions of RTEMS: */
-#define SPIN_DECLARE(name)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
-#define SPIN_ISR_IRQFLAGS(k)
-
-#ifdef RTEMS_SMP
-#error SMP mode not compatible with these interrupt lock primitives
-#endif
-
-#endif
+#include <grlib-impl.h>
/*#define STATIC*/
#define STATIC static
diff --git a/bsps/sparc/shared/spw/grspw_router.c b/bsps/sparc/shared/spw/grspw_router.c
index d95c351443..bec23912a7 100644
--- a/bsps/sparc/shared/spw/grspw_router.c
+++ b/bsps/sparc/shared/spw/grspw_router.c
@@ -13,12 +13,13 @@
#include <rtems/bspIo.h>
#include <stdio.h>
#include <bsp.h>
-#include <rtems/bspIo.h> /* printk */
#include <drvmgr/drvmgr.h>
#include <drvmgr/ambapp_bus.h>
#include <bsp/grspw_router.h>
+#include <grlib-impl.h>
+
//#define STATIC
#define STATIC static
@@ -34,56 +35,6 @@
#define THREAD_SAFE 1
-/* Use interrupt lock privmitives compatible with SMP defined in
- * RTEMS 4.11.99 and higher.
- */
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-#ifdef THREAD_SAFE
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-#define SPIN_FREE(lock) rtems_interrupt_lock_destroy(lock)
-#else
-#define SPIN_DECLARE(lock)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level)
-#define SPIN_IRQFLAGS(k)
-#define SPIN_ISR_IRQFLAGS(k)
-#define SPIN_FREE(lock)
-#endif
-
-#else
-
-#ifdef THREAD_SAFE
-#error THREAD SAFE operation not supported on this RTEMS version
-#else
-#define SPIN_DECLARE(lock)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level)
-#define SPIN_IRQFLAGS(k)
-#define SPIN_ISR_IRQFLAGS(k)
-#define SPIN_FREE(lock)
-#endif
-
-#ifdef RTEMS_SMP
-#error SMP mode not compatible with these interrupt lock primitives
-#endif
-
-#endif
-
#define REG_WRITE(addr, val) (*(volatile unsigned int *)(addr) = (unsigned int)(val))
#define REG_READ(addr) (*(volatile unsigned int *)(addr))
diff --git a/bsps/sparc/shared/spw/spwtdp.c b/bsps/sparc/shared/spw/spwtdp.c
index cf5b3af946..ca1e73de01 100644
--- a/bsps/sparc/shared/spw/spwtdp.c
+++ b/bsps/sparc/shared/spw/spwtdp.c
@@ -21,38 +21,7 @@
#include <bsp.h>
#include <bsp/spwtdp.h>
-/* Use interrupt lock privmitives compatible with SMP defined in
- * RTEMS 4.11.99 and higher.
- */
-#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
-
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-
-#else
-
-/* maintain single-core compatibility with older versions of RTEMS: */
-#define SPIN_DECLARE(name)
-#define SPIN_INIT(lock, name)
-#define SPIN_LOCK(lock, level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
-#define SPIN_UNLOCK(lock, level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
-#define SPIN_ISR_IRQFLAGS(k)
-
-#ifdef RTEMS_SMP
-#error SMP mode not compatible with these interrupt lock primitives
-#endif
-
-#endif
+#include <grlib-impl.h>
/*#define STATIC*/
#define STATIC static
diff --git a/bsps/sparc/shared/tmtc/grtc.c b/bsps/sparc/shared/tmtc/grtc.c
index c01d7d8391..7d5e21c9d5 100644
--- a/bsps/sparc/shared/tmtc/grtc.c
+++ b/bsps/sparc/shared/tmtc/grtc.c
@@ -23,20 +23,7 @@
#include <ambapp.h>
#include <bsp/grtc.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
-
-/* turn on/off local CPU's interrupt to ensure HW timing - not SMP safe. */
-#define IRQ_LOCAL_DECLARE(_level) rtems_interrupt_level _level
-#define IRQ_LOCAL_DISABLE(_level) rtems_interrupt_local_disable(_level)
-#define IRQ_LOCAL_ENABLE(_level) rtems_interrupt_local_enable(_level)
+#include <grlib-impl.h>
/*
#define DEBUG
diff --git a/bsps/sparc/shared/tmtc/grtm.c b/bsps/sparc/shared/tmtc/grtm.c
index bd7d98f972..31d0d7e22d 100644
--- a/bsps/sparc/shared/tmtc/grtm.c
+++ b/bsps/sparc/shared/tmtc/grtm.c
@@ -23,15 +23,7 @@
#include <drvmgr/ambapp_bus.h>
#include <bsp/grtm.h>
-/* map via rtems_interrupt_lock_* API: */
-#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
-#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
-#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
-#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
-#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
-#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
-#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
-#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
+#include <grlib-impl.h>
/*
#define DEBUG
--
2.16.4
More information about the devel
mailing list