setup.c 37 KB

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