Skip to content

Commit 054c564

Browse files
crafcat7xiaoxiang781216
authored andcommitted
arm_mpu:Fix mpu_initialize not taking effect
Modified the input parameters of mpu_initialize to require the caller to provide the number of entries in the table Signed-off-by: chenrun1 <[email protected]>
1 parent 62f598e commit 054c564

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

arch/arm/src/armv7-m/arm_mpu.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
558558
*
559559
* Input Parameters:
560560
* table - MPU initialization table.
561+
* count - Initialize the number of entries in the region table.
561562
* hfnmiena - A boolean indicating whether the MPU should enable the
562563
* HFNMIENA bit.
563564
* privdefena - A boolean indicating whether the MPU should enable the
@@ -568,14 +569,14 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
568569
*
569570
****************************************************************************/
570571

571-
void mpu_initialize(const struct mpu_region_s *table, bool hfnmiena,
572-
bool privdefena)
572+
void mpu_initialize(const struct mpu_region_s *table, size_t count,
573+
bool hfnmiena, bool privdefena)
573574
{
574575
const struct mpu_region_s *conf;
575-
int index;
576+
size_t index;
576577

577578
mpu_control(false, false, false);
578-
for (index = 0; index < nitems(table); index++)
579+
for (index = 0; index < count; index++)
579580
{
580581
conf = &table[index];
581582
mpu_configure_region(conf->base, conf->size, conf->flags);

arch/arm/src/armv7-m/mpu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
380380
*
381381
* Input Parameters:
382382
* table - MPU initialization table.
383+
* count - Initialize the number of entries in the region table.
383384
* hfnmiena - A boolean indicating whether the MPU should enable the
384385
* HFNMIENA bit.
385386
* privdefena - A boolean indicating whether the MPU should enable the
@@ -390,8 +391,8 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
390391
*
391392
****************************************************************************/
392393

393-
void mpu_initialize(const struct mpu_region_s *table, bool hfnmiena,
394-
bool privdefena);
394+
void mpu_initialize(const struct mpu_region_s *table, size_t count,
395+
bool hfnmiena, bool privdefena);
395396

396397
/****************************************************************************
397398
* Inline Functions

arch/arm/src/armv7-r/arm_mpu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,19 +486,20 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
486486
*
487487
* Input Parameters:
488488
* table - MPU Initiaze table.
489+
* count - Initialize the number of entries in the region table.
489490
*
490491
* Returned Value:
491492
* NULL.
492493
*
493494
****************************************************************************/
494495

495-
void mpu_initialize(const struct mpu_region_s *table)
496+
void mpu_initialize(const struct mpu_region_s *table, size_t count)
496497
{
497498
const struct mpu_region_s *conf;
498-
int index;
499+
size_t index;
499500

500501
mpu_control(false);
501-
for (index = 0; index < nitems(table); index++)
502+
for (index = 0; index < count; index++)
502503
{
503504
conf = &table[index];
504505
mpu_configure_region(conf->base, conf->size, conf->flags);

arch/arm/src/armv7-r/mpu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,14 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
318318
*
319319
* Input Parameters:
320320
* table - MPU Initiaze table.
321+
* count - Initialize the number of entries in the region table.
321322
*
322323
* Returned Value:
323324
* NULL.
324325
*
325326
****************************************************************************/
326327

327-
void mpu_initialize(const struct mpu_region_s *table);
328+
void mpu_initialize(const struct mpu_region_s *table, size_t count);
328329

329330
/****************************************************************************
330331
* Inline Functions

arch/arm/src/armv8-m/arm_mpu.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
289289
*
290290
* Input Parameters:
291291
* table - MPU initialization table.
292+
* count - Initialize the number of entries in the region table.
292293
* hfnmiena - A boolean indicating whether the MPU should enable the
293294
* HFNMIENA bit.
294295
* privdefena - A boolean indicating whether the MPU should enable the
@@ -299,14 +300,14 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
299300
*
300301
****************************************************************************/
301302

302-
void mpu_initialize(const struct mpu_region_s *table, bool hfnmiena,
303-
bool privdefena)
303+
void mpu_initialize(const struct mpu_region_s *table, size_t count,
304+
bool hfnmiena, bool privdefena)
304305
{
305306
const struct mpu_region_s *conf;
306-
int index;
307+
size_t index;
307308

308309
mpu_control(false, false, false);
309-
for (index = 0; index < nitems(table); index++)
310+
for (index = 0; index < count; index++)
310311
{
311312
conf = &table[index];
312313
mpu_configure_region(conf->base, conf->size, conf->flags1,

arch/arm/src/armv8-m/mpu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
347347
*
348348
* Input Parameters:
349349
* table - MPU initialization table.
350+
* count - Initialize the number of entries in the region table.
350351
* hfnmiena - A boolean indicating whether the MPU should enable the
351352
* HFNMIENA bit.
352353
* privdefena - A boolean indicating whether the MPU should enable the
@@ -357,8 +358,8 @@ unsigned int mpu_configure_region(uintptr_t base, size_t size,
357358
*
358359
****************************************************************************/
359360

360-
void mpu_initialize(const struct mpu_region_s *table, bool hfnmiena,
361-
bool privdefena);
361+
void mpu_initialize(const struct mpu_region_s *table, size_t count,
362+
bool hfnmiena, bool privdefena);
362363

363364
/****************************************************************************
364365
* Inline Functions

0 commit comments

Comments
 (0)