Browse Source

Merge branch 'master' of sylixos.com:libVxWorks

master
Jiaojinxing 10 years ago
parent
commit
18775a91f9
  1. 1
      Makefile
  2. 38
      target/h/vxCpuLib.h
  3. 18
      target/src/usrLib.c
  4. 54
      target/src/vxCpuLib.c

1
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

38
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 <sylixos@gmail.com>
*/
#ifndef __VXWORKS_VXCPULIB_H
#define __VXWORKS_VXCPULIB_H
#include "vxWorksCommon.h"
#include <sched.h>
/*
* 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 */

18
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);

54
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 <sylixos@gmail.com>
*/
#define __SYLIXOS_KERNEL
#include <unistd.h>
#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
*/
Loading…
Cancel
Save