head64.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * prepare to run common code
  3. *
  4. * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
  5. */
  6. #include <linux/init.h>
  7. #include <linux/linkage.h>
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/string.h>
  11. #include <linux/percpu.h>
  12. #include <linux/start_kernel.h>
  13. #include <asm/processor.h>
  14. #include <asm/proto.h>
  15. #include <asm/smp.h>
  16. #include <asm/setup.h>
  17. #include <asm/desc.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/tlbflush.h>
  20. #include <asm/sections.h>
  21. #include <asm/kdebug.h>
  22. static void __init zap_identity_mappings(void)
  23. {
  24. pgd_t *pgd = pgd_offset_k(0UL);
  25. pgd_clear(pgd);
  26. __flush_tlb();
  27. }
  28. /* Don't add a printk in there. printk relies on the PDA which is not initialized
  29. yet. */
  30. static void __init clear_bss(void)
  31. {
  32. memset(__bss_start, 0,
  33. (unsigned long) __bss_stop - (unsigned long) __bss_start);
  34. }
  35. static void __init copy_bootdata(char *real_mode_data)
  36. {
  37. char * command_line;
  38. memcpy(&boot_params, real_mode_data, sizeof boot_params);
  39. if (boot_params.hdr.cmd_line_ptr) {
  40. command_line = __va(boot_params.hdr.cmd_line_ptr);
  41. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  42. }
  43. }
  44. void __init x86_64_start_kernel(char * real_mode_data)
  45. {
  46. int i;
  47. /* clear bss before set_intr_gate with early_idt_handler */
  48. clear_bss();
  49. /* Make NULL pointers segfault */
  50. zap_identity_mappings();
  51. for (i = 0; i < IDT_ENTRIES; i++) {
  52. #ifdef CONFIG_EARLY_PRINTK
  53. set_intr_gate(i, &early_idt_handlers[i]);
  54. #else
  55. set_intr_gate(i, early_idt_handler);
  56. #endif
  57. }
  58. load_idt((const struct desc_ptr *)&idt_descr);
  59. early_printk("Kernel alive\n");
  60. for (i = 0; i < NR_CPUS; i++)
  61. cpu_pda(i) = &boot_cpu_pda[i];
  62. pda_init(0);
  63. copy_bootdata(__va(real_mode_data));
  64. start_kernel();
  65. }