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

Add utilities for allocating dynamic grants. #2053

Merged
merged 2 commits into from
Sep 17, 2020

Commits on Jul 29, 2020

  1. Add utilities for allocating dynamic grants.

    This adds two new utilities allocating arbitrary types as grants
    to kernel::grant::Allocator, and splits the internal `alloc_unowned`
    method into `alloc_raw` and `alloc_default_unowned` to allow allocating
    non-`Default` values.
    
    The new `alloc` allows allocating values not default-initializable,
    such as references to AppSlices. I believe this is a reasonable change,
    as no existing methods use `alloc`, and the new interface more closely
    matches other Rust allocation interfaces, such as `std::boxed::Box`.
    
    The new `alloc_n_with` then allows allocating a runtime-determined
    number of values. This will be useful if, for example, the size of
    allocation needed is determined by a variable given by a TockOS app.
    
    This is motivated by a use case in the Rubble BLE capsule, storing
    attributes. The number of attributes is usually known at compile-time
    for the app, but not for the kernel. If the capsule ends up using an
    array-like structure, `alloc_n_with` will be useful to allocate
    app-specific memory meant for dealing with attributes the app
    provides. If the capsule ends up using a linked-list-like structure,
    then the new `alloc` will allow allocating list nodes which contain
    non-Default data, such as `AppSlice`s. We don't necessarily need both
    interfaces, but I believe that together they form a sane base for
    everything one might need for dynamic memory allocation.
    
    Signed-off-by: David Ross <David.Ross@wdc.com>
    David Ross authored and David Ross committed Jul 29, 2020
    Configuration menu
    Copy the full SHA
    6f4ef06 View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2020

  1. Keep stackoverflow protections in alloc interface

    This also renames the function, as I think the closure makes it more of
    a "_with" function than not.
    
    Signed-off-by: David Ross <David.Ross@wdc.com>
    David Ross authored and David Ross committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    1dd5754 View commit details
    Browse the repository at this point in the history