05 Dec, 2018

1 commit


30 Nov, 2018

1 commit

  • The use of strcpy() to remove characters at the start of a string is safe
    in U-Boot, since we know the implementation. But in os.c we are using the
    C library's strcpy() function, where this behaviour is not permitted.

    Update the code to use memmove() instead.

    Reported-by: Coverity (CID: 173279)
    Signed-off-by: Simon Glass
    Reviewed-by: Alexander Graf

    Simon Glass
     

26 Nov, 2018

4 commits

  • Most architectures use jump_to_image_no_args() to jump from SPL to U-Boot.
    At present sandbox is special in that it jumps in its
    spl_board_load_image() call. This is not strictly correct, and means that
    sandbox misses out some parts of board_init_r(), just as calling
    bloblist_finish(), for example.

    Change spl_board_load_image() to just identify the filename to boot, and
    implement jump_to_image_no_args() to actually jump to it.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • The current method of starting U-Boot from U-Boot adds arguments to pass
    the memory file through, so that memory is preserved. This is fine for a
    single call, but if we call from TPL -> SPL -> U-Boot the arguments build
    up and we have several memory files in the argument list.

    Adjust the implementation to filter out arguments that we want to replace
    with new ones. Also print a useful error if the exec() call fails.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • At present sandbox calls malloc() from various places in the OS layer and
    this results in calls to U-Boot's malloc() implementation. It is better to
    use the on in the OS layer, since it does not mix allocations with the
    main U-Boot code.

    Fix this by replacing calls with malloc() to os_malloc(), etc.

    Signed-off-by: Simon Glass
    Reviewed-by: Joe Hershberger

    Simon Glass
     
  • At present os_jump_to_image() jumps to a given image, and this is written
    to a file. But it is useful to be able to jump to a file also.

    To avoid duplicating code, split out the implementation of
    os_jump_to_image() into a new function that jumps to a file.

    Signed-off-by: Simon Glass

    Simon Glass
     

21 Nov, 2018

1 commit


15 Nov, 2018

1 commit


09 Oct, 2018

4 commits


08 Oct, 2018

1 commit

  • On my Ubuntu 18.04.1 machine two driver-model bus tests have started
    failing recently. The problem appears to be that the DATA region of the
    executable is protected. This does not seem correct, but perhaps there
    is a reason.

    To work around it, unprotect the regions in these tests before accessing
    them.

    Signed-off-by: Simon Glass

    Simon Glass
     

24 Sep, 2018

4 commits

  • With efi_loader, we may want to execute payloads from RAM. By default,
    permissions on the RAM region don't allow us to execute from there though.

    So let's change the default allocation scheme for RAM to also allow
    execution from it. That way payloads that live in U-Boot RAM can be
    directly executed.

    Signed-off-by: Alexander Graf
    Reviewed-by: Simon Glass
    Signed-off-by: Alexander Graf

    Alexander Graf
     
  • In sandbox, longjmp returns to itself in an endless loop because
    os_longjmp() calls into longjmp() which is provided by U-Boot which
    again calls os_longjmp().

    Setjmp on the other hand must not return because otherwise the
    return freees up stack elements that we need during longjmp().

    The only straight forward fix that doesn't involve nasty hacks I
    could find is to directly link against the system setjmp/longjmp
    implementations. That means we just provide the compiler with
    hints that the symbol will be available and actually fill them
    out with versions from libc.

    This approach should be reasonably platform agnostic

    Signed-off-by: Alexander Graf
    Reviewed-by: Simon Glass
    Signed-off-by: Alexander Graf

    Alexander Graf
     
  • This function is useful to signal that the application needs to exit
    immediate. It can be caught with a debugger (e.g. gdb). Add a stub for it
    so that it can be called from within sandbox when an internal error
    occurs.

    Signed-off-by: Simon Glass
    Signed-off-by: Alexander Graf

    Simon Glass
     
  • At present the sandbox RAM buffer is not aligned to any particular
    address boundary. This makes the internal pointers somewhat random with
    respect to the associated RAM buffer addresses.

    Align the buffer to the page size of the machine to help with this. Note
    that there is a header at the start of the allocated pointer. To avoid
    returning a pointer which is not aligned to a page boundary, we waste
    almost an entire page of memory for each allocation.

    Signed-off-by: Simon Glass
    Signed-off-by: Alexander Graf

    Simon Glass
     

03 Jun, 2018

1 commit

  • Add an implementation of setjmp() and longjmp() which rely on the
    underlying host C library. Since we cannot know how large the jump buffer
    needs to be, pick something that should be suitable and check it at
    runtime. At present we need access to the underlying struct as well.

    Signed-off-by: Simon Glass
    Signed-off-by: Alexander Graf

    Simon Glass
     

07 May, 2018

1 commit

  • When U-Boot started using SPDX tags we were among the early adopters and
    there weren't a lot of other examples to borrow from. So we picked the
    area of the file that usually had a full license text and replaced it
    with an appropriate SPDX-License-Identifier: entry. Since then, the
    Linux Kernel has adopted SPDX tags and they place it as the very first
    line in a file (except where shebangs are used, then it's second line)
    and with slightly different comment styles than us.

    In part due to community overlap, in part due to better tag visibility
    and in part for other minor reasons, switch over to that style.

    This commit changes all instances where we have a single declared
    license in the tag as both the before and after are identical in tag
    contents. There's also a few places where I found we did not have a tag
    and have introduced one.

    Signed-off-by: Tom Rini

    Tom Rini
     

08 Dec, 2017

1 commit

  • While sandbox works OK without the special-case code, it does result in
    console output being stored in the pre-console buffer while sandbox starts
    up. If there is a crash or a problem then there is no indication of what
    is going on.

    For ease of debugging it seems better to revert this change.

    This reverts commit 47b98ad0f6779485d0f0c14f337c3eece273eb54.

    Signed-off-by: Simon Glass

    Simon Glass
     

09 Oct, 2017

1 commit


29 Jul, 2017

1 commit


09 Jun, 2017

1 commit

  • In os_dirent_get_typename() we are checking that type falls within the
    known values of the enum os_dirent_t. With clang-3.8 testing this value
    as being >= 0 results in a warning as it will always be true. This
    assumes of course that we are only given valid data. Given that we want
    to sanity check the input, we change this to check that it falls within
    the range of the first to the last entry in the given enum.

    Cc: Simon Glass
    Signed-off-by: Tom Rini
    Reviewed-by: Simon Glass

    Tom Rini
     

12 Oct, 2016

4 commits


15 Jul, 2016

1 commit


04 Jun, 2015

1 commit

  • For some reason 'u-boot -D' does not restore the terminal correctly when
    the 'reset' command is used. Call the terminal restore function explicitly
    in this case.

    Signed-off-by: Simon Glass
    Reviewed-by: Joe Hershberger

    Simon Glass
     

06 May, 2015

1 commit


27 Nov, 2014

1 commit


23 Nov, 2014

1 commit


24 Jun, 2014

1 commit

  • Each node in the linked-list that os_dirent_ls() returns has its next
    pointer set only when the next node is created. For the last node in the
    list, there is no next node, so this never happens, and the next pointer
    is never initialized. Explicitly initialize the next pointer so that it
    isn't dangling. Without this, "sb ls" might crash.

    Signed-off-by: Stephen Warren
    Acked-by: Simon Glass

    Stephen Warren
     

18 Mar, 2014

3 commits

  • When jumping from one sandbox U-Boot to another in sandbox, the RAM buffer
    is preserved in the jump by using a temporary file. Add an option to tell
    the receiving U-Boot to remove this file when it is no longer needed.

    Similarly the old U-Boot image is left behind in this case. We cannot delete
    it immediately since gdb cannot then find its debug symbols. Delete it just
    before exiting.

    Together these changes ensure that temporary files are removed both for
    memory and U-Boot.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • It is useful for Cltl-C to be handled by U-Boot as it is on other boards.
    But it is also useful to be able to terminate U-Boot with Ctrl-C.

    Add an option to enable signals while in raw mode, and make this the
    default. Add an option to leave the terminal cooked, which is useful for
    redirecting output.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • For some tests it is useful to be able to run U-Boot again but pass on the
    same memory contents. Add a function to achieve this.

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

    Simon Glass
     

07 Mar, 2014

1 commit

  • The unit-test for hush's "test -e" currently relies upon being run in
    the U-Boot build directory, because it tests for the existence of a file
    that exists in that directory.

    Fix this by explicitly creating the file we use for the existence test,
    and deleting it afterwards so that multiple successive unit-test
    invocations succeed. This required adding an os.c function to erase
    files.

    Reported-by: Simon Glass
    Signed-off-by: Stephen Warren

    Stephen Warren
     

25 Jan, 2014

1 commit


09 Jan, 2014

2 commits

  • It is useful to be able to save and restore the RAM contents of sandbox
    U-Boot either for setting up tests, for later analysys, or for chaining
    together multiple tests which need to keep the same memory contents.

    Add a function to provide a memory file for U-Boot. This is read on
    start-up and written when shutting down. If the file does not exist
    on start-up, it will be created when shutting down.

    Signed-off-by: Simon Glass
    Signed-off-by: Simon Glass

    Simon Glass
     
  • With sandbox, errors and problems may be reported before console_init_f()
    is executed. For example, an argument may not parse correctly or U-Boot may
    panic(). At present this output is swallowed so there is no indication what
    is going wrong.

    Adjust the console to deal with a very early sandbox setup, by detecting that
    there is no global_data yet, and calling os functions in that case.

    Signed-off-by: Simon Glass
    Signed-off-by: Simon Glass

    Simon Glass