06 Feb, 2020

1 commit

  • At present dm/device.h includes the linux-compatible features. This
    requires including linux/compat.h which in turn includes a lot of headers.
    One of these is malloc.h which we thus end up including in every file in
    U-Boot. Apart from the inefficiency of this, it is problematic for sandbox
    which needs to use the system malloc() in some files.

    Move the compatibility features into a separate header file.

    Signed-off-by: Simon Glass

    Simon Glass
     

02 Feb, 2019

1 commit


26 Jan, 2019

1 commit


17 Jan, 2019

4 commits

  • This adds two new functions, lmb_alloc_addr and
    lmb_get_unreserved_size.

    lmb_alloc_addr behaves like lmb_alloc, but it tries to allocate a
    pre-specified address range. Unlike lmb_reserve, this address range
    must be inside one of the memory ranges that has been set up with
    lmb_add.

    lmb_get_unreserved_size returns the number of bytes that can be
    used up to the next reserved region or the end of valid ram. This
    can be 0 if the address passed is reserved.

    Added test for these new functions.

    Reviewed-by: Simon Glass
    Signed-off-by: Simon Goldschmidt

    Simon Goldschmidt
     
  • lmb_add_region handles overlapping regions wrong: instead of merging
    or rejecting to add a new reserved region that overlaps an existing
    one, it just adds the new region.

    Since internally the same function is used for lmb_alloc, change
    lmb_add_region to reject overlapping regions.

    Also, to keep reserved memory correct after 'free', reserved entries
    created by allocating memory must not set their size to a multiple
    of alignment but to the original size. This ensures the reserved
    region is completely removed when the caller calls 'lmb_free', as
    this one takes the same size as passed to 'lmb_alloc' etc.

    Add test to assert this.

    Reviewed-by: Simon Glass
    Signed-off-by: Simon Goldschmidt

    Simon Goldschmidt
     
  • The lmb code fails if base + size of RAM overflows to zero.

    Fix this by calculating end as 'base + size - 1' instead of 'base + size'
    where appropriate.

    Added tests to assert this is fixed.

    Reviewed-by: Simon Glass
    Signed-off-by: Simon Goldschmidt

    Simon Goldschmidt
     
  • Add basic tests for the lmb memory allocation code used to reserve and
    allocate memory during boot.

    Signed-off-by: Simon Goldschmidt
    Reviewed-by: Simon Glass

    Simon Goldschmidt