head64.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * linux/arch/x86_64/kernel/head64.c -- 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/bootsetup.h>
  16. #include <asm/setup.h>
  17. #include <asm/desc.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/sections.h>
  20. /* Don't add a printk in there. printk relies on the PDA which is not initialized
  21. yet. */
  22. static void __init clear_bss(void)
  23. {
  24. memset(__bss_start, 0,
  25. (unsigned long) __bss_stop - (unsigned long) __bss_start);
  26. }
  27. #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
  28. #define OLD_CL_MAGIC_ADDR 0x90020
  29. #define OLD_CL_MAGIC 0xA33F
  30. #define OLD_CL_BASE_ADDR 0x90000
  31. #define OLD_CL_OFFSET 0x90022
  32. extern char saved_command_line[];
  33. static void __init copy_bootdata(char *real_mode_data)
  34. {
  35. int new_data;
  36. char * command_line;
  37. memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
  38. new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
  39. if (!new_data) {
  40. if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
  41. printk("so old bootloader that it does not support commandline?!\n");
  42. return;
  43. }
  44. new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
  45. printk("old bootloader convention, maybe loadlin?\n");
  46. }
  47. command_line = (char *) ((u64)(new_data));
  48. memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
  49. printk("Bootdata ok (command line is %s)\n", saved_command_line);
  50. }
  51. void __init x86_64_start_kernel(char * real_mode_data)
  52. {
  53. char *s;
  54. int i;
  55. for (i = 0; i < 256; i++)
  56. set_intr_gate(i, early_idt_handler);
  57. asm volatile("lidt %0" :: "m" (idt_descr));
  58. clear_bss();
  59. /*
  60. * This must be called really, really early:
  61. */
  62. lockdep_init();
  63. /*
  64. * switch to init_level4_pgt from boot_level4_pgt
  65. */
  66. memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
  67. asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
  68. for (i = 0; i < NR_CPUS; i++)
  69. cpu_pda(i) = &boot_cpu_pda[i];
  70. pda_init(0);
  71. copy_bootdata(real_mode_data);
  72. #ifdef CONFIG_SMP
  73. cpu_set(0, cpu_online_map);
  74. #endif
  75. s = strstr(saved_command_line, "earlyprintk=");
  76. if (s != NULL)
  77. setup_early_printk(strchr(s, '=') + 1);
  78. #ifdef CONFIG_NUMA
  79. s = strstr(saved_command_line, "numa=");
  80. if (s != NULL)
  81. numa_setup(s+5);
  82. #endif
  83. if (strstr(saved_command_line, "disableapic"))
  84. disable_apic = 1;
  85. /* You need early console to see that */
  86. if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
  87. panic("Kernel too big for kernel mapping\n");
  88. start_kernel();
  89. }