compiler-rt.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2013 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/symbol.h>
  19. #include <grub/dl.h>
  20. .file "misc.S"
  21. .text
  22. .syntax unified
  23. #if !defined (__thumb2__)
  24. .arm
  25. #else
  26. .thumb
  27. #endif
  28. .align 2
  29. FUNCTION(__muldi3)
  30. FUNCTION(__aeabi_lmul)
  31. stmfd sp!, {r4, fp}
  32. add fp, sp, #4
  33. sub sp, sp, #16
  34. str r0, [fp, #-12]
  35. str r1, [fp, #-8]
  36. str r2, [fp, #-20]
  37. str r3, [fp, #-16]
  38. ldr r3, [fp, #-8]
  39. ldr r2, [fp, #-20]
  40. mul r2, r3, r2
  41. ldr r3, [fp, #-16]
  42. ldr r1, [fp, #-12]
  43. mul r3, r1, r3
  44. add r2, r2, r3
  45. ldr r0, [fp, #-12]
  46. ldr r1, [fp, #-20]
  47. umull r3, r4, r0, r1
  48. add r2, r2, r4
  49. mov r4, r2
  50. mov r0, r3
  51. mov r1, r4
  52. mov sp, fp
  53. sub sp, sp, #4
  54. ldmfd sp!, {r4, fp}
  55. bx lr
  56. .macro division32 parent
  57. sub sp, sp, #8 @ Allocate naturally aligned 64-bit space
  58. stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment
  59. add r2, sp, #8 @ Set r2 to address of 64-bit space
  60. bl \parent
  61. ldr r1, [sp, #8] @ Extract remainder
  62. ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register
  63. add sp, sp, #8
  64. bx lr
  65. .endm
  66. FUNCTION(__aeabi_uidivmod)
  67. division32 grub_divmod32
  68. FUNCTION(__aeabi_idivmod)
  69. division32 grub_divmod32s
  70. /*
  71. * Null divide-by-zero handler
  72. */
  73. FUNCTION(__aeabi_unwind_cpp_pr0)
  74. FUNCTION(raise)
  75. mov r0, #0
  76. bx lr
  77. END