int psci_check_afflvl_range(int start_afflvl, int end_afflvl)
{
/* Sanity check the parameters passed */
- if (end_afflvl > MPIDR_MAX_AFFLVL)
+ if (end_afflvl > get_max_afflvl())
return PSCI_E_INVALID_PARAMS;
if (start_afflvl < MPIDR_AFFLVL0)
/* Sanity check the requested state */
target_afflvl = psci_get_pstate_afflvl(power_state);
- if (target_afflvl > MPIDR_MAX_AFFLVL)
+ if (target_afflvl > get_max_afflvl())
return PSCI_E_INVALID_PARAMS;
/* Determine the 'state type' in the 'power_state' parameter */
if (max_idx < min_idx)
return PSCI_E_INVALID_PARAMS;
+ /*
+ * Make sure we are within array limits.
+ */
+ assert(min_idx >= 0 && max_idx < PSCI_NUM_AFFS);
+
/*
* Bisect the array around 'mid' and then recurse into the array chunk
* where the key is likely to be found. The mpidrs in each node in the
* order which makes the binary search possible.
*/
mid = min_idx + ((max_idx - min_idx) >> 1); /* Divide by 2 */
+
if (psci_aff_map[mid].mpidr > key)
return psci_aff_map_get_idx(key, min_idx, mid - 1);
else if (psci_aff_map[mid].mpidr < key)
{
int rc;
+ if (aff_lvl > get_max_afflvl())
+ return NULL;
+
/* Right shift the mpidr to the required affinity level */
mpidr = mpidr_mask_lower_afflvls(mpidr, aff_lvl);