summaryrefslogtreecommitdiffstatsabout
path: root/SylixOS
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2020-09-03 09:48:59 (GMT)
committer Hanhui <hanhui@acoinfo.com>2020-09-03 09:48:59 (GMT)
commitfa51d81059cd5996bbc34cc97b487b366ee80c5d (patch)
treebd08b0e3947694f49cfb12bde9e04434db5b19a1 /SylixOS
parent910117c56d5e922f25de6548a71fd0a515f6894b (diff)
downloadlibsylixos-fa51d81059cd5996bbc34cc97b487b366ee80c5d.zip
libsylixos-fa51d81059cd5996bbc34cc97b487b366ee80c5d.tar.gz
libsylixos-fa51d81059cd5996bbc34cc97b487b366ee80c5d.tar.bz2
The version number is upgraded to 2.0.0! add some quick task context interfaces.
Diffstat (limited to 'SylixOS')
-rw-r--r--SylixOS/api/Lw_Api_Kernel.h2
-rw-r--r--SylixOS/arch/x86/apic/x86IoApic.c5
-rw-r--r--SylixOS/kernel/include/k_api.h4
-rw-r--r--SylixOS/kernel/include/k_kernel.h10
-rw-r--r--SylixOS/kernel/interface/ThreadGetNotePad.c4
-rw-r--r--SylixOS/kernel/interface/ThreadIdSelf.c51
-rw-r--r--SylixOS/vpmpdm/ptmalloc3/sysdeps/pthread/malloc-machine.h22
7 files changed, 87 insertions, 11 deletions
diff --git a/SylixOS/api/Lw_Api_Kernel.h b/SylixOS/api/Lw_Api_Kernel.h
index e68d501..71d8522 100644
--- a/SylixOS/api/Lw_Api_Kernel.h
+++ b/SylixOS/api/Lw_Api_Kernel.h
@@ -99,7 +99,7 @@
#define Lw_Thread_Create API_ThreadCreate
#define Lw_Thread_Init API_ThreadInit
#define Lw_Thread_Self API_ThreadIdSelf
-#define Lw_Thread_Tcb API_ThreadTcbSelf
+#define Lw_Thread_SelfFast API_ThreadIdSelfFast
#define Lw_Thread_Desc API_ThreadDesc
diff --git a/SylixOS/arch/x86/apic/x86IoApic.c b/SylixOS/arch/x86/apic/x86IoApic.c
index beff441..600bed8 100644
--- a/SylixOS/arch/x86/apic/x86IoApic.c
+++ b/SylixOS/arch/x86/apic/x86IoApic.c
@@ -217,9 +217,8 @@ static PX86_IOAPIC_INTR __x86IoApicIntrLookup (UINT8 ucIrq, UINT8 *pucRedNum)
INT i;
for (i = 0; i < _G_uiX86IoApicNr; i++) {
- pIoApicIntr = &_G_x86IoApicIntrs[i];
-
- uiIoApicIdOffset = _G_x86IoApicIntrs->IOAPIC_ucId - _G_ucX86MpApicIoBaseId;
+ pIoApicIntr = &_G_x86IoApicIntrs[i];
+ uiIoApicIdOffset = pIoApicIntr->IOAPIC_ucId - _G_ucX86MpApicIoBaseId;
if ((ucIrq >= (uiIoApicIdOffset * _G_uiX86IoApicRedEntriesNr)) &&
(ucIrq < ((uiIoApicIdOffset + 1) * _G_uiX86IoApicRedEntriesNr))) {
diff --git a/SylixOS/kernel/include/k_api.h b/SylixOS/kernel/include/k_api.h
index dcc3daa..f1ba9f7 100644
--- a/SylixOS/kernel/include/k_api.h
+++ b/SylixOS/kernel/include/k_api.h
@@ -282,9 +282,13 @@ LW_API ULONG API_ThreadRestartEx(LW_OBJECT_HANDLE ulId,
LW_API LW_OBJECT_HANDLE API_ThreadIdSelf(VOID); /* 获得线程自己的句柄 */
+LW_API LW_OBJECT_HANDLE API_ThreadIdSelfFast(VOID);
+
#ifdef __SYLIXOS_KERNEL
LW_API PLW_CLASS_TCB API_ThreadTcbSelf(VOID); /* 获得线程自己的 TCB */
+LW_API PLW_CLASS_TCB API_ThreadTcbSelfFast(VOID);
+
LW_API LW_OBJECT_HANDLE API_ThreadIdInter(VOID); /* 获得被中断线程 ID */
LW_API PLW_CLASS_TCB API_ThreadTcbInter(VOID); /* 获得被中断线程 TCB */
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index 0d07943..c429bad 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -32,6 +32,8 @@
2016.10.08 修改项目代号为: LongYuan(龙渊).
2018.01.18 修改项目代号为: Octopus(八爪鱼).
2019.06.19 修改项目代号为: Tangram(七巧板).
+2020.09.02 升级版本到 2.0.
+ 修改项目代号为: Enterprise(进取).
*********************************************************************************************************/
#ifndef __K_KERNEL_H
@@ -49,9 +51,9 @@
版本号
*********************************************************************************************************/
-#define __SYLIXOS_MAJOR_VER 1
-#define __SYLIXOS_MINOR_VER 12
-#define __SYLIXOS_PATCH_VER 8
+#define __SYLIXOS_MAJOR_VER 2
+#define __SYLIXOS_MINOR_VER 0
+#define __SYLIXOS_PATCH_VER 0
#define __SYLIXOS_PATCH_PAD 0
/*********************************************************************************************************
@@ -81,7 +83,7 @@
__SYLIXOS_PATCH_VER, \
__SYLIXOS_PATCH_PAD)
-#define __SYLIXOS_RELSTR "Tangram"
+#define __SYLIXOS_RELSTR "Enterprise"
#define __SYLIXOS_VERINFO "SylixOS kernel version: " \
__SYLIXOS_VERSTR \
" Code name: " __SYLIXOS_RELSTR
diff --git a/SylixOS/kernel/interface/ThreadGetNotePad.c b/SylixOS/kernel/interface/ThreadGetNotePad.c
index 73b873a..3c0c9f3 100644
--- a/SylixOS/kernel/interface/ThreadGetNotePad.c
+++ b/SylixOS/kernel/interface/ThreadGetNotePad.c
@@ -128,9 +128,7 @@ ULONG API_ThreadCurNotePad (UINT8 ucNoteIndex)
LW_API
ULONG API_ThreadFastNotePad (UINT8 ucNoteIndex)
{
- REGISTER PLW_CLASS_TCB ptcbCur;
-
- asm volatile ("mov %0, x18" : "=r"(ptcbCur));
+ REGISTER PLW_CLASS_TCB ptcbCur asm("x18"); /* x18 saved current tcb */
return (ptcbCur->TCB_notepadThreadNotePad.NOTEPAD_ulNotePad[ucNoteIndex]);
}
diff --git a/SylixOS/kernel/interface/ThreadIdSelf.c b/SylixOS/kernel/interface/ThreadIdSelf.c
index 67fa6f5..1dad25e 100644
--- a/SylixOS/kernel/interface/ThreadIdSelf.c
+++ b/SylixOS/kernel/interface/ThreadIdSelf.c
@@ -22,6 +22,7 @@
2007.07.18 加入 _DebugHandle() 功能
2009.10.12 加入提示注释.
2013.07.18 使用新的获取 TCB 的方法, 确保 SMP 系统安全.
+2020.09.02 加入 Fast 获取方法.
*********************************************************************************************************/
#define __SYLIXOS_KERNEL
#include "../SylixOS/kernel/include/k_kernel.h"
@@ -52,6 +53,31 @@ LW_OBJECT_HANDLE API_ThreadIdSelf (VOID)
return (ptcbCur->TCB_ulId);
}
/*********************************************************************************************************
+** 函数名称: API_ThreadIdSelfFast
+** 功能描述: 当前线程 ID
+** 输 入 : NONE
+** 输 出 : ID
+** 全局变量:
+** 调用模块:
+ API 函数
+
+ (不得在中断中调用)
+*********************************************************************************************************/
+LW_API
+LW_OBJECT_HANDLE API_ThreadIdSelfFast (VOID)
+{
+#if LW_CFG_ARM64_FAST_TCB_CUR > 0
+ REGISTER PLW_CLASS_TCB ptcbCur asm("x18"); /* x18 saved current tcb */
+
+#else
+ REGISTER PLW_CLASS_TCB ptcbCur;
+
+ LW_TCB_GET_CUR_SAFE(ptcbCur);
+#endif
+
+ return (ptcbCur->TCB_ulId);
+}
+/*********************************************************************************************************
** 函数名称: API_ThreadTcbSelf
** 功能描述: 当前线程 TCB (危险...)
** 输 入 : NONE
@@ -78,6 +104,31 @@ PLW_CLASS_TCB API_ThreadTcbSelf (VOID)
return (ptcbCur);
}
/*********************************************************************************************************
+** 函数名称: API_ThreadTcbSelfFast
+** 功能描述: 当前线程 TCB (危险...)
+** 输 入 : NONE
+** 输 出 : TCB
+** 全局变量:
+** 调用模块:
+ API 函数
+
+ (不得在中断中调用)
+*********************************************************************************************************/
+LW_API
+PLW_CLASS_TCB API_ThreadTcbSelfFast (VOID)
+{
+#if LW_CFG_ARM64_FAST_TCB_CUR > 0
+ REGISTER PLW_CLASS_TCB ptcbCur asm("x18"); /* x18 saved current tcb */
+
+#else
+ REGISTER PLW_CLASS_TCB ptcbCur;
+
+ LW_TCB_GET_CUR_SAFE(ptcbCur);
+#endif
+
+ return (ptcbCur);
+}
+/*********************************************************************************************************
** 函数名称: API_ThreadIdInter
** 功能描述: 当前被中断线程 ID, BSP 中断程序使用
** 输 入 : NONE
diff --git a/SylixOS/vpmpdm/ptmalloc3/sysdeps/pthread/malloc-machine.h b/SylixOS/vpmpdm/ptmalloc3/sysdeps/pthread/malloc-machine.h
index 04767e3..a044447 100644
--- a/SylixOS/vpmpdm/ptmalloc3/sysdeps/pthread/malloc-machine.h
+++ b/SylixOS/vpmpdm/ptmalloc3/sysdeps/pthread/malloc-machine.h
@@ -27,6 +27,11 @@ PERFORMANCE OF THIS SOFTWARE.
#include <pthread.h>
+/* SylixOS use this hack method to speed up */
+#ifndef USE_TSD_DATA_HACK
+#define USE_TSD_DATA_HACK
+#endif
+
#undef thread_atfork_static
/* Use fast inline spinlocks with gcc. */
@@ -117,6 +122,21 @@ typedef pthread_spinlock_t mutex_t;
The hack only works when pthread_t can be converted to an integral
type. */
+#ifdef SYLIXOS
+
+#define TSD_HACK_KEY_SIZE 32
+typedef void *tsd_key_t[TSD_HACK_KEY_SIZE];
+
+#define tsd_key_create(key, destr) do { \
+ bzero(key, sizeof(void *) * TSD_HACK_KEY_SIZE); \
+} while(0)
+#define tsd_setspecific(key, data) \
+ (key[(unsigned)Lw_Thread_SelfFast() % TSD_HACK_KEY_SIZE] = (data))
+#define tsd_getspecific(key, vptr) \
+ (vptr = key[(unsigned)Lw_Thread_SelfFast() % TSD_HACK_KEY_SIZE])
+
+#else /* SYLIXOS */
+
typedef void *tsd_key_t[256];
#define tsd_key_create(key, destr) do { \
int i; \
@@ -127,6 +147,8 @@ typedef void *tsd_key_t[256];
#define tsd_getspecific(key, vptr) \
(vptr = key[(unsigned)pthread_self() % 256])
+#endif /* !SYLIXOS */
+
#else
typedef pthread_key_t tsd_key_t;