zephyr/include/init.h
Benjamin Walsh 629e1dd861 init: add SYS_INIT()
This is to be used by subsystem that don't really want to create a
device but rather only want to be initialized automatically during the
kernel init sequence. It is just a wrapper around DEVICE_INIT(), and
thus still uses a device object, but it hides that fact and can be
replaced in the future without changing its model.

It can be used when a device created does not have objects associated
with it, but only an init function, and also when the device name
(DEVICE_INIT(<dev_name>, ...) does not matter.

Change-Id: I5488f430a6fb757cdcb499ef352775dc67aa0565
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00

49 lines
1.4 KiB
C

/*
* Copyright (c) 2015 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _INIT_H_
#define _INIT_H_
#include <device.h>
#include <toolchain.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* System initialization levels. The PRIMARY and SECONDARY levels are
* executed in the kernel's initialization context, which uses the interrupt
* stack. The remaining levels are executed in the kernel's main task
* (i.e. the nanokernel's background task or the microkernel's idle task).
*/
#define _SYS_INIT_LEVEL_PRIMARY 0
#define _SYS_INIT_LEVEL_SECONDARY 1
#define _SYS_INIT_LEVEL_NANOKERNEL 2
#define _SYS_INIT_LEVEL_MICROKERNEL 3
#define _SYS_INIT_LEVEL_APPLICATION 4
#define SYS_INIT(init_fn, level, prio) \
DEVICE_INIT(sys_init_##init_fn, "", init_fn, NULL, NULL, level, prio)
#ifdef __cplusplus
}
#endif
#endif /* _INIT_H_ */