altos: Allow AO_CONFIG_MAX_SIZE to be configured. Validate it.
authorKeith Packard <keithp@keithp.com>
Sat, 7 Jun 2014 17:05:21 +0000 (10:05 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 7 Jun 2014 17:05:21 +0000 (10:05 -0700)
TeleMega config is 200 bytes. AO_CONFIG_MAX_SIZE was 128. That didn't
work out well when logging erased flight information. Allow TeleMega
to use a larger value (1k), and then do a compiler hack to make sure
the defined value is at least as large as the ao_config structure.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_config.h

index 85673764e62c5d0f8a781ae328646c8d49506a0e..7ad221c68487d77df865739e653829ea5605f7f9 100644 (file)
@@ -112,7 +112,12 @@ struct ao_config {
 #define AO_PAD_ORIENTATION_ANTENNA_UP  0
 #define AO_PAD_ORIENTATION_ANTENNA_DOWN        1
 
 #define AO_PAD_ORIENTATION_ANTENNA_UP  0
 #define AO_PAD_ORIENTATION_ANTENNA_DOWN        1
 
+#ifndef AO_CONFIG_MAX_SIZE
 #define AO_CONFIG_MAX_SIZE     128
 #define AO_CONFIG_MAX_SIZE     128
+#endif
+
+/* Make sure AO_CONFIG_MAX_SIZE is big enough */
+typedef uint8_t        config_check_space[(int) (AO_CONFIG_MAX_SIZE - sizeof (struct ao_config))];
 
 extern __xdata struct ao_config ao_config;
 extern __pdata uint8_t ao_config_loaded;
 
 extern __xdata struct ao_config ao_config;
 extern __pdata uint8_t ao_config_loaded;