Commit 9afe8cdc authored by Deepika Bhavnani's avatar Deepika Bhavnani
Browse files

Coding guideline suggest not to use unsigned long



`unsigned long` should be replaced to
1. `unsigned int` or `unsigned long long` - If fixed,
based on the architecture AArch32 or AArch64
2. `u_register_t` - If it is supposed to be 32-bit
wide in AArch32 and 64-bit wide in AArch64.

Translation descriptors are always 32-bit wide, here
`uint32_t` is used to describe the `exact size` of
translation descriptors instead of `unsigned int` which
guarantees minimum 32-bits
Signed-off-by: default avatarDeepika Bhavnani <deepika.bhavnani@arm.com>
Change-Id: I6a2af2e8b3c71170e2634044e0b887f07a41677e
parent 1d2b4161
...@@ -284,10 +284,10 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va, ...@@ -284,10 +284,10 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
} }
/* map all memory as shared/global/domain0/no-usr access */ /* map all memory as shared/global/domain0/no-usr access */
static unsigned long mmap_desc(unsigned attr, unsigned long addr_pa, static uint32_t mmap_desc(unsigned attr, unsigned int addr_pa,
unsigned int level) unsigned int level)
{ {
unsigned long desc; uint32_t desc;
switch (level) { switch (level) {
case 1: case 1:
...@@ -380,14 +380,14 @@ static unsigned int mmap_region_attr(const mmap_region_t *mm, uintptr_t base_va, ...@@ -380,14 +380,14 @@ static unsigned int mmap_region_attr(const mmap_region_t *mm, uintptr_t base_va,
} }
static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm, static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
unsigned long base_va, unsigned int base_va,
unsigned long *table, uint32_t *table,
unsigned int level) unsigned int level)
{ {
unsigned int level_size_shift = (level == 1) ? unsigned int level_size_shift = (level == 1) ?
ONE_MB_SHIFT : FOUR_KB_SHIFT; ONE_MB_SHIFT : FOUR_KB_SHIFT;
unsigned int level_size = 1 << level_size_shift; unsigned int level_size = 1 << level_size_shift;
unsigned long level_index_mask = (level == 1) ? unsigned int level_index_mask = (level == 1) ?
(NUM_1MB_IN_4GB - 1) << ONE_MB_SHIFT : (NUM_1MB_IN_4GB - 1) << ONE_MB_SHIFT :
(NUM_4K_IN_1MB - 1) << FOUR_KB_SHIFT; (NUM_4K_IN_1MB - 1) << FOUR_KB_SHIFT;
...@@ -396,7 +396,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm, ...@@ -396,7 +396,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
VERBOSE("init xlat table at %p (level%1d)\n", (void *)table, level); VERBOSE("init xlat table at %p (level%1d)\n", (void *)table, level);
do { do {
unsigned long desc = MMU32B_UNSET_DESC; uint32_t desc = MMU32B_UNSET_DESC;
if (mm->base_va + mm->size <= base_va) { if (mm->base_va + mm->size <= base_va) {
/* Area now after the region so skip it */ /* Area now after the region so skip it */
...@@ -427,7 +427,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm, ...@@ -427,7 +427,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
} }
if (desc == MMU32B_UNSET_DESC) { if (desc == MMU32B_UNSET_DESC) {
unsigned long xlat_table; uintptr_t xlat_table;
/* /*
* Area not covered by a region so need finer table * Area not covered by a region so need finer table
...@@ -443,7 +443,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm, ...@@ -443,7 +443,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
~(MMU32B_L1_TABLE_ALIGN - 1); ~(MMU32B_L1_TABLE_ALIGN - 1);
desc = *table; desc = *table;
} else { } else {
xlat_table = (unsigned long)mmu_l2_base + xlat_table = (uintptr_t)mmu_l2_base +
next_xlat * MMU32B_L2_TABLE_SIZE; next_xlat * MMU32B_L2_TABLE_SIZE;
next_xlat++; next_xlat++;
assert(next_xlat <= MAX_XLAT_TABLES); assert(next_xlat <= MAX_XLAT_TABLES);
...@@ -456,7 +456,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm, ...@@ -456,7 +456,7 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
} }
/* Recurse to fill in new table */ /* Recurse to fill in new table */
mm = init_xlation_table_inner(mm, base_va, mm = init_xlation_table_inner(mm, base_va,
(unsigned long *)xlat_table, (uint32_t *)xlat_table,
level + 1); level + 1);
} }
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
...@@ -480,7 +480,7 @@ void init_xlat_tables(void) ...@@ -480,7 +480,7 @@ void init_xlat_tables(void)
memset(mmu_l1_base, 0, MMU32B_L1_TABLE_SIZE); memset(mmu_l1_base, 0, MMU32B_L1_TABLE_SIZE);
init_xlation_table_inner(mmap, 0, (unsigned long *)mmu_l1_base, 1); init_xlation_table_inner(mmap, 0, (uint32_t *)mmu_l1_base, 1);
VERBOSE("init xlat - max_va=%p, max_pa=%llx\n", VERBOSE("init xlat - max_va=%p, max_pa=%llx\n",
(void *)xlat_max_va, xlat_max_pa); (void *)xlat_max_va, xlat_max_pa);
......
...@@ -607,7 +607,8 @@ static uintptr_t xlat_tables_map_region(xlat_ctx_t *ctx, mmap_region_t *mm, ...@@ -607,7 +607,8 @@ static uintptr_t xlat_tables_map_region(xlat_ctx_t *ctx, mmap_region_t *mm,
} }
/* Point to new subtable from this one. */ /* Point to new subtable from this one. */
table_base[table_idx] = TABLE_DESC | (unsigned long)subtable; table_base[table_idx] =
TABLE_DESC | (uintptr_t)subtable;
/* Recurse to write into subtable */ /* Recurse to write into subtable */
end_va = xlat_tables_map_region(ctx, mm, table_idx_va, end_va = xlat_tables_map_region(ctx, mm, table_idx_va,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment