uint8_t cf_off_time; /**< @brief Offset of @p p_time field. */
};
-#define GET_CH_KERNEL_MAJOR(codedVersion) ((codedVersion >> 11) & 0x1f)
-#define GET_CH_KERNEL_MINOR(codedVersion) ((codedVersion >> 6) & 0x1f)
-#define GET_CH_KERNEL_PATCH(codedVersion) ((codedVersion >> 0) & 0x3f)
+#define GET_CH_KERNEL_MAJOR(coded_version) ((coded_version >> 11) & 0x1f)
+#define GET_CH_KERNEL_MINOR(coded_version) ((coded_version >> 6) & 0x1f)
+#define GET_CH_KERNEL_PATCH(coded_version) ((coded_version >> 0) & 0x3f)
/**
* @brief ChibiOS thread states.
"WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "FINAL"
};
-#define CHIBIOS_NUM_STATES (sizeof(chibios_thread_states)/sizeof(char *))
+#define CHIBIOS_NUM_STATES ARRAY_SIZE(chibios_thread_states)
/* Maximum ChibiOS thread name. There is no real limit set by ChibiOS but 64
* chars ought to be enough.
NULL, /* stacking_info */
}
};
-#define CHIBIOS_NUM_PARAMS ((int)(sizeof(chibios_params_list)/sizeof(struct chibios_params)))
static bool chibios_detect_rtos(struct target *target);
static int chibios_create(struct target *target);
}
/* Convert endianness of version field */
- const uint8_t *versionTarget = (const uint8_t *)
+ const uint8_t *versiontarget = (const uint8_t *)
&signature->ch_version;
signature->ch_version = rtos->target->endianness == TARGET_LITTLE_ENDIAN ?
- le_to_h_u32(versionTarget) : be_to_h_u32(versionTarget);
+ le_to_h_u32(versiontarget) : be_to_h_u32(versiontarget);
const uint16_t ch_version = signature->ch_version;
LOG_INFO("Successfully loaded memory map of ChibiOS/RT target "
const struct chibios_params *param;
uint32_t stack_ptr = 0;
- if ((rtos == NULL) || (thread_id == 0) ||
- (rtos->rtos_specific_params == NULL))
+ if ((!rtos) || (thread_id == 0) ||
+ (!rtos->rtos_specific_params))
return -1;
param = (const struct chibios_params *) rtos->rtos_specific_params;
{
*symbol_list = malloc(sizeof(chibios_symbol_list));
- if (*symbol_list == NULL)
+ if (!*symbol_list)
return ERROR_FAIL;
memcpy(*symbol_list, chibios_symbol_list, sizeof(chibios_symbol_list));
static bool chibios_detect_rtos(struct target *target)
{
- if ((target->rtos->symbols != NULL) &&
+ if ((target->rtos->symbols) &&
((target->rtos->symbols[CHIBIOS_VAL_RLIST].address != 0) ||
(target->rtos->symbols[CHIBIOS_VAL_CH].address != 0))) {
static int chibios_create(struct target *target)
{
- int i = 0;
- while ((i < CHIBIOS_NUM_PARAMS) &&
- (0 != strcmp(chibios_params_list[i].target_name, target->type->name))) {
- i++;
- }
- if (i >= CHIBIOS_NUM_PARAMS) {
- LOG_WARNING("Could not find target \"%s\" in ChibiOS compatibility "
- "list", target->type->name);
- return -1;
- }
+ for (unsigned int i = 0; i < ARRAY_SIZE(chibios_params_list); i++)
+ if (strcmp(chibios_params_list[i].target_name, target->type->name) == 0) {
+ target->rtos->rtos_specific_params = (void *)&chibios_params_list[i];
+ return 0;
+ }
- target->rtos->rtos_specific_params = (void *) &chibios_params_list[i];
- return 0;
+ LOG_WARNING("Could not find target \"%s\" in ChibiOS compatibility "
+ "list", target->type->name);
+ return -1;
}