head64.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <asm/processor.h>
  13. #include <asm/proto.h>
  14. #include <asm/smp.h>
  15. #include <asm/setup.h>
  16. #include <asm/desc.h>
  17. #include <asm/pgtable.h>
  18. #include <asm/tlbflush.h>
  19. #include <asm/sections.h>
  20. #include <asm/kdebug.h>
  21. static void __init zap_identity_mappings(void)
  22. {
  23. pgd_t *pgd = pgd_offset_k(0UL);
  24. pgd_clear(pgd);
  25. __flush_tlb();
  26. }
  27. /* Don't add a printk in there. printk relies on the PDA which is not initialized
  28. yet. */
  29. static void __init clear_bss(void)
  30. {
  31. memset(__bss_start, 0,
  32. (unsigned long) __bss_stop - (unsigned long) __bss_start);
  33. }
  34. static void __init copy_bootdata(char *real_mode_data)
  35. {
  36. char * command_line;
  37. memcpy(&boot_params, real_mode_data, sizeof boot_params);
  38. if (boot_params.hdr.cmd_line_ptr) {
  39. command_line = __va(boot_params.hdr.cmd_line_ptr);
  40. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  41. }
  42. }
  43. void __init x86_64_start_kernel(char * real_mode_data)
  44. {
  45. int i;
  46. /* clear bss before set_intr_gate with early_idt_handler */
  47. clear_bss();
  48. /* Make NULL pointers segfault */
  49. zap_identity_mappings();
  50. for (i = 0; i < IDT_ENTRIES; i++)
  51. set_intr_gate(i, early_idt_handler);
  52. load_idt((const struct desc_ptr *)&idt_descr);
  53. early_printk("Kernel alive\n");
  54. for (i = 0; i < NR_CPUS; i++)
  55. cpu_pda(i) = &boot_cpu_pda[i];
  56. pda_init(0);
  57. copy_bootdata(__va(real_mode_data));
  58. #ifdef CONFIG_SMP
  59. cpu_set(0, cpu_online_map);
  60. #endif
  61. start_kernel();
  62. }