Skip to content

Commit

Permalink
ESP32: add support for "Misc Paltform Entries"
Browse files Browse the repository at this point in the history
This will allow to store miscellaneous information inside ESP32PlatformData
sturct, so we don't need to add new fields or lists to it every time we
add support for a new NIF.

This change has been introduced to support tracking of mounted
filesystem in order to allow umounting them using `esp:umount/1`.

Signed-off-by: Davide Bettio <[email protected]>
  • Loading branch information
bettio committed Sep 29, 2024
1 parent 4b37211 commit 905adb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/platforms/esp32/components/avm_sys/include/esp32_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ struct EventListener
listener_event_t sender;
};

struct MiscEntry
{
struct ListHead list_head;

// entry_type must be unique for a certain type of entry.
// I suggest using a function pointer to the "constructor function" as a unique value since
// since 2 different functions have always different addressed.
uintptr_t entry_type;
};

struct ESP32PlatformData
{
pthread_t select_thread;
Expand All @@ -114,6 +124,8 @@ struct ESP32PlatformData
#endif
mbedtls_ctr_drbg_context random_ctx;
bool random_is_initialized;

struct SyncList misc_entries;
};

typedef void (*port_driver_init_t)(GlobalContext *global);
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/esp32/components/avm_sys/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ void sys_init_platform(GlobalContext *glb)

platform->entropy_is_initialized = false;
platform->random_is_initialized = false;

synclist_init(&platform->misc_entries);
}

void sys_free_platform(GlobalContext *glb)
Expand Down

0 comments on commit 905adb7

Please sign in to comment.