setup.c 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  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/screen_info.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/cpu.h>
  25. #include <linux/errno.h>
  26. #include <linux/init.h>
  27. #include <linux/string.h>
  28. #include <linux/ioport.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/bootmem.h>
  31. #include <linux/pci.h>
  32. #include <linux/seq_file.h>
  33. #include <linux/root_dev.h>
  34. #include <linux/initrd.h>
  35. #include <linux/eisa.h>
  36. #include <linux/pfn.h>
  37. #ifdef CONFIG_MAGIC_SYSRQ
  38. #include <linux/sysrq.h>
  39. #include <linux/reboot.h>
  40. #endif
  41. #include <linux/notifier.h>
  42. #include <asm/setup.h>
  43. #include <asm/io.h>
  44. extern struct atomic_notifier_head panic_notifier_list;
  45. static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
  46. static struct notifier_block alpha_panic_block = {
  47. alpha_panic_event,
  48. NULL,
  49. INT_MAX /* try to do it first */
  50. };
  51. #include <asm/uaccess.h>
  52. #include <asm/pgtable.h>
  53. #include <asm/system.h>
  54. #include <asm/hwrpb.h>
  55. #include <asm/dma.h>
  56. #include <asm/io.h>
  57. #include <asm/mmu_context.h>
  58. #include <asm/console.h>
  59. #include "proto.h"
  60. #include "pci_impl.h"
  61. struct hwrpb_struct *hwrpb;
  62. unsigned long srm_hae;
  63. int alpha_l1i_cacheshape;
  64. int alpha_l1d_cacheshape;
  65. int alpha_l2_cacheshape;
  66. int alpha_l3_cacheshape;
  67. #ifdef CONFIG_VERBOSE_MCHECK
  68. /* 0=minimum, 1=verbose, 2=all */
  69. /* These can be overridden via the command line, ie "verbose_mcheck=2") */
  70. unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
  71. #endif
  72. /* Which processor we booted from. */
  73. int boot_cpuid;
  74. /*
  75. * Using SRM callbacks for initial console output. This works from
  76. * setup_arch() time through the end of time_init(), as those places
  77. * are under our (Alpha) control.
  78. * "srmcons" specified in the boot command arguments allows us to
  79. * see kernel messages during the period of time before the true
  80. * console device is "registered" during console_init().
  81. * As of this version (2.5.59), console_init() will call
  82. * disable_early_printk() as the last action before initializing
  83. * the console drivers. That's the last possible time srmcons can be
  84. * unregistered without interfering with console behavior.
  85. *
  86. * By default, OFF; set it with a bootcommand arg of "srmcons" or
  87. * "console=srm". The meaning of these two args is:
  88. * "srmcons" - early callback prints
  89. * "console=srm" - full callback based console, including early prints
  90. */
  91. int srmcons_output = 0;
  92. /* Enforce a memory size limit; useful for testing. By default, none. */
  93. unsigned long mem_size_limit = 0;
  94. /* Set AGP GART window size (0 means disabled). */
  95. unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
  96. #ifdef CONFIG_ALPHA_GENERIC
  97. struct alpha_machine_vector alpha_mv;
  98. int alpha_using_srm;
  99. #endif
  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 < ARRAY_SIZE(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. static int __init
  412. register_cpus(void)
  413. {
  414. int i;
  415. for_each_possible_cpu(i) {
  416. struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
  417. if (!p)
  418. return -ENOMEM;
  419. register_cpu(p, i);
  420. }
  421. return 0;
  422. }
  423. arch_initcall(register_cpus);
  424. void __init
  425. setup_arch(char **cmdline_p)
  426. {
  427. extern char _end[];
  428. struct alpha_machine_vector *vec = NULL;
  429. struct percpu_struct *cpu;
  430. char *type_name, *var_name, *p;
  431. void *kernel_end = _end; /* end of kernel */
  432. char *args = command_line;
  433. hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
  434. boot_cpuid = hard_smp_processor_id();
  435. /*
  436. * Pre-process the system type to make sure it will be valid.
  437. *
  438. * This may restore real CABRIO and EB66+ family names, ie
  439. * EB64+ and EB66.
  440. *
  441. * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
  442. * and AS1200 (DIGITAL Server 5000 series) have the type as
  443. * the negative of the real one.
  444. */
  445. if ((long)hwrpb->sys_type < 0) {
  446. hwrpb->sys_type = -((long)hwrpb->sys_type);
  447. hwrpb_update_checksum(hwrpb);
  448. }
  449. /* Register a call for panic conditions. */
  450. atomic_notifier_chain_register(&panic_notifier_list,
  451. &alpha_panic_block);
  452. #ifdef CONFIG_ALPHA_GENERIC
  453. /* Assume that we've booted from SRM if we haven't booted from MILO.
  454. Detect the later by looking for "MILO" in the system serial nr. */
  455. alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
  456. #endif
  457. /* If we are using SRM, we want to allow callbacks
  458. as early as possible, so do this NOW, and then
  459. they should work immediately thereafter.
  460. */
  461. kernel_end = callback_init(kernel_end);
  462. /*
  463. * Locate the command line.
  464. */
  465. /* Hack for Jensen... since we're restricted to 8 or 16 chars for
  466. boot flags depending on the boot mode, we need some shorthand.
  467. This should do for installation. */
  468. if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
  469. strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
  470. } else {
  471. strlcpy(command_line, COMMAND_LINE, sizeof command_line);
  472. }
  473. strcpy(saved_command_line, command_line);
  474. *cmdline_p = command_line;
  475. /*
  476. * Process command-line arguments.
  477. */
  478. while ((p = strsep(&args, " \t")) != NULL) {
  479. if (!*p) continue;
  480. if (strncmp(p, "alpha_mv=", 9) == 0) {
  481. vec = get_sysvec_byname(p+9);
  482. continue;
  483. }
  484. if (strncmp(p, "cycle=", 6) == 0) {
  485. est_cycle_freq = simple_strtol(p+6, NULL, 0);
  486. continue;
  487. }
  488. if (strncmp(p, "mem=", 4) == 0) {
  489. mem_size_limit = get_mem_size_limit(p+4);
  490. continue;
  491. }
  492. if (strncmp(p, "srmcons", 7) == 0) {
  493. srmcons_output |= 1;
  494. continue;
  495. }
  496. if (strncmp(p, "console=srm", 11) == 0) {
  497. srmcons_output |= 2;
  498. continue;
  499. }
  500. if (strncmp(p, "gartsize=", 9) == 0) {
  501. alpha_agpgart_size =
  502. get_mem_size_limit(p+9) << PAGE_SHIFT;
  503. continue;
  504. }
  505. #ifdef CONFIG_VERBOSE_MCHECK
  506. if (strncmp(p, "verbose_mcheck=", 15) == 0) {
  507. alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
  508. continue;
  509. }
  510. #endif
  511. }
  512. /* Replace the command line, now that we've killed it with strsep. */
  513. strcpy(command_line, saved_command_line);
  514. /* If we want SRM console printk echoing early, do it now. */
  515. if (alpha_using_srm && srmcons_output) {
  516. register_srm_console();
  517. /*
  518. * If "console=srm" was specified, clear the srmcons_output
  519. * flag now so that time.c won't unregister_srm_console
  520. */
  521. if (srmcons_output & 2)
  522. srmcons_output = 0;
  523. }
  524. #ifdef CONFIG_MAGIC_SYSRQ
  525. /* If we're using SRM, make sysrq-b halt back to the prom,
  526. not auto-reboot. */
  527. if (alpha_using_srm) {
  528. struct sysrq_key_op *op = __sysrq_get_key_op('b');
  529. op->handler = (void *) machine_halt;
  530. }
  531. #endif
  532. /*
  533. * Identify and reconfigure for the current system.
  534. */
  535. cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
  536. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  537. cpu->type, &type_name, &var_name);
  538. if (*var_name == '0')
  539. var_name = "";
  540. if (!vec) {
  541. vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
  542. cpu->type);
  543. }
  544. if (!vec) {
  545. panic("Unsupported system type: %s%s%s (%ld %ld)\n",
  546. type_name, (*var_name ? " variation " : ""), var_name,
  547. hwrpb->sys_type, hwrpb->sys_variation);
  548. }
  549. if (vec != &alpha_mv) {
  550. alpha_mv = *vec;
  551. }
  552. printk("Booting "
  553. #ifdef CONFIG_ALPHA_GENERIC
  554. "GENERIC "
  555. #endif
  556. "on %s%s%s using machine vector %s from %s\n",
  557. type_name, (*var_name ? " variation " : ""),
  558. var_name, alpha_mv.vector_name,
  559. (alpha_using_srm ? "SRM" : "MILO"));
  560. printk("Major Options: "
  561. #ifdef CONFIG_SMP
  562. "SMP "
  563. #endif
  564. #ifdef CONFIG_ALPHA_EV56
  565. "EV56 "
  566. #endif
  567. #ifdef CONFIG_ALPHA_EV67
  568. "EV67 "
  569. #endif
  570. #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
  571. "LEGACY_START "
  572. #endif
  573. #ifdef CONFIG_VERBOSE_MCHECK
  574. "VERBOSE_MCHECK "
  575. #endif
  576. #ifdef CONFIG_DISCONTIGMEM
  577. "DISCONTIGMEM "
  578. #ifdef CONFIG_NUMA
  579. "NUMA "
  580. #endif
  581. #endif
  582. #ifdef CONFIG_DEBUG_SPINLOCK
  583. "DEBUG_SPINLOCK "
  584. #endif
  585. #ifdef CONFIG_MAGIC_SYSRQ
  586. "MAGIC_SYSRQ "
  587. #endif
  588. "\n");
  589. printk("Command line: %s\n", command_line);
  590. /*
  591. * Sync up the HAE.
  592. * Save the SRM's current value for restoration.
  593. */
  594. srm_hae = *alpha_mv.hae_register;
  595. __set_hae(alpha_mv.hae_cache);
  596. /* Reset enable correctable error reports. */
  597. wrmces(0x7);
  598. /* Find our memory. */
  599. setup_memory(kernel_end);
  600. /* First guess at cpu cache sizes. Do this before init_arch. */
  601. determine_cpu_caches(cpu->type);
  602. /* Initialize the machine. Usually has to do with setting up
  603. DMA windows and the like. */
  604. if (alpha_mv.init_arch)
  605. alpha_mv.init_arch();
  606. /* Reserve standard resources. */
  607. reserve_std_resources();
  608. /*
  609. * Give us a default console. TGA users will see nothing until
  610. * chr_dev_init is called, rather late in the boot sequence.
  611. */
  612. #ifdef CONFIG_VT
  613. #if defined(CONFIG_VGA_CONSOLE)
  614. conswitchp = &vga_con;
  615. #elif defined(CONFIG_DUMMY_CONSOLE)
  616. conswitchp = &dummy_con;
  617. #endif
  618. #endif
  619. /* Default root filesystem to sda2. */
  620. ROOT_DEV = Root_SDA2;
  621. #ifdef CONFIG_EISA
  622. /* FIXME: only set this when we actually have EISA in this box? */
  623. EISA_bus = 1;
  624. #endif
  625. /*
  626. * Check ASN in HWRPB for validity, report if bad.
  627. * FIXME: how was this failing? Should we trust it instead,
  628. * and copy the value into alpha_mv.max_asn?
  629. */
  630. if (hwrpb->max_asn != MAX_ASN) {
  631. printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
  632. }
  633. /*
  634. * Identify the flock of penguins.
  635. */
  636. #ifdef CONFIG_SMP
  637. setup_smp();
  638. #endif
  639. paging_init();
  640. }
  641. void __init
  642. disable_early_printk(void)
  643. {
  644. if (alpha_using_srm && srmcons_output) {
  645. unregister_srm_console();
  646. srmcons_output = 0;
  647. }
  648. }
  649. static char sys_unknown[] = "Unknown";
  650. static char systype_names[][16] = {
  651. "0",
  652. "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
  653. "Pelican", "Morgan", "Sable", "Medulla", "Noname",
  654. "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
  655. "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
  656. "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
  657. "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
  658. "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
  659. };
  660. static char unofficial_names[][8] = {"100", "Ruffian"};
  661. static char api_names[][16] = {"200", "Nautilus"};
  662. static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
  663. static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
  664. static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
  665. static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
  666. static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
  667. static int eb64p_indices[] = {0,0,1,2};
  668. static char eb66_names[][8] = {"EB66", "EB66+"};
  669. static int eb66_indices[] = {0,0,1};
  670. static char marvel_names[][16] = {
  671. "Marvel/EV7"
  672. };
  673. static int marvel_indices[] = { 0 };
  674. static char rawhide_names[][16] = {
  675. "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
  676. };
  677. static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
  678. static char titan_names[][16] = {
  679. "DEFAULT", "Privateer", "Falcon", "Granite"
  680. };
  681. static int titan_indices[] = {0,1,2,2,3};
  682. static char tsunami_names[][16] = {
  683. "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
  684. "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
  685. "Flying Clipper", "Shark"
  686. };
  687. static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
  688. static struct alpha_machine_vector * __init
  689. get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
  690. {
  691. static struct alpha_machine_vector *systype_vecs[] __initdata =
  692. {
  693. NULL, /* 0 */
  694. NULL, /* ADU */
  695. NULL, /* Cobra */
  696. NULL, /* Ruby */
  697. NULL, /* Flamingo */
  698. NULL, /* Mannequin */
  699. &jensen_mv,
  700. NULL, /* Pelican */
  701. NULL, /* Morgan */
  702. NULL, /* Sable -- see below. */
  703. NULL, /* Medulla */
  704. &noname_mv,
  705. NULL, /* Turbolaser */
  706. &avanti_mv,
  707. NULL, /* Mustang */
  708. NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
  709. NULL, /* Tradewind */
  710. NULL, /* Mikasa -- see below. */
  711. NULL, /* EB64 */
  712. NULL, /* EB66 -- see variation. */
  713. NULL, /* EB64+ -- see variation. */
  714. &alphabook1_mv,
  715. &rawhide_mv,
  716. NULL, /* K2 */
  717. &lynx_mv, /* Lynx */
  718. &xl_mv,
  719. NULL, /* EB164 -- see variation. */
  720. NULL, /* Noritake -- see below. */
  721. NULL, /* Cortex */
  722. NULL, /* 29 */
  723. &miata_mv,
  724. NULL, /* XXM */
  725. &takara_mv,
  726. NULL, /* Yukon */
  727. NULL, /* Tsunami -- see variation. */
  728. &wildfire_mv, /* Wildfire */
  729. NULL, /* CUSCO */
  730. &eiger_mv, /* Eiger */
  731. NULL, /* Titan */
  732. NULL, /* Marvel */
  733. };
  734. static struct alpha_machine_vector *unofficial_vecs[] __initdata =
  735. {
  736. NULL, /* 100 */
  737. &ruffian_mv,
  738. };
  739. static struct alpha_machine_vector *api_vecs[] __initdata =
  740. {
  741. NULL, /* 200 */
  742. &nautilus_mv,
  743. };
  744. static struct alpha_machine_vector *alcor_vecs[] __initdata =
  745. {
  746. &alcor_mv, &xlt_mv, &xlt_mv
  747. };
  748. static struct alpha_machine_vector *eb164_vecs[] __initdata =
  749. {
  750. &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
  751. };
  752. static struct alpha_machine_vector *eb64p_vecs[] __initdata =
  753. {
  754. &eb64p_mv,
  755. &cabriolet_mv,
  756. &cabriolet_mv /* AlphaPCI64 */
  757. };
  758. static struct alpha_machine_vector *eb66_vecs[] __initdata =
  759. {
  760. &eb66_mv,
  761. &eb66p_mv
  762. };
  763. static struct alpha_machine_vector *marvel_vecs[] __initdata =
  764. {
  765. &marvel_ev7_mv,
  766. };
  767. static struct alpha_machine_vector *titan_vecs[] __initdata =
  768. {
  769. &titan_mv, /* default */
  770. &privateer_mv, /* privateer */
  771. &titan_mv, /* falcon */
  772. &privateer_mv, /* granite */
  773. };
  774. static struct alpha_machine_vector *tsunami_vecs[] __initdata =
  775. {
  776. NULL,
  777. &dp264_mv, /* dp264 */
  778. &dp264_mv, /* warhol */
  779. &dp264_mv, /* windjammer */
  780. &monet_mv, /* monet */
  781. &clipper_mv, /* clipper */
  782. &dp264_mv, /* goldrush */
  783. &webbrick_mv, /* webbrick */
  784. &dp264_mv, /* catamaran */
  785. NULL, /* brisbane? */
  786. NULL, /* melbourne? */
  787. NULL, /* flying clipper? */
  788. &shark_mv, /* shark */
  789. };
  790. /* ??? Do we need to distinguish between Rawhides? */
  791. struct alpha_machine_vector *vec;
  792. /* Search the system tables first... */
  793. vec = NULL;
  794. if (type < ARRAY_SIZE(systype_vecs)) {
  795. vec = systype_vecs[type];
  796. } else if ((type > ST_API_BIAS) &&
  797. (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
  798. vec = api_vecs[type - ST_API_BIAS];
  799. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  800. (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
  801. vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
  802. }
  803. /* If we've not found one, try for a variation. */
  804. if (!vec) {
  805. /* Member ID is a bit-field. */
  806. unsigned long member = (variation >> 10) & 0x3f;
  807. cpu &= 0xffffffff; /* make it usable */
  808. switch (type) {
  809. case ST_DEC_ALCOR:
  810. if (member < ARRAY_SIZE(alcor_indices))
  811. vec = alcor_vecs[alcor_indices[member]];
  812. break;
  813. case ST_DEC_EB164:
  814. if (member < ARRAY_SIZE(eb164_indices))
  815. vec = eb164_vecs[eb164_indices[member]];
  816. /* PC164 may show as EB164 variation with EV56 CPU,
  817. but, since no true EB164 had anything but EV5... */
  818. if (vec == &eb164_mv && cpu == EV56_CPU)
  819. vec = &pc164_mv;
  820. break;
  821. case ST_DEC_EB64P:
  822. if (member < ARRAY_SIZE(eb64p_indices))
  823. vec = eb64p_vecs[eb64p_indices[member]];
  824. break;
  825. case ST_DEC_EB66:
  826. if (member < ARRAY_SIZE(eb66_indices))
  827. vec = eb66_vecs[eb66_indices[member]];
  828. break;
  829. case ST_DEC_MARVEL:
  830. if (member < ARRAY_SIZE(marvel_indices))
  831. vec = marvel_vecs[marvel_indices[member]];
  832. break;
  833. case ST_DEC_TITAN:
  834. vec = titan_vecs[0]; /* default */
  835. if (member < ARRAY_SIZE(titan_indices))
  836. vec = titan_vecs[titan_indices[member]];
  837. break;
  838. case ST_DEC_TSUNAMI:
  839. if (member < ARRAY_SIZE(tsunami_indices))
  840. vec = tsunami_vecs[tsunami_indices[member]];
  841. break;
  842. case ST_DEC_1000:
  843. if (cpu == EV5_CPU || cpu == EV56_CPU)
  844. vec = &mikasa_primo_mv;
  845. else
  846. vec = &mikasa_mv;
  847. break;
  848. case ST_DEC_NORITAKE:
  849. if (cpu == EV5_CPU || cpu == EV56_CPU)
  850. vec = &noritake_primo_mv;
  851. else
  852. vec = &noritake_mv;
  853. break;
  854. case ST_DEC_2100_A500:
  855. if (cpu == EV5_CPU || cpu == EV56_CPU)
  856. vec = &sable_gamma_mv;
  857. else
  858. vec = &sable_mv;
  859. break;
  860. }
  861. }
  862. return vec;
  863. }
  864. static struct alpha_machine_vector * __init
  865. get_sysvec_byname(const char *name)
  866. {
  867. static struct alpha_machine_vector *all_vecs[] __initdata =
  868. {
  869. &alcor_mv,
  870. &alphabook1_mv,
  871. &avanti_mv,
  872. &cabriolet_mv,
  873. &clipper_mv,
  874. &dp264_mv,
  875. &eb164_mv,
  876. &eb64p_mv,
  877. &eb66_mv,
  878. &eb66p_mv,
  879. &eiger_mv,
  880. &jensen_mv,
  881. &lx164_mv,
  882. &lynx_mv,
  883. &miata_mv,
  884. &mikasa_mv,
  885. &mikasa_primo_mv,
  886. &monet_mv,
  887. &nautilus_mv,
  888. &noname_mv,
  889. &noritake_mv,
  890. &noritake_primo_mv,
  891. &p2k_mv,
  892. &pc164_mv,
  893. &privateer_mv,
  894. &rawhide_mv,
  895. &ruffian_mv,
  896. &rx164_mv,
  897. &sable_mv,
  898. &sable_gamma_mv,
  899. &shark_mv,
  900. &sx164_mv,
  901. &takara_mv,
  902. &webbrick_mv,
  903. &wildfire_mv,
  904. &xl_mv,
  905. &xlt_mv
  906. };
  907. size_t i;
  908. for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
  909. struct alpha_machine_vector *mv = all_vecs[i];
  910. if (strcasecmp(mv->vector_name, name) == 0)
  911. return mv;
  912. }
  913. return NULL;
  914. }
  915. static void
  916. get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
  917. char **type_name, char **variation_name)
  918. {
  919. unsigned long member;
  920. /* If not in the tables, make it UNKNOWN,
  921. else set type name to family */
  922. if (type < ARRAY_SIZE(systype_names)) {
  923. *type_name = systype_names[type];
  924. } else if ((type > ST_API_BIAS) &&
  925. (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
  926. *type_name = api_names[type - ST_API_BIAS];
  927. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  928. (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
  929. *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
  930. } else {
  931. *type_name = sys_unknown;
  932. *variation_name = sys_unknown;
  933. return;
  934. }
  935. /* Set variation to "0"; if variation is zero, done. */
  936. *variation_name = systype_names[0];
  937. if (variation == 0) {
  938. return;
  939. }
  940. member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
  941. cpu &= 0xffffffff; /* make it usable */
  942. switch (type) { /* select by family */
  943. default: /* default to variation "0" for now */
  944. break;
  945. case ST_DEC_EB164:
  946. if (member < ARRAY_SIZE(eb164_indices))
  947. *variation_name = eb164_names[eb164_indices[member]];
  948. /* PC164 may show as EB164 variation, but with EV56 CPU,
  949. so, since no true EB164 had anything but EV5... */
  950. if (eb164_indices[member] == 0 && cpu == EV56_CPU)
  951. *variation_name = eb164_names[1]; /* make it PC164 */
  952. break;
  953. case ST_DEC_ALCOR:
  954. if (member < ARRAY_SIZE(alcor_indices))
  955. *variation_name = alcor_names[alcor_indices[member]];
  956. break;
  957. case ST_DEC_EB64P:
  958. if (member < ARRAY_SIZE(eb64p_indices))
  959. *variation_name = eb64p_names[eb64p_indices[member]];
  960. break;
  961. case ST_DEC_EB66:
  962. if (member < ARRAY_SIZE(eb66_indices))
  963. *variation_name = eb66_names[eb66_indices[member]];
  964. break;
  965. case ST_DEC_MARVEL:
  966. if (member < ARRAY_SIZE(marvel_indices))
  967. *variation_name = marvel_names[marvel_indices[member]];
  968. break;
  969. case ST_DEC_RAWHIDE:
  970. if (member < ARRAY_SIZE(rawhide_indices))
  971. *variation_name = rawhide_names[rawhide_indices[member]];
  972. break;
  973. case ST_DEC_TITAN:
  974. *variation_name = titan_names[0]; /* default */
  975. if (member < ARRAY_SIZE(titan_indices))
  976. *variation_name = titan_names[titan_indices[member]];
  977. break;
  978. case ST_DEC_TSUNAMI:
  979. if (member < ARRAY_SIZE(tsunami_indices))
  980. *variation_name = tsunami_names[tsunami_indices[member]];
  981. break;
  982. }
  983. }
  984. /*
  985. * A change was made to the HWRPB via an ECO and the following code
  986. * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
  987. * was not implemented in the console firmware. If it's revision 5 or
  988. * greater we can get the name of the platform as an ASCII string from
  989. * the HWRPB. That's what this function does. It checks the revision
  990. * level and if the string is in the HWRPB it returns the address of
  991. * the string--a pointer to the name of the platform.
  992. *
  993. * Returns:
  994. * - Pointer to a ASCII string if it's in the HWRPB
  995. * - Pointer to a blank string if the data is not in the HWRPB.
  996. */
  997. static char *
  998. platform_string(void)
  999. {
  1000. struct dsr_struct *dsr;
  1001. static char unk_system_string[] = "N/A";
  1002. /* Go to the console for the string pointer.
  1003. * If the rpb_vers is not 5 or greater the rpb
  1004. * is old and does not have this data in it.
  1005. */
  1006. if (hwrpb->revision < 5)
  1007. return (unk_system_string);
  1008. else {
  1009. /* The Dynamic System Recognition struct
  1010. * has the system platform name starting
  1011. * after the character count of the string.
  1012. */
  1013. dsr = ((struct dsr_struct *)
  1014. ((char *)hwrpb + hwrpb->dsr_offset));
  1015. return ((char *)dsr + (dsr->sysname_off +
  1016. sizeof(long)));
  1017. }
  1018. }
  1019. static int
  1020. get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
  1021. {
  1022. struct percpu_struct *cpu;
  1023. unsigned long i;
  1024. int count = 0;
  1025. for (i = 0; i < num; i++) {
  1026. cpu = (struct percpu_struct *)
  1027. ((char *)cpubase + i*hwrpb->processor_size);
  1028. if ((cpu->flags & 0x1cc) == 0x1cc)
  1029. count++;
  1030. }
  1031. return count;
  1032. }
  1033. static void
  1034. show_cache_size (struct seq_file *f, const char *which, int shape)
  1035. {
  1036. if (shape == -1)
  1037. seq_printf (f, "%s\t\t: n/a\n", which);
  1038. else if (shape == 0)
  1039. seq_printf (f, "%s\t\t: unknown\n", which);
  1040. else
  1041. seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
  1042. which, shape >> 10, shape & 15,
  1043. 1 << ((shape >> 4) & 15));
  1044. }
  1045. static int
  1046. show_cpuinfo(struct seq_file *f, void *slot)
  1047. {
  1048. extern struct unaligned_stat {
  1049. unsigned long count, va, pc;
  1050. } unaligned[2];
  1051. static char cpu_names[][8] = {
  1052. "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
  1053. "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
  1054. "EV68CX", "EV7", "EV79", "EV69"
  1055. };
  1056. struct percpu_struct *cpu = slot;
  1057. unsigned int cpu_index;
  1058. char *cpu_name;
  1059. char *systype_name;
  1060. char *sysvariation_name;
  1061. int nr_processors;
  1062. cpu_index = (unsigned) (cpu->type - 1);
  1063. cpu_name = "Unknown";
  1064. if (cpu_index < ARRAY_SIZE(cpu_names))
  1065. cpu_name = cpu_names[cpu_index];
  1066. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  1067. cpu->type, &systype_name, &sysvariation_name);
  1068. nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
  1069. seq_printf(f, "cpu\t\t\t: Alpha\n"
  1070. "cpu model\t\t: %s\n"
  1071. "cpu variation\t\t: %ld\n"
  1072. "cpu revision\t\t: %ld\n"
  1073. "cpu serial number\t: %s\n"
  1074. "system type\t\t: %s\n"
  1075. "system variation\t: %s\n"
  1076. "system revision\t\t: %ld\n"
  1077. "system serial number\t: %s\n"
  1078. "cycle frequency [Hz]\t: %lu %s\n"
  1079. "timer frequency [Hz]\t: %lu.%02lu\n"
  1080. "page size [bytes]\t: %ld\n"
  1081. "phys. address bits\t: %ld\n"
  1082. "max. addr. space #\t: %ld\n"
  1083. "BogoMIPS\t\t: %lu.%02lu\n"
  1084. "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1085. "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1086. "platform string\t\t: %s\n"
  1087. "cpus detected\t\t: %d\n",
  1088. cpu_name, cpu->variation, cpu->revision,
  1089. (char*)cpu->serial_no,
  1090. systype_name, sysvariation_name, hwrpb->sys_revision,
  1091. (char*)hwrpb->ssn,
  1092. est_cycle_freq ? : hwrpb->cycle_freq,
  1093. est_cycle_freq ? "est." : "",
  1094. hwrpb->intr_freq / 4096,
  1095. (100 * hwrpb->intr_freq / 4096) % 100,
  1096. hwrpb->pagesize,
  1097. hwrpb->pa_bits,
  1098. hwrpb->max_asn,
  1099. loops_per_jiffy / (500000/HZ),
  1100. (loops_per_jiffy / (5000/HZ)) % 100,
  1101. unaligned[0].count, unaligned[0].pc, unaligned[0].va,
  1102. unaligned[1].count, unaligned[1].pc, unaligned[1].va,
  1103. platform_string(), nr_processors);
  1104. #ifdef CONFIG_SMP
  1105. seq_printf(f, "cpus active\t\t: %d\n"
  1106. "cpu active mask\t\t: %016lx\n",
  1107. num_online_cpus(), cpus_addr(cpu_possible_map)[0]);
  1108. #endif
  1109. show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
  1110. show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
  1111. show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
  1112. show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
  1113. return 0;
  1114. }
  1115. static int __init
  1116. read_mem_block(int *addr, int stride, int size)
  1117. {
  1118. long nloads = size / stride, cnt, tmp;
  1119. __asm__ __volatile__(
  1120. " rpcc %0\n"
  1121. "1: ldl %3,0(%2)\n"
  1122. " subq %1,1,%1\n"
  1123. /* Next two XORs introduce an explicit data dependency between
  1124. consecutive loads in the loop, which will give us true load
  1125. latency. */
  1126. " xor %3,%2,%2\n"
  1127. " xor %3,%2,%2\n"
  1128. " addq %2,%4,%2\n"
  1129. " bne %1,1b\n"
  1130. " rpcc %3\n"
  1131. " subl %3,%0,%0\n"
  1132. : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
  1133. : "r" (stride), "1" (nloads), "2" (addr));
  1134. return cnt / (size / stride);
  1135. }
  1136. #define CSHAPE(totalsize, linesize, assoc) \
  1137. ((totalsize & ~0xff) | (linesize << 4) | assoc)
  1138. /* ??? EV5 supports up to 64M, but did the systems with more than
  1139. 16M of BCACHE ever exist? */
  1140. #define MAX_BCACHE_SIZE 16*1024*1024
  1141. /* Note that the offchip caches are direct mapped on all Alphas. */
  1142. static int __init
  1143. external_cache_probe(int minsize, int width)
  1144. {
  1145. int cycles, prev_cycles = 1000000;
  1146. int stride = 1 << width;
  1147. long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
  1148. if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
  1149. maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
  1150. /* Get the first block cached. */
  1151. read_mem_block(__va(0), stride, size);
  1152. while (size < maxsize) {
  1153. /* Get an average load latency in cycles. */
  1154. cycles = read_mem_block(__va(0), stride, size);
  1155. if (cycles > prev_cycles * 2) {
  1156. /* Fine, we exceed the cache. */
  1157. printk("%ldK Bcache detected; load hit latency %d "
  1158. "cycles, load miss latency %d cycles\n",
  1159. size >> 11, prev_cycles, cycles);
  1160. return CSHAPE(size >> 1, width, 1);
  1161. }
  1162. /* Try to get the next block cached. */
  1163. read_mem_block(__va(size), stride, size);
  1164. prev_cycles = cycles;
  1165. size <<= 1;
  1166. }
  1167. return -1; /* No BCACHE found. */
  1168. }
  1169. static void __init
  1170. determine_cpu_caches (unsigned int cpu_type)
  1171. {
  1172. int L1I, L1D, L2, L3;
  1173. switch (cpu_type) {
  1174. case EV4_CPU:
  1175. case EV45_CPU:
  1176. {
  1177. if (cpu_type == EV4_CPU)
  1178. L1I = CSHAPE(8*1024, 5, 1);
  1179. else
  1180. L1I = CSHAPE(16*1024, 5, 1);
  1181. L1D = L1I;
  1182. L3 = -1;
  1183. /* BIU_CTL is a write-only Abox register. PALcode has a
  1184. shadow copy, and may be available from some versions
  1185. of the CSERVE PALcall. If we can get it, then
  1186. unsigned long biu_ctl, size;
  1187. size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
  1188. L2 = CSHAPE (size, 5, 1);
  1189. Unfortunately, we can't rely on that.
  1190. */
  1191. L2 = external_cache_probe(128*1024, 5);
  1192. break;
  1193. }
  1194. case LCA4_CPU:
  1195. {
  1196. unsigned long car, size;
  1197. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1198. L3 = -1;
  1199. car = *(vuip) phys_to_virt (0x120000078UL);
  1200. size = 64*1024 * (1 << ((car >> 5) & 7));
  1201. /* No typo -- 8 byte cacheline size. Whodathunk. */
  1202. L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
  1203. break;
  1204. }
  1205. case EV5_CPU:
  1206. case EV56_CPU:
  1207. {
  1208. unsigned long sc_ctl, width;
  1209. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1210. /* Check the line size of the Scache. */
  1211. sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
  1212. width = sc_ctl & 0x1000 ? 6 : 5;
  1213. L2 = CSHAPE (96*1024, width, 3);
  1214. /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
  1215. has a shadow copy, and may be available from some versions
  1216. of the CSERVE PALcall. If we can get it, then
  1217. unsigned long bc_control, bc_config, size;
  1218. size = 1024*1024 * (1 << ((bc_config & 7) - 1));
  1219. L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
  1220. Unfortunately, we can't rely on that.
  1221. */
  1222. L3 = external_cache_probe(1024*1024, width);
  1223. break;
  1224. }
  1225. case PCA56_CPU:
  1226. case PCA57_CPU:
  1227. {
  1228. unsigned long cbox_config, size;
  1229. if (cpu_type == PCA56_CPU) {
  1230. L1I = CSHAPE(16*1024, 6, 1);
  1231. L1D = CSHAPE(8*1024, 5, 1);
  1232. } else {
  1233. L1I = CSHAPE(32*1024, 6, 2);
  1234. L1D = CSHAPE(16*1024, 5, 1);
  1235. }
  1236. L3 = -1;
  1237. cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
  1238. size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
  1239. #if 0
  1240. L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
  1241. #else
  1242. L2 = external_cache_probe(512*1024, 6);
  1243. #endif
  1244. break;
  1245. }
  1246. case EV6_CPU:
  1247. case EV67_CPU:
  1248. case EV68CB_CPU:
  1249. case EV68AL_CPU:
  1250. case EV68CX_CPU:
  1251. case EV69_CPU:
  1252. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1253. L2 = external_cache_probe(1024*1024, 6);
  1254. L3 = -1;
  1255. break;
  1256. case EV7_CPU:
  1257. case EV79_CPU:
  1258. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1259. L2 = CSHAPE(7*1024*1024/4, 6, 7);
  1260. L3 = -1;
  1261. break;
  1262. default:
  1263. /* Nothing known about this cpu type. */
  1264. L1I = L1D = L2 = L3 = 0;
  1265. break;
  1266. }
  1267. alpha_l1i_cacheshape = L1I;
  1268. alpha_l1d_cacheshape = L1D;
  1269. alpha_l2_cacheshape = L2;
  1270. alpha_l3_cacheshape = L3;
  1271. }
  1272. /*
  1273. * We show only CPU #0 info.
  1274. */
  1275. static void *
  1276. c_start(struct seq_file *f, loff_t *pos)
  1277. {
  1278. return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
  1279. }
  1280. static void *
  1281. c_next(struct seq_file *f, void *v, loff_t *pos)
  1282. {
  1283. return NULL;
  1284. }
  1285. static void
  1286. c_stop(struct seq_file *f, void *v)
  1287. {
  1288. }
  1289. struct seq_operations cpuinfo_op = {
  1290. .start = c_start,
  1291. .next = c_next,
  1292. .stop = c_stop,
  1293. .show = show_cpuinfo,
  1294. };
  1295. static int
  1296. alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
  1297. {
  1298. #if 1
  1299. /* FIXME FIXME FIXME */
  1300. /* If we are using SRM and serial console, just hard halt here. */
  1301. if (alpha_using_srm && srmcons_output)
  1302. __halt();
  1303. #endif
  1304. return NOTIFY_DONE;
  1305. }
  1306. static __init int add_pcspkr(void)
  1307. {
  1308. struct platform_device *pd;
  1309. int ret;
  1310. pd = platform_device_alloc("pcspkr", -1);
  1311. if (!pd)
  1312. return -ENOMEM;
  1313. ret = platform_device_add(pd);
  1314. if (ret)
  1315. platform_device_put(pd);
  1316. return ret;
  1317. }
  1318. device_initcall(add_pcspkr);