diff --git a/Buildscripts/DevicetreeCompiler/source/generator.py b/Buildscripts/DevicetreeCompiler/source/generator.py index 8a85e1fc..9d59a952 100644 --- a/Buildscripts/DevicetreeCompiler/source/generator.py +++ b/Buildscripts/DevicetreeCompiler/source/generator.py @@ -134,6 +134,7 @@ def write_device_structs(file, device: Device, parent_device: Device, bindings: file.write(f"\t.name = \"{device.node_name}\",\n") # Use original name file.write(f"\t.config = &{config_variable_name},\n") file.write(f"\t.parent = {parent_value},\n") + file.write("\t.internal = NULL\n") file.write("};\n\n") # Child devices for child_device in device.devices: diff --git a/Devices/btt-panda-touch/Source/module.cpp b/Devices/btt-panda-touch/Source/module.cpp index 3bd6afb7..f0b27828 100644 --- a/Devices/btt-panda-touch/Source/module.cpp +++ b/Devices/btt-panda-touch/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "btt-panda-touch", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-2432s024c/Source/module.cpp b/Devices/cyd-2432s024c/Source/module.cpp index 6898097e..cd632d31 100644 --- a/Devices/cyd-2432s024c/Source/module.cpp +++ b/Devices/cyd-2432s024c/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-2432s024c", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-2432s028r/Source/module.cpp b/Devices/cyd-2432s028r/Source/module.cpp index 449be9cf..d5642eee 100644 --- a/Devices/cyd-2432s028r/Source/module.cpp +++ b/Devices/cyd-2432s028r/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-2432s028r", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-2432s028rv3/Source/module.cpp b/Devices/cyd-2432s028rv3/Source/module.cpp index 9723e37c..e6633689 100644 --- a/Devices/cyd-2432s028rv3/Source/module.cpp +++ b/Devices/cyd-2432s028rv3/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-2432s028rv3", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-2432s032c/Source/module.cpp b/Devices/cyd-2432s032c/Source/module.cpp index 87e8f63e..239c5c0f 100644 --- a/Devices/cyd-2432s032c/Source/module.cpp +++ b/Devices/cyd-2432s032c/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-2432s032c", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-4848s040c/Source/module.cpp b/Devices/cyd-4848s040c/Source/module.cpp index f9d28174..44b6b327 100644 --- a/Devices/cyd-4848s040c/Source/module.cpp +++ b/Devices/cyd-4848s040c/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-4848s040c", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-8048s043c/Source/module.cpp b/Devices/cyd-8048s043c/Source/module.cpp index 13d35d5f..58e04116 100644 --- a/Devices/cyd-8048s043c/Source/module.cpp +++ b/Devices/cyd-8048s043c/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-8048s043c", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-e32r28t/Source/module.cpp b/Devices/cyd-e32r28t/Source/module.cpp index fa32e809..615d412c 100644 --- a/Devices/cyd-e32r28t/Source/module.cpp +++ b/Devices/cyd-e32r28t/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-e32r28t", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/cyd-e32r32p/Source/module.cpp b/Devices/cyd-e32r32p/Source/module.cpp index 57fc73db..62e4d293 100644 --- a/Devices/cyd-e32r32p/Source/module.cpp +++ b/Devices/cyd-e32r32p/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "cyd-e32r32p", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/elecrow-crowpanel-advance-35/Source/module.cpp b/Devices/elecrow-crowpanel-advance-35/Source/module.cpp index c9a1756b..34048139 100644 --- a/Devices/elecrow-crowpanel-advance-35/Source/module.cpp +++ b/Devices/elecrow-crowpanel-advance-35/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "elecrow-crowpanel-advance-35", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/elecrow-crowpanel-advance-50/Source/module.cpp b/Devices/elecrow-crowpanel-advance-50/Source/module.cpp index b8e4f0f7..ec449848 100644 --- a/Devices/elecrow-crowpanel-advance-50/Source/module.cpp +++ b/Devices/elecrow-crowpanel-advance-50/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "elecrow-crowpanel-advance-50", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/elecrow-crowpanel-basic-28/Source/module.cpp b/Devices/elecrow-crowpanel-basic-28/Source/module.cpp index 8c284b32..eed3d132 100644 --- a/Devices/elecrow-crowpanel-basic-28/Source/module.cpp +++ b/Devices/elecrow-crowpanel-basic-28/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "elecrow-crowpanel-basic-28", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/elecrow-crowpanel-basic-35/Source/module.cpp b/Devices/elecrow-crowpanel-basic-35/Source/module.cpp index 5bf88d8f..0af55e09 100644 --- a/Devices/elecrow-crowpanel-basic-35/Source/module.cpp +++ b/Devices/elecrow-crowpanel-basic-35/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "elecrow-crowpanel-basic-35", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/elecrow-crowpanel-basic-50/Source/module.cpp b/Devices/elecrow-crowpanel-basic-50/Source/module.cpp index 8ae5c1f6..e38e0036 100644 --- a/Devices/elecrow-crowpanel-basic-50/Source/module.cpp +++ b/Devices/elecrow-crowpanel-basic-50/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "elecrow-crowpanel-basic-50", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/generic-esp32/Source/module.cpp b/Devices/generic-esp32/Source/module.cpp index e30198aa..d21e2365 100644 --- a/Devices/generic-esp32/Source/module.cpp +++ b/Devices/generic-esp32/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "generic-esp32", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/generic-esp32c6/Source/module.cpp b/Devices/generic-esp32c6/Source/module.cpp index c22545ca..231208d4 100644 --- a/Devices/generic-esp32c6/Source/module.cpp +++ b/Devices/generic-esp32c6/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "generic-esp32c6", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/generic-esp32p4/Source/module.cpp b/Devices/generic-esp32p4/Source/module.cpp index 9dbf7c20..82290049 100644 --- a/Devices/generic-esp32p4/Source/module.cpp +++ b/Devices/generic-esp32p4/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "generic-esp32p4", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/generic-esp32s3/Source/module.cpp b/Devices/generic-esp32s3/Source/module.cpp index d28a5d0e..7efaed5e 100644 --- a/Devices/generic-esp32s3/Source/module.cpp +++ b/Devices/generic-esp32s3/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "generic-esp32s3", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/guition-jc1060p470ciwy/Source/module.cpp b/Devices/guition-jc1060p470ciwy/Source/module.cpp index 00b4e076..71a565f2 100644 --- a/Devices/guition-jc1060p470ciwy/Source/module.cpp +++ b/Devices/guition-jc1060p470ciwy/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "guition-jc1060p470ciwy", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/guition-jc2432w328c/Source/module.cpp b/Devices/guition-jc2432w328c/Source/module.cpp index ef9ac9eb..e33a90c0 100644 --- a/Devices/guition-jc2432w328c/Source/module.cpp +++ b/Devices/guition-jc2432w328c/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "guition-jc2432w328c", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/guition-jc3248w535c/Source/module.cpp b/Devices/guition-jc3248w535c/Source/module.cpp index e99aad6b..f9c90650 100644 --- a/Devices/guition-jc3248w535c/Source/module.cpp +++ b/Devices/guition-jc3248w535c/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "guition-jc3248w535c", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/guition-jc8048w550c/Source/module.cpp b/Devices/guition-jc8048w550c/Source/module.cpp index 0549e5f9..a4406fb7 100644 --- a/Devices/guition-jc8048w550c/Source/module.cpp +++ b/Devices/guition-jc8048w550c/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "guition-jc8048w550c", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/heltec-wifi-lora-32-v3/Source/module.cpp b/Devices/heltec-wifi-lora-32-v3/Source/module.cpp index 0294e375..ecb336ab 100644 --- a/Devices/heltec-wifi-lora-32-v3/Source/module.cpp +++ b/Devices/heltec-wifi-lora-32-v3/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "heltec-wifi-lora-32-v3", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/lilygo-tdeck/Source/module.cpp b/Devices/lilygo-tdeck/Source/module.cpp index cf804c19..298c614e 100644 --- a/Devices/lilygo-tdeck/Source/module.cpp +++ b/Devices/lilygo-tdeck/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "lilygo-tdeck", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/lilygo-tdisplay-s3/Source/module.cpp b/Devices/lilygo-tdisplay-s3/Source/module.cpp index 91233e41..fa3624ba 100644 --- a/Devices/lilygo-tdisplay-s3/Source/module.cpp +++ b/Devices/lilygo-tdisplay-s3/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "lilygo-tdisplay-s3", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/lilygo-tdisplay/Source/module.cpp b/Devices/lilygo-tdisplay/Source/module.cpp index 000b0acf..e0db7dcc 100644 --- a/Devices/lilygo-tdisplay/Source/module.cpp +++ b/Devices/lilygo-tdisplay/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "lilygo-tdisplay", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/lilygo-tdongle-s3/Source/module.cpp b/Devices/lilygo-tdongle-s3/Source/module.cpp index b3387eb7..b1ef5fb3 100644 --- a/Devices/lilygo-tdongle-s3/Source/module.cpp +++ b/Devices/lilygo-tdongle-s3/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "lilygo-tdongle-s3", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp b/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp index 741750ae..f659b872 100644 --- a/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp +++ b/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp @@ -24,7 +24,7 @@ Driver tlora_pager_driver = { .api = nullptr, .device_type = nullptr, .owner = &device_module, - .driver_private = nullptr + .internal = nullptr }; } diff --git a/Devices/lilygo-tlora-pager/Source/module.cpp b/Devices/lilygo-tlora-pager/Source/module.cpp index d840cd7b..23a4de5e 100644 --- a/Devices/lilygo-tlora-pager/Source/module.cpp +++ b/Devices/lilygo-tlora-pager/Source/module.cpp @@ -25,7 +25,8 @@ struct Module device_module = { .name = "lilygo-tlora-pager", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-cardputer-adv/Source/module.cpp b/Devices/m5stack-cardputer-adv/Source/module.cpp index 656d9766..e49f44b4 100644 --- a/Devices/m5stack-cardputer-adv/Source/module.cpp +++ b/Devices/m5stack-cardputer-adv/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-cardputer-adv", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-cardputer/Source/module.cpp b/Devices/m5stack-cardputer/Source/module.cpp index 66b2f7cf..4cb38034 100644 --- a/Devices/m5stack-cardputer/Source/module.cpp +++ b/Devices/m5stack-cardputer/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-cardputer", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-core2/Source/module.cpp b/Devices/m5stack-core2/Source/module.cpp index b8166a5c..abe98186 100644 --- a/Devices/m5stack-core2/Source/module.cpp +++ b/Devices/m5stack-core2/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-core2", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-cores3/Source/module.cpp b/Devices/m5stack-cores3/Source/module.cpp index 1fdd059b..393fbf3f 100644 --- a/Devices/m5stack-cores3/Source/module.cpp +++ b/Devices/m5stack-cores3/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-cores3", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-cores3/m5stack,cores3.dts b/Devices/m5stack-cores3/m5stack,cores3.dts index 217a3e93..a35822c2 100644 --- a/Devices/m5stack-cores3/m5stack,cores3.dts +++ b/Devices/m5stack-cores3/m5stack,cores3.dts @@ -55,8 +55,8 @@ scl-pullup; }; - // TODO: Enable speaker via I2C: https://github.com/m5stack/M5Unified/blob/a6256725481f1bc366655fa48cf03b6095e30ad1/src/M5Unified.cpp#L417 - // TODO: Enable microphone via I2C: https://github.com/m5stack/M5Unified/blob/a6256725481f1bc366655fa48cf03b6095e30ad1/src/M5Unified.cpp#L616 + // TODO: Enable speaker via ES7210 I2C: https://github.com/m5stack/M5Unified/blob/a6256725481f1bc366655fa48cf03b6095e30ad1/src/M5Unified.cpp#L417 + // TODO: Enable microphone via ES7210 I2C: https://github.com/m5stack/M5Unified/blob/a6256725481f1bc366655fa48cf03b6095e30ad1/src/M5Unified.cpp#L616 i2s0 { // Note: M5Unified sets the following for speaker: magnification = 2, oversampling = 1 // Note: M5Unified sets the following for microphone: magnification = 4 diff --git a/Devices/m5stack-papers3/Source/module.cpp b/Devices/m5stack-papers3/Source/module.cpp index 507ff816..7334626b 100644 --- a/Devices/m5stack-papers3/Source/module.cpp +++ b/Devices/m5stack-papers3/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-papers3", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-stickc-plus/Source/module.cpp b/Devices/m5stack-stickc-plus/Source/module.cpp index 8e4face5..9fab289f 100644 --- a/Devices/m5stack-stickc-plus/Source/module.cpp +++ b/Devices/m5stack-stickc-plus/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-stickc-plus", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-stickc-plus2/Source/module.cpp b/Devices/m5stack-stickc-plus2/Source/module.cpp index f8ee926d..9374ef77 100644 --- a/Devices/m5stack-stickc-plus2/Source/module.cpp +++ b/Devices/m5stack-stickc-plus2/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-stickc-plus2", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/m5stack-tab5/Source/module.cpp b/Devices/m5stack-tab5/Source/module.cpp index a0d99011..fc9e2675 100644 --- a/Devices/m5stack-tab5/Source/module.cpp +++ b/Devices/m5stack-tab5/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "m5stack-tab5", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/simulator/Source/module.cpp b/Devices/simulator/Source/module.cpp index c52deb06..8ae3a55e 100644 --- a/Devices/simulator/Source/module.cpp +++ b/Devices/simulator/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "simulator", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/unphone/Source/module.cpp b/Devices/unphone/Source/module.cpp index e1929eed..19de7394 100644 --- a/Devices/unphone/Source/module.cpp +++ b/Devices/unphone/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "unphone", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/waveshare-esp32-s3-geek/Source/module.cpp b/Devices/waveshare-esp32-s3-geek/Source/module.cpp index 682dcd3c..5eef7d46 100644 --- a/Devices/waveshare-esp32-s3-geek/Source/module.cpp +++ b/Devices/waveshare-esp32-s3-geek/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "waveshare-esp32-s3-geek", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/waveshare-s3-lcd-13/Source/module.cpp b/Devices/waveshare-s3-lcd-13/Source/module.cpp index 2071dc4b..ca7a21c6 100644 --- a/Devices/waveshare-s3-lcd-13/Source/module.cpp +++ b/Devices/waveshare-s3-lcd-13/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "waveshare-s3-lcd-13", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/waveshare-s3-touch-lcd-128/Source/module.cpp b/Devices/waveshare-s3-touch-lcd-128/Source/module.cpp index 90dc8667..a5b15030 100644 --- a/Devices/waveshare-s3-touch-lcd-128/Source/module.cpp +++ b/Devices/waveshare-s3-touch-lcd-128/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "waveshare-s3-touch-lcd-128", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/waveshare-s3-touch-lcd-147/Source/module.cpp b/Devices/waveshare-s3-touch-lcd-147/Source/module.cpp index 86dba168..b53792e3 100644 --- a/Devices/waveshare-s3-touch-lcd-147/Source/module.cpp +++ b/Devices/waveshare-s3-touch-lcd-147/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "waveshare-s3-touch-lcd-147", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/waveshare-s3-touch-lcd-43/Source/module.cpp b/Devices/waveshare-s3-touch-lcd-43/Source/module.cpp index a6c203ba..2019004c 100644 --- a/Devices/waveshare-s3-touch-lcd-43/Source/module.cpp +++ b/Devices/waveshare-s3-touch-lcd-43/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "waveshare-s3-touch-lcd-43", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Devices/wireless-tag-wt32-sc01-plus/Source/module.cpp b/Devices/wireless-tag-wt32-sc01-plus/Source/module.cpp index 85e806fc..ff0aa0ab 100644 --- a/Devices/wireless-tag-wt32-sc01-plus/Source/module.cpp +++ b/Devices/wireless-tag-wt32-sc01-plus/Source/module.cpp @@ -17,7 +17,8 @@ struct Module device_module = { .name = "wireless-tag-wt32-sc01-plus", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Modules/hal-device-module/Source/drivers/hal_device.cpp b/Modules/hal-device-module/Source/drivers/hal_device.cpp index 992f359d..e51ba3ea 100644 --- a/Modules/hal-device-module/Source/drivers/hal_device.cpp +++ b/Modules/hal-device-module/Source/drivers/hal_device.cpp @@ -14,7 +14,7 @@ struct HalDevicePrivate { std::shared_ptr halDevice; }; -#define GET_DATA(device) ((struct HalDevicePrivate*)device->internal.driver_data) +#define GET_DATA(device) ((HalDevicePrivate*)device_get_driver_data(device)) static enum HalDeviceType getHalDeviceType(tt::hal::Device::Type type) { switch (type) { @@ -94,7 +94,9 @@ void hal_device_set_device(::Device* kernelDevice, std::shared_ptr halDe static error_t start(Device* device) { LOG_I(TAG, "start %s", device->name); - device->internal.driver_data = new HalDevicePrivate(); + auto hal_device_data = new(std::nothrow) HalDevicePrivate(); + if (hal_device_data == nullptr) return ERROR_OUT_OF_MEMORY; + device_set_driver_data(device, hal_device_data); return ERROR_NONE; } @@ -120,7 +122,7 @@ Driver hal_device_driver = { .api = nullptr, .device_type = &HAL_DEVICE_TYPE, .owner = &hal_device_module, - .driver_private = nullptr + .internal = nullptr }; } \ No newline at end of file diff --git a/Modules/hal-device-module/Source/module.cpp b/Modules/hal-device-module/Source/module.cpp index 49d65107..bf36c6b7 100644 --- a/Modules/hal-device-module/Source/module.cpp +++ b/Modules/hal-device-module/Source/module.cpp @@ -25,7 +25,8 @@ struct Module hal_device_module = { .name = "hal-device", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Modules/lvgl-module/Source/module.c b/Modules/lvgl-module/Source/module.c index 6a4b0afd..b8bcd9c7 100644 --- a/Modules/lvgl-module/Source/module.c +++ b/Modules/lvgl-module/Source/module.c @@ -64,5 +64,6 @@ struct Module lvgl_module = { .name = "lvgl", .start = start, .stop = stop, - .symbols = (const struct ModuleSymbol*)lvgl_module_symbols + .symbols = (const struct ModuleSymbol*)lvgl_module_symbols, + .internal = NULL }; diff --git a/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp b/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp index bfe37836..81680018 100644 --- a/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp +++ b/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp @@ -123,7 +123,7 @@ Driver esp32_gpio_driver = { .api = (void*)&esp32_gpio_api, .device_type = &GPIO_CONTROLLER_TYPE, .owner = &platform_module, - .driver_private = nullptr + .internal = nullptr }; } // extern "C" diff --git a/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp b/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp index 5f444739..b6992805 100644 --- a/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp +++ b/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp @@ -25,7 +25,7 @@ struct InternalData { }; #define GET_CONFIG(device) ((Esp32I2cConfig*)device->config) -#define GET_DATA(device) ((InternalData*)device->internal.driver_data) +#define GET_DATA(device) ((InternalData*)device_get_driver_data(device)) #define lock(data) mutex_lock(&data->mutex); #define unlock(data) mutex_unlock(&data->mutex); @@ -216,7 +216,7 @@ Driver esp32_i2c_driver = { .api = (void*)&esp32_i2c_api, .device_type = &I2C_CONTROLLER_TYPE, .owner = &platform_module, - .driver_private = nullptr + .internal = nullptr }; } // extern "C" diff --git a/Platforms/PlatformEsp32/Source/drivers/esp32_i2s.cpp b/Platforms/PlatformEsp32/Source/drivers/esp32_i2s.cpp index 8f1d0ed9..5082dd24 100644 --- a/Platforms/PlatformEsp32/Source/drivers/esp32_i2s.cpp +++ b/Platforms/PlatformEsp32/Source/drivers/esp32_i2s.cpp @@ -31,7 +31,7 @@ struct InternalData { }; #define GET_CONFIG(device) ((Esp32I2sConfig*)device->config) -#define GET_DATA(device) ((InternalData*)device->internal.driver_data) +#define GET_DATA(device) ((InternalData*)device_get_driver_data(device)) #define lock(data) mutex_lock(&data->mutex); #define unlock(data) mutex_unlock(&data->mutex); @@ -236,7 +236,7 @@ Driver esp32_i2s_driver = { .api = (void*)&esp32_i2s_api, .device_type = &I2S_CONTROLLER_TYPE, .owner = &platform_module, - .driver_private = nullptr + .internal = nullptr }; } // extern "C" diff --git a/Platforms/PlatformEsp32/Source/module.cpp b/Platforms/PlatformEsp32/Source/module.cpp index 0170152d..0671803f 100644 --- a/Platforms/PlatformEsp32/Source/module.cpp +++ b/Platforms/PlatformEsp32/Source/module.cpp @@ -31,7 +31,8 @@ struct Module platform_module = { .name = "platform-esp32", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/Platforms/PlatformPosix/Source/module.cpp b/Platforms/PlatformPosix/Source/module.cpp index c696aa51..0dec030c 100644 --- a/Platforms/PlatformPosix/Source/module.cpp +++ b/Platforms/PlatformPosix/Source/module.cpp @@ -18,7 +18,8 @@ struct Module platform_module = { .name = "platform-posix", .start = start, .stop = stop, - .symbols = nullptr + .symbols = nullptr, + .internal = nullptr }; } diff --git a/TactilityKernel/Include/tactility/concurrent/mutex.h b/TactilityKernel/Include/tactility/concurrent/mutex.h index 4d5e3b98..a6e0d579 100644 --- a/TactilityKernel/Include/tactility/concurrent/mutex.h +++ b/TactilityKernel/Include/tactility/concurrent/mutex.h @@ -18,12 +18,10 @@ struct Mutex { }; inline static void mutex_construct(struct Mutex* mutex) { - assert(mutex->handle == NULL); mutex->handle = xSemaphoreCreateMutex(); } inline static void mutex_destruct(struct Mutex* mutex) { - assert(mutex->handle != NULL); vPortAssertIfInISR(); vSemaphoreDelete(mutex->handle); mutex->handle = NULL; diff --git a/TactilityKernel/Include/tactility/device.h b/TactilityKernel/Include/tactility/device.h index fedb29d7..4f76d866 100644 --- a/TactilityKernel/Include/tactility/device.h +++ b/TactilityKernel/Include/tactility/device.h @@ -16,39 +16,30 @@ extern "C" { #endif struct Driver; -struct DevicePrivate; +struct DeviceInternal; /** Enables discovering devices of the same type */ struct DeviceType { - /* Placeholder because empty structs have a different size with C vs C++ compilers */ - uint8_t _; + const char* name; }; /** Represents a piece of hardware */ struct Device { /** The name of the device. Valid characters: a-z a-Z 0-9 - _ . */ const char* name; + /** The configuration data for the device's driver */ const void* config; + /** The parent device that this device belongs to. Can be NULL, but only the root device should have a NULL parent. */ struct Device* parent; - /** Internal data */ - struct { - /** Address of the API exposed by the device instance. */ - struct Driver* driver; - /** The driver data for this device (e.g. a mutex) */ - void* driver_data; - /** The mutex for device operations */ - struct Mutex mutex; - /** The device state */ - struct { - int start_result; - bool started : 1; - bool added : 1; - } state; - /** Private data */ - struct DevicePrivate* device_private; - } internal; + + /** + * Internal state managed by the kernel. + * Device implementers should initialize this to NULL. + * Do not access or modify directly; use device_* functions. + */ + struct DeviceInternal* internal; }; /** diff --git a/TactilityKernel/Include/tactility/driver.h b/TactilityKernel/Include/tactility/driver.h index a3cf24d3..7ae115a3 100644 --- a/TactilityKernel/Include/tactility/driver.h +++ b/TactilityKernel/Include/tactility/driver.h @@ -12,7 +12,7 @@ extern "C" { struct Device; struct DeviceType; struct Module; -struct DriverPrivate; +struct DriverInternal; struct Driver { /** The driver name */ @@ -29,8 +29,12 @@ struct Driver { const struct DeviceType* device_type; /** The module that owns this driver. When it is NULL, the system owns the driver and it cannot be removed from registration. */ const struct Module* owner; - /** Internal data */ - struct DriverPrivate* driver_private; + /** + * Internal state managed by the kernel. + * Driver implementers should initialize this to NULL. + * Do not access or modify directly; use driver_* functions. + */ + struct DriverInternal* internal; }; /** diff --git a/TactilityKernel/Include/tactility/module.h b/TactilityKernel/Include/tactility/module.h index 5e44dfe4..aa49ba05 100644 --- a/TactilityKernel/Include/tactility/module.h +++ b/TactilityKernel/Include/tactility/module.h @@ -25,6 +25,8 @@ struct ModuleSymbol { const void* symbol; }; +struct ModuleInternal; + /** * A module is a collection of drivers or other functionality that can be loaded and unloaded at runtime. */ @@ -36,7 +38,6 @@ struct Module { * Desirable format "platform-esp32", "lilygo-tdeck", etc. */ const char* name; - /** * A function to initialize the module. * Should never be NULL. @@ -44,24 +45,24 @@ struct Module { * @return ERROR_NONE if successful */ error_t (*start)(void); - /** * Deinitializes the module. * Should never be NULL. * @return ERROR_NONE if successful */ error_t (*stop)(void); - /** * A list of symbols exported by the module. * Should be terminated by MODULE_SYMBOL_TERMINATOR. * Can be a NULL value. */ const struct ModuleSymbol* symbols; - - struct { - bool started; - } internal; + /** + * Internal state managed by the kernel. + * Module implementers should initialize this to NULL. + * Do not access or modify directly; use module_* functions. + */ + struct ModuleInternal* internal; }; /** diff --git a/TactilityKernel/Source/device.cpp b/TactilityKernel/Source/device.cpp index b16fc747..9420b1db 100644 --- a/TactilityKernel/Source/device.cpp +++ b/TactilityKernel/Source/device.cpp @@ -13,8 +13,21 @@ #define TAG "device" -struct DevicePrivate { - std::vector children; +struct DeviceInternal { + /** Address of the API exposed by the device instance. */ + struct Driver* driver = nullptr; + /** The driver data for this device (e.g. a mutex) */ + void* driver_data = nullptr; + /** The mutex for device operations */ + struct Mutex mutex {}; + /** The device state */ + struct { + int start_result = 0; + bool started : 1 = false; + bool added : 1 = false; + } state; + /** Attached child devices */ + std::vector children {}; }; struct DeviceLedger { @@ -42,47 +55,55 @@ extern "C" { #define ledger_lock() mutex_lock(&ledger.mutex) #define ledger_unlock() mutex_unlock(&ledger.mutex) -#define get_device_private(device) static_cast(device->internal.device_private) +#define lock_internal(internal) mutex_lock(&internal->mutex) +#define unlock_internal(internal) mutex_unlock(&internal->mutex) error_t device_construct(Device* device) { - device->internal.device_private = new(std::nothrow) DevicePrivate; - if (device->internal.device_private == nullptr) { + device->internal = new(std::nothrow) DeviceInternal; + if (device->internal == nullptr) { return ERROR_OUT_OF_MEMORY; } LOG_D(TAG, "construct %s", device->name); - mutex_construct(&device->internal.mutex); + mutex_construct(&device->internal->mutex); return ERROR_NONE; } error_t device_destruct(Device* device) { - if (device->internal.state.started || device->internal.state.added) { + lock_internal(device->internal); + + auto* internal = device->internal; + + if (internal->state.started || internal->state.added) { + unlock_internal(device->internal); return ERROR_INVALID_STATE; } - if (!get_device_private(device)->children.empty()) { + if (!internal->children.empty()) { + unlock_internal(device->internal); return ERROR_INVALID_STATE; } LOG_D(TAG, "destruct %s", device->name); - mutex_destruct(&device->internal.mutex); - delete get_device_private(device); - device->internal.device_private = nullptr; + + device->internal = nullptr; + mutex_unlock(&internal->mutex); + delete internal; + return ERROR_NONE; } /** Add a child to the list of children */ static void device_add_child(struct Device* device, struct Device* child) { device_lock(device); - assert(device->internal.state.added); - get_device_private(device)->children.push_back(child); + check(device->internal->state.added); + device->internal->children.push_back(child); device_unlock(device); } /** Remove a child from the list of children */ static void device_remove_child(struct Device* device, struct Device* child) { device_lock(device); - auto* parent_data = get_device_private(device); - const auto iterator = std::ranges::find(parent_data->children, child); - if (iterator != parent_data->children.end()) { - parent_data->children.erase(iterator); + const auto iterator = std::ranges::find(device->internal->children, child); + if (iterator != device->internal->children.end()) { + device->internal->children.erase(iterator); } device_unlock(device); } @@ -91,7 +112,7 @@ error_t device_add(Device* device) { LOG_D(TAG, "add %s", device->name); // Already added - if (device->internal.state.started || device->internal.state.added) { + if (device->internal->state.started || device->internal->state.added) { return ERROR_INVALID_STATE; } @@ -106,14 +127,14 @@ error_t device_add(Device* device) { device_add_child(parent, device); } - device->internal.state.added = true; + device->internal->state.added = true; return ERROR_NONE; } error_t device_remove(Device* device) { LOG_D(TAG, "remove %s", device->name); - if (device->internal.state.started || !device->internal.state.added) { + if (device->internal->state.started || !device->internal->state.added) { return ERROR_INVALID_STATE; } @@ -132,7 +153,7 @@ error_t device_remove(Device* device) { ledger.devices.erase(iterator); ledger_unlock(); - device->internal.state.added = false; + device->internal->state.added = false; return ERROR_NONE; failed_ledger_lookup: @@ -147,41 +168,41 @@ failed_ledger_lookup: error_t device_start(Device* device) { LOG_I(TAG, "start %s", device->name); - if (!device->internal.state.added) { + if (!device->internal->state.added) { return ERROR_INVALID_STATE; } - if (device->internal.driver == nullptr) { + if (device->internal->driver == nullptr) { return ERROR_INVALID_STATE; } // Already started - if (device->internal.state.started) { + if (device->internal->state.started) { return ERROR_NONE; } - error_t bind_error = driver_bind(device->internal.driver, device); - device->internal.state.started = (bind_error == ERROR_NONE); - device->internal.state.start_result = bind_error; + error_t bind_error = driver_bind(device->internal->driver, device); + device->internal->state.started = (bind_error == ERROR_NONE); + device->internal->state.start_result = bind_error; return bind_error == ERROR_NONE ? ERROR_NONE : ERROR_RESOURCE; } error_t device_stop(struct Device* device) { LOG_I(TAG, "stop %s", device->name); - if (!device->internal.state.added) { + if (!device->internal->state.added) { return ERROR_INVALID_STATE; } - if (!device->internal.state.started) { + if (!device->internal->state.started) { return ERROR_NONE; } - if (driver_unbind(device->internal.driver, device) != ERROR_NONE) { + if (driver_unbind(device->internal->driver, device) != ERROR_NONE) { return ERROR_RESOURCE; } - device->internal.state.started = false; - device->internal.state.start_result = 0; + device->internal->state.started = false; + device->internal->state.start_result = 0; return ERROR_NONE; } @@ -236,7 +257,7 @@ on_construct_add_error: } void device_set_parent(Device* device, Device* parent) { - assert(!device->internal.state.started); + assert(!device->internal->state.started); device->parent = parent; } @@ -245,43 +266,43 @@ Device* device_get_parent(struct Device* device) { } void device_set_driver(struct Device* device, struct Driver* driver) { - device->internal.driver = driver; + device->internal->driver = driver; } struct Driver* device_get_driver(struct Device* device) { - return device->internal.driver; + return device->internal->driver; } bool device_is_ready(const struct Device* device) { - return device->internal.state.started; + return device->internal->state.started; } void device_set_driver_data(struct Device* device, void* driver_data) { - device->internal.driver_data = driver_data; + device->internal->driver_data = driver_data; } void* device_get_driver_data(struct Device* device) { - return device->internal.driver_data; + return device->internal->driver_data; } bool device_is_added(const struct Device* device) { - return device->internal.state.added; + return device->internal->state.added; } void device_lock(struct Device* device) { - mutex_lock(&device->internal.mutex); + mutex_lock(&device->internal->mutex); } bool device_try_lock(struct Device* device) { - return mutex_try_lock(&device->internal.mutex); + return mutex_try_lock(&device->internal->mutex); } void device_unlock(struct Device* device) { - mutex_unlock(&device->internal.mutex); + mutex_unlock(&device->internal->mutex); } const struct DeviceType* device_get_type(struct Device* device) { - return device->internal.driver ? device->internal.driver->device_type : NULL; + return device->internal->driver ? device->internal->driver->device_type : NULL; } void device_for_each(void* callback_context, bool(*on_device)(Device* device, void* context)) { @@ -295,8 +316,7 @@ void device_for_each(void* callback_context, bool(*on_device)(Device* device, vo } void device_for_each_child(Device* device, void* callbackContext, bool(*on_device)(struct Device* device, void* context)) { - auto* data = get_device_private(device); - for (auto* child_device : data->children) { + for (auto* child_device : device->internal->children) { if (!on_device(child_device, callbackContext)) { break; } @@ -306,7 +326,7 @@ void device_for_each_child(Device* device, void* callbackContext, bool(*on_devic void device_for_each_of_type(const DeviceType* type, void* callbackContext, bool(*on_device)(Device* device, void* context)) { ledger_lock(); for (auto* device : ledger.devices) { - auto* driver = device->internal.driver; + auto* driver = device->internal->driver; if (driver != nullptr) { if (driver->device_type == type) { if (!on_device(device, callbackContext)) { diff --git a/TactilityKernel/Source/driver.cpp b/TactilityKernel/Source/driver.cpp index a4bf0bfd..9a05d6ec 100644 --- a/TactilityKernel/Source/driver.cpp +++ b/TactilityKernel/Source/driver.cpp @@ -12,23 +12,14 @@ #define TAG "driver" -struct DriverPrivate { - Mutex mutex { 0 }; +struct DriverInternal { int use_count = 0; bool destroying = false; - - DriverPrivate() { - mutex_construct(&mutex); - } - - ~DriverPrivate() { - mutex_destruct(&mutex); - } }; struct DriverLedger { std::vector drivers; - Mutex mutex { 0 }; + Mutex mutex {}; DriverLedger() { mutex_construct(&mutex); } ~DriverLedger() { mutex_destruct(&mutex); } @@ -37,43 +28,32 @@ struct DriverLedger { void unlock() { mutex_unlock(&mutex); } }; -static DriverLedger& get_ledger() { - static DriverLedger ledger; - return ledger; -} - -#define ledger get_ledger() - -#define get_driver_private(driver) static_cast(driver->driver_private) -#define driver_lock(driver) mutex_lock(&get_driver_private(driver)->mutex); -#define driver_unlock(driver) mutex_unlock(&get_driver_private(driver)->mutex); +static DriverLedger ledger; extern "C" { error_t driver_construct(Driver* driver) { - driver->driver_private = new(std::nothrow) DriverPrivate; - if (driver->driver_private == nullptr) { + driver->internal = new(std::nothrow) DriverInternal; + if (driver->internal == nullptr) { return ERROR_OUT_OF_MEMORY; } return ERROR_NONE; } error_t driver_destruct(Driver* driver) { - driver_lock(driver); - // No module means the system owns it and it cannot be destroyed + auto* internal = driver->internal; + if (driver->owner == nullptr) { - driver_unlock(driver); return ERROR_NOT_ALLOWED; } - if (get_driver_private(driver)->use_count != 0 || get_driver_private(driver)->destroying) { - driver_unlock(driver); + if (internal->use_count != 0 || internal->destroying) { return ERROR_INVALID_STATE; } - get_driver_private(driver)->destroying = true; + internal->destroying = true; - driver_unlock(driver); - delete get_driver_private(driver); - driver->driver_private = nullptr; + // Nullify internal reference before deletion to prevent use-after-free + driver->internal = nullptr; + delete internal; return ERROR_NONE; } @@ -143,10 +123,8 @@ Driver* driver_find_compatible(const char* compatible) { } error_t driver_bind(Driver* driver, Device* device) { - driver_lock(driver); - error_t error = ERROR_NONE; - if (get_driver_private(driver)->destroying || !device_is_added(device)) { + if (driver->internal->destroying || !device_is_added(device)) { error = ERROR_INVALID_STATE; goto error; } @@ -158,23 +136,18 @@ error_t driver_bind(Driver* driver, Device* device) { } } - get_driver_private(driver)->use_count++; - driver_unlock(driver); + driver->internal->use_count++; LOG_I(TAG, "bound %s to %s", driver->name, device->name); return ERROR_NONE; error: - - driver_unlock(driver); return error; } error_t driver_unbind(Driver* driver, Device* device) { - driver_lock(driver); - error_t error = ERROR_NONE; - if (get_driver_private(driver)->destroying || !device_is_added(device)) { + if (driver->internal->destroying || !device_is_added(device)) { error = ERROR_INVALID_STATE; goto error; } @@ -186,16 +159,13 @@ error_t driver_unbind(Driver* driver, Device* device) { } } - get_driver_private(driver)->use_count--; - driver_unlock(driver); + driver->internal->use_count--; LOG_I(TAG, "unbound %s from %s", driver->name, device->name); return ERROR_NONE; error: - - driver_unlock(driver); return error; } diff --git a/TactilityKernel/Source/drivers/gpio_controller.cpp b/TactilityKernel/Source/drivers/gpio_controller.cpp index 4fe89ac5..f7e3a583 100644 --- a/TactilityKernel/Source/drivers/gpio_controller.cpp +++ b/TactilityKernel/Source/drivers/gpio_controller.cpp @@ -32,6 +32,8 @@ error_t gpio_controller_get_pin_count(struct Device* device, uint32_t* count) { return GPIO_DRIVER_API(driver)->get_pin_count(device, count); } -extern const struct DeviceType GPIO_CONTROLLER_TYPE { 0 }; +extern const struct DeviceType GPIO_CONTROLLER_TYPE { + .name = "gpio-controller" +}; } diff --git a/TactilityKernel/Source/drivers/i2c_controller.cpp b/TactilityKernel/Source/drivers/i2c_controller.cpp index 661cf1df..31a92519 100644 --- a/TactilityKernel/Source/drivers/i2c_controller.cpp +++ b/TactilityKernel/Source/drivers/i2c_controller.cpp @@ -49,6 +49,8 @@ error_t i2c_controller_has_device_at_address(Device* device, uint8_t address, Ti return I2C_DRIVER_API(driver)->write(device, address, message, 2, timeout); } -extern const struct DeviceType I2C_CONTROLLER_TYPE { 0 }; +extern const struct DeviceType I2C_CONTROLLER_TYPE { + .name = "i2c-controller" +}; } diff --git a/TactilityKernel/Source/drivers/i2s_controller.cpp b/TactilityKernel/Source/drivers/i2s_controller.cpp index ba0c8b27..e4c04c72 100644 --- a/TactilityKernel/Source/drivers/i2s_controller.cpp +++ b/TactilityKernel/Source/drivers/i2s_controller.cpp @@ -32,6 +32,8 @@ error_t i2s_controller_reset(struct Device* device) { return I2S_DRIVER_API(driver)->reset(device); } -extern const struct DeviceType I2S_CONTROLLER_TYPE { 0 }; +extern const struct DeviceType I2S_CONTROLLER_TYPE { + .name = "i2s-controller" +}; } diff --git a/TactilityKernel/Source/kernel_init.cpp b/TactilityKernel/Source/kernel_init.cpp index ee492ed3..58aca07e 100644 --- a/TactilityKernel/Source/kernel_init.cpp +++ b/TactilityKernel/Source/kernel_init.cpp @@ -23,7 +23,8 @@ struct Module root_module = { .name = "kernel", .start = start, .stop = stop, - .symbols = (const struct ModuleSymbol*)KERNEL_SYMBOLS + .symbols = (const struct ModuleSymbol*)KERNEL_SYMBOLS, + .internal = nullptr }; error_t kernel_init(struct Module* platform_module, struct Module* device_module, struct CompatibleDevice devicetree_devices[]) { diff --git a/TactilityKernel/Source/module.cpp b/TactilityKernel/Source/module.cpp index ff1def98..51200f43 100644 --- a/TactilityKernel/Source/module.cpp +++ b/TactilityKernel/Source/module.cpp @@ -1,14 +1,19 @@ -#include -#include +#include #include +#include #include #include +#include #define TAG "module" +struct ModuleInternal { + bool started = false; +}; + struct ModuleLedger { std::vector modules; - struct Mutex mutex = { 0 }; + struct Mutex mutex {}; ModuleLedger() { mutex_construct(&mutex); } ~ModuleLedger() { mutex_destruct(&mutex); } @@ -19,11 +24,14 @@ static ModuleLedger ledger; extern "C" { error_t module_construct(struct Module* module) { - module->internal.started = false; + module->internal = new (std::nothrow) ModuleInternal(); + if (module->internal == nullptr) return ERROR_OUT_OF_MEMORY; return ERROR_NONE; } error_t module_destruct(struct Module* module) { + delete static_cast(module->internal); + module->internal = nullptr; return ERROR_NONE; } @@ -44,28 +52,30 @@ error_t module_remove(struct Module* module) { error_t module_start(struct Module* module) { LOG_I(TAG, "start %s", module->name); - if (module->internal.started) return ERROR_NONE; + auto* internal = static_cast(module->internal); + if (internal->started) return ERROR_NONE; error_t error = module->start(); - module->internal.started = (error == ERROR_NONE); + internal->started = (error == ERROR_NONE); return error; } bool module_is_started(struct Module* module) { - return module->internal.started; + return static_cast(module->internal)->started; } error_t module_stop(struct Module* module) { LOG_I(TAG, "stop %s", module->name); - if (!module->internal.started) return ERROR_NONE; + auto* internal = static_cast(module->internal); + if (!internal->started) return ERROR_NONE; error_t error = module->stop(); if (error != ERROR_NONE) { return error; } - module->internal.started = false; + internal->started = false; return error; } @@ -106,4 +116,3 @@ bool module_resolve_symbol_global(const char* symbol_name, uintptr_t* symbol_add } } - diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5883c72c..7cae47be 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,6 +1,6 @@ project(tests) -set(DOCTESTINC ${PROJECT_SOURCE_DIR}/Include) +set(DOCTESTINC ${PROJECT_SOURCE_DIR}/Doctest/Include) enable_testing() add_subdirectory(TactilityCore) diff --git a/Tests/Include/doctest.h b/Tests/Doctest/Include/doctest.h similarity index 100% rename from Tests/Include/doctest.h rename to Tests/Doctest/Include/doctest.h diff --git a/Tests/Tactility/CMakeLists.txt b/Tests/Tactility/CMakeLists.txt index 9a070b7c..c31c724d 100644 --- a/Tests/Tactility/CMakeLists.txt +++ b/Tests/Tactility/CMakeLists.txt @@ -4,16 +4,12 @@ enable_language(C CXX ASM) set(CMAKE_CXX_COMPILER g++) -file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/*.cpp) +file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/Source/*.cpp) add_executable(TactilityTests EXCLUDE_FROM_ALL ${TEST_SOURCES}) -target_include_directories(TactilityTests PRIVATE - ${DOCTESTINC} -) +target_include_directories(TactilityTests PRIVATE ${DOCTESTINC}) -add_test(NAME TactilityTests - COMMAND TactilityTests -) +add_test(NAME TactilityTests COMMAND TactilityTests) target_link_libraries(TactilityTests PRIVATE Tactility diff --git a/Tests/Tactility/HalDeviceTest.cpp b/Tests/Tactility/Source/HalDeviceTest.cpp similarity index 100% rename from Tests/Tactility/HalDeviceTest.cpp rename to Tests/Tactility/Source/HalDeviceTest.cpp diff --git a/Tests/Tactility/Main.cpp b/Tests/Tactility/Source/Main.cpp similarity index 100% rename from Tests/Tactility/Main.cpp rename to Tests/Tactility/Source/Main.cpp diff --git a/Tests/Tactility/ObjectFileTest.cpp b/Tests/Tactility/Source/ObjectFileTest.cpp similarity index 100% rename from Tests/Tactility/ObjectFileTest.cpp rename to Tests/Tactility/Source/ObjectFileTest.cpp diff --git a/Tests/Tactility/PropertiesFileTest.cpp b/Tests/Tactility/Source/PropertiesFileTest.cpp similarity index 88% rename from Tests/Tactility/PropertiesFileTest.cpp rename to Tests/Tactility/Source/PropertiesFileTest.cpp index 2face09b..fdf467d6 100644 --- a/Tests/Tactility/PropertiesFileTest.cpp +++ b/Tests/Tactility/Source/PropertiesFileTest.cpp @@ -1,7 +1,7 @@ -#include "../TactilityCore/TestFile.h" -#include "doctest.h" +#include "../../TactilityCore/Source/TestFile.h" +#include "../../Tactility/Include/Tactility/file/PropertiesFile.h" -#include <../../Tactility/Include/Tactility/file/PropertiesFile.h> +#include "doctest.h" using namespace tt; diff --git a/Tests/Tactility/UrlTest.cpp b/Tests/Tactility/Source/UrlTest.cpp similarity index 100% rename from Tests/Tactility/UrlTest.cpp rename to Tests/Tactility/Source/UrlTest.cpp diff --git a/Tests/TactilityCore/CMakeLists.txt b/Tests/TactilityCore/CMakeLists.txt index a97a301b..93f494da 100644 --- a/Tests/TactilityCore/CMakeLists.txt +++ b/Tests/TactilityCore/CMakeLists.txt @@ -4,16 +4,12 @@ enable_language(C CXX ASM) set(CMAKE_CXX_COMPILER g++) -file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/*.cpp) +file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/Source/*.cpp) add_executable(TactilityCoreTests EXCLUDE_FROM_ALL ${TEST_SOURCES}) -target_include_directories(TactilityCoreTests PRIVATE - ${DOCTESTINC} -) +target_include_directories(TactilityCoreTests PRIVATE ${DOCTESTINC}) -add_test(NAME TactilityCoreTests - COMMAND TactilityCoreTests -) +add_test(NAME TactilityCoreTests COMMAND TactilityCoreTests) target_link_libraries(TactilityCoreTests PUBLIC TactilityCore diff --git a/Tests/TactilityCore/BundleTest.cpp b/Tests/TactilityCore/Source/BundleTest.cpp similarity index 100% rename from Tests/TactilityCore/BundleTest.cpp rename to Tests/TactilityCore/Source/BundleTest.cpp diff --git a/Tests/TactilityCore/FileTest.cpp b/Tests/TactilityCore/Source/FileTest.cpp similarity index 100% rename from Tests/TactilityCore/FileTest.cpp rename to Tests/TactilityCore/Source/FileTest.cpp diff --git a/Tests/TactilityCore/Main.cpp b/Tests/TactilityCore/Source/Main.cpp similarity index 100% rename from Tests/TactilityCore/Main.cpp rename to Tests/TactilityCore/Source/Main.cpp diff --git a/Tests/TactilityCore/StringTest.cpp b/Tests/TactilityCore/Source/StringTest.cpp similarity index 100% rename from Tests/TactilityCore/StringTest.cpp rename to Tests/TactilityCore/Source/StringTest.cpp diff --git a/Tests/TactilityCore/TestFile.h b/Tests/TactilityCore/Source/TestFile.h similarity index 100% rename from Tests/TactilityCore/TestFile.h rename to Tests/TactilityCore/Source/TestFile.h diff --git a/Tests/TactilityFreeRtos/CMakeLists.txt b/Tests/TactilityFreeRtos/CMakeLists.txt index 883244e4..a2558f8e 100644 --- a/Tests/TactilityFreeRtos/CMakeLists.txt +++ b/Tests/TactilityFreeRtos/CMakeLists.txt @@ -4,16 +4,12 @@ enable_language(C CXX ASM) set(CMAKE_CXX_COMPILER g++) -file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/*.cpp) +file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/Source/*.cpp) add_executable(TactilityFreeRtosTests EXCLUDE_FROM_ALL ${TEST_SOURCES}) -target_include_directories(TactilityFreeRtosTests PRIVATE - ${DOCTESTINC} -) +target_include_directories(TactilityFreeRtosTests PRIVATE ${DOCTESTINC}) -add_test(NAME TactilityFreeRtosTests - COMMAND TactilityFreeRtosTests -) +add_test(NAME TactilityFreeRtosTests COMMAND TactilityFreeRtosTests) target_link_libraries(TactilityFreeRtosTests PUBLIC TactilityFreeRtos diff --git a/Tests/TactilityFreeRtos/DispatcherTest.cpp b/Tests/TactilityFreeRtos/Source/DispatcherTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/DispatcherTest.cpp rename to Tests/TactilityFreeRtos/Source/DispatcherTest.cpp diff --git a/Tests/TactilityFreeRtos/DispatcherThreadTest.cpp b/Tests/TactilityFreeRtos/Source/DispatcherThreadTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/DispatcherThreadTest.cpp rename to Tests/TactilityFreeRtos/Source/DispatcherThreadTest.cpp diff --git a/Tests/TactilityFreeRtos/LockTest.cpp b/Tests/TactilityFreeRtos/Source/LockTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/LockTest.cpp rename to Tests/TactilityFreeRtos/Source/LockTest.cpp diff --git a/Tests/TactilityFreeRtos/Main.cpp b/Tests/TactilityFreeRtos/Source/Main.cpp similarity index 100% rename from Tests/TactilityFreeRtos/Main.cpp rename to Tests/TactilityFreeRtos/Source/Main.cpp diff --git a/Tests/TactilityFreeRtos/MessageQueueTest.cpp b/Tests/TactilityFreeRtos/Source/MessageQueueTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/MessageQueueTest.cpp rename to Tests/TactilityFreeRtos/Source/MessageQueueTest.cpp diff --git a/Tests/TactilityFreeRtos/MutexTest.cpp b/Tests/TactilityFreeRtos/Source/MutexTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/MutexTest.cpp rename to Tests/TactilityFreeRtos/Source/MutexTest.cpp diff --git a/Tests/TactilityFreeRtos/PubSubTest.cpp b/Tests/TactilityFreeRtos/Source/PubSubTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/PubSubTest.cpp rename to Tests/TactilityFreeRtos/Source/PubSubTest.cpp diff --git a/Tests/TactilityFreeRtos/RecursiveMutexTest.cpp b/Tests/TactilityFreeRtos/Source/RecursiveMutexTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/RecursiveMutexTest.cpp rename to Tests/TactilityFreeRtos/Source/RecursiveMutexTest.cpp diff --git a/Tests/TactilityFreeRtos/SemaphoreTest.cpp b/Tests/TactilityFreeRtos/Source/SemaphoreTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/SemaphoreTest.cpp rename to Tests/TactilityFreeRtos/Source/SemaphoreTest.cpp diff --git a/Tests/TactilityFreeRtos/ThreadTest.cpp b/Tests/TactilityFreeRtos/Source/ThreadTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/ThreadTest.cpp rename to Tests/TactilityFreeRtos/Source/ThreadTest.cpp diff --git a/Tests/TactilityFreeRtos/TimerTest.cpp b/Tests/TactilityFreeRtos/Source/TimerTest.cpp similarity index 100% rename from Tests/TactilityFreeRtos/TimerTest.cpp rename to Tests/TactilityFreeRtos/Source/TimerTest.cpp diff --git a/Tests/TactilityKernel/CMakeLists.txt b/Tests/TactilityKernel/CMakeLists.txt index 37589f7a..082d5dcb 100644 --- a/Tests/TactilityKernel/CMakeLists.txt +++ b/Tests/TactilityKernel/CMakeLists.txt @@ -4,7 +4,7 @@ enable_language(C CXX ASM) set(CMAKE_CXX_COMPILER g++) -file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/*.cpp) +file(GLOB_RECURSE TEST_SOURCES ${PROJECT_SOURCE_DIR}/Source/*.cpp) add_executable(TactilityKernelTests EXCLUDE_FROM_ALL ${TEST_SOURCES}) target_include_directories(TactilityKernelTests PRIVATE ${DOCTESTINC}) diff --git a/Tests/TactilityKernel/DeviceTest.cpp b/Tests/TactilityKernel/Source/DeviceTest.cpp similarity index 75% rename from Tests/TactilityKernel/DeviceTest.cpp rename to Tests/TactilityKernel/Source/DeviceTest.cpp index 48651813..897eda9c 100644 --- a/Tests/TactilityKernel/DeviceTest.cpp +++ b/Tests/TactilityKernel/Source/DeviceTest.cpp @@ -12,30 +12,26 @@ static Module module = { .stop = nullptr }; -TEST_CASE("device_construct and device_destruct should set and unset the correct fields") { +TEST_CASE("device_construct and device_destruct should set and unset the internal field") { Device device = { 0 }; error_t error = device_construct(&device); CHECK_EQ(error, ERROR_NONE); - CHECK_NE(device.internal.device_private, nullptr); - CHECK_NE(device.internal.mutex.handle, nullptr); + CHECK_NE(device.internal, nullptr); CHECK_EQ(device_destruct(&device), ERROR_NONE); - CHECK_EQ(device.internal.device_private, nullptr); - CHECK_EQ(device.internal.mutex.handle, nullptr); - - Device comparison_device = { 0 }; - comparison_device.internal.device_private = device.internal.device_private; - comparison_device.internal.mutex.handle = device.internal.mutex.handle; - - // Check that no other data was set - CHECK_EQ(memcmp(&device, &comparison_device, sizeof(Device)), 0); + CHECK_EQ(device.internal, nullptr); } TEST_CASE("device_add should add the device to the list of all devices") { - Device device = { 0 }; + Device device = { + .name = "device", + .config = nullptr, + .parent = nullptr, + .internal = nullptr + }; CHECK_EQ(device_construct(&device), ERROR_NONE); CHECK_EQ(device_add(&device), ERROR_NONE); @@ -55,12 +51,18 @@ TEST_CASE("device_add should add the device to the list of all devices") { } TEST_CASE("device_add should add the device to its parent") { - Device parent = { 0 }; + Device parent = { + .name = "parent", + .config = nullptr, + .parent = nullptr, + .internal = nullptr + }; Device child = { - .name = nullptr, + .name = "child", .config = nullptr, - .parent = &parent + .parent = &parent, + .internal = nullptr }; CHECK_EQ(device_construct(&parent), ERROR_NONE); @@ -88,19 +90,31 @@ TEST_CASE("device_add should add the device to its parent") { } TEST_CASE("device_add should set the state to 'added'") { - Device device = { 0 }; + Device device = { + .name = "device", + .config = nullptr, + .parent = nullptr, + .internal = nullptr + }; + CHECK_EQ(device_construct(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.added, false); + CHECK_EQ(device_is_added(&device), false); CHECK_EQ(device_add(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.added, true); + CHECK_EQ(device_is_added(&device), true); CHECK_EQ(device_remove(&device), ERROR_NONE); CHECK_EQ(device_destruct(&device), ERROR_NONE); } TEST_CASE("device_remove should remove it from the list of all devices") { - Device device = { 0 }; + Device device = { + .name = "device", + .config = nullptr, + .parent = nullptr, + .internal = nullptr + }; + CHECK_EQ(device_construct(&device), ERROR_NONE); CHECK_EQ(device_add(&device), ERROR_NONE); CHECK_EQ(device_remove(&device), ERROR_NONE); @@ -119,12 +133,18 @@ TEST_CASE("device_remove should remove it from the list of all devices") { } TEST_CASE("device_remove should remove the device from its parent") { - Device parent = { 0 }; + Device parent = { + .name = "parent", + .config = nullptr, + .parent = nullptr, + .internal = nullptr + }; Device child = { - .name = nullptr, + .name = "child", .config = nullptr, - .parent = &parent + .parent = &parent, + .internal = nullptr }; CHECK_EQ(device_construct(&parent), ERROR_NONE); @@ -151,13 +171,19 @@ TEST_CASE("device_remove should remove the device from its parent") { } TEST_CASE("device_remove should clear the state 'added'") { - Device device = { 0 }; + Device device = { + .name = "device", + .config = nullptr, + .parent = nullptr, + .internal = nullptr + }; + CHECK_EQ(device_construct(&device), ERROR_NONE); CHECK_EQ(device_add(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.added, true); + CHECK_EQ(device_is_added(&device), true); CHECK_EQ(device_remove(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.added, false); + CHECK_EQ(device_is_added(&device), false); CHECK_EQ(device_destruct(&device), ERROR_NONE); } @@ -172,7 +198,7 @@ TEST_CASE("device_is_ready should return true only when it is started") { .api = nullptr, .device_type = nullptr, .owner = &module, - .driver_private = nullptr + .internal = nullptr }; Device device = { 0 }; @@ -180,17 +206,17 @@ TEST_CASE("device_is_ready should return true only when it is started") { CHECK_EQ(driver_construct_add(&driver), ERROR_NONE); CHECK_EQ(device_construct(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.started, false); + CHECK_EQ(device_is_ready(&device), false); device_set_driver(&device, &driver); - CHECK_EQ(device.internal.state.started, false); + CHECK_EQ(device_is_ready(&device), false); CHECK_EQ(device_add(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.started, false); + CHECK_EQ(device_is_ready(&device), false); CHECK_EQ(device_start(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.started, true); + CHECK_EQ(device_is_ready(&device), true); CHECK_EQ(device_stop(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.started, false); + CHECK_EQ(device_is_ready(&device), false); CHECK_EQ(device_remove(&device), ERROR_NONE); - CHECK_EQ(device.internal.state.started, false); + CHECK_EQ(device_is_ready(&device), false); CHECK_EQ(device_destruct(&device), ERROR_NONE); CHECK_EQ(driver_remove_destruct(&driver), ERROR_NONE); diff --git a/Tests/TactilityKernel/DispatcherTest.cpp b/Tests/TactilityKernel/Source/DispatcherTest.cpp similarity index 100% rename from Tests/TactilityKernel/DispatcherTest.cpp rename to Tests/TactilityKernel/Source/DispatcherTest.cpp diff --git a/Tests/TactilityKernel/DriverIntegrationTest.cpp b/Tests/TactilityKernel/Source/DriverIntegrationTest.cpp similarity index 98% rename from Tests/TactilityKernel/DriverIntegrationTest.cpp rename to Tests/TactilityKernel/Source/DriverIntegrationTest.cpp index afb82567..0d7f33fe 100644 --- a/Tests/TactilityKernel/DriverIntegrationTest.cpp +++ b/Tests/TactilityKernel/Source/DriverIntegrationTest.cpp @@ -38,7 +38,7 @@ static Driver integration_driver = { .api = nullptr, .device_type = nullptr, .owner = &module, - .driver_private = nullptr, + .internal = nullptr, }; TEST_CASE("driver with with start success and stop success should start and stop a device") { diff --git a/Tests/TactilityKernel/DriverTest.cpp b/Tests/TactilityKernel/Source/DriverTest.cpp similarity index 93% rename from Tests/TactilityKernel/DriverTest.cpp rename to Tests/TactilityKernel/Source/DriverTest.cpp index f7531202..6b364c83 100644 --- a/Tests/TactilityKernel/DriverTest.cpp +++ b/Tests/TactilityKernel/Source/DriverTest.cpp @@ -15,10 +15,10 @@ TEST_CASE("driver_construct and driver_destruct should set and unset the correct CHECK_EQ(driver_construct(&driver), ERROR_NONE); CHECK_EQ(driver_add(&driver), ERROR_NONE); - CHECK_NE(driver.driver_private, nullptr); + CHECK_NE(driver.internal, nullptr); CHECK_EQ(driver_remove(&driver), ERROR_NONE); CHECK_EQ(driver_destruct(&driver), ERROR_NONE); - CHECK_EQ(driver.driver_private, nullptr); + CHECK_EQ(driver.internal, nullptr); } TEST_CASE("a driver without a module should not be destructible") { @@ -40,7 +40,7 @@ TEST_CASE("driver_is_compatible should return true if a compatible value is foun .api = nullptr, .device_type = nullptr, .owner = &module, - .driver_private = nullptr + .internal = nullptr }; CHECK_EQ(driver_is_compatible(&driver, "test_compatible"), true); CHECK_EQ(driver_is_compatible(&driver, "nope"), false); @@ -57,7 +57,7 @@ TEST_CASE("driver_find should only find a compatible driver when the driver was .api = nullptr, .device_type = nullptr, .owner = &module, - .driver_private = nullptr + .internal = nullptr }; Driver* found_driver = driver_find_compatible("test_compatible"); diff --git a/Tests/TactilityKernel/Main.cpp b/Tests/TactilityKernel/Source/Main.cpp similarity index 100% rename from Tests/TactilityKernel/Main.cpp rename to Tests/TactilityKernel/Source/Main.cpp diff --git a/Tests/TactilityKernel/ModuleTest.cpp b/Tests/TactilityKernel/Source/ModuleTest.cpp similarity index 92% rename from Tests/TactilityKernel/ModuleTest.cpp rename to Tests/TactilityKernel/Source/ModuleTest.cpp index d4f00f8e..24d60fb7 100644 --- a/Tests/TactilityKernel/ModuleTest.cpp +++ b/Tests/TactilityKernel/Source/ModuleTest.cpp @@ -23,12 +23,12 @@ TEST_CASE("Module construction and destruction") { .start = test_start, .stop = test_stop, .symbols = nullptr, - .internal = {.started = false} + .internal = nullptr }; // Test successful construction CHECK_EQ(module_construct(&module), ERROR_NONE); - CHECK_EQ(module.internal.started, false); + CHECK_EQ(module_is_started(&module), false); // Test successful destruction CHECK_EQ(module_destruct(&module), ERROR_NONE); @@ -40,7 +40,7 @@ TEST_CASE("Module registration") { .start = test_start, .stop = test_stop, .symbols = nullptr, - .internal = {.started = false} + .internal = nullptr }; // module_add should succeed @@ -61,9 +61,11 @@ TEST_CASE("Module lifecycle") { .start = test_start, .stop = test_stop, .symbols = nullptr, - .internal = {.started = false} + .internal = nullptr }; + CHECK_EQ(module_construct(&module), ERROR_NONE); + // 1. Successful start (no parent required anymore) CHECK_EQ(module_start(&module), ERROR_NONE); CHECK_EQ(module_is_started(&module), true); @@ -104,6 +106,8 @@ TEST_CASE("Module lifecycle") { // Clean up: fix stop result so we can stop it test_stop_result = ERROR_NONE; CHECK_EQ(module_stop(&module), ERROR_NONE); + + CHECK_EQ(module_destruct(&module), ERROR_NONE); } TEST_CASE("Global symbol resolution") { @@ -117,9 +121,11 @@ TEST_CASE("Global symbol resolution") { .start = test_start, .stop = test_stop, .symbols = test_symbols, - .internal = {.started = false} + .internal = nullptr }; + REQUIRE_EQ(module_construct(&module), ERROR_NONE); + uintptr_t addr; // Should fail as it is not added or started CHECK_EQ(module_resolve_symbol_global("symbol_test_function", &addr), false); @@ -128,8 +134,8 @@ TEST_CASE("Global symbol resolution") { REQUIRE_EQ(module_start(&module), ERROR_NONE); // Still fails as symbols are null CHECK_EQ(module_resolve_symbol_global("symbol_test_function", &addr), true); - // Cleanup CHECK_EQ(module_remove(&module), ERROR_NONE); + CHECK_EQ(module_destruct(&module), ERROR_NONE); } diff --git a/Tests/TactilityKernel/MutexTest.cpp b/Tests/TactilityKernel/Source/MutexTest.cpp similarity index 100% rename from Tests/TactilityKernel/MutexTest.cpp rename to Tests/TactilityKernel/Source/MutexTest.cpp diff --git a/Tests/TactilityKernel/RecursiveMutexTest.cpp b/Tests/TactilityKernel/Source/RecursiveMutexTest.cpp similarity index 100% rename from Tests/TactilityKernel/RecursiveMutexTest.cpp rename to Tests/TactilityKernel/Source/RecursiveMutexTest.cpp diff --git a/Tests/TactilityKernel/ThreadTest.cpp b/Tests/TactilityKernel/Source/ThreadTest.cpp similarity index 100% rename from Tests/TactilityKernel/ThreadTest.cpp rename to Tests/TactilityKernel/Source/ThreadTest.cpp diff --git a/Tests/TactilityKernel/TimeAndDelay.cpp b/Tests/TactilityKernel/Source/TimeAndDelay.cpp similarity index 100% rename from Tests/TactilityKernel/TimeAndDelay.cpp rename to Tests/TactilityKernel/Source/TimeAndDelay.cpp diff --git a/Tests/TactilityKernel/TimerTest.cpp b/Tests/TactilityKernel/Source/TimerTest.cpp similarity index 100% rename from Tests/TactilityKernel/TimerTest.cpp rename to Tests/TactilityKernel/Source/TimerTest.cpp diff --git a/devicetree.c b/devicetree.c deleted file mode 100644 index c675bd3f..00000000 --- a/devicetree.c +++ /dev/null @@ -1,64 +0,0 @@ -// Default headers -#include -// DTS headers -#include -#include -#include -#include - -static const root_config_dt root_config = { - "LilyGO T-Deck" -}; - -static struct Device root = { - .name = "/", - .config = &root_config, - .parent = NULL, -}; - -static const esp32_i2s_config_dt i2s0_config = { - I2S_NUM_0, - 7, - 5, - 6, - GPIO_PIN_NONE, - GPIO_PIN_NONE -}; - -static struct Device i2s0 = { - .name = "i2s0", - .config = &i2s0_config, - .parent = &root, -}; - -static const esp32_i2c_config_dt i2c0_config = { - I2C_NUM_0, - 400000, - 18, - 8, - 0, - 0 -}; - -static struct Device i2c0 = { - .name = "i2c0", - .config = &i2c0_config, - .parent = &root, -}; - -static const esp32_i2c_config_dt i2c1_config = { - I2C_NUM_1, - 400000, - 43, - 44, - 0, - 0 -}; - -static struct Device i2c1 = { - .name = "i2c1", - .config = &i2c1_config, - .parent = &root, -}; - -static const esp32_gpio_config_dt gpio0_config = {