Application Event Manager: Where does event_subscriber array in event_type get populated

I'm browsing the Application Event Manager code, and I'm wondering:

I see that struct event_type has (effectively) an array of struct event_subscriber, bounded by pointers .subs_start and .subs_stop.

And, I see that when an event is submitted (using EVENT_SUBMIT()), work function event_processor_fn() walks this array, and calls the listener handler function for each subscriber.

What I don't see is where/how the array is populated with event_subscriber objects - where/how the objects are added onto the array.

I see macro EVENT_SUBSCRIBE(), which defines an event_subscriber object, but I don't see where/how that object is placed in the event_subscriber array for the corresponding event_type.

Thanks!

Parents
  • nvm, I see what's going on here now. Grinning

    The full macro:

    #define _EVENT_SUBSCRIBE(lname, ename, prio)							\
    	const struct event_subscriber _CONCAT(_CONCAT(__event_subscriber_, ename), lname)	\
    	__used __aligned(__alignof(struct event_subscriber))					\
    	__attribute__((__section__(_EVENT_SUBSCRIBERS_SECTION_NAME(ename, prio)))) = {		\
    		.listener = &_CONCAT(__event_listener_, lname),					\
    	}

    The __section__ attribute places the defined struct in the correct place in memory (a defined memory "section" corresponding to the event, to which the pointer in the event_type object points.

Reply
  • nvm, I see what's going on here now. Grinning

    The full macro:

    #define _EVENT_SUBSCRIBE(lname, ename, prio)							\
    	const struct event_subscriber _CONCAT(_CONCAT(__event_subscriber_, ename), lname)	\
    	__used __aligned(__alignof(struct event_subscriber))					\
    	__attribute__((__section__(_EVENT_SUBSCRIBERS_SECTION_NAME(ename, prio)))) = {		\
    		.listener = &_CONCAT(__event_listener_, lname),					\
    	}

    The __section__ attribute places the defined struct in the correct place in memory (a defined memory "section" corresponding to the event, to which the pointer in the event_type object points.

Children
No Data
Related