head64.c 1.6 KB

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