1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/alpha/kernel/setup.c
5 * Copyright (C) 1995 Linus Torvalds
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
17 #include <linux/stddef.h>
18 #include <linux/unistd.h>
19 #include <linux/ptrace.h>
20 #include <linux/slab.h>
21 #include <linux/user.h>
22 #include <linux/screen_info.h>
23 #include <linux/delay.h>
24 #include <linux/mc146818rtc.h>
25 #include <linux/console.h>
26 #include <linux/cpu.h>
27 #include <linux/errno.h>
28 #include <linux/init.h>
29 #include <linux/string.h>
30 #include <linux/ioport.h>
31 #include <linux/panic_notifier.h>
32 #include <linux/platform_device.h>
33 #include <linux/memblock.h>
34 #include <linux/pci.h>
35 #include <linux/seq_file.h>
36 #include <linux/root_dev.h>
37 #include <linux/initrd.h>
38 #include <linux/eisa.h>
39 #include <linux/pfn.h>
40 #ifdef CONFIG_MAGIC_SYSRQ
41 #include <linux/sysrq.h>
42 #include <linux/reboot.h>
44 #include <linux/notifier.h>
45 #include <asm/setup.h>
47 #include <linux/log2.h>
48 #include <linux/export.h>
50 static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
51 static struct notifier_block alpha_panic_block = {
54 INT_MAX /* try to do it first */
57 #include <linux/uaccess.h>
58 #include <asm/hwrpb.h>
60 #include <asm/mmu_context.h>
61 #include <asm/console.h>
67 struct hwrpb_struct *hwrpb;
69 unsigned long srm_hae;
71 int alpha_l1i_cacheshape;
72 int alpha_l1d_cacheshape;
73 int alpha_l2_cacheshape;
74 int alpha_l3_cacheshape;
76 #ifdef CONFIG_VERBOSE_MCHECK
77 /* 0=minimum, 1=verbose, 2=all */
78 /* These can be overridden via the command line, ie "verbose_mcheck=2") */
79 unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
82 /* Which processor we booted from. */
86 * Using SRM callbacks for initial console output. This works from
87 * setup_arch() time through the end of time_init(), as those places
88 * are under our (Alpha) control.
90 * "srmcons" specified in the boot command arguments allows us to
91 * see kernel messages during the period of time before the true
92 * console device is "registered" during console_init().
93 * As of this version (2.5.59), console_init() will call
94 * disable_early_printk() as the last action before initializing
95 * the console drivers. That's the last possible time srmcons can be
96 * unregistered without interfering with console behavior.
98 * By default, OFF; set it with a bootcommand arg of "srmcons" or
99 * "console=srm". The meaning of these two args is:
100 * "srmcons" - early callback prints
101 * "console=srm" - full callback based console, including early prints
103 int srmcons_output = 0;
105 /* Enforce a memory size limit; useful for testing. By default, none. */
106 unsigned long mem_size_limit = 0;
108 /* Set AGP GART window size (0 means disabled). */
109 unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
111 #ifdef CONFIG_ALPHA_GENERIC
112 struct alpha_machine_vector alpha_mv;
113 EXPORT_SYMBOL(alpha_mv);
116 #ifndef alpha_using_srm
118 EXPORT_SYMBOL(alpha_using_srm);
121 #ifndef alpha_using_qemu
122 int alpha_using_qemu;
125 static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
127 static struct alpha_machine_vector *get_sysvec_byname(const char *);
128 static void get_sysnames(unsigned long, unsigned long, unsigned long,
130 static void determine_cpu_caches (unsigned int);
132 static char __initdata command_line[COMMAND_LINE_SIZE];
135 * The format of "screen_info" is strange, and due to early
136 * i386-setup code. This is just enough to make the console
137 * code think we're on a VGA color display.
140 struct screen_info screen_info = {
143 .orig_video_cols = 80,
144 .orig_video_lines = 25,
145 .orig_video_isVGA = 1,
146 .orig_video_points = 16
149 EXPORT_SYMBOL(screen_info);
152 * The direct map I/O window, if any. This should be the same
153 * for all busses, since it's used by virt_to_bus.
156 unsigned long __direct_map_base;
157 unsigned long __direct_map_size;
158 EXPORT_SYMBOL(__direct_map_base);
159 EXPORT_SYMBOL(__direct_map_size);
162 * Declare all of the machine vectors.
165 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
166 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
170 extern struct alpha_machine_vector X; \
190 WEAK(mikasa_primo_mv);
195 WEAK(noritake_primo_mv);
203 WEAK(sable_gamma_mv);
216 * I/O resources inherited from PeeCees. Except for perhaps the
217 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
219 * ??? If this becomes less standard, move the struct out into the
224 reserve_std_resources(void)
226 static struct resource standard_io_resources[] = {
227 { .name = "rtc", .start = -1, .end = -1 },
228 { .name = "dma1", .start = 0x00, .end = 0x1f },
229 { .name = "pic1", .start = 0x20, .end = 0x3f },
230 { .name = "timer", .start = 0x40, .end = 0x5f },
231 { .name = "keyboard", .start = 0x60, .end = 0x6f },
232 { .name = "dma page reg", .start = 0x80, .end = 0x8f },
233 { .name = "pic2", .start = 0xa0, .end = 0xbf },
234 { .name = "dma2", .start = 0xc0, .end = 0xdf },
237 struct resource *io = &ioport_resource;
241 struct pci_controller *hose;
242 for (hose = hose_head; hose; hose = hose->next)
243 if (hose->index == 0) {
249 /* Fix up for the Jensen's queer RTC placement. */
250 standard_io_resources[0].start = RTC_PORT(0);
251 standard_io_resources[0].end = RTC_PORT(0) + 0x0f;
253 for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i)
254 request_resource(io, standard_io_resources+i);
257 #define PFN_MAX PFN_DOWN(0x80000000)
258 #define for_each_mem_cluster(memdesc, _cluster, i) \
259 for ((_cluster) = (memdesc)->cluster, (i) = 0; \
260 (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
262 static unsigned long __init
263 get_mem_size_limit(char *s)
265 unsigned long end = 0;
268 end = simple_strtoul(from, &from, 0);
269 if ( *from == 'K' || *from == 'k' ) {
272 } else if ( *from == 'M' || *from == 'm' ) {
275 } else if ( *from == 'G' || *from == 'g' ) {
279 return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
282 #ifdef CONFIG_BLK_DEV_INITRD
284 move_initrd(unsigned long mem_limit)
289 size = initrd_end - initrd_start;
290 start = memblock_alloc(PAGE_ALIGN(size), PAGE_SIZE);
291 if (!start || __pa(start) + size > mem_limit) {
292 initrd_start = initrd_end = 0;
295 memmove(start, (void *)initrd_start, size);
296 initrd_start = (unsigned long)start;
297 initrd_end = initrd_start + size;
298 printk("initrd moved to %p\n", start);
304 setup_memory(void *kernel_end)
306 struct memclust_struct * cluster;
307 struct memdesc_struct * memdesc;
308 unsigned long kernel_size;
311 /* Find free clusters, and init and free the bootmem accordingly. */
312 memdesc = (struct memdesc_struct *)
313 (hwrpb->mddt_offset + (unsigned long) hwrpb);
315 for_each_mem_cluster(memdesc, cluster, i) {
318 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
319 i, cluster->usage, cluster->start_pfn,
320 cluster->start_pfn + cluster->numpages);
322 end = cluster->start_pfn + cluster->numpages;
323 if (end > max_low_pfn)
326 memblock_add(PFN_PHYS(cluster->start_pfn),
327 cluster->numpages << PAGE_SHIFT);
329 /* Bit 0 is console/PALcode reserved. Bit 1 is
330 non-volatile memory -- we might want to mark
332 if (cluster->usage & 3)
333 memblock_reserve(PFN_PHYS(cluster->start_pfn),
334 cluster->numpages << PAGE_SHIFT);
338 * Except for the NUMA systems (wildfire, marvel) all of the
339 * Alpha systems we run on support 32GB of memory or less.
340 * Since the NUMA systems introduce large holes in memory addressing,
341 * we can get into a situation where there is not enough contiguous
342 * memory for the memory map.
344 * Limit memory to the first 32GB to limit the NUMA systems to
345 * memory on their first node (wildfire) or 2 (marvel) to avoid
346 * not being able to produce the memory map. In order to access
347 * all of the memory on the NUMA systems, build with discontiguous
350 * If the user specified a memory limit, let that memory limit stand.
353 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
355 if (mem_size_limit && max_low_pfn >= mem_size_limit)
357 printk("setup: forcing memory size to %ldK (from %ldK).\n",
358 mem_size_limit << (PAGE_SHIFT - 10),
359 max_low_pfn << (PAGE_SHIFT - 10));
360 max_low_pfn = mem_size_limit;
363 /* Reserve the kernel memory. */
364 kernel_size = virt_to_phys(kernel_end) - KERNEL_START_PHYS;
365 memblock_reserve(KERNEL_START_PHYS, kernel_size);
367 #ifdef CONFIG_BLK_DEV_INITRD
368 initrd_start = INITRD_START;
370 initrd_end = initrd_start+INITRD_SIZE;
371 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
372 (void *) initrd_start, INITRD_SIZE);
374 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
375 if (!move_initrd(PFN_PHYS(max_low_pfn)))
376 printk("initrd extends beyond end of memory "
377 "(0x%08lx > 0x%p)\ndisabling initrd\n",
379 phys_to_virt(PFN_PHYS(max_low_pfn)));
381 memblock_reserve(virt_to_phys((void *)initrd_start),
385 #endif /* CONFIG_BLK_DEV_INITRD */
389 page_is_ram(unsigned long pfn)
391 struct memclust_struct * cluster;
392 struct memdesc_struct * memdesc;
395 memdesc = (struct memdesc_struct *)
396 (hwrpb->mddt_offset + (unsigned long) hwrpb);
397 for_each_mem_cluster(memdesc, cluster, i)
399 if (pfn >= cluster->start_pfn &&
400 pfn < cluster->start_pfn + cluster->numpages) {
401 return (cluster->usage & 3) ? 0 : 1;
413 for_each_possible_cpu(i) {
414 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
422 arch_initcall(register_cpus);
424 #ifdef CONFIG_MAGIC_SYSRQ
425 static void sysrq_reboot_handler(int unused)
430 static const struct sysrq_key_op srm_sysrq_reboot_op = {
431 .handler = sysrq_reboot_handler,
432 .help_msg = "reboot(b)",
433 .action_msg = "Resetting",
434 .enable_mask = SYSRQ_ENABLE_BOOT,
439 setup_arch(char **cmdline_p)
443 struct alpha_machine_vector *vec = NULL;
444 struct percpu_struct *cpu;
445 char *type_name, *var_name, *p;
446 void *kernel_end = _end; /* end of kernel */
447 char *args = command_line;
449 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
450 boot_cpuid = hard_smp_processor_id();
453 * Pre-process the system type to make sure it will be valid.
455 * This may restore real CABRIO and EB66+ family names, ie
458 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
459 * and AS1200 (DIGITAL Server 5000 series) have the type as
460 * the negative of the real one.
462 if ((long)hwrpb->sys_type < 0) {
463 hwrpb->sys_type = -((long)hwrpb->sys_type);
464 hwrpb_update_checksum(hwrpb);
467 /* Register a call for panic conditions. */
468 atomic_notifier_chain_register(&panic_notifier_list,
471 #ifndef alpha_using_srm
472 /* Assume that we've booted from SRM if we haven't booted from MILO.
473 Detect the later by looking for "MILO" in the system serial nr. */
474 alpha_using_srm = !str_has_prefix((const char *)hwrpb->ssn, "MILO");
476 #ifndef alpha_using_qemu
477 /* Similarly, look for QEMU. */
478 alpha_using_qemu = strstr((const char *)hwrpb->ssn, "QEMU") != 0;
481 /* If we are using SRM, we want to allow callbacks
482 as early as possible, so do this NOW, and then
483 they should work immediately thereafter.
485 kernel_end = callback_init(kernel_end);
488 * Locate the command line.
490 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
491 boot flags depending on the boot mode, we need some shorthand.
492 This should do for installation. */
493 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
494 strscpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof(command_line));
496 strscpy(command_line, COMMAND_LINE, sizeof(command_line));
498 strcpy(boot_command_line, command_line);
499 *cmdline_p = command_line;
502 * Process command-line arguments.
504 while ((p = strsep(&args, " \t")) != NULL) {
506 if (strncmp(p, "alpha_mv=", 9) == 0) {
507 vec = get_sysvec_byname(p+9);
510 if (strncmp(p, "cycle=", 6) == 0) {
511 est_cycle_freq = simple_strtol(p+6, NULL, 0);
514 if (strncmp(p, "mem=", 4) == 0) {
515 mem_size_limit = get_mem_size_limit(p+4);
518 if (strncmp(p, "srmcons", 7) == 0) {
522 if (strncmp(p, "console=srm", 11) == 0) {
526 if (strncmp(p, "gartsize=", 9) == 0) {
528 get_mem_size_limit(p+9) << PAGE_SHIFT;
531 #ifdef CONFIG_VERBOSE_MCHECK
532 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
533 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
539 /* Replace the command line, now that we've killed it with strsep. */
540 strcpy(command_line, boot_command_line);
542 /* If we want SRM console printk echoing early, do it now. */
543 if (alpha_using_srm && srmcons_output) {
544 register_srm_console();
547 * If "console=srm" was specified, clear the srmcons_output
548 * flag now so that time.c won't unregister_srm_console
550 if (srmcons_output & 2)
554 #ifdef CONFIG_MAGIC_SYSRQ
555 /* If we're using SRM, make sysrq-b halt back to the prom,
557 if (alpha_using_srm) {
558 unregister_sysrq_key('b', __sysrq_reboot_op);
559 register_sysrq_key('b', &srm_sysrq_reboot_op);
564 * Identify and reconfigure for the current system.
566 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
568 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
569 cpu->type, &type_name, &var_name);
570 if (*var_name == '0')
574 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
579 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
580 type_name, (*var_name ? " variation " : ""), var_name,
581 hwrpb->sys_type, hwrpb->sys_variation);
583 if (vec != &alpha_mv) {
588 #ifdef CONFIG_ALPHA_GENERIC
591 "on %s%s%s using machine vector %s from %s\n",
592 type_name, (*var_name ? " variation " : ""),
593 var_name, alpha_mv.vector_name,
594 (alpha_using_srm ? "SRM" : "MILO"));
596 printk("Major Options: "
600 #ifdef CONFIG_ALPHA_EV56
603 #ifdef CONFIG_ALPHA_EV67
606 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
609 #ifdef CONFIG_VERBOSE_MCHECK
613 #ifdef CONFIG_DEBUG_SPINLOCK
616 #ifdef CONFIG_MAGIC_SYSRQ
621 printk("Command line: %s\n", command_line);
625 * Save the SRM's current value for restoration.
627 srm_hae = *alpha_mv.hae_register;
628 __set_hae(alpha_mv.hae_cache);
630 /* Reset enable correctable error reports. */
633 /* Find our memory. */
634 setup_memory(kernel_end);
635 memblock_set_bottom_up(true);
638 /* First guess at cpu cache sizes. Do this before init_arch. */
639 determine_cpu_caches(cpu->type);
641 /* Initialize the machine. Usually has to do with setting up
642 DMA windows and the like. */
643 if (alpha_mv.init_arch)
644 alpha_mv.init_arch();
646 /* Reserve standard resources. */
647 reserve_std_resources();
650 * Give us a default console. TGA users will see nothing until
651 * chr_dev_init is called, rather late in the boot sequence.
655 #if defined(CONFIG_VGA_CONSOLE)
656 conswitchp = &vga_con;
660 /* Default root filesystem to sda2. */
661 ROOT_DEV = Root_SDA2;
664 /* FIXME: only set this when we actually have EISA in this box? */
669 * Check ASN in HWRPB for validity, report if bad.
670 * FIXME: how was this failing? Should we trust it instead,
671 * and copy the value into alpha_mv.max_asn?
674 if (hwrpb->max_asn != MAX_ASN) {
675 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
679 * Identify the flock of penguins.
688 static char sys_unknown[] = "Unknown";
689 static char systype_names[][16] = {
691 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
692 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
693 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
694 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
695 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
696 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
697 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
700 static char unofficial_names[][8] = {"100", "Ruffian"};
702 static char api_names[][16] = {"200", "Nautilus"};
704 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
705 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
707 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
708 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
710 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
711 static int eb64p_indices[] = {0,0,1,2};
713 static char eb66_names[][8] = {"EB66", "EB66+"};
714 static int eb66_indices[] = {0,0,1};
716 static char marvel_names[][16] = {
719 static int marvel_indices[] = { 0 };
721 static char rawhide_names[][16] = {
722 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
724 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
726 static char titan_names[][16] = {
727 "DEFAULT", "Privateer", "Falcon", "Granite"
729 static int titan_indices[] = {0,1,2,2,3};
731 static char tsunami_names[][16] = {
732 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
733 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
734 "Flying Clipper", "Shark"
736 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
738 static struct alpha_machine_vector * __init
739 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
741 static struct alpha_machine_vector *systype_vecs[] __initdata =
748 NULL, /* Mannequin */
752 NULL, /* Sable -- see below. */
755 NULL, /* Turbolaser */
758 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
759 NULL, /* Tradewind */
760 NULL, /* Mikasa -- see below. */
762 NULL, /* EB66 -- see variation. */
763 NULL, /* EB64+ -- see variation. */
769 NULL, /* EB164 -- see variation. */
770 NULL, /* Noritake -- see below. */
777 NULL, /* Tsunami -- see variation. */
778 &wildfire_mv, /* Wildfire */
780 &eiger_mv, /* Eiger */
785 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
791 static struct alpha_machine_vector *api_vecs[] __initdata =
797 static struct alpha_machine_vector *alcor_vecs[] __initdata =
799 &alcor_mv, &xlt_mv, &xlt_mv
802 static struct alpha_machine_vector *eb164_vecs[] __initdata =
804 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
807 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
811 &cabriolet_mv /* AlphaPCI64 */
814 static struct alpha_machine_vector *eb66_vecs[] __initdata =
820 static struct alpha_machine_vector *marvel_vecs[] __initdata =
825 static struct alpha_machine_vector *titan_vecs[] __initdata =
827 &titan_mv, /* default */
828 &privateer_mv, /* privateer */
829 &titan_mv, /* falcon */
830 &privateer_mv, /* granite */
833 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
836 &dp264_mv, /* dp264 */
837 &dp264_mv, /* warhol */
838 &dp264_mv, /* windjammer */
839 &monet_mv, /* monet */
840 &clipper_mv, /* clipper */
841 &dp264_mv, /* goldrush */
842 &webbrick_mv, /* webbrick */
843 &dp264_mv, /* catamaran */
844 NULL, /* brisbane? */
845 NULL, /* melbourne? */
846 NULL, /* flying clipper? */
847 &shark_mv, /* shark */
850 /* ??? Do we need to distinguish between Rawhides? */
852 struct alpha_machine_vector *vec;
854 /* Search the system tables first... */
856 if (type < ARRAY_SIZE(systype_vecs)) {
857 vec = systype_vecs[type];
858 } else if ((type > ST_API_BIAS) &&
859 (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
860 vec = api_vecs[type - ST_API_BIAS];
861 } else if ((type > ST_UNOFFICIAL_BIAS) &&
862 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
863 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
866 /* If we've not found one, try for a variation. */
869 /* Member ID is a bit-field. */
870 unsigned long member = (variation >> 10) & 0x3f;
872 cpu &= 0xffffffff; /* make it usable */
876 if (member < ARRAY_SIZE(alcor_indices))
877 vec = alcor_vecs[alcor_indices[member]];
880 if (member < ARRAY_SIZE(eb164_indices))
881 vec = eb164_vecs[eb164_indices[member]];
882 /* PC164 may show as EB164 variation with EV56 CPU,
883 but, since no true EB164 had anything but EV5... */
884 if (vec == &eb164_mv && cpu == EV56_CPU)
888 if (member < ARRAY_SIZE(eb64p_indices))
889 vec = eb64p_vecs[eb64p_indices[member]];
892 if (member < ARRAY_SIZE(eb66_indices))
893 vec = eb66_vecs[eb66_indices[member]];
896 if (member < ARRAY_SIZE(marvel_indices))
897 vec = marvel_vecs[marvel_indices[member]];
900 vec = titan_vecs[0]; /* default */
901 if (member < ARRAY_SIZE(titan_indices))
902 vec = titan_vecs[titan_indices[member]];
905 if (member < ARRAY_SIZE(tsunami_indices))
906 vec = tsunami_vecs[tsunami_indices[member]];
909 if (cpu == EV5_CPU || cpu == EV56_CPU)
910 vec = &mikasa_primo_mv;
914 case ST_DEC_NORITAKE:
915 if (cpu == EV5_CPU || cpu == EV56_CPU)
916 vec = &noritake_primo_mv;
920 case ST_DEC_2100_A500:
921 if (cpu == EV5_CPU || cpu == EV56_CPU)
922 vec = &sable_gamma_mv;
931 static struct alpha_machine_vector * __init
932 get_sysvec_byname(const char *name)
934 static struct alpha_machine_vector *all_vecs[] __initdata =
977 for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
978 struct alpha_machine_vector *mv = all_vecs[i];
979 if (strcasecmp(mv->vector_name, name) == 0)
986 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
987 char **type_name, char **variation_name)
989 unsigned long member;
991 /* If not in the tables, make it UNKNOWN,
992 else set type name to family */
993 if (type < ARRAY_SIZE(systype_names)) {
994 *type_name = systype_names[type];
995 } else if ((type > ST_API_BIAS) &&
996 (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
997 *type_name = api_names[type - ST_API_BIAS];
998 } else if ((type > ST_UNOFFICIAL_BIAS) &&
999 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
1000 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1002 *type_name = sys_unknown;
1003 *variation_name = sys_unknown;
1007 /* Set variation to "0"; if variation is zero, done. */
1008 *variation_name = systype_names[0];
1009 if (variation == 0) {
1013 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1015 cpu &= 0xffffffff; /* make it usable */
1017 switch (type) { /* select by family */
1018 default: /* default to variation "0" for now */
1021 if (member >= ARRAY_SIZE(eb164_indices))
1023 *variation_name = eb164_names[eb164_indices[member]];
1024 /* PC164 may show as EB164 variation, but with EV56 CPU,
1025 so, since no true EB164 had anything but EV5... */
1026 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1027 *variation_name = eb164_names[1]; /* make it PC164 */
1030 if (member < ARRAY_SIZE(alcor_indices))
1031 *variation_name = alcor_names[alcor_indices[member]];
1034 if (member < ARRAY_SIZE(eb64p_indices))
1035 *variation_name = eb64p_names[eb64p_indices[member]];
1038 if (member < ARRAY_SIZE(eb66_indices))
1039 *variation_name = eb66_names[eb66_indices[member]];
1042 if (member < ARRAY_SIZE(marvel_indices))
1043 *variation_name = marvel_names[marvel_indices[member]];
1045 case ST_DEC_RAWHIDE:
1046 if (member < ARRAY_SIZE(rawhide_indices))
1047 *variation_name = rawhide_names[rawhide_indices[member]];
1050 *variation_name = titan_names[0]; /* default */
1051 if (member < ARRAY_SIZE(titan_indices))
1052 *variation_name = titan_names[titan_indices[member]];
1054 case ST_DEC_TSUNAMI:
1055 if (member < ARRAY_SIZE(tsunami_indices))
1056 *variation_name = tsunami_names[tsunami_indices[member]];
1062 * A change was made to the HWRPB via an ECO and the following code
1063 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1064 * was not implemented in the console firmware. If it's revision 5 or
1065 * greater we can get the name of the platform as an ASCII string from
1066 * the HWRPB. That's what this function does. It checks the revision
1067 * level and if the string is in the HWRPB it returns the address of
1068 * the string--a pointer to the name of the platform.
1071 * - Pointer to a ASCII string if it's in the HWRPB
1072 * - Pointer to a blank string if the data is not in the HWRPB.
1076 platform_string(void)
1078 struct dsr_struct *dsr;
1079 static char unk_system_string[] = "N/A";
1081 /* Go to the console for the string pointer.
1082 * If the rpb_vers is not 5 or greater the rpb
1083 * is old and does not have this data in it.
1085 if (hwrpb->revision < 5)
1086 return (unk_system_string);
1088 /* The Dynamic System Recognition struct
1089 * has the system platform name starting
1090 * after the character count of the string.
1092 dsr = ((struct dsr_struct *)
1093 ((char *)hwrpb + hwrpb->dsr_offset));
1094 return ((char *)dsr + (dsr->sysname_off +
1100 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1102 struct percpu_struct *cpu;
1106 for (i = 0; i < num; i++) {
1107 cpu = (struct percpu_struct *)
1108 ((char *)cpubase + i*hwrpb->processor_size);
1109 if ((cpu->flags & 0x1cc) == 0x1cc)
1116 show_cache_size (struct seq_file *f, const char *which, int shape)
1119 seq_printf (f, "%s\t\t: n/a\n", which);
1120 else if (shape == 0)
1121 seq_printf (f, "%s\t\t: unknown\n", which);
1123 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1124 which, shape >> 10, shape & 15,
1125 1 << ((shape >> 4) & 15));
1129 show_cpuinfo(struct seq_file *f, void *slot)
1131 extern struct unaligned_stat {
1132 unsigned long count, va, pc;
1135 static char cpu_names[][8] = {
1136 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1137 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1138 "EV68CX", "EV7", "EV79", "EV69"
1141 struct percpu_struct *cpu = slot;
1142 unsigned int cpu_index;
1145 char *sysvariation_name;
1147 unsigned long timer_freq;
1149 cpu_index = (unsigned) (cpu->type - 1);
1150 cpu_name = "Unknown";
1151 if (cpu_index < ARRAY_SIZE(cpu_names))
1152 cpu_name = cpu_names[cpu_index];
1154 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1155 cpu->type, &systype_name, &sysvariation_name);
1157 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1159 #if CONFIG_HZ == 1024 || CONFIG_HZ == 1200
1160 timer_freq = (100UL * hwrpb->intr_freq) / 4096;
1162 timer_freq = 100UL * CONFIG_HZ;
1165 seq_printf(f, "cpu\t\t\t: Alpha\n"
1166 "cpu model\t\t: %s\n"
1167 "cpu variation\t\t: %ld\n"
1168 "cpu revision\t\t: %ld\n"
1169 "cpu serial number\t: %s\n"
1170 "system type\t\t: %s\n"
1171 "system variation\t: %s\n"
1172 "system revision\t\t: %ld\n"
1173 "system serial number\t: %s\n"
1174 "cycle frequency [Hz]\t: %lu %s\n"
1175 "timer frequency [Hz]\t: %lu.%02lu\n"
1176 "page size [bytes]\t: %ld\n"
1177 "phys. address bits\t: %ld\n"
1178 "max. addr. space #\t: %ld\n"
1179 "BogoMIPS\t\t: %lu.%02lu\n"
1180 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1181 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1182 "platform string\t\t: %s\n"
1183 "cpus detected\t\t: %d\n",
1184 cpu_name, cpu->variation, cpu->revision,
1185 (char*)cpu->serial_no,
1186 systype_name, sysvariation_name, hwrpb->sys_revision,
1188 est_cycle_freq ? : hwrpb->cycle_freq,
1189 est_cycle_freq ? "est." : "",
1190 timer_freq / 100, timer_freq % 100,
1194 loops_per_jiffy / (500000/HZ),
1195 (loops_per_jiffy / (5000/HZ)) % 100,
1196 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1197 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1198 platform_string(), nr_processors);
1201 seq_printf(f, "cpus active\t\t: %u\n"
1202 "cpu active mask\t\t: %016lx\n",
1203 num_online_cpus(), cpumask_bits(cpu_possible_mask)[0]);
1206 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1207 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1208 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1209 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1215 read_mem_block(int *addr, int stride, int size)
1217 long nloads = size / stride, cnt, tmp;
1219 __asm__ __volatile__(
1223 /* Next two XORs introduce an explicit data dependency between
1224 consecutive loads in the loop, which will give us true load
1232 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1233 : "r" (stride), "1" (nloads), "2" (addr));
1235 return cnt / (size / stride);
1238 #define CSHAPE(totalsize, linesize, assoc) \
1239 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1241 /* ??? EV5 supports up to 64M, but did the systems with more than
1242 16M of BCACHE ever exist? */
1243 #define MAX_BCACHE_SIZE 16*1024*1024
1245 /* Note that the offchip caches are direct mapped on all Alphas. */
1247 external_cache_probe(int minsize, int width)
1249 int cycles, prev_cycles = 1000000;
1250 int stride = 1 << width;
1251 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1253 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1254 maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
1256 /* Get the first block cached. */
1257 read_mem_block(__va(0), stride, size);
1259 while (size < maxsize) {
1260 /* Get an average load latency in cycles. */
1261 cycles = read_mem_block(__va(0), stride, size);
1262 if (cycles > prev_cycles * 2) {
1263 /* Fine, we exceed the cache. */
1264 printk("%ldK Bcache detected; load hit latency %d "
1265 "cycles, load miss latency %d cycles\n",
1266 size >> 11, prev_cycles, cycles);
1267 return CSHAPE(size >> 1, width, 1);
1269 /* Try to get the next block cached. */
1270 read_mem_block(__va(size), stride, size);
1271 prev_cycles = cycles;
1274 return -1; /* No BCACHE found. */
1278 determine_cpu_caches (unsigned int cpu_type)
1280 int L1I, L1D, L2, L3;
1286 if (cpu_type == EV4_CPU)
1287 L1I = CSHAPE(8*1024, 5, 1);
1289 L1I = CSHAPE(16*1024, 5, 1);
1293 /* BIU_CTL is a write-only Abox register. PALcode has a
1294 shadow copy, and may be available from some versions
1295 of the CSERVE PALcall. If we can get it, then
1297 unsigned long biu_ctl, size;
1298 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1299 L2 = CSHAPE (size, 5, 1);
1301 Unfortunately, we can't rely on that.
1303 L2 = external_cache_probe(128*1024, 5);
1309 unsigned long car, size;
1311 L1I = L1D = CSHAPE(8*1024, 5, 1);
1314 car = *(vuip) phys_to_virt (0x120000078UL);
1315 size = 64*1024 * (1 << ((car >> 5) & 7));
1316 /* No typo -- 8 byte cacheline size. Whodathunk. */
1317 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1324 unsigned long sc_ctl, width;
1326 L1I = L1D = CSHAPE(8*1024, 5, 1);
1328 /* Check the line size of the Scache. */
1329 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1330 width = sc_ctl & 0x1000 ? 6 : 5;
1331 L2 = CSHAPE (96*1024, width, 3);
1333 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1334 has a shadow copy, and may be available from some versions
1335 of the CSERVE PALcall. If we can get it, then
1337 unsigned long bc_control, bc_config, size;
1338 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1339 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1341 Unfortunately, we can't rely on that.
1343 L3 = external_cache_probe(1024*1024, width);
1350 if (cpu_type == PCA56_CPU) {
1351 L1I = CSHAPE(16*1024, 6, 1);
1352 L1D = CSHAPE(8*1024, 5, 1);
1354 L1I = CSHAPE(32*1024, 6, 2);
1355 L1D = CSHAPE(16*1024, 5, 1);
1360 unsigned long cbox_config, size;
1362 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1363 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1365 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1367 L2 = external_cache_probe(512*1024, 6);
1378 L1I = L1D = CSHAPE(64*1024, 6, 2);
1379 L2 = external_cache_probe(1024*1024, 6);
1385 L1I = L1D = CSHAPE(64*1024, 6, 2);
1386 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1391 /* Nothing known about this cpu type. */
1392 L1I = L1D = L2 = L3 = 0;
1396 alpha_l1i_cacheshape = L1I;
1397 alpha_l1d_cacheshape = L1D;
1398 alpha_l2_cacheshape = L2;
1399 alpha_l3_cacheshape = L3;
1403 * We show only CPU #0 info.
1406 c_start(struct seq_file *f, loff_t *pos)
1408 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1412 c_next(struct seq_file *f, void *v, loff_t *pos)
1419 c_stop(struct seq_file *f, void *v)
1423 const struct seq_operations cpuinfo_op = {
1427 .show = show_cpuinfo,
1432 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1435 /* FIXME FIXME FIXME */
1436 /* If we are using SRM and serial console, just hard halt here. */
1437 if (alpha_using_srm && srmcons_output)
1443 static __init int add_pcspkr(void)
1445 struct platform_device *pd;
1448 pd = platform_device_alloc("pcspkr", -1);
1452 ret = platform_device_add(pd);
1454 platform_device_put(pd);
1458 device_initcall(add_pcspkr);