setup.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #include <linux/config.h>
  9. #include <linux/module.h>
  10. #include <linux/init.h>
  11. #include <linux/delay.h>
  12. #include <linux/kernel.h>
  13. #include <linux/kdev_t.h>
  14. #include <linux/string.h>
  15. #include <linux/tty.h>
  16. #include <linux/console.h>
  17. #include <linux/timex.h>
  18. #include <linux/sched.h>
  19. #include <linux/ioport.h>
  20. #include <linux/mm.h>
  21. #include <linux/serial.h>
  22. #include <linux/irq.h>
  23. #include <linux/bootmem.h>
  24. #include <linux/mmzone.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/acpi.h>
  27. #include <linux/compiler.h>
  28. #include <linux/sched.h>
  29. #include <linux/root_dev.h>
  30. #include <linux/nodemask.h>
  31. #include <linux/pm.h>
  32. #include <asm/io.h>
  33. #include <asm/sal.h>
  34. #include <asm/machvec.h>
  35. #include <asm/system.h>
  36. #include <asm/processor.h>
  37. #include <asm/vga.h>
  38. #include <asm/sn/arch.h>
  39. #include <asm/sn/addrs.h>
  40. #include <asm/sn/pda.h>
  41. #include <asm/sn/nodepda.h>
  42. #include <asm/sn/sn_cpuid.h>
  43. #include <asm/sn/simulator.h>
  44. #include <asm/sn/leds.h>
  45. #include <asm/sn/bte.h>
  46. #include <asm/sn/shub_mmr.h>
  47. #include <asm/sn/clksupport.h>
  48. #include <asm/sn/sn_sal.h>
  49. #include <asm/sn/geo.h>
  50. #include "xtalk/xwidgetdev.h"
  51. #include "xtalk/hubdev.h"
  52. #include <asm/sn/klconfig.h>
  53. DEFINE_PER_CPU(struct pda_s, pda_percpu);
  54. #define MAX_PHYS_MEMORY (1UL << 49) /* 1 TB */
  55. lboard_t *root_lboard[MAX_COMPACT_NODES];
  56. extern void bte_init_node(nodepda_t *, cnodeid_t);
  57. extern void sn_timer_init(void);
  58. extern unsigned long last_time_offset;
  59. extern void (*ia64_mark_idle) (int);
  60. extern void snidle(int);
  61. extern unsigned char acpi_kbd_controller_present;
  62. unsigned long sn_rtc_cycles_per_second;
  63. EXPORT_SYMBOL(sn_rtc_cycles_per_second);
  64. DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
  65. EXPORT_PER_CPU_SYMBOL(__sn_hub_info);
  66. DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_NUMNODES]);
  67. EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);
  68. DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);
  69. EXPORT_PER_CPU_SYMBOL(__sn_nodepda);
  70. partid_t sn_partid = -1;
  71. EXPORT_SYMBOL(sn_partid);
  72. char sn_system_serial_number_string[128];
  73. EXPORT_SYMBOL(sn_system_serial_number_string);
  74. u64 sn_partition_serial_number;
  75. EXPORT_SYMBOL(sn_partition_serial_number);
  76. u8 sn_partition_id;
  77. EXPORT_SYMBOL(sn_partition_id);
  78. u8 sn_system_size;
  79. EXPORT_SYMBOL(sn_system_size);
  80. u8 sn_sharing_domain_size;
  81. EXPORT_SYMBOL(sn_sharing_domain_size);
  82. u8 sn_coherency_id;
  83. EXPORT_SYMBOL(sn_coherency_id);
  84. u8 sn_region_size;
  85. EXPORT_SYMBOL(sn_region_size);
  86. int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */
  87. short physical_node_map[MAX_PHYSNODE_ID];
  88. EXPORT_SYMBOL(physical_node_map);
  89. int numionodes;
  90. static void sn_init_pdas(char **);
  91. static void scan_for_ionodes(void);
  92. static nodepda_t *nodepdaindr[MAX_COMPACT_NODES];
  93. /*
  94. * The format of "screen_info" is strange, and due to early i386-setup
  95. * code. This is just enough to make the console code think we're on a
  96. * VGA color display.
  97. */
  98. struct screen_info sn_screen_info = {
  99. .orig_x = 0,
  100. .orig_y = 0,
  101. .orig_video_mode = 3,
  102. .orig_video_cols = 80,
  103. .orig_video_ega_bx = 3,
  104. .orig_video_lines = 25,
  105. .orig_video_isVGA = 1,
  106. .orig_video_points = 16
  107. };
  108. /*
  109. * This is here so we can use the CMOS detection in ide-probe.c to
  110. * determine what drives are present. In theory, we don't need this
  111. * as the auto-detection could be done via ide-probe.c:do_probe() but
  112. * in practice that would be much slower, which is painful when
  113. * running in the simulator. Note that passing zeroes in DRIVE_INFO
  114. * is sufficient (the IDE driver will autodetect the drive geometry).
  115. */
  116. #ifdef CONFIG_IA64_GENERIC
  117. extern char drive_info[4 * 16];
  118. #else
  119. char drive_info[4 * 16];
  120. #endif
  121. /*
  122. * Get nasid of current cpu early in boot before nodepda is initialized
  123. */
  124. static int
  125. boot_get_nasid(void)
  126. {
  127. int nasid;
  128. if (ia64_sn_get_sapic_info(get_sapicid(), &nasid, NULL, NULL))
  129. BUG();
  130. return nasid;
  131. }
  132. /*
  133. * This routine can only be used during init, since
  134. * smp_boot_data is an init data structure.
  135. * We have to use smp_boot_data.cpu_phys_id to find
  136. * the physical id of the processor because the normal
  137. * cpu_physical_id() relies on data structures that
  138. * may not be initialized yet.
  139. */
  140. static int __init pxm_to_nasid(int pxm)
  141. {
  142. int i;
  143. int nid;
  144. nid = pxm_to_nid_map[pxm];
  145. for (i = 0; i < num_node_memblks; i++) {
  146. if (node_memblk[i].nid == nid) {
  147. return NASID_GET(node_memblk[i].start_paddr);
  148. }
  149. }
  150. return -1;
  151. }
  152. /**
  153. * early_sn_setup - early setup routine for SN platforms
  154. *
  155. * Sets up an initial console to aid debugging. Intended primarily
  156. * for bringup. See start_kernel() in init/main.c.
  157. */
  158. void __init early_sn_setup(void)
  159. {
  160. efi_system_table_t *efi_systab;
  161. efi_config_table_t *config_tables;
  162. struct ia64_sal_systab *sal_systab;
  163. struct ia64_sal_desc_entry_point *ep;
  164. char *p;
  165. int i, j;
  166. /*
  167. * Parse enough of the SAL tables to locate the SAL entry point. Since, console
  168. * IO on SN2 is done via SAL calls, early_printk won't work without this.
  169. *
  170. * This code duplicates some of the ACPI table parsing that is in efi.c & sal.c.
  171. * Any changes to those file may have to be made hereas well.
  172. */
  173. efi_systab = (efi_system_table_t *) __va(ia64_boot_param->efi_systab);
  174. config_tables = __va(efi_systab->tables);
  175. for (i = 0; i < efi_systab->nr_tables; i++) {
  176. if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) ==
  177. 0) {
  178. sal_systab = __va(config_tables[i].table);
  179. p = (char *)(sal_systab + 1);
  180. for (j = 0; j < sal_systab->entry_count; j++) {
  181. if (*p == SAL_DESC_ENTRY_POINT) {
  182. ep = (struct ia64_sal_desc_entry_point
  183. *)p;
  184. ia64_sal_handler_init(__va
  185. (ep->sal_proc),
  186. __va(ep->gp));
  187. return;
  188. }
  189. p += SAL_DESC_SIZE(*p);
  190. }
  191. }
  192. }
  193. /* Uh-oh, SAL not available?? */
  194. printk(KERN_ERR "failed to find SAL entry point\n");
  195. }
  196. extern int platform_intr_list[];
  197. extern nasid_t master_nasid;
  198. static int __initdata shub_1_1_found = 0;
  199. /*
  200. * sn_check_for_wars
  201. *
  202. * Set flag for enabling shub specific wars
  203. */
  204. static inline int __init is_shub_1_1(int nasid)
  205. {
  206. unsigned long id;
  207. int rev;
  208. if (is_shub2())
  209. return 0;
  210. id = REMOTE_HUB_L(nasid, SH1_SHUB_ID);
  211. rev = (id & SH1_SHUB_ID_REVISION_MASK) >> SH1_SHUB_ID_REVISION_SHFT;
  212. return rev <= 2;
  213. }
  214. static void __init sn_check_for_wars(void)
  215. {
  216. int cnode;
  217. if (is_shub2()) {
  218. /* none yet */
  219. } else {
  220. for_each_online_node(cnode) {
  221. if (is_shub_1_1(cnodeid_to_nasid(cnode)))
  222. shub_1_1_found = 1;
  223. }
  224. }
  225. }
  226. /**
  227. * sn_setup - SN platform setup routine
  228. * @cmdline_p: kernel command line
  229. *
  230. * Handles platform setup for SN machines. This includes determining
  231. * the RTC frequency (via a SAL call), initializing secondary CPUs, and
  232. * setting up per-node data areas. The console is also initialized here.
  233. */
  234. void __init sn_setup(char **cmdline_p)
  235. {
  236. long status, ticks_per_sec, drift;
  237. int pxm;
  238. u32 version = sn_sal_rev();
  239. extern void sn_cpu_init(void);
  240. ia64_sn_plat_set_error_handling_features();
  241. #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
  242. /*
  243. * If there was a primary vga adapter identified through the
  244. * EFI PCDP table, make it the preferred console. Otherwise
  245. * zero out conswitchp.
  246. */
  247. if (vga_console_membase) {
  248. /* usable vga ... make tty0 the preferred default console */
  249. add_preferred_console("tty", 0, NULL);
  250. } else {
  251. printk(KERN_DEBUG "SGI: Disabling VGA console\n");
  252. #ifdef CONFIG_DUMMY_CONSOLE
  253. conswitchp = &dummy_con;
  254. #else
  255. conswitchp = NULL;
  256. #endif /* CONFIG_DUMMY_CONSOLE */
  257. }
  258. #endif /* def(CONFIG_VT) && def(CONFIG_VGA_CONSOLE) */
  259. MAX_DMA_ADDRESS = PAGE_OFFSET + MAX_PHYS_MEMORY;
  260. memset(physical_node_map, -1, sizeof(physical_node_map));
  261. for (pxm = 0; pxm < MAX_PXM_DOMAINS; pxm++)
  262. if (pxm_to_nid_map[pxm] != -1)
  263. physical_node_map[pxm_to_nasid(pxm)] =
  264. pxm_to_nid_map[pxm];
  265. /*
  266. * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard
  267. * support here so we don't have to listen to failed keyboard probe
  268. * messages.
  269. */
  270. if (version <= 0x0209 && acpi_kbd_controller_present) {
  271. printk(KERN_INFO "Disabling legacy keyboard support as prom "
  272. "is too old and doesn't provide FADT\n");
  273. acpi_kbd_controller_present = 0;
  274. }
  275. printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF);
  276. /*
  277. * Confirm the SAL we're running on is recent enough...
  278. */
  279. if (version < SN_SAL_MIN_VERSION) {
  280. printk(KERN_ERR "This kernel needs SGI SAL version >= "
  281. "%x.%02x\n", SN_SAL_MIN_VERSION >> 8,
  282. SN_SAL_MIN_VERSION & 0x00FF);
  283. panic("PROM version too old\n");
  284. }
  285. master_nasid = boot_get_nasid();
  286. status =
  287. ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec,
  288. &drift);
  289. if (status != 0 || ticks_per_sec < 100000) {
  290. printk(KERN_WARNING
  291. "unable to determine platform RTC clock frequency, guessing.\n");
  292. /* PROM gives wrong value for clock freq. so guess */
  293. sn_rtc_cycles_per_second = 1000000000000UL / 30000UL;
  294. } else
  295. sn_rtc_cycles_per_second = ticks_per_sec;
  296. platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR;
  297. /*
  298. * we set the default root device to /dev/hda
  299. * to make simulation easy
  300. */
  301. ROOT_DEV = Root_HDA1;
  302. /*
  303. * Create the PDAs and NODEPDAs for all the cpus.
  304. */
  305. sn_init_pdas(cmdline_p);
  306. ia64_mark_idle = &snidle;
  307. /*
  308. * For the bootcpu, we do this here. All other cpus will make the
  309. * call as part of cpu_init in slave cpu initialization.
  310. */
  311. sn_cpu_init();
  312. #ifdef CONFIG_SMP
  313. init_smp_config();
  314. #endif
  315. screen_info = sn_screen_info;
  316. sn_timer_init();
  317. /*
  318. * set pm_power_off to a SAL call to allow
  319. * sn machines to power off. The SAL call can be replaced
  320. * by an ACPI interface call when ACPI is fully implemented
  321. * for sn.
  322. */
  323. pm_power_off = ia64_sn_power_down;
  324. }
  325. /**
  326. * sn_init_pdas - setup node data areas
  327. *
  328. * One time setup for Node Data Area. Called by sn_setup().
  329. */
  330. static void __init sn_init_pdas(char **cmdline_p)
  331. {
  332. cnodeid_t cnode;
  333. memset(sn_cnodeid_to_nasid, -1,
  334. sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));
  335. for_each_online_node(cnode)
  336. sn_cnodeid_to_nasid[cnode] =
  337. pxm_to_nasid(nid_to_pxm_map[cnode]);
  338. numionodes = num_online_nodes();
  339. scan_for_ionodes();
  340. /*
  341. * Allocate & initalize the nodepda for each node.
  342. */
  343. for_each_online_node(cnode) {
  344. nodepdaindr[cnode] =
  345. alloc_bootmem_node(NODE_DATA(cnode), sizeof(nodepda_t));
  346. memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
  347. memset(nodepdaindr[cnode]->phys_cpuid, -1,
  348. sizeof(nodepdaindr[cnode]->phys_cpuid));
  349. }
  350. /*
  351. * Allocate & initialize nodepda for TIOs. For now, put them on node 0.
  352. */
  353. for (cnode = num_online_nodes(); cnode < numionodes; cnode++) {
  354. nodepdaindr[cnode] =
  355. alloc_bootmem_node(NODE_DATA(0), sizeof(nodepda_t));
  356. memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
  357. }
  358. /*
  359. * Now copy the array of nodepda pointers to each nodepda.
  360. */
  361. for (cnode = 0; cnode < numionodes; cnode++)
  362. memcpy(nodepdaindr[cnode]->pernode_pdaindr, nodepdaindr,
  363. sizeof(nodepdaindr));
  364. /*
  365. * Set up IO related platform-dependent nodepda fields.
  366. * The following routine actually sets up the hubinfo struct
  367. * in nodepda.
  368. */
  369. for_each_online_node(cnode) {
  370. bte_init_node(nodepdaindr[cnode], cnode);
  371. }
  372. /*
  373. * Initialize the per node hubdev. This includes IO Nodes and
  374. * headless/memless nodes.
  375. */
  376. for (cnode = 0; cnode < numionodes; cnode++) {
  377. hubdev_init_node(nodepdaindr[cnode], cnode);
  378. }
  379. }
  380. /**
  381. * sn_cpu_init - initialize per-cpu data areas
  382. * @cpuid: cpuid of the caller
  383. *
  384. * Called during cpu initialization on each cpu as it starts.
  385. * Currently, initializes the per-cpu data area for SNIA.
  386. * Also sets up a few fields in the nodepda. Also known as
  387. * platform_cpu_init() by the ia64 machvec code.
  388. */
  389. void __init sn_cpu_init(void)
  390. {
  391. int cpuid;
  392. int cpuphyid;
  393. int nasid;
  394. int subnode;
  395. int slice;
  396. int cnode;
  397. int i;
  398. static int wars_have_been_checked;
  399. if (smp_processor_id() == 0 && IS_MEDUSA()) {
  400. if (ia64_sn_is_fake_prom())
  401. sn_prom_type = 2;
  402. else
  403. sn_prom_type = 1;
  404. printk("Running on medusa with %s PROM\n", (sn_prom_type == 1) ? "real" : "fake");
  405. }
  406. memset(pda, 0, sizeof(pda));
  407. if (ia64_sn_get_sn_info(0, &sn_hub_info->shub2, &sn_hub_info->nasid_bitmask, &sn_hub_info->nasid_shift,
  408. &sn_system_size, &sn_sharing_domain_size, &sn_partition_id,
  409. &sn_coherency_id, &sn_region_size))
  410. BUG();
  411. sn_hub_info->as_shift = sn_hub_info->nasid_shift - 2;
  412. /*
  413. * The boot cpu makes this call again after platform initialization is
  414. * complete.
  415. */
  416. if (nodepdaindr[0] == NULL)
  417. return;
  418. cpuid = smp_processor_id();
  419. cpuphyid = get_sapicid();
  420. if (ia64_sn_get_sapic_info(cpuphyid, &nasid, &subnode, &slice))
  421. BUG();
  422. for (i=0; i < MAX_NUMNODES; i++) {
  423. if (nodepdaindr[i]) {
  424. nodepdaindr[i]->phys_cpuid[cpuid].nasid = nasid;
  425. nodepdaindr[i]->phys_cpuid[cpuid].slice = slice;
  426. nodepdaindr[i]->phys_cpuid[cpuid].subnode = subnode;
  427. }
  428. }
  429. cnode = nasid_to_cnodeid(nasid);
  430. sn_nodepda = nodepdaindr[cnode];
  431. pda->led_address =
  432. (typeof(pda->led_address)) (LED0 + (slice << LED_CPU_SHIFT));
  433. pda->led_state = LED_ALWAYS_SET;
  434. pda->hb_count = HZ / 2;
  435. pda->hb_state = 0;
  436. pda->idle_flag = 0;
  437. if (cpuid != 0) {
  438. /* copy cpu 0's sn_cnodeid_to_nasid table to this cpu's */
  439. memcpy(sn_cnodeid_to_nasid,
  440. (&per_cpu(__sn_cnodeid_to_nasid, 0)),
  441. sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));
  442. }
  443. /*
  444. * Check for WARs.
  445. * Only needs to be done once, on BSP.
  446. * Has to be done after loop above, because it uses this cpu's
  447. * sn_cnodeid_to_nasid table which was just initialized if this
  448. * isn't cpu 0.
  449. * Has to be done before assignment below.
  450. */
  451. if (!wars_have_been_checked) {
  452. sn_check_for_wars();
  453. wars_have_been_checked = 1;
  454. }
  455. sn_hub_info->shub_1_1_found = shub_1_1_found;
  456. /*
  457. * Set up addresses of PIO/MEM write status registers.
  458. */
  459. {
  460. u64 pio1[] = {SH1_PIO_WRITE_STATUS_0, 0, SH1_PIO_WRITE_STATUS_1, 0};
  461. u64 pio2[] = {SH2_PIO_WRITE_STATUS_0, SH2_PIO_WRITE_STATUS_1,
  462. SH2_PIO_WRITE_STATUS_2, SH2_PIO_WRITE_STATUS_3};
  463. u64 *pio;
  464. pio = is_shub1() ? pio1 : pio2;
  465. pda->pio_write_status_addr = (volatile unsigned long *) LOCAL_MMR_ADDR(pio[slice]);
  466. pda->pio_write_status_val = is_shub1() ? SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK : 0;
  467. }
  468. /*
  469. * WAR addresses for SHUB 1.x.
  470. */
  471. if (local_node_data->active_cpu_count++ == 0 && is_shub1()) {
  472. int buddy_nasid;
  473. buddy_nasid =
  474. cnodeid_to_nasid(numa_node_id() ==
  475. num_online_nodes() - 1 ? 0 : numa_node_id() + 1);
  476. pda->pio_shub_war_cam_addr =
  477. (volatile unsigned long *)GLOBAL_MMR_ADDR(nasid,
  478. SH1_PI_CAM_CONTROL);
  479. }
  480. }
  481. /*
  482. * Scan klconfig for ionodes. Add the nasids to the
  483. * physical_node_map and the pda and increment numionodes.
  484. */
  485. static void __init scan_for_ionodes(void)
  486. {
  487. int nasid = 0;
  488. lboard_t *brd;
  489. /* fakeprom does not support klgraph */
  490. if (IS_RUNNING_ON_FAKE_PROM())
  491. return;
  492. /* Setup ionodes with memory */
  493. for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
  494. char *klgraph_header;
  495. cnodeid_t cnodeid;
  496. if (physical_node_map[nasid] == -1)
  497. continue;
  498. cnodeid = -1;
  499. klgraph_header = __va(ia64_sn_get_klconfig_addr(nasid));
  500. if (!klgraph_header) {
  501. BUG(); /* All nodes must have klconfig tables! */
  502. }
  503. cnodeid = nasid_to_cnodeid(nasid);
  504. root_lboard[cnodeid] = (lboard_t *)
  505. NODE_OFFSET_TO_LBOARD((nasid),
  506. ((kl_config_hdr_t
  507. *) (klgraph_header))->
  508. ch_board_info);
  509. }
  510. /* Scan headless/memless IO Nodes. */
  511. for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
  512. /* if there's no nasid, don't try to read the klconfig on the node */
  513. if (physical_node_map[nasid] == -1)
  514. continue;
  515. brd = find_lboard_any((lboard_t *)
  516. root_lboard[nasid_to_cnodeid(nasid)],
  517. KLTYPE_SNIA);
  518. if (brd) {
  519. brd = KLCF_NEXT_ANY(brd); /* Skip this node's lboard */
  520. if (!brd)
  521. continue;
  522. }
  523. brd = find_lboard_any(brd, KLTYPE_SNIA);
  524. while (brd) {
  525. sn_cnodeid_to_nasid[numionodes] = brd->brd_nasid;
  526. physical_node_map[brd->brd_nasid] = numionodes;
  527. root_lboard[numionodes] = brd;
  528. numionodes++;
  529. brd = KLCF_NEXT_ANY(brd);
  530. if (!brd)
  531. break;
  532. brd = find_lboard_any(brd, KLTYPE_SNIA);
  533. }
  534. }
  535. /* Scan for TIO nodes. */
  536. for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid += 2) {
  537. /* if there's no nasid, don't try to read the klconfig on the node */
  538. if (physical_node_map[nasid] == -1)
  539. continue;
  540. brd = find_lboard_any((lboard_t *)
  541. root_lboard[nasid_to_cnodeid(nasid)],
  542. KLTYPE_TIO);
  543. while (brd) {
  544. sn_cnodeid_to_nasid[numionodes] = brd->brd_nasid;
  545. physical_node_map[brd->brd_nasid] = numionodes;
  546. root_lboard[numionodes] = brd;
  547. numionodes++;
  548. brd = KLCF_NEXT_ANY(brd);
  549. if (!brd)
  550. break;
  551. brd = find_lboard_any(brd, KLTYPE_TIO);
  552. }
  553. }
  554. }
  555. int
  556. nasid_slice_to_cpuid(int nasid, int slice)
  557. {
  558. long cpu;
  559. for (cpu=0; cpu < NR_CPUS; cpu++)
  560. if (cpuid_to_nasid(cpu) == nasid &&
  561. cpuid_to_slice(cpu) == slice)
  562. return cpu;
  563. return -1;
  564. }