kfreebsd.init-i386.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_OPEN 5
  21. #define SYSCALL_WRITE 4
  22. #define SYSCALL_RESET 55
  23. #define SYSCALL_FSYNC 95
  24. #define SYSCALL_ARCH 165
  25. #define SYSCALL_EXIT 1
  26. #define SYSCALL_ARCH_IOPERM 4
  27. #define SYSCALL_INT 0x80
  28. #define RESET_NOSYNC 0x4
  29. #define RESET_HALT 0x8
  30. #define RESET_POWEROFF 0x4000
  31. .section ".init", "ax"
  32. .global start,_start
  33. start:
  34. _start:
  35. /* open. */
  36. movl $SYSCALL_OPEN, %eax
  37. pushl $FLAGS_NONE
  38. pushl $MODE_RDRW
  39. leal device, %ebx
  40. pushl %ebx
  41. pushl $0
  42. int $SYSCALL_INT
  43. addl $16, %esp
  44. movl %eax, %ecx
  45. /* write. */
  46. movl $SYSCALL_WRITE, %eax
  47. pushl $(messageend-message)
  48. leal message, %ebx
  49. pushl %ebx
  50. pushl %ecx
  51. pushl $0
  52. int $SYSCALL_INT
  53. addl $16, %esp
  54. /* fsync. */
  55. movl $SYSCALL_FSYNC, %eax
  56. pushl %ecx
  57. pushl $0
  58. int $SYSCALL_INT
  59. addl $8, %esp
  60. /* IOPERM. */
  61. movl $SYSCALL_ARCH, %eax
  62. pushl $ioperm_arg1
  63. pushl $SYSCALL_ARCH_IOPERM
  64. pushl $0
  65. int $SYSCALL_INT
  66. addl $12, %esp
  67. /* IOPERM. */
  68. movl $SYSCALL_ARCH, %eax
  69. pushl $ioperm_arg2
  70. pushl $SYSCALL_ARCH_IOPERM
  71. pushl $0
  72. int $SYSCALL_INT
  73. addl $12, %esp
  74. #include "qemu-shutdown-x86.S"
  75. /* shutdown. */
  76. movl $SYSCALL_RESET, %eax
  77. pushl $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC)
  78. pushl $0
  79. int $SYSCALL_INT
  80. addl $8, %esp
  81. /* exit (1). Shouldn't be reached. */
  82. movl $SYSCALL_EXIT, %eax
  83. pushl $1
  84. pushl $0
  85. int $SYSCALL_INT
  86. device:
  87. .ascii "/dev/console"
  88. .byte 0
  89. message:
  90. .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
  91. messageend:
  92. ioperm_arg1:
  93. .long 0xcf8
  94. .long 8
  95. .long 1
  96. ioperm_arg2:
  97. .long 0x7000
  98. .long 8
  99. .long 1