Compare commits
6 Commits
OpenHarmon
...
OpenHarmon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1eb753cd25 | ||
|
|
19769f795b | ||
|
|
5b44332cff | ||
|
|
0d50fad855 | ||
|
|
a37c850d1b | ||
|
|
1eca7a502a |
@@ -44,6 +44,8 @@ extern "C" {
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP_LOCKDEP == YES)
|
||||
|
||||
#define PRINT_BUF_SIZE 256
|
||||
|
||||
#define LOCKDEP_GET_NAME(lockDep, index) (((SPIN_LOCK_S *)((lockDep)->heldLocks[(index)].lockPtr))->name)
|
||||
#define LOCKDEP_GET_ADDR(lockDep, index) ((lockDep)->heldLocks[(index)].lockAddr)
|
||||
|
||||
@@ -107,6 +109,31 @@ WEAK VOID OsLockDepPanic(enum LockDepErrType errType)
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
STATIC VOID OsLockDepPrint(const CHAR *fmt, va_list ap)
|
||||
{
|
||||
UINT32 len;
|
||||
CHAR buf[PRINT_BUF_SIZE] = {0};
|
||||
|
||||
len = vsnprintf_s(buf, PRINT_BUF_SIZE, PRINT_BUF_SIZE - 1, fmt, ap);
|
||||
if ((len == -1) && (*buf == '\0')) {
|
||||
/* parameter is illegal or some features in fmt dont support */
|
||||
UartPuts("OsLockDepPrint is error\n", strlen("OsLockDepPrint is error\n") + 1, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
*(buf + len) = '\0';
|
||||
|
||||
UartPuts(buf, len, 0);
|
||||
}
|
||||
|
||||
STATIC VOID OsPrintLockDepInfo(const CHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
OsLockDepPrint(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
STATIC VOID OsLockDepDumpLock(const LosTaskCB *task, const SPIN_LOCK_S *lock,
|
||||
const VOID *requestAddr, enum LockDepErrType errType)
|
||||
{
|
||||
@@ -114,24 +141,24 @@ STATIC VOID OsLockDepDumpLock(const LosTaskCB *task, const SPIN_LOCK_S *lock,
|
||||
const LockDep *lockDep = &task->lockDep;
|
||||
const LosTaskCB *temp = task;
|
||||
|
||||
PrintExcInfo("lockdep check failed\n");
|
||||
PrintExcInfo("error type : %s\n", OsLockDepErrorStringGet(errType));
|
||||
PrintExcInfo("request addr : 0x%x\n", requestAddr);
|
||||
OsPrintLockDepInfo("lockdep check failed\n");
|
||||
OsPrintLockDepInfo("error type : %s\n", OsLockDepErrorStringGet(errType));
|
||||
OsPrintLockDepInfo("request addr : 0x%x\n", requestAddr);
|
||||
|
||||
while (1) {
|
||||
PrintExcInfo("task name : %s\n", temp->taskName);
|
||||
PrintExcInfo("task id : %u\n", temp->taskID);
|
||||
PrintExcInfo("cpu num : %u\n", temp->currCpu);
|
||||
PrintExcInfo("start dumping lockdep infomation\n");
|
||||
OsPrintLockDepInfo("task name : %s\n", temp->taskName);
|
||||
OsPrintLockDepInfo("task id : %u\n", temp->taskID);
|
||||
OsPrintLockDepInfo("cpu num : %u\n", temp->currCpu);
|
||||
OsPrintLockDepInfo("start dumping lockdep infomation\n");
|
||||
for (i = 0; i < lockDep->lockDepth; i++) {
|
||||
if (lockDep->heldLocks[i].lockPtr == lock) {
|
||||
PrintExcInfo("[%d] %s <-- addr:0x%x\n", i, LOCKDEP_GET_NAME(lockDep, i),
|
||||
OsPrintLockDepInfo("[%d] %s <-- addr:0x%x\n", i, LOCKDEP_GET_NAME(lockDep, i),
|
||||
LOCKDEP_GET_ADDR(lockDep, i));
|
||||
} else {
|
||||
PrintExcInfo("[%d] %s \n", i, LOCKDEP_GET_NAME(lockDep, i));
|
||||
OsPrintLockDepInfo("[%d] %s \n", i, LOCKDEP_GET_NAME(lockDep, i));
|
||||
}
|
||||
}
|
||||
PrintExcInfo("[%d] %s <-- now\n", i, lock->name);
|
||||
OsPrintLockDepInfo("[%d] %s <-- now\n", i, lock->name);
|
||||
|
||||
if (errType == LOCKDEP_ERR_DEAD_LOCK) {
|
||||
temp = lock->owner;
|
||||
@@ -144,7 +171,6 @@ STATIC VOID OsLockDepDumpLock(const LosTaskCB *task, const SPIN_LOCK_S *lock,
|
||||
}
|
||||
}
|
||||
|
||||
OsLockDepPanic(errType);
|
||||
}
|
||||
|
||||
STATIC BOOL OsLockDepCheckDependancy(const LosTaskCB *current, LosTaskCB *lockOwner)
|
||||
@@ -172,7 +198,7 @@ VOID OsLockDepCheckIn(SPIN_LOCK_S *lock)
|
||||
{
|
||||
UINT32 intSave;
|
||||
enum LockDepErrType checkResult = LOCKDEP_SUCEESS;
|
||||
VOID *requestAddr = (VOID *)__builtin_return_address(0);
|
||||
VOID *requestAddr = (VOID *)__builtin_return_address(1);
|
||||
LosTaskCB *current = OsCurrTaskGet();
|
||||
LockDep *lockDep = ¤t->lockDep;
|
||||
LosTaskCB *lockOwner = NULL;
|
||||
@@ -211,11 +237,12 @@ OUT:
|
||||
lockDep->waitLock = lock;
|
||||
lockDep->heldLocks[lockDep->lockDepth].lockAddr = requestAddr;
|
||||
lockDep->heldLocks[lockDep->lockDepth].waitTime = OsLockDepGetCycles(); /* start time */
|
||||
} else {
|
||||
OsLockDepDumpLock(current, lock, requestAddr, checkResult);
|
||||
OsLockDepRelease(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
OsLockDepDumpLock(current, lock, requestAddr, checkResult);
|
||||
OsLockDepRelease(intSave);
|
||||
OsLockDepPanic(checkResult);
|
||||
}
|
||||
|
||||
VOID OsLockDepRecord(SPIN_LOCK_S *lock)
|
||||
@@ -253,7 +280,7 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
|
||||
UINT32 intSave;
|
||||
INT32 depth;
|
||||
enum LockDepErrType checkResult = LOCKDEP_SUCEESS;
|
||||
VOID *requestAddr = (VOID *)__builtin_return_address(0);
|
||||
VOID *requestAddr = (VOID *)__builtin_return_address(1);
|
||||
LosTaskCB *current = OsCurrTaskGet();
|
||||
LosTaskCB *owner = NULL;
|
||||
LockDep *lockDep = NULL;
|
||||
@@ -265,7 +292,8 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
|
||||
if (owner == SPINLOCK_OWNER_INIT) {
|
||||
checkResult = LOCKDEP_ERR_UNLOCK_WITOUT_LOCK;
|
||||
OsLockDepDumpLock(current, lock, requestAddr, checkResult);
|
||||
goto OUT;
|
||||
OsLockDepRelease(intSave);
|
||||
OsLockDepPanic(checkResult);
|
||||
}
|
||||
|
||||
lockDep = &owner->lockDep;
|
||||
@@ -294,7 +322,6 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
|
||||
lock->cpuid = (UINT32)(-1);
|
||||
lock->owner = SPINLOCK_OWNER_INIT;
|
||||
|
||||
OUT:
|
||||
OsLockDepRelease(intSave);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ STATIC VOID ConsoleOutput(const CHAR *str, UINT32 len)
|
||||
|
||||
for (;;) {
|
||||
cnt = write(STDOUT_FILENO, str + writen, (size_t)toWrite);
|
||||
if ((cnt < 0) || (toWrite == cnt)) {
|
||||
if ((cnt < 0) || ((cnt == 0) && OS_INT_ACTIVE) || (toWrite == cnt)) {
|
||||
break;
|
||||
}
|
||||
writen += cnt;
|
||||
|
||||
@@ -108,7 +108,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
|
||||
{
|
||||
int ret;
|
||||
struct itimerval svalue;
|
||||
struct itimerval sovalue;
|
||||
struct itimerval sovalue = { 0 };
|
||||
|
||||
if (value == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -136,7 +136,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
|
||||
int SysGetiTimer(int which, struct itimerval *value)
|
||||
{
|
||||
int ret;
|
||||
struct itimerval svalue;
|
||||
struct itimerval svalue = { 0 };
|
||||
|
||||
if (value == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -188,7 +188,7 @@ int SysTimerCreate(clockid_t clockID, struct sigevent *evp, timer_t *timerID)
|
||||
int SysTimerGettime(timer_t timerID, struct itimerspec *value)
|
||||
{
|
||||
int ret;
|
||||
struct itimerspec svalue;
|
||||
struct itimerspec svalue = { 0 };
|
||||
|
||||
if (value == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -212,7 +212,7 @@ int SysTimerSettime(timer_t timerID, int flags, const struct itimerspec *value,
|
||||
{
|
||||
int ret;
|
||||
struct itimerspec svalue;
|
||||
struct itimerspec soldValue;
|
||||
struct itimerspec soldValue = { 0 };
|
||||
|
||||
if (value == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -284,7 +284,7 @@ int SysClockSettime(clockid_t clockID, const struct timespec *tp)
|
||||
int SysClockGettime(clockid_t clockID, struct timespec *tp)
|
||||
{
|
||||
int ret;
|
||||
struct timespec stp;
|
||||
struct timespec stp = { 0 };
|
||||
|
||||
if (tp == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -307,7 +307,7 @@ int SysClockGettime(clockid_t clockID, struct timespec *tp)
|
||||
int SysClockGetres(clockid_t clockID, struct timespec *tp)
|
||||
{
|
||||
int ret;
|
||||
struct timespec stp;
|
||||
struct timespec stp = { 0 };
|
||||
|
||||
if (tp == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -355,7 +355,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
{
|
||||
int ret;
|
||||
struct timespec srqtp;
|
||||
struct timespec srmtp;
|
||||
struct timespec srmtp = { 0 };
|
||||
|
||||
if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) {
|
||||
errno = EFAULT;
|
||||
@@ -383,7 +383,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
clock_t SysTimes(struct tms *buf)
|
||||
{
|
||||
clock_t ret;
|
||||
struct tms sbuf;
|
||||
struct tms sbuf = { 0 };
|
||||
|
||||
if (buf == NULL) {
|
||||
errno = EFAULT;
|
||||
@@ -435,7 +435,7 @@ int SysClockGettime64(clockid_t clockID, struct timespec64 *tp)
|
||||
{
|
||||
int ret;
|
||||
struct timespec t;
|
||||
struct timespec64 stp;
|
||||
struct timespec64 stp = { 0 };
|
||||
|
||||
if (tp == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -462,7 +462,7 @@ int SysClockGetres64(clockid_t clockID, struct timespec64 *tp)
|
||||
{
|
||||
int ret;
|
||||
struct timespec t;
|
||||
struct timespec64 stp;
|
||||
struct timespec64 stp = { 0 };
|
||||
|
||||
if (tp == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -524,7 +524,7 @@ int SysTimerGettime64(timer_t timerID, struct itimerspec64 *value)
|
||||
{
|
||||
int ret;
|
||||
struct itimerspec val;
|
||||
struct itimerspec64 svalue;
|
||||
struct itimerspec64 svalue = { 0 };
|
||||
|
||||
if (value == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -583,6 +583,7 @@ int SysTimerSettime64(timer_t timerID, int flags, const struct itimerspec64 *val
|
||||
}
|
||||
|
||||
if (oldValue != NULL) {
|
||||
(void)memset_s(&soldValue, sizeof(struct itimerspec64), 0, sizeof(struct itimerspec64));
|
||||
soldValue.it_interval.tv_sec = oldVal.it_interval.tv_sec;
|
||||
soldValue.it_interval.tv_nsec = oldVal.it_interval.tv_nsec;
|
||||
soldValue.it_value.tv_sec = oldVal.it_value.tv_sec;
|
||||
|
||||
Reference in New Issue
Block a user