[Xenomai-git] Philippe Gerum : vxworks: add task hook services
Module: xenomai-3 Branch: next Commit: 92a4a8f21cd4d9f7bd29540fcd1fe129eb4ecf94 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=92a4a8f21cd4d9f7bd29540fcd1fe129eb4ecf94 Author: Philippe Gerum r...@xenomai.org Date: Mon Apr 20 17:08:14 2015 +0200 vxworks: add task hook services Create and delete task event hooks are supported, switch hook is not since we don't control scheduling. Hooks are process-local. --- include/vxworks/Makefile.am |1 + include/vxworks/taskHookLib.h | 46 ++ lib/vxworks/Makefile.am |2 + lib/vxworks/taskHookLib.c | 107 + lib/vxworks/taskHookLib.h | 37 ++ lib/vxworks/taskLib.c |2 + 6 files changed, 195 insertions(+) diff --git a/include/vxworks/Makefile.am b/include/vxworks/Makefile.am index f880426..849fbdf 100644 --- a/include/vxworks/Makefile.am +++ b/include/vxworks/Makefile.am @@ -10,6 +10,7 @@ includesub_HEADERS = \ rngLib.h\ semLib.h\ sysLib.h\ + taskHookLib.h \ taskInfo.h \ taskLib.h \ tickLib.h \ diff --git a/include/vxworks/taskHookLib.h b/include/vxworks/taskHookLib.h new file mode 100644 index 000..132786e --- /dev/null +++ b/include/vxworks/taskHookLib.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 Philippe Gerum r...@xenomai.org. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * This file satisfies the references within the emulator code + * mimicking a VxWorks-like API built upon the copperplate library. + * + * VxWorks is a registered trademark of Wind River Systems, Inc. + */ + +#ifndef _XENOMAI_VXWORKS_TASKHOOKLIB_H +#define _XENOMAI_VXWORKS_TASKHOOKLIB_H + +#include vxworks/types.h +#include vxworks/taskLib.h + +#ifdef __cplusplus +extern C { +#endif + +STATUS taskCreateHookAdd(FUNCPTR createHook); + +STATUS taskCreateHookDelete(FUNCPTR createHook); + +STATUS taskDeleteHookAdd(FUNCPTR deleteHook); + +STATUS taskDeleteHookDelete(FUNCPTR deleteHook); + +#ifdef __cplusplus +} +#endif + +#endif /* !_XENOMAI_VXWORKS_TASKHOOKLIB_H */ diff --git a/lib/vxworks/Makefile.am b/lib/vxworks/Makefile.am index f012f3e..483d811 100644 --- a/lib/vxworks/Makefile.am +++ b/lib/vxworks/Makefile.am @@ -19,6 +19,8 @@ libvxworks_la_SOURCES = \ semLib.h\ taskLib.c \ taskLib.h \ + taskHookLib.c \ + taskHookLib.h \ taskInfo.c \ tickLib.c \ tickLib.h \ diff --git a/lib/vxworks/taskHookLib.c b/lib/vxworks/taskHookLib.c new file mode 100644 index 000..bf61b79 --- /dev/null +++ b/lib/vxworks/taskHookLib.c @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2015 Philippe Gerum r...@xenomai.org. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include copperplate/heapobj.h +#include vxworks/taskHookLib.h +#include vxworks/errnoLib.h +#include taskLib.h +#include taskHookLib.h + +DEFINE_PRIVATE_LIST(wind_create_hooks); + +DEFINE_PRIVATE_LIST(wind_delete_hooks); + +static STATUS add_hook(struct pvlist *list, FUNCPTR hook, int prepend) +{ + struct wind_task_hook *p; + + p = xnmalloc(sizeof(*p)); + if (p == NULL) + return ERROR; + + p-handler = (void (*)(TASK_ID))hook; + write_lock_nocancel(wind_task_lock); + + if (prepend) + pvlist_prepend(p-next, list); + else + pvlist_append(p-next, list); + + write_unlock(wind_task_lock); + + return OK; +} + +static STATUS remove_hook(struct pvlist *list,
[Xenomai-git] Philippe Gerum : vxworks: add task hook services
Module: xenomai-3 Branch: next Commit: 31174fe55b03eb4d91005807a6eed7dbdcfcf82d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=31174fe55b03eb4d91005807a6eed7dbdcfcf82d Author: Philippe Gerum r...@xenomai.org Date: Mon Apr 20 17:08:14 2015 +0200 vxworks: add task hook services Create and delete task event hooks are supported, switch hook is not since we don't control scheduling. Hooks are process-local. --- include/vxworks/Makefile.am |1 + include/vxworks/taskHookLib.h | 46 ++ lib/vxworks/Makefile.am |2 + lib/vxworks/taskHookLib.c | 107 + lib/vxworks/taskHookLib.h | 37 ++ lib/vxworks/taskLib.c |4 ++ 6 files changed, 197 insertions(+) diff --git a/include/vxworks/Makefile.am b/include/vxworks/Makefile.am index f880426..849fbdf 100644 --- a/include/vxworks/Makefile.am +++ b/include/vxworks/Makefile.am @@ -10,6 +10,7 @@ includesub_HEADERS = \ rngLib.h\ semLib.h\ sysLib.h\ + taskHookLib.h \ taskInfo.h \ taskLib.h \ tickLib.h \ diff --git a/include/vxworks/taskHookLib.h b/include/vxworks/taskHookLib.h new file mode 100644 index 000..132786e --- /dev/null +++ b/include/vxworks/taskHookLib.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 Philippe Gerum r...@xenomai.org. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * This file satisfies the references within the emulator code + * mimicking a VxWorks-like API built upon the copperplate library. + * + * VxWorks is a registered trademark of Wind River Systems, Inc. + */ + +#ifndef _XENOMAI_VXWORKS_TASKHOOKLIB_H +#define _XENOMAI_VXWORKS_TASKHOOKLIB_H + +#include vxworks/types.h +#include vxworks/taskLib.h + +#ifdef __cplusplus +extern C { +#endif + +STATUS taskCreateHookAdd(FUNCPTR createHook); + +STATUS taskCreateHookDelete(FUNCPTR createHook); + +STATUS taskDeleteHookAdd(FUNCPTR deleteHook); + +STATUS taskDeleteHookDelete(FUNCPTR deleteHook); + +#ifdef __cplusplus +} +#endif + +#endif /* !_XENOMAI_VXWORKS_TASKHOOKLIB_H */ diff --git a/lib/vxworks/Makefile.am b/lib/vxworks/Makefile.am index f012f3e..483d811 100644 --- a/lib/vxworks/Makefile.am +++ b/lib/vxworks/Makefile.am @@ -19,6 +19,8 @@ libvxworks_la_SOURCES = \ semLib.h\ taskLib.c \ taskLib.h \ + taskHookLib.c \ + taskHookLib.h \ taskInfo.c \ tickLib.c \ tickLib.h \ diff --git a/lib/vxworks/taskHookLib.c b/lib/vxworks/taskHookLib.c new file mode 100644 index 000..bf61b79 --- /dev/null +++ b/lib/vxworks/taskHookLib.c @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2015 Philippe Gerum r...@xenomai.org. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include copperplate/heapobj.h +#include vxworks/taskHookLib.h +#include vxworks/errnoLib.h +#include taskLib.h +#include taskHookLib.h + +DEFINE_PRIVATE_LIST(wind_create_hooks); + +DEFINE_PRIVATE_LIST(wind_delete_hooks); + +static STATUS add_hook(struct pvlist *list, FUNCPTR hook, int prepend) +{ + struct wind_task_hook *p; + + p = xnmalloc(sizeof(*p)); + if (p == NULL) + return ERROR; + + p-handler = (void (*)(TASK_ID))hook; + write_lock_nocancel(wind_task_lock); + + if (prepend) + pvlist_prepend(p-next, list); + else + pvlist_append(p-next, list); + + write_unlock(wind_task_lock); + + return OK; +} + +static STATUS remove_hook(struct pvlist *list,