Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
test_driver_init.c File Reference
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <zephyr/ztest.h>
#include <zephyr/linker/sections.h>

Data Structures

struct  my_driver_api
 

Macros

#define MY_DRIVER_LV_1   "my_driver_level_1"
 Test cases to device driver initialization.
 
#define MY_DRIVER_LV_2   "my_driver_level_2"
 
#define MY_DRIVER_LV_3   "my_driver_level_3"
 
#define MY_DRIVER_PRI_1   "my_driver_priority_1"
 
#define MY_DRIVER_PRI_2   "my_driver_priority_2"
 
#define MY_DRIVER_PRI_3   "my_driver_priority_3"
 
#define MY_DRIVER_PRI_4   "my_driver_priority_4"
 
#define LEVEL_PRE_KERNEL_1   1
 
#define LEVEL_PRE_KERNEL_2   2
 
#define LEVEL_POST_KERNEL   3
 
#define PRIORITY_1   1
 
#define PRIORITY_2   2
 
#define PRIORITY_3   3
 
#define PRIORITY_4   4
 

Typedefs

typedef int(* my_api_configure_t) (const struct device *dev, int dev_config)
 

Functions

static int my_configure (const struct device *dev, int config)
 
static __pinned_func int my_driver_lv_1_init (const struct device *dev)
 
static __pinned_func int my_driver_lv_2_init (const struct device *dev)
 
static int my_driver_lv_3_init (const struct device *dev)
 
static int my_driver_pri_1_init (const struct device *dev)
 
static int my_driver_pri_2_init (const struct device *dev)
 
static int my_driver_pri_3_init (const struct device *dev)
 
static int my_driver_pri_4_init (const struct device *dev)
 
static int my_driver_sub_pri_0_init (const struct device *dev)
 
static int my_driver_sub_pri_1_init (const struct device *dev)
 
static int my_driver_sub_pri_2_init (const struct device *dev)
 
 DEVICE_DT_DEFINE (DT_NODELABEL(fakedomain_0), my_driver_sub_pri_0_init, NULL, NULL, NULL, POST_KERNEL, 33, NULL)
 Test providing control device driver initialization order.
 
 DEVICE_DT_DEFINE (DT_NODELABEL(fakedomain_1), my_driver_sub_pri_1_init, NULL, NULL, NULL, POST_KERNEL, 33, NULL)
 
 DEVICE_DT_DEFINE (DT_NODELABEL(fakedomain_2), my_driver_sub_pri_2_init, NULL, NULL, NULL, POST_KERNEL, 33, NULL)
 

Variables

__pinned_bss int init_level_sequence [3] = {0}
 
__pinned_bss int init_priority_sequence [4] = {0}
 
__pinned_bss int init_sub_priority_sequence [3] = {0}
 
__pinned_bss unsigned int seq_level_cnt
 
__pinned_bss unsigned int seq_priority_cnt
 
__pinned_bss unsigned int seq_sub_priority_cnt
 
static const struct my_driver_api funcs_my_drivers
 

Macro Definition Documentation

◆ LEVEL_POST_KERNEL

#define LEVEL_POST_KERNEL   3

◆ LEVEL_PRE_KERNEL_1

#define LEVEL_PRE_KERNEL_1   1

◆ LEVEL_PRE_KERNEL_2

#define LEVEL_PRE_KERNEL_2   2

◆ MY_DRIVER_LV_1

#define MY_DRIVER_LV_1   "my_driver_level_1"

Test cases to device driver initialization.

◆ MY_DRIVER_LV_2

#define MY_DRIVER_LV_2   "my_driver_level_2"

◆ MY_DRIVER_LV_3

#define MY_DRIVER_LV_3   "my_driver_level_3"

◆ MY_DRIVER_PRI_1

#define MY_DRIVER_PRI_1   "my_driver_priority_1"

◆ MY_DRIVER_PRI_2

#define MY_DRIVER_PRI_2   "my_driver_priority_2"

◆ MY_DRIVER_PRI_3

#define MY_DRIVER_PRI_3   "my_driver_priority_3"

◆ MY_DRIVER_PRI_4

#define MY_DRIVER_PRI_4   "my_driver_priority_4"

◆ PRIORITY_1

#define PRIORITY_1   1

◆ PRIORITY_2

#define PRIORITY_2   2

◆ PRIORITY_3

#define PRIORITY_3   3

◆ PRIORITY_4

#define PRIORITY_4   4

Typedef Documentation

◆ my_api_configure_t

typedef int(* my_api_configure_t) (const struct device *dev, int dev_config)

Function Documentation

◆ DEVICE_DT_DEFINE() [1/3]

DEVICE_DT_DEFINE ( DT_NODELABEL(fakedomain_0)  ,
my_driver_sub_pri_0_init  ,
NULL  ,
NULL  ,
NULL  ,
POST_KERNEL  ,
33  ,
NULL   
)

Test providing control device driver initialization order.

Test that kernel shall provide control over device driver initialization order, using initialization level and priority for each instance. We use DEVICE_DEFINE to define device instances and set it's level and priority here, then we run check function later after all of this instance finish their initialization.

◆ DEVICE_DT_DEFINE() [2/3]

DEVICE_DT_DEFINE ( DT_NODELABEL(fakedomain_1)  ,
my_driver_sub_pri_1_init  ,
NULL  ,
NULL  ,
NULL  ,
POST_KERNEL  ,
33  ,
NULL   
)

◆ DEVICE_DT_DEFINE() [3/3]

DEVICE_DT_DEFINE ( DT_NODELABEL(fakedomain_2)  ,
my_driver_sub_pri_2_init  ,
NULL  ,
NULL  ,
NULL  ,
POST_KERNEL  ,
33  ,
NULL   
)

◆ my_configure()

static int my_configure ( const struct device dev,
int  config 
)
static

◆ my_driver_lv_1_init()

static __pinned_func int my_driver_lv_1_init ( const struct device dev)
static

◆ my_driver_lv_2_init()

static __pinned_func int my_driver_lv_2_init ( const struct device dev)
static

◆ my_driver_lv_3_init()

static int my_driver_lv_3_init ( const struct device dev)
static

◆ my_driver_pri_1_init()

static int my_driver_pri_1_init ( const struct device dev)
static

◆ my_driver_pri_2_init()

static int my_driver_pri_2_init ( const struct device dev)
static

◆ my_driver_pri_3_init()

static int my_driver_pri_3_init ( const struct device dev)
static

◆ my_driver_pri_4_init()

static int my_driver_pri_4_init ( const struct device dev)
static

◆ my_driver_sub_pri_0_init()

static int my_driver_sub_pri_0_init ( const struct device dev)
static

◆ my_driver_sub_pri_1_init()

static int my_driver_sub_pri_1_init ( const struct device dev)
static

◆ my_driver_sub_pri_2_init()

static int my_driver_sub_pri_2_init ( const struct device dev)
static

Variable Documentation

◆ funcs_my_drivers

const struct my_driver_api funcs_my_drivers
static
Initial value:
= {
.configure = my_configure,
}
static int my_configure(const struct device *dev, int config)
Definition test_driver_init.c:52

◆ seq_sub_priority_cnt

__pinned_bss unsigned int seq_sub_priority_cnt