2015-06-02 02:11:39 +08:00
|
|
|
|
|
|
|
/* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1) Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* 3) Neither the name of Intel Corporation nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INIT_H_
|
|
|
|
#define _INIT_H_
|
|
|
|
|
|
|
|
#include <device.h>
|
2015-08-05 07:37:35 +08:00
|
|
|
#include <toolchain.h>
|
2015-06-02 02:11:39 +08:00
|
|
|
|
2015-09-26 04:02:12 +08:00
|
|
|
#define PRE_KERNEL_CORE 0
|
2015-09-26 04:02:12 +08:00
|
|
|
#define PRE_KERNEL_EARLY 1
|
|
|
|
#define PRE_KERNEL_LATE 2
|
|
|
|
#define NANO_EARLY 3
|
|
|
|
#define NANO_LATE 4
|
|
|
|
#define MICRO_EARLY 5
|
|
|
|
#define MICRO_LATE 6
|
|
|
|
#define APP_EARLY 7
|
|
|
|
#define APP_LATE 8
|
2015-07-11 02:52:53 +08:00
|
|
|
|
2015-07-02 04:47:13 +08:00
|
|
|
/** @def __define_initconfig
|
2015-06-02 02:11:39 +08:00
|
|
|
*
|
|
|
|
* @brief Define an init object
|
|
|
|
*
|
2015-07-11 02:52:53 +08:00
|
|
|
* @details This macro declares an init object to be placed in a
|
|
|
|
* given init level section in the image. This macro should not be used
|
2015-06-02 02:11:39 +08:00
|
|
|
* directly.
|
|
|
|
*
|
|
|
|
* @param cfg_name Name of the config object created with
|
|
|
|
* DECLARE_DEVICE_INIT_CONFIG() macro that will be referenced by
|
|
|
|
* init object.
|
|
|
|
*
|
|
|
|
* @param id The init level id where the init object will be placed
|
|
|
|
* in the image.
|
|
|
|
*
|
2015-09-18 00:59:48 +08:00
|
|
|
* @param data The pointer to the driver data for the driver instance.
|
2015-06-02 02:11:39 +08:00
|
|
|
* @sa DECLARE_DEVICE_INIT_CONFIG()
|
|
|
|
*/
|
2015-06-11 23:13:09 +08:00
|
|
|
#define __define_initconfig(cfg_name, id, data) \
|
2015-06-02 02:11:39 +08:00
|
|
|
static struct device (__initconfig_##cfg_name##id) __used \
|
|
|
|
__attribute__((__section__(".initconfig" #id ".init"))) = { \
|
2015-06-11 23:13:09 +08:00
|
|
|
.config = &(config_##cfg_name),\
|
2015-07-06 23:34:51 +08:00
|
|
|
.driver_data = data}
|
2015-09-26 04:02:12 +08:00
|
|
|
/*
|
|
|
|
* There are four distinct init levels, pre_kernel, nano, micro
|
|
|
|
* and app. Each init level a unique set of restrictions placed on the
|
|
|
|
* component being initialized within the level.
|
|
|
|
* pre_kernel:
|
|
|
|
* At this level no kernel objects or services are available to
|
|
|
|
* the component. pre_kernel has three phases, core, early and
|
|
|
|
* late. The core phase is intended for components that rely
|
|
|
|
* solely on hardware present in the processor/SOC and do *not*
|
|
|
|
* rely on services from any other component in the system. The
|
|
|
|
* early phase can be used by components that do *not* need kernel
|
|
|
|
* services and may rely on components from the core phase. The
|
|
|
|
* late phase can be used by components that do *not* need kernel
|
|
|
|
* services and may rely on components from the core and early
|
|
|
|
* phases.
|
|
|
|
* nano:
|
|
|
|
* At this level nano kernel services are available to the
|
|
|
|
* component. All services provided by the components initialized
|
|
|
|
* in the pre_kernel are also available. The nano level has an
|
|
|
|
* early and late phase. Components in the early phase may rely
|
|
|
|
* on the nano kernel and pre_kernel services. Components in the
|
|
|
|
* late phase may rely on, nano kernel, pre_kernel services and
|
|
|
|
* nano_early services
|
|
|
|
* micro:
|
|
|
|
* At this level micro kernel, nano kernel and pre_kernel services
|
|
|
|
* are available to the component. The micor level has an
|
|
|
|
* early and late phase. Components in the early phase may rely
|
|
|
|
* on micro kernel, nano kernel and pre_kernel services.
|
|
|
|
* Components in the late phase may rely on, micro kernel, nano
|
|
|
|
* kernel, pre_kernel services and micro_early services
|
|
|
|
* app:
|
|
|
|
* The app level is not intended for core kernel components but for
|
|
|
|
* the application developer to add any components that they wish to
|
|
|
|
* have initialized automatically during kernel initialization. The
|
|
|
|
* app level is executed as the final init stage in both nanokernel
|
|
|
|
* and microkernel configurations. The application component may
|
|
|
|
* rely any component configured into the system.
|
|
|
|
*/
|
2015-06-02 02:11:39 +08:00
|
|
|
|
2015-09-26 04:02:12 +08:00
|
|
|
/* Run on pre_kernel stack; no {micro,nano} kernel objects available */
|
2015-09-26 04:02:12 +08:00
|
|
|
#define pre_kernel_core_init(cfg, data) __define_initconfig(cfg, 0, data)
|
|
|
|
#define pre_kernel_early_init(cfg, data) __define_initconfig(cfg, 1, data)
|
|
|
|
#define pre_kernel_late_init(cfg, data) __define_initconfig(cfg, 2, data)
|
2015-06-24 23:22:56 +08:00
|
|
|
|
|
|
|
/* Run from nano kernel idle task; no micro kernel objects available */
|
2015-09-26 04:02:12 +08:00
|
|
|
#define nano_early_init(cfg, data) __define_initconfig(cfg, 3, data)
|
|
|
|
#define nano_late_init(cfg, data) __define_initconfig(cfg, 4, data)
|
2015-06-24 23:22:56 +08:00
|
|
|
|
|
|
|
/* Run from micro kernel idle task. */
|
2015-09-26 04:02:12 +08:00
|
|
|
#define micro_early_init(cfg, data) __define_initconfig(cfg, 5, data)
|
|
|
|
#define micro_late_init(cfg, data) __define_initconfig(cfg, 6, data)
|
2015-06-24 23:22:56 +08:00
|
|
|
|
|
|
|
/* Run in the idle task; In a nano kernel only system run after
|
|
|
|
* nano_late_init(). In a micro kernel system after micro_late_init()
|
|
|
|
*/
|
2015-09-26 04:02:12 +08:00
|
|
|
#define app_early_init(cfg, data) __define_initconfig(cfg, 7, data)
|
|
|
|
#define app_late_init(cfg, data) __define_initconfig(cfg, 8, data)
|
2015-06-02 02:11:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* _INIT_H_ */
|