setup.c 35 KB

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