setup.c 37 KB

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