startup.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 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/machine/memory.h>
  20. #include <grub/cpu/linux.h>
  21. #include <grub/offsets.h>
  22. #include <multiboot.h>
  23. #include <multiboot2.h>
  24. /*
  25. * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
  26. * So the first three arguments are passed in %eax, %edx, and %ecx,
  27. * respectively, and if a function has a fixed number of arguments
  28. * and the number if greater than three, the function must return
  29. * with "ret $N" where N is ((the number of arguments) - 3) * 4.
  30. */
  31. .file "startup.S"
  32. .text
  33. .globl start, _start
  34. start:
  35. _start:
  36. #ifdef GRUB_MACHINE_MULTIBOOT
  37. cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
  38. jne 0f
  39. movl %ebx, EXT_C(startup_multiboot_info)
  40. 0:
  41. #endif
  42. /* initialize the stack */
  43. movl $GRUB_MEMORY_MACHINE_PROT_STACK, %esp
  44. /* jump to the main body of C code */
  45. jmp EXT_C(grub_main)
  46. /*
  47. * Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
  48. */
  49. .p2align 2 /* force 4-byte alignment */
  50. multiboot_header:
  51. /* magic */
  52. .long 0x1BADB002
  53. /* flags */
  54. .long MULTIBOOT_MEMORY_INFO
  55. /* checksum */
  56. .long -0x1BADB002 - MULTIBOOT_MEMORY_INFO