Skip to content

Commit

Permalink
Components:MM:add early map api
Browse files Browse the repository at this point in the history
1.The earlycon in dm needs ioremap in early
initialization such as uart mmio.
2.Add name member in rt_region_t that user
could know what's mean of a memory region.

Signed-off-by: GuEe-GUI <[email protected]>
  • Loading branch information
GuEe-GUI committed Jul 31, 2023
1 parent 3278369 commit 3e49b6a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ static void *_ioremap_type(void *paddr, size_t size, enum ioremap_type type)
return v_addr;
}

rt_weak void *rt_ioremap_early(void *paddr, size_t size)
{
if (!size)
{
return RT_NULL;
}

return paddr;
}

void *rt_ioremap(void *paddr, size_t size)
{
return _ioremap_type(paddr, size, MM_AREA_TYPE_PHY);
Expand Down
1 change: 1 addition & 0 deletions components/mm/ioremap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {
* | Currently as non-cacheable
*/

void *rt_ioremap_early(void *paddr, size_t size);
void *rt_ioremap(void *paddr, size_t size);
void *rt_ioremap_nocache(void *paddr, size_t size);
void *rt_ioremap_cached(void *paddr, size_t size);
Expand Down
2 changes: 2 additions & 0 deletions components/mm/mm_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ typedef struct tag_region
{
rt_size_t start;
rt_size_t end;

const char *name;
} rt_region_t;

extern const rt_size_t rt_mpr_size;
Expand Down
25 changes: 25 additions & 0 deletions libcpu/aarch64/common/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,31 @@ static int _map_single_page_2M(unsigned long *lv0_tbl, unsigned long va,
return 0;
}

void *rt_ioremap_early(void *paddr, size_t size)
{
size_t count;
static void *tbl = RT_NULL;

if (!size)
{
return RT_NULL;
}

if (!tbl)
{
tbl = rt_hw_mmu_tbl_get();
}

count = (size + ARCH_SECTION_MASK) >> ARCH_SECTION_SHIFT;

while (count --> 0)
{
_map_single_page_2M(tbl, (unsigned long)paddr, (unsigned long)paddr, MMU_MAP_K_DEVICE);
}

return paddr;
}

static int _init_map_2M(unsigned long *lv0_tbl, unsigned long va,
unsigned long pa, unsigned long count,
unsigned long attr)
Expand Down

0 comments on commit 3e49b6a

Please sign in to comment.