setup.c 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/alpha/kernel/setup.c
  4. *
  5. * Copyright (C) 1995 Linus Torvalds
  6. */
  7. /* 2.3.x bootmem, 1999 Andrea Arcangeli <andrea@suse.de> */
  8. /*
  9. * Bootup setup stuff.
  10. */
  11. #include <linux/sched.h>
  12. #include <linux/kernel.h>
  13. #include <linux/mm.h>
  14. #include <linux/stddef.h>
  15. #include <linux/unistd.h>
  16. #include <linux/ptrace.h>
  17. #include <linux/slab.h>
  18. #include <linux/user.h>
  19. #include <linux/screen_info.h>
  20. #include <linux/delay.h>
  21. #include <linux/mc146818rtc.h>
  22. #include <linux/console.h>
  23. #include <linux/cpu.h>
  24. #include <linux/errno.h>
  25. #include <linux/init.h>
  26. #include <linux/string.h>
  27. #include <linux/ioport.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/bootmem.h>
  30. #include <linux/pci.h>
  31. #include <linux/seq_file.h>
  32. #include <linux/root_dev.h>
  33. #include <linux/initrd.h>
  34. #include <linux/eisa.h>
  35. #include <linux/pfn.h>
  36. #ifdef CONFIG_MAGIC_SYSRQ
  37. #include <linux/sysrq.h>
  38. #include <linux/reboot.h>
  39. #endif
  40. #include <linux/notifier.h>
  41. #include <asm/setup.h>
  42. #include <asm/io.h>
  43. #include <linux/log2.h>
  44. #include <linux/export.h>
  45. extern struct atomic_notifier_head panic_notifier_list;
  46. static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
  47. static struct notifier_block alpha_panic_block = {
  48. alpha_panic_event,
  49. NULL,
  50. INT_MAX /* try to do it first */
  51. };
  52. #include <linux/uaccess.h>
  53. #include <asm/pgtable.h>
  54. #include <asm/hwrpb.h>
  55. #include <asm/dma.h>
  56. #include <asm/mmu_context.h>
  57. #include <asm/console.h>
  58. #include "proto.h"
  59. #include "pci_impl.h"
  60. struct hwrpb_struct *hwrpb;
  61. EXPORT_SYMBOL(hwrpb);
  62. unsigned long srm_hae;
  63. int alpha_l1i_cacheshape;
  64. int alpha_l1d_cacheshape;
  65. int alpha_l2_cacheshape;
  66. int alpha_l3_cacheshape;
  67. #ifdef CONFIG_VERBOSE_MCHECK
  68. /* 0=minimum, 1=verbose, 2=all */
  69. /* These can be overridden via the command line, ie "verbose_mcheck=2") */
  70. unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
  71. #endif
  72. #ifdef CONFIG_NUMA
  73. struct cpumask node_to_cpumask_map[MAX_NUMNODES] __read_mostly;
  74. EXPORT_SYMBOL(node_to_cpumask_map);
  75. #endif
  76. /* Which processor we booted from. */
  77. int boot_cpuid;
  78. /*
  79. * Using SRM callbacks for initial console output. This works from
  80. * setup_arch() time through the end of time_init(), as those places
  81. * are under our (Alpha) control.
  82. * "srmcons" specified in the boot command arguments allows us to
  83. * see kernel messages during the period of time before the true
  84. * console device is "registered" during console_init().
  85. * As of this version (2.5.59), console_init() will call
  86. * disable_early_printk() as the last action before initializing
  87. * the console drivers. That's the last possible time srmcons can be
  88. * unregistered without interfering with console behavior.
  89. *
  90. * By default, OFF; set it with a bootcommand arg of "srmcons" or
  91. * "console=srm". The meaning of these two args is:
  92. * "srmcons" - early callback prints
  93. * "console=srm" - full callback based console, including early prints
  94. */
  95. int srmcons_output = 0;
  96. /* Enforce a memory size limit; useful for testing. By default, none. */
  97. unsigned long mem_size_limit = 0;
  98. /* Set AGP GART window size (0 means disabled). */
  99. unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
  100. #ifdef CONFIG_ALPHA_GENERIC
  101. struct alpha_machine_vector alpha_mv;
  102. EXPORT_SYMBOL(alpha_mv);
  103. #endif
  104. #ifndef alpha_using_srm
  105. int alpha_using_srm;
  106. EXPORT_SYMBOL(alpha_using_srm);
  107. #endif
  108. #ifndef alpha_using_qemu
  109. int alpha_using_qemu;
  110. #endif
  111. static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
  112. unsigned long);
  113. static struct alpha_machine_vector *get_sysvec_byname(const char *);
  114. static void get_sysnames(unsigned long, unsigned long, unsigned long,
  115. char **, char **);
  116. static void determine_cpu_caches (unsigned int);
  117. static char __initdata command_line[COMMAND_LINE_SIZE];
  118. /*
  119. * The format of "screen_info" is strange, and due to early
  120. * i386-setup code. This is just enough to make the console
  121. * code think we're on a VGA color display.
  122. */
  123. struct screen_info screen_info = {
  124. .orig_x = 0,
  125. .orig_y = 25,
  126. .orig_video_cols = 80,
  127. .orig_video_lines = 25,
  128. .orig_video_isVGA = 1,
  129. .orig_video_points = 16
  130. };
  131. EXPORT_SYMBOL(screen_info);
  132. /*
  133. * The direct map I/O window, if any. This should be the same
  134. * for all busses, since it's used by virt_to_bus.
  135. */
  136. unsigned long __direct_map_base;
  137. unsigned long __direct_map_size;
  138. EXPORT_SYMBOL(__direct_map_base);
  139. EXPORT_SYMBOL(__direct_map_size);
  140. /*
  141. * Declare all of the machine vectors.
  142. */
  143. /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
  144. __attribute__((weak)) or #pragma weak. Bypass it and talk directly
  145. to the assembler. */
  146. #define WEAK(X) \
  147. extern struct alpha_machine_vector X; \
  148. asm(".weak "#X)
  149. WEAK(alcor_mv);
  150. WEAK(alphabook1_mv);
  151. WEAK(avanti_mv);
  152. WEAK(cabriolet_mv);
  153. WEAK(clipper_mv);
  154. WEAK(dp264_mv);
  155. WEAK(eb164_mv);
  156. WEAK(eb64p_mv);
  157. WEAK(eb66_mv);
  158. WEAK(eb66p_mv);
  159. WEAK(eiger_mv);
  160. WEAK(jensen_mv);
  161. WEAK(lx164_mv);
  162. WEAK(lynx_mv);
  163. WEAK(marvel_ev7_mv);
  164. WEAK(miata_mv);
  165. WEAK(mikasa_mv);
  166. WEAK(mikasa_primo_mv);
  167. WEAK(monet_mv);
  168. WEAK(nautilus_mv);
  169. WEAK(noname_mv);
  170. WEAK(noritake_mv);
  171. WEAK(noritake_primo_mv);
  172. WEAK(p2k_mv);
  173. WEAK(pc164_mv);
  174. WEAK(privateer_mv);
  175. WEAK(rawhide_mv);
  176. WEAK(ruffian_mv);
  177. WEAK(rx164_mv);
  178. WEAK(sable_mv);
  179. WEAK(sable_gamma_mv);
  180. WEAK(shark_mv);
  181. WEAK(sx164_mv);
  182. WEAK(takara_mv);
  183. WEAK(titan_mv);
  184. WEAK(webbrick_mv);
  185. WEAK(wildfire_mv);
  186. WEAK(xl_mv);
  187. WEAK(xlt_mv);
  188. #undef WEAK
  189. /*
  190. * I/O resources inherited from PeeCees. Except for perhaps the
  191. * turbochannel alphas, everyone has these on some sort of SuperIO chip.
  192. *
  193. * ??? If this becomes less standard, move the struct out into the
  194. * machine vector.
  195. */
  196. static void __init
  197. reserve_std_resources(void)
  198. {
  199. static struct resource standard_io_resources[] = {
  200. { .name = "rtc", .start = -1, .end = -1 },
  201. { .name = "dma1", .start = 0x00, .end = 0x1f },
  202. { .name = "pic1", .start = 0x20, .end = 0x3f },
  203. { .name = "timer", .start = 0x40, .end = 0x5f },
  204. { .name = "keyboard", .start = 0x60, .end = 0x6f },
  205. { .name = "dma page reg", .start = 0x80, .end = 0x8f },
  206. { .name = "pic2", .start = 0xa0, .end = 0xbf },
  207. { .name = "dma2", .start = 0xc0, .end = 0xdf },
  208. };
  209. struct resource *io = &ioport_resource;
  210. size_t i;
  211. if (hose_head) {
  212. struct pci_controller *hose;
  213. for (hose = hose_head; hose; hose = hose->next)
  214. if (hose->index == 0) {
  215. io = hose->io_space;
  216. break;
  217. }
  218. }
  219. /* Fix up for the Jensen's queer RTC placement. */
  220. standard_io_resources[0].start = RTC_PORT(0);
  221. standard_io_resources[0].end = RTC_PORT(0) + 0x10;
  222. for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i)
  223. request_resource(io, standard_io_resources+i);
  224. }
  225. #define PFN_MAX PFN_DOWN(0x80000000)
  226. #define for_each_mem_cluster(memdesc, _cluster, i) \
  227. for ((_cluster) = (memdesc)->cluster, (i) = 0; \
  228. (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
  229. static unsigned long __init
  230. get_mem_size_limit(char *s)
  231. {
  232. unsigned long end = 0;
  233. char *from = s;
  234. end = simple_strtoul(from, &from, 0);
  235. if ( *from == 'K' || *from == 'k' ) {
  236. end = end << 10;
  237. from++;
  238. } else if ( *from == 'M' || *from == 'm' ) {
  239. end = end << 20;
  240. from++;
  241. } else if ( *from == 'G' || *from == 'g' ) {
  242. end = end << 30;
  243. from++;
  244. }
  245. return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
  246. }
  247. #ifdef CONFIG_BLK_DEV_INITRD
  248. void * __init
  249. move_initrd(unsigned long mem_limit)
  250. {
  251. void *start;
  252. unsigned long size;
  253. size = initrd_end - initrd_start;
  254. start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
  255. if (!start || __pa(start) + size > mem_limit) {
  256. initrd_start = initrd_end = 0;
  257. return NULL;
  258. }
  259. memmove(start, (void *)initrd_start, size);
  260. initrd_start = (unsigned long)start;
  261. initrd_end = initrd_start + size;
  262. printk("initrd moved to %p\n", start);
  263. return start;
  264. }
  265. #endif
  266. #ifndef CONFIG_DISCONTIGMEM
  267. static void __init
  268. setup_memory(void *kernel_end)
  269. {
  270. struct memclust_struct * cluster;
  271. struct memdesc_struct * memdesc;
  272. unsigned long start_kernel_pfn, end_kernel_pfn;
  273. unsigned long bootmap_size, bootmap_pages, bootmap_start;
  274. unsigned long start, end;
  275. unsigned long i;
  276. /* Find free clusters, and init and free the bootmem accordingly. */
  277. memdesc = (struct memdesc_struct *)
  278. (hwrpb->mddt_offset + (unsigned long) hwrpb);
  279. for_each_mem_cluster(memdesc, cluster, i) {
  280. printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
  281. i, cluster->usage, cluster->start_pfn,
  282. cluster->start_pfn + cluster->numpages);
  283. /* Bit 0 is console/PALcode reserved. Bit 1 is
  284. non-volatile memory -- we might want to mark
  285. this for later. */
  286. if (cluster->usage & 3)
  287. continue;
  288. end = cluster->start_pfn + cluster->numpages;
  289. if (end > max_low_pfn)
  290. max_low_pfn = end;
  291. }
  292. /*
  293. * Except for the NUMA systems (wildfire, marvel) all of the
  294. * Alpha systems we run on support 32GB of memory or less.
  295. * Since the NUMA systems introduce large holes in memory addressing,
  296. * we can get into a situation where there is not enough contiguous
  297. * memory for the memory map.
  298. *
  299. * Limit memory to the first 32GB to limit the NUMA systems to
  300. * memory on their first node (wildfire) or 2 (marvel) to avoid
  301. * not being able to produce the memory map. In order to access
  302. * all of the memory on the NUMA systems, build with discontiguous
  303. * memory support.
  304. *
  305. * If the user specified a memory limit, let that memory limit stand.
  306. */
  307. if (!mem_size_limit)
  308. mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
  309. if (mem_size_limit && max_low_pfn >= mem_size_limit)
  310. {
  311. printk("setup: forcing memory size to %ldK (from %ldK).\n",
  312. mem_size_limit << (PAGE_SHIFT - 10),
  313. max_low_pfn << (PAGE_SHIFT - 10));
  314. max_low_pfn = mem_size_limit;
  315. }
  316. /* Find the bounds of kernel memory. */
  317. start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
  318. end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
  319. bootmap_start = -1;
  320. try_again:
  321. if (max_low_pfn <= end_kernel_pfn)
  322. panic("not enough memory to boot");
  323. /* We need to know how many physically contiguous pages
  324. we'll need for the bootmap. */
  325. bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
  326. /* Now find a good region where to allocate the bootmap. */
  327. for_each_mem_cluster(memdesc, cluster, i) {
  328. if (cluster->usage & 3)
  329. continue;
  330. start = cluster->start_pfn;
  331. end = start + cluster->numpages;
  332. if (start >= max_low_pfn)
  333. continue;
  334. if (end > max_low_pfn)
  335. end = max_low_pfn;
  336. if (start < start_kernel_pfn) {
  337. if (end > end_kernel_pfn
  338. && end - end_kernel_pfn >= bootmap_pages) {
  339. bootmap_start = end_kernel_pfn;
  340. break;
  341. } else if (end > start_kernel_pfn)
  342. end = start_kernel_pfn;
  343. } else if (start < end_kernel_pfn)
  344. start = end_kernel_pfn;
  345. if (end - start >= bootmap_pages) {
  346. bootmap_start = start;
  347. break;
  348. }
  349. }
  350. if (bootmap_start == ~0UL) {
  351. max_low_pfn >>= 1;
  352. goto try_again;
  353. }
  354. /* Allocate the bootmap and mark the whole MM as reserved. */
  355. bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
  356. /* Mark the free regions. */
  357. for_each_mem_cluster(memdesc, cluster, i) {
  358. if (cluster->usage & 3)
  359. continue;
  360. start = cluster->start_pfn;
  361. end = cluster->start_pfn + cluster->numpages;
  362. if (start >= max_low_pfn)
  363. continue;
  364. if (end > max_low_pfn)
  365. end = max_low_pfn;
  366. if (start < start_kernel_pfn) {
  367. if (end > end_kernel_pfn) {
  368. free_bootmem(PFN_PHYS(start),
  369. (PFN_PHYS(start_kernel_pfn)
  370. - PFN_PHYS(start)));
  371. printk("freeing pages %ld:%ld\n",
  372. start, start_kernel_pfn);
  373. start = end_kernel_pfn;
  374. } else if (end > start_kernel_pfn)
  375. end = start_kernel_pfn;
  376. } else if (start < end_kernel_pfn)
  377. start = end_kernel_pfn;
  378. if (start >= end)
  379. continue;
  380. free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
  381. printk("freeing pages %ld:%ld\n", start, end);
  382. }
  383. /* Reserve the bootmap memory. */
  384. reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size,
  385. BOOTMEM_DEFAULT);
  386. printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
  387. #ifdef CONFIG_BLK_DEV_INITRD
  388. initrd_start = INITRD_START;
  389. if (initrd_start) {
  390. initrd_end = initrd_start+INITRD_SIZE;
  391. printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
  392. (void *) initrd_start, INITRD_SIZE);
  393. if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
  394. if (!move_initrd(PFN_PHYS(max_low_pfn)))
  395. printk("initrd extends beyond end of memory "
  396. "(0x%08lx > 0x%p)\ndisabling initrd\n",
  397. initrd_end,
  398. phys_to_virt(PFN_PHYS(max_low_pfn)));
  399. } else {
  400. reserve_bootmem(virt_to_phys((void *)initrd_start),
  401. INITRD_SIZE, BOOTMEM_DEFAULT);
  402. }
  403. }
  404. #endif /* CONFIG_BLK_DEV_INITRD */
  405. }
  406. #else
  407. extern void setup_memory(void *);
  408. #endif /* !CONFIG_DISCONTIGMEM */
  409. int __init
  410. page_is_ram(unsigned long pfn)
  411. {
  412. struct memclust_struct * cluster;
  413. struct memdesc_struct * memdesc;
  414. unsigned long i;
  415. memdesc = (struct memdesc_struct *)
  416. (hwrpb->mddt_offset + (unsigned long) hwrpb);
  417. for_each_mem_cluster(memdesc, cluster, i)
  418. {
  419. if (pfn >= cluster->start_pfn &&
  420. pfn < cluster->start_pfn + cluster->numpages) {
  421. return (cluster->usage & 3) ? 0 : 1;
  422. }
  423. }
  424. return 0;
  425. }
  426. static int __init
  427. register_cpus(void)
  428. {
  429. int i;
  430. for_each_possible_cpu(i) {
  431. struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
  432. if (!p)
  433. return -ENOMEM;
  434. register_cpu(p, i);
  435. }
  436. return 0;
  437. }
  438. arch_initcall(register_cpus);
  439. void __init
  440. setup_arch(char **cmdline_p)
  441. {
  442. extern char _end[];
  443. struct alpha_machine_vector *vec = NULL;
  444. struct percpu_struct *cpu;
  445. char *type_name, *var_name, *p;
  446. void *kernel_end = _end; /* end of kernel */
  447. char *args = command_line;
  448. hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
  449. boot_cpuid = hard_smp_processor_id();
  450. /*
  451. * Pre-process the system type to make sure it will be valid.
  452. *
  453. * This may restore real CABRIO and EB66+ family names, ie
  454. * EB64+ and EB66.
  455. *
  456. * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
  457. * and AS1200 (DIGITAL Server 5000 series) have the type as
  458. * the negative of the real one.
  459. */
  460. if ((long)hwrpb->sys_type < 0) {
  461. hwrpb->sys_type = -((long)hwrpb->sys_type);
  462. hwrpb_update_checksum(hwrpb);
  463. }
  464. /* Register a call for panic conditions. */
  465. atomic_notifier_chain_register(&panic_notifier_list,
  466. &alpha_panic_block);
  467. #ifndef alpha_using_srm
  468. /* Assume that we've booted from SRM if we haven't booted from MILO.
  469. Detect the later by looking for "MILO" in the system serial nr. */
  470. alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
  471. #endif
  472. #ifndef alpha_using_qemu
  473. /* Similarly, look for QEMU. */
  474. alpha_using_qemu = strstr((const char *)hwrpb->ssn, "QEMU") != 0;
  475. #endif
  476. /* If we are using SRM, we want to allow callbacks
  477. as early as possible, so do this NOW, and then
  478. they should work immediately thereafter.
  479. */
  480. kernel_end = callback_init(kernel_end);
  481. /*
  482. * Locate the command line.
  483. */
  484. /* Hack for Jensen... since we're restricted to 8 or 16 chars for
  485. boot flags depending on the boot mode, we need some shorthand.
  486. This should do for installation. */
  487. if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
  488. strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
  489. } else {
  490. strlcpy(command_line, COMMAND_LINE, sizeof command_line);
  491. }
  492. strcpy(boot_command_line, command_line);
  493. *cmdline_p = command_line;
  494. /*
  495. * Process command-line arguments.
  496. */
  497. while ((p = strsep(&args, " \t")) != NULL) {
  498. if (!*p) continue;
  499. if (strncmp(p, "alpha_mv=", 9) == 0) {
  500. vec = get_sysvec_byname(p+9);
  501. continue;
  502. }
  503. if (strncmp(p, "cycle=", 6) == 0) {
  504. est_cycle_freq = simple_strtol(p+6, NULL, 0);
  505. continue;
  506. }
  507. if (strncmp(p, "mem=", 4) == 0) {
  508. mem_size_limit = get_mem_size_limit(p+4);
  509. continue;
  510. }
  511. if (strncmp(p, "srmcons", 7) == 0) {
  512. srmcons_output |= 1;
  513. continue;
  514. }
  515. if (strncmp(p, "console=srm", 11) == 0) {
  516. srmcons_output |= 2;
  517. continue;
  518. }
  519. if (strncmp(p, "gartsize=", 9) == 0) {
  520. alpha_agpgart_size =
  521. get_mem_size_limit(p+9) << PAGE_SHIFT;
  522. continue;
  523. }
  524. #ifdef CONFIG_VERBOSE_MCHECK
  525. if (strncmp(p, "verbose_mcheck=", 15) == 0) {
  526. alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
  527. continue;
  528. }
  529. #endif
  530. }
  531. /* Replace the command line, now that we've killed it with strsep. */
  532. strcpy(command_line, boot_command_line);
  533. /* If we want SRM console printk echoing early, do it now. */
  534. if (alpha_using_srm && srmcons_output) {
  535. register_srm_console();
  536. /*
  537. * If "console=srm" was specified, clear the srmcons_output
  538. * flag now so that time.c won't unregister_srm_console
  539. */
  540. if (srmcons_output & 2)
  541. srmcons_output = 0;
  542. }
  543. #ifdef CONFIG_MAGIC_SYSRQ
  544. /* If we're using SRM, make sysrq-b halt back to the prom,
  545. not auto-reboot. */
  546. if (alpha_using_srm) {
  547. struct sysrq_key_op *op = __sysrq_get_key_op('b');
  548. op->handler = (void *) machine_halt;
  549. }
  550. #endif
  551. /*
  552. * Identify and reconfigure for the current system.
  553. */
  554. cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
  555. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  556. cpu->type, &type_name, &var_name);
  557. if (*var_name == '0')
  558. var_name = "";
  559. if (!vec) {
  560. vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
  561. cpu->type);
  562. }
  563. if (!vec) {
  564. panic("Unsupported system type: %s%s%s (%ld %ld)\n",
  565. type_name, (*var_name ? " variation " : ""), var_name,
  566. hwrpb->sys_type, hwrpb->sys_variation);
  567. }
  568. if (vec != &alpha_mv) {
  569. alpha_mv = *vec;
  570. }
  571. printk("Booting "
  572. #ifdef CONFIG_ALPHA_GENERIC
  573. "GENERIC "
  574. #endif
  575. "on %s%s%s using machine vector %s from %s\n",
  576. type_name, (*var_name ? " variation " : ""),
  577. var_name, alpha_mv.vector_name,
  578. (alpha_using_srm ? "SRM" : "MILO"));
  579. printk("Major Options: "
  580. #ifdef CONFIG_SMP
  581. "SMP "
  582. #endif
  583. #ifdef CONFIG_ALPHA_EV56
  584. "EV56 "
  585. #endif
  586. #ifdef CONFIG_ALPHA_EV67
  587. "EV67 "
  588. #endif
  589. #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
  590. "LEGACY_START "
  591. #endif
  592. #ifdef CONFIG_VERBOSE_MCHECK
  593. "VERBOSE_MCHECK "
  594. #endif
  595. #ifdef CONFIG_DISCONTIGMEM
  596. "DISCONTIGMEM "
  597. #ifdef CONFIG_NUMA
  598. "NUMA "
  599. #endif
  600. #endif
  601. #ifdef CONFIG_DEBUG_SPINLOCK
  602. "DEBUG_SPINLOCK "
  603. #endif
  604. #ifdef CONFIG_MAGIC_SYSRQ
  605. "MAGIC_SYSRQ "
  606. #endif
  607. "\n");
  608. printk("Command line: %s\n", command_line);
  609. /*
  610. * Sync up the HAE.
  611. * Save the SRM's current value for restoration.
  612. */
  613. srm_hae = *alpha_mv.hae_register;
  614. __set_hae(alpha_mv.hae_cache);
  615. /* Reset enable correctable error reports. */
  616. wrmces(0x7);
  617. /* Find our memory. */
  618. setup_memory(kernel_end);
  619. /* First guess at cpu cache sizes. Do this before init_arch. */
  620. determine_cpu_caches(cpu->type);
  621. /* Initialize the machine. Usually has to do with setting up
  622. DMA windows and the like. */
  623. if (alpha_mv.init_arch)
  624. alpha_mv.init_arch();
  625. /* Reserve standard resources. */
  626. reserve_std_resources();
  627. /*
  628. * Give us a default console. TGA users will see nothing until
  629. * chr_dev_init is called, rather late in the boot sequence.
  630. */
  631. #ifdef CONFIG_VT
  632. #if defined(CONFIG_VGA_CONSOLE)
  633. conswitchp = &vga_con;
  634. #elif defined(CONFIG_DUMMY_CONSOLE)
  635. conswitchp = &dummy_con;
  636. #endif
  637. #endif
  638. /* Default root filesystem to sda2. */
  639. ROOT_DEV = Root_SDA2;
  640. #ifdef CONFIG_EISA
  641. /* FIXME: only set this when we actually have EISA in this box? */
  642. EISA_bus = 1;
  643. #endif
  644. /*
  645. * Check ASN in HWRPB for validity, report if bad.
  646. * FIXME: how was this failing? Should we trust it instead,
  647. * and copy the value into alpha_mv.max_asn?
  648. */
  649. if (hwrpb->max_asn != MAX_ASN) {
  650. printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
  651. }
  652. /*
  653. * Identify the flock of penguins.
  654. */
  655. #ifdef CONFIG_SMP
  656. setup_smp();
  657. #endif
  658. paging_init();
  659. }
  660. static char sys_unknown[] = "Unknown";
  661. static char systype_names[][16] = {
  662. "0",
  663. "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
  664. "Pelican", "Morgan", "Sable", "Medulla", "Noname",
  665. "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
  666. "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
  667. "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
  668. "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
  669. "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
  670. };
  671. static char unofficial_names[][8] = {"100", "Ruffian"};
  672. static char api_names[][16] = {"200", "Nautilus"};
  673. static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
  674. static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
  675. static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
  676. static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
  677. static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
  678. static int eb64p_indices[] = {0,0,1,2};
  679. static char eb66_names[][8] = {"EB66", "EB66+"};
  680. static int eb66_indices[] = {0,0,1};
  681. static char marvel_names[][16] = {
  682. "Marvel/EV7"
  683. };
  684. static int marvel_indices[] = { 0 };
  685. static char rawhide_names[][16] = {
  686. "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
  687. };
  688. static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
  689. static char titan_names[][16] = {
  690. "DEFAULT", "Privateer", "Falcon", "Granite"
  691. };
  692. static int titan_indices[] = {0,1,2,2,3};
  693. static char tsunami_names[][16] = {
  694. "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
  695. "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
  696. "Flying Clipper", "Shark"
  697. };
  698. static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
  699. static struct alpha_machine_vector * __init
  700. get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
  701. {
  702. static struct alpha_machine_vector *systype_vecs[] __initdata =
  703. {
  704. NULL, /* 0 */
  705. NULL, /* ADU */
  706. NULL, /* Cobra */
  707. NULL, /* Ruby */
  708. NULL, /* Flamingo */
  709. NULL, /* Mannequin */
  710. &jensen_mv,
  711. NULL, /* Pelican */
  712. NULL, /* Morgan */
  713. NULL, /* Sable -- see below. */
  714. NULL, /* Medulla */
  715. &noname_mv,
  716. NULL, /* Turbolaser */
  717. &avanti_mv,
  718. NULL, /* Mustang */
  719. NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
  720. NULL, /* Tradewind */
  721. NULL, /* Mikasa -- see below. */
  722. NULL, /* EB64 */
  723. NULL, /* EB66 -- see variation. */
  724. NULL, /* EB64+ -- see variation. */
  725. &alphabook1_mv,
  726. &rawhide_mv,
  727. NULL, /* K2 */
  728. &lynx_mv, /* Lynx */
  729. &xl_mv,
  730. NULL, /* EB164 -- see variation. */
  731. NULL, /* Noritake -- see below. */
  732. NULL, /* Cortex */
  733. NULL, /* 29 */
  734. &miata_mv,
  735. NULL, /* XXM */
  736. &takara_mv,
  737. NULL, /* Yukon */
  738. NULL, /* Tsunami -- see variation. */
  739. &wildfire_mv, /* Wildfire */
  740. NULL, /* CUSCO */
  741. &eiger_mv, /* Eiger */
  742. NULL, /* Titan */
  743. NULL, /* Marvel */
  744. };
  745. static struct alpha_machine_vector *unofficial_vecs[] __initdata =
  746. {
  747. NULL, /* 100 */
  748. &ruffian_mv,
  749. };
  750. static struct alpha_machine_vector *api_vecs[] __initdata =
  751. {
  752. NULL, /* 200 */
  753. &nautilus_mv,
  754. };
  755. static struct alpha_machine_vector *alcor_vecs[] __initdata =
  756. {
  757. &alcor_mv, &xlt_mv, &xlt_mv
  758. };
  759. static struct alpha_machine_vector *eb164_vecs[] __initdata =
  760. {
  761. &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
  762. };
  763. static struct alpha_machine_vector *eb64p_vecs[] __initdata =
  764. {
  765. &eb64p_mv,
  766. &cabriolet_mv,
  767. &cabriolet_mv /* AlphaPCI64 */
  768. };
  769. static struct alpha_machine_vector *eb66_vecs[] __initdata =
  770. {
  771. &eb66_mv,
  772. &eb66p_mv
  773. };
  774. static struct alpha_machine_vector *marvel_vecs[] __initdata =
  775. {
  776. &marvel_ev7_mv,
  777. };
  778. static struct alpha_machine_vector *titan_vecs[] __initdata =
  779. {
  780. &titan_mv, /* default */
  781. &privateer_mv, /* privateer */
  782. &titan_mv, /* falcon */
  783. &privateer_mv, /* granite */
  784. };
  785. static struct alpha_machine_vector *tsunami_vecs[] __initdata =
  786. {
  787. NULL,
  788. &dp264_mv, /* dp264 */
  789. &dp264_mv, /* warhol */
  790. &dp264_mv, /* windjammer */
  791. &monet_mv, /* monet */
  792. &clipper_mv, /* clipper */
  793. &dp264_mv, /* goldrush */
  794. &webbrick_mv, /* webbrick */
  795. &dp264_mv, /* catamaran */
  796. NULL, /* brisbane? */
  797. NULL, /* melbourne? */
  798. NULL, /* flying clipper? */
  799. &shark_mv, /* shark */
  800. };
  801. /* ??? Do we need to distinguish between Rawhides? */
  802. struct alpha_machine_vector *vec;
  803. /* Search the system tables first... */
  804. vec = NULL;
  805. if (type < ARRAY_SIZE(systype_vecs)) {
  806. vec = systype_vecs[type];
  807. } else if ((type > ST_API_BIAS) &&
  808. (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
  809. vec = api_vecs[type - ST_API_BIAS];
  810. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  811. (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
  812. vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
  813. }
  814. /* If we've not found one, try for a variation. */
  815. if (!vec) {
  816. /* Member ID is a bit-field. */
  817. unsigned long member = (variation >> 10) & 0x3f;
  818. cpu &= 0xffffffff; /* make it usable */
  819. switch (type) {
  820. case ST_DEC_ALCOR:
  821. if (member < ARRAY_SIZE(alcor_indices))
  822. vec = alcor_vecs[alcor_indices[member]];
  823. break;
  824. case ST_DEC_EB164:
  825. if (member < ARRAY_SIZE(eb164_indices))
  826. vec = eb164_vecs[eb164_indices[member]];
  827. /* PC164 may show as EB164 variation with EV56 CPU,
  828. but, since no true EB164 had anything but EV5... */
  829. if (vec == &eb164_mv && cpu == EV56_CPU)
  830. vec = &pc164_mv;
  831. break;
  832. case ST_DEC_EB64P:
  833. if (member < ARRAY_SIZE(eb64p_indices))
  834. vec = eb64p_vecs[eb64p_indices[member]];
  835. break;
  836. case ST_DEC_EB66:
  837. if (member < ARRAY_SIZE(eb66_indices))
  838. vec = eb66_vecs[eb66_indices[member]];
  839. break;
  840. case ST_DEC_MARVEL:
  841. if (member < ARRAY_SIZE(marvel_indices))
  842. vec = marvel_vecs[marvel_indices[member]];
  843. break;
  844. case ST_DEC_TITAN:
  845. vec = titan_vecs[0]; /* default */
  846. if (member < ARRAY_SIZE(titan_indices))
  847. vec = titan_vecs[titan_indices[member]];
  848. break;
  849. case ST_DEC_TSUNAMI:
  850. if (member < ARRAY_SIZE(tsunami_indices))
  851. vec = tsunami_vecs[tsunami_indices[member]];
  852. break;
  853. case ST_DEC_1000:
  854. if (cpu == EV5_CPU || cpu == EV56_CPU)
  855. vec = &mikasa_primo_mv;
  856. else
  857. vec = &mikasa_mv;
  858. break;
  859. case ST_DEC_NORITAKE:
  860. if (cpu == EV5_CPU || cpu == EV56_CPU)
  861. vec = &noritake_primo_mv;
  862. else
  863. vec = &noritake_mv;
  864. break;
  865. case ST_DEC_2100_A500:
  866. if (cpu == EV5_CPU || cpu == EV56_CPU)
  867. vec = &sable_gamma_mv;
  868. else
  869. vec = &sable_mv;
  870. break;
  871. }
  872. }
  873. return vec;
  874. }
  875. static struct alpha_machine_vector * __init
  876. get_sysvec_byname(const char *name)
  877. {
  878. static struct alpha_machine_vector *all_vecs[] __initdata =
  879. {
  880. &alcor_mv,
  881. &alphabook1_mv,
  882. &avanti_mv,
  883. &cabriolet_mv,
  884. &clipper_mv,
  885. &dp264_mv,
  886. &eb164_mv,
  887. &eb64p_mv,
  888. &eb66_mv,
  889. &eb66p_mv,
  890. &eiger_mv,
  891. &jensen_mv,
  892. &lx164_mv,
  893. &lynx_mv,
  894. &miata_mv,
  895. &mikasa_mv,
  896. &mikasa_primo_mv,
  897. &monet_mv,
  898. &nautilus_mv,
  899. &noname_mv,
  900. &noritake_mv,
  901. &noritake_primo_mv,
  902. &p2k_mv,
  903. &pc164_mv,
  904. &privateer_mv,
  905. &rawhide_mv,
  906. &ruffian_mv,
  907. &rx164_mv,
  908. &sable_mv,
  909. &sable_gamma_mv,
  910. &shark_mv,
  911. &sx164_mv,
  912. &takara_mv,
  913. &webbrick_mv,
  914. &wildfire_mv,
  915. &xl_mv,
  916. &xlt_mv
  917. };
  918. size_t i;
  919. for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
  920. struct alpha_machine_vector *mv = all_vecs[i];
  921. if (strcasecmp(mv->vector_name, name) == 0)
  922. return mv;
  923. }
  924. return NULL;
  925. }
  926. static void
  927. get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
  928. char **type_name, char **variation_name)
  929. {
  930. unsigned long member;
  931. /* If not in the tables, make it UNKNOWN,
  932. else set type name to family */
  933. if (type < ARRAY_SIZE(systype_names)) {
  934. *type_name = systype_names[type];
  935. } else if ((type > ST_API_BIAS) &&
  936. (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
  937. *type_name = api_names[type - ST_API_BIAS];
  938. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  939. (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
  940. *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
  941. } else {
  942. *type_name = sys_unknown;
  943. *variation_name = sys_unknown;
  944. return;
  945. }
  946. /* Set variation to "0"; if variation is zero, done. */
  947. *variation_name = systype_names[0];
  948. if (variation == 0) {
  949. return;
  950. }
  951. member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
  952. cpu &= 0xffffffff; /* make it usable */
  953. switch (type) { /* select by family */
  954. default: /* default to variation "0" for now */
  955. break;
  956. case ST_DEC_EB164:
  957. if (member >= ARRAY_SIZE(eb164_indices))
  958. break;
  959. *variation_name = eb164_names[eb164_indices[member]];
  960. /* PC164 may show as EB164 variation, but with EV56 CPU,
  961. so, since no true EB164 had anything but EV5... */
  962. if (eb164_indices[member] == 0 && cpu == EV56_CPU)
  963. *variation_name = eb164_names[1]; /* make it PC164 */
  964. break;
  965. case ST_DEC_ALCOR:
  966. if (member < ARRAY_SIZE(alcor_indices))
  967. *variation_name = alcor_names[alcor_indices[member]];
  968. break;
  969. case ST_DEC_EB64P:
  970. if (member < ARRAY_SIZE(eb64p_indices))
  971. *variation_name = eb64p_names[eb64p_indices[member]];
  972. break;
  973. case ST_DEC_EB66:
  974. if (member < ARRAY_SIZE(eb66_indices))
  975. *variation_name = eb66_names[eb66_indices[member]];
  976. break;
  977. case ST_DEC_MARVEL:
  978. if (member < ARRAY_SIZE(marvel_indices))
  979. *variation_name = marvel_names[marvel_indices[member]];
  980. break;
  981. case ST_DEC_RAWHIDE:
  982. if (member < ARRAY_SIZE(rawhide_indices))
  983. *variation_name = rawhide_names[rawhide_indices[member]];
  984. break;
  985. case ST_DEC_TITAN:
  986. *variation_name = titan_names[0]; /* default */
  987. if (member < ARRAY_SIZE(titan_indices))
  988. *variation_name = titan_names[titan_indices[member]];
  989. break;
  990. case ST_DEC_TSUNAMI:
  991. if (member < ARRAY_SIZE(tsunami_indices))
  992. *variation_name = tsunami_names[tsunami_indices[member]];
  993. break;
  994. }
  995. }
  996. /*
  997. * A change was made to the HWRPB via an ECO and the following code
  998. * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
  999. * was not implemented in the console firmware. If it's revision 5 or
  1000. * greater we can get the name of the platform as an ASCII string from
  1001. * the HWRPB. That's what this function does. It checks the revision
  1002. * level and if the string is in the HWRPB it returns the address of
  1003. * the string--a pointer to the name of the platform.
  1004. *
  1005. * Returns:
  1006. * - Pointer to a ASCII string if it's in the HWRPB
  1007. * - Pointer to a blank string if the data is not in the HWRPB.
  1008. */
  1009. static char *
  1010. platform_string(void)
  1011. {
  1012. struct dsr_struct *dsr;
  1013. static char unk_system_string[] = "N/A";
  1014. /* Go to the console for the string pointer.
  1015. * If the rpb_vers is not 5 or greater the rpb
  1016. * is old and does not have this data in it.
  1017. */
  1018. if (hwrpb->revision < 5)
  1019. return (unk_system_string);
  1020. else {
  1021. /* The Dynamic System Recognition struct
  1022. * has the system platform name starting
  1023. * after the character count of the string.
  1024. */
  1025. dsr = ((struct dsr_struct *)
  1026. ((char *)hwrpb + hwrpb->dsr_offset));
  1027. return ((char *)dsr + (dsr->sysname_off +
  1028. sizeof(long)));
  1029. }
  1030. }
  1031. static int
  1032. get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
  1033. {
  1034. struct percpu_struct *cpu;
  1035. unsigned long i;
  1036. int count = 0;
  1037. for (i = 0; i < num; i++) {
  1038. cpu = (struct percpu_struct *)
  1039. ((char *)cpubase + i*hwrpb->processor_size);
  1040. if ((cpu->flags & 0x1cc) == 0x1cc)
  1041. count++;
  1042. }
  1043. return count;
  1044. }
  1045. static void
  1046. show_cache_size (struct seq_file *f, const char *which, int shape)
  1047. {
  1048. if (shape == -1)
  1049. seq_printf (f, "%s\t\t: n/a\n", which);
  1050. else if (shape == 0)
  1051. seq_printf (f, "%s\t\t: unknown\n", which);
  1052. else
  1053. seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
  1054. which, shape >> 10, shape & 15,
  1055. 1 << ((shape >> 4) & 15));
  1056. }
  1057. static int
  1058. show_cpuinfo(struct seq_file *f, void *slot)
  1059. {
  1060. extern struct unaligned_stat {
  1061. unsigned long count, va, pc;
  1062. } unaligned[2];
  1063. static char cpu_names[][8] = {
  1064. "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
  1065. "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
  1066. "EV68CX", "EV7", "EV79", "EV69"
  1067. };
  1068. struct percpu_struct *cpu = slot;
  1069. unsigned int cpu_index;
  1070. char *cpu_name;
  1071. char *systype_name;
  1072. char *sysvariation_name;
  1073. int nr_processors;
  1074. unsigned long timer_freq;
  1075. cpu_index = (unsigned) (cpu->type - 1);
  1076. cpu_name = "Unknown";
  1077. if (cpu_index < ARRAY_SIZE(cpu_names))
  1078. cpu_name = cpu_names[cpu_index];
  1079. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  1080. cpu->type, &systype_name, &sysvariation_name);
  1081. nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
  1082. #if CONFIG_HZ == 1024 || CONFIG_HZ == 1200
  1083. timer_freq = (100UL * hwrpb->intr_freq) / 4096;
  1084. #else
  1085. timer_freq = 100UL * CONFIG_HZ;
  1086. #endif
  1087. seq_printf(f, "cpu\t\t\t: Alpha\n"
  1088. "cpu model\t\t: %s\n"
  1089. "cpu variation\t\t: %ld\n"
  1090. "cpu revision\t\t: %ld\n"
  1091. "cpu serial number\t: %s\n"
  1092. "system type\t\t: %s\n"
  1093. "system variation\t: %s\n"
  1094. "system revision\t\t: %ld\n"
  1095. "system serial number\t: %s\n"
  1096. "cycle frequency [Hz]\t: %lu %s\n"
  1097. "timer frequency [Hz]\t: %lu.%02lu\n"
  1098. "page size [bytes]\t: %ld\n"
  1099. "phys. address bits\t: %ld\n"
  1100. "max. addr. space #\t: %ld\n"
  1101. "BogoMIPS\t\t: %lu.%02lu\n"
  1102. "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1103. "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1104. "platform string\t\t: %s\n"
  1105. "cpus detected\t\t: %d\n",
  1106. cpu_name, cpu->variation, cpu->revision,
  1107. (char*)cpu->serial_no,
  1108. systype_name, sysvariation_name, hwrpb->sys_revision,
  1109. (char*)hwrpb->ssn,
  1110. est_cycle_freq ? : hwrpb->cycle_freq,
  1111. est_cycle_freq ? "est." : "",
  1112. timer_freq / 100, timer_freq % 100,
  1113. hwrpb->pagesize,
  1114. hwrpb->pa_bits,
  1115. hwrpb->max_asn,
  1116. loops_per_jiffy / (500000/HZ),
  1117. (loops_per_jiffy / (5000/HZ)) % 100,
  1118. unaligned[0].count, unaligned[0].pc, unaligned[0].va,
  1119. unaligned[1].count, unaligned[1].pc, unaligned[1].va,
  1120. platform_string(), nr_processors);
  1121. #ifdef CONFIG_SMP
  1122. seq_printf(f, "cpus active\t\t: %u\n"
  1123. "cpu active mask\t\t: %016lx\n",
  1124. num_online_cpus(), cpumask_bits(cpu_possible_mask)[0]);
  1125. #endif
  1126. show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
  1127. show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
  1128. show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
  1129. show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
  1130. return 0;
  1131. }
  1132. static int __init
  1133. read_mem_block(int *addr, int stride, int size)
  1134. {
  1135. long nloads = size / stride, cnt, tmp;
  1136. __asm__ __volatile__(
  1137. " rpcc %0\n"
  1138. "1: ldl %3,0(%2)\n"
  1139. " subq %1,1,%1\n"
  1140. /* Next two XORs introduce an explicit data dependency between
  1141. consecutive loads in the loop, which will give us true load
  1142. latency. */
  1143. " xor %3,%2,%2\n"
  1144. " xor %3,%2,%2\n"
  1145. " addq %2,%4,%2\n"
  1146. " bne %1,1b\n"
  1147. " rpcc %3\n"
  1148. " subl %3,%0,%0\n"
  1149. : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
  1150. : "r" (stride), "1" (nloads), "2" (addr));
  1151. return cnt / (size / stride);
  1152. }
  1153. #define CSHAPE(totalsize, linesize, assoc) \
  1154. ((totalsize & ~0xff) | (linesize << 4) | assoc)
  1155. /* ??? EV5 supports up to 64M, but did the systems with more than
  1156. 16M of BCACHE ever exist? */
  1157. #define MAX_BCACHE_SIZE 16*1024*1024
  1158. /* Note that the offchip caches are direct mapped on all Alphas. */
  1159. static int __init
  1160. external_cache_probe(int minsize, int width)
  1161. {
  1162. int cycles, prev_cycles = 1000000;
  1163. int stride = 1 << width;
  1164. long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
  1165. if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
  1166. maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
  1167. /* Get the first block cached. */
  1168. read_mem_block(__va(0), stride, size);
  1169. while (size < maxsize) {
  1170. /* Get an average load latency in cycles. */
  1171. cycles = read_mem_block(__va(0), stride, size);
  1172. if (cycles > prev_cycles * 2) {
  1173. /* Fine, we exceed the cache. */
  1174. printk("%ldK Bcache detected; load hit latency %d "
  1175. "cycles, load miss latency %d cycles\n",
  1176. size >> 11, prev_cycles, cycles);
  1177. return CSHAPE(size >> 1, width, 1);
  1178. }
  1179. /* Try to get the next block cached. */
  1180. read_mem_block(__va(size), stride, size);
  1181. prev_cycles = cycles;
  1182. size <<= 1;
  1183. }
  1184. return -1; /* No BCACHE found. */
  1185. }
  1186. static void __init
  1187. determine_cpu_caches (unsigned int cpu_type)
  1188. {
  1189. int L1I, L1D, L2, L3;
  1190. switch (cpu_type) {
  1191. case EV4_CPU:
  1192. case EV45_CPU:
  1193. {
  1194. if (cpu_type == EV4_CPU)
  1195. L1I = CSHAPE(8*1024, 5, 1);
  1196. else
  1197. L1I = CSHAPE(16*1024, 5, 1);
  1198. L1D = L1I;
  1199. L3 = -1;
  1200. /* BIU_CTL is a write-only Abox register. PALcode has a
  1201. shadow copy, and may be available from some versions
  1202. of the CSERVE PALcall. If we can get it, then
  1203. unsigned long biu_ctl, size;
  1204. size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
  1205. L2 = CSHAPE (size, 5, 1);
  1206. Unfortunately, we can't rely on that.
  1207. */
  1208. L2 = external_cache_probe(128*1024, 5);
  1209. break;
  1210. }
  1211. case LCA4_CPU:
  1212. {
  1213. unsigned long car, size;
  1214. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1215. L3 = -1;
  1216. car = *(vuip) phys_to_virt (0x120000078UL);
  1217. size = 64*1024 * (1 << ((car >> 5) & 7));
  1218. /* No typo -- 8 byte cacheline size. Whodathunk. */
  1219. L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
  1220. break;
  1221. }
  1222. case EV5_CPU:
  1223. case EV56_CPU:
  1224. {
  1225. unsigned long sc_ctl, width;
  1226. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1227. /* Check the line size of the Scache. */
  1228. sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
  1229. width = sc_ctl & 0x1000 ? 6 : 5;
  1230. L2 = CSHAPE (96*1024, width, 3);
  1231. /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
  1232. has a shadow copy, and may be available from some versions
  1233. of the CSERVE PALcall. If we can get it, then
  1234. unsigned long bc_control, bc_config, size;
  1235. size = 1024*1024 * (1 << ((bc_config & 7) - 1));
  1236. L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
  1237. Unfortunately, we can't rely on that.
  1238. */
  1239. L3 = external_cache_probe(1024*1024, width);
  1240. break;
  1241. }
  1242. case PCA56_CPU:
  1243. case PCA57_CPU:
  1244. {
  1245. if (cpu_type == PCA56_CPU) {
  1246. L1I = CSHAPE(16*1024, 6, 1);
  1247. L1D = CSHAPE(8*1024, 5, 1);
  1248. } else {
  1249. L1I = CSHAPE(32*1024, 6, 2);
  1250. L1D = CSHAPE(16*1024, 5, 1);
  1251. }
  1252. L3 = -1;
  1253. #if 0
  1254. unsigned long cbox_config, size;
  1255. cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
  1256. size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
  1257. L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
  1258. #else
  1259. L2 = external_cache_probe(512*1024, 6);
  1260. #endif
  1261. break;
  1262. }
  1263. case EV6_CPU:
  1264. case EV67_CPU:
  1265. case EV68CB_CPU:
  1266. case EV68AL_CPU:
  1267. case EV68CX_CPU:
  1268. case EV69_CPU:
  1269. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1270. L2 = external_cache_probe(1024*1024, 6);
  1271. L3 = -1;
  1272. break;
  1273. case EV7_CPU:
  1274. case EV79_CPU:
  1275. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1276. L2 = CSHAPE(7*1024*1024/4, 6, 7);
  1277. L3 = -1;
  1278. break;
  1279. default:
  1280. /* Nothing known about this cpu type. */
  1281. L1I = L1D = L2 = L3 = 0;
  1282. break;
  1283. }
  1284. alpha_l1i_cacheshape = L1I;
  1285. alpha_l1d_cacheshape = L1D;
  1286. alpha_l2_cacheshape = L2;
  1287. alpha_l3_cacheshape = L3;
  1288. }
  1289. /*
  1290. * We show only CPU #0 info.
  1291. */
  1292. static void *
  1293. c_start(struct seq_file *f, loff_t *pos)
  1294. {
  1295. return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
  1296. }
  1297. static void *
  1298. c_next(struct seq_file *f, void *v, loff_t *pos)
  1299. {
  1300. return NULL;
  1301. }
  1302. static void
  1303. c_stop(struct seq_file *f, void *v)
  1304. {
  1305. }
  1306. const struct seq_operations cpuinfo_op = {
  1307. .start = c_start,
  1308. .next = c_next,
  1309. .stop = c_stop,
  1310. .show = show_cpuinfo,
  1311. };
  1312. static int
  1313. alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
  1314. {
  1315. #if 1
  1316. /* FIXME FIXME FIXME */
  1317. /* If we are using SRM and serial console, just hard halt here. */
  1318. if (alpha_using_srm && srmcons_output)
  1319. __halt();
  1320. #endif
  1321. return NOTIFY_DONE;
  1322. }
  1323. static __init int add_pcspkr(void)
  1324. {
  1325. struct platform_device *pd;
  1326. int ret;
  1327. pd = platform_device_alloc("pcspkr", -1);
  1328. if (!pd)
  1329. return -ENOMEM;
  1330. ret = platform_device_add(pd);
  1331. if (ret)
  1332. platform_device_put(pd);
  1333. return ret;
  1334. }
  1335. device_initcall(add_pcspkr);