HI Michal,

> On 17 Nov 2025, at 12:51, Orzel, Michal <[email protected]> wrote:
> 
> 
> 
> On 12/11/2025 17:06, Luca Fancellu wrote:
>> Hi Michal,
>> 
>>>>> +void __init setup_mm(void)
>>>>> +{
>>>>> +    const struct membanks *banks = bootinfo_get_mem();
>>>>> +    paddr_t ram_start = INVALID_PADDR;
>>>>> +    paddr_t ram_end = 0;
>>>>> +    paddr_t ram_size = 0;
>>>>> +    unsigned int i;
>>>>> +
>>>>> +    init_pdx();
>>>>> +
>>>>> +    for ( i = 0; i < banks->nr_banks; i++ )
>>>>> +    {
>>>>> +        const struct membank *bank = &banks->bank[i];
>>>>> +        paddr_t bank_end = bank->start + bank->size;
>>>>> +
>>>>> +        ram_size = ram_size + bank->size;
>>>>> +        ram_start = min(ram_start, bank->start);
>>>>> +        ram_end = max(ram_end, bank_end);
>>>>> +    }
>>>>> +
>>>>> +    total_pages = ram_size >> PAGE_SHIFT;
>>>>> +
>>>>> +    /*
>>>>> +     * On MMU systems we need some memory to allocate the page-tables 
>>>>> used for
>>>>> +     * the directmap mappings.  But some regions may contain memory 
>>>>> already
>>>>> +     * allocated for other uses (e.g. modules, reserved-memory...).
>>>>> +     *
>>>>> +     * On MPU systems we need to pre-reserve regions that were allocated 
>>>>> for
>>>>> +     * other uses (e.g. modules, reserved-memory...).
>>>> I'm not sure I understand this part of the comment with regards to
>>>> populate_boot_allocator(). Could you please explain?
>> 
>> Maybe here we should just write that on MPU system we are populating the 
>> boot allocator with the
>> static heap region, since static heap is mandatory for MPU.
>> 
>> What do you think?
> The reason for the original comment was to explain why we need to call
> populate_boot_allocator() that early (i.e. before setting up direct map and 
> not
> before setting up frametable). It's not about explaining why we need to 
> populate
> boot allocator because that is rather clear. In case of MPU I don't think 
> there
> is a reason for doing that early, so we might not need any reasoning.

ok sounds good, we can avoid mentioning the MPU section all together.

Cheers,
Luca


Reply via email to