summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2021-06-01 11:56:54 (GMT)
committer Hanhui <hanhui@acoinfo.com>2021-06-01 11:56:54 (GMT)
commit3995fe529009e4efab9c416b1df7418f9841ea50 (patch)
tree7dcca6738287160972965aab341b8ce27fb485cc
parent21b8c477b99309d52f91d6292c5c0aa928918b50 (diff)
downloadlibsylixos-3995fe529009e4efab9c416b1df7418f9841ea50.zip
libsylixos-3995fe529009e4efab9c416b1df7418f9841ea50.tar.gz
libsylixos-3995fe529009e4efab9c416b1df7418f9841ea50.tar.bz2
Fixed atomic nand operate error and correct spelling of comments.
-rw-r--r--SylixOS/arch/arm/arm_atomic.h44
-rw-r--r--SylixOS/arch/arm/common/v7m/armExcV7MAsm.S1
-rw-r--r--SylixOS/arch/arm/common/v7m/armLibV7MAsm.S1
-rw-r--r--SylixOS/arch/arm/mm/mmu/v4/armMmuV4.c2
-rw-r--r--SylixOS/arch/arm/mm/mmu/v7/armMmuV7.c2
-rw-r--r--SylixOS/arch/arm64/arm64_atomic.h42
-rw-r--r--SylixOS/arch/arm64/common/arm64ExcAsm.S6
-rw-r--r--SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S25
-rw-r--r--SylixOS/arch/arm64/mm/mmu/arm64Mmu4K.c10
-rw-r--r--SylixOS/arch/arm64/mm/mmu/arm64Mmu64K.c8
-rw-r--r--SylixOS/arch/csky/common/cskyExcAsm.S4
-rw-r--r--SylixOS/arch/csky/csky_atomic.h18
-rw-r--r--SylixOS/arch/mips/common/mipsExc.c4
-rw-r--r--SylixOS/arch/mips/mips_atomic.h58
-rw-r--r--SylixOS/arch/ppc/ppc_atomic.h2
-rw-r--r--SylixOS/arch/riscv/riscv_atomic.h40
-rw-r--r--SylixOS/arch/sparc/common/sparcAtomicAsm.S34
-rw-r--r--SylixOS/arch/sparc/sparc_atomic.h1
-rw-r--r--SylixOS/arch/x86/bsp/bspSmp.c2
-rw-r--r--SylixOS/arch/x86/common/x64/x64AtomicAsm.S36
-rw-r--r--SylixOS/arch/x86/common/x86AtomicAsm.S19
-rw-r--r--SylixOS/arch/x86/common/x86Gdt.c4
-rw-r--r--SylixOS/arch/x86/x86_atomic.h33
-rw-r--r--SylixOS/driver/pci/null/pciNullDrv.c8
-rw-r--r--SylixOS/driver/pci/sio/pciSioNetmos.c8
-rw-r--r--SylixOS/driver/pci/storage/pciStorageAta.c8
-rw-r--r--SylixOS/driver/pci/storage/pciStorageNvme.c20
-rw-r--r--SylixOS/driver/pci/storage/pciStorageSata.c10
-rw-r--r--SylixOS/fs/oemDisk/oemFdisk.c73
-rw-r--r--SylixOS/kernel/core/_HeapLib.c8
-rw-r--r--SylixOS/kernel/core/_Sched.c6
-rw-r--r--SylixOS/kernel/core/_TimeCvt.c2
-rw-r--r--SylixOS/kernel/include/k_atomic.h56
-rw-r--r--SylixOS/kernel/include/k_class.h6
-rw-r--r--SylixOS/kernel/include/k_kernel.h2
-rw-r--r--SylixOS/kernel/interface/CpuActive.c1
-rw-r--r--SylixOS/kernel/list/listLink.c1
-rw-r--r--SylixOS/kernel/threadext/ThreadOnce.c4
-rw-r--r--SylixOS/loader/src/loader.c14
-rw-r--r--SylixOS/loader/src/loader_exec.c2
-rw-r--r--SylixOS/loader/src/loader_malloc.c2
-rw-r--r--SylixOS/loader/src/loader_shell.c4
-rw-r--r--SylixOS/net/lwip/bonding/netbonding.c6
-rw-r--r--SylixOS/net/lwip/lwip_ifctl.c4
-rw-r--r--SylixOS/net/lwip/netdev/netdev.c65
-rw-r--r--SylixOS/posix/pthread/pthread_spinlock.c2
-rw-r--r--SylixOS/shell/fsLib/ttinyShellFsCmd.c4
-rw-r--r--SylixOS/shell/ttinyShell/ttinyShellLib.c8
-rw-r--r--SylixOS/shell/ttinyVar/ttinyVarLib.c3
-rw-r--r--SylixOS/system/device/semfd/semfdDev.c2
-rw-r--r--SylixOS/system/ioLib/ioSys.c2
-rw-r--r--SylixOS/system/signal/signal.c2
-rw-r--r--SylixOS/system/signal/signalLib.c2
53 files changed, 539 insertions, 192 deletions
diff --git a/SylixOS/arch/arm/arm_atomic.h b/SylixOS/arch/arm/arm_atomic.h
index 391bfad..157ee6a 100644
--- a/SylixOS/arch/arm/arm_atomic.h
+++ b/SylixOS/arch/arm/arm_atomic.h
@@ -54,6 +54,27 @@ ATOMIC_OP_RETURN(And, &=, and)
ATOMIC_OP_RETURN(Or, |=, orr)
ATOMIC_OP_RETURN(Xor, ^=, eor)
+static LW_INLINE INT archAtomicNand (INT i, atomic_t *v)
+{
+ ULONG ulTemp;
+ INT iResult;
+
+ ARM_PREFETCH_W(&v->counter);
+
+ __asm__ __volatile__(
+ "1: ldrex %0, [%2] \n"
+ " and %0, %0, %3 \n"
+ " mvn %0, %0 \n"
+ " strex %1, %0, [%2] \n"
+ " teq %1, #0 \n"
+ " bne 1b"
+ : "=&r" (iResult), "=&r" (ulTemp)
+ : "r" (&v->counter), "Ir" (i)
+ : "cc");
+
+ return (iResult);
+}
+
/*********************************************************************************************************
On ARM, ordinary assignment (str instruction) doesn't clear the local
strex/ldrex monitor on some implementations. The reason we can use it for
@@ -161,6 +182,29 @@ ATOMIC64_OP_RETURN(And, &=, and, and)
ATOMIC64_OP_RETURN(Or, |=, orr, orr)
ATOMIC64_OP_RETURN(Xor, ^=, eor, eor)
+static LW_INLINE INT64 archAtomic64Nand (INT64 i, atomic64_t *v)
+{
+ ULONG ulTemp;
+ INT64 i64Result;
+
+ ARM_PREFETCH_W(&v->counter);
+
+ __asm__ __volatile__(
+ "1: ldrexd %0, %H0, [%3] \n"
+ " and %Q0, %Q0, %Q4 \n"
+ " and %R0, %R0, %R4 \n"
+ " mvn %Q0, %Q0 \n"
+ " mvn %R0, %R0 \n"
+ " strexd %1, %0, %H0, [%3] \n"
+ " teq %1, #0 \n"
+ " bne 1b"
+ : "=&r" (i64Result), "=&r" (ulTemp), "+Qo" (v->counter)
+ : "r" (&v->counter), "r" (i)
+ : "cc");
+
+ return (i64Result);
+}
+
/*********************************************************************************************************
On ARM, ordinary assignment (str instruction) doesn't clear the local
strexd/ldrexd monitor on some implementations. The reason we can use it for
diff --git a/SylixOS/arch/arm/common/v7m/armExcV7MAsm.S b/SylixOS/arch/arm/common/v7m/armExcV7MAsm.S
index 8e4d421..5a52419 100644
--- a/SylixOS/arch/arm/common/v7m/armExcV7MAsm.S
+++ b/SylixOS/arch/arm/common/v7m/armExcV7MAsm.S
@@ -43,7 +43,6 @@
IMPORT_LABEL(API_InterEnter)
IMPORT_LABEL(API_InterExit)
IMPORT_LABEL(API_InterExitNoSched)
- IMPORT_LABEL(archPendSvCtxSaveReg)
IMPORT_LABEL(_CpuGetCur)
#if LW_CFG_SMP_EN > 0
diff --git a/SylixOS/arch/arm/common/v7m/armLibV7MAsm.S b/SylixOS/arch/arm/common/v7m/armLibV7MAsm.S
index bfe98a7..a8ab4bc 100644
--- a/SylixOS/arch/arm/common/v7m/armLibV7MAsm.S
+++ b/SylixOS/arch/arm/common/v7m/armLibV7MAsm.S
@@ -48,7 +48,6 @@
EXPORT_LABEL(archIntDisable)
EXPORT_LABEL(archIntEnable)
EXPORT_LABEL(archIntEnableForce)
- EXPORT_LABEL(archPageCopy)
EXPORT_LABEL(archReboot)
EXPORT_LABEL(archBogoMipsLoop)
diff --git a/SylixOS/arch/arm/mm/mmu/v4/armMmuV4.c b/SylixOS/arch/arm/mm/mmu/v4/armMmuV4.c
index 4da48d5..196a84e 100644
--- a/SylixOS/arch/arm/mm/mmu/v4/armMmuV4.c
+++ b/SylixOS/arch/arm/mm/mmu/v4/armMmuV4.c
@@ -395,7 +395,7 @@ static LW_PMD_TRANSENTRY *armMmuPmdOffset (LW_PGD_TRANSENTRY *p_pgdentry, addr_
/*********************************************************************************************************
** 函数名称: armMmuPteOffset
** 功能描述: 通过虚拟地址计算 PMD 项
-** 输 入 : p_pgdentry pgd 入口地址
+** 输 入 : p_pmdentry pmd 入口地址
** ulAddr 虚拟地址
** 输 出 : 对应的 PMD 表项地址
** 全局变量:
diff --git a/SylixOS/arch/arm/mm/mmu/v7/armMmuV7.c b/SylixOS/arch/arm/mm/mmu/v7/armMmuV7.c
index dd33114..c3f596a 100644
--- a/SylixOS/arch/arm/mm/mmu/v7/armMmuV7.c
+++ b/SylixOS/arch/arm/mm/mmu/v7/armMmuV7.c
@@ -435,7 +435,7 @@ static LW_PMD_TRANSENTRY *armMmuPmdOffset (LW_PGD_TRANSENTRY *p_pgdentry, addr_
/*********************************************************************************************************
** 函数名称: armMmuPteOffset
** 功能描述: 通过虚拟地址计算 PTE 项
-** 输 入 : p_pgdentry pgd 入口地址
+** 输 入 : p_pmdentry pmd 入口地址
** ulAddr 虚拟地址
** 输 出 : 对应的 PTE 表项地址
** 全局变量:
diff --git a/SylixOS/arch/arm64/arm64_atomic.h b/SylixOS/arch/arm64/arm64_atomic.h
index 642c434..a3ff2ad 100644
--- a/SylixOS/arch/arm64/arm64_atomic.h
+++ b/SylixOS/arch/arm64/arm64_atomic.h
@@ -54,6 +54,27 @@ ATOMIC_OP_RETURN(And, &=, and)
ATOMIC_OP_RETURN(Or, |=, orr)
ATOMIC_OP_RETURN(Xor, ^=, eor)
+static LW_INLINE INT archAtomicNand (INT i, atomic_t *v)
+{
+ ULONG ulTemp;
+ INT iResult;
+
+ ARM_PREFETCH_W(&v->counter);
+
+ __asm__ __volatile__(
+ "1: ldxr %w0, %2 \n"
+ " and %w0, %w0, %w3 \n"
+ " mvn %w0, %w0 \n"
+ " stlxr %w1, %w0, %2 \n"
+ " cbnz %w1, 1b \n"
+ " dmb ish"
+ : "=&r" (iResult), "=&r" (ulTemp), "+Q" (v->counter)
+ : "Ir" (i)
+ : "memory");
+
+ return (iResult);
+}
+
/*********************************************************************************************************
On ARM64, ordinary assignment (str instruction) doesn't clear the local
strex/ldrex monitor on some implementations. The reason we can use it for
@@ -154,6 +175,27 @@ ATOMIC64_OP_RETURN(And, &=, and)
ATOMIC64_OP_RETURN(Or, |=, orr)
ATOMIC64_OP_RETURN(Xor, ^=, eor)
+static LW_INLINE INT64 archAtomic64Nand (INT64 i, atomic64_t *v)
+{
+ ULONG ulTemp;
+ INT64 i64Result;
+
+ ARM_PREFETCH_W(&v->counter);
+
+ __asm__ __volatile__(
+ "1: ldxr %0, %2 \n"
+ " and %0, %0, %3 \n"
+ " mvn %0, %0 \n"
+ " stlxr %w1, %0, %2 \n"
+ " cbnz %w1, 1b \n"
+ " dmb ish"
+ : "=&r" (i64Result), "=&r" (ulTemp), "+Q" (v->counter)
+ : "Ir" (i)
+ : "memory");
+
+ return (i64Result);
+}
+
/*********************************************************************************************************
On ARM, ordinary assignment (str instruction) doesn't clear the local
strexd/ldrexd monitor on some implementations. The reason we can use it for
diff --git a/SylixOS/arch/arm64/common/arm64ExcAsm.S b/SylixOS/arch/arm64/common/arm64ExcAsm.S
index bf29848..5415d51 100644
--- a/SylixOS/arch/arm64/common/arm64ExcAsm.S
+++ b/SylixOS/arch/arm64/common/arm64ExcAsm.S
@@ -225,7 +225,7 @@ MACRO_DEF(ARCH_INVALID_EXC_ENTRY type)
BL API_InterEnter
;/*
- ; * 如果不是第一次进入中断, 跳转
+ ; * 如果不是第一次进入异常, 跳转
; */
CMP X0 , #1
BNE 1f
@@ -263,14 +263,14 @@ MACRO_DEF(ARCH_INVALID_EXC_ENTRY type)
BL archInvalidExcHandle
;/*
- ; * 来到这里, 说明发生了中断嵌套
+ ; * 来到这里, 说明发生了异常嵌套
; */
MOV X18 , SP
RESTORE_BIG_REG_CTX ;/* 恢复所有寄存器 */
1:
;/*
- ; * 不是第一次进入中断
+ ; * 不是第一次进入异常
; */
LDR X0 , [SP, #XSP_OFFSET] ;/* 获取异常前 SP */
SUB X0 , X0 , ARCH_REG_CTX_SIZE ;/* 在异常堆栈开辟上下文保存区 */
diff --git a/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S b/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S
index 3514591..c20bd44 100644
--- a/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S
+++ b/SylixOS/arch/arm64/mm/cache/arm64CacheAsm.S
@@ -71,8 +71,18 @@ FUNC_DEF(arm64CacheSetCSSELR)
;*********************************************************************************************************/
FUNC_DEF(arm64ICacheEnable)
+ MRS X0 , SCTLR_EL1
+ AND X0 , X0 , #(1 << 12)
+ CMP X0 , #0
+ BEQ do_icache_enable
+ RET
+
+LINE_LABEL(do_icache_enable)
MOV X13 , LR
BL arm64ICacheInvalidateAll
+
+ ARM_ISB()
+
MRS X0 , SCTLR_EL1
ORR X0 , X0, #(1 << 12)
MSR SCTLR_EL1, X0
@@ -81,9 +91,23 @@ FUNC_DEF(arm64ICacheEnable)
FUNC_END()
FUNC_DEF(arm64DCacheEnable)
+ MRS X0 , SCTLR_EL1
+ AND X0 , X0 , #(1 << 2)
+ CMP X0 , #0
+ BEQ do_dcache_enable
+ RET
+
+LINE_LABEL(do_dcache_enable)
+ MOV X13 , LR ;/* 记录返回地址 */
+ BL arm64DCacheInvalidateAll
+
+ ARM_DSB()
+ ARM_ISB()
+
MRS X0 , SCTLR_EL1
ORR X0 , X0, #(1 << 2)
MSR SCTLR_EL1 , X0
+ MOV LR , X13
RET
FUNC_END()
@@ -140,6 +164,7 @@ MACRO_DEF(armDCacheV8Op Op Kstart Kend LineSize Tmp)
;/*********************************************************************************************************
; ARMv8 回写 部分 DCACHE X0=void *start; X1=void *end; X2=cache line size
;*********************************************************************************************************/
+
FUNC_DEF(arm64DCacheFlushPoU)
armDCacheV8Op CVAU X0 X1 X2 X3
FUNC_END()
diff --git a/SylixOS/arch/arm64/mm/mmu/arm64Mmu4K.c b/SylixOS/arch/arm64/mm/mmu/arm64Mmu4K.c
index 7482231..f4bb770 100644
--- a/SylixOS/arch/arm64/mm/mmu/arm64Mmu4K.c
+++ b/SylixOS/arch/arm64/mm/mmu/arm64Mmu4K.c
@@ -342,7 +342,7 @@ static LW_INLINE LW_PMD_TRANSENTRY arm64MmuBuildPmdEntry (addr_t ulBaseAddr,
return (ulDescriptor);
}
/*********************************************************************************************************
-** 函数名称: x64MmuBuildPtsEntry
+** 函数名称: arm64MmuBuildPtsEntry
** 功能描述: 生成一个三级描述符 (PTS 描述符)
** 输 入 : ulBaseAddr 基地址 (四级页表基地址)
** ucNS 是否访问安全区域
@@ -374,8 +374,8 @@ static LW_INLINE LW_PTS_TRANSENTRY arm64MmuBuildPtsEntry (addr_t ulBaseAddr,
}
/*********************************************************************************************************
** 函数名称: arm64MmuBuildPtentry
-** 功能描述: 生成一个二级描述符 (PTE 描述符)
-** 输 入 : uiBaseAddr 基地址 (页地址)
+** 功能描述: 生成一个四级描述符 (PTE 描述符)
+** 输 入 : ulBaseAddr 基地址 (页地址)
** ucGuard 进行严格的权限检查
** ucXN 可执行权限标志
** ucPXN 特权可执行权限标志
@@ -387,7 +387,7 @@ static LW_INLINE LW_PTS_TRANSENTRY arm64MmuBuildPtsEntry (addr_t ulBaseAddr,
** ucNS Non-Secure 标志
** ucAIn Attribute Index
** ucType 描述符类型
-** 输 出 : ERROR or OK
+** 输 出 : 四级描述符
** 全局变量:
** 调用模块:
*********************************************************************************************************/
@@ -582,7 +582,7 @@ static LW_PTS_TRANSENTRY *arm64MmuPtsOffset (LW_PMD_TRANSENTRY *p_pmdentry, ad
/*********************************************************************************************************
** 函数名称: arm64MmuPteOffset
** 功能描述: 通过虚拟地址计算 PTE 项
-** 输 入 : p_pgdentry pgd 入口地址
+** 输 入 : p_ptsentry pts 入口地址
** ulAddr 虚拟地址
** 输 出 : 对应的 PTE 表项地址
** 全局变量:
diff --git a/SylixOS/arch/arm64/mm/mmu/arm64Mmu64K.c b/SylixOS/arch/arm64/mm/mmu/arm64Mmu64K.c
index 90ee8be..74f583c 100644
--- a/SylixOS/arch/arm64/mm/mmu/arm64Mmu64K.c
+++ b/SylixOS/arch/arm64/mm/mmu/arm64Mmu64K.c
@@ -332,8 +332,8 @@ static LW_INLINE LW_PMD_TRANSENTRY arm64MmuBuildPmdEntry (addr_t ulBaseAddr,
}
/*********************************************************************************************************
** 函数名称: arm64MmuBuildPtentry
-** 功能描述: 生成一个二级描述符 (PTE 描述符)
-** 输 入 : uiBaseAddr 基地址 (页地址)
+** 功能描述: 生成一个三级描述符 (PTE 描述符)
+** 输 入 : ulBaseAddr 基地址 (页地址)
** ucGuard 进行严格的权限检查
** ucXN 可执行权限标志
** ucPXN 特权可执行权限标志
@@ -345,7 +345,7 @@ static LW_INLINE LW_PMD_TRANSENTRY arm64MmuBuildPmdEntry (addr_t ulBaseAddr,
** ucNS Non-Secure 标志
** ucAIn Attribute Index
** ucType 描述符类型
-** 输 出 : ERROR or OK
+** 输 出 : 三级描述符
** 全局变量:
** 调用模块:
*********************************************************************************************************/
@@ -507,7 +507,7 @@ static LW_PMD_TRANSENTRY *arm64MmuPmdOffset (LW_PGD_TRANSENTRY *p_pgdentry, add
/*********************************************************************************************************
** 函数名称: arm64MmuPteOffset
** 功能描述: 通过虚拟地址计算 PTE 项
-** 输 入 : p_pgdentry pgd 入口地址
+** 输 入 : p_pmdentry pmd 入口地址
** ulAddr 虚拟地址
** 输 出 : 对应的 PTE 表项地址
** 全局变量:
diff --git a/SylixOS/arch/csky/common/cskyExcAsm.S b/SylixOS/arch/csky/common/cskyExcAsm.S
index b072569..f6fd095 100644
--- a/SylixOS/arch/csky/common/cskyExcAsm.S
+++ b/SylixOS/arch/csky/common/cskyExcAsm.S
@@ -378,13 +378,13 @@ FUNC_DEF(archTlbFatalExceptEntry)
;/*********************************************************************************************************
; TLB 重填异常入口函数
;*********************************************************************************************************/
-
#if LW_CFG_VMM_EN == 0
+
FUNC_DEF(archTlbRefillExceptEntry)
IRQ_ENTRY 14 archTlbRefillExceptHandle
FUNC_END(archTlbRefillExceptEntry)
-#endif
+#endif
;/*********************************************************************************************************
; TLB 修改异常入口函数
;*********************************************************************************************************/
diff --git a/SylixOS/arch/csky/csky_atomic.h b/SylixOS/arch/csky/csky_atomic.h
index 4fa17f0..c0a7640 100644
--- a/SylixOS/arch/csky/csky_atomic.h
+++ b/SylixOS/arch/csky/csky_atomic.h
@@ -61,6 +61,24 @@ static LW_INLINE INT archAtomicGet (atomic_t *v)
return (LW_ACCESS_ONCE(INT, v->counter));
}
+static LW_INLINE INT archAtomicNand (INT i, atomic_t *v)
+{
+ INT iTemp, iResult;
+
+ __asm__ __volatile__(
+ "1: ldex.w %0, (%3) \n"
+ " and %0, %2 \n"
+ " not %0 \n"
+ " mov %1, %0 \n"
+ " stex.w %0, (%3) \n"
+ " bez %0, 1b \n"
+ : "=&r" (iTemp), "=&r" (iResult)
+ : "r" (i), "r"(&v->counter)
+ : "memory");
+
+ return (iResult);
+}
+
/*********************************************************************************************************
atomic cas op
*********************************************************************************************************/
diff --git a/SylixOS/arch/mips/common/mipsExc.c b/SylixOS/arch/mips/common/mipsExc.c
index 0342bb3..75a3e9a 100644
--- a/SylixOS/arch/mips/common/mipsExc.c
+++ b/SylixOS/arch/mips/common/mipsExc.c
@@ -120,8 +120,8 @@ LW_WEAK VOID archIntHandle (ULONG ulVector, BOOL bPreemptive)
}
/*********************************************************************************************************
** 函数名称: archCacheErrorHandle
-** 功能描述: Cache 错误处理
-** 输 入 : NONE
+** 功能描述: CACHE 错误处理
+** 输 入 : pregctx 寄存器上下文
** 输 出 : NONE
** 全局变量:
** 调用模块:
diff --git a/SylixOS/arch/mips/mips_atomic.h b/SylixOS/arch/mips/mips_atomic.h
index 9403107..13f5bb1 100644
--- a/SylixOS/arch/mips/mips_atomic.h
+++ b/SylixOS/arch/mips/mips_atomic.h
@@ -65,6 +65,35 @@ ATOMIC_OP_RETURN(And, &=, and)
ATOMIC_OP_RETURN(Or, |=, or)
ATOMIC_OP_RETURN(Xor, ^=, xor)
+static LW_INLINE INT archAtomicNand (INT i, atomic_t *v)
+{
+ INT iTemp;
+ INT iResult;
+
+ KN_SMP_MB_BEFORE_ATOMIC();
+
+ do {
+ __asm__ __volatile__(
+ " .set push \n"
+ " .set noreorder \n"
+ KN_WEAK_LLSC_MB
+ " ll %1, %2 \n"
+ " and %0, %1, %3 \n"
+ " not %0, %0 \n"
+ " sc %0, %2 \n"
+ " .set pop \n"
+ : "=&r" (iResult), "=&r" (iTemp),
+ "+R" (v->counter)
+ : "Ir" (i));
+ } while (!iResult);
+
+ iResult = ~(iTemp & i);
+
+ KN_SMP_MB_AFTER_ATOMIC();
+
+ return (iResult);
+}
+
static LW_INLINE VOID archAtomicSet (INT i, atomic_t *v)
{
#if (LW_CFG_MIPS_CPU_LOONGSON3 > 0) || (LW_CFG_MIPS_CPU_LOONGSON2K > 0) || defined(_MIPS_ARCH_HR2)
@@ -209,6 +238,35 @@ ATOMIC64_OP_RETURN(And, &=, and)
ATOMIC64_OP_RETURN(Or, |=, or)
ATOMIC64_OP_RETURN(Xor, ^=, xor)
+static LW_INLINE INT64 archAtomic64Nand (INT64 i, atomic64_t *v)
+{
+ INT64 i64Temp;
+ INT64 i64Result;
+
+ KN_SMP_MB_BEFORE_ATOMIC();
+
+ do {
+ __asm__ __volatile__(
+ " .set push \n"
+ " .set noreorder \n"
+ KN_WEAK_LLSC_MB
+ " lld %1, %2 \n"
+ " and %0, %1, %3 \n"
+ " not %0, %0 \n"
+ " scd %0, %2 \n"
+ " .set pop \n"
+ : "=&r" (i64Result), "=&r" (i64Temp),
+ "+R" (v->counter)
+ : "Ir" (i));
+ } while (!i64Result);
+
+ i64Result = ~(i64Temp & i);
+
+ KN_SMP_MB_AFTER_ATOMIC();
+
+ return (i64Result);
+}
+
static LW_INLINE VOID archAtomic64Set (INT64 i, atomic64_t *v)
{
#if (LW_CFG_MIPS_CPU_LOONGSON3 > 0) || (LW_CFG_MIPS_CPU_LOONGSON2K > 0) || defined(_MIPS_ARCH_HR2)
diff --git a/SylixOS/arch/ppc/ppc_atomic.h b/SylixOS/arch/ppc/ppc_atomic.h
index 3ce4869..115a658 100644
--- a/SylixOS/arch/ppc/ppc_atomic.h
+++ b/SylixOS/arch/ppc/ppc_atomic.h
@@ -49,6 +49,7 @@ ATOMIC_OP_RETURN(Sub, -=, subf)
ATOMIC_OP_RETURN(And, &=, and)
ATOMIC_OP_RETURN(Or, |=, or)
ATOMIC_OP_RETURN(Xor, ^=, xor)
+ATOMIC_OP_RETURN(Nand, &~, nand)
static LW_INLINE INT archAtomicGet (atomic_t *v)
{
@@ -159,6 +160,7 @@ ATOMIC64_OP_RETURN(Sub, -=, subf)
ATOMIC64_OP_RETURN(And, &=, and)
ATOMIC64_OP_RETURN(Or, |=, or)
ATOMIC64_OP_RETURN(Xor, ^=, xor)
+ATOMIC64_OP_RETURN(Nand, &~, nand)
static LW_INLINE INT64 archAtomic64Get (atomic64_t *v)
{
diff --git a/SylixOS/arch/riscv/riscv_atomic.h b/SylixOS/arch/riscv/riscv_atomic.h
index 8888af2..f8a0a94 100644
--- a/SylixOS/arch/riscv/riscv_atomic.h
+++ b/SylixOS/arch/riscv/riscv_atomic.h
@@ -46,6 +46,26 @@ ATOMIC_OP_RETURN(And, and, &, i)
ATOMIC_OP_RETURN(Or, or, |, i)
ATOMIC_OP_RETURN(Xor, xor, ^, i)
+static LW_INLINE INT archAtomicNand (INT i, atomic_t *v)
+{
+ INT iResult;
+ REGISTER UINT uiTemp;
+
+ __asm__ __volatile__ (
+ "0: lr.w %0, %2 \n"
+ " and %0, %0, %z3 \n"
+ " not %0, %0 \n"
+ " sc.w.rl %1, %0, %2 \n"
+ " bnez %1, 0b \n"
+ " fence rw, rw \n"
+ "1: \n"
+ : "=&r" (iResult), "=&r" (uiTemp), "+A" (v->counter)
+ : "rJ" (i)
+ : "memory");
+
+ return (iResult);
+}
+
static LW_INLINE VOID archAtomicSet (INT i, atomic_t *v)
{
LW_ACCESS_ONCE(INT, v->counter) = i;
@@ -136,6 +156,26 @@ ATOMIC64_OP_RETURN(And, and, &, i)
ATOMIC64_OP_RETURN(Or, or, |, i)
ATOMIC64_OP_RETURN(Xor, xor, ^, i)
+static LW_INLINE INT64 archAtomic64Nand (INT64 i, atomic64_t *v)
+{
+ INT64 i64Result;
+ REGISTER UINT uiTemp;
+
+ __asm__ __volatile__ (
+ "0: lr.d %0, %2 \n"
+ " and %0, %0, %z3 \n"
+ " not %0, %0 \n"
+ " sc.d.rl %1, %0, %2 \n"
+ " bnez %1, 0b \n"
+ " fence rw, rw \n"
+ "1: \n"
+ : "=&r" (i64Result), "=&r" (uiTemp), "+A" (v->counter)
+ : "rJ" (i)
+ : "memory");
+
+ return (i64Result);
+}
+
static LW_INLINE VOID archAtomic64Set (INT64 i, atomic64_t *v)
{
LW_ACCESS_ONCE(INT64, v->counter) = i;
diff --git a/SylixOS/arch/sparc/common/sparcAtomicAsm.S b/SylixOS/arch/sparc/common/sparcAtomicAsm.S
index ec3ef2c..57cbf0b 100644
--- a/SylixOS/arch/sparc/common/sparcAtomicAsm.S
+++ b/SylixOS/arch/sparc/common/sparcAtomicAsm.S
@@ -34,20 +34,21 @@
EXPORT_LABEL(archAtomicAnd)
EXPORT_LABEL(archAtomicOr)
EXPORT_LABEL(archAtomicXor)
+ EXPORT_LABEL(archAtomicNand)
;/*********************************************************************************************************
; 原子量操作并返回结果
;*********************************************************************************************************/
#undef ATOMIC_OP_RETURN
-#define ATOMIC_OP_RETURN(op) \
-1: LD [%o1], %g1; \
- op %g1, %o0, %g7; \
- CASA [%o1] 0xb, %g1, %g7; \
- CMP %g1, %g7; \
- BNE 1b; \
- NOP; \
- RETL; \
+#define ATOMIC_OP_RETURN(op) \
+1: LD [%o1], %g1; \
+ op %g1, %o0, %g7; \
+ CASA [%o1] 0xb, %g1, %g7; \
+ CMP %g1, %g7; \
+ BNE 1b; \
+ NOP; \
+ RETL; \
op %g1, %o0, %o0;
;/*********************************************************************************************************
@@ -75,6 +76,23 @@ FUNC_DEF(archAtomicAnd)
FUNC_END(archAtomicAnd)
;/*********************************************************************************************************
+; 原子量与非
+;*********************************************************************************************************/
+
+FUNC_DEF(archAtomicNand)
+1: LD [%o1], %g1
+ AND %g1, %o0, %g7
+ NOT %g7
+ CASA [%o1] 0xb, %g1, %g7
+ CMP %g1, %g7
+ BNE 1b
+ NOP
+ AND %g1, %o0, %o0
+ RETL
+ NOT %o0
+ FUNC_END(archAtomicNand)
+
+;/*********************************************************************************************************
; 原子量或
;*********************************************************************************************************/
diff --git a/SylixOS/arch/sparc/sparc_atomic.h b/SylixOS/arch/sparc/sparc_atomic.h
index 074a444..0ec8f2a 100644
--- a/SylixOS/arch/sparc/sparc_atomic.h
+++ b/SylixOS/arch/sparc/sparc_atomic.h
@@ -35,6 +35,7 @@ ATOMIC_OP_RETURN(Sub)
ATOMIC_OP_RETURN(And)
ATOMIC_OP_RETURN(Or)
ATOMIC_OP_RETURN(Xor)
+ATOMIC_OP_RETURN(Nand)
static LW_INLINE VOID archAtomicSet (INT i, atomic_t *v)
{
diff --git a/SylixOS/arch/x86/bsp/bspSmp.c b/SylixOS/arch/x86/bsp/bspSmp.c
index b42938d..7f59325 100644
--- a/SylixOS/arch/x86/bsp/bspSmp.c
+++ b/SylixOS/arch/x86/bsp/bspSmp.c
@@ -202,7 +202,7 @@ LW_WEAK VOID bspCpuUp (ULONG ulCPUId)
*(volatile UINT16 *)(WARM_RESET_VECTOR + 2) = (((addr_t)pulEntryAddr) >> 4);
/*
- * Initialze the BIOS shutdown code to be 0xa
+ * Initialize the BIOS shutdown code to be 0xa
*/
/*
* Selects shutdown status register
diff --git a/SylixOS/arch/x86/common/x64/x64AtomicAsm.S b/SylixOS/arch/x86/common/x64/x64AtomicAsm.S
index 9904a89..94e3204 100644
--- a/SylixOS/arch/x86/common/x64/x64AtomicAsm.S
+++ b/SylixOS/arch/x86/common/x64/x64AtomicAsm.S
@@ -28,12 +28,14 @@
EXPORT_LABEL(archAtomicAdd)
EXPORT_LABEL(archAtomicSub)
EXPORT_LABEL(archAtomicAnd)
+ EXPORT_LABEL(archAtomicNand)
EXPORT_LABEL(archAtomicOr)
EXPORT_LABEL(archAtomicXor)
EXPORT_LABEL(archAtomic64Add)
EXPORT_LABEL(archAtomic64Sub)
EXPORT_LABEL(archAtomic64And)
+ EXPORT_LABEL(archAtomic64Nand)
EXPORT_LABEL(archAtomic64Or)
EXPORT_LABEL(archAtomic64Xor)
@@ -79,6 +81,23 @@ LINE_LABEL(1)
FUNC_END(archAtomicAnd)
;/*********************************************************************************************************
+; 原子量与非
+;*********************************************************************************************************/
+
+FUNC_DEF(archAtomicNand)
+ MOVL (%RSI), %EAX ;/* 旧值 */
+LINE_LABEL(1)
+ MOVL %EDI , %ECX
+ ANDL %EAX , %ECX
+ NOT %ECX
+ LOCK
+ CMPXCHGL %ECX, (%RSI)
+ JNZ 1b
+ MOVL %ECX , %EAX
+ RET
+ FUNC_END(archAtomicNand)
+
+;/*********************************************************************************************************
; 原子量或
;*********************************************************************************************************/
@@ -152,6 +171,23 @@ LINE_LABEL(1)
FUNC_END(archAtomic64And)
;/*********************************************************************************************************
+; 64 位原子量与非
+;*********************************************************************************************************/
+
+FUNC_DEF(archAtomic64Nand)
+ MOVQ (%RSI), %RAX ;/* 旧值 */
+LINE_LABEL(1)
+ MOVQ %RDI , %RCX
+ ANDQ %RAX , %RCX
+ NOTQ %RCX
+ LOCK
+ CMPXCHGQ %RCX, (%RSI)
+ JNZ 1b
+ MOVQ %RCX , %RAX
+ RET
+ FUNC_END(archAtomic64Nand)
+
+;/*********************************************************************************************************
; 64 位原子量或
;*********************************************************************************************************/
diff --git a/SylixOS/arch/x86/common/x86AtomicAsm.S b/SylixOS/arch/x86/common/x86AtomicAsm.S
index 15b4947..310306c 100644
--- a/SylixOS/arch/x86/common/x86AtomicAsm.S
+++ b/SylixOS/arch/x86/common/x86AtomicAsm.S
@@ -30,6 +30,7 @@
EXPORT_LABEL(archAtomicAnd)
EXPORT_LABEL(archAtomicOr)
EXPORT_LABEL(archAtomicXor)
+ EXPORT_LABEL(archAtomicNand)
#if LW_CFG_CPU_ATOMIC64_EN > 0
EXPORT_LABEL(archAtomic64SetCx8)
@@ -85,6 +86,24 @@ LINE_LABEL(1)
FUNC_END(archAtomicAnd)
;/*********************************************************************************************************
+; 原子量与非
+;*********************************************************************************************************/
+
+FUNC_DEF(archAtomicNand)
+ MOVL X86_SP_ARG2(%ESP) , %EDX ;/* 地址 */
+ MOVL (%EDX), %EAX ;/* 旧值 */
+LINE_LABEL(1)
+ MOVL X86_SP_ARG1(%ESP) , %ECX ;/* 值 */
+ ANDL %EAX , %ECX
+ NOT %ECX
+ LOCK
+ CMPXCHGL %ECX, (%EDX)
+ JNZ 1b
+ MOVL %ECX , %EAX
+ RET
+ FUNC_END(archAtomicNand)
+
+;/*********************************************************************************************************
; 原子量或
;*********************************************************************************************************/
diff --git a/SylixOS/arch/x86/common/x86Gdt.c b/SylixOS/arch/x86/common/x86Gdt.c
index 6736c01..da566f5 100644
--- a/SylixOS/arch/x86/common/x86Gdt.c
+++ b/SylixOS/arch/x86/common/x86Gdt.c
@@ -25,7 +25,7 @@
类型定义
*********************************************************************************************************/
/*********************************************************************************************************
- The sructure of a segment descriptor.
+ The structure of a segment descriptor.
@see Intel x86 doc, Vol 3, section 3.4.5, figure 3-8. For segment types, see section 3.5
*********************************************************************************************************/
@@ -77,7 +77,7 @@ struct x86_gdt_register {
/*
* This is not exactly a "virtual" address, ie an adddress such as
* those of instructions and data; this is a "linear" address, ie an
- * address in the paged memory. However, in X86 we configure the
+ * address in the paged memory. However, in x86 we configure the
* segmented memory as a "flat" space: the 0-4GB segment-based (ie
* "virtual") addresses directly map to the 0-4GB paged memory (ie
* "linear"), so that the "linear" addresses are numerically equal
diff --git a/SylixOS/arch/x86/x86_atomic.h b/SylixOS/arch/x86/x86_atomic.h
index dc3def0..0e7d364 100644
--- a/SylixOS/arch/x86/x86_atomic.h
+++ b/SylixOS/arch/x86/x86_atomic.h
@@ -37,11 +37,12 @@ static LW_INLINE INT archAtomicGet (atomic_t *v)
return (LW_ACCESS_ONCE(INT, v->counter));
}
-INT archAtomicAdd(INT i, atomic_t *v);
-INT archAtomicSub(INT i, atomic_t *v);
-INT archAtomicAnd(INT i, atomic_t *v);
-INT archAtomicOr (INT i, atomic_t *v);
-INT archAtomicXor(INT i, atomic_t *v);
+INT archAtomicAdd(INT i, atomic_t *v);
+INT archAtomicSub(INT i, atomic_t *v);
+INT archAtomicAnd(INT i, atomic_t *v);
+INT archAtomicOr(INT i, atomic_t *v);
+INT archAtomicXor(INT i, atomic_t *v);
+INT archAtomicNand(INT i, atomic_t *v);
/*********************************************************************************************************
atomic cas op
@@ -94,11 +95,12 @@ static LW_INLINE INT64 archAtomic64Get (atomic64_t *v)
return (LW_ACCESS_ONCE(INT64, v->counter));
}
-INT64 archAtomic64Add(INT64 i, atomic64_t *v);
-INT64 archAtomic64Sub(INT64 i, atomic64_t *v);
-INT64 archAtomic64And(INT64 i, atomic64_t *v);
-INT64 archAtomic64Or (INT64 i, atomic64_t *v);
-INT64 archAtomic64Xor(INT64 i, atomic64_t *v);
+INT64 archAtomic64Add(INT64 i, atomic64_t *v);
+INT64 archAtomic64Sub(INT64 i, atomic64_t *v);
+INT64 archAtomic64And(INT64 i, atomic64_t *v);
+INT64 archAtomic64Or(INT64 i, atomic64_t *v);
+INT64 archAtomic64Xor(INT64 i, atomic64_t *v);
+INT64 archAtomic64Nand(INT64 i, atomic64_t *v);
/*********************************************************************************************************
atomic64 cas op
@@ -233,6 +235,17 @@ static LW_INLINE INT64 archAtomic64Xor(INT64 i, atomic64_t *v)
return (i64Temp ^ i);
}
+static LW_INLINE INT64 archAtomic64Nand(INT64 i, atomic64_t *v)
+{
+ INT64 i64Old, i64Temp = 0;
+
+ while ((i64Old = archAtomic64Cas(v, i64Temp, ~(i64Temp & i))) != i64Temp) {
+ i64Temp = i64Old;
+ }
+
+ return (~(i64Temp & i));
+}
+
#endif /* LW_CFG_CPU_WORD_LENGHT 32 */
#endif /* LW_CFG_CPU_ATOMIC64_EN */
#endif /* LW_CFG_CPU_ATOMIC_EN */
diff --git a/SylixOS/driver/pci/null/pciNullDrv.c b/SylixOS/driver/pci/null/pciNullDrv.c
index e8177d2..a238253 100644
--- a/SylixOS/driver/pci/null/pciNullDrv.c
+++ b/SylixOS/driver/pci/null/pciNullDrv.c
@@ -80,19 +80,19 @@ static irqreturn_t pciNullDevIsr (PVOID pvArg, ULONG ulVector)
** 函数名称: pciNullDevIdTblGet
** 功能描述: 获取设备 ID 表的表头与表的大小
** 输 入 : hPciDevId 设备 ID 列表句柄缓冲区
-** puiSzie 设备 ID 列表大小缓冲区
+** puiSize 设备 ID 列表大小缓冲区
** 输 出 : ERROR or OK
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT pciNullDevIdTblGet (PCI_DEV_ID_HANDLE *hPciDevId, UINT32 *puiSzie)
+static INT pciNullDevIdTblGet (PCI_DEV_ID_HANDLE *hPciDevId, UINT32 *puiSize)
{
- if ((!hPciDevId) || (!puiSzie)) { /* 参数无效 */
+ if ((!hPciDevId) || (!puiSize)) { /* 参数无效 */
return (PX_ERROR); /* 错误返回 */
}
*hPciDevId = (PCI_DEV_ID_HANDLE)pciNullDrvIdTbl; /* 获取表头 */
- *puiSzie = sizeof(pciNullDrvIdTbl) / sizeof(PCI_DEV_ID_CB); /* 获取表的大小 */
+ *puiSize = sizeof(pciNullDrvIdTbl) / sizeof(PCI_DEV_ID_CB); /* 获取表的大小 */
return (ERROR_NONE);
}
diff --git a/SylixOS/driver/pci/sio/pciSioNetmos.c b/SylixOS/driver/pci/sio/pciSioNetmos.c
index 4457ab9..14d325e 100644
--- a/SylixOS/driver/pci/sio/pciSioNetmos.c
+++ b/SylixOS/driver/pci/sio/pciSioNetmos.c
@@ -234,19 +234,19 @@ static SIO_CHAN *pciSioNetmosChan (UINT uiChannel,
** 函数名称: pciSioNetmosIdTblGet
** 功能描述: 获取设备 ID 表的表头与表的大小
** 输 入 : hPciDevId 设备 ID 列表句柄缓冲区
-** puiSzie 设备 ID 列表大小缓冲区
+** puiSize 设备 ID 列表大小缓冲区
** 输 出 : ERROR or OK
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT pciSioNetmosIdTblGet (PCI_DEV_ID_HANDLE *hPciDevId, UINT32 *puiSzie)
+static INT pciSioNetmosIdTblGet (PCI_DEV_ID_HANDLE *hPciDevId, UINT32 *puiSize)
{
- if ((!hPciDevId) || (!puiSzie)) { /* 参数无效 */
+ if ((!hPciDevId) || (!puiSize)) { /* 参数无效 */
return (PX_ERROR); /* 错误返回 */
}
*hPciDevId = (PCI_DEV_ID_HANDLE)pciSioNetmosIdTbl; /* 获取表头 */
- *puiSzie = sizeof(pciSioNetmosIdTbl) / sizeof(PCI_DEV_ID_CB); /* 获取表的大小 */
+ *puiSize = sizeof(pciSioNetmosIdTbl) / sizeof(PCI_DEV_ID_CB); /* 获取表的大小 */
return (ERROR_NONE);
}
diff --git a/SylixOS/driver/pci/storage/pciStorageAta.c b/SylixOS/driver/pci/storage/pciStorageAta.c
index 1b52745..397c41a 100644
--- a/SylixOS/driver/pci/storage/pciStorageAta.c
+++ b/SylixOS/driver/pci/storage/pciStorageAta.c
@@ -275,19 +275,19 @@ static INT pciStorageAtaCtrlQuirk (PCI_DEV_HANDLE hPciDev,
** 函数名称: pciStorageAtaDevIdTblGet
** 功能描述: 获取设备列表
** 输 入 : phPciDevId 设备 ID 列表句柄缓冲区
-** puiSzie 设备列表大小
+** puiSize 设备列表大小
** 输 出 : ERROR or OK
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT pciStorageAtaDevIdTblGet (PCI_DEV_ID_HANDLE *phPciDevId, UINT32 *puiSzie)
+static INT pciStorageAtaDevIdTblGet (PCI_DEV_ID_HANDLE *phPciDevId, UINT32 *puiSize)
{
- if ((!phPciDevId) || (!puiSzie)) {
+ if ((!phPciDevId) || (!puiSize)) {
return (PX_ERROR);
}
*phPciDevId = (PCI_DEV_ID_HANDLE)pciStorageAtaIdTbl;
- *puiSzie = sizeof(pciStorageAtaIdTbl) / sizeof(PCI_DEV_ID_CB);
+ *puiSize = sizeof(pciStorageAtaIdTbl) / sizeof(PCI_DEV_ID_CB);
return (ERROR_NONE);
}
diff --git a/SylixOS/driver/pci/storage/pciStorageNvme.c b/SylixOS/driver/pci/storage/pciStorageNvme.c
index ab386aa..3c6b3d5 100644
--- a/SylixOS/driver/pci/storage/pciStorageNvme.c
+++ b/SylixOS/driver/pci/storage/pciStorageNvme.c
@@ -61,19 +61,19 @@ static INT pciStorageNvmeHeaderQuirk (PCI_DEV_HANDLE hPciDevHandle)
** 函数名称: pciNvmeDevIdTblGet
** 功能描述: 获取设备列表
** 输 入 : phPciDevId 设备 ID 列表句柄缓冲区
-** puiSzie 设备列表大小
+** puiSize 设备列表大小
** 输 出 : ERROR or OK
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT pciNvmeDevIdTblGet (PCI_DEV_ID_HANDLE *phPciDevId, UINT32 *puiSzie)
+static INT pciNvmeDevIdTblGet (PCI_DEV_ID_HANDLE *phPciDevId, UINT32 *puiSize)
{
- if ((!phPciDevId) || (!puiSzie)) {
+ if ((!phPciDevId) || (!puiSize)) {
return (PX_ERROR);
}
*phPciDevId = (PCI_DEV_ID_HANDLE)pciStorageNvmeIdTbl;
- *puiSzie = sizeof(pciStorageNvmeIdTbl) / sizeof(PCI_DEV_ID_CB);
+ *puiSize = sizeof(pciStorageNvmeIdTbl) / sizeof(PCI_DEV_ID_CB);
return (ERROR_NONE);
}
@@ -321,7 +321,7 @@ static INT pciStorageNvmeVendorCtrlIntDisConnect (NVME_CTRL_HANDLE hCtrl,
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT pciStorageNvmeVendorCtrlReadyWork (NVME_CTRL_HANDLE hCtrl, UINT uiIrqNum)
+static INT pciStorageNvmeVendorCtrlReadyWork (NVME_CTRL_HANDLE hCtrl, UINT uiIrqNum)
{
INT iRet;
PCI_DEV_HANDLE hPciDev;
@@ -329,7 +329,7 @@ static INT pciStorageNvmeVendorCtrlReadyWork (NVME_CTRL_HANDLE hCtrl, UINT uiI
phys_addr_t paBaseAddr;
PCI_RESOURCE_HANDLE hResource;
- hPciDev = (PCI_DEV_HANDLE)hCtrl->NVMECTRL_pvArg; /* 获取设备句柄 */
+ hPciDev = (PCI_DEV_HANDLE)hCtrl->NVMECTRL_pvArg; /* 获取设备句柄 */
API_PciDevConfigReadWord(hPciDev, PCI_DEVICE_ID, &usPciDevId);
NVME_LOG(NVME_LOG_PRT, "ctrl name %s index %d unit %d for pci dev %d:%d.%d dev id 0x%04x.\r\n",
@@ -337,7 +337,7 @@ static INT pciStorageNvmeVendorCtrlReadyWork (NVME_CTRL_HANDLE hCtrl, UINT uiI
hPciDev->PCIDEV_iDevBus,
hPciDev->PCIDEV_iDevDevice,
hPciDev->PCIDEV_iDevFunction, usPciDevId);
- /* 查找对应资源信息 */
+ /* 查找对应资源信息 */
hResource = API_PciDevStdResourceGet(hPciDev, PCI_IORESOURCE_MEM, PCI_BAR_INDEX_0);
if (!hResource) {
NVME_LOG(NVME_LOG_ERR, "pci BAR index %d error.\r\n", PCI_BAR_INDEX_0);
@@ -352,7 +352,7 @@ static INT pciStorageNvmeVendorCtrlReadyWork (NVME_CTRL_HANDLE hCtrl, UINT uiI
hCtrl->NVMECTRL_pvRegAddr, hCtrl->NVMECTRL_stRegSize);
return (PX_ERROR);
}
- NVME_LOG(NVME_LOG_PRT, "nvme reg addr 0x%llx szie %llx.\r\n",
+ NVME_LOG(NVME_LOG_PRT, "nvme reg addr 0x%llx size %llx.\r\n",
hCtrl->NVMECTRL_pvRegAddr, hCtrl->NVMECTRL_stRegSize);
iRet = API_PciDevMasterEnable(hPciDev, LW_TRUE); /* 使能 Master 模式 */
@@ -370,7 +370,7 @@ static INT pciStorageNvmeVendorCtrlReadyWork (NVME_CTRL_HANDLE hCtrl, UINT uiI
* 分配 MSI-X 描述符
*/
hCtrl->NVMECTRL_pvIntHandle = __SHEAP_ZALLOC(sizeof(PCI_MSI_DESC) * uiIrqNum);
- if (!hCtrl->NVMECTRL_pvIntHandle) { /* 分配描述符失败 */
+ if (!hCtrl->NVMECTRL_pvIntHandle) { /* 分配描述符失败 */
goto __msi_handle;
}
@@ -409,7 +409,7 @@ __intx_handle:
* 则 NVMe 设备本身必须支持 INTx 中断模式,购买设备时需确认。
* 此时对 Msi 和 Msi-X 中断的处理会返回错误,但仍能在 INTx 中断模式下正常工作。
*/
- iRet = API_PciDevMsiEnableSet(hPciDev, LW_FALSE); /* 可能会失败,不做处理 */
+ iRet = API_PciDevMsiEnableSet(hPciDev, LW_FALSE); /* 可能会失败,不做处理 */
hCtrl->NVMECTRL_uiIntNum = 1;
hCtrl->NVMECTRL_bMsix = LW_FALSE;
diff --git a/SylixOS/driver/pci/storage/pciStorageSata.c b/SylixOS/driver/pci/storage/pciStorageSata.c
index c54e815..2cedf4f 100644
--- a/SylixOS/driver/pci/storage/pciStorageSata.c
+++ b/SylixOS/driver/pci/storage/pciStorageSata.c
@@ -528,20 +528,20 @@ static INT pciStorageSataHeaderQuirk (PCI_DEV_HANDLE hPciDevHandle)
** 函数名称: pciStorageSataDevIdTblGet
** 功能描述: 获取设备列表
** 输 入 : phPciDevId 设备 ID 列表句柄缓冲区
-** puiSzie 设备列表大小
+** puiSize 设备列表大小
** 输 出 : ERROR or OK
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT pciStorageSataDevIdTblGet (PCI_DEV_ID_HANDLE *phPciDevId, UINT32 *puiSzie)
+static INT pciStorageSataDevIdTblGet (PCI_DEV_ID_HANDLE *phPciDevId, UINT32 *puiSize)
{
if ((!phPciDevId) ||
- (!puiSzie)) {
+ (!puiSize)) {
return (PX_ERROR);
}
*phPciDevId = (PCI_DEV_ID_HANDLE)pciStorageSataIdTbl;
- *puiSzie = sizeof(pciStorageSataIdTbl) / sizeof(PCI_DEV_ID_CB);
+ *puiSize = sizeof(pciStorageSataIdTbl) / sizeof(PCI_DEV_ID_CB);
return (ERROR_NONE);
}
@@ -973,7 +973,7 @@ static INT pciStorageSataVendorCtrlReadyWork (AHCI_CTRL_HANDLE hCtrl)
hCtrl->AHCICTRL_pvRegAddr, hCtrl->AHCICTRL_stRegSize);
return (PX_ERROR);
}
- AHCI_LOG(AHCI_LOG_PRT, "ahci reg addr 0x%llx szie %llx.\r\n",
+ AHCI_LOG(AHCI_LOG_PRT, "ahci reg addr 0x%llx size %llx.\r\n",
hCtrl->AHCICTRL_pvRegAddr, hCtrl->AHCICTRL_stRegSize);
API_PciDevConfigReadWord(hPciDev, PCI_STATUS, &usStatus);
diff --git a/SylixOS/fs/oemDisk/oemFdisk.c b/SylixOS/fs/oemDisk/oemFdisk.c
index 118dfa5..d66e519 100644
--- a/SylixOS/fs/oemDisk/oemFdisk.c
+++ b/SylixOS/fs/oemDisk/oemFdisk.c
@@ -41,6 +41,7 @@
#define __DISK_PART_STARTSECTOR 0x8
#define __DISK_PART_NSECTOR 0xc
#define __DISK_PART_OFFSEC 2048
+#define __DISK_PART_MINSEC (__DISK_PART_OFFSEC + 128)
/*********************************************************************************************************
** 函数名称: __oemFdisk
** 功能描述: 对 OEM 磁盘设备进行分区操作
@@ -69,7 +70,7 @@ static INT __oemFdisk (INT iBlkFd,
UINT8 *pucSecBuf, *pucFillBuf;
UINT8 *pucPartEntry;
BOOL bMaster = LW_FALSE;
- ULONG ulLeftSec;
+ ULONG ulLeftSec, ulInvSec = ulTotalSec;
ULONG ulNSecPerMB = LW_CFG_MB_SIZE / ulSecSize;
UINT64 u64Temp;
UINT32 uiPSecNext;
@@ -79,20 +80,6 @@ static INT __oemFdisk (INT iBlkFd,
UINT uiCylStart, uiCylEnd;
UINT uiSecStart, uiSecEnd;
- pucSecBuf = (UINT8 *)__SHEAP_ALLOC((size_t)ulSecSize << 1);
- if (pucSecBuf == LW_NULL) {
- _DebugHandle(__ERRORMESSAGE_LEVEL, "system low memory.\r\n");
- _ErrorHandle(ERROR_SYSTEM_LOW_MEMORY);
- return (PX_ERROR);
- }
-
- pucFillBuf = pucSecBuf + ulSecSize;
- lib_memset(pucFillBuf, 0xff, (size_t)ulSecSize); /* 用 0xff 填充扇区缓存 */
- if (ulTotalSec > 2050) {
- pwrite(iBlkFd, pucFillBuf,
- (size_t)ulSecSize, (2050 * (off_t)ulSecSize)); /* 去掉 Linux 文件系统信息 */
- }
-
ulTotalSec -= __DISK_PART_OFFSEC; /* 有效的总扇区数 */
uiPSecNext = __DISK_PART_OFFSEC;
ulLeftSec = ulTotalSec;
@@ -112,11 +99,30 @@ static INT __oemFdisk (INT iBlkFd,
uiPNSec[i] = (UINT32)u64Temp;
}
- uiPNSec[i] = ROUND_DOWN(uiPNSec[i], (stAlign / ulSecSize)); /* 对齐的扇区个数 */
+ uiPNSec[i] = ROUND_DOWN(uiPNSec[i], (stAlign / ulSecSize)); /* 对齐的扇区个数 */
+ if (ulLeftSec < uiPNSec[i]) { /* 分区越界 */
+ _ErrorHandle(ENOSPC);
+ return (PX_ERROR);
+ }
+
ulLeftSec -= uiPNSec[i];
uiPSecNext += uiPNSec[i];
}
-
+
+ pucSecBuf = (UINT8 *)__SHEAP_ALLOC((size_t)ulSecSize << 1);
+ if (pucSecBuf == LW_NULL) {
+ _DebugHandle(__ERRORMESSAGE_LEVEL, "system low memory.\r\n");
+ _ErrorHandle(ERROR_SYSTEM_LOW_MEMORY);
+ return (PX_ERROR);
+ }
+
+ pucFillBuf = pucSecBuf + ulSecSize;
+ lib_memset(pucFillBuf, 0xff, (size_t)ulSecSize); /* 用 0xff 填充扇区缓存 */
+ if (ulInvSec > 2050) {
+ pwrite(iBlkFd, pucFillBuf,
+ (size_t)ulSecSize, (2050 * (off_t)ulSecSize)); /* 去掉 Linux 文件系统信息 */
+ }
+
if (pread(iBlkFd, pucSecBuf, (size_t)ulSecSize, 0) != (ssize_t)ulSecSize) {
__SHEAP_FREE(pucSecBuf);
return (PX_ERROR);
@@ -203,7 +209,6 @@ INT API_OemFdisk (CPCHAR pcBlkDev, const LW_OEMFDISK_PART fdpPart[], UINT ui
struct stat statGet;
ULONG ulSecSize;
ULONG ulTotalSec;
- UINT8 ucTotalPct = 0;
if (!pcBlkDev || !fdpPart || !uiNPart || (uiNPart > 4)) {
_ErrorHandle(EINVAL);
@@ -239,7 +244,7 @@ INT API_OemFdisk (CPCHAR pcBlkDev, const LW_OEMFDISK_PART fdpPart[], UINT ui
return (PX_ERROR);
}
- if (ulTotalSec < __DISK_PART_OFFSEC) {
+ if (ulTotalSec < __DISK_PART_MINSEC) {
close(iBlkFd);
_ErrorHandle(ENOSPC);
return (PX_ERROR);
@@ -255,36 +260,12 @@ INT API_OemFdisk (CPCHAR pcBlkDev, const LW_OEMFDISK_PART fdpPart[], UINT ui
}
for (i = 0; i < uiNPart; i++) {
- if (fdpPart[i].FDP_ucSzPct > 100) { /* 容量分配 */
- ULONG ulNSecPerMB = LW_CFG_MB_SIZE / ulSecSize;
- ULONG ulPartNSec;
- UINT8 ucSzPct;
-
- if (!fdpPart[i].FDP_ulMBytes) { /* 容量信息错误 */
- close(iBlkFd);
- _ErrorHandle(EINVAL);
- return (PX_ERROR);
- }
-
- ulPartNSec = fdpPart[i].FDP_ulMBytes * ulNSecPerMB;
- ucSzPct = ulPartNSec / (ulTotalSec / 100);
- ucTotalPct += ucSzPct;
-
- } else { /* 比例分配 */
- ucTotalPct += fdpPart[i].FDP_ucSzPct;
- if (!fdpPart[i].FDP_ucSzPct) {
- i++;
- break;
- }
+ if (fdpPart[i].FDP_ucSzPct == 0) {
+ i++;
+ break;
}
}
- if (ucTotalPct > 100) {
- close(iBlkFd);
- _ErrorHandle(ENOSPC);
- return (PX_ERROR);
- }
-
uiNPart = i;
iNCnt = __oemFdisk(iBlkFd, ulSecSize, ulTotalSec, fdpPart, uiNPart, stAlign);
if (iNCnt > 0) {
diff --git a/SylixOS/kernel/core/_HeapLib.c b/SylixOS/kernel/core/_HeapLib.c
index 31bb3e0..33380ba 100644
--- a/SylixOS/kernel/core/_HeapLib.c
+++ b/SylixOS/kernel/core/_HeapLib.c
@@ -155,7 +155,7 @@ VOIDFUNCPTR _K_pfuncHeapTraceFree;
*********************************************************************************************************/
#define __DEBUG_MEM_ERROR(caller, heap, error, addr) \
_DebugFormat(__ERRORMESSAGE_LEVEL, "\'%s\' heap %s memory is %s, address %p.\r\n", \
- caller, heap, error, addr);
+ caller, heap, error, addr)
/*********************************************************************************************************
需要内存越界检查
*********************************************************************************************************/
@@ -763,7 +763,7 @@ PVOID _HeapAllocate (PLW_CLASS_HEAP pheap, size_t stByteSize, CPCHAR pcPurpo
__heap_crossbord_mark(psegment); /* 加入内存越界标志 */
MONITOR_EVT_LONG4(MONITOR_EVENT_ID_REGION, MONITOR_EVENT_REGION_ALLOC,
- pheap, __HEAP_SEGMENT_DATA_PTR(psegment),
+ pheap, __HEAP_SEGMENT_DATA_PTR(psegment),
psegment->SEGMENT_stByteSize, sizeof(LW_STACK), pcPurpose);
return ((PVOID)__HEAP_SEGMENT_DATA_PTR(psegment)); /* 返回分配的内存首地址 */
@@ -923,8 +923,8 @@ PVOID _HeapAllocateAlign (PLW_CLASS_HEAP pheap, size_t stByteSize, size_t st
__heap_crossbord_mark(psegment); /* 加入内存越界标志 */
MONITOR_EVT_LONG4(MONITOR_EVENT_ID_REGION, MONITOR_EVENT_REGION_ALLOC,
- pheap, pcAlign, psegment->SEGMENT_stByteSize,
- stAlign, pcPurpose);
+ pheap, pcAlign, psegment->SEGMENT_stByteSize,
+ stAlign, pcPurpose);
return (pcAlign); /* 返回分配的内存首地址 */
}
diff --git a/SylixOS/kernel/core/_Sched.c b/SylixOS/kernel/core/_Sched.c
index 1c3f03a..f465012 100644
--- a/SylixOS/kernel/core/_Sched.c
+++ b/SylixOS/kernel/core/_Sched.c
@@ -289,9 +289,9 @@ VOID _SchedSwp (PLW_CLASS_CPU pcpuCur)
}
}
/*********************************************************************************************************
-** 函数名称: _CoroutineDeleteAll
-** 功能描述: 释放指定线程所有的协程空间.
-** 输 入 : ptcb 线程控制块
+** 函数名称: _SchedCrSwp
+** 功能描述: 协程切换.
+** 输 入 : pcpuCur CPU 控制块
** 输 出 : NONE
** 全局变量:
** 调用模块:
diff --git a/SylixOS/kernel/core/_TimeCvt.c b/SylixOS/kernel/core/_TimeCvt.c
index 677b579..d30e310 100644
--- a/SylixOS/kernel/core/_TimeCvt.c
+++ b/SylixOS/kernel/core/_TimeCvt.c
@@ -37,7 +37,7 @@ ULONG (*_K_pfuncTimespecTimeoutTick)() = __timespecTimeoutTickSimple;
INT64 (*_K_pfuncTimespecTimeoutTick64)() = __timespecTimeoutTick64Simple;
/*********************************************************************************************************
** 函数名称: __timespecToTickDiff
-** 功能描述: 计算两个时间点只差, 并转换为 tick
+** 功能描述: 计算两个时间点之差, 并转换为 tick
** 输 入 : ptvS, ptvE 时间点开始与结束
** 输 出 : tick
** 全局变量:
diff --git a/SylixOS/kernel/include/k_atomic.h b/SylixOS/kernel/include/k_atomic.h
index 66ca32f..089a4fe 100644
--- a/SylixOS/kernel/include/k_atomic.h
+++ b/SylixOS/kernel/include/k_atomic.h
@@ -10,7 +10,7 @@
**
**--------------文件信息--------------------------------------------------------------------------------
**
-** 文 件 名: k_atomic.c
+** 文 件 名: k_atomic.h
**
** 创 建 人: Han.Hui (韩辉)
**
@@ -51,6 +51,11 @@ static LW_INLINE INT __LW_ATOMIC_AND (INT iVal, atomic_t *patomic)
return (archAtomicAnd(iVal, patomic));
}
+static LW_INLINE INT __LW_ATOMIC_NAND (INT iVal, atomic_t *patomic)
+{
+ return (archAtomicNand(iVal, patomic));
+}
+
static LW_INLINE INT __LW_ATOMIC_OR (INT iVal, atomic_t *patomic)
{
return (archAtomicOr(iVal, patomic));
@@ -139,6 +144,19 @@ static LW_INLINE INT __LW_ATOMIC_AND (INT iVal, atomic_t *patomic)
return (iRet);
}
+static LW_INLINE INT __LW_ATOMIC_NAND (INT iVal, atomic_t *patomic)
+{
+ INTREG iregInterLevel;
+ REGISTER INT iRet;
+
+ __LW_ATOMIC_LOCK(iregInterLevel);
+ iRet = ~(patomic->counter & iVal);
+ patomic->counter = iRet;
+ __LW_ATOMIC_UNLOCK(iregInterLevel);
+
+ return (iRet);
+}
+
static LW_INLINE INT __LW_ATOMIC_OR (INT iVal, atomic_t *patomic)
{
INTREG iregInterLevel;
@@ -156,12 +174,12 @@ static LW_INLINE INT __LW_ATOMIC_XOR (INT iVal, atomic_t *patomic)
{
INTREG iregInterLevel;
REGISTER INT iRet;
-
+
__LW_ATOMIC_LOCK(iregInterLevel);
iRet = patomic->counter ^ iVal;
patomic->counter = iRet;
__LW_ATOMIC_UNLOCK(iregInterLevel);
-
+
return (iRet);
}
@@ -243,6 +261,11 @@ static LW_INLINE INT64 __LW_ATOMIC64_AND (INT64 i64Val, atomic64_t *patomic64
return (archAtomic64And(i64Val, patomic64));
}
+static LW_INLINE INT64 __LW_ATOMIC64_NAND (INT64 i64Val, atomic64_t *patomic64)
+{
+ return (archAtomic64Nand(i64Val, patomic64));
+}
+
static LW_INLINE INT64 __LW_ATOMIC64_OR (INT64 i64Val, atomic64_t *patomic64)
{
return (archAtomic64Or(i64Val, patomic64));
@@ -325,6 +348,19 @@ static LW_INLINE INT64 __LW_ATOMIC64_AND (INT64 i64Val, atomic64_t *patomic64
return (i64Ret);
}
+static LW_INLINE INT64 __LW_ATOMIC64_NAND (INT64 i64Val, atomic64_t *patomic64)
+{
+ INTREG iregInterLevel;
+ REGISTER INT64 i64Ret;
+
+ __LW_ATOMIC_LOCK(iregInterLevel);
+ i64Ret = ~(patomic64->counter & i64Val);
+ patomic64->counter = i64Ret;
+ __LW_ATOMIC_UNLOCK(iregInterLevel);
+
+ return (i64Ret);
+}
+
static LW_INLINE INT64 __LW_ATOMIC64_OR (INT64 i64Val, atomic64_t *patomic64)
{
INTREG iregInterLevel;
@@ -342,12 +378,12 @@ static LW_INLINE INT64 __LW_ATOMIC64_XOR (INT64 i64Val, atomic64_t *patomic64
{
INTREG iregInterLevel;
REGISTER INT64 i64Ret;
-
+
__LW_ATOMIC_LOCK(iregInterLevel);
i64Ret = patomic64->counter ^ i64Val;
patomic64->counter = i64Ret;
__LW_ATOMIC_UNLOCK(iregInterLevel);
-
+
return (i64Ret);
}
@@ -420,11 +456,6 @@ static LW_INLINE INT __LW_ATOMIC_DEC (atomic_t *patomic)
return (__LW_ATOMIC_SUB(1, patomic));
}
-static LW_INLINE INT __LW_ATOMIC_NAND (INT iVal, atomic_t *patomic)
-{
- return (__LW_ATOMIC_AND(~iVal, patomic));
-}
-
static LW_INLINE INT64 __LW_ATOMIC64_INC (atomic64_t *patomic64)
{
return (__LW_ATOMIC64_ADD(1, patomic64));
@@ -435,11 +466,6 @@ static LW_INLINE INT64 __LW_ATOMIC64_DEC (atomic64_t *patomic64)
return (__LW_ATOMIC64_SUB(1, patomic64));
}
-static LW_INLINE INT64 __LW_ATOMIC64_NAND (INT64 i64Val, atomic64_t *patomic64)
-{
- return (__LW_ATOMIC64_AND(~i64Val, patomic64));
-}
-
#endif /* __K_ATOMIC_H */
/*********************************************************************************************************
END
diff --git a/SylixOS/kernel/include/k_class.h b/SylixOS/kernel/include/k_class.h
index 45e479a..d078d65 100644
--- a/SylixOS/kernel/include/k_class.h
+++ b/SylixOS/kernel/include/k_class.h
@@ -325,11 +325,11 @@ typedef LW_CLASS_MSGQUEUE *PLW_CLASS_MSGQUEUE;
typedef struct {
ARCH_REG_CTX COROUTINE_archRegCtx; /* 寄存器上下文 */
- PLW_STACK COROUTINE_pstkStackTop; /* 线程主堆栈栈顶 */
+ PLW_STACK COROUTINE_pstkStackTop; /* 协程主堆栈栈顶 */
/* 不包括 CRCB 堆栈区 */
- PLW_STACK COROUTINE_pstkStackBottom; /* 线程主堆栈栈底 */
+ PLW_STACK COROUTINE_pstkStackBottom; /* 协程主堆栈栈底 */
/* 不包括 CRCB 堆栈区 */
- size_t COROUTINE_stStackSize; /* 线程堆栈大小(单位:字) */
+ size_t COROUTINE_stStackSize; /* 协程堆栈大小(单位:字) */
/* 包括 CRCB 在内的所有堆栈 */
PLW_STACK COROUTINE_pstkStackLowAddr; /* 总堆栈最低地址 */
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index 2717898..fa224af 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -53,7 +53,7 @@
#define __SYLIXOS_MAJOR_VER 2
#define __SYLIXOS_MINOR_VER 1
-#define __SYLIXOS_PATCH_VER 5
+#define __SYLIXOS_PATCH_VER 6
#define __SYLIXOS_PATCH_PAD 0
/*********************************************************************************************************
diff --git a/SylixOS/kernel/interface/CpuActive.c b/SylixOS/kernel/interface/CpuActive.c
index 4e99e02..8a440ab 100644
--- a/SylixOS/kernel/interface/CpuActive.c
+++ b/SylixOS/kernel/interface/CpuActive.c
@@ -139,7 +139,6 @@ BOOL API_CpuIsUp (ULONG ulCPUId)
return (LW_FALSE);
}
}
-
/*********************************************************************************************************
** 函数名称: API_CpuIsRunning
** 功能描述: 指定 CPU 是否在运行.
diff --git a/SylixOS/kernel/list/listLink.c b/SylixOS/kernel/list/listLink.c
index 3bfc46c..41eae69 100644
--- a/SylixOS/kernel/list/listLink.c
+++ b/SylixOS/kernel/list/listLink.c
@@ -252,7 +252,6 @@ VOID _List_Line_Add_Right (PLW_LIST_LINE plineNew, PLW_LIST_LINE plineLeft)
*********************************************************************************************************/
VOID _List_Line_Del (PLW_LIST_LINE plineDel, LW_LIST_LINE_HEADER *pplineHeader)
{
-
if (plineDel->LINE_plistPrev == LW_NULL) { /* 表头 */
*pplineHeader = plineDel->LINE_plistNext;
} else {
diff --git a/SylixOS/kernel/threadext/ThreadOnce.c b/SylixOS/kernel/threadext/ThreadOnce.c
index 35907c0..8fd2a7a 100644
--- a/SylixOS/kernel/threadext/ThreadOnce.c
+++ b/SylixOS/kernel/threadext/ThreadOnce.c
@@ -113,7 +113,7 @@ INT API_ThreadOnce (INT *piOnce, VOIDFUNCPTR pfuncRoutine)
INT iValue;
atomic_t *patomic;
- if (!piOnce && !pfuncRoutine) {
+ if (!piOnce || !pfuncRoutine) {
_ErrorHandle(EINVAL);
return (PX_ERROR);
}
@@ -178,7 +178,7 @@ INT API_ThreadOnce2 (INT *piOnce, VOIDFUNCPTR pfuncRoutine, PVOID pvArg)
INT iValue;
atomic_t *patomic;
- if (!piOnce && !pfuncRoutine) {
+ if (!piOnce || !pfuncRoutine) {
_ErrorHandle(EINVAL);
return (PX_ERROR);
}
diff --git a/SylixOS/loader/src/loader.c b/SylixOS/loader/src/loader.c
index 2747c39..b705cfe 100644
--- a/SylixOS/loader/src/loader.c
+++ b/SylixOS/loader/src/loader.c
@@ -290,7 +290,7 @@ static INT moduleDelAndDestory (LW_LD_EXEC_MODULE *pmodule)
moduleDestory(pmodTemp);
if (pvproc->VP_ringModules) {
- pmodTemp = _LIST_ENTRY(pringTemp, LW_LD_EXEC_MODULE, EMOD_ringModules);
+ pmodTemp = _LIST_ENTRY(pringTemp, LW_LD_EXEC_MODULE, EMOD_ringModules);
}
}
@@ -994,8 +994,8 @@ PVOID API_ModuleLoadEx (CPCHAR pcFile,
__moduleVpPatchInit(pmodule);
}
- if (ERROR_NONE != initArrayCall(pmodule)) { /* 调用c++初始化代码 */
- pmodule->EMOD_pfuncExit = LW_NULL; /* init函数失败时不调用exit */
+ if (ERROR_NONE != initArrayCall(pmodule)) { /* 调用 c++ 初始化代码 */
+ pmodule->EMOD_pfuncExit = LW_NULL; /* init 函数失败时不调用 exit */
fprintf(stderr, "[ld]Function module_init return not 0!\n");
API_ModuleUnload(pmodule);
errno = ERROR_LOADER_UNEXPECTED;
@@ -1065,7 +1065,7 @@ INT API_ModuleUnload (PVOID pvModule)
API 函数
*********************************************************************************************************/
LW_API
-INT API_ModuleFinish (PVOID pvVProc)
+INT API_ModuleFinish (PVOID pvVProc)
{
LW_LD_VPROC *pvproc = (LW_LD_VPROC *)pvVProc;
LW_LD_EXEC_MODULE *pmodule;
@@ -1091,7 +1091,7 @@ INT API_ModuleFinish (PVOID pvVProc)
}
/*********************************************************************************************************
** 函数名称: API_ModuleTerminal
-** 功能描述: 清空进程中已经加载的elf文件. (首先应该调用 API_ModuleFinish 才能待用此函数)
+** 功能描述: 清空进程中已经加载的 elf 文件. (首先应该调用 API_ModuleFinish 才能调用此函数)
** 输 入 : pvproc 进程控制块指针
** 输 出 : ERROR_NONE 表示没有错误, PX_ERROR 表示错误
** 全局变量:
@@ -1099,7 +1099,7 @@ INT API_ModuleFinish (PVOID pvVProc)
API 函数
*********************************************************************************************************/
LW_API
-INT API_ModuleTerminal (PVOID pvVProc)
+INT API_ModuleTerminal (PVOID pvVProc)
{
LW_LD_VPROC *pvproc = (LW_LD_VPROC *)pvVProc;
LW_LD_EXEC_MODULE *pmodule;
@@ -1120,7 +1120,7 @@ INT API_ModuleTerminal (PVOID pvVProc)
LW_VP_UNLOCK(pmodule->EMOD_pvproc);
moduleDelAndDestory(pmodule);
-
+
pvproc->VP_ringModules = LW_NULL; /* 进程不再含有模块 */
return (ERROR_NONE);
diff --git a/SylixOS/loader/src/loader_exec.c b/SylixOS/loader/src/loader_exec.c
index 387ea9d..3bcf20c 100644
--- a/SylixOS/loader/src/loader_exec.c
+++ b/SylixOS/loader/src/loader_exec.c
@@ -375,7 +375,7 @@ static INT __processShell (PVOID pvArg)
}
/*********************************************************************************************************
** 函数名称: __processStart
-** 功能描述: start a process shell (新的继承继承当前线程优先级和堆栈大小)
+** 功能描述: start a process shell (新的进程继承当前线程优先级和堆栈大小)
** 输 入 : mode run mode
** psarg
** 输 出 : return code
diff --git a/SylixOS/loader/src/loader_malloc.c b/SylixOS/loader/src/loader_malloc.c
index c332911..002a983 100644
--- a/SylixOS/loader/src/loader_malloc.c
+++ b/SylixOS/loader/src/loader_malloc.c
@@ -172,7 +172,7 @@ static LW_LD_EXEC_SHARE *__ldExecShareFindByBase (PVOID pvBase)
}
}
/*********************************************************************************************************
-** 函数名称: __ldExecShareFindByBase
+** 函数名称: __ldExecShareFindByFile
** 功能描述: 通过文件信息查询共享段信息
** 输 入 : dev 设备
** ino64 ino64_t
diff --git a/SylixOS/loader/src/loader_shell.c b/SylixOS/loader/src/loader_shell.c
index f120681..263e6fd 100644
--- a/SylixOS/loader/src/loader_shell.c
+++ b/SylixOS/loader/src/loader_shell.c
@@ -905,7 +905,7 @@ static INT __tshellVProcShow (INT iArgC, PCHAR *ppcArgV)
}
/*********************************************************************************************************
** 函数名称: __tshellLsmod
-** 功能描述: 系统命令 "ps"
+** 功能描述: 系统命令 "lsmod"
** 输 入 : iArgC 参数个数
** ppcArgV 参数表
** 输 出 : 0
@@ -1046,7 +1046,7 @@ VOID API_LoaderInit (VOID)
_G_ulExecShareLock = API_SemaphoreMCreate("execshare_lock", LW_PRIO_DEF_CEILING, LW_OPTION_WAIT_PRIORITY |
LW_OPTION_INHERIT_PRIORITY | LW_OPTION_DELETE_SAFE |
LW_OPTION_OBJECT_GLOBAL, LW_NULL);
-#endif /* LW_CFG_VMM_EN > 0 */
+#endif /* LW_CFG_VMM_EN > 0 */
lib_bzero(&_G_vprocKernel, sizeof(_G_vprocKernel));
diff --git a/SylixOS/net/lwip/bonding/netbonding.c b/SylixOS/net/lwip/bonding/netbonding.c
index 41c5006..caaf907 100644
--- a/SylixOS/net/lwip/bonding/netbonding.c
+++ b/SylixOS/net/lwip/bonding/netbonding.c
@@ -617,7 +617,7 @@ static void netbd_proc (void *arg)
sub_is_ifname == 1: if name */
int netbd_add_dev (const char *bddev, int bdindex, const char *sub, int sub_is_ifname)
{
- int found, flags, need_up = 0;
+ int found, flags, need_up = 0, has_mac = 0;
struct netif *netif;
struct netif *netif_bd;
netbd_t *netbd;
@@ -703,6 +703,8 @@ int netbd_add_dev (const char *bddev, int bdindex, const char *sub, int sub_is_
if (memcmp(netdev_bd->hwaddr, netbd_zeroaddr, ETH_ALEN) == 0) {
MEMCPY(netdev_bd->hwaddr, netdev->hwaddr, ETH_ALEN); /* use this port mac address */
MEMCPY(netif_bd->hwaddr, netdev->hwaddr, ETH_ALEN);
+ } else {
+ has_mac = 1;
}
MEMCPY(netbd_eth->old_hwaddr, netdev->hwaddr, ETH_ALEN); /* save old hwaddr */
@@ -712,7 +714,7 @@ int netbd_add_dev (const char *bddev, int bdindex, const char *sub, int sub_is_
netbd_eth->old_vlanid = netif->vlanid; /* use net bonding vlan id */
netif->vlanid = netif_bd->vlanid;
- if (!need_up) { /* not first sub device */
+ if (!need_up || has_mac) { /* not first sub device or bonding has mac */
if (netif->ioctl) {
ifreq.ifr_name[0] = 0;
MEMCPY(ifreq.ifr_hwaddr.sa_data, netdev_bd->hwaddr, ETH_ALEN);
diff --git a/SylixOS/net/lwip/lwip_ifctl.c b/SylixOS/net/lwip/lwip_ifctl.c
index 31d9ec6..0f5a1a1 100644
--- a/SylixOS/net/lwip/lwip_ifctl.c
+++ b/SylixOS/net/lwip/lwip_ifctl.c
@@ -824,7 +824,7 @@ INT __ifIoctlInet (INT iCmd, PVOID pvArg)
case SIOCSIFTCPWND:
case SIOCGIFPFLAGS:
case SIOCSIFPFLAGS:
- LWIP_IF_LIST_LOCK(LW_FALSE); /* 进入临界区 */
+ LWIP_IF_LIST_LOCK(LW_TRUE); /* 进入临界区 (独占) */
iRet = __ifSubIoctlIf(iCmd, pvArg);
LWIP_IF_LIST_UNLOCK(); /* 退出临界区 */
break;
@@ -1001,7 +1001,7 @@ INT __ifIoctlPacket (INT iCmd, PVOID pvArg)
case SIOCSIFHWADDR:
case SIOCGIFPFLAGS:
case SIOCSIFPFLAGS:
- LWIP_IF_LIST_LOCK(LW_FALSE); /* 进入临界区 */
+ LWIP_IF_LIST_LOCK(LW_TRUE); /* 进入临界区 (独占) */
iRet = __ifSubIoctlIf(iCmd, pvArg);
LWIP_IF_LIST_UNLOCK(); /* 退出临界区 */
break;
diff --git a/SylixOS/net/lwip/netdev/netdev.c b/SylixOS/net/lwip/netdev/netdev.c
index 28084ec..e8df8ca 100644
--- a/SylixOS/net/lwip/netdev/netdev.c
+++ b/SylixOS/net/lwip/netdev/netdev.c
@@ -85,7 +85,6 @@ extern void netbd_sub_delete_hook(netdev_t *netdev);
#define NETDEV_DOWN(netdev) if ((netdev)->drv->down) { (netdev)->drv->down((netdev)); }
#define NETDEV_REMOVE(netdev) if ((netdev)->drv->remove) { (netdev)->drv->remove((netdev)); }
#define NETDEV_IOCTL(netdev, a, b) if ((netdev)->drv->ioctl) { (netdev)->drv->ioctl((netdev), (a), (b)); }
-#define NETDEV_PROMISC(netdev, a, b) if ((netdev)->drv->promisc) { (netdev)->drv->promisc((netdev), (a), (b)); }
#define NETDEV_RXMODE(netdev, a) if ((netdev)->drv->rxmode) { (netdev)->drv->rxmode((netdev), (a)); }
#define NETDEV_TRANSMIT(netdev, a) (netdev)->drv->transmit((netdev), (a))
#define NETDEV_RECEIVE(netdev, input, a) (netdev)->drv->receive((netdev), (input), (a))
@@ -205,9 +204,12 @@ static err_t netdev_netif_igmp_mac_filter (struct netif *netif,
mem_free(mac);
netif_set_maddr_hook(netif, group, 0);
- flags = netif_get_flags(netif);
- if (!(flags & (IFF_PROMISC | IFF_ALLMULTI))) {
- NETDEV_RXMODE(netdev, flags);
+ if (!netdev->mac_filter) {
+ flags = netif_get_flags(netif);
+ if (flags & IFF_ALLMULTI) {
+ NETDEV_RXMODE(netdev, flags & ~IFF_ALLMULTI);
+ netif->flags2 &= ~NETIF_FLAG2_ALLMULTI;
+ }
}
} else {
@@ -231,8 +233,9 @@ static err_t netdev_netif_igmp_mac_filter (struct netif *netif,
netif_set_maddr_hook(netif, group, 1);
flags = netif_get_flags(netif);
- if (!(flags & (IFF_PROMISC | IFF_ALLMULTI))) {
- NETDEV_RXMODE(netdev, flags);
+ if (!(flags & IFF_ALLMULTI)) {
+ NETDEV_RXMODE(netdev, flags | IFF_ALLMULTI);
+ netif->flags2 |= NETIF_FLAG2_ALLMULTI;
}
}
@@ -283,9 +286,12 @@ static err_t netdev_netif_mld_mac_filter (struct netif *netif,
mem_free(mac);
netif_set_maddr6_hook(netif, group, 0);
- flags = netif_get_flags(netif);
- if (!(flags & (IFF_PROMISC | IFF_ALLMULTI))) {
- NETDEV_RXMODE(netdev, flags);
+ if (!netdev->mac_filter) {
+ flags = netif_get_flags(netif);
+ if (flags & IFF_ALLMULTI) {
+ NETDEV_RXMODE(netdev, flags & ~IFF_ALLMULTI);
+ netif->flags2 &= ~NETIF_FLAG2_ALLMULTI;
+ }
}
} else {
@@ -309,8 +315,9 @@ static err_t netdev_netif_mld_mac_filter (struct netif *netif,
netif_set_maddr6_hook(netif, group, 1);
flags = netif_get_flags(netif);
- if (!(flags & (IFF_PROMISC | IFF_ALLMULTI))) {
- NETDEV_RXMODE(netdev, flags);
+ if (!(flags & IFF_ALLMULTI)) {
+ NETDEV_RXMODE(netdev, flags | IFF_ALLMULTI);
+ netif->flags2 |= NETIF_FLAG2_ALLMULTI;
}
}
@@ -1483,7 +1490,8 @@ int netdev_macfilter_isempty (netdev_t *netdev)
return (!netdev->mac_filter);
}
-/* netdev mac filter cnt */
+/* netdev mac filter cnt.
+ * NOTICE: MUST use LWIP_IF_LIST_LOCK(LW_TRUE) lock */
int netdev_macfilter_count (netdev_t *netdev)
{
struct netdev_mac *ha;
@@ -1496,10 +1504,12 @@ int netdev_macfilter_count (netdev_t *netdev)
return (cnt);
}
-/* netdev mac filter add a hwaddr and allow to recv */
+/* netdev mac filter add a hwaddr and allow to recv
+ * NOTICE: MUST use LWIP_IF_LIST_LOCK(LW_TRUE) lock */
int netdev_macfilter_add (netdev_t *netdev, const UINT8 hwaddr[])
{
struct netdev_mac *mac, *prev;
+ struct netif *netif;
int type, flags;
if (netdev->net_type != NETDEV_TYPE_ETHERNET) {
@@ -1539,20 +1549,25 @@ int netdev_macfilter_add (netdev_t *netdev, const UINT8 hwaddr[])
mac->next = netdev->mac_filter;
netdev->mac_filter = mac;
- flags = netif_get_flags((struct netif *)(netdev->sys));
- if (!(flags & (IFF_PROMISC | IFF_ALLMULTI)) ||
- (type != NETDEV_MAC_TYPE_MULTICAST)) {
- NETDEV_RXMODE(netdev, flags);
+ if (type == NETDEV_MAC_TYPE_MULTICAST) {
+ netif = (struct netif *)(netdev->sys);
+ flags = netif_get_flags(netif);
+ if (!(flags & IFF_ALLMULTI)) {
+ NETDEV_RXMODE(netdev, flags | IFF_ALLMULTI);
+ netif->flags2 |= NETIF_FLAG2_ALLMULTI;
+ }
}
return (0);
}
-/* netdev mac filter delete a hwaddr */
+/* netdev mac filter delete a hwaddr
+ * NOTICE: MUST use LWIP_IF_LIST_LOCK(LW_TRUE) lock */
int netdev_macfilter_delete (netdev_t *netdev, const UINT8 hwaddr[])
{
struct netdev_mac *mac, *prev;
- int type, flags;
+ struct netif *netif;
+ int flags;
if (netdev->net_type != NETDEV_TYPE_ETHERNET) {
return (-1);
@@ -1575,13 +1590,15 @@ int netdev_macfilter_delete (netdev_t *netdev, const UINT8 hwaddr[])
netdev->mac_filter = mac->next;
}
- type = mac->type;
mem_free(mac);
- flags = netif_get_flags((struct netif *)(netdev->sys));
- if (!(flags & (IFF_PROMISC | IFF_ALLMULTI)) ||
- (type != NETDEV_MAC_TYPE_MULTICAST)) {
- NETDEV_RXMODE(netdev, flags);
+ if (!netdev->mac_filter) {
+ netif = (struct netif *)(netdev->sys);
+ flags = netif_get_flags(netif);
+ if (flags & IFF_ALLMULTI) {
+ NETDEV_RXMODE(netdev, flags & ~IFF_ALLMULTI);
+ netif->flags2 &= ~NETIF_FLAG2_ALLMULTI;
+ }
}
return (0);
diff --git a/SylixOS/posix/pthread/pthread_spinlock.c b/SylixOS/posix/pthread/pthread_spinlock.c
index 71d91b3..2a42e7e 100644
--- a/SylixOS/posix/pthread/pthread_spinlock.c
+++ b/SylixOS/posix/pthread/pthread_spinlock.c
@@ -220,7 +220,7 @@ int pthread_spin_trylock_irq_np (pthread_spinlock_t *pspinlock, pthread_int_t
}
}
-#endif /* W_CFG_POSIXEX_EN > 0 */
+#endif /* LW_CFG_POSIXEX_EN > 0 */
#endif /* LW_CFG_POSIX_EN > 0 */
/*********************************************************************************************************
END
diff --git a/SylixOS/shell/fsLib/ttinyShellFsCmd.c b/SylixOS/shell/fsLib/ttinyShellFsCmd.c
index 989514f..a44292b 100644
--- a/SylixOS/shell/fsLib/ttinyShellFsCmd.c
+++ b/SylixOS/shell/fsLib/ttinyShellFsCmd.c
@@ -2055,7 +2055,9 @@ static INT __tshellFsCmdFdisk (INT iArgC, PCHAR ppcArgV[])
return (-ERROR_TSHELL_EPARAM);
}
- printf("block device %s total size: %llu (MB)\n", pcBlkFile, (statGet.st_size >> 20));
+ printf("block device %s total size: %llu (MB), reserved: %lu (KB)\n",
+ pcBlkFile, (statGet.st_size >> 20),
+ statGet.st_blksize * 2048 / 1024); /* 保留了 2048 个扇区 */
__input_num:
printf("please input how many partition(s) you want to make (1 ~ 4) : ");
diff --git a/SylixOS/shell/ttinyShell/ttinyShellLib.c b/SylixOS/shell/ttinyShell/ttinyShellLib.c
index d95d6cc..a7b86c7 100644
--- a/SylixOS/shell/ttinyShell/ttinyShellLib.c
+++ b/SylixOS/shell/ttinyShell/ttinyShellLib.c
@@ -66,6 +66,7 @@
2014.04.17 对重定向描述符的回收需要在内核 IO 环境中中进行.
2017.07.19 执行完每条命令后使用 fpurge(stdin) 清除输入缓存.
2018.12.13 有些命令必须使用强制内建命令.
+2021.05.25 重定向完成后, 需要清理标准文件的错误标志.
*********************************************************************************************************/
#define __SYLIXOS_STDIO
#define __SYLIXOS_KERNEL
@@ -405,6 +406,7 @@ static INT __tshellWrapper (FUNCPTR pfuncCommand, INT iArgC, PCHAR ppcArgV[]
INT iOldStd[3] = {PX_ERROR, PX_ERROR, PX_ERROR};
INT iRealArgc = iArgC;
INT iRet = PX_ERROR;
+ FILE *pFile;
LW_OBJECT_HANDLE ulMe = API_ThreadIdSelf();
@@ -441,6 +443,10 @@ static INT __tshellWrapper (FUNCPTR pfuncCommand, INT iArgC, PCHAR ppcArgV[]
__ret:
for (i = 0; i < 3; i++) { /* 还原旧的 */
API_IoTaskStdSet(ulMe, i, iOldStd[i]);
+ pFile = *lib_nlreent_stdfile(i);
+ if (pFile) {
+ clearerr(pFile);
+ }
}
for (i = 0; i < iPopCnt; i++) {
@@ -604,7 +610,7 @@ INT __tshellExec (CPCHAR pcCommandExec, VOIDFUNCPTR pfuncHook)
}
/*
- * 如果存在可执行文件则, 则优先运行文件.
+ * 如果存在可执行文件, 则优先运行文件.
*/
#if LW_CFG_MODULELOADER_EN > 0 /* 如果存在文件, 则优先运行 */
if (!__tshellIsResCmd(cKeyword)) {
diff --git a/SylixOS/shell/ttinyVar/ttinyVarLib.c b/SylixOS/shell/ttinyVar/ttinyVarLib.c
index 24cf229..3f299c7 100644
--- a/SylixOS/shell/ttinyVar/ttinyVarLib.c
+++ b/SylixOS/shell/ttinyVar/ttinyVarLib.c
@@ -597,11 +597,12 @@ ULONG __tshellVarGet (CPCHAR pcVarName, PCHAR *ppcVarValue)
** 功能描述: 设置一个变量的值
** 输 入 : pcVarName 变量名
** pcVarValue 变量的值
+** iIsOverwrite 是否覆盖
** 输 出 : 错误代码
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-ULONG __tshellVarSet (CPCHAR pcVarName, CPCHAR pcVarValue, INT iIsOverwrite)
+ULONG __tshellVarSet (CPCHAR pcVarName, CPCHAR pcVarValue, INT iIsOverwrite)
{
REGISTER PLW_LIST_LINE plineHash;
REGISTER __PTSHELL_VAR pskvNode = LW_NULL; /* 变量节点 */
diff --git a/SylixOS/system/device/semfd/semfdDev.c b/SylixOS/system/device/semfd/semfdDev.c
index ab7f454..8766f0b 100644
--- a/SylixOS/system/device/semfd/semfdDev.c
+++ b/SylixOS/system/device/semfd/semfdDev.c
@@ -857,7 +857,7 @@ static INT _semfdSetFnode (PLW_SEMFD_FILE psemfdfil, struct semfd_param *param
** 功能描述: semfd 获取文件缓存
** 输 入 : psemfdfil semfd 文件
** param 信号量参数
-** pulOwner 呼哧信号了拥有者
+** pulOwner 互斥信号量拥有者
** 输 出 : < 0 表示错误
** 全局变量:
** 调用模块:
diff --git a/SylixOS/system/ioLib/ioSys.c b/SylixOS/system/ioLib/ioSys.c
index c47b706..4044972 100644
--- a/SylixOS/system/ioLib/ioSys.c
+++ b/SylixOS/system/ioLib/ioSys.c
@@ -615,7 +615,7 @@ __again: /* 分配
}
pdevhdrHdr->DEVHDR_usDevNum = usDevNum;
- __LW_DEV_NUMINIT(iDrvNum) = usDevNum + 1; /* 添加如设备头链表 */
+ __LW_DEV_NUMINIT(iDrvNum) = usDevNum + 1; /* 添加入设备头链表 */
_List_Line_Add_Ahead(&pdevhdrHdr->DEVHDR_lineManage, &_S_plineDevHdrHeader);
_IosUnlock(); /* 退出 IO 临界区 */
diff --git a/SylixOS/system/signal/signal.c b/SylixOS/system/signal/signal.c
index d0e7941..607a163 100644
--- a/SylixOS/system/signal/signal.c
+++ b/SylixOS/system/signal/signal.c
@@ -640,7 +640,7 @@ INT sigrelse (INT iSigNo)
/*********************************************************************************************************
** 函数名称: sigpause
** 功能描述: 在当前掩码中清除指定的信号等待信号的到来, 然后返回先前的信号掩码.
-** 此 API 以被 sigsuspend 替代.
+** 此 API 已被 sigsuspend 替代.
** 输 入 : iSigMask 掩码
** 输 出 : ERROR
** 全局变量:
diff --git a/SylixOS/system/signal/signalLib.c b/SylixOS/system/signal/signalLib.c
index 336d1ea..79d17ff 100644
--- a/SylixOS/system/signal/signalLib.c
+++ b/SylixOS/system/signal/signalLib.c
@@ -822,7 +822,7 @@ VOID _signalInit (VOID)
#endif /* LW_CFG_THREAD_DEL_EN > 0 */
}
/*********************************************************************************************************
-** 函数名称: _sigGetMsb
+** 函数名称: _sigGetLsb
** 功能描述: 从一个信号集中获取信号数值. (优先递送信号值小的信号)
** 输 入 : psigset 信号集
** 输 出 : 信号数值