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/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) + 0x0f;
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 void sysrq_reboot_handler(int unused)
438 static const struct sysrq_key_op srm_sysrq_reboot_op = {
439 .handler = sysrq_reboot_handler,
440 .help_msg = "reboot(b)",
441 .action_msg = "Resetting",
442 .enable_mask = SYSRQ_ENABLE_BOOT,
447 setup_arch(char **cmdline_p)
451 struct alpha_machine_vector *vec = NULL;
452 struct percpu_struct *cpu;
453 char *type_name, *var_name, *p;
454 void *kernel_end = _end; /* end of kernel */
455 char *args = command_line;
457 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
458 boot_cpuid = hard_smp_processor_id();
461 * Pre-process the system type to make sure it will be valid.
463 * This may restore real CABRIO and EB66+ family names, ie
466 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
467 * and AS1200 (DIGITAL Server 5000 series) have the type as
468 * the negative of the real one.
470 if ((long)hwrpb->sys_type < 0) {
471 hwrpb->sys_type = -((long)hwrpb->sys_type);
472 hwrpb_update_checksum(hwrpb);
475 /* Register a call for panic conditions. */
476 atomic_notifier_chain_register(&panic_notifier_list,
479 #ifndef alpha_using_srm
480 /* Assume that we've booted from SRM if we haven't booted from MILO.
481 Detect the later by looking for "MILO" in the system serial nr. */
482 alpha_using_srm = !str_has_prefix((const char *)hwrpb->ssn, "MILO");
484 #ifndef alpha_using_qemu
485 /* Similarly, look for QEMU. */
486 alpha_using_qemu = strstr((const char *)hwrpb->ssn, "QEMU") != 0;
489 /* If we are using SRM, we want to allow callbacks
490 as early as possible, so do this NOW, and then
491 they should work immediately thereafter.
493 kernel_end = callback_init(kernel_end);
496 * Locate the command line.
498 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
499 boot flags depending on the boot mode, we need some shorthand.
500 This should do for installation. */
501 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
502 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
504 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
506 strcpy(boot_command_line, command_line);
507 *cmdline_p = command_line;
510 * Process command-line arguments.
512 while ((p = strsep(&args, " \t")) != NULL) {
514 if (strncmp(p, "alpha_mv=", 9) == 0) {
515 vec = get_sysvec_byname(p+9);
518 if (strncmp(p, "cycle=", 6) == 0) {
519 est_cycle_freq = simple_strtol(p+6, NULL, 0);
522 if (strncmp(p, "mem=", 4) == 0) {
523 mem_size_limit = get_mem_size_limit(p+4);
526 if (strncmp(p, "srmcons", 7) == 0) {
530 if (strncmp(p, "console=srm", 11) == 0) {
534 if (strncmp(p, "gartsize=", 9) == 0) {
536 get_mem_size_limit(p+9) << PAGE_SHIFT;
539 #ifdef CONFIG_VERBOSE_MCHECK
540 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
541 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
547 /* Replace the command line, now that we've killed it with strsep. */
548 strcpy(command_line, boot_command_line);
550 /* If we want SRM console printk echoing early, do it now. */
551 if (alpha_using_srm && srmcons_output) {
552 register_srm_console();
555 * If "console=srm" was specified, clear the srmcons_output
556 * flag now so that time.c won't unregister_srm_console
558 if (srmcons_output & 2)
562 #ifdef CONFIG_MAGIC_SYSRQ
563 /* If we're using SRM, make sysrq-b halt back to the prom,
565 if (alpha_using_srm) {
566 unregister_sysrq_key('b', __sysrq_reboot_op);
567 register_sysrq_key('b', &srm_sysrq_reboot_op);
572 * Identify and reconfigure for the current system.
574 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
576 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
577 cpu->type, &type_name, &var_name);
578 if (*var_name == '0')
582 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
587 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
588 type_name, (*var_name ? " variation " : ""), var_name,
589 hwrpb->sys_type, hwrpb->sys_variation);
591 if (vec != &alpha_mv) {
596 #ifdef CONFIG_ALPHA_GENERIC
599 "on %s%s%s using machine vector %s from %s\n",
600 type_name, (*var_name ? " variation " : ""),
601 var_name, alpha_mv.vector_name,
602 (alpha_using_srm ? "SRM" : "MILO"));
604 printk("Major Options: "
608 #ifdef CONFIG_ALPHA_EV56
611 #ifdef CONFIG_ALPHA_EV67
614 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
617 #ifdef CONFIG_VERBOSE_MCHECK
621 #ifdef CONFIG_DISCONTIGMEM
628 #ifdef CONFIG_DEBUG_SPINLOCK
631 #ifdef CONFIG_MAGIC_SYSRQ
636 printk("Command line: %s\n", command_line);
640 * Save the SRM's current value for restoration.
642 srm_hae = *alpha_mv.hae_register;
643 __set_hae(alpha_mv.hae_cache);
645 /* Reset enable correctable error reports. */
648 /* Find our memory. */
649 setup_memory(kernel_end);
650 memblock_set_bottom_up(true);
653 /* First guess at cpu cache sizes. Do this before init_arch. */
654 determine_cpu_caches(cpu->type);
656 /* Initialize the machine. Usually has to do with setting up
657 DMA windows and the like. */
658 if (alpha_mv.init_arch)
659 alpha_mv.init_arch();
661 /* Reserve standard resources. */
662 reserve_std_resources();
665 * Give us a default console. TGA users will see nothing until
666 * chr_dev_init is called, rather late in the boot sequence.
670 #if defined(CONFIG_VGA_CONSOLE)
671 conswitchp = &vga_con;
675 /* Default root filesystem to sda2. */
676 ROOT_DEV = Root_SDA2;
679 /* FIXME: only set this when we actually have EISA in this box? */
684 * Check ASN in HWRPB for validity, report if bad.
685 * FIXME: how was this failing? Should we trust it instead,
686 * and copy the value into alpha_mv.max_asn?
689 if (hwrpb->max_asn != MAX_ASN) {
690 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
694 * Identify the flock of penguins.
703 static char sys_unknown[] = "Unknown";
704 static char systype_names[][16] = {
706 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
707 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
708 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
709 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
710 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
711 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
712 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
715 static char unofficial_names[][8] = {"100", "Ruffian"};
717 static char api_names[][16] = {"200", "Nautilus"};
719 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
720 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
722 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
723 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
725 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
726 static int eb64p_indices[] = {0,0,1,2};
728 static char eb66_names[][8] = {"EB66", "EB66+"};
729 static int eb66_indices[] = {0,0,1};
731 static char marvel_names[][16] = {
734 static int marvel_indices[] = { 0 };
736 static char rawhide_names[][16] = {
737 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
739 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
741 static char titan_names[][16] = {
742 "DEFAULT", "Privateer", "Falcon", "Granite"
744 static int titan_indices[] = {0,1,2,2,3};
746 static char tsunami_names[][16] = {
747 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
748 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
749 "Flying Clipper", "Shark"
751 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
753 static struct alpha_machine_vector * __init
754 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
756 static struct alpha_machine_vector *systype_vecs[] __initdata =
763 NULL, /* Mannequin */
767 NULL, /* Sable -- see below. */
770 NULL, /* Turbolaser */
773 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
774 NULL, /* Tradewind */
775 NULL, /* Mikasa -- see below. */
777 NULL, /* EB66 -- see variation. */
778 NULL, /* EB64+ -- see variation. */
784 NULL, /* EB164 -- see variation. */
785 NULL, /* Noritake -- see below. */
792 NULL, /* Tsunami -- see variation. */
793 &wildfire_mv, /* Wildfire */
795 &eiger_mv, /* Eiger */
800 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
806 static struct alpha_machine_vector *api_vecs[] __initdata =
812 static struct alpha_machine_vector *alcor_vecs[] __initdata =
814 &alcor_mv, &xlt_mv, &xlt_mv
817 static struct alpha_machine_vector *eb164_vecs[] __initdata =
819 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
822 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
826 &cabriolet_mv /* AlphaPCI64 */
829 static struct alpha_machine_vector *eb66_vecs[] __initdata =
835 static struct alpha_machine_vector *marvel_vecs[] __initdata =
840 static struct alpha_machine_vector *titan_vecs[] __initdata =
842 &titan_mv, /* default */
843 &privateer_mv, /* privateer */
844 &titan_mv, /* falcon */
845 &privateer_mv, /* granite */
848 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
851 &dp264_mv, /* dp264 */
852 &dp264_mv, /* warhol */
853 &dp264_mv, /* windjammer */
854 &monet_mv, /* monet */
855 &clipper_mv, /* clipper */
856 &dp264_mv, /* goldrush */
857 &webbrick_mv, /* webbrick */
858 &dp264_mv, /* catamaran */
859 NULL, /* brisbane? */
860 NULL, /* melbourne? */
861 NULL, /* flying clipper? */
862 &shark_mv, /* shark */
865 /* ??? Do we need to distinguish between Rawhides? */
867 struct alpha_machine_vector *vec;
869 /* Search the system tables first... */
871 if (type < ARRAY_SIZE(systype_vecs)) {
872 vec = systype_vecs[type];
873 } else if ((type > ST_API_BIAS) &&
874 (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
875 vec = api_vecs[type - ST_API_BIAS];
876 } else if ((type > ST_UNOFFICIAL_BIAS) &&
877 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
878 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
881 /* If we've not found one, try for a variation. */
884 /* Member ID is a bit-field. */
885 unsigned long member = (variation >> 10) & 0x3f;
887 cpu &= 0xffffffff; /* make it usable */
891 if (member < ARRAY_SIZE(alcor_indices))
892 vec = alcor_vecs[alcor_indices[member]];
895 if (member < ARRAY_SIZE(eb164_indices))
896 vec = eb164_vecs[eb164_indices[member]];
897 /* PC164 may show as EB164 variation with EV56 CPU,
898 but, since no true EB164 had anything but EV5... */
899 if (vec == &eb164_mv && cpu == EV56_CPU)
903 if (member < ARRAY_SIZE(eb64p_indices))
904 vec = eb64p_vecs[eb64p_indices[member]];
907 if (member < ARRAY_SIZE(eb66_indices))
908 vec = eb66_vecs[eb66_indices[member]];
911 if (member < ARRAY_SIZE(marvel_indices))
912 vec = marvel_vecs[marvel_indices[member]];
915 vec = titan_vecs[0]; /* default */
916 if (member < ARRAY_SIZE(titan_indices))
917 vec = titan_vecs[titan_indices[member]];
920 if (member < ARRAY_SIZE(tsunami_indices))
921 vec = tsunami_vecs[tsunami_indices[member]];
924 if (cpu == EV5_CPU || cpu == EV56_CPU)
925 vec = &mikasa_primo_mv;
929 case ST_DEC_NORITAKE:
930 if (cpu == EV5_CPU || cpu == EV56_CPU)
931 vec = &noritake_primo_mv;
935 case ST_DEC_2100_A500:
936 if (cpu == EV5_CPU || cpu == EV56_CPU)
937 vec = &sable_gamma_mv;
946 static struct alpha_machine_vector * __init
947 get_sysvec_byname(const char *name)
949 static struct alpha_machine_vector *all_vecs[] __initdata =
992 for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
993 struct alpha_machine_vector *mv = all_vecs[i];
994 if (strcasecmp(mv->vector_name, name) == 0)
1001 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
1002 char **type_name, char **variation_name)
1004 unsigned long member;
1006 /* If not in the tables, make it UNKNOWN,
1007 else set type name to family */
1008 if (type < ARRAY_SIZE(systype_names)) {
1009 *type_name = systype_names[type];
1010 } else if ((type > ST_API_BIAS) &&
1011 (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
1012 *type_name = api_names[type - ST_API_BIAS];
1013 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1014 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
1015 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1017 *type_name = sys_unknown;
1018 *variation_name = sys_unknown;
1022 /* Set variation to "0"; if variation is zero, done. */
1023 *variation_name = systype_names[0];
1024 if (variation == 0) {
1028 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1030 cpu &= 0xffffffff; /* make it usable */
1032 switch (type) { /* select by family */
1033 default: /* default to variation "0" for now */
1036 if (member >= ARRAY_SIZE(eb164_indices))
1038 *variation_name = eb164_names[eb164_indices[member]];
1039 /* PC164 may show as EB164 variation, but with EV56 CPU,
1040 so, since no true EB164 had anything but EV5... */
1041 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1042 *variation_name = eb164_names[1]; /* make it PC164 */
1045 if (member < ARRAY_SIZE(alcor_indices))
1046 *variation_name = alcor_names[alcor_indices[member]];
1049 if (member < ARRAY_SIZE(eb64p_indices))
1050 *variation_name = eb64p_names[eb64p_indices[member]];
1053 if (member < ARRAY_SIZE(eb66_indices))
1054 *variation_name = eb66_names[eb66_indices[member]];
1057 if (member < ARRAY_SIZE(marvel_indices))
1058 *variation_name = marvel_names[marvel_indices[member]];
1060 case ST_DEC_RAWHIDE:
1061 if (member < ARRAY_SIZE(rawhide_indices))
1062 *variation_name = rawhide_names[rawhide_indices[member]];
1065 *variation_name = titan_names[0]; /* default */
1066 if (member < ARRAY_SIZE(titan_indices))
1067 *variation_name = titan_names[titan_indices[member]];
1069 case ST_DEC_TSUNAMI:
1070 if (member < ARRAY_SIZE(tsunami_indices))
1071 *variation_name = tsunami_names[tsunami_indices[member]];
1077 * A change was made to the HWRPB via an ECO and the following code
1078 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1079 * was not implemented in the console firmware. If it's revision 5 or
1080 * greater we can get the name of the platform as an ASCII string from
1081 * the HWRPB. That's what this function does. It checks the revision
1082 * level and if the string is in the HWRPB it returns the address of
1083 * the string--a pointer to the name of the platform.
1086 * - Pointer to a ASCII string if it's in the HWRPB
1087 * - Pointer to a blank string if the data is not in the HWRPB.
1091 platform_string(void)
1093 struct dsr_struct *dsr;
1094 static char unk_system_string[] = "N/A";
1096 /* Go to the console for the string pointer.
1097 * If the rpb_vers is not 5 or greater the rpb
1098 * is old and does not have this data in it.
1100 if (hwrpb->revision < 5)
1101 return (unk_system_string);
1103 /* The Dynamic System Recognition struct
1104 * has the system platform name starting
1105 * after the character count of the string.
1107 dsr = ((struct dsr_struct *)
1108 ((char *)hwrpb + hwrpb->dsr_offset));
1109 return ((char *)dsr + (dsr->sysname_off +
1115 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1117 struct percpu_struct *cpu;
1121 for (i = 0; i < num; i++) {
1122 cpu = (struct percpu_struct *)
1123 ((char *)cpubase + i*hwrpb->processor_size);
1124 if ((cpu->flags & 0x1cc) == 0x1cc)
1131 show_cache_size (struct seq_file *f, const char *which, int shape)
1134 seq_printf (f, "%s\t\t: n/a\n", which);
1135 else if (shape == 0)
1136 seq_printf (f, "%s\t\t: unknown\n", which);
1138 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1139 which, shape >> 10, shape & 15,
1140 1 << ((shape >> 4) & 15));
1144 show_cpuinfo(struct seq_file *f, void *slot)
1146 extern struct unaligned_stat {
1147 unsigned long count, va, pc;
1150 static char cpu_names[][8] = {
1151 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1152 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1153 "EV68CX", "EV7", "EV79", "EV69"
1156 struct percpu_struct *cpu = slot;
1157 unsigned int cpu_index;
1160 char *sysvariation_name;
1162 unsigned long timer_freq;
1164 cpu_index = (unsigned) (cpu->type - 1);
1165 cpu_name = "Unknown";
1166 if (cpu_index < ARRAY_SIZE(cpu_names))
1167 cpu_name = cpu_names[cpu_index];
1169 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1170 cpu->type, &systype_name, &sysvariation_name);
1172 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1174 #if CONFIG_HZ == 1024 || CONFIG_HZ == 1200
1175 timer_freq = (100UL * hwrpb->intr_freq) / 4096;
1177 timer_freq = 100UL * CONFIG_HZ;
1180 seq_printf(f, "cpu\t\t\t: Alpha\n"
1181 "cpu model\t\t: %s\n"
1182 "cpu variation\t\t: %ld\n"
1183 "cpu revision\t\t: %ld\n"
1184 "cpu serial number\t: %s\n"
1185 "system type\t\t: %s\n"
1186 "system variation\t: %s\n"
1187 "system revision\t\t: %ld\n"
1188 "system serial number\t: %s\n"
1189 "cycle frequency [Hz]\t: %lu %s\n"
1190 "timer frequency [Hz]\t: %lu.%02lu\n"
1191 "page size [bytes]\t: %ld\n"
1192 "phys. address bits\t: %ld\n"
1193 "max. addr. space #\t: %ld\n"
1194 "BogoMIPS\t\t: %lu.%02lu\n"
1195 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1196 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1197 "platform string\t\t: %s\n"
1198 "cpus detected\t\t: %d\n",
1199 cpu_name, cpu->variation, cpu->revision,
1200 (char*)cpu->serial_no,
1201 systype_name, sysvariation_name, hwrpb->sys_revision,
1203 est_cycle_freq ? : hwrpb->cycle_freq,
1204 est_cycle_freq ? "est." : "",
1205 timer_freq / 100, timer_freq % 100,
1209 loops_per_jiffy / (500000/HZ),
1210 (loops_per_jiffy / (5000/HZ)) % 100,
1211 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1212 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1213 platform_string(), nr_processors);
1216 seq_printf(f, "cpus active\t\t: %u\n"
1217 "cpu active mask\t\t: %016lx\n",
1218 num_online_cpus(), cpumask_bits(cpu_possible_mask)[0]);
1221 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1222 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1223 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1224 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1230 read_mem_block(int *addr, int stride, int size)
1232 long nloads = size / stride, cnt, tmp;
1234 __asm__ __volatile__(
1238 /* Next two XORs introduce an explicit data dependency between
1239 consecutive loads in the loop, which will give us true load
1247 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1248 : "r" (stride), "1" (nloads), "2" (addr));
1250 return cnt / (size / stride);
1253 #define CSHAPE(totalsize, linesize, assoc) \
1254 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1256 /* ??? EV5 supports up to 64M, but did the systems with more than
1257 16M of BCACHE ever exist? */
1258 #define MAX_BCACHE_SIZE 16*1024*1024
1260 /* Note that the offchip caches are direct mapped on all Alphas. */
1262 external_cache_probe(int minsize, int width)
1264 int cycles, prev_cycles = 1000000;
1265 int stride = 1 << width;
1266 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1268 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1269 maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
1271 /* Get the first block cached. */
1272 read_mem_block(__va(0), stride, size);
1274 while (size < maxsize) {
1275 /* Get an average load latency in cycles. */
1276 cycles = read_mem_block(__va(0), stride, size);
1277 if (cycles > prev_cycles * 2) {
1278 /* Fine, we exceed the cache. */
1279 printk("%ldK Bcache detected; load hit latency %d "
1280 "cycles, load miss latency %d cycles\n",
1281 size >> 11, prev_cycles, cycles);
1282 return CSHAPE(size >> 1, width, 1);
1284 /* Try to get the next block cached. */
1285 read_mem_block(__va(size), stride, size);
1286 prev_cycles = cycles;
1289 return -1; /* No BCACHE found. */
1293 determine_cpu_caches (unsigned int cpu_type)
1295 int L1I, L1D, L2, L3;
1301 if (cpu_type == EV4_CPU)
1302 L1I = CSHAPE(8*1024, 5, 1);
1304 L1I = CSHAPE(16*1024, 5, 1);
1308 /* BIU_CTL is a write-only Abox register. PALcode has a
1309 shadow copy, and may be available from some versions
1310 of the CSERVE PALcall. If we can get it, then
1312 unsigned long biu_ctl, size;
1313 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1314 L2 = CSHAPE (size, 5, 1);
1316 Unfortunately, we can't rely on that.
1318 L2 = external_cache_probe(128*1024, 5);
1324 unsigned long car, size;
1326 L1I = L1D = CSHAPE(8*1024, 5, 1);
1329 car = *(vuip) phys_to_virt (0x120000078UL);
1330 size = 64*1024 * (1 << ((car >> 5) & 7));
1331 /* No typo -- 8 byte cacheline size. Whodathunk. */
1332 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1339 unsigned long sc_ctl, width;
1341 L1I = L1D = CSHAPE(8*1024, 5, 1);
1343 /* Check the line size of the Scache. */
1344 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1345 width = sc_ctl & 0x1000 ? 6 : 5;
1346 L2 = CSHAPE (96*1024, width, 3);
1348 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1349 has a shadow copy, and may be available from some versions
1350 of the CSERVE PALcall. If we can get it, then
1352 unsigned long bc_control, bc_config, size;
1353 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1354 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1356 Unfortunately, we can't rely on that.
1358 L3 = external_cache_probe(1024*1024, width);
1365 if (cpu_type == PCA56_CPU) {
1366 L1I = CSHAPE(16*1024, 6, 1);
1367 L1D = CSHAPE(8*1024, 5, 1);
1369 L1I = CSHAPE(32*1024, 6, 2);
1370 L1D = CSHAPE(16*1024, 5, 1);
1375 unsigned long cbox_config, size;
1377 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1378 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1380 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1382 L2 = external_cache_probe(512*1024, 6);
1393 L1I = L1D = CSHAPE(64*1024, 6, 2);
1394 L2 = external_cache_probe(1024*1024, 6);
1400 L1I = L1D = CSHAPE(64*1024, 6, 2);
1401 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1406 /* Nothing known about this cpu type. */
1407 L1I = L1D = L2 = L3 = 0;
1411 alpha_l1i_cacheshape = L1I;
1412 alpha_l1d_cacheshape = L1D;
1413 alpha_l2_cacheshape = L2;
1414 alpha_l3_cacheshape = L3;
1418 * We show only CPU #0 info.
1421 c_start(struct seq_file *f, loff_t *pos)
1423 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1427 c_next(struct seq_file *f, void *v, loff_t *pos)
1434 c_stop(struct seq_file *f, void *v)
1438 const struct seq_operations cpuinfo_op = {
1442 .show = show_cpuinfo,
1447 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1450 /* FIXME FIXME FIXME */
1451 /* If we are using SRM and serial console, just hard halt here. */
1452 if (alpha_using_srm && srmcons_output)
1458 static __init int add_pcspkr(void)
1460 struct platform_device *pd;
1463 pd = platform_device_alloc("pcspkr", -1);
1467 ret = platform_device_add(pd);
1469 platform_device_put(pd);
1473 device_initcall(add_pcspkr);