sfi.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * sfi.c - x86 architecture SFI support.
  3. *
  4. * Copyright (c) 2009, Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. */
  20. #define KMSG_COMPONENT "SFI"
  21. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  22. #include <linux/acpi.h>
  23. #include <linux/init.h>
  24. #include <linux/sfi.h>
  25. #include <linux/io.h>
  26. #include <asm/io_apic.h>
  27. #include <asm/mpspec.h>
  28. #include <asm/setup.h>
  29. #include <asm/apic.h>
  30. #ifdef CONFIG_X86_LOCAL_APIC
  31. static unsigned long sfi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
  32. void __init mp_sfi_register_lapic_address(unsigned long address)
  33. {
  34. mp_lapic_addr = address;
  35. set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
  36. if (boot_cpu_physical_apicid == -1U)
  37. boot_cpu_physical_apicid = read_apic_id();
  38. pr_info("Boot CPU = %d\n", boot_cpu_physical_apicid);
  39. }
  40. /* All CPUs enumerated by SFI must be present and enabled */
  41. void __cpuinit mp_sfi_register_lapic(u8 id)
  42. {
  43. if (MAX_APICS - id <= 0) {
  44. pr_warning("Processor #%d invalid (max %d)\n",
  45. id, MAX_APICS);
  46. return;
  47. }
  48. pr_info("registering lapic[%d]\n", id);
  49. generic_processor_info(id, GET_APIC_VERSION(apic_read(APIC_LVR)));
  50. }
  51. static int __init sfi_parse_cpus(struct sfi_table_header *table)
  52. {
  53. struct sfi_table_simple *sb;
  54. struct sfi_cpu_table_entry *pentry;
  55. int i;
  56. int cpu_num;
  57. sb = (struct sfi_table_simple *)table;
  58. cpu_num = SFI_GET_NUM_ENTRIES(sb, struct sfi_cpu_table_entry);
  59. pentry = (struct sfi_cpu_table_entry *)sb->pentry;
  60. for (i = 0; i < cpu_num; i++) {
  61. mp_sfi_register_lapic(pentry->apic_id);
  62. pentry++;
  63. }
  64. smp_found_config = 1;
  65. return 0;
  66. }
  67. #endif /* CONFIG_X86_LOCAL_APIC */
  68. #ifdef CONFIG_X86_IO_APIC
  69. static u32 gsi_base;
  70. static int __init sfi_parse_ioapic(struct sfi_table_header *table)
  71. {
  72. struct sfi_table_simple *sb;
  73. struct sfi_apic_table_entry *pentry;
  74. int i, num;
  75. sb = (struct sfi_table_simple *)table;
  76. num = SFI_GET_NUM_ENTRIES(sb, struct sfi_apic_table_entry);
  77. pentry = (struct sfi_apic_table_entry *)sb->pentry;
  78. for (i = 0; i < num; i++) {
  79. mp_register_ioapic(i, pentry->phys_addr, gsi_base);
  80. gsi_base += io_apic_get_redir_entries(i);
  81. pentry++;
  82. }
  83. WARN(pic_mode, KERN_WARNING
  84. "SFI: pic_mod shouldn't be 1 when IOAPIC table is present\n");
  85. pic_mode = 0;
  86. return 0;
  87. }
  88. #endif /* CONFIG_X86_IO_APIC */
  89. /*
  90. * sfi_platform_init(): register lapics & io-apics
  91. */
  92. int __init sfi_platform_init(void)
  93. {
  94. #ifdef CONFIG_X86_LOCAL_APIC
  95. mp_sfi_register_lapic_address(sfi_lapic_addr);
  96. sfi_table_parse(SFI_SIG_CPUS, NULL, NULL, sfi_parse_cpus);
  97. #endif
  98. #ifdef CONFIG_X86_IO_APIC
  99. sfi_table_parse(SFI_SIG_APIC, NULL, NULL, sfi_parse_ioapic);
  100. #endif
  101. return 0;
  102. }