Skip to content

WIP: refactor hal #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

WIP: refactor hal #647

wants to merge 2 commits into from

Conversation

xvuko
Copy link
Contributor

@xvuko xvuko commented Apr 17, 2025

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @xvuko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request is a work in progress (WIP) focused on refactoring the HAL (Hardware Abstraction Layer). The primary change involves moving common page-related definitions and the page_t structure into a new hal/page.h file. This change aims to consolidate page management and improve code organization across different architectures. The hal/page.h header is then included in the architecture-specific pmap.h files. Additionally, the architecture-specific pmap.h files have had the page_t struct and page flags removed, as these are now defined in the common hal/page.h header.

Highlights

  • Code Reorganization: Common page-related definitions and the page_t structure are moved to a new hal/page.h file.
  • Header Inclusion: The hal/page.h header is included in architecture-specific pmap.h files to provide access to the shared page definitions.
  • Duplication Removal: The page_t struct and page flags are removed from architecture-specific pmap.h files, as they are now defined in hal/page.h.

Changelog

Click here to see the changelog
  • hal/aarch64/arch/pmap.h
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 40-52.
    • Removed page_t struct definition from lines 57-63.
  • hal/armv7a/arch/pmap.h
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 42-54.
    • Removed page_t struct definition from lines 59-65.
  • hal/armv7m/arch/pmap.h
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 30-42.
    • Removed page_t struct definition from lines 47-52.
  • hal/armv7r/arch/pmap.h
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 29-41.
    • Removed page_t struct definition from lines 46-51.
  • hal/armv8m/arch/pmap.h
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 29-41.
    • Removed page_t struct definition from lines 46-51.
    • Removed u32 mpr member from pmap_t struct definition from line 55.
  • hal/armv8r/arch/pmap.h
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 29-41.
    • Removed page_t struct definition from lines 46-51.
    • Removed u32 mpr member from pmap_t struct definition from line 55.
  • hal/ia32/arch/pmap.h
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 53-65.
    • Removed page_t struct definition from lines 77-83.
  • hal/page.h
    • Created new file hal/page.h containing common page definitions and the page_t structure.
  • hal/pmap.h
    • No significant changes.
  • hal/riscv64/arch/pmap.h
    • Added include for hal/page.h at line 19.
    • Removed page flags definitions from lines 36-48.
    • Removed PAGE_ALIGN and PAGE_OFFS macros from lines 61-62.
    • Removed page_t struct definition from lines 66-72.
  • hal/sparcv8leon/arch/pmap.h
    • Added include for hal/types.h at line 19.
    • Added include for hal/page.h at line 20.
    • Removed page flags definitions from lines 46-58.
    • Removed PAGE_ALIGN and PAGE_OFFS macros from lines 79-80.
    • Removed page_t struct definition from lines 83-89.
    • Removed u32 mpr member from pmap_t struct definition from line 110.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A page, a frame,
Memory's neat domain grows,
HAL's order takes hold.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request refactors the HAL (Hardware Abstraction Layer) related to memory management, specifically the pmap (physical map) component. The changes involve moving common page definitions into a shared hal/page.h file and removing redundant definitions from architecture-specific pmap headers. The goal appears to be to reduce code duplication and improve maintainability. The changes look good overall, but there are a few things that can be improved.

Summary of Findings

  • Inclusion of hal/page.h: The addition of hal/page.h in multiple architecture-specific pmap.h files introduces a dependency that might not be necessary for all architectures. It's important to ensure that each architecture truly requires the definitions in hal/page.h to avoid unnecessary coupling.
  • Removal of page flags and page_t struct: The removal of page flags and the page_t struct from architecture-specific pmap.h files centralizes these definitions in hal/page.h. This is generally good for maintainability, but it's crucial to verify that all architectures still function correctly with this change and that no architecture-specific customizations are lost.
  • Copyright year: The copyright year in hal/page.h is 2025, which is in the future. This should be corrected to the current year or a range that includes the current year.

Merge Readiness

The pull request is not quite ready for merging. While the refactoring aims to improve code maintainability and reduce duplication, the potential impact on individual architectures needs careful verification. The copyright year in hal/page.h should also be corrected. I am unable to approve this pull request, and recommend that these issues be addressed before merging, and that others review and approve this code before merging.

Copy link

Unit Test Results

7 958 tests  ±0   7 434 ✅ ±0   42m 51s ⏱️ + 1m 55s
  470 suites ±0     524 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit e120aee. ± Comparison against base commit 053e367.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant