hal/armv7a: Adding IO mapping functionality in HAL initialization#787
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the ARMv7a HAL to dynamically map device memory using a new _pmap_halMapDevice function, replacing the previous approach of hardcoding virtual addresses relative to _end in boot assembly. Feedback on these changes focuses on addressing potential edge cases in _pmap_halMapDevice (such as zero-size mappings, page alignment spans, and slot exhaustion assertions), ensuring inline assembly consistency, using addr_t for physical addresses, and appending the U suffix to various hexadecimal constants to prevent signedness issues.
a9000e2 to
79086f2
Compare
Unit Test Results10 860 tests +275 10 190 ✅ +275 52m 59s ⏱️ +51s Results for commit ad0cef8. ± Comparison against base commit 57b3041. This pull request removes 3 and adds 278 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
79086f2 to
c197c89
Compare
c197c89 to
7401084
Compare
Create _pmap_halMapDevice() function similar to AArch64 implementation. YT: RTOS-1337
Change IMX6ULL console driver to respect UART_CONSOLE_KERNEL definition. YT: RTOS-1337
Change from previous method of copying syspage to the page after the end of kernel data to copying to a named object in .bss section. Remove SIZE_EXTEND_BSS from pmap.c as it is no longer necessary. YT: RTOS-1337
Fix incorrect mapping that could happen if offset within the page is not 0. YT: RTOS-1337
7401084 to
ad0cef8
Compare
Add IO memory mapping functionality similar to aarch64
Adjust code for imx6ull, zynq7000 targets to use this mapping functionality
Copy syspage to named object in
.bsssection instead of memory mapped past-the-end of.bssDescription
Previously the way memory-mapped IO devices were made available to the kernel on armv7a platforms was very unintuitive. Code within
_init.Smapped them past-the-end of.bsssection at arbitrarily chosen offsets, which made it difficult for someone reading the code to understand what was going on.To solve this, memory-mapped IO is now mapped near the top of the address space (range 0xFFC00000 - 0xFFFF0000) using unused entries in the page table
excptab. It is done using_pmap_halMapDevicefunction with the same API asaarch64,riscv64andsparcv8leontargets. The physical addresses of peripherals are now declared in C code close to the driver where they are actually used, which helps readability and maintainability.There are almost 4 MB of address space available through
excptabwhich should be more than enough considering our OS has a microkernel design with few built-in drivers.Additionally, memory for the syspage was also mapped past-the-end of
.bss- which was not necessary considering that syspage could simply be stored to a named object within.bss. After changing this, there is nothing more mapped past.bsson armv7a and this unintuitive mechanism could be removed.Other changes:
excptabwas removed - it was unused because this target supports Security extensions and thus exception vector address is set using the VBAR register. This doesn't change the functioning of the system.UART_CONSOLE_KERNELdefinition fromboard_config.h.Motivation and Context
Part of the work for phoenix-rtos/phoenix-rtos-project#1500
Types of changes
How Has This Been Tested?
Checklist:
Special treatment