kfreebsd.init-x86_64.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2010 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. #define MODE_RDRW 2
  19. #define FLAGS_NONE 0
  20. #define SYSCALL_ARCH 165
  21. #define SYSCALL_OPEN 5
  22. #define SYSCALL_WRITE 4
  23. #define SYSCALL_RESET 55
  24. #define SYSCALL_EXIT 1
  25. #define SYSCALL_ARCH_IOPERM 4
  26. #define SYSCALL_FSYNC 95
  27. #define RESET_NOSYNC 0x4
  28. #define RESET_HALT 0x8
  29. #define RESET_POWEROFF 0x4000
  30. .section ".init", "ax"
  31. .global start,_start
  32. start:
  33. _start:
  34. /* open. */
  35. movq $SYSCALL_OPEN, %rax
  36. leaq device, %rdi
  37. movq $MODE_RDRW, %rsi
  38. movq $FLAGS_NONE, %rdx
  39. syscall
  40. movq %rax, %rdi
  41. /* write. */
  42. leaq message, %rsi
  43. movq $SYSCALL_WRITE, %rax
  44. movq $(messageend - message), %rdx
  45. syscall
  46. /* fsync. */
  47. movq $SYSCALL_FSYNC, %rax
  48. syscall
  49. /* IOPERM. */
  50. movq $SYSCALL_ARCH, %rax
  51. movq $SYSCALL_ARCH_IOPERM, %rdi
  52. leaq ioperm_arg1, %rsi
  53. syscall
  54. movq $SYSCALL_ARCH, %rax
  55. movq $SYSCALL_ARCH_IOPERM, %rdi
  56. leaq ioperm_arg2, %rsi
  57. syscall
  58. #include "qemu-shutdown-x86.S"
  59. /* shutdown. */
  60. movq $SYSCALL_RESET, %rax
  61. movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi
  62. syscall
  63. /* exit (1). Shouldn't be reached. */
  64. movq $SYSCALL_EXIT, %rax
  65. movq $1, %rdi
  66. syscall
  67. device:
  68. .ascii "/dev/console"
  69. .byte 0
  70. message:
  71. .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
  72. messageend:
  73. ioperm_arg1:
  74. .long 0xcf8
  75. .long 8
  76. .long 1
  77. ioperm_arg2:
  78. .long 0x7000
  79. .long 8
  80. .long 1