uboot.S 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/offsets.h>
  19. #include <grub/symbol.h>
  20. #include <grub/machine/kernel.h>
  21. /*
  22. * uboot_syscall():
  23. * This function is effectively a veneer, so it cannot
  24. * modify the stack or corrupt any registers other than
  25. * r12 (ip). Furthermore it needs to restore r8 for
  26. * U-Boot (Global Data Pointer) and preserve it for Grub.
  27. */
  28. FUNCTION(grub_uboot_syscall)
  29. str r8, transition_space
  30. str lr, transition_space + 4
  31. str r9, transition_space + 8
  32. ldr ip, saved_registers_ptr
  33. ldr r8, [ip, #4 * 8]
  34. ldr r9, [ip, #4 * 9]
  35. bl do_syscall
  36. ldr r8, transition_space
  37. ldr lr, transition_space + 4
  38. ldr r9, transition_space + 8
  39. bx lr
  40. do_syscall:
  41. ldr ip, grub_uboot_syscall_ptr
  42. bx ip
  43. FUNCTION(grub_uboot_return)
  44. ldr ip, saved_registers_ptr
  45. ldr sp, [ip, #4 * 4]
  46. pop {r4-r12, lr}
  47. mov sp, r12
  48. bx lr
  49. .align 3
  50. @ GRUB context stack space
  51. transition_space:
  52. .long 0 @ r8
  53. .long 0 @ lr
  54. .long 0 @ r9
  55. saved_registers_ptr:
  56. .long EXT_C(grub_arm_saved_registers)
  57. VARIABLE(grub_uboot_syscall_ptr)
  58. .long 0 @
  59. END