setup.c 38 KB

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