setup.c 38 KB

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