add port definition for mcf UART driver
[linux-2.6/next.git] / arch / ia64 / sn / kernel / setup.c
blob1f38a3a68390f0502a04c2a3fca273b37e7d3a7d
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.
6 * Copyright (C) 1999,2001-2006 Silicon Graphics, Inc. All rights reserved.
7 */
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/screen_info.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/root_dev.h>
29 #include <linux/nodemask.h>
30 #include <linux/pm.h>
31 #include <linux/efi.h>
33 #include <asm/io.h>
34 #include <asm/sal.h>
35 #include <asm/machvec.h>
36 #include <asm/system.h>
37 #include <asm/processor.h>
38 #include <asm/vga.h>
39 #include <asm/sn/arch.h>
40 #include <asm/sn/addrs.h>
41 #include <asm/sn/pda.h>
42 #include <asm/sn/nodepda.h>
43 #include <asm/sn/sn_cpuid.h>
44 #include <asm/sn/simulator.h>
45 #include <asm/sn/leds.h>
46 #include <asm/sn/bte.h>
47 #include <asm/sn/shub_mmr.h>
48 #include <asm/sn/clksupport.h>
49 #include <asm/sn/sn_sal.h>
50 #include <asm/sn/geo.h>
51 #include <asm/sn/sn_feature_sets.h>
52 #include "xtalk/xwidgetdev.h"
53 #include "xtalk/hubdev.h"
54 #include <asm/sn/klconfig.h>
57 DEFINE_PER_CPU(struct pda_s, pda_percpu);
59 #define MAX_PHYS_MEMORY (1UL << IA64_MAX_PHYS_BITS) /* Max physical address supported */
61 extern void bte_init_node(nodepda_t *, cnodeid_t);
63 extern void sn_timer_init(void);
64 extern unsigned long last_time_offset;
65 extern void (*ia64_mark_idle) (int);
66 extern void snidle(int);
67 extern unsigned long long (*ia64_printk_clock)(void);
69 unsigned long sn_rtc_cycles_per_second;
70 EXPORT_SYMBOL(sn_rtc_cycles_per_second);
72 DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
73 EXPORT_PER_CPU_SYMBOL(__sn_hub_info);
75 DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_COMPACT_NODES]);
76 EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);
78 DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);
79 EXPORT_PER_CPU_SYMBOL(__sn_nodepda);
81 char sn_system_serial_number_string[128];
82 EXPORT_SYMBOL(sn_system_serial_number_string);
83 u64 sn_partition_serial_number;
84 EXPORT_SYMBOL(sn_partition_serial_number);
85 u8 sn_partition_id;
86 EXPORT_SYMBOL(sn_partition_id);
87 u8 sn_system_size;
88 EXPORT_SYMBOL(sn_system_size);
89 u8 sn_sharing_domain_size;
90 EXPORT_SYMBOL(sn_sharing_domain_size);
91 u8 sn_coherency_id;
92 EXPORT_SYMBOL(sn_coherency_id);
93 u8 sn_region_size;
94 EXPORT_SYMBOL(sn_region_size);
95 int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */
97 short physical_node_map[MAX_NUMALINK_NODES];
98 static unsigned long sn_prom_features[MAX_PROM_FEATURE_SETS];
100 EXPORT_SYMBOL(physical_node_map);
102 int num_cnodes;
104 static void sn_init_pdas(char **);
105 static void build_cnode_tables(void);
107 static nodepda_t *nodepdaindr[MAX_COMPACT_NODES];
110 * The format of "screen_info" is strange, and due to early i386-setup
111 * code. This is just enough to make the console code think we're on a
112 * VGA color display.
114 struct screen_info sn_screen_info = {
115 .orig_x = 0,
116 .orig_y = 0,
117 .orig_video_mode = 3,
118 .orig_video_cols = 80,
119 .orig_video_ega_bx = 3,
120 .orig_video_lines = 25,
121 .orig_video_isVGA = 1,
122 .orig_video_points = 16
126 * This routine can only be used during init, since
127 * smp_boot_data is an init data structure.
128 * We have to use smp_boot_data.cpu_phys_id to find
129 * the physical id of the processor because the normal
130 * cpu_physical_id() relies on data structures that
131 * may not be initialized yet.
134 static int __init pxm_to_nasid(int pxm)
136 int i;
137 int nid;
139 nid = pxm_to_node(pxm);
140 for (i = 0; i < num_node_memblks; i++) {
141 if (node_memblk[i].nid == nid) {
142 return NASID_GET(node_memblk[i].start_paddr);
145 return -1;
149 * early_sn_setup - early setup routine for SN platforms
151 * Sets up an initial console to aid debugging. Intended primarily
152 * for bringup. See start_kernel() in init/main.c.
155 void __init early_sn_setup(void)
157 efi_system_table_t *efi_systab;
158 efi_config_table_t *config_tables;
159 struct ia64_sal_systab *sal_systab;
160 struct ia64_sal_desc_entry_point *ep;
161 char *p;
162 int i, j;
165 * Parse enough of the SAL tables to locate the SAL entry point. Since, console
166 * IO on SN2 is done via SAL calls, early_printk won't work without this.
168 * This code duplicates some of the ACPI table parsing that is in efi.c & sal.c.
169 * Any changes to those file may have to be made here as well.
171 efi_systab = (efi_system_table_t *) __va(ia64_boot_param->efi_systab);
172 config_tables = __va(efi_systab->tables);
173 for (i = 0; i < efi_systab->nr_tables; i++) {
174 if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) ==
175 0) {
176 sal_systab = __va(config_tables[i].table);
177 p = (char *)(sal_systab + 1);
178 for (j = 0; j < sal_systab->entry_count; j++) {
179 if (*p == SAL_DESC_ENTRY_POINT) {
180 ep = (struct ia64_sal_desc_entry_point
181 *)p;
182 ia64_sal_handler_init(__va
183 (ep->sal_proc),
184 __va(ep->gp));
185 return;
187 p += SAL_DESC_SIZE(*p);
191 /* Uh-oh, SAL not available?? */
192 printk(KERN_ERR "failed to find SAL entry point\n");
195 extern int platform_intr_list[];
196 static int __cpuinitdata shub_1_1_found;
199 * sn_check_for_wars
201 * Set flag for enabling shub specific wars
204 static inline int __init is_shub_1_1(int nasid)
206 unsigned long id;
207 int rev;
209 if (is_shub2())
210 return 0;
211 id = REMOTE_HUB_L(nasid, SH1_SHUB_ID);
212 rev = (id & SH1_SHUB_ID_REVISION_MASK) >> SH1_SHUB_ID_REVISION_SHFT;
213 return rev <= 2;
216 static void __init sn_check_for_wars(void)
218 int cnode;
220 if (is_shub2()) {
221 /* none yet */
222 } else {
223 for_each_online_node(cnode) {
224 if (is_shub_1_1(cnodeid_to_nasid(cnode)))
225 shub_1_1_found = 1;
231 * Scan the EFI PCDP table (if it exists) for an acceptable VGA console
232 * output device. If one exists, pick it and set sn_legacy_{io,mem} to
233 * reflect the bus offsets needed to address it.
235 * Since pcdp support in SN is not supported in the 2.4 kernel (or at least
236 * the one lbs is based on) just declare the needed structs here.
238 * Reference spec http://www.dig64.org/specifications/DIG64_PCDPv20.pdf
240 * Returns 0 if no acceptable vga is found, !0 otherwise.
242 * Note: This stuff is duped here because Altix requires the PCDP to
243 * locate a usable VGA device due to lack of proper ACPI support. Structures
244 * could be used from drivers/firmware/pcdp.h, but it was decided that moving
245 * this file to a more public location just for Altix use was undesireable.
248 struct hcdp_uart_desc {
249 u8 pad[45];
252 struct pcdp {
253 u8 signature[4]; /* should be 'HCDP' */
254 u32 length;
255 u8 rev; /* should be >=3 for pcdp, <3 for hcdp */
256 u8 sum;
257 u8 oem_id[6];
258 u64 oem_tableid;
259 u32 oem_rev;
260 u32 creator_id;
261 u32 creator_rev;
262 u32 num_type0;
263 struct hcdp_uart_desc uart[0]; /* num_type0 of these */
264 /* pcdp descriptors follow */
265 } __attribute__((packed));
267 struct pcdp_device_desc {
268 u8 type;
269 u8 primary;
270 u16 length;
271 u16 index;
272 /* interconnect specific structure follows */
273 /* device specific structure follows that */
274 } __attribute__((packed));
276 struct pcdp_interface_pci {
277 u8 type; /* 1 == pci */
278 u8 reserved;
279 u16 length;
280 u8 segment;
281 u8 bus;
282 u8 dev;
283 u8 fun;
284 u16 devid;
285 u16 vendid;
286 u32 acpi_interrupt;
287 u64 mmio_tra;
288 u64 ioport_tra;
289 u8 flags;
290 u8 translation;
291 } __attribute__((packed));
293 struct pcdp_vga_device {
294 u8 num_eas_desc;
295 /* ACPI Extended Address Space Desc follows */
296 } __attribute__((packed));
298 /* from pcdp_device_desc.primary */
299 #define PCDP_PRIMARY_CONSOLE 0x01
301 /* from pcdp_device_desc.type */
302 #define PCDP_CONSOLE_INOUT 0x0
303 #define PCDP_CONSOLE_DEBUG 0x1
304 #define PCDP_CONSOLE_OUT 0x2
305 #define PCDP_CONSOLE_IN 0x3
306 #define PCDP_CONSOLE_TYPE_VGA 0x8
308 #define PCDP_CONSOLE_VGA (PCDP_CONSOLE_TYPE_VGA | PCDP_CONSOLE_OUT)
310 /* from pcdp_interface_pci.type */
311 #define PCDP_IF_PCI 1
313 /* from pcdp_interface_pci.translation */
314 #define PCDP_PCI_TRANS_IOPORT 0x02
315 #define PCDP_PCI_TRANS_MMIO 0x01
317 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
318 static void
319 sn_scan_pcdp(void)
321 u8 *bp;
322 struct pcdp *pcdp;
323 struct pcdp_device_desc device;
324 struct pcdp_interface_pci if_pci;
325 extern struct efi efi;
327 if (efi.hcdp == EFI_INVALID_TABLE_ADDR)
328 return; /* no hcdp/pcdp table */
330 pcdp = __va(efi.hcdp);
332 if (pcdp->rev < 3)
333 return; /* only support PCDP (rev >= 3) */
335 for (bp = (u8 *)&pcdp->uart[pcdp->num_type0];
336 bp < (u8 *)pcdp + pcdp->length;
337 bp += device.length) {
338 memcpy(&device, bp, sizeof(device));
339 if (! (device.primary & PCDP_PRIMARY_CONSOLE))
340 continue; /* not primary console */
342 if (device.type != PCDP_CONSOLE_VGA)
343 continue; /* not VGA descriptor */
345 memcpy(&if_pci, bp+sizeof(device), sizeof(if_pci));
346 if (if_pci.type != PCDP_IF_PCI)
347 continue; /* not PCI interconnect */
349 if (if_pci.translation & PCDP_PCI_TRANS_IOPORT)
350 vga_console_iobase = if_pci.ioport_tra;
352 if (if_pci.translation & PCDP_PCI_TRANS_MMIO)
353 vga_console_membase =
354 if_pci.mmio_tra | __IA64_UNCACHED_OFFSET;
356 break; /* once we find the primary, we're done */
359 #endif
361 static unsigned long sn2_rtc_initial;
363 static unsigned long long ia64_sn2_printk_clock(void)
365 unsigned long rtc_now = rtc_time();
367 return (rtc_now - sn2_rtc_initial) *
368 (1000000000 / sn_rtc_cycles_per_second);
372 * sn_setup - SN platform setup routine
373 * @cmdline_p: kernel command line
375 * Handles platform setup for SN machines. This includes determining
376 * the RTC frequency (via a SAL call), initializing secondary CPUs, and
377 * setting up per-node data areas. The console is also initialized here.
379 void __init sn_setup(char **cmdline_p)
381 long status, ticks_per_sec, drift;
382 u32 version = sn_sal_rev();
383 extern void sn_cpu_init(void);
385 sn2_rtc_initial = rtc_time();
386 ia64_sn_plat_set_error_handling_features(); // obsolete
387 ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV);
388 ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES);
390 * Note: The calls to notify the PROM of ACPI and PCI Segment
391 * support must be done prior to acpi_load_tables(), as
392 * an ACPI capable PROM will rebuild the DSDT as result
393 * of the call.
395 ia64_sn_set_os_feature(OSF_PCISEGMENT_ENABLE);
396 ia64_sn_set_os_feature(OSF_ACPI_ENABLE);
398 /* Load the new DSDT and SSDT tables into the global table list. */
399 acpi_table_init();
401 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
403 * Handle SN vga console.
405 * SN systems do not have enough ACPI table information
406 * being passed from prom to identify VGA adapters and the legacy
407 * addresses to access them. Until that is done, SN systems rely
408 * on the PCDP table to identify the primary VGA console if one
409 * exists.
411 * However, kernel PCDP support is optional, and even if it is built
412 * into the kernel, it will not be used if the boot cmdline contains
413 * console= directives.
415 * So, to work around this mess, we duplicate some of the PCDP code
416 * here so that the primary VGA console (as defined by PCDP) will
417 * work on SN systems even if a different console (e.g. serial) is
418 * selected on the boot line (or CONFIG_EFI_PCDP is off).
421 if (! vga_console_membase)
422 sn_scan_pcdp();
425 * Setup legacy IO space.
426 * vga_console_iobase maps to PCI IO Space address 0 on the
427 * bus containing the VGA console.
429 if (vga_console_iobase) {
430 io_space[0].mmio_base =
431 (unsigned long) ioremap(vga_console_iobase, 0);
432 io_space[0].sparse = 0;
435 if (vga_console_membase) {
436 /* usable vga ... make tty0 the preferred default console */
437 if (!strstr(*cmdline_p, "console="))
438 add_preferred_console("tty", 0, NULL);
439 } else {
440 printk(KERN_DEBUG "SGI: Disabling VGA console\n");
441 if (!strstr(*cmdline_p, "console="))
442 add_preferred_console("ttySG", 0, NULL);
443 #ifdef CONFIG_DUMMY_CONSOLE
444 conswitchp = &dummy_con;
445 #else
446 conswitchp = NULL;
447 #endif /* CONFIG_DUMMY_CONSOLE */
449 #endif /* def(CONFIG_VT) && def(CONFIG_VGA_CONSOLE) */
451 MAX_DMA_ADDRESS = PAGE_OFFSET + MAX_PHYS_MEMORY;
454 * Build the tables for managing cnodes.
456 build_cnode_tables();
458 status =
459 ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec,
460 &drift);
461 if (status != 0 || ticks_per_sec < 100000) {
462 printk(KERN_WARNING
463 "unable to determine platform RTC clock frequency, guessing.\n");
464 /* PROM gives wrong value for clock freq. so guess */
465 sn_rtc_cycles_per_second = 1000000000000UL / 30000UL;
466 } else
467 sn_rtc_cycles_per_second = ticks_per_sec;
469 platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR;
471 ia64_printk_clock = ia64_sn2_printk_clock;
473 printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF);
476 * we set the default root device to /dev/hda
477 * to make simulation easy
479 ROOT_DEV = Root_HDA1;
482 * Create the PDAs and NODEPDAs for all the cpus.
484 sn_init_pdas(cmdline_p);
486 ia64_mark_idle = &snidle;
489 * For the bootcpu, we do this here. All other cpus will make the
490 * call as part of cpu_init in slave cpu initialization.
492 sn_cpu_init();
494 #ifdef CONFIG_SMP
495 init_smp_config();
496 #endif
497 screen_info = sn_screen_info;
499 sn_timer_init();
502 * set pm_power_off to a SAL call to allow
503 * sn machines to power off. The SAL call can be replaced
504 * by an ACPI interface call when ACPI is fully implemented
505 * for sn.
507 pm_power_off = ia64_sn_power_down;
508 current->thread.flags |= IA64_THREAD_MIGRATION;
512 * sn_init_pdas - setup node data areas
514 * One time setup for Node Data Area. Called by sn_setup().
516 static void __init sn_init_pdas(char **cmdline_p)
518 cnodeid_t cnode;
521 * Allocate & initalize the nodepda for each node.
523 for_each_online_node(cnode) {
524 nodepdaindr[cnode] =
525 alloc_bootmem_node(NODE_DATA(cnode), sizeof(nodepda_t));
526 memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
527 memset(nodepdaindr[cnode]->phys_cpuid, -1,
528 sizeof(nodepdaindr[cnode]->phys_cpuid));
529 spin_lock_init(&nodepdaindr[cnode]->ptc_lock);
533 * Allocate & initialize nodepda for TIOs. For now, put them on node 0.
535 for (cnode = num_online_nodes(); cnode < num_cnodes; cnode++) {
536 nodepdaindr[cnode] =
537 alloc_bootmem_node(NODE_DATA(0), sizeof(nodepda_t));
538 memset(nodepdaindr[cnode], 0, sizeof(nodepda_t));
542 * Now copy the array of nodepda pointers to each nodepda.
544 for (cnode = 0; cnode < num_cnodes; cnode++)
545 memcpy(nodepdaindr[cnode]->pernode_pdaindr, nodepdaindr,
546 sizeof(nodepdaindr));
549 * Set up IO related platform-dependent nodepda fields.
550 * The following routine actually sets up the hubinfo struct
551 * in nodepda.
553 for_each_online_node(cnode) {
554 bte_init_node(nodepdaindr[cnode], cnode);
558 * Initialize the per node hubdev. This includes IO Nodes and
559 * headless/memless nodes.
561 for (cnode = 0; cnode < num_cnodes; cnode++) {
562 hubdev_init_node(nodepdaindr[cnode], cnode);
567 * sn_cpu_init - initialize per-cpu data areas
568 * @cpuid: cpuid of the caller
570 * Called during cpu initialization on each cpu as it starts.
571 * Currently, initializes the per-cpu data area for SNIA.
572 * Also sets up a few fields in the nodepda. Also known as
573 * platform_cpu_init() by the ia64 machvec code.
575 void __cpuinit sn_cpu_init(void)
577 int cpuid;
578 int cpuphyid;
579 int nasid;
580 int subnode;
581 int slice;
582 int cnode;
583 int i;
584 static int wars_have_been_checked, set_cpu0_number;
586 cpuid = smp_processor_id();
587 if (cpuid == 0 && IS_MEDUSA()) {
588 if (ia64_sn_is_fake_prom())
589 sn_prom_type = 2;
590 else
591 sn_prom_type = 1;
592 printk(KERN_INFO "Running on medusa with %s PROM\n",
593 (sn_prom_type == 1) ? "real" : "fake");
596 memset(pda, 0, sizeof(pda));
597 if (ia64_sn_get_sn_info(0, &sn_hub_info->shub2,
598 &sn_hub_info->nasid_bitmask,
599 &sn_hub_info->nasid_shift,
600 &sn_system_size, &sn_sharing_domain_size,
601 &sn_partition_id, &sn_coherency_id,
602 &sn_region_size))
603 BUG();
604 sn_hub_info->as_shift = sn_hub_info->nasid_shift - 2;
607 * Don't check status. The SAL call is not supported on all PROMs
608 * but a failure is harmless.
609 * Architechtuallly, cpu_init is always called twice on cpu 0. We
610 * should set cpu_number on cpu 0 once.
612 if (cpuid == 0) {
613 if (!set_cpu0_number) {
614 (void) ia64_sn_set_cpu_number(cpuid);
615 set_cpu0_number = 1;
617 } else
618 (void) ia64_sn_set_cpu_number(cpuid);
621 * The boot cpu makes this call again after platform initialization is
622 * complete.
624 if (nodepdaindr[0] == NULL)
625 return;
627 for (i = 0; i < MAX_PROM_FEATURE_SETS; i++)
628 if (ia64_sn_get_prom_feature_set(i, &sn_prom_features[i]) != 0)
629 break;
631 cpuphyid = get_sapicid();
633 if (ia64_sn_get_sapic_info(cpuphyid, &nasid, &subnode, &slice))
634 BUG();
636 for (i=0; i < MAX_NUMNODES; i++) {
637 if (nodepdaindr[i]) {
638 nodepdaindr[i]->phys_cpuid[cpuid].nasid = nasid;
639 nodepdaindr[i]->phys_cpuid[cpuid].slice = slice;
640 nodepdaindr[i]->phys_cpuid[cpuid].subnode = subnode;
644 cnode = nasid_to_cnodeid(nasid);
646 sn_nodepda = nodepdaindr[cnode];
648 pda->led_address =
649 (typeof(pda->led_address)) (LED0 + (slice << LED_CPU_SHIFT));
650 pda->led_state = LED_ALWAYS_SET;
651 pda->hb_count = HZ / 2;
652 pda->hb_state = 0;
653 pda->idle_flag = 0;
655 if (cpuid != 0) {
656 /* copy cpu 0's sn_cnodeid_to_nasid table to this cpu's */
657 memcpy(sn_cnodeid_to_nasid,
658 (&per_cpu(__sn_cnodeid_to_nasid, 0)),
659 sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));
663 * Check for WARs.
664 * Only needs to be done once, on BSP.
665 * Has to be done after loop above, because it uses this cpu's
666 * sn_cnodeid_to_nasid table which was just initialized if this
667 * isn't cpu 0.
668 * Has to be done before assignment below.
670 if (!wars_have_been_checked) {
671 sn_check_for_wars();
672 wars_have_been_checked = 1;
674 sn_hub_info->shub_1_1_found = shub_1_1_found;
677 * Set up addresses of PIO/MEM write status registers.
680 u64 pio1[] = {SH1_PIO_WRITE_STATUS_0, 0, SH1_PIO_WRITE_STATUS_1, 0};
681 u64 pio2[] = {SH2_PIO_WRITE_STATUS_0, SH2_PIO_WRITE_STATUS_2,
682 SH2_PIO_WRITE_STATUS_1, SH2_PIO_WRITE_STATUS_3};
683 u64 *pio;
684 pio = is_shub1() ? pio1 : pio2;
685 pda->pio_write_status_addr =
686 (volatile unsigned long *)GLOBAL_MMR_ADDR(nasid, pio[slice]);
687 pda->pio_write_status_val = is_shub1() ? SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK : 0;
691 * WAR addresses for SHUB 1.x.
693 if (local_node_data->active_cpu_count++ == 0 && is_shub1()) {
694 int buddy_nasid;
695 buddy_nasid =
696 cnodeid_to_nasid(numa_node_id() ==
697 num_online_nodes() - 1 ? 0 : numa_node_id() + 1);
698 pda->pio_shub_war_cam_addr =
699 (volatile unsigned long *)GLOBAL_MMR_ADDR(nasid,
700 SH1_PI_CAM_CONTROL);
705 * Build tables for converting between NASIDs and cnodes.
707 static inline int __init board_needs_cnode(int type)
709 return (type == KLTYPE_SNIA || type == KLTYPE_TIO);
712 void __init build_cnode_tables(void)
714 int nasid;
715 int node;
716 lboard_t *brd;
718 memset(physical_node_map, -1, sizeof(physical_node_map));
719 memset(sn_cnodeid_to_nasid, -1,
720 sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));
723 * First populate the tables with C/M bricks. This ensures that
724 * cnode == node for all C & M bricks.
726 for_each_online_node(node) {
727 nasid = pxm_to_nasid(node_to_pxm(node));
728 sn_cnodeid_to_nasid[node] = nasid;
729 physical_node_map[nasid] = node;
733 * num_cnodes is total number of C/M/TIO bricks. Because of the 256 node
734 * limit on the number of nodes, we can't use the generic node numbers
735 * for this. Note that num_cnodes is incremented below as TIOs or
736 * headless/memoryless nodes are discovered.
738 num_cnodes = num_online_nodes();
740 /* fakeprom does not support klgraph */
741 if (IS_RUNNING_ON_FAKE_PROM())
742 return;
744 /* Find TIOs & headless/memoryless nodes and add them to the tables */
745 for_each_online_node(node) {
746 kl_config_hdr_t *klgraph_header;
747 nasid = cnodeid_to_nasid(node);
748 klgraph_header = ia64_sn_get_klconfig_addr(nasid);
749 if (klgraph_header == NULL)
750 BUG();
751 brd = NODE_OFFSET_TO_LBOARD(nasid, klgraph_header->ch_board_info);
752 while (brd) {
753 if (board_needs_cnode(brd->brd_type) && physical_node_map[brd->brd_nasid] < 0) {
754 sn_cnodeid_to_nasid[num_cnodes] = brd->brd_nasid;
755 physical_node_map[brd->brd_nasid] = num_cnodes++;
757 brd = find_lboard_next(brd);
763 nasid_slice_to_cpuid(int nasid, int slice)
765 long cpu;
767 for (cpu = 0; cpu < NR_CPUS; cpu++)
768 if (cpuid_to_nasid(cpu) == nasid &&
769 cpuid_to_slice(cpu) == slice)
770 return cpu;
772 return -1;
775 int sn_prom_feature_available(int id)
777 if (id >= BITS_PER_LONG * MAX_PROM_FEATURE_SETS)
778 return 0;
779 return test_bit(id, sn_prom_features);
782 void
783 sn_kernel_launch_event(void)
785 /* ignore status until we understand possible failure, if any*/
786 if (ia64_sn_kernel_launch_event())
787 printk(KERN_ERR "KEXEC is not supported in this PROM, Please update the PROM.\n");
789 EXPORT_SYMBOL(sn_prom_feature_available);