Commit 942876b8 authored by Florian Bezdeka's avatar Florian Bezdeka Committed by Jan Kiszka

lib/cobalt: Introduce generic feature initialization and check API

The feature initialization was arch specific up to now and the
available features (= features offered by the currently running kernel)
were no longer accessible once the bind syscall finished.

This patch introduces a simple API for fetching the offered features
during runtime.
Signed-off-by: default avatarFlorian Bezdeka <florian.bezdeka@siemens.com>
[Jan: simplify cobalt_features_available]
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 75553fbd
......@@ -177,7 +177,7 @@ static void low_init(void)
early_panic("mlockall: %s", strerror(errno));
trace_me("memory locked");
cobalt_arch_check_features(f);
cobalt_features_init(f);
cobalt_init_umm(f->vdso_offset);
trace_me("memory heaps mapped");
cobalt_init_current_keys();
......
......@@ -565,3 +565,13 @@ void cobalt_assert_nrt(void)
if (cobalt_should_warn())
pthread_kill(pthread_self(), SIGDEBUG);
}
unsigned int cobalt_features;
void cobalt_features_init(struct cobalt_featinfo *f)
{
cobalt_features = f->feat_all;
/* Trigger arch specific feature initialization */
cobalt_arch_check_features(f);
}
\ No newline at end of file
......@@ -19,6 +19,7 @@
#define _LIB_COBALT_INTERNAL_H
#include <limits.h>
#include <stdbool.h>
#include <boilerplate/ancillaries.h>
#include <cobalt/sys/cobalt.h>
#include "current.h"
......@@ -86,10 +87,6 @@ int cobalt_xlate_schedparam(int policy,
struct sched_param *param);
int cobalt_init(void);
struct cobalt_featinfo;
void cobalt_arch_check_features(struct cobalt_featinfo *finfo);
extern struct sigaction __cobalt_orig_sigdebug;
extern int __cobalt_std_fifo_minpri,
......@@ -98,4 +95,35 @@ extern int __cobalt_std_fifo_minpri,
extern int __cobalt_std_rr_minpri,
__cobalt_std_rr_maxpri;
extern unsigned int cobalt_features;
struct cobalt_featinfo;
/**
* Arch specific feature initialization
*
* @param finfo
*/
void cobalt_arch_check_features(struct cobalt_featinfo *finfo);
/**
* Initialize the feature handling.
*
* @param f Feature info that will be cached for future feature checks
*/
void cobalt_features_init(struct cobalt_featinfo *f);
/**
* Check if a given set of features is available / provided by the kernel
*
* @param feat_mask A bit mask of features to check availability for. See
* __xn_feat_* macros for a list of defined features
*
* @return true if all features are available, false otherwise
*/
static inline bool cobalt_features_available(unsigned int feat_mask)
{
return (cobalt_features & feat_mask) == feat_mask;
}
#endif /* _LIB_COBALT_INTERNAL_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment