Skip to content
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

core: remove Core_env #5408

Open
nfeske opened this issue Dec 18, 2024 · 1 comment
Open

core: remove Core_env #5408

nfeske opened this issue Dec 18, 2024 · 1 comment

Comments

@nfeske
Copy link
Member

nfeske commented Dec 18, 2024

The Core_env is a relic from olden times before we fully embraced the dependency-injection pattern in our code base. Its implementation is merely a hollow shadow of its former self but it still exists. The time is ripe to abandon it.

@nfeske nfeske added the cleanup label Dec 18, 2024
nfeske added a commit to nfeske/genode that referenced this issue Dec 18, 2024
Replace the use of the global 'core_env()' accessor by the explicit
delegation of interfaces.

- For allocating UTCBs in base-hw, 'Platform_thread' requires
  a way to allocate dataspaces ('Ram_allocator') accounted to the
  corresponding CPU session, a way to locally map the allocated
  dataspaces (core's 'Region_map'), and a way to determine the
  physical address (via 'Rpc_entrypoint') used for the initial
  UTCB mapping of main threads. Hence those interfaces must be
  passed to 'Platform_thread'.

- NOVA's pager code needs to look up 'Cpu_thread_component'
  objects using a map item as key. The lookup requires the
  'Rpc_entrypoint' that hold the 'Cpu_thread_component' objects.
  To make this 'Rpc_entrypoint' available, this patch adds
  the 'init_page_fault_handing' function.

- The 'Region_map_mmap' for Linux requires a way to look up
  'Linux_dataspace' objects for given dataspace capabilities.
  This lookup requires the 'Rpc_entrypoint' holding the dataspaces,
  which is now passed to 'platform.cc' via the new Linux-specific
  'Core_region_map::init' function.

Issue genodelabs#5408
nfeske added a commit to nfeske/genode that referenced this issue Dec 18, 2024
This patch replaces the use of 'core_env()' in 'platform_services.cc' by
the function arguments 'core_ram', 'core_rm', and 'io_port_ranges'.

It also removes the 'Pd_session' argument from 'Io_port_root' and
'Irq_root' to avoid the reliance on the 'Pd_session' interface within
core,

Issue genodelabs#5408
nfeske added a commit to nfeske/genode that referenced this issue Dec 18, 2024
Core uses an instance of 'Pd_session_component' as a representative
for RAM/cap quota accounts used whenever session resources are
donated to core's services. All other facets of 'Pd_sesson_component'
remain unused. Core's instance of 'Pd_session_component' is hosted
at 'Core_env'. Upon its construction, all unused facets of
'Pd_session_component' are initialized by dummy arguments in 'Core_env'.

To overcome the need for dummy arguments, this patch splits the
accounting part of the PD-session interface into a separate
'Pd_account' interface. This gives us the prospect of narrowing
core's current use of 'Pd_session_component' by 'Pd_account',
alleviating dead code and the need for any dummy arguments.

Issue genodelabs#5408
nfeske added a commit to nfeske/genode that referenced this issue Dec 18, 2024
This patch adjusts the last remaining callers of 'core_env' and removes
the 'Core_env' interface.

- Core's RAM/cap accounts are now represented by 'Core_account'
  implementing the 'Pd_account' interface.

- The former parts of 'Core_env' are now initialized in sequence
  in 'bootstrap_component'.

- 'Core_child' has been moved to a header to reduce the code in
  'main.cc' to a bare minimum. This as a preparation for the
  plan of making 'main.cc' specific for each kernel.

Fixes genodelabs#5408
@nfeske nfeske added the fixed label Dec 18, 2024
@nfeske
Copy link
Member Author

nfeske commented Dec 18, 2024

The four commit on my https://github.com/nfeske/genode/commits/core_pd_session branch contain this change.

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

No branches or pull requests

1 participant