2 * linux/arch/alpha/kernel/setup.c
4 * Copyright (C) 1995 Linus Torvalds
7 /* 2.3.x bootmem, 1999 Andrea Arcangeli <andrea@suse.de> */
13 #include <linux/sched.h>
14 #include <linux/kernel.h>
16 #include <linux/stddef.h>
17 #include <linux/unistd.h>
18 #include <linux/ptrace.h>
19 #include <linux/slab.h>
20 #include <linux/user.h>
21 #include <linux/a.out.h>
22 #include <linux/tty.h>
23 #include <linux/delay.h>
24 #include <linux/config.h> /* CONFIG_ALPHA_LCA etc */
25 #include <linux/mc146818rtc.h>
26 #include <linux/console.h>
27 #include <linux/errno.h>
28 #include <linux/init.h>
29 #include <linux/string.h>
30 #include <linux/ioport.h>
31 #include <linux/bootmem.h>
32 #include <linux/pci.h>
33 #include <linux/seq_file.h>
34 #include <linux/root_dev.h>
35 #include <linux/initrd.h>
36 #include <linux/eisa.h>
37 #ifdef CONFIG_MAGIC_SYSRQ
38 #include <linux/sysrq.h>
39 #include <linux/reboot.h>
41 #include <linux/notifier.h>
44 extern struct notifier_block *panic_notifier_list;
45 static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
46 static struct notifier_block alpha_panic_block = {
49 INT_MAX /* try to do it first */
52 #include <asm/uaccess.h>
53 #include <asm/pgtable.h>
54 #include <asm/system.h>
55 #include <asm/hwrpb.h>
58 #include <asm/mmu_context.h>
59 #include <asm/console.h>
65 struct hwrpb_struct *hwrpb;
66 unsigned long srm_hae;
68 int alpha_l1i_cacheshape;
69 int alpha_l1d_cacheshape;
70 int alpha_l2_cacheshape;
71 int alpha_l3_cacheshape;
73 #ifdef CONFIG_VERBOSE_MCHECK
74 /* 0=minimum, 1=verbose, 2=all */
75 /* These can be overridden via the command line, ie "verbose_mcheck=2") */
76 unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
79 /* Which processor we booted from. */
83 * Using SRM callbacks for initial console output. This works from
84 * setup_arch() time through the end of time_init(), as those places
85 * are under our (Alpha) control.
87 * "srmcons" specified in the boot command arguments allows us to
88 * see kernel messages during the period of time before the true
89 * console device is "registered" during console_init().
90 * As of this version (2.5.59), console_init() will call
91 * disable_early_printk() as the last action before initializing
92 * the console drivers. That's the last possible time srmcons can be
93 * unregistered without interfering with console behavior.
95 * By default, OFF; set it with a bootcommand arg of "srmcons" or
96 * "console=srm". The meaning of these two args is:
97 * "srmcons" - early callback prints
98 * "console=srm" - full callback based console, including early prints
100 int srmcons_output = 0;
102 /* Enforce a memory size limit; useful for testing. By default, none. */
103 unsigned long mem_size_limit = 0;
105 /* Set AGP GART window size (0 means disabled). */
106 unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
108 #ifdef CONFIG_ALPHA_GENERIC
109 struct alpha_machine_vector alpha_mv;
113 unsigned char aux_device_present = 0xaa;
115 #define N(a) (sizeof(a)/sizeof(a[0]))
117 static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
119 static struct alpha_machine_vector *get_sysvec_byname(const char *);
120 static void get_sysnames(unsigned long, unsigned long, unsigned long,
122 static void determine_cpu_caches (unsigned int);
124 static char command_line[COMMAND_LINE_SIZE];
125 char saved_command_line[COMMAND_LINE_SIZE];
128 * The format of "screen_info" is strange, and due to early
129 * i386-setup code. This is just enough to make the console
130 * code think we're on a VGA color display.
133 struct screen_info screen_info = {
136 .orig_video_cols = 80,
137 .orig_video_lines = 25,
138 .orig_video_isVGA = 1,
139 .orig_video_points = 16
143 * The direct map I/O window, if any. This should be the same
144 * for all busses, since it's used by virt_to_bus.
147 unsigned long __direct_map_base;
148 unsigned long __direct_map_size;
151 * Declare all of the machine vectors.
154 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
155 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
159 extern struct alpha_machine_vector X; \
179 WEAK(mikasa_primo_mv);
184 WEAK(noritake_primo_mv);
192 WEAK(sable_gamma_mv);
205 * I/O resources inherited from PeeCees. Except for perhaps the
206 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
208 * ??? If this becomes less standard, move the struct out into the
213 reserve_std_resources(void)
215 static struct resource standard_io_resources[] = {
217 { "dma1", 0x00, 0x1f },
218 { "pic1", 0x20, 0x3f },
219 { "timer", 0x40, 0x5f },
220 { "keyboard", 0x60, 0x6f },
221 { "dma page reg", 0x80, 0x8f },
222 { "pic2", 0xa0, 0xbf },
223 { "dma2", 0xc0, 0xdf },
226 struct resource *io = &ioport_resource;
230 struct pci_controller *hose;
231 for (hose = hose_head; hose; hose = hose->next)
232 if (hose->index == 0) {
238 /* Fix up for the Jensen's queer RTC placement. */
239 standard_io_resources[0].start = RTC_PORT(0);
240 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
242 for (i = 0; i < N(standard_io_resources); ++i)
243 request_resource(io, standard_io_resources+i);
246 #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
247 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
248 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
249 #define PFN_MAX PFN_DOWN(0x80000000)
250 #define for_each_mem_cluster(memdesc, cluster, i) \
251 for ((cluster) = (memdesc)->cluster, (i) = 0; \
252 (i) < (memdesc)->numclusters; (i)++, (cluster)++)
254 static unsigned long __init
255 get_mem_size_limit(char *s)
257 unsigned long end = 0;
260 end = simple_strtoul(from, &from, 0);
261 if ( *from == 'K' || *from == 'k' ) {
264 } else if ( *from == 'M' || *from == 'm' ) {
267 } else if ( *from == 'G' || *from == 'g' ) {
271 return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
274 #ifdef CONFIG_BLK_DEV_INITRD
276 move_initrd(unsigned long mem_limit)
281 size = initrd_end - initrd_start;
282 start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
283 if (!start || __pa(start) + size > mem_limit) {
284 initrd_start = initrd_end = 0;
287 memmove(start, (void *)initrd_start, size);
288 initrd_start = (unsigned long)start;
289 initrd_end = initrd_start + size;
290 printk("initrd moved to %p\n", start);
295 #ifndef CONFIG_DISCONTIGMEM
297 setup_memory(void *kernel_end)
299 struct memclust_struct * cluster;
300 struct memdesc_struct * memdesc;
301 unsigned long start_kernel_pfn, end_kernel_pfn;
302 unsigned long bootmap_size, bootmap_pages, bootmap_start;
303 unsigned long start, end;
306 /* Find free clusters, and init and free the bootmem accordingly. */
307 memdesc = (struct memdesc_struct *)
308 (hwrpb->mddt_offset + (unsigned long) hwrpb);
310 for_each_mem_cluster(memdesc, cluster, i) {
311 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
312 i, cluster->usage, cluster->start_pfn,
313 cluster->start_pfn + cluster->numpages);
315 /* Bit 0 is console/PALcode reserved. Bit 1 is
316 non-volatile memory -- we might want to mark
318 if (cluster->usage & 3)
321 end = cluster->start_pfn + cluster->numpages;
322 if (end > max_low_pfn)
327 * Except for the NUMA systems (wildfire, marvel) all of the
328 * Alpha systems we run on support 32GB of memory or less.
329 * Since the NUMA systems introduce large holes in memory addressing,
330 * we can get into a situation where there is not enough contiguous
331 * memory for the memory map.
333 * Limit memory to the first 32GB to limit the NUMA systems to
334 * memory on their first node (wildfire) or 2 (marvel) to avoid
335 * not being able to produce the memory map. In order to access
336 * all of the memory on the NUMA systems, build with discontiguous
339 * If the user specified a memory limit, let that memory limit stand.
342 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
344 if (mem_size_limit && max_low_pfn >= mem_size_limit)
346 printk("setup: forcing memory size to %ldK (from %ldK).\n",
347 mem_size_limit << (PAGE_SHIFT - 10),
348 max_low_pfn << (PAGE_SHIFT - 10));
349 max_low_pfn = mem_size_limit;
352 /* Find the bounds of kernel memory. */
353 start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
354 end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
358 if (max_low_pfn <= end_kernel_pfn)
359 panic("not enough memory to boot");
361 /* We need to know how many physically contiguous pages
362 we'll need for the bootmap. */
363 bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
365 /* Now find a good region where to allocate the bootmap. */
366 for_each_mem_cluster(memdesc, cluster, i) {
367 if (cluster->usage & 3)
370 start = cluster->start_pfn;
371 end = start + cluster->numpages;
372 if (start >= max_low_pfn)
374 if (end > max_low_pfn)
376 if (start < start_kernel_pfn) {
377 if (end > end_kernel_pfn
378 && end - end_kernel_pfn >= bootmap_pages) {
379 bootmap_start = end_kernel_pfn;
381 } else if (end > start_kernel_pfn)
382 end = start_kernel_pfn;
383 } else if (start < end_kernel_pfn)
384 start = end_kernel_pfn;
385 if (end - start >= bootmap_pages) {
386 bootmap_start = start;
391 if (bootmap_start == ~0UL) {
396 /* Allocate the bootmap and mark the whole MM as reserved. */
397 bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
399 /* Mark the free regions. */
400 for_each_mem_cluster(memdesc, cluster, i) {
401 if (cluster->usage & 3)
404 start = cluster->start_pfn;
405 end = cluster->start_pfn + cluster->numpages;
406 if (start >= max_low_pfn)
408 if (end > max_low_pfn)
410 if (start < start_kernel_pfn) {
411 if (end > end_kernel_pfn) {
412 free_bootmem(PFN_PHYS(start),
413 (PFN_PHYS(start_kernel_pfn)
415 printk("freeing pages %ld:%ld\n",
416 start, start_kernel_pfn);
417 start = end_kernel_pfn;
418 } else if (end > start_kernel_pfn)
419 end = start_kernel_pfn;
420 } else if (start < end_kernel_pfn)
421 start = end_kernel_pfn;
425 free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
426 printk("freeing pages %ld:%ld\n", start, end);
429 /* Reserve the bootmap memory. */
430 reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size);
431 printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
433 #ifdef CONFIG_BLK_DEV_INITRD
434 initrd_start = INITRD_START;
436 initrd_end = initrd_start+INITRD_SIZE;
437 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
438 (void *) initrd_start, INITRD_SIZE);
440 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
441 if (!move_initrd(PFN_PHYS(max_low_pfn)))
442 printk("initrd extends beyond end of memory "
443 "(0x%08lx > 0x%p)\ndisabling initrd\n",
445 phys_to_virt(PFN_PHYS(max_low_pfn)));
447 reserve_bootmem(virt_to_phys((void *)initrd_start),
451 #endif /* CONFIG_BLK_DEV_INITRD */
454 extern void setup_memory(void *);
455 #endif /* !CONFIG_DISCONTIGMEM */
458 page_is_ram(unsigned long pfn)
460 struct memclust_struct * cluster;
461 struct memdesc_struct * memdesc;
464 memdesc = (struct memdesc_struct *)
465 (hwrpb->mddt_offset + (unsigned long) hwrpb);
466 for_each_mem_cluster(memdesc, cluster, i)
468 if (pfn >= cluster->start_pfn &&
469 pfn < cluster->start_pfn + cluster->numpages) {
470 return (cluster->usage & 3) ? 0 : 1;
483 setup_arch(char **cmdline_p)
487 struct alpha_machine_vector *vec = NULL;
488 struct percpu_struct *cpu;
489 char *type_name, *var_name, *p;
490 void *kernel_end = _end; /* end of kernel */
491 char *args = command_line;
493 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
494 boot_cpuid = hard_smp_processor_id();
497 * Pre-process the system type to make sure it will be valid.
499 * This may restore real CABRIO and EB66+ family names, ie
502 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
503 * and AS1200 (DIGITAL Server 5000 series) have the type as
504 * the negative of the real one.
506 if ((long)hwrpb->sys_type < 0) {
507 hwrpb->sys_type = -((long)hwrpb->sys_type);
508 hwrpb_update_checksum(hwrpb);
511 /* Register a call for panic conditions. */
512 notifier_chain_register(&panic_notifier_list, &alpha_panic_block);
514 #ifdef CONFIG_ALPHA_GENERIC
515 /* Assume that we've booted from SRM if we haven't booted from MILO.
516 Detect the later by looking for "MILO" in the system serial nr. */
517 alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
520 /* If we are using SRM, we want to allow callbacks
521 as early as possible, so do this NOW, and then
522 they should work immediately thereafter.
524 kernel_end = callback_init(kernel_end);
527 * Locate the command line.
529 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
530 boot flags depending on the boot mode, we need some shorthand.
531 This should do for installation. */
532 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
533 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
535 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
537 strcpy(saved_command_line, command_line);
538 *cmdline_p = command_line;
541 * Process command-line arguments.
543 while ((p = strsep(&args, " \t")) != NULL) {
545 if (strncmp(p, "alpha_mv=", 9) == 0) {
546 vec = get_sysvec_byname(p+9);
549 if (strncmp(p, "cycle=", 6) == 0) {
550 est_cycle_freq = simple_strtol(p+6, NULL, 0);
553 if (strncmp(p, "mem=", 4) == 0) {
554 mem_size_limit = get_mem_size_limit(p+4);
557 if (strncmp(p, "srmcons", 7) == 0) {
561 if (strncmp(p, "console=srm", 11) == 0) {
565 if (strncmp(p, "gartsize=", 9) == 0) {
567 get_mem_size_limit(p+9) << PAGE_SHIFT;
570 #ifdef CONFIG_VERBOSE_MCHECK
571 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
572 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
578 /* Replace the command line, now that we've killed it with strsep. */
579 strcpy(command_line, saved_command_line);
581 /* If we want SRM console printk echoing early, do it now. */
582 if (alpha_using_srm && srmcons_output) {
583 register_srm_console();
586 * If "console=srm" was specified, clear the srmcons_output
587 * flag now so that time.c won't unregister_srm_console
589 if (srmcons_output & 2)
593 #ifdef CONFIG_MAGIC_SYSRQ
594 /* If we're using SRM, make sysrq-b halt back to the prom,
596 if (alpha_using_srm) {
597 struct sysrq_key_op *op = __sysrq_get_key_op('b');
598 op->handler = (void *) machine_halt;
603 * Identify and reconfigure for the current system.
605 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
607 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
608 cpu->type, &type_name, &var_name);
609 if (*var_name == '0')
613 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
618 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
619 type_name, (*var_name ? " variation " : ""), var_name,
620 hwrpb->sys_type, hwrpb->sys_variation);
622 if (vec != &alpha_mv) {
627 #ifdef CONFIG_ALPHA_GENERIC
630 "on %s%s%s using machine vector %s from %s\n",
631 type_name, (*var_name ? " variation " : ""),
632 var_name, alpha_mv.vector_name,
633 (alpha_using_srm ? "SRM" : "MILO"));
635 printk("Major Options: "
639 #ifdef CONFIG_ALPHA_EV56
642 #ifdef CONFIG_ALPHA_EV67
645 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
648 #ifdef CONFIG_VERBOSE_MCHECK
652 #ifdef CONFIG_DISCONTIGMEM
659 #ifdef CONFIG_DEBUG_SPINLOCK
662 #ifdef CONFIG_MAGIC_SYSRQ
667 printk("Command line: %s\n", command_line);
671 * Save the SRM's current value for restoration.
673 srm_hae = *alpha_mv.hae_register;
674 __set_hae(alpha_mv.hae_cache);
676 /* Reset enable correctable error reports. */
679 /* Find our memory. */
680 setup_memory(kernel_end);
682 /* First guess at cpu cache sizes. Do this before init_arch. */
683 determine_cpu_caches(cpu->type);
685 /* Initialize the machine. Usually has to do with setting up
686 DMA windows and the like. */
687 if (alpha_mv.init_arch)
688 alpha_mv.init_arch();
690 /* Reserve standard resources. */
691 reserve_std_resources();
694 * Give us a default console. TGA users will see nothing until
695 * chr_dev_init is called, rather late in the boot sequence.
699 #if defined(CONFIG_VGA_CONSOLE)
700 conswitchp = &vga_con;
701 #elif defined(CONFIG_DUMMY_CONSOLE)
702 conswitchp = &dummy_con;
706 /* Default root filesystem to sda2. */
707 ROOT_DEV = Root_SDA2;
710 /* FIXME: only set this when we actually have EISA in this box? */
715 * Check ASN in HWRPB for validity, report if bad.
716 * FIXME: how was this failing? Should we trust it instead,
717 * and copy the value into alpha_mv.max_asn?
720 if (hwrpb->max_asn != MAX_ASN) {
721 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
725 * Identify the flock of penguins.
735 disable_early_printk(void)
737 if (alpha_using_srm && srmcons_output) {
738 unregister_srm_console();
743 static char sys_unknown[] = "Unknown";
744 static char systype_names[][16] = {
746 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
747 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
748 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
749 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
750 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
751 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
752 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
755 static char unofficial_names[][8] = {"100", "Ruffian"};
757 static char api_names[][16] = {"200", "Nautilus"};
759 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
760 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
762 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
763 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
765 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
766 static int eb64p_indices[] = {0,0,1,2};
768 static char eb66_names[][8] = {"EB66", "EB66+"};
769 static int eb66_indices[] = {0,0,1};
771 static char marvel_names[][16] = {
774 static int marvel_indices[] = { 0 };
776 static char rawhide_names[][16] = {
777 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
779 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
781 static char titan_names[][16] = {
782 "DEFAULT", "Privateer", "Falcon", "Granite"
784 static int titan_indices[] = {0,1,2,2,3};
786 static char tsunami_names[][16] = {
787 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
788 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
789 "Flying Clipper", "Shark"
791 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
793 static struct alpha_machine_vector * __init
794 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
796 static struct alpha_machine_vector *systype_vecs[] __initdata =
803 NULL, /* Mannequin */
807 NULL, /* Sable -- see below. */
810 NULL, /* Turbolaser */
813 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
814 NULL, /* Tradewind */
815 NULL, /* Mikasa -- see below. */
817 NULL, /* EB66 -- see variation. */
818 NULL, /* EB64+ -- see variation. */
824 NULL, /* EB164 -- see variation. */
825 NULL, /* Noritake -- see below. */
832 NULL, /* Tsunami -- see variation. */
833 &wildfire_mv, /* Wildfire */
835 &eiger_mv, /* Eiger */
840 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
846 static struct alpha_machine_vector *api_vecs[] __initdata =
852 static struct alpha_machine_vector *alcor_vecs[] __initdata =
854 &alcor_mv, &xlt_mv, &xlt_mv
857 static struct alpha_machine_vector *eb164_vecs[] __initdata =
859 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
862 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
866 &cabriolet_mv /* AlphaPCI64 */
869 static struct alpha_machine_vector *eb66_vecs[] __initdata =
875 static struct alpha_machine_vector *marvel_vecs[] __initdata =
880 static struct alpha_machine_vector *titan_vecs[] __initdata =
882 &titan_mv, /* default */
883 &privateer_mv, /* privateer */
884 &titan_mv, /* falcon */
885 &privateer_mv, /* granite */
888 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
891 &dp264_mv, /* dp264 */
892 &dp264_mv, /* warhol */
893 &dp264_mv, /* windjammer */
894 &monet_mv, /* monet */
895 &clipper_mv, /* clipper */
896 &dp264_mv, /* goldrush */
897 &webbrick_mv, /* webbrick */
898 &dp264_mv, /* catamaran */
899 NULL, /* brisbane? */
900 NULL, /* melbourne? */
901 NULL, /* flying clipper? */
902 &shark_mv, /* shark */
905 /* ??? Do we need to distinguish between Rawhides? */
907 struct alpha_machine_vector *vec;
909 /* Search the system tables first... */
911 if (type < N(systype_vecs)) {
912 vec = systype_vecs[type];
913 } else if ((type > ST_API_BIAS) &&
914 (type - ST_API_BIAS) < N(api_vecs)) {
915 vec = api_vecs[type - ST_API_BIAS];
916 } else if ((type > ST_UNOFFICIAL_BIAS) &&
917 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_vecs)) {
918 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
921 /* If we've not found one, try for a variation. */
924 /* Member ID is a bit-field. */
925 unsigned long member = (variation >> 10) & 0x3f;
927 cpu &= 0xffffffff; /* make it usable */
931 if (member < N(alcor_indices))
932 vec = alcor_vecs[alcor_indices[member]];
935 if (member < N(eb164_indices))
936 vec = eb164_vecs[eb164_indices[member]];
937 /* PC164 may show as EB164 variation with EV56 CPU,
938 but, since no true EB164 had anything but EV5... */
939 if (vec == &eb164_mv && cpu == EV56_CPU)
943 if (member < N(eb64p_indices))
944 vec = eb64p_vecs[eb64p_indices[member]];
947 if (member < N(eb66_indices))
948 vec = eb66_vecs[eb66_indices[member]];
951 if (member < N(marvel_indices))
952 vec = marvel_vecs[marvel_indices[member]];
955 vec = titan_vecs[0]; /* default */
956 if (member < N(titan_indices))
957 vec = titan_vecs[titan_indices[member]];
960 if (member < N(tsunami_indices))
961 vec = tsunami_vecs[tsunami_indices[member]];
964 if (cpu == EV5_CPU || cpu == EV56_CPU)
965 vec = &mikasa_primo_mv;
969 case ST_DEC_NORITAKE:
970 if (cpu == EV5_CPU || cpu == EV56_CPU)
971 vec = &noritake_primo_mv;
975 case ST_DEC_2100_A500:
976 if (cpu == EV5_CPU || cpu == EV56_CPU)
977 vec = &sable_gamma_mv;
986 static struct alpha_machine_vector * __init
987 get_sysvec_byname(const char *name)
989 static struct alpha_machine_vector *all_vecs[] __initdata =
1032 for (i = 0; i < N(all_vecs); ++i) {
1033 struct alpha_machine_vector *mv = all_vecs[i];
1034 if (strcasecmp(mv->vector_name, name) == 0)
1041 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
1042 char **type_name, char **variation_name)
1044 unsigned long member;
1046 /* If not in the tables, make it UNKNOWN,
1047 else set type name to family */
1048 if (type < N(systype_names)) {
1049 *type_name = systype_names[type];
1050 } else if ((type > ST_API_BIAS) &&
1051 (type - ST_API_BIAS) < N(api_names)) {
1052 *type_name = api_names[type - ST_API_BIAS];
1053 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1054 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_names)) {
1055 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1057 *type_name = sys_unknown;
1058 *variation_name = sys_unknown;
1062 /* Set variation to "0"; if variation is zero, done. */
1063 *variation_name = systype_names[0];
1064 if (variation == 0) {
1068 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1070 cpu &= 0xffffffff; /* make it usable */
1072 switch (type) { /* select by family */
1073 default: /* default to variation "0" for now */
1076 if (member < N(eb164_indices))
1077 *variation_name = eb164_names[eb164_indices[member]];
1078 /* PC164 may show as EB164 variation, but with EV56 CPU,
1079 so, since no true EB164 had anything but EV5... */
1080 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1081 *variation_name = eb164_names[1]; /* make it PC164 */
1084 if (member < N(alcor_indices))
1085 *variation_name = alcor_names[alcor_indices[member]];
1088 if (member < N(eb64p_indices))
1089 *variation_name = eb64p_names[eb64p_indices[member]];
1092 if (member < N(eb66_indices))
1093 *variation_name = eb66_names[eb66_indices[member]];
1096 if (member < N(marvel_indices))
1097 *variation_name = marvel_names[marvel_indices[member]];
1099 case ST_DEC_RAWHIDE:
1100 if (member < N(rawhide_indices))
1101 *variation_name = rawhide_names[rawhide_indices[member]];
1104 *variation_name = titan_names[0]; /* default */
1105 if (member < N(titan_indices))
1106 *variation_name = titan_names[titan_indices[member]];
1108 case ST_DEC_TSUNAMI:
1109 if (member < N(tsunami_indices))
1110 *variation_name = tsunami_names[tsunami_indices[member]];
1116 * A change was made to the HWRPB via an ECO and the following code
1117 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1118 * was not implemented in the console firmware. If it's revision 5 or
1119 * greater we can get the name of the platform as an ASCII string from
1120 * the HWRPB. That's what this function does. It checks the revision
1121 * level and if the string is in the HWRPB it returns the address of
1122 * the string--a pointer to the name of the platform.
1125 * - Pointer to a ASCII string if it's in the HWRPB
1126 * - Pointer to a blank string if the data is not in the HWRPB.
1130 platform_string(void)
1132 struct dsr_struct *dsr;
1133 static char unk_system_string[] = "N/A";
1135 /* Go to the console for the string pointer.
1136 * If the rpb_vers is not 5 or greater the rpb
1137 * is old and does not have this data in it.
1139 if (hwrpb->revision < 5)
1140 return (unk_system_string);
1142 /* The Dynamic System Recognition struct
1143 * has the system platform name starting
1144 * after the character count of the string.
1146 dsr = ((struct dsr_struct *)
1147 ((char *)hwrpb + hwrpb->dsr_offset));
1148 return ((char *)dsr + (dsr->sysname_off +
1154 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1156 struct percpu_struct *cpu;
1160 for (i = 0; i < num; i++) {
1161 cpu = (struct percpu_struct *)
1162 ((char *)cpubase + i*hwrpb->processor_size);
1163 if ((cpu->flags & 0x1cc) == 0x1cc)
1170 show_cache_size (struct seq_file *f, const char *which, int shape)
1173 seq_printf (f, "%s\t\t: n/a\n", which);
1174 else if (shape == 0)
1175 seq_printf (f, "%s\t\t: unknown\n", which);
1177 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1178 which, shape >> 10, shape & 15,
1179 1 << ((shape >> 4) & 15));
1183 show_cpuinfo(struct seq_file *f, void *slot)
1185 extern struct unaligned_stat {
1186 unsigned long count, va, pc;
1189 static char cpu_names[][8] = {
1190 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1191 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1192 "EV68CX", "EV7", "EV79", "EV69"
1195 struct percpu_struct *cpu = slot;
1196 unsigned int cpu_index;
1199 char *sysvariation_name;
1202 cpu_index = (unsigned) (cpu->type - 1);
1203 cpu_name = "Unknown";
1204 if (cpu_index < N(cpu_names))
1205 cpu_name = cpu_names[cpu_index];
1207 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1208 cpu->type, &systype_name, &sysvariation_name);
1210 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1212 seq_printf(f, "cpu\t\t\t: Alpha\n"
1213 "cpu model\t\t: %s\n"
1214 "cpu variation\t\t: %ld\n"
1215 "cpu revision\t\t: %ld\n"
1216 "cpu serial number\t: %s\n"
1217 "system type\t\t: %s\n"
1218 "system variation\t: %s\n"
1219 "system revision\t\t: %ld\n"
1220 "system serial number\t: %s\n"
1221 "cycle frequency [Hz]\t: %lu %s\n"
1222 "timer frequency [Hz]\t: %lu.%02lu\n"
1223 "page size [bytes]\t: %ld\n"
1224 "phys. address bits\t: %ld\n"
1225 "max. addr. space #\t: %ld\n"
1226 "BogoMIPS\t\t: %lu.%02lu\n"
1227 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1228 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1229 "platform string\t\t: %s\n"
1230 "cpus detected\t\t: %d\n",
1231 cpu_name, cpu->variation, cpu->revision,
1232 (char*)cpu->serial_no,
1233 systype_name, sysvariation_name, hwrpb->sys_revision,
1235 est_cycle_freq ? : hwrpb->cycle_freq,
1236 est_cycle_freq ? "est." : "",
1237 hwrpb->intr_freq / 4096,
1238 (100 * hwrpb->intr_freq / 4096) % 100,
1242 loops_per_jiffy / (500000/HZ),
1243 (loops_per_jiffy / (5000/HZ)) % 100,
1244 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1245 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1246 platform_string(), nr_processors);
1249 seq_printf(f, "cpus active\t\t: %ld\n"
1250 "cpu active mask\t\t: %016lx\n",
1251 num_online_cpus(), cpu_present_mask);
1254 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1255 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1256 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1257 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1263 read_mem_block(int *addr, int stride, int size)
1265 long nloads = size / stride, cnt, tmp;
1267 __asm__ __volatile__(
1271 /* Next two XORs introduce an explicit data dependency between
1272 consecutive loads in the loop, which will give us true load
1280 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1281 : "r" (stride), "1" (nloads), "2" (addr));
1283 return cnt / (size / stride);
1286 #define CSHAPE(totalsize, linesize, assoc) \
1287 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1289 /* ??? EV5 supports up to 64M, but did the systems with more than
1290 16M of BCACHE ever exist? */
1291 #define MAX_BCACHE_SIZE 16*1024*1024
1293 /* Note that the offchip caches are direct mapped on all Alphas. */
1295 external_cache_probe(int minsize, int width)
1297 int cycles, prev_cycles = 1000000;
1298 int stride = 1 << width;
1299 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1301 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1302 maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
1304 /* Get the first block cached. */
1305 read_mem_block(__va(0), stride, size);
1307 while (size < maxsize) {
1308 /* Get an average load latency in cycles. */
1309 cycles = read_mem_block(__va(0), stride, size);
1310 if (cycles > prev_cycles * 2) {
1311 /* Fine, we exceed the cache. */
1312 printk("%ldK Bcache detected; load hit latency %d "
1313 "cycles, load miss latency %d cycles\n",
1314 size >> 11, prev_cycles, cycles);
1315 return CSHAPE(size >> 1, width, 1);
1317 /* Try to get the next block cached. */
1318 read_mem_block(__va(size), stride, size);
1319 prev_cycles = cycles;
1322 return -1; /* No BCACHE found. */
1326 determine_cpu_caches (unsigned int cpu_type)
1328 int L1I, L1D, L2, L3;
1334 if (cpu_type == EV4_CPU)
1335 L1I = CSHAPE(8*1024, 5, 1);
1337 L1I = CSHAPE(16*1024, 5, 1);
1341 /* BIU_CTL is a write-only Abox register. PALcode has a
1342 shadow copy, and may be available from some versions
1343 of the CSERVE PALcall. If we can get it, then
1345 unsigned long biu_ctl, size;
1346 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1347 L2 = CSHAPE (size, 5, 1);
1349 Unfortunately, we can't rely on that.
1351 L2 = external_cache_probe(128*1024, 5);
1357 unsigned long car, size;
1359 L1I = L1D = CSHAPE(8*1024, 5, 1);
1362 car = *(vuip) phys_to_virt (0x120000078);
1363 size = 64*1024 * (1 << ((car >> 5) & 7));
1364 /* No typo -- 8 byte cacheline size. Whodathunk. */
1365 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1372 unsigned long sc_ctl, width;
1374 L1I = L1D = CSHAPE(8*1024, 5, 1);
1376 /* Check the line size of the Scache. */
1377 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8);
1378 width = sc_ctl & 0x1000 ? 6 : 5;
1379 L2 = CSHAPE (96*1024, width, 3);
1381 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1382 has a shadow copy, and may be available from some versions
1383 of the CSERVE PALcall. If we can get it, then
1385 unsigned long bc_control, bc_config, size;
1386 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1387 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1389 Unfortunately, we can't rely on that.
1391 L3 = external_cache_probe(1024*1024, width);
1398 unsigned long cbox_config, size;
1400 if (cpu_type == PCA56_CPU) {
1401 L1I = CSHAPE(16*1024, 6, 1);
1402 L1D = CSHAPE(8*1024, 5, 1);
1404 L1I = CSHAPE(32*1024, 6, 2);
1405 L1D = CSHAPE(16*1024, 5, 1);
1409 cbox_config = *(vulp) phys_to_virt (0xfffff00008);
1410 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1413 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1415 L2 = external_cache_probe(512*1024, 6);
1426 L1I = L1D = CSHAPE(64*1024, 6, 2);
1427 L2 = external_cache_probe(1024*1024, 6);
1433 L1I = L1D = CSHAPE(64*1024, 6, 2);
1434 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1439 /* Nothing known about this cpu type. */
1440 L1I = L1D = L2 = L3 = 0;
1444 alpha_l1i_cacheshape = L1I;
1445 alpha_l1d_cacheshape = L1D;
1446 alpha_l2_cacheshape = L2;
1447 alpha_l3_cacheshape = L3;
1451 * We show only CPU #0 info.
1454 c_start(struct seq_file *f, loff_t *pos)
1456 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1460 c_next(struct seq_file *f, void *v, loff_t *pos)
1466 c_stop(struct seq_file *f, void *v)
1470 struct seq_operations cpuinfo_op = {
1474 .show = show_cpuinfo,
1479 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1482 /* FIXME FIXME FIXME */
1483 /* If we are using SRM and serial console, just hard halt here. */
1484 if (alpha_using_srm && srmcons_output)