From 4495e8270c4f6b5ff4d5600c1df6f89a73112cd0 Mon Sep 17 00:00:00 2001 From: Hanhui Date: Thu, 14 Aug 2014 22:07:03 +0800 Subject: [PATCH 1/2] Fixed logo print bug. --- target/src/usrLib.c | 18 ++++++++---------- target/src/vxWorks.c | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/target/src/usrLib.c b/target/src/usrLib.c index 9a33bd4..4cc7256 100644 --- a/target/src/usrLib.c +++ b/target/src/usrLib.c @@ -73,21 +73,19 @@ void printLogo (void) " ]]]]]]]] ]]]]] ]]] ]]]]]]] ] ]]]]]]] ]]]] ]]]] ]]]] ]]]]]\n" " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n" " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]] Development System\n" - " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n"; + " ]]]]]]]]]]]]]]]]]]]]]]]]]]]]"; int fd; ssize_t num; char buffer[256]; - printf ("%s\n", logo); - - printf ("%s%s %s\n", - " ]]]]]]]]]]]]]]]]]]]]]]]]]]] ", runtimeName, runtimeVersion); - printf ("%s%s\n", - " ]]]]]]]]]]]]]]]]]]]]]]]]]] KERNEL: ", LIB_VXWORKS_VERSION); - printf ("%s\n", - " ]]]]]]]]]]]]]]]]]]]]]]]]] Copyright SylixOS Group. 2006-2014"); - + printf("%s\n", logo); + printf("%s%s %s\n", + " ]]]]]]]]]]]]]]]]]]]]]]]]]]] ", runtimeName, runtimeVersion); + printf("%s%s\n", + " ]]]]]]]]]]]]]]]]]]]]]]]]]] KERNEL: ", LIB_VXWORKS_VERSION); + printf("%s\n", + " ]]]]]]]]]]]]]]]]]]]]]]]]] Copyright SylixOS Group. 2006-2014"); printf ("\n"); fd = open("/proc/cpuinfo", O_RDONLY); diff --git a/target/src/vxWorks.c b/target/src/vxWorks.c index f848778..870ccc2 100644 --- a/target/src/vxWorks.c +++ b/target/src/vxWorks.c @@ -10,6 +10,7 @@ * Author: Han.hui */ +#define __SYLIXOS_KERNEL /* because we want use API_CacheLine() */ #include #include "vxWorks.h" #include "version.h" From ddc0ce8781b7d8a628741038a71ceae611a1488b Mon Sep 17 00:00:00 2001 From: Hanhui Date: Fri, 15 Aug 2014 17:05:42 +0800 Subject: [PATCH 2/2] Add vxCpuLib functions. --- Makefile | 1 + target/h/vxCpuLib.h | 38 ++++++++++++++++++++++++++++++ target/src/vxCpuLib.c | 54 +++++++++++++++++++++++++++++++++++++++++++ target/src/vxWorks.c | 1 - 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 target/h/vxCpuLib.h create mode 100644 target/src/vxCpuLib.c diff --git a/Makefile b/Makefile index 667fd84..7c86914 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ target/src/taskLib.c \ target/src/tickLib.c \ target/src/usrLib.c \ target/src/vxAtomicLib.c \ +target/src/vxCpuLib.c \ target/src/vxWorks.c \ target/src/wdLib.c diff --git a/target/h/vxCpuLib.h b/target/h/vxCpuLib.h new file mode 100644 index 0000000..e88cd64 --- /dev/null +++ b/target/h/vxCpuLib.h @@ -0,0 +1,38 @@ +/** + * @file + * CPU library header. + * + * VxWork compatibility layer in SylixOS. + * + * Copyright (c) 2001-2014 SylixOS Group. + * All rights reserved. + * + * Author: Han.hui + */ + +#ifndef __VXWORKS_VXCPULIB_H +#define __VXWORKS_VXCPULIB_H + +#include "vxWorksCommon.h" +#include + +/* + * CPU set + */ +typedef cpu_set_t cpuset_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* function declarations */ + +unsigned int vxCpuIndexGet(void); +cpuset_t vxCpuEnabledGet(void); +unsigned int vxCpuConfiguredGet(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __VXWORKS_VXCPULIB_H */ diff --git a/target/src/vxCpuLib.c b/target/src/vxCpuLib.c new file mode 100644 index 0000000..3fe7a2a --- /dev/null +++ b/target/src/vxCpuLib.c @@ -0,0 +1,54 @@ +/** + * @file + * CPU library. + * + * VxWork compatibility layer in SylixOS. + * + * Copyright (c) 2001-2014 SylixOS Group. + * All rights reserved. + * + * Author: Han.hui + */ + +#define __SYLIXOS_KERNEL +#include +#include "vxCpuLib.h" + +/* + * get current CPU index. + */ +unsigned int vxCpuIndexGet (void) +{ + INTREG ireg; + ULONG id; + + API_InterLock(&ireg); + id = LW_CPU_GET_CUR_ID(); + API_InterUnlock(ireg); + + return ((unsigned int)id); +} + +/* + * get enable CPU index. + */ +cpuset_t vxCpuEnabledGet (void) +{ + static cpuset_t set; + + sched_getaffinity(getpid(), sizeof(set), &set); + + return (set); +} + +/* + * get CPU count. + */ +unsigned int vxCpuConfiguredGet (void) +{ + return ((unsigned int)sysconf(_SC_NPROCESSORS_CONF)); +} + +/* + * end + */ diff --git a/target/src/vxWorks.c b/target/src/vxWorks.c index 870ccc2..f848778 100644 --- a/target/src/vxWorks.c +++ b/target/src/vxWorks.c @@ -10,7 +10,6 @@ * Author: Han.hui */ -#define __SYLIXOS_KERNEL /* because we want use API_CacheLine() */ #include #include "vxWorks.h" #include "version.h"