18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_MPSPEC_H 38c2ecf20Sopenharmony_ci#define _ASM_X86_MPSPEC_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <asm/mpspec_def.h> 78c2ecf20Sopenharmony_ci#include <asm/x86_init.h> 88c2ecf20Sopenharmony_ci#include <asm/apicdef.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciextern int pic_mode; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_32 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * Summit or generic (i.e. installer) kernels need lots of bus entries. 168c2ecf20Sopenharmony_ci * Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#if CONFIG_BASE_SMALL == 0 198c2ecf20Sopenharmony_ci# define MAX_MP_BUSSES 260 208c2ecf20Sopenharmony_ci#else 218c2ecf20Sopenharmony_ci# define MAX_MP_BUSSES 32 228c2ecf20Sopenharmony_ci#endif 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define MAX_IRQ_SOURCES 256 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciextern unsigned int def_to_bigsmp; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#else /* CONFIG_X86_64: */ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define MAX_MP_BUSSES 256 318c2ecf20Sopenharmony_ci/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */ 328c2ecf20Sopenharmony_ci#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4) 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#endif /* CONFIG_X86_64 */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#ifdef CONFIG_EISA 378c2ecf20Sopenharmony_ciextern int mp_bus_id_to_type[MAX_MP_BUSSES]; 388c2ecf20Sopenharmony_ci#endif 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciextern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ciextern unsigned int boot_cpu_physical_apicid; 438c2ecf20Sopenharmony_ciextern u8 boot_cpu_apic_version; 448c2ecf20Sopenharmony_ciextern unsigned long mp_lapic_addr; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC 478c2ecf20Sopenharmony_ciextern int smp_found_config; 488c2ecf20Sopenharmony_ci#else 498c2ecf20Sopenharmony_ci# define smp_found_config 0 508c2ecf20Sopenharmony_ci#endif 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic inline void get_smp_config(void) 538c2ecf20Sopenharmony_ci{ 548c2ecf20Sopenharmony_ci x86_init.mpparse.get_smp_config(0); 558c2ecf20Sopenharmony_ci} 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistatic inline void early_get_smp_config(void) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci x86_init.mpparse.get_smp_config(1); 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistatic inline void find_smp_config(void) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci x86_init.mpparse.find_smp_config(); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_MPPARSE 688c2ecf20Sopenharmony_ciextern void e820__memblock_alloc_reserved_mpc_new(void); 698c2ecf20Sopenharmony_ciextern int enable_update_mptable; 708c2ecf20Sopenharmony_ciextern void default_find_smp_config(void); 718c2ecf20Sopenharmony_ciextern void default_get_smp_config(unsigned int early); 728c2ecf20Sopenharmony_ci#else 738c2ecf20Sopenharmony_cistatic inline void e820__memblock_alloc_reserved_mpc_new(void) { } 748c2ecf20Sopenharmony_ci#define enable_update_mptable 0 758c2ecf20Sopenharmony_ci#define default_find_smp_config x86_init_noop 768c2ecf20Sopenharmony_ci#define default_get_smp_config x86_init_uint_noop 778c2ecf20Sopenharmony_ci#endif 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciint generic_processor_info(int apicid, int version); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_LOCAL_APIC) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistruct physid_mask { 848c2ecf20Sopenharmony_ci unsigned long mask[PHYSID_ARRAY_SIZE]; 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_citypedef struct physid_mask physid_mask_t; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define physid_set(physid, map) set_bit(physid, (map).mask) 908c2ecf20Sopenharmony_ci#define physid_clear(physid, map) clear_bit(physid, (map).mask) 918c2ecf20Sopenharmony_ci#define physid_isset(physid, map) test_bit(physid, (map).mask) 928c2ecf20Sopenharmony_ci#define physid_test_and_set(physid, map) \ 938c2ecf20Sopenharmony_ci test_and_set_bit(physid, (map).mask) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define physids_and(dst, src1, src2) \ 968c2ecf20Sopenharmony_ci bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_LOCAL_APIC) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define physids_or(dst, src1, src2) \ 998c2ecf20Sopenharmony_ci bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_LOCAL_APIC) 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#define physids_clear(map) \ 1028c2ecf20Sopenharmony_ci bitmap_zero((map).mask, MAX_LOCAL_APIC) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#define physids_complement(dst, src) \ 1058c2ecf20Sopenharmony_ci bitmap_complement((dst).mask, (src).mask, MAX_LOCAL_APIC) 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define physids_empty(map) \ 1088c2ecf20Sopenharmony_ci bitmap_empty((map).mask, MAX_LOCAL_APIC) 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci#define physids_equal(map1, map2) \ 1118c2ecf20Sopenharmony_ci bitmap_equal((map1).mask, (map2).mask, MAX_LOCAL_APIC) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define physids_weight(map) \ 1148c2ecf20Sopenharmony_ci bitmap_weight((map).mask, MAX_LOCAL_APIC) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define physids_shift_right(d, s, n) \ 1178c2ecf20Sopenharmony_ci bitmap_shift_right((d).mask, (s).mask, n, MAX_LOCAL_APIC) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define physids_shift_left(d, s, n) \ 1208c2ecf20Sopenharmony_ci bitmap_shift_left((d).mask, (s).mask, n, MAX_LOCAL_APIC) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistatic inline unsigned long physids_coerce(physid_mask_t *map) 1238c2ecf20Sopenharmony_ci{ 1248c2ecf20Sopenharmony_ci return map->mask[0]; 1258c2ecf20Sopenharmony_ci} 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistatic inline void physids_promote(unsigned long physids, physid_mask_t *map) 1288c2ecf20Sopenharmony_ci{ 1298c2ecf20Sopenharmony_ci physids_clear(*map); 1308c2ecf20Sopenharmony_ci map->mask[0] = physids; 1318c2ecf20Sopenharmony_ci} 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistatic inline void physid_set_mask_of_physid(int physid, physid_mask_t *map) 1348c2ecf20Sopenharmony_ci{ 1358c2ecf20Sopenharmony_ci physids_clear(*map); 1368c2ecf20Sopenharmony_ci physid_set(physid, *map); 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} } 1408c2ecf20Sopenharmony_ci#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} } 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ciextern physid_mask_t phys_cpu_present_map; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci#endif /* _ASM_X86_MPSPEC_H */ 145