2929
3030#include "sys.h"
3131
32- #define REGISTER_PORT_DRIVER (NAME , INIT_CB , CREATE_CB ) \
32+ #define REGISTER_PORT_DRIVER (NAME , INIT_CB , DESTROY_CB , CREATE_CB ) \
3333 struct PortDriverDef NAME##_port_driver_def = { \
3434 .port_driver_name = #NAME, \
3535 .port_driver_init_cb = INIT_CB, \
36+ .port_driver_destroy_cb = DESTROY_CB, \
3637 .port_driver_create_port_cb = CREATE_CB \
3738 }; \
3839 \
4647 port_driver_list = &NAME##_port_driver_def_list_item; \
4748 }
4849
49- #define REGISTER_NIF_COLLECTION (NAME , INIT_CB , RESOLVE_NIF_CB ) \
50+ #define REGISTER_NIF_COLLECTION (NAME , INIT_CB , DESTROY_CB , RESOLVE_NIF_CB ) \
5051 struct NifCollectionDef NAME##_nif_collection_def = { \
5152 .nif_collection_init_cb = INIT_CB, \
53+ .nif_collection_destroy_cb = DESTROY_CB, \
5254 .nif_collection_resove_nif_cb = RESOLVE_NIF_CB \
5355 }; \
5456 \
@@ -75,17 +77,21 @@ struct EventListener
7577
7678struct ESP32PlatformData
7779{
80+ // socket_driver
81+ EventListener * socket_listener ;
7882 struct SyncList sockets ;
7983 struct ListHead ready_connections ;
8084};
8185
8286typedef void (* port_driver_init_t )(GlobalContext * global );
87+ typedef void (* port_driver_destroy_t )(GlobalContext * global );
8388typedef Context * (* port_driver_create_port_t )(GlobalContext * global , term opts );
8489
8590struct PortDriverDef
8691{
8792 const char * port_driver_name ;
8893 const port_driver_init_t port_driver_init_cb ;
94+ const port_driver_destroy_t port_driver_destroy_cb ;
8995 const port_driver_create_port_t port_driver_create_port_cb ;
9096};
9197
@@ -96,11 +102,13 @@ struct PortDriverDefListItem
96102};
97103
98104typedef void (* nif_collection_init_t )(GlobalContext * global );
105+ typedef void (* nif_collection_destroy_t )(GlobalContext * global );
99106typedef const struct Nif * (* nif_collection_resolve_nif_t )(const char * name );
100107
101108struct NifCollectionDef
102109{
103110 const nif_collection_init_t nif_collection_init_cb ;
111+ const nif_collection_destroy_t nif_collection_destroy_cb ;
104112 const nif_collection_resolve_nif_t nif_collection_resove_nif_cb ;
105113};
106114
@@ -122,7 +130,9 @@ void sys_event_listener_init(EventListener *listener, void *sender, event_handle
122130void socket_init (Context * ctx , term opts );
123131
124132void port_driver_init_all (GlobalContext * global );
133+ void port_driver_destroy_all (GlobalContext * global );
125134void nif_collection_init_all (GlobalContext * global );
135+ void nif_collection_destroy_all (GlobalContext * global );
126136const struct Nif * nif_collection_resolve_nif (const char * name );
127137
128138const void * esp32_sys_mmap_partition (
0 commit comments