Browse Source

Fixed spin lock bug.

master
Hanhui 6 years ago
parent
commit
6bced744ae
  1. 5
      target/h/spinLockLib.h
  2. 5
      target/h/spinlockIsrNdLib.h
  3. 4
      target/h/version.h
  4. 26
      target/src/spinLockLib.c
  5. 2
      target/src/usrLib.c

5
target/h/spinLockLib.h

@ -15,6 +15,11 @@
#include "vxWorksCommon.h" #include "vxWorksCommon.h"
/* NOTICE: you can change SPIN_LOCK_USE_QUICK_LOCK to 1 and rebuild libVxWorks
* make spin lock use SylixOS Quick spinlock */
#define SPIN_LOCK_USE_QUICK_LOCK 0
#define S_spinLockLib_NOT_SPIN_LOCK_CALLABLE EEXIST #define S_spinLockLib_NOT_SPIN_LOCK_CALLABLE EEXIST
#define S_spinLockLib_INVALID_OPERATION EINVAL #define S_spinLockLib_INVALID_OPERATION EINVAL
#define S_spinLockLib_LOCK_IN_RECOVERY EINVAL #define S_spinLockLib_LOCK_IN_RECOVERY EINVAL

5
target/h/spinlockIsrNdLib.h

@ -15,6 +15,11 @@
#include "vxWorksCommon.h" #include "vxWorksCommon.h"
/* NOTICE: you can change SPIN_LOCK_ND_USE_QUICK_LOCK to 1 and rebuild libVxWorks
* make spin lock nd use SylixOS Quick spinlock */
#define SPIN_LOCK_ND_USE_QUICK_LOCK 0
/* types */ /* types */
typedef struct spinlockIsrNd_s { typedef struct spinlockIsrNd_s {

4
target/h/version.h

@ -35,7 +35,7 @@
#define _LIB_VXWORKS_MAJOR 0 #define _LIB_VXWORKS_MAJOR 0
#define _LIB_VXWORKS_MINOR 3 #define _LIB_VXWORKS_MINOR 3
#define _LIB_VXWORKS_MAINT 2 #define _LIB_VXWORKS_MAINT 3
/* there is now a space between the runtime name, and the version */ /* there is now a space between the runtime name, and the version */
@ -45,7 +45,7 @@
/* VxWorks compatibility layer */ /* VxWorks compatibility layer */
/* 0.1.1 add cpu affinity */ /* 0.1.1 add cpu affinity */
#define LIB_VXWORKS_VERSION "SylixOS Compatibility Pack 0.3.2" #define LIB_VXWORKS_VERSION "SylixOS Compatibility Pack 0.3.3"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

26
target/src/spinLockLib.c

@ -42,15 +42,29 @@ void spinLockIsrInit (spinlockIsr_t * lock, int flags)
void spinLockIsrGive (spinlockIsr_t * lock) void spinLockIsrGive (spinlockIsr_t * lock)
{ {
INTREG *key;
if (lock) { if (lock) {
API_SpinUnlock(&lock->lock); key = (INTREG *)&(lock->lock.SL_pvReserved);
#if SPIN_LOCK_USE_QUICK_LOCK > 0
API_SpinUnlockQuick(&lock->lock, *key);
#else
API_SpinUnlockIrq(&lock->lock, *key);
#endif
} }
} }
void spinLockIsrTake (spinlockIsr_t * lock) void spinLockIsrTake (spinlockIsr_t * lock)
{ {
INTREG *key;
if (lock) { if (lock) {
API_SpinLock(&lock->lock); key = (INTREG *)&(lock->lock.SL_pvReserved);
#if SPIN_LOCK_USE_QUICK_LOCK > 0
API_SpinLockQuick(&lock->lock, key);
#else
API_SpinLockIrq(&lock->lock, key);
#endif
} }
} }
@ -94,7 +108,11 @@ INTREG spinLockIsrNdTake (spinlockIsrNd_t * spin)
INTREG key = -1; INTREG key = -1;
if (spin) { if (spin) {
#if SPIN_LOCK_ND_USE_QUICK_LOCK > 0
API_SpinLockQuick(&spin->lock, &key); API_SpinLockQuick(&spin->lock, &key);
#else
API_SpinLockIrq(&spin->lock, &key);
#endif
} }
return (key); return (key);
@ -103,7 +121,11 @@ INTREG spinLockIsrNdTake (spinlockIsrNd_t * spin)
void spinLockIsrNdGive (spinlockIsrNd_t * spin, INTREG key) void spinLockIsrNdGive (spinlockIsrNd_t * spin, INTREG key)
{ {
if (spin) { if (spin) {
#if SPIN_LOCK_ND_USE_QUICK_LOCK > 0
API_SpinUnlockQuick(&spin->lock, key); API_SpinUnlockQuick(&spin->lock, key);
#else
API_SpinUnlockIrq(&spin->lock, key);
#endif
} }
} }

2
target/src/usrLib.c

@ -81,7 +81,7 @@ void printLogo (void)
printf("%s%s\n", printf("%s%s\n",
" ]]]]]]]]]]]]]]]]]]]]]]]]]] KERNEL: ", LIB_VXWORKS_VERSION); " ]]]]]]]]]]]]]]]]]]]]]]]]]] KERNEL: ", LIB_VXWORKS_VERSION);
printf("%s\n", printf("%s\n",
" ]]]]]]]]]]]]]]]]]]]]]]]]] Copyright SylixOS Group. 2006-2017"); " ]]]]]]]]]]]]]]]]]]]]]]]]] Copyright SylixOS Group. 2006-2019");
printf("\n"); printf("\n");
API_SystemHwInfoPrint(); API_SystemHwInfoPrint();

Loading…
Cancel
Save