Skip to content

Add caching policy configuration#60

Merged
d4ilyrun merged 8 commits intomasterfrom
59-caching-policies
Dec 26, 2025
Merged

Add caching policy configuration#60
d4ilyrun merged 8 commits intomasterfrom
59-caching-policies

Conversation

@d4ilyrun
Copy link
Owner

@d4ilyrun d4ilyrun commented Dec 26, 2025

Resolves #59

Remove the previous magic values, and add bit macros with explicit
names. This makes reading the code easier, and is more is sync with
what's done for device registers.
We do not check whether the running CPU supports the CPUID instruction,
but this should not be the case unless we are running on ancient
hardware.
This structure contains information about the system's CPU. It is
intended to be used to fetch the CPU's capabilities instead of using
and parsing the CPUID instruction each time.

We will surely be adding more fields in the future (e.g. processor
model).
Split the mmu_init() function into distinct parts using sub-functions
to make it more readable. This will also help when having to initialize
the PAT table in the next commits.
Reference: Intel SDM 2023 volume 3 chapter 12 (Memory cache control)
The caching policy used for a vm_segment is now explicitely configured
inside the segment's flag. The chosen policy is forwarded to the MMU API
when mapping an address inside the segment.

This commit also adds the vm_set_policy() function that can be called
to dynamically re-configure these policies for an already existing
segment.

When no policies are specified the API defaults back to using write-back
caching (regular caching).
Accesses to memory-mapped I/O often have side-effects and should not
be combined or delayed. Add a new VM_IOMEM flag that should be used
with memory-mapped registers.
@d4ilyrun d4ilyrun linked an issue Dec 26, 2025 that may be closed by this pull request
@d4ilyrun d4ilyrun self-assigned this Dec 26, 2025
@d4ilyrun d4ilyrun added target: kernel Kernel related features arch: x86 x86 specific features type: new Implement a new feature labels Dec 26, 2025
@d4ilyrun d4ilyrun merged commit a2aa406 into master Dec 26, 2025
2 checks passed
@d4ilyrun d4ilyrun deleted the 59-caching-policies branch December 26, 2025 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch: x86 x86 specific features target: kernel Kernel related features type: new Implement a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x86: memory: allow configuring caching policies

1 participant