device: Add device model infrastructure
Add infrastructure support having multiple instances of a driver configured into the system each with its own compile time configuration information. Change-Id: I1e447af18311139b43f74fe0439483ccd132b63f Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
This commit is contained in:
parent
4ef2d598cc
commit
c9ac95a43a
6 changed files with 286 additions and 1 deletions
68
include/init.h
Normal file
68
include/init.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
|
||||
/* 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>
|
||||
#define __used __attribute__((__used__))
|
||||
|
||||
/*! @def __define_initconfig
|
||||
*
|
||||
* @brief Define an init object
|
||||
*
|
||||
* @details This macro declares an init object to be placed a
|
||||
* given init level section in the image. This macro not should be used
|
||||
* 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.
|
||||
*
|
||||
* @sa DECLARE_DEVICE_INIT_CONFIG()
|
||||
*/
|
||||
#define __define_initconfig(cfg_name, id) \
|
||||
static struct device (__initconfig_##cfg_name##id) __used \
|
||||
__attribute__((__section__(".initconfig" #id ".init"))) = { \
|
||||
.config = &(config_##cfg_name)};
|
||||
|
||||
#define pure_init(cfg) __define_initconfig(cfg, 0)
|
||||
#define nano_early_init(cfg) __define_initconfig(cfg, 1)
|
||||
#define nano_late_init(cfg) __define_initconfig(cfg, 2)
|
||||
#define micro_early_init(cfg) __define_initconfig(cfg, 3)
|
||||
#define micro_late_init(cfg) __define_initconfig(cfg, 4)
|
||||
#define pre_app_init(cfg) __define_initconfig(cfg, 5)
|
||||
#define late_initconfig(cfg) __define_initconfig(cfg, 6)
|
||||
|
||||
|
||||
#endif /* _INIT_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue