head64.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. * $Id: head64.c,v 1.22 2001/07/06 14:28:20 ak Exp $
  7. */
  8. #include <linux/init.h>
  9. #include <linux/linkage.h>
  10. #include <linux/types.h>
  11. #include <linux/kernel.h>
  12. #include <linux/string.h>
  13. #include <linux/percpu.h>
  14. #include <asm/processor.h>
  15. #include <asm/proto.h>
  16. #include <asm/smp.h>
  17. #include <asm/bootsetup.h>
  18. #include <asm/setup.h>
  19. #include <asm/desc.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. extern char __bss_start[], __bss_end[];
  25. memset(__bss_start, 0,
  26. (unsigned long) __bss_end - (unsigned long) __bss_start);
  27. }
  28. #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
  29. #define OLD_CL_MAGIC_ADDR 0x90020
  30. #define OLD_CL_MAGIC 0xA33F
  31. #define OLD_CL_BASE_ADDR 0x90000
  32. #define OLD_CL_OFFSET 0x90022
  33. extern char saved_command_line[];
  34. static void __init copy_bootdata(char *real_mode_data)
  35. {
  36. int new_data;
  37. char * command_line;
  38. memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
  39. new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
  40. if (!new_data) {
  41. if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
  42. printk("so old bootloader that it does not support commandline?!\n");
  43. return;
  44. }
  45. new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
  46. printk("old bootloader convention, maybe loadlin?\n");
  47. }
  48. command_line = (char *) ((u64)(new_data));
  49. memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
  50. printk("Bootdata ok (command line is %s)\n", saved_command_line);
  51. }
  52. static void __init setup_boot_cpu_data(void)
  53. {
  54. unsigned int dummy, eax;
  55. /* get vendor info */
  56. cpuid(0, (unsigned int *)&boot_cpu_data.cpuid_level,
  57. (unsigned int *)&boot_cpu_data.x86_vendor_id[0],
  58. (unsigned int *)&boot_cpu_data.x86_vendor_id[8],
  59. (unsigned int *)&boot_cpu_data.x86_vendor_id[4]);
  60. /* get cpu type */
  61. cpuid(1, &eax, &dummy, &dummy,
  62. (unsigned int *) &boot_cpu_data.x86_capability);
  63. boot_cpu_data.x86 = (eax >> 8) & 0xf;
  64. boot_cpu_data.x86_model = (eax >> 4) & 0xf;
  65. boot_cpu_data.x86_mask = eax & 0xf;
  66. }
  67. extern char _end[];
  68. void __init x86_64_start_kernel(char * real_mode_data)
  69. {
  70. char *s;
  71. int i;
  72. for (i = 0; i < 256; i++)
  73. set_intr_gate(i, early_idt_handler);
  74. asm volatile("lidt %0" :: "m" (idt_descr));
  75. clear_bss();
  76. pda_init(0);
  77. copy_bootdata(real_mode_data);
  78. #ifdef CONFIG_SMP
  79. cpu_set(0, cpu_online_map);
  80. #endif
  81. s = strstr(saved_command_line, "earlyprintk=");
  82. if (s != NULL)
  83. setup_early_printk(s);
  84. #ifdef CONFIG_NUMA
  85. s = strstr(saved_command_line, "numa=");
  86. if (s != NULL)
  87. numa_setup(s+5);
  88. #endif
  89. #ifdef CONFIG_X86_IO_APIC
  90. if (strstr(saved_command_line, "disableapic"))
  91. disable_apic = 1;
  92. #endif
  93. /* You need early console to see that */
  94. if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
  95. panic("Kernel too big for kernel mapping\n");
  96. setup_boot_cpu_data();
  97. start_kernel();
  98. }