1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/alpha/kernel/setup.c
5 * Copyright (C) 1995 Linus Torvalds
8 /* 2.3.x bootmem, 1999 Andrea Arcangeli <andrea@suse.de> */
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/platform_device.h>
32 #include <linux/memblock.h>
33 #include <linux/pci.h>
34 #include <linux/seq_file.h>
35 #include <linux/root_dev.h>
36 #include <linux/initrd.h>
37 #include <linux/eisa.h>
38 #include <linux/pfn.h>
39 #ifdef CONFIG_MAGIC_SYSRQ
40 #include <linux/sysrq.h>
41 #include <linux/reboot.h>
43 #include <linux/notifier.h>
44 #include <asm/setup.h>
46 #include <linux/log2.h>
47 #include <linux/export.h>
49 extern struct atomic_notifier_head panic_notifier_list;
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;
83 struct cpumask node_to_cpumask_map[MAX_NUMNODES] __read_mostly;
84 EXPORT_SYMBOL(node_to_cpumask_map);
87 /* Which processor we booted from. */
91 * Using SRM callbacks for initial console output. This works from
92 * setup_arch() time through the end of time_init(), as those places
93 * are under our (Alpha) control.
95 * "srmcons" specified in the boot command arguments allows us to
96 * see kernel messages during the period of time before the true
97 * console device is "registered" during console_init().
98 * As of this version (2.5.59), console_init() will call
99 * disable_early_printk() as the last action before initializing
100 * the console drivers. That's the last possible time srmcons can be
101 * unregistered without interfering with console behavior.
103 * By default, OFF; set it with a bootcommand arg of "srmcons" or
104 * "console=srm". The meaning of these two args is:
105 * "srmcons" - early callback prints
106 * "console=srm" - full callback based console, including early prints
108 int srmcons_output = 0;
110 /* Enforce a memory size limit; useful for testing. By default, none. */
111 unsigned long mem_size_limit = 0;
113 /* Set AGP GART window size (0 means disabled). */
114 unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
116 #ifdef CONFIG_ALPHA_GENERIC
117 struct alpha_machine_vector alpha_mv;
118 EXPORT_SYMBOL(alpha_mv);
121 #ifndef alpha_using_srm
123 EXPORT_SYMBOL(alpha_using_srm);
126 #ifndef alpha_using_qemu
127 int alpha_using_qemu;
130 static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
132 static struct alpha_machine_vector *get_sysvec_byname(const char *);
133 static void get_sysnames(unsigned long, unsigned long, unsigned long,
135 static void determine_cpu_caches (unsigned int);
137 static char __initdata command_line[COMMAND_LINE_SIZE];
140 * The format of "screen_info" is strange, and due to early
141 * i386-setup code. This is just enough to make the console
142 * code think we're on a VGA color display.
145 struct screen_info screen_info = {
148 .orig_video_cols = 80,
149 .orig_video_lines = 25,
150 .orig_video_isVGA = 1,
151 .orig_video_points = 16
154 EXPORT_SYMBOL(screen_info);
157 * The direct map I/O window, if any. This should be the same
158 * for all busses, since it's used by virt_to_bus.
161 unsigned long __direct_map_base;
162 unsigned long __direct_map_size;
163 EXPORT_SYMBOL(__direct_map_base);
164 EXPORT_SYMBOL(__direct_map_size);
167 * Declare all of the machine vectors.
170 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
171 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
175 extern struct alpha_machine_vector X; \
195 WEAK(mikasa_primo_mv);
200 WEAK(noritake_primo_mv);
208 WEAK(sable_gamma_mv);
221 * I/O resources inherited from PeeCees. Except for perhaps the
222 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
224 * ??? If this becomes less standard, move the struct out into the
229 reserve_std_resources(void)
231 static struct resource standard_io_resources[] = {
232 { .name = "rtc", .start = -1, .end = -1 },
233 { .name = "dma1", .start = 0x00, .end = 0x1f },
234 { .name = "pic1", .start = 0x20, .end = 0x3f },
235 { .name = "timer", .start = 0x40, .end = 0x5f },
236 { .name = "keyboard", .start = 0x60, .end = 0x6f },
237 { .name = "dma page reg", .start = 0x80, .end = 0x8f },
238 { .name = "pic2", .start = 0xa0, .end = 0xbf },
239 { .name = "dma2", .start = 0xc0, .end = 0xdf },
242 struct resource *io = &ioport_resource;
246 struct pci_controller *hose;
247 for (hose = hose_head; hose; hose = hose->next)
248 if (hose->index == 0) {
254 /* Fix up for the Jensen's queer RTC placement. */
255 standard_io_resources[0].start = RTC_PORT(0);
256 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
258 for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i)
259 request_resource(io, standard_io_resources+i);
262 #define PFN_MAX PFN_DOWN(0x80000000)
263 #define for_each_mem_cluster(memdesc, _cluster, i) \
264 for ((_cluster) = (memdesc)->cluster, (i) = 0; \
265 (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
267 static unsigned long __init
268 get_mem_size_limit(char *s)
270 unsigned long end = 0;
273 end = simple_strtoul(from, &from, 0);
274 if ( *from == 'K' || *from == 'k' ) {
277 } else if ( *from == 'M' || *from == 'm' ) {
280 } else if ( *from == 'G' || *from == 'g' ) {
284 return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
287 #ifdef CONFIG_BLK_DEV_INITRD
289 move_initrd(unsigned long mem_limit)
294 size = initrd_end - initrd_start;
295 start = memblock_alloc(PAGE_ALIGN(size), PAGE_SIZE);
296 if (!start || __pa(start) + size > mem_limit) {
297 initrd_start = initrd_end = 0;
300 memmove(start, (void *)initrd_start, size);
301 initrd_start = (unsigned long)start;
302 initrd_end = initrd_start + size;
303 printk("initrd moved to %p\n", start);
308 #ifndef CONFIG_DISCONTIGMEM
310 setup_memory(void *kernel_end)
312 struct memclust_struct * cluster;
313 struct memdesc_struct * memdesc;
314 unsigned long kernel_size;
317 /* Find free clusters, and init and free the bootmem accordingly. */
318 memdesc = (struct memdesc_struct *)
319 (hwrpb->mddt_offset + (unsigned long) hwrpb);
321 for_each_mem_cluster(memdesc, cluster, i) {
324 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
325 i, cluster->usage, cluster->start_pfn,
326 cluster->start_pfn + cluster->numpages);
328 /* Bit 0 is console/PALcode reserved. Bit 1 is
329 non-volatile memory -- we might want to mark
331 if (cluster->usage & 3)
334 end = cluster->start_pfn + cluster->numpages;
335 if (end > max_low_pfn)
338 memblock_add(PFN_PHYS(cluster->start_pfn),
339 cluster->numpages << PAGE_SHIFT);
343 * Except for the NUMA systems (wildfire, marvel) all of the
344 * Alpha systems we run on support 32GB of memory or less.
345 * Since the NUMA systems introduce large holes in memory addressing,
346 * we can get into a situation where there is not enough contiguous
347 * memory for the memory map.
349 * Limit memory to the first 32GB to limit the NUMA systems to
350 * memory on their first node (wildfire) or 2 (marvel) to avoid
351 * not being able to produce the memory map. In order to access
352 * all of the memory on the NUMA systems, build with discontiguous
355 * If the user specified a memory limit, let that memory limit stand.
358 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
360 if (mem_size_limit && max_low_pfn >= mem_size_limit)
362 printk("setup: forcing memory size to %ldK (from %ldK).\n",
363 mem_size_limit << (PAGE_SHIFT - 10),
364 max_low_pfn << (PAGE_SHIFT - 10));
365 max_low_pfn = mem_size_limit;
368 /* Reserve the kernel memory. */
369 kernel_size = virt_to_phys(kernel_end) - KERNEL_START_PHYS;
370 memblock_reserve(KERNEL_START_PHYS, kernel_size);
372 #ifdef CONFIG_BLK_DEV_INITRD
373 initrd_start = INITRD_START;
375 initrd_end = initrd_start+INITRD_SIZE;
376 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
377 (void *) initrd_start, INITRD_SIZE);
379 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
380 if (!move_initrd(PFN_PHYS(max_low_pfn)))
381 printk("initrd extends beyond end of memory "
382 "(0x%08lx > 0x%p)\ndisabling initrd\n",
384 phys_to_virt(PFN_PHYS(max_low_pfn)));
386 memblock_reserve(virt_to_phys((void *)initrd_start),
390 #endif /* CONFIG_BLK_DEV_INITRD */
393 extern void setup_memory(void *);
394 #endif /* !CONFIG_DISCONTIGMEM */
397 page_is_ram(unsigned long pfn)
399 struct memclust_struct * cluster;
400 struct memdesc_struct * memdesc;
403 memdesc = (struct memdesc_struct *)
404 (hwrpb->mddt_offset + (unsigned long) hwrpb);
405 for_each_mem_cluster(memdesc, cluster, i)
407 if (pfn >= cluster->start_pfn &&
408 pfn < cluster->start_pfn + cluster->numpages) {
409 return (cluster->usage & 3) ? 0 : 1;
421 for_each_possible_cpu(i) {
422 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
430 arch_initcall(register_cpus);
432 #ifdef CONFIG_MAGIC_SYSRQ
433 static const struct sysrq_key_op srm_sysrq_reboot_op = {
434 .handler = machine_halt,
435 .help_msg = "reboot(b)",
436 .action_msg = "Resetting",
437 .enable_mask = SYSRQ_ENABLE_BOOT,
442 setup_arch(char **cmdline_p)
446 struct alpha_machine_vector *vec = NULL;
447 struct percpu_struct *cpu;
448 char *type_name, *var_name, *p;
449 void *kernel_end = _end; /* end of kernel */
450 char *args = command_line;
452 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
453 boot_cpuid = hard_smp_processor_id();
456 * Pre-process the system type to make sure it will be valid.
458 * This may restore real CABRIO and EB66+ family names, ie
461 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
462 * and AS1200 (DIGITAL Server 5000 series) have the type as
463 * the negative of the real one.
465 if ((long)hwrpb->sys_type < 0) {
466 hwrpb->sys_type = -((long)hwrpb->sys_type);
467 hwrpb_update_checksum(hwrpb);
470 /* Register a call for panic conditions. */
471 atomic_notifier_chain_register(&panic_notifier_list,
474 #ifndef alpha_using_srm
475 /* Assume that we've booted from SRM if we haven't booted from MILO.
476 Detect the later by looking for "MILO" in the system serial nr. */
477 alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
479 #ifndef alpha_using_qemu
480 /* Similarly, look for QEMU. */
481 alpha_using_qemu = strstr((const char *)hwrpb->ssn, "QEMU") != 0;
484 /* If we are using SRM, we want to allow callbacks
485 as early as possible, so do this NOW, and then
486 they should work immediately thereafter.
488 kernel_end = callback_init(kernel_end);
491 * Locate the command line.
493 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
494 boot flags depending on the boot mode, we need some shorthand.
495 This should do for installation. */
496 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
497 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
499 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
501 strcpy(boot_command_line, command_line);
502 *cmdline_p = command_line;
505 * Process command-line arguments.
507 while ((p = strsep(&args, " \t")) != NULL) {
509 if (strncmp(p, "alpha_mv=", 9) == 0) {
510 vec = get_sysvec_byname(p+9);
513 if (strncmp(p, "cycle=", 6) == 0) {
514 est_cycle_freq = simple_strtol(p+6, NULL, 0);
517 if (strncmp(p, "mem=", 4) == 0) {
518 mem_size_limit = get_mem_size_limit(p+4);
521 if (strncmp(p, "srmcons", 7) == 0) {
525 if (strncmp(p, "console=srm", 11) == 0) {
529 if (strncmp(p, "gartsize=", 9) == 0) {
531 get_mem_size_limit(p+9) << PAGE_SHIFT;
534 #ifdef CONFIG_VERBOSE_MCHECK
535 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
536 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
542 /* Replace the command line, now that we've killed it with strsep. */
543 strcpy(command_line, boot_command_line);
545 /* If we want SRM console printk echoing early, do it now. */
546 if (alpha_using_srm && srmcons_output) {
547 register_srm_console();
550 * If "console=srm" was specified, clear the srmcons_output
551 * flag now so that time.c won't unregister_srm_console
553 if (srmcons_output & 2)
557 #ifdef CONFIG_MAGIC_SYSRQ
558 /* If we're using SRM, make sysrq-b halt back to the prom,
560 if (alpha_using_srm) {
561 unregister_sysrq_key('b', __sysrq_reboot_op);
562 register_sysrq_key('b', &srm_sysrq_reboot_op);
567 * Identify and reconfigure for the current system.
569 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
571 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
572 cpu->type, &type_name, &var_name);
573 if (*var_name == '0')
577 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
582 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
583 type_name, (*var_name ? " variation " : ""), var_name,
584 hwrpb->sys_type, hwrpb->sys_variation);
586 if (vec != &alpha_mv) {
591 #ifdef CONFIG_ALPHA_GENERIC
594 "on %s%s%s using machine vector %s from %s\n",
595 type_name, (*var_name ? " variation " : ""),
596 var_name, alpha_mv.vector_name,
597 (alpha_using_srm ? "SRM" : "MILO"));
599 printk("Major Options: "
603 #ifdef CONFIG_ALPHA_EV56
606 #ifdef CONFIG_ALPHA_EV67
609 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
612 #ifdef CONFIG_VERBOSE_MCHECK
616 #ifdef CONFIG_DISCONTIGMEM
623 #ifdef CONFIG_DEBUG_SPINLOCK
626 #ifdef CONFIG_MAGIC_SYSRQ
631 printk("Command line: %s\n", command_line);
635 * Save the SRM's current value for restoration.
637 srm_hae = *alpha_mv.hae_register;
638 __set_hae(alpha_mv.hae_cache);
640 /* Reset enable correctable error reports. */
643 /* Find our memory. */
644 setup_memory(kernel_end);
645 memblock_set_bottom_up(true);
647 /* First guess at cpu cache sizes. Do this before init_arch. */
648 determine_cpu_caches(cpu->type);
650 /* Initialize the machine. Usually has to do with setting up
651 DMA windows and the like. */
652 if (alpha_mv.init_arch)
653 alpha_mv.init_arch();
655 /* Reserve standard resources. */
656 reserve_std_resources();
659 * Give us a default console. TGA users will see nothing until
660 * chr_dev_init is called, rather late in the boot sequence.
664 #if defined(CONFIG_VGA_CONSOLE)
665 conswitchp = &vga_con;
669 /* Default root filesystem to sda2. */
670 ROOT_DEV = Root_SDA2;
673 /* FIXME: only set this when we actually have EISA in this box? */
678 * Check ASN in HWRPB for validity, report if bad.
679 * FIXME: how was this failing? Should we trust it instead,
680 * and copy the value into alpha_mv.max_asn?
683 if (hwrpb->max_asn != MAX_ASN) {
684 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
688 * Identify the flock of penguins.
697 static char sys_unknown[] = "Unknown";
698 static char systype_names[][16] = {
700 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
701 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
702 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
703 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
704 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
705 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
706 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
709 static char unofficial_names[][8] = {"100", "Ruffian"};
711 static char api_names[][16] = {"200", "Nautilus"};
713 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
714 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
716 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
717 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
719 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
720 static int eb64p_indices[] = {0,0,1,2};
722 static char eb66_names[][8] = {"EB66", "EB66+"};
723 static int eb66_indices[] = {0,0,1};
725 static char marvel_names[][16] = {
728 static int marvel_indices[] = { 0 };
730 static char rawhide_names[][16] = {
731 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
733 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
735 static char titan_names[][16] = {
736 "DEFAULT", "Privateer", "Falcon", "Granite"
738 static int titan_indices[] = {0,1,2,2,3};
740 static char tsunami_names[][16] = {
741 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
742 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
743 "Flying Clipper", "Shark"
745 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
747 static struct alpha_machine_vector * __init
748 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
750 static struct alpha_machine_vector *systype_vecs[] __initdata =
757 NULL, /* Mannequin */
761 NULL, /* Sable -- see below. */
764 NULL, /* Turbolaser */
767 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
768 NULL, /* Tradewind */
769 NULL, /* Mikasa -- see below. */
771 NULL, /* EB66 -- see variation. */
772 NULL, /* EB64+ -- see variation. */
778 NULL, /* EB164 -- see variation. */
779 NULL, /* Noritake -- see below. */
786 NULL, /* Tsunami -- see variation. */
787 &wildfire_mv, /* Wildfire */
789 &eiger_mv, /* Eiger */
794 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
800 static struct alpha_machine_vector *api_vecs[] __initdata =
806 static struct alpha_machine_vector *alcor_vecs[] __initdata =
808 &alcor_mv, &xlt_mv, &xlt_mv
811 static struct alpha_machine_vector *eb164_vecs[] __initdata =
813 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
816 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
820 &cabriolet_mv /* AlphaPCI64 */
823 static struct alpha_machine_vector *eb66_vecs[] __initdata =
829 static struct alpha_machine_vector *marvel_vecs[] __initdata =
834 static struct alpha_machine_vector *titan_vecs[] __initdata =
836 &titan_mv, /* default */
837 &privateer_mv, /* privateer */
838 &titan_mv, /* falcon */
839 &privateer_mv, /* granite */
842 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
845 &dp264_mv, /* dp264 */
846 &dp264_mv, /* warhol */
847 &dp264_mv, /* windjammer */
848 &monet_mv, /* monet */
849 &clipper_mv, /* clipper */
850 &dp264_mv, /* goldrush */
851 &webbrick_mv, /* webbrick */
852 &dp264_mv, /* catamaran */
853 NULL, /* brisbane? */
854 NULL, /* melbourne? */
855 NULL, /* flying clipper? */
856 &shark_mv, /* shark */
859 /* ??? Do we need to distinguish between Rawhides? */
861 struct alpha_machine_vector *vec;
863 /* Search the system tables first... */
865 if (type < ARRAY_SIZE(systype_vecs)) {
866 vec = systype_vecs[type];
867 } else if ((type > ST_API_BIAS) &&
868 (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
869 vec = api_vecs[type - ST_API_BIAS];
870 } else if ((type > ST_UNOFFICIAL_BIAS) &&
871 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
872 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
875 /* If we've not found one, try for a variation. */
878 /* Member ID is a bit-field. */
879 unsigned long member = (variation >> 10) & 0x3f;
881 cpu &= 0xffffffff; /* make it usable */
885 if (member < ARRAY_SIZE(alcor_indices))
886 vec = alcor_vecs[alcor_indices[member]];
889 if (member < ARRAY_SIZE(eb164_indices))
890 vec = eb164_vecs[eb164_indices[member]];
891 /* PC164 may show as EB164 variation with EV56 CPU,
892 but, since no true EB164 had anything but EV5... */
893 if (vec == &eb164_mv && cpu == EV56_CPU)
897 if (member < ARRAY_SIZE(eb64p_indices))
898 vec = eb64p_vecs[eb64p_indices[member]];
901 if (member < ARRAY_SIZE(eb66_indices))
902 vec = eb66_vecs[eb66_indices[member]];
905 if (member < ARRAY_SIZE(marvel_indices))
906 vec = marvel_vecs[marvel_indices[member]];
909 vec = titan_vecs[0]; /* default */
910 if (member < ARRAY_SIZE(titan_indices))
911 vec = titan_vecs[titan_indices[member]];
914 if (member < ARRAY_SIZE(tsunami_indices))
915 vec = tsunami_vecs[tsunami_indices[member]];
918 if (cpu == EV5_CPU || cpu == EV56_CPU)
919 vec = &mikasa_primo_mv;
923 case ST_DEC_NORITAKE:
924 if (cpu == EV5_CPU || cpu == EV56_CPU)
925 vec = &noritake_primo_mv;
929 case ST_DEC_2100_A500:
930 if (cpu == EV5_CPU || cpu == EV56_CPU)
931 vec = &sable_gamma_mv;
940 static struct alpha_machine_vector * __init
941 get_sysvec_byname(const char *name)
943 static struct alpha_machine_vector *all_vecs[] __initdata =
986 for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
987 struct alpha_machine_vector *mv = all_vecs[i];
988 if (strcasecmp(mv->vector_name, name) == 0)
995 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
996 char **type_name, char **variation_name)
998 unsigned long member;
1000 /* If not in the tables, make it UNKNOWN,
1001 else set type name to family */
1002 if (type < ARRAY_SIZE(systype_names)) {
1003 *type_name = systype_names[type];
1004 } else if ((type > ST_API_BIAS) &&
1005 (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
1006 *type_name = api_names[type - ST_API_BIAS];
1007 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1008 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
1009 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1011 *type_name = sys_unknown;
1012 *variation_name = sys_unknown;
1016 /* Set variation to "0"; if variation is zero, done. */
1017 *variation_name = systype_names[0];
1018 if (variation == 0) {
1022 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1024 cpu &= 0xffffffff; /* make it usable */
1026 switch (type) { /* select by family */
1027 default: /* default to variation "0" for now */
1030 if (member >= ARRAY_SIZE(eb164_indices))
1032 *variation_name = eb164_names[eb164_indices[member]];
1033 /* PC164 may show as EB164 variation, but with EV56 CPU,
1034 so, since no true EB164 had anything but EV5... */
1035 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1036 *variation_name = eb164_names[1]; /* make it PC164 */
1039 if (member < ARRAY_SIZE(alcor_indices))
1040 *variation_name = alcor_names[alcor_indices[member]];
1043 if (member < ARRAY_SIZE(eb64p_indices))
1044 *variation_name = eb64p_names[eb64p_indices[member]];
1047 if (member < ARRAY_SIZE(eb66_indices))
1048 *variation_name = eb66_names[eb66_indices[member]];
1051 if (member < ARRAY_SIZE(marvel_indices))
1052 *variation_name = marvel_names[marvel_indices[member]];
1054 case ST_DEC_RAWHIDE:
1055 if (member < ARRAY_SIZE(rawhide_indices))
1056 *variation_name = rawhide_names[rawhide_indices[member]];
1059 *variation_name = titan_names[0]; /* default */
1060 if (member < ARRAY_SIZE(titan_indices))
1061 *variation_name = titan_names[titan_indices[member]];
1063 case ST_DEC_TSUNAMI:
1064 if (member < ARRAY_SIZE(tsunami_indices))
1065 *variation_name = tsunami_names[tsunami_indices[member]];
1071 * A change was made to the HWRPB via an ECO and the following code
1072 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1073 * was not implemented in the console firmware. If it's revision 5 or
1074 * greater we can get the name of the platform as an ASCII string from
1075 * the HWRPB. That's what this function does. It checks the revision
1076 * level and if the string is in the HWRPB it returns the address of
1077 * the string--a pointer to the name of the platform.
1080 * - Pointer to a ASCII string if it's in the HWRPB
1081 * - Pointer to a blank string if the data is not in the HWRPB.
1085 platform_string(void)
1087 struct dsr_struct *dsr;
1088 static char unk_system_string[] = "N/A";
1090 /* Go to the console for the string pointer.
1091 * If the rpb_vers is not 5 or greater the rpb
1092 * is old and does not have this data in it.
1094 if (hwrpb->revision < 5)
1095 return (unk_system_string);
1097 /* The Dynamic System Recognition struct
1098 * has the system platform name starting
1099 * after the character count of the string.
1101 dsr = ((struct dsr_struct *)
1102 ((char *)hwrpb + hwrpb->dsr_offset));
1103 return ((char *)dsr + (dsr->sysname_off +
1109 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1111 struct percpu_struct *cpu;
1115 for (i = 0; i < num; i++) {
1116 cpu = (struct percpu_struct *)
1117 ((char *)cpubase + i*hwrpb->processor_size);
1118 if ((cpu->flags & 0x1cc) == 0x1cc)
1125 show_cache_size (struct seq_file *f, const char *which, int shape)
1128 seq_printf (f, "%s\t\t: n/a\n", which);
1129 else if (shape == 0)
1130 seq_printf (f, "%s\t\t: unknown\n", which);
1132 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1133 which, shape >> 10, shape & 15,
1134 1 << ((shape >> 4) & 15));
1138 show_cpuinfo(struct seq_file *f, void *slot)
1140 extern struct unaligned_stat {
1141 unsigned long count, va, pc;
1144 static char cpu_names[][8] = {
1145 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1146 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1147 "EV68CX", "EV7", "EV79", "EV69"
1150 struct percpu_struct *cpu = slot;
1151 unsigned int cpu_index;
1154 char *sysvariation_name;
1156 unsigned long timer_freq;
1158 cpu_index = (unsigned) (cpu->type - 1);
1159 cpu_name = "Unknown";
1160 if (cpu_index < ARRAY_SIZE(cpu_names))
1161 cpu_name = cpu_names[cpu_index];
1163 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1164 cpu->type, &systype_name, &sysvariation_name);
1166 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1168 #if CONFIG_HZ == 1024 || CONFIG_HZ == 1200
1169 timer_freq = (100UL * hwrpb->intr_freq) / 4096;
1171 timer_freq = 100UL * CONFIG_HZ;
1174 seq_printf(f, "cpu\t\t\t: Alpha\n"
1175 "cpu model\t\t: %s\n"
1176 "cpu variation\t\t: %ld\n"
1177 "cpu revision\t\t: %ld\n"
1178 "cpu serial number\t: %s\n"
1179 "system type\t\t: %s\n"
1180 "system variation\t: %s\n"
1181 "system revision\t\t: %ld\n"
1182 "system serial number\t: %s\n"
1183 "cycle frequency [Hz]\t: %lu %s\n"
1184 "timer frequency [Hz]\t: %lu.%02lu\n"
1185 "page size [bytes]\t: %ld\n"
1186 "phys. address bits\t: %ld\n"
1187 "max. addr. space #\t: %ld\n"
1188 "BogoMIPS\t\t: %lu.%02lu\n"
1189 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1190 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1191 "platform string\t\t: %s\n"
1192 "cpus detected\t\t: %d\n",
1193 cpu_name, cpu->variation, cpu->revision,
1194 (char*)cpu->serial_no,
1195 systype_name, sysvariation_name, hwrpb->sys_revision,
1197 est_cycle_freq ? : hwrpb->cycle_freq,
1198 est_cycle_freq ? "est." : "",
1199 timer_freq / 100, timer_freq % 100,
1203 loops_per_jiffy / (500000/HZ),
1204 (loops_per_jiffy / (5000/HZ)) % 100,
1205 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1206 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1207 platform_string(), nr_processors);
1210 seq_printf(f, "cpus active\t\t: %u\n"
1211 "cpu active mask\t\t: %016lx\n",
1212 num_online_cpus(), cpumask_bits(cpu_possible_mask)[0]);
1215 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1216 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1217 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1218 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1224 read_mem_block(int *addr, int stride, int size)
1226 long nloads = size / stride, cnt, tmp;
1228 __asm__ __volatile__(
1232 /* Next two XORs introduce an explicit data dependency between
1233 consecutive loads in the loop, which will give us true load
1241 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1242 : "r" (stride), "1" (nloads), "2" (addr));
1244 return cnt / (size / stride);
1247 #define CSHAPE(totalsize, linesize, assoc) \
1248 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1250 /* ??? EV5 supports up to 64M, but did the systems with more than
1251 16M of BCACHE ever exist? */
1252 #define MAX_BCACHE_SIZE 16*1024*1024
1254 /* Note that the offchip caches are direct mapped on all Alphas. */
1256 external_cache_probe(int minsize, int width)
1258 int cycles, prev_cycles = 1000000;
1259 int stride = 1 << width;
1260 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1262 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1263 maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
1265 /* Get the first block cached. */
1266 read_mem_block(__va(0), stride, size);
1268 while (size < maxsize) {
1269 /* Get an average load latency in cycles. */
1270 cycles = read_mem_block(__va(0), stride, size);
1271 if (cycles > prev_cycles * 2) {
1272 /* Fine, we exceed the cache. */
1273 printk("%ldK Bcache detected; load hit latency %d "
1274 "cycles, load miss latency %d cycles\n",
1275 size >> 11, prev_cycles, cycles);
1276 return CSHAPE(size >> 1, width, 1);
1278 /* Try to get the next block cached. */
1279 read_mem_block(__va(size), stride, size);
1280 prev_cycles = cycles;
1283 return -1; /* No BCACHE found. */
1287 determine_cpu_caches (unsigned int cpu_type)
1289 int L1I, L1D, L2, L3;
1295 if (cpu_type == EV4_CPU)
1296 L1I = CSHAPE(8*1024, 5, 1);
1298 L1I = CSHAPE(16*1024, 5, 1);
1302 /* BIU_CTL is a write-only Abox register. PALcode has a
1303 shadow copy, and may be available from some versions
1304 of the CSERVE PALcall. If we can get it, then
1306 unsigned long biu_ctl, size;
1307 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1308 L2 = CSHAPE (size, 5, 1);
1310 Unfortunately, we can't rely on that.
1312 L2 = external_cache_probe(128*1024, 5);
1318 unsigned long car, size;
1320 L1I = L1D = CSHAPE(8*1024, 5, 1);
1323 car = *(vuip) phys_to_virt (0x120000078UL);
1324 size = 64*1024 * (1 << ((car >> 5) & 7));
1325 /* No typo -- 8 byte cacheline size. Whodathunk. */
1326 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1333 unsigned long sc_ctl, width;
1335 L1I = L1D = CSHAPE(8*1024, 5, 1);
1337 /* Check the line size of the Scache. */
1338 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1339 width = sc_ctl & 0x1000 ? 6 : 5;
1340 L2 = CSHAPE (96*1024, width, 3);
1342 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1343 has a shadow copy, and may be available from some versions
1344 of the CSERVE PALcall. If we can get it, then
1346 unsigned long bc_control, bc_config, size;
1347 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1348 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1350 Unfortunately, we can't rely on that.
1352 L3 = external_cache_probe(1024*1024, width);
1359 if (cpu_type == PCA56_CPU) {
1360 L1I = CSHAPE(16*1024, 6, 1);
1361 L1D = CSHAPE(8*1024, 5, 1);
1363 L1I = CSHAPE(32*1024, 6, 2);
1364 L1D = CSHAPE(16*1024, 5, 1);
1369 unsigned long cbox_config, size;
1371 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1372 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1374 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1376 L2 = external_cache_probe(512*1024, 6);
1387 L1I = L1D = CSHAPE(64*1024, 6, 2);
1388 L2 = external_cache_probe(1024*1024, 6);
1394 L1I = L1D = CSHAPE(64*1024, 6, 2);
1395 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1400 /* Nothing known about this cpu type. */
1401 L1I = L1D = L2 = L3 = 0;
1405 alpha_l1i_cacheshape = L1I;
1406 alpha_l1d_cacheshape = L1D;
1407 alpha_l2_cacheshape = L2;
1408 alpha_l3_cacheshape = L3;
1412 * We show only CPU #0 info.
1415 c_start(struct seq_file *f, loff_t *pos)
1417 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1421 c_next(struct seq_file *f, void *v, loff_t *pos)
1427 c_stop(struct seq_file *f, void *v)
1431 const struct seq_operations cpuinfo_op = {
1435 .show = show_cpuinfo,
1440 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1443 /* FIXME FIXME FIXME */
1444 /* If we are using SRM and serial console, just hard halt here. */
1445 if (alpha_using_srm && srmcons_output)
1451 static __init int add_pcspkr(void)
1453 struct platform_device *pd;
1456 pd = platform_device_alloc("pcspkr", -1);
1460 ret = platform_device_add(pd);
1462 platform_device_put(pd);
1466 device_initcall(add_pcspkr);