Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

hooks.c 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "stdint.h"
  2. #include "stddef.h"
  3. #include "registers.h"
  4. #include "string.h"
  5. #include "hooks.h"
  6. #include "init.h"
  7. #include "main.h"
  8. #include "relocate.h"
  9. #include "etherboot.h"
  10. /* Symbols defined by the linker */
  11. extern char _bss[], _ebss[];
  12. /*
  13. * This file provides the basic entry points from assembly code. See
  14. * README.i386 for a description of the entry code path.
  15. *
  16. */
  17. /*
  18. * arch_initialise(): perform any required initialisation such as
  19. * setting up the console device and relocating to high memory. Note
  20. * that if we relocate to high memory and the prefix is in base
  21. * memory, then we will need to install a copy of librm in base
  22. * memory. librm's reset function takes care of this.
  23. *
  24. */
  25. #include "librm.h"
  26. void arch_initialise ( struct i386_all_regs *regs __unused ) {
  27. /* Zero the BSS */
  28. memset ( _bss, 0, _ebss - _bss );
  29. /* Call all registered initialisation functions.
  30. */
  31. call_init_fns ();
  32. /* Relocate to high memory. (This is a no-op under
  33. * -DKEEP_IT_REAL.)
  34. */
  35. relocate();
  36. /* Call all registered reset functions. Note that if librm is
  37. * included, it is the reset function that will install a
  38. * fresh copy of librm in base memory. It follows from this
  39. * that (a) librm must be first in the reset list and (b) you
  40. * cannot call console output functions between relocate() and
  41. * call_reset_fns(), because real-mode calls will crash the
  42. * machine.
  43. */
  44. call_reset_fns();
  45. printf ( "init finished\n" );
  46. regs->es = virt_to_phys ( installed_librm ) >> 4;
  47. __asm__ ( "xchgw %bx, %bx" );
  48. }
  49. /*
  50. * arch_main() : call main() and then exit via whatever exit mechanism
  51. * the prefix requested.
  52. *
  53. */
  54. void arch_main ( struct i386_all_regs *regs ) {
  55. void (*exit_path) ( struct i386_all_regs *regs );
  56. /* Determine exit path requested by prefix */
  57. exit_path = ( typeof ( exit_path ) ) regs->eax;
  58. /* Call to main() */
  59. regs->eax = main();
  60. /* Call registered per-object exit functions */
  61. call_exit_fns ();
  62. if ( exit_path ) {
  63. /* Prefix requested that we use a particular function
  64. * as the exit path, so we call this function, which
  65. * must not return.
  66. */
  67. exit_path ( regs );
  68. }
  69. }