- Get rid of kern_delta. Its definition makes no sense: KERNBASE is a virtual address and kernstart is a physical address.
- Don't use avail_slot to index into physmap, that just appears to be bug.
- Simplify the first stage of phys_avail initialization by avoiding the extra external if statement.
- Clean up and fix some comments for the second stage of phys_avail initialization.
- Rmeove some dead stores.
Booted under QEMU and spike. Used EARLY_PRINTF to verify
This is inspired by PR 231515?
Also, I wonder if in general it would be simpler if we had a single loop to populate phys_avail at the end that just split regions as necessary to skip over '[kernstart, freemempos (but PA instead of VA)]'?
I think used_map_slot can be removed. I think the result of these lines is:
used_map_slot = map_slot; /* Various bits that don't change map_slot. */ map_slot = used_map_slot;
What is the purpose of this section of code? The loop that walks L2 slots results in 'va' being set, but then 'va' isn't used in the rest of the function AFAICT. The old version set 'pa' that wasn't used either. The arm64 pmap_bootstrap() uses 'va' and 'pa' in a call to pmap_bootstrap_l2() before the call to pmap_bootstrap_l3(), but riscv doesn't have a pmap_bootstrap_l2()?
> Also, I wonder if in general it would be simpler if we had a single loop to populate phys_avail at the end that just split regions as necessary to skip over '[kernstart, freemempos (but PA instead of VA)]'?
It seems to be simpler, I did that in the latest upload.
I agree that it doesn't do anything, so I removed it for now.