virt.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2012 Linaro Limited.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef VIRT_H
  19. #define VIRT_H
  20. #include <asm/ptrace.h>
  21. /*
  22. * Flag indicating that the kernel was not entered in the same mode on every
  23. * CPU. The zImage loader stashes this value in an SPSR, so we need an
  24. * architecturally defined flag bit here (the N flag, as it happens)
  25. */
  26. #define BOOT_CPU_MODE_MISMATCH (1<<31)
  27. #ifndef __ASSEMBLY__
  28. #ifdef CONFIG_ARM_VIRT_EXT
  29. /*
  30. * __boot_cpu_mode records what mode the primary CPU was booted in.
  31. * A correctly-implemented bootloader must start all CPUs in the same mode:
  32. * if it fails to do this, the flag BOOT_CPU_MODE_MISMATCH is set to indicate
  33. * that some CPU(s) were booted in a different mode.
  34. *
  35. * This allows the kernel to flag an error when the secondaries have come up.
  36. */
  37. extern int __boot_cpu_mode;
  38. void __hyp_set_vectors(unsigned long phys_vector_base);
  39. unsigned long __hyp_get_vectors(void);
  40. #else
  41. #define __boot_cpu_mode (SVC_MODE)
  42. #endif
  43. #ifndef ZIMAGE
  44. void hyp_mode_check(void);
  45. /* Reports the availability of HYP mode */
  46. static inline bool is_hyp_mode_available(void)
  47. {
  48. return ((__boot_cpu_mode & MODE_MASK) == HYP_MODE &&
  49. !(__boot_cpu_mode & BOOT_CPU_MODE_MISMATCH));
  50. }
  51. /* Check if the bootloader has booted CPUs in different modes */
  52. static inline bool is_hyp_mode_mismatched(void)
  53. {
  54. return !!(__boot_cpu_mode & BOOT_CPU_MODE_MISMATCH);
  55. }
  56. #endif
  57. #endif /* __ASSEMBLY__ */
  58. #endif /* ! VIRT_H */