setup.c 38 KB

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