assert.c 749 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <cdefs.h>
  8. #include <stdio.h>
  9. #include <common/debug.h>
  10. #include <drivers/console.h>
  11. #include <plat/common/platform.h>
  12. /*
  13. * Only print the output if PLAT_LOG_LEVEL_ASSERT is higher or equal to
  14. * LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
  15. */
  16. #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
  17. void __dead2 __assert(const char *file, unsigned int line)
  18. {
  19. printf("ASSERT: %s:%u\n", file, line);
  20. backtrace("assert");
  21. console_flush();
  22. plat_panic_handler();
  23. }
  24. #else
  25. void __dead2 __assert(void)
  26. {
  27. backtrace("assert");
  28. console_flush();
  29. plat_panic_handler();
  30. }
  31. #endif