setup.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. /*
  2. * Architecture-specific setup.
  3. *
  4. * Copyright (C) 1998-2001, 2003-2004 Hewlett-Packard Co
  5. * David Mosberger-Tang <davidm@hpl.hp.com>
  6. * Stephane Eranian <eranian@hpl.hp.com>
  7. * Copyright (C) 2000, Rohit Seth <rohit.seth@intel.com>
  8. * Copyright (C) 1999 VA Linux Systems
  9. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  10. *
  11. * 11/12/01 D.Mosberger Convert get_cpuinfo() to seq_file based show_cpuinfo().
  12. * 04/04/00 D.Mosberger renamed cpu_initialized to cpu_online_map
  13. * 03/31/00 R.Seth cpu_initialized and current->processor fixes
  14. * 02/04/00 D.Mosberger some more get_cpuinfo fixes...
  15. * 02/01/00 R.Seth fixed get_cpuinfo for SMP
  16. * 01/07/99 S.Eranian added the support for command line argument
  17. * 06/24/99 W.Drummond added boot_cpu_data.
  18. */
  19. #include <linux/config.h>
  20. #include <linux/module.h>
  21. #include <linux/init.h>
  22. #include <linux/acpi.h>
  23. #include <linux/bootmem.h>
  24. #include <linux/console.h>
  25. #include <linux/delay.h>
  26. #include <linux/kernel.h>
  27. #include <linux/reboot.h>
  28. #include <linux/sched.h>
  29. #include <linux/seq_file.h>
  30. #include <linux/string.h>
  31. #include <linux/threads.h>
  32. #include <linux/tty.h>
  33. #include <linux/serial.h>
  34. #include <linux/serial_core.h>
  35. #include <linux/efi.h>
  36. #include <linux/initrd.h>
  37. #include <asm/ia32.h>
  38. #include <asm/machvec.h>
  39. #include <asm/mca.h>
  40. #include <asm/meminit.h>
  41. #include <asm/page.h>
  42. #include <asm/patch.h>
  43. #include <asm/pgtable.h>
  44. #include <asm/processor.h>
  45. #include <asm/sal.h>
  46. #include <asm/sections.h>
  47. #include <asm/serial.h>
  48. #include <asm/setup.h>
  49. #include <asm/smp.h>
  50. #include <asm/system.h>
  51. #include <asm/unistd.h>
  52. #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE)
  53. # error "struct cpuinfo_ia64 too big!"
  54. #endif
  55. #ifdef CONFIG_SMP
  56. unsigned long __per_cpu_offset[NR_CPUS];
  57. EXPORT_SYMBOL(__per_cpu_offset);
  58. #endif
  59. DEFINE_PER_CPU(struct cpuinfo_ia64, cpu_info);
  60. DEFINE_PER_CPU(unsigned long, local_per_cpu_offset);
  61. DEFINE_PER_CPU(unsigned long, ia64_phys_stacked_size_p8);
  62. unsigned long ia64_cycles_per_usec;
  63. struct ia64_boot_param *ia64_boot_param;
  64. struct screen_info screen_info;
  65. unsigned long ia64_max_cacheline_size;
  66. unsigned long ia64_iobase; /* virtual address for I/O accesses */
  67. EXPORT_SYMBOL(ia64_iobase);
  68. struct io_space io_space[MAX_IO_SPACES];
  69. EXPORT_SYMBOL(io_space);
  70. unsigned int num_io_spaces;
  71. /*
  72. * The merge_mask variable needs to be set to (max(iommu_page_size(iommu)) - 1). This
  73. * mask specifies a mask of address bits that must be 0 in order for two buffers to be
  74. * mergeable by the I/O MMU (i.e., the end address of the first buffer and the start
  75. * address of the second buffer must be aligned to (merge_mask+1) in order to be
  76. * mergeable). By default, we assume there is no I/O MMU which can merge physically
  77. * discontiguous buffers, so we set the merge_mask to ~0UL, which corresponds to a iommu
  78. * page-size of 2^64.
  79. */
  80. unsigned long ia64_max_iommu_merge_mask = ~0UL;
  81. EXPORT_SYMBOL(ia64_max_iommu_merge_mask);
  82. /*
  83. * We use a special marker for the end of memory and it uses the extra (+1) slot
  84. */
  85. struct rsvd_region rsvd_region[IA64_MAX_RSVD_REGIONS + 1];
  86. int num_rsvd_regions;
  87. /*
  88. * Filter incoming memory segments based on the primitive map created from the boot
  89. * parameters. Segments contained in the map are removed from the memory ranges. A
  90. * caller-specified function is called with the memory ranges that remain after filtering.
  91. * This routine does not assume the incoming segments are sorted.
  92. */
  93. int
  94. filter_rsvd_memory (unsigned long start, unsigned long end, void *arg)
  95. {
  96. unsigned long range_start, range_end, prev_start;
  97. void (*func)(unsigned long, unsigned long, int);
  98. int i;
  99. #if IGNORE_PFN0
  100. if (start == PAGE_OFFSET) {
  101. printk(KERN_WARNING "warning: skipping physical page 0\n");
  102. start += PAGE_SIZE;
  103. if (start >= end) return 0;
  104. }
  105. #endif
  106. /*
  107. * lowest possible address(walker uses virtual)
  108. */
  109. prev_start = PAGE_OFFSET;
  110. func = arg;
  111. for (i = 0; i < num_rsvd_regions; ++i) {
  112. range_start = max(start, prev_start);
  113. range_end = min(end, rsvd_region[i].start);
  114. if (range_start < range_end)
  115. call_pernode_memory(__pa(range_start), range_end - range_start, func);
  116. /* nothing more available in this segment */
  117. if (range_end == end) return 0;
  118. prev_start = rsvd_region[i].end;
  119. }
  120. /* end of memory marker allows full processing inside loop body */
  121. return 0;
  122. }
  123. static void
  124. sort_regions (struct rsvd_region *rsvd_region, int max)
  125. {
  126. int j;
  127. /* simple bubble sorting */
  128. while (max--) {
  129. for (j = 0; j < max; ++j) {
  130. if (rsvd_region[j].start > rsvd_region[j+1].start) {
  131. struct rsvd_region tmp;
  132. tmp = rsvd_region[j];
  133. rsvd_region[j] = rsvd_region[j + 1];
  134. rsvd_region[j + 1] = tmp;
  135. }
  136. }
  137. }
  138. }
  139. /**
  140. * reserve_memory - setup reserved memory areas
  141. *
  142. * Setup the reserved memory areas set aside for the boot parameters,
  143. * initrd, etc. There are currently %IA64_MAX_RSVD_REGIONS defined,
  144. * see include/asm-ia64/meminit.h if you need to define more.
  145. */
  146. void
  147. reserve_memory (void)
  148. {
  149. int n = 0;
  150. /*
  151. * none of the entries in this table overlap
  152. */
  153. rsvd_region[n].start = (unsigned long) ia64_boot_param;
  154. rsvd_region[n].end = rsvd_region[n].start + sizeof(*ia64_boot_param);
  155. n++;
  156. rsvd_region[n].start = (unsigned long) __va(ia64_boot_param->efi_memmap);
  157. rsvd_region[n].end = rsvd_region[n].start + ia64_boot_param->efi_memmap_size;
  158. n++;
  159. rsvd_region[n].start = (unsigned long) __va(ia64_boot_param->command_line);
  160. rsvd_region[n].end = (rsvd_region[n].start
  161. + strlen(__va(ia64_boot_param->command_line)) + 1);
  162. n++;
  163. rsvd_region[n].start = (unsigned long) ia64_imva((void *)KERNEL_START);
  164. rsvd_region[n].end = (unsigned long) ia64_imva(_end);
  165. n++;
  166. #ifdef CONFIG_BLK_DEV_INITRD
  167. if (ia64_boot_param->initrd_start) {
  168. rsvd_region[n].start = (unsigned long)__va(ia64_boot_param->initrd_start);
  169. rsvd_region[n].end = rsvd_region[n].start + ia64_boot_param->initrd_size;
  170. n++;
  171. }
  172. #endif
  173. /* end of memory marker */
  174. rsvd_region[n].start = ~0UL;
  175. rsvd_region[n].end = ~0UL;
  176. n++;
  177. num_rsvd_regions = n;
  178. sort_regions(rsvd_region, num_rsvd_regions);
  179. }
  180. /**
  181. * find_initrd - get initrd parameters from the boot parameter structure
  182. *
  183. * Grab the initrd start and end from the boot parameter struct given us by
  184. * the boot loader.
  185. */
  186. void
  187. find_initrd (void)
  188. {
  189. #ifdef CONFIG_BLK_DEV_INITRD
  190. if (ia64_boot_param->initrd_start) {
  191. initrd_start = (unsigned long)__va(ia64_boot_param->initrd_start);
  192. initrd_end = initrd_start+ia64_boot_param->initrd_size;
  193. printk(KERN_INFO "Initial ramdisk at: 0x%lx (%lu bytes)\n",
  194. initrd_start, ia64_boot_param->initrd_size);
  195. }
  196. #endif
  197. }
  198. static void __init
  199. io_port_init (void)
  200. {
  201. extern unsigned long ia64_iobase;
  202. unsigned long phys_iobase;
  203. /*
  204. * Set `iobase' to the appropriate address in region 6 (uncached access range).
  205. *
  206. * The EFI memory map is the "preferred" location to get the I/O port space base,
  207. * rather the relying on AR.KR0. This should become more clear in future SAL
  208. * specs. We'll fall back to getting it out of AR.KR0 if no appropriate entry is
  209. * found in the memory map.
  210. */
  211. phys_iobase = efi_get_iobase();
  212. if (phys_iobase)
  213. /* set AR.KR0 since this is all we use it for anyway */
  214. ia64_set_kr(IA64_KR_IO_BASE, phys_iobase);
  215. else {
  216. phys_iobase = ia64_get_kr(IA64_KR_IO_BASE);
  217. printk(KERN_INFO "No I/O port range found in EFI memory map, falling back "
  218. "to AR.KR0\n");
  219. printk(KERN_INFO "I/O port base = 0x%lx\n", phys_iobase);
  220. }
  221. ia64_iobase = (unsigned long) ioremap(phys_iobase, 0);
  222. /* setup legacy IO port space */
  223. io_space[0].mmio_base = ia64_iobase;
  224. io_space[0].sparse = 1;
  225. num_io_spaces = 1;
  226. }
  227. /**
  228. * early_console_setup - setup debugging console
  229. *
  230. * Consoles started here require little enough setup that we can start using
  231. * them very early in the boot process, either right after the machine
  232. * vector initialization, or even before if the drivers can detect their hw.
  233. *
  234. * Returns non-zero if a console couldn't be setup.
  235. */
  236. static inline int __init
  237. early_console_setup (char *cmdline)
  238. {
  239. #ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
  240. {
  241. extern int sn_serial_console_early_setup(void);
  242. if (!sn_serial_console_early_setup())
  243. return 0;
  244. }
  245. #endif
  246. #ifdef CONFIG_EFI_PCDP
  247. if (!efi_setup_pcdp_console(cmdline))
  248. return 0;
  249. #endif
  250. #ifdef CONFIG_SERIAL_8250_CONSOLE
  251. if (!early_serial_console_init(cmdline))
  252. return 0;
  253. #endif
  254. return -1;
  255. }
  256. static inline void
  257. mark_bsp_online (void)
  258. {
  259. #ifdef CONFIG_SMP
  260. /* If we register an early console, allow CPU 0 to printk */
  261. cpu_set(smp_processor_id(), cpu_online_map);
  262. #endif
  263. }
  264. void __init
  265. setup_arch (char **cmdline_p)
  266. {
  267. unw_init();
  268. ia64_patch_vtop((u64) __start___vtop_patchlist, (u64) __end___vtop_patchlist);
  269. *cmdline_p = __va(ia64_boot_param->command_line);
  270. strlcpy(saved_command_line, *cmdline_p, COMMAND_LINE_SIZE);
  271. efi_init();
  272. io_port_init();
  273. #ifdef CONFIG_IA64_GENERIC
  274. {
  275. const char *mvec_name = strstr (*cmdline_p, "machvec=");
  276. char str[64];
  277. if (mvec_name) {
  278. const char *end;
  279. size_t len;
  280. mvec_name += 8;
  281. end = strchr (mvec_name, ' ');
  282. if (end)
  283. len = end - mvec_name;
  284. else
  285. len = strlen (mvec_name);
  286. len = min(len, sizeof (str) - 1);
  287. strncpy (str, mvec_name, len);
  288. str[len] = '\0';
  289. mvec_name = str;
  290. } else
  291. mvec_name = acpi_get_sysname();
  292. machvec_init(mvec_name);
  293. }
  294. #endif
  295. if (early_console_setup(*cmdline_p) == 0)
  296. mark_bsp_online();
  297. #ifdef CONFIG_ACPI_BOOT
  298. /* Initialize the ACPI boot-time table parser */
  299. acpi_table_init();
  300. # ifdef CONFIG_ACPI_NUMA
  301. acpi_numa_init();
  302. # endif
  303. #else
  304. # ifdef CONFIG_SMP
  305. smp_build_cpu_map(); /* happens, e.g., with the Ski simulator */
  306. # endif
  307. #endif /* CONFIG_APCI_BOOT */
  308. find_memory();
  309. /* process SAL system table: */
  310. ia64_sal_init(efi.sal_systab);
  311. #ifdef CONFIG_SMP
  312. cpu_physical_id(0) = hard_smp_processor_id();
  313. #endif
  314. cpu_init(); /* initialize the bootstrap CPU */
  315. #ifdef CONFIG_ACPI_BOOT
  316. acpi_boot_init();
  317. #endif
  318. #ifdef CONFIG_VT
  319. if (!conswitchp) {
  320. # if defined(CONFIG_DUMMY_CONSOLE)
  321. conswitchp = &dummy_con;
  322. # endif
  323. # if defined(CONFIG_VGA_CONSOLE)
  324. /*
  325. * Non-legacy systems may route legacy VGA MMIO range to system
  326. * memory. vga_con probes the MMIO hole, so memory looks like
  327. * a VGA device to it. The EFI memory map can tell us if it's
  328. * memory so we can avoid this problem.
  329. */
  330. if (efi_mem_type(0xA0000) != EFI_CONVENTIONAL_MEMORY)
  331. conswitchp = &vga_con;
  332. # endif
  333. }
  334. #endif
  335. /* enable IA-64 Machine Check Abort Handling unless disabled */
  336. if (!strstr(saved_command_line, "nomca"))
  337. ia64_mca_init();
  338. platform_setup(cmdline_p);
  339. paging_init();
  340. }
  341. /*
  342. * Display cpu info for all cpu's.
  343. */
  344. static int
  345. show_cpuinfo (struct seq_file *m, void *v)
  346. {
  347. #ifdef CONFIG_SMP
  348. # define lpj c->loops_per_jiffy
  349. # define cpunum c->cpu
  350. #else
  351. # define lpj loops_per_jiffy
  352. # define cpunum 0
  353. #endif
  354. static struct {
  355. unsigned long mask;
  356. const char *feature_name;
  357. } feature_bits[] = {
  358. { 1UL << 0, "branchlong" },
  359. { 1UL << 1, "spontaneous deferral"},
  360. { 1UL << 2, "16-byte atomic ops" }
  361. };
  362. char family[32], features[128], *cp, sep;
  363. struct cpuinfo_ia64 *c = v;
  364. unsigned long mask;
  365. int i;
  366. mask = c->features;
  367. switch (c->family) {
  368. case 0x07: memcpy(family, "Itanium", 8); break;
  369. case 0x1f: memcpy(family, "Itanium 2", 10); break;
  370. default: sprintf(family, "%u", c->family); break;
  371. }
  372. /* build the feature string: */
  373. memcpy(features, " standard", 10);
  374. cp = features;
  375. sep = 0;
  376. for (i = 0; i < (int) ARRAY_SIZE(feature_bits); ++i) {
  377. if (mask & feature_bits[i].mask) {
  378. if (sep)
  379. *cp++ = sep;
  380. sep = ',';
  381. *cp++ = ' ';
  382. strcpy(cp, feature_bits[i].feature_name);
  383. cp += strlen(feature_bits[i].feature_name);
  384. mask &= ~feature_bits[i].mask;
  385. }
  386. }
  387. if (mask) {
  388. /* print unknown features as a hex value: */
  389. if (sep)
  390. *cp++ = sep;
  391. sprintf(cp, " 0x%lx", mask);
  392. }
  393. seq_printf(m,
  394. "processor : %d\n"
  395. "vendor : %s\n"
  396. "arch : IA-64\n"
  397. "family : %s\n"
  398. "model : %u\n"
  399. "revision : %u\n"
  400. "archrev : %u\n"
  401. "features :%s\n" /* don't change this---it _is_ right! */
  402. "cpu number : %lu\n"
  403. "cpu regs : %u\n"
  404. "cpu MHz : %lu.%06lu\n"
  405. "itc MHz : %lu.%06lu\n"
  406. "BogoMIPS : %lu.%02lu\n\n",
  407. cpunum, c->vendor, family, c->model, c->revision, c->archrev,
  408. features, c->ppn, c->number,
  409. c->proc_freq / 1000000, c->proc_freq % 1000000,
  410. c->itc_freq / 1000000, c->itc_freq % 1000000,
  411. lpj*HZ/500000, (lpj*HZ/5000) % 100);
  412. return 0;
  413. }
  414. static void *
  415. c_start (struct seq_file *m, loff_t *pos)
  416. {
  417. #ifdef CONFIG_SMP
  418. while (*pos < NR_CPUS && !cpu_isset(*pos, cpu_online_map))
  419. ++*pos;
  420. #endif
  421. return *pos < NR_CPUS ? cpu_data(*pos) : NULL;
  422. }
  423. static void *
  424. c_next (struct seq_file *m, void *v, loff_t *pos)
  425. {
  426. ++*pos;
  427. return c_start(m, pos);
  428. }
  429. static void
  430. c_stop (struct seq_file *m, void *v)
  431. {
  432. }
  433. struct seq_operations cpuinfo_op = {
  434. .start = c_start,
  435. .next = c_next,
  436. .stop = c_stop,
  437. .show = show_cpuinfo
  438. };
  439. void
  440. identify_cpu (struct cpuinfo_ia64 *c)
  441. {
  442. union {
  443. unsigned long bits[5];
  444. struct {
  445. /* id 0 & 1: */
  446. char vendor[16];
  447. /* id 2 */
  448. u64 ppn; /* processor serial number */
  449. /* id 3: */
  450. unsigned number : 8;
  451. unsigned revision : 8;
  452. unsigned model : 8;
  453. unsigned family : 8;
  454. unsigned archrev : 8;
  455. unsigned reserved : 24;
  456. /* id 4: */
  457. u64 features;
  458. } field;
  459. } cpuid;
  460. pal_vm_info_1_u_t vm1;
  461. pal_vm_info_2_u_t vm2;
  462. pal_status_t status;
  463. unsigned long impl_va_msb = 50, phys_addr_size = 44; /* Itanium defaults */
  464. int i;
  465. for (i = 0; i < 5; ++i)
  466. cpuid.bits[i] = ia64_get_cpuid(i);
  467. memcpy(c->vendor, cpuid.field.vendor, 16);
  468. #ifdef CONFIG_SMP
  469. c->cpu = smp_processor_id();
  470. #endif
  471. c->ppn = cpuid.field.ppn;
  472. c->number = cpuid.field.number;
  473. c->revision = cpuid.field.revision;
  474. c->model = cpuid.field.model;
  475. c->family = cpuid.field.family;
  476. c->archrev = cpuid.field.archrev;
  477. c->features = cpuid.field.features;
  478. status = ia64_pal_vm_summary(&vm1, &vm2);
  479. if (status == PAL_STATUS_SUCCESS) {
  480. impl_va_msb = vm2.pal_vm_info_2_s.impl_va_msb;
  481. phys_addr_size = vm1.pal_vm_info_1_s.phys_add_size;
  482. }
  483. c->unimpl_va_mask = ~((7L<<61) | ((1L << (impl_va_msb + 1)) - 1));
  484. c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1));
  485. }
  486. void
  487. setup_per_cpu_areas (void)
  488. {
  489. /* start_kernel() requires this... */
  490. }
  491. static void
  492. get_max_cacheline_size (void)
  493. {
  494. unsigned long line_size, max = 1;
  495. u64 l, levels, unique_caches;
  496. pal_cache_config_info_t cci;
  497. s64 status;
  498. status = ia64_pal_cache_summary(&levels, &unique_caches);
  499. if (status != 0) {
  500. printk(KERN_ERR "%s: ia64_pal_cache_summary() failed (status=%ld)\n",
  501. __FUNCTION__, status);
  502. max = SMP_CACHE_BYTES;
  503. goto out;
  504. }
  505. for (l = 0; l < levels; ++l) {
  506. status = ia64_pal_cache_config_info(l, /* cache_type (data_or_unified)= */ 2,
  507. &cci);
  508. if (status != 0) {
  509. printk(KERN_ERR
  510. "%s: ia64_pal_cache_config_info(l=%lu) failed (status=%ld)\n",
  511. __FUNCTION__, l, status);
  512. max = SMP_CACHE_BYTES;
  513. }
  514. line_size = 1 << cci.pcci_line_size;
  515. if (line_size > max)
  516. max = line_size;
  517. }
  518. out:
  519. if (max > ia64_max_cacheline_size)
  520. ia64_max_cacheline_size = max;
  521. }
  522. /*
  523. * cpu_init() initializes state that is per-CPU. This function acts
  524. * as a 'CPU state barrier', nothing should get across.
  525. */
  526. void
  527. cpu_init (void)
  528. {
  529. extern void __devinit ia64_mmu_init (void *);
  530. unsigned long num_phys_stacked;
  531. pal_vm_info_2_u_t vmi;
  532. unsigned int max_ctx;
  533. struct cpuinfo_ia64 *cpu_info;
  534. void *cpu_data;
  535. cpu_data = per_cpu_init();
  536. /*
  537. * We set ar.k3 so that assembly code in MCA handler can compute
  538. * physical addresses of per cpu variables with a simple:
  539. * phys = ar.k3 + &per_cpu_var
  540. */
  541. ia64_set_kr(IA64_KR_PER_CPU_DATA,
  542. ia64_tpa(cpu_data) - (long) __per_cpu_start);
  543. get_max_cacheline_size();
  544. /*
  545. * We can't pass "local_cpu_data" to identify_cpu() because we haven't called
  546. * ia64_mmu_init() yet. And we can't call ia64_mmu_init() first because it
  547. * depends on the data returned by identify_cpu(). We break the dependency by
  548. * accessing cpu_data() through the canonical per-CPU address.
  549. */
  550. cpu_info = cpu_data + ((char *) &__ia64_per_cpu_var(cpu_info) - __per_cpu_start);
  551. identify_cpu(cpu_info);
  552. #ifdef CONFIG_MCKINLEY
  553. {
  554. # define FEATURE_SET 16
  555. struct ia64_pal_retval iprv;
  556. if (cpu_info->family == 0x1f) {
  557. PAL_CALL_PHYS(iprv, PAL_PROC_GET_FEATURES, 0, FEATURE_SET, 0);
  558. if ((iprv.status == 0) && (iprv.v0 & 0x80) && (iprv.v2 & 0x80))
  559. PAL_CALL_PHYS(iprv, PAL_PROC_SET_FEATURES,
  560. (iprv.v1 | 0x80), FEATURE_SET, 0);
  561. }
  562. }
  563. #endif
  564. /* Clear the stack memory reserved for pt_regs: */
  565. memset(ia64_task_regs(current), 0, sizeof(struct pt_regs));
  566. ia64_set_kr(IA64_KR_FPU_OWNER, 0);
  567. /*
  568. * Initialize the page-table base register to a global
  569. * directory with all zeroes. This ensure that we can handle
  570. * TLB-misses to user address-space even before we created the
  571. * first user address-space. This may happen, e.g., due to
  572. * aggressive use of lfetch.fault.
  573. */
  574. ia64_set_kr(IA64_KR_PT_BASE, __pa(ia64_imva(empty_zero_page)));
  575. /*
  576. * Initialize default control register to defer all speculative faults. The
  577. * kernel MUST NOT depend on a particular setting of these bits (in other words,
  578. * the kernel must have recovery code for all speculative accesses). Turn on
  579. * dcr.lc as per recommendation by the architecture team. Most IA-32 apps
  580. * shouldn't be affected by this (moral: keep your ia32 locks aligned and you'll
  581. * be fine).
  582. */
  583. ia64_setreg(_IA64_REG_CR_DCR, ( IA64_DCR_DP | IA64_DCR_DK | IA64_DCR_DX | IA64_DCR_DR
  584. | IA64_DCR_DA | IA64_DCR_DD | IA64_DCR_LC));
  585. atomic_inc(&init_mm.mm_count);
  586. current->active_mm = &init_mm;
  587. if (current->mm)
  588. BUG();
  589. ia64_mmu_init(ia64_imva(cpu_data));
  590. ia64_mca_cpu_init(ia64_imva(cpu_data));
  591. #ifdef CONFIG_IA32_SUPPORT
  592. ia32_cpu_init();
  593. #endif
  594. /* Clear ITC to eliminiate sched_clock() overflows in human time. */
  595. ia64_set_itc(0);
  596. /* disable all local interrupt sources: */
  597. ia64_set_itv(1 << 16);
  598. ia64_set_lrr0(1 << 16);
  599. ia64_set_lrr1(1 << 16);
  600. ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
  601. ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
  602. /* clear TPR & XTP to enable all interrupt classes: */
  603. ia64_setreg(_IA64_REG_CR_TPR, 0);
  604. #ifdef CONFIG_SMP
  605. normal_xtp();
  606. #endif
  607. /* set ia64_ctx.max_rid to the maximum RID that is supported by all CPUs: */
  608. if (ia64_pal_vm_summary(NULL, &vmi) == 0)
  609. max_ctx = (1U << (vmi.pal_vm_info_2_s.rid_size - 3)) - 1;
  610. else {
  611. printk(KERN_WARNING "cpu_init: PAL VM summary failed, assuming 18 RID bits\n");
  612. max_ctx = (1U << 15) - 1; /* use architected minimum */
  613. }
  614. while (max_ctx < ia64_ctx.max_ctx) {
  615. unsigned int old = ia64_ctx.max_ctx;
  616. if (cmpxchg(&ia64_ctx.max_ctx, old, max_ctx) == old)
  617. break;
  618. }
  619. if (ia64_pal_rse_info(&num_phys_stacked, NULL) != 0) {
  620. printk(KERN_WARNING "cpu_init: PAL RSE info failed; assuming 96 physical "
  621. "stacked regs\n");
  622. num_phys_stacked = 96;
  623. }
  624. /* size of physical stacked register partition plus 8 bytes: */
  625. __get_cpu_var(ia64_phys_stacked_size_p8) = num_phys_stacked*8 + 8;
  626. platform_cpu_init();
  627. }
  628. void
  629. check_bugs (void)
  630. {
  631. ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
  632. (unsigned long) __end___mckinley_e9_bundles);
  633. }