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

Discontinuous view section support #110

Closed
wants to merge 9 commits into from
Closed

Conversation

mentlerd
Copy link

This PR extends the pattern language's concept of sections to be more polymorphic. A section is defined as a (not necessarily contiguous!) area of address space which can be read/written with chunked IO operations, and can provide additional information about the chunks of data it contains.

This generalisation allows the implementation of "view sections". These sections don't host chunks themselves, instead they are a view over spans of already existing sections, such as the ones that can be created with std::mem::create_section, or the main section itself.

This allows parsing patterns over discontinuous area of the main section as-if the data was laid out linearly. For example:

auto view = builtin::std::mem::create_view_section("view");

for (u8 j = 0, j < sizeof(data), j = j + 4) {
    builtin::std::mem::append_view_section_span(view, 0 /* main section */, j, 2);
}

u128 value @ 0x00 in view;

This PR includes API breakage! The pattern language no longer exposes custom sections as std::vector<u8>, but provides api::Sections instead, which can be easily read to obtain their data.

Additionally, sections now may contain discontinuous data which requires additional care when rendering their contents, as trying to read unmapped areas of a section will result in an IOError being returned.

To support this usecase sections provide an API which may be used to iterate over their chunks' attributes.

Commit-by-commit review is highly advised!

@mentlerd mentlerd closed this Aug 7, 2024
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.

None yet

1 participant