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/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/bootmem.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>
48 extern struct atomic_notifier_head panic_notifier_list;
49 static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
50 static struct notifier_block alpha_panic_block = {
53 INT_MAX /* try to do it first */
56 #include <asm/uaccess.h>
57 #include <asm/pgtable.h>
58 #include <asm/system.h>
59 #include <asm/hwrpb.h>
62 #include <asm/mmu_context.h>
63 #include <asm/console.h>
69 struct hwrpb_struct *hwrpb;
71 unsigned long srm_hae;
73 int alpha_l1i_cacheshape;
74 int alpha_l1d_cacheshape;
75 int alpha_l2_cacheshape;
76 int alpha_l3_cacheshape;
78 #ifdef CONFIG_VERBOSE_MCHECK
79 /* 0=minimum, 1=verbose, 2=all */
80 /* These can be overridden via the command line, ie "verbose_mcheck=2") */
81 unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
84 /* Which processor we booted from. */
88 * Using SRM callbacks for initial console output. This works from
89 * setup_arch() time through the end of time_init(), as those places
90 * are under our (Alpha) control.
92 * "srmcons" specified in the boot command arguments allows us to
93 * see kernel messages during the period of time before the true
94 * console device is "registered" during console_init().
95 * As of this version (2.5.59), console_init() will call
96 * disable_early_printk() as the last action before initializing
97 * the console drivers. That's the last possible time srmcons can be
98 * unregistered without interfering with console behavior.
100 * By default, OFF; set it with a bootcommand arg of "srmcons" or
101 * "console=srm". The meaning of these two args is:
102 * "srmcons" - early callback prints
103 * "console=srm" - full callback based console, including early prints
105 int srmcons_output = 0;
107 /* Enforce a memory size limit; useful for testing. By default, none. */
108 unsigned long mem_size_limit = 0;
110 /* Set AGP GART window size (0 means disabled). */
111 unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
113 #ifdef CONFIG_ALPHA_GENERIC
114 struct alpha_machine_vector alpha_mv;
116 EXPORT_SYMBOL(alpha_using_srm);
119 static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
121 static struct alpha_machine_vector *get_sysvec_byname(const char *);
122 static void get_sysnames(unsigned long, unsigned long, unsigned long,
124 static void determine_cpu_caches (unsigned int);
126 static char __initdata command_line[COMMAND_LINE_SIZE];
129 * The format of "screen_info" is strange, and due to early
130 * i386-setup code. This is just enough to make the console
131 * code think we're on a VGA color display.
134 struct screen_info screen_info = {
137 .orig_video_cols = 80,
138 .orig_video_lines = 25,
139 .orig_video_isVGA = 1,
140 .orig_video_points = 16
143 EXPORT_SYMBOL(screen_info);
146 * The direct map I/O window, if any. This should be the same
147 * for all busses, since it's used by virt_to_bus.
150 unsigned long __direct_map_base;
151 unsigned long __direct_map_size;
152 EXPORT_SYMBOL(__direct_map_base);
153 EXPORT_SYMBOL(__direct_map_size);
156 * Declare all of the machine vectors.
159 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
160 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
164 extern struct alpha_machine_vector X; \
184 WEAK(mikasa_primo_mv);
189 WEAK(noritake_primo_mv);
197 WEAK(sable_gamma_mv);
210 * I/O resources inherited from PeeCees. Except for perhaps the
211 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
213 * ??? If this becomes less standard, move the struct out into the
218 reserve_std_resources(void)
220 static struct resource standard_io_resources[] = {
221 { .name = "rtc", .start = -1, .end = -1 },
222 { .name = "dma1", .start = 0x00, .end = 0x1f },
223 { .name = "pic1", .start = 0x20, .end = 0x3f },
224 { .name = "timer", .start = 0x40, .end = 0x5f },
225 { .name = "keyboard", .start = 0x60, .end = 0x6f },
226 { .name = "dma page reg", .start = 0x80, .end = 0x8f },
227 { .name = "pic2", .start = 0xa0, .end = 0xbf },
228 { .name = "dma2", .start = 0xc0, .end = 0xdf },
231 struct resource *io = &ioport_resource;
235 struct pci_controller *hose;
236 for (hose = hose_head; hose; hose = hose->next)
237 if (hose->index == 0) {
243 /* Fix up for the Jensen's queer RTC placement. */
244 standard_io_resources[0].start = RTC_PORT(0);
245 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
247 for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i)
248 request_resource(io, standard_io_resources+i);
251 #define PFN_MAX PFN_DOWN(0x80000000)
252 #define for_each_mem_cluster(memdesc, cluster, i) \
253 for ((cluster) = (memdesc)->cluster, (i) = 0; \
254 (i) < (memdesc)->numclusters; (i)++, (cluster)++)
256 static unsigned long __init
257 get_mem_size_limit(char *s)
259 unsigned long end = 0;
262 end = simple_strtoul(from, &from, 0);
263 if ( *from == 'K' || *from == 'k' ) {
266 } else if ( *from == 'M' || *from == 'm' ) {
269 } else if ( *from == 'G' || *from == 'g' ) {
273 return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
276 #ifdef CONFIG_BLK_DEV_INITRD
278 move_initrd(unsigned long mem_limit)
283 size = initrd_end - initrd_start;
284 start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
285 if (!start || __pa(start) + size > mem_limit) {
286 initrd_start = initrd_end = 0;
289 memmove(start, (void *)initrd_start, size);
290 initrd_start = (unsigned long)start;
291 initrd_end = initrd_start + size;
292 printk("initrd moved to %p\n", start);
297 #ifndef CONFIG_DISCONTIGMEM
299 setup_memory(void *kernel_end)
301 struct memclust_struct * cluster;
302 struct memdesc_struct * memdesc;
303 unsigned long start_kernel_pfn, end_kernel_pfn;
304 unsigned long bootmap_size, bootmap_pages, bootmap_start;
305 unsigned long start, end;
308 /* Find free clusters, and init and free the bootmem accordingly. */
309 memdesc = (struct memdesc_struct *)
310 (hwrpb->mddt_offset + (unsigned long) hwrpb);
312 for_each_mem_cluster(memdesc, cluster, i) {
313 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
314 i, cluster->usage, cluster->start_pfn,
315 cluster->start_pfn + cluster->numpages);
317 /* Bit 0 is console/PALcode reserved. Bit 1 is
318 non-volatile memory -- we might want to mark
320 if (cluster->usage & 3)
323 end = cluster->start_pfn + cluster->numpages;
324 if (end > max_low_pfn)
329 * Except for the NUMA systems (wildfire, marvel) all of the
330 * Alpha systems we run on support 32GB of memory or less.
331 * Since the NUMA systems introduce large holes in memory addressing,
332 * we can get into a situation where there is not enough contiguous
333 * memory for the memory map.
335 * Limit memory to the first 32GB to limit the NUMA systems to
336 * memory on their first node (wildfire) or 2 (marvel) to avoid
337 * not being able to produce the memory map. In order to access
338 * all of the memory on the NUMA systems, build with discontiguous
341 * If the user specified a memory limit, let that memory limit stand.
344 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
346 if (mem_size_limit && max_low_pfn >= mem_size_limit)
348 printk("setup: forcing memory size to %ldK (from %ldK).\n",
349 mem_size_limit << (PAGE_SHIFT - 10),
350 max_low_pfn << (PAGE_SHIFT - 10));
351 max_low_pfn = mem_size_limit;
354 /* Find the bounds of kernel memory. */
355 start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
356 end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
360 if (max_low_pfn <= end_kernel_pfn)
361 panic("not enough memory to boot");
363 /* We need to know how many physically contiguous pages
364 we'll need for the bootmap. */
365 bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
367 /* Now find a good region where to allocate the bootmap. */
368 for_each_mem_cluster(memdesc, cluster, i) {
369 if (cluster->usage & 3)
372 start = cluster->start_pfn;
373 end = start + cluster->numpages;
374 if (start >= max_low_pfn)
376 if (end > max_low_pfn)
378 if (start < start_kernel_pfn) {
379 if (end > end_kernel_pfn
380 && end - end_kernel_pfn >= bootmap_pages) {
381 bootmap_start = end_kernel_pfn;
383 } else if (end > start_kernel_pfn)
384 end = start_kernel_pfn;
385 } else if (start < end_kernel_pfn)
386 start = end_kernel_pfn;
387 if (end - start >= bootmap_pages) {
388 bootmap_start = start;
393 if (bootmap_start == ~0UL) {
398 /* Allocate the bootmap and mark the whole MM as reserved. */
399 bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
401 /* Mark the free regions. */
402 for_each_mem_cluster(memdesc, cluster, i) {
403 if (cluster->usage & 3)
406 start = cluster->start_pfn;
407 end = cluster->start_pfn + cluster->numpages;
408 if (start >= max_low_pfn)
410 if (end > max_low_pfn)
412 if (start < start_kernel_pfn) {
413 if (end > end_kernel_pfn) {
414 free_bootmem(PFN_PHYS(start),
415 (PFN_PHYS(start_kernel_pfn)
417 printk("freeing pages %ld:%ld\n",
418 start, start_kernel_pfn);
419 start = end_kernel_pfn;
420 } else if (end > start_kernel_pfn)
421 end = start_kernel_pfn;
422 } else if (start < end_kernel_pfn)
423 start = end_kernel_pfn;
427 free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
428 printk("freeing pages %ld:%ld\n", start, end);
431 /* Reserve the bootmap memory. */
432 reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size);
433 printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
435 #ifdef CONFIG_BLK_DEV_INITRD
436 initrd_start = INITRD_START;
438 initrd_end = initrd_start+INITRD_SIZE;
439 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
440 (void *) initrd_start, INITRD_SIZE);
442 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
443 if (!move_initrd(PFN_PHYS(max_low_pfn)))
444 printk("initrd extends beyond end of memory "
445 "(0x%08lx > 0x%p)\ndisabling initrd\n",
447 phys_to_virt(PFN_PHYS(max_low_pfn)));
449 reserve_bootmem(virt_to_phys((void *)initrd_start),
453 #endif /* CONFIG_BLK_DEV_INITRD */
456 extern void setup_memory(void *);
457 #endif /* !CONFIG_DISCONTIGMEM */
460 page_is_ram(unsigned long pfn)
462 struct memclust_struct * cluster;
463 struct memdesc_struct * memdesc;
466 memdesc = (struct memdesc_struct *)
467 (hwrpb->mddt_offset + (unsigned long) hwrpb);
468 for_each_mem_cluster(memdesc, cluster, i)
470 if (pfn >= cluster->start_pfn &&
471 pfn < cluster->start_pfn + cluster->numpages) {
472 return (cluster->usage & 3) ? 0 : 1;
484 for_each_possible_cpu(i) {
485 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
493 arch_initcall(register_cpus);
496 setup_arch(char **cmdline_p)
500 struct alpha_machine_vector *vec = NULL;
501 struct percpu_struct *cpu;
502 char *type_name, *var_name, *p;
503 void *kernel_end = _end; /* end of kernel */
504 char *args = command_line;
506 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
507 boot_cpuid = hard_smp_processor_id();
510 * Pre-process the system type to make sure it will be valid.
512 * This may restore real CABRIO and EB66+ family names, ie
515 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
516 * and AS1200 (DIGITAL Server 5000 series) have the type as
517 * the negative of the real one.
519 if ((long)hwrpb->sys_type < 0) {
520 hwrpb->sys_type = -((long)hwrpb->sys_type);
521 hwrpb_update_checksum(hwrpb);
524 /* Register a call for panic conditions. */
525 atomic_notifier_chain_register(&panic_notifier_list,
528 #ifdef CONFIG_ALPHA_GENERIC
529 /* Assume that we've booted from SRM if we haven't booted from MILO.
530 Detect the later by looking for "MILO" in the system serial nr. */
531 alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
534 /* If we are using SRM, we want to allow callbacks
535 as early as possible, so do this NOW, and then
536 they should work immediately thereafter.
538 kernel_end = callback_init(kernel_end);
541 * Locate the command line.
543 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
544 boot flags depending on the boot mode, we need some shorthand.
545 This should do for installation. */
546 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
547 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
549 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
551 strcpy(boot_command_line, command_line);
552 *cmdline_p = command_line;
555 * Process command-line arguments.
557 while ((p = strsep(&args, " \t")) != NULL) {
559 if (strncmp(p, "alpha_mv=", 9) == 0) {
560 vec = get_sysvec_byname(p+9);
563 if (strncmp(p, "cycle=", 6) == 0) {
564 est_cycle_freq = simple_strtol(p+6, NULL, 0);
567 if (strncmp(p, "mem=", 4) == 0) {
568 mem_size_limit = get_mem_size_limit(p+4);
571 if (strncmp(p, "srmcons", 7) == 0) {
575 if (strncmp(p, "console=srm", 11) == 0) {
579 if (strncmp(p, "gartsize=", 9) == 0) {
581 get_mem_size_limit(p+9) << PAGE_SHIFT;
584 #ifdef CONFIG_VERBOSE_MCHECK
585 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
586 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
592 /* Replace the command line, now that we've killed it with strsep. */
593 strcpy(command_line, boot_command_line);
595 /* If we want SRM console printk echoing early, do it now. */
596 if (alpha_using_srm && srmcons_output) {
597 register_srm_console();
600 * If "console=srm" was specified, clear the srmcons_output
601 * flag now so that time.c won't unregister_srm_console
603 if (srmcons_output & 2)
607 #ifdef CONFIG_MAGIC_SYSRQ
608 /* If we're using SRM, make sysrq-b halt back to the prom,
610 if (alpha_using_srm) {
611 struct sysrq_key_op *op = __sysrq_get_key_op('b');
612 op->handler = (void *) machine_halt;
617 * Identify and reconfigure for the current system.
619 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
621 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
622 cpu->type, &type_name, &var_name);
623 if (*var_name == '0')
627 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
632 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
633 type_name, (*var_name ? " variation " : ""), var_name,
634 hwrpb->sys_type, hwrpb->sys_variation);
636 if (vec != &alpha_mv) {
641 #ifdef CONFIG_ALPHA_GENERIC
644 "on %s%s%s using machine vector %s from %s\n",
645 type_name, (*var_name ? " variation " : ""),
646 var_name, alpha_mv.vector_name,
647 (alpha_using_srm ? "SRM" : "MILO"));
649 printk("Major Options: "
653 #ifdef CONFIG_ALPHA_EV56
656 #ifdef CONFIG_ALPHA_EV67
659 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
662 #ifdef CONFIG_VERBOSE_MCHECK
666 #ifdef CONFIG_DISCONTIGMEM
673 #ifdef CONFIG_DEBUG_SPINLOCK
676 #ifdef CONFIG_MAGIC_SYSRQ
681 printk("Command line: %s\n", command_line);
685 * Save the SRM's current value for restoration.
687 srm_hae = *alpha_mv.hae_register;
688 __set_hae(alpha_mv.hae_cache);
690 /* Reset enable correctable error reports. */
693 /* Find our memory. */
694 setup_memory(kernel_end);
696 /* First guess at cpu cache sizes. Do this before init_arch. */
697 determine_cpu_caches(cpu->type);
699 /* Initialize the machine. Usually has to do with setting up
700 DMA windows and the like. */
701 if (alpha_mv.init_arch)
702 alpha_mv.init_arch();
704 /* Reserve standard resources. */
705 reserve_std_resources();
708 * Give us a default console. TGA users will see nothing until
709 * chr_dev_init is called, rather late in the boot sequence.
713 #if defined(CONFIG_VGA_CONSOLE)
714 conswitchp = &vga_con;
715 #elif defined(CONFIG_DUMMY_CONSOLE)
716 conswitchp = &dummy_con;
720 /* Default root filesystem to sda2. */
721 ROOT_DEV = Root_SDA2;
724 /* FIXME: only set this when we actually have EISA in this box? */
729 * Check ASN in HWRPB for validity, report if bad.
730 * FIXME: how was this failing? Should we trust it instead,
731 * and copy the value into alpha_mv.max_asn?
734 if (hwrpb->max_asn != MAX_ASN) {
735 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
739 * Identify the flock of penguins.
748 static char sys_unknown[] = "Unknown";
749 static char systype_names[][16] = {
751 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
752 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
753 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
754 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
755 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
756 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
757 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
760 static char unofficial_names[][8] = {"100", "Ruffian"};
762 static char api_names[][16] = {"200", "Nautilus"};
764 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
765 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
767 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
768 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
770 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
771 static int eb64p_indices[] = {0,0,1,2};
773 static char eb66_names[][8] = {"EB66", "EB66+"};
774 static int eb66_indices[] = {0,0,1};
776 static char marvel_names[][16] = {
779 static int marvel_indices[] = { 0 };
781 static char rawhide_names[][16] = {
782 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
784 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
786 static char titan_names[][16] = {
787 "DEFAULT", "Privateer", "Falcon", "Granite"
789 static int titan_indices[] = {0,1,2,2,3};
791 static char tsunami_names[][16] = {
792 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
793 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
794 "Flying Clipper", "Shark"
796 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
798 static struct alpha_machine_vector * __init
799 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
801 static struct alpha_machine_vector *systype_vecs[] __initdata =
808 NULL, /* Mannequin */
812 NULL, /* Sable -- see below. */
815 NULL, /* Turbolaser */
818 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
819 NULL, /* Tradewind */
820 NULL, /* Mikasa -- see below. */
822 NULL, /* EB66 -- see variation. */
823 NULL, /* EB64+ -- see variation. */
829 NULL, /* EB164 -- see variation. */
830 NULL, /* Noritake -- see below. */
837 NULL, /* Tsunami -- see variation. */
838 &wildfire_mv, /* Wildfire */
840 &eiger_mv, /* Eiger */
845 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
851 static struct alpha_machine_vector *api_vecs[] __initdata =
857 static struct alpha_machine_vector *alcor_vecs[] __initdata =
859 &alcor_mv, &xlt_mv, &xlt_mv
862 static struct alpha_machine_vector *eb164_vecs[] __initdata =
864 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
867 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
871 &cabriolet_mv /* AlphaPCI64 */
874 static struct alpha_machine_vector *eb66_vecs[] __initdata =
880 static struct alpha_machine_vector *marvel_vecs[] __initdata =
885 static struct alpha_machine_vector *titan_vecs[] __initdata =
887 &titan_mv, /* default */
888 &privateer_mv, /* privateer */
889 &titan_mv, /* falcon */
890 &privateer_mv, /* granite */
893 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
896 &dp264_mv, /* dp264 */
897 &dp264_mv, /* warhol */
898 &dp264_mv, /* windjammer */
899 &monet_mv, /* monet */
900 &clipper_mv, /* clipper */
901 &dp264_mv, /* goldrush */
902 &webbrick_mv, /* webbrick */
903 &dp264_mv, /* catamaran */
904 NULL, /* brisbane? */
905 NULL, /* melbourne? */
906 NULL, /* flying clipper? */
907 &shark_mv, /* shark */
910 /* ??? Do we need to distinguish between Rawhides? */
912 struct alpha_machine_vector *vec;
914 /* Search the system tables first... */
916 if (type < ARRAY_SIZE(systype_vecs)) {
917 vec = systype_vecs[type];
918 } else if ((type > ST_API_BIAS) &&
919 (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
920 vec = api_vecs[type - ST_API_BIAS];
921 } else if ((type > ST_UNOFFICIAL_BIAS) &&
922 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
923 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
926 /* If we've not found one, try for a variation. */
929 /* Member ID is a bit-field. */
930 unsigned long member = (variation >> 10) & 0x3f;
932 cpu &= 0xffffffff; /* make it usable */
936 if (member < ARRAY_SIZE(alcor_indices))
937 vec = alcor_vecs[alcor_indices[member]];
940 if (member < ARRAY_SIZE(eb164_indices))
941 vec = eb164_vecs[eb164_indices[member]];
942 /* PC164 may show as EB164 variation with EV56 CPU,
943 but, since no true EB164 had anything but EV5... */
944 if (vec == &eb164_mv && cpu == EV56_CPU)
948 if (member < ARRAY_SIZE(eb64p_indices))
949 vec = eb64p_vecs[eb64p_indices[member]];
952 if (member < ARRAY_SIZE(eb66_indices))
953 vec = eb66_vecs[eb66_indices[member]];
956 if (member < ARRAY_SIZE(marvel_indices))
957 vec = marvel_vecs[marvel_indices[member]];
960 vec = titan_vecs[0]; /* default */
961 if (member < ARRAY_SIZE(titan_indices))
962 vec = titan_vecs[titan_indices[member]];
965 if (member < ARRAY_SIZE(tsunami_indices))
966 vec = tsunami_vecs[tsunami_indices[member]];
969 if (cpu == EV5_CPU || cpu == EV56_CPU)
970 vec = &mikasa_primo_mv;
974 case ST_DEC_NORITAKE:
975 if (cpu == EV5_CPU || cpu == EV56_CPU)
976 vec = &noritake_primo_mv;
980 case ST_DEC_2100_A500:
981 if (cpu == EV5_CPU || cpu == EV56_CPU)
982 vec = &sable_gamma_mv;
991 static struct alpha_machine_vector * __init
992 get_sysvec_byname(const char *name)
994 static struct alpha_machine_vector *all_vecs[] __initdata =
1037 for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
1038 struct alpha_machine_vector *mv = all_vecs[i];
1039 if (strcasecmp(mv->vector_name, name) == 0)
1046 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
1047 char **type_name, char **variation_name)
1049 unsigned long member;
1051 /* If not in the tables, make it UNKNOWN,
1052 else set type name to family */
1053 if (type < ARRAY_SIZE(systype_names)) {
1054 *type_name = systype_names[type];
1055 } else if ((type > ST_API_BIAS) &&
1056 (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
1057 *type_name = api_names[type - ST_API_BIAS];
1058 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1059 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
1060 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1062 *type_name = sys_unknown;
1063 *variation_name = sys_unknown;
1067 /* Set variation to "0"; if variation is zero, done. */
1068 *variation_name = systype_names[0];
1069 if (variation == 0) {
1073 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1075 cpu &= 0xffffffff; /* make it usable */
1077 switch (type) { /* select by family */
1078 default: /* default to variation "0" for now */
1081 if (member < ARRAY_SIZE(eb164_indices))
1082 *variation_name = eb164_names[eb164_indices[member]];
1083 /* PC164 may show as EB164 variation, but with EV56 CPU,
1084 so, since no true EB164 had anything but EV5... */
1085 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1086 *variation_name = eb164_names[1]; /* make it PC164 */
1089 if (member < ARRAY_SIZE(alcor_indices))
1090 *variation_name = alcor_names[alcor_indices[member]];
1093 if (member < ARRAY_SIZE(eb64p_indices))
1094 *variation_name = eb64p_names[eb64p_indices[member]];
1097 if (member < ARRAY_SIZE(eb66_indices))
1098 *variation_name = eb66_names[eb66_indices[member]];
1101 if (member < ARRAY_SIZE(marvel_indices))
1102 *variation_name = marvel_names[marvel_indices[member]];
1104 case ST_DEC_RAWHIDE:
1105 if (member < ARRAY_SIZE(rawhide_indices))
1106 *variation_name = rawhide_names[rawhide_indices[member]];
1109 *variation_name = titan_names[0]; /* default */
1110 if (member < ARRAY_SIZE(titan_indices))
1111 *variation_name = titan_names[titan_indices[member]];
1113 case ST_DEC_TSUNAMI:
1114 if (member < ARRAY_SIZE(tsunami_indices))
1115 *variation_name = tsunami_names[tsunami_indices[member]];
1121 * A change was made to the HWRPB via an ECO and the following code
1122 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1123 * was not implemented in the console firmware. If it's revision 5 or
1124 * greater we can get the name of the platform as an ASCII string from
1125 * the HWRPB. That's what this function does. It checks the revision
1126 * level and if the string is in the HWRPB it returns the address of
1127 * the string--a pointer to the name of the platform.
1130 * - Pointer to a ASCII string if it's in the HWRPB
1131 * - Pointer to a blank string if the data is not in the HWRPB.
1135 platform_string(void)
1137 struct dsr_struct *dsr;
1138 static char unk_system_string[] = "N/A";
1140 /* Go to the console for the string pointer.
1141 * If the rpb_vers is not 5 or greater the rpb
1142 * is old and does not have this data in it.
1144 if (hwrpb->revision < 5)
1145 return (unk_system_string);
1147 /* The Dynamic System Recognition struct
1148 * has the system platform name starting
1149 * after the character count of the string.
1151 dsr = ((struct dsr_struct *)
1152 ((char *)hwrpb + hwrpb->dsr_offset));
1153 return ((char *)dsr + (dsr->sysname_off +
1159 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1161 struct percpu_struct *cpu;
1165 for (i = 0; i < num; i++) {
1166 cpu = (struct percpu_struct *)
1167 ((char *)cpubase + i*hwrpb->processor_size);
1168 if ((cpu->flags & 0x1cc) == 0x1cc)
1175 show_cache_size (struct seq_file *f, const char *which, int shape)
1178 seq_printf (f, "%s\t\t: n/a\n", which);
1179 else if (shape == 0)
1180 seq_printf (f, "%s\t\t: unknown\n", which);
1182 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1183 which, shape >> 10, shape & 15,
1184 1 << ((shape >> 4) & 15));
1188 show_cpuinfo(struct seq_file *f, void *slot)
1190 extern struct unaligned_stat {
1191 unsigned long count, va, pc;
1194 static char cpu_names[][8] = {
1195 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1196 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1197 "EV68CX", "EV7", "EV79", "EV69"
1200 struct percpu_struct *cpu = slot;
1201 unsigned int cpu_index;
1204 char *sysvariation_name;
1207 cpu_index = (unsigned) (cpu->type - 1);
1208 cpu_name = "Unknown";
1209 if (cpu_index < ARRAY_SIZE(cpu_names))
1210 cpu_name = cpu_names[cpu_index];
1212 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1213 cpu->type, &systype_name, &sysvariation_name);
1215 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1217 seq_printf(f, "cpu\t\t\t: Alpha\n"
1218 "cpu model\t\t: %s\n"
1219 "cpu variation\t\t: %ld\n"
1220 "cpu revision\t\t: %ld\n"
1221 "cpu serial number\t: %s\n"
1222 "system type\t\t: %s\n"
1223 "system variation\t: %s\n"
1224 "system revision\t\t: %ld\n"
1225 "system serial number\t: %s\n"
1226 "cycle frequency [Hz]\t: %lu %s\n"
1227 "timer frequency [Hz]\t: %lu.%02lu\n"
1228 "page size [bytes]\t: %ld\n"
1229 "phys. address bits\t: %ld\n"
1230 "max. addr. space #\t: %ld\n"
1231 "BogoMIPS\t\t: %lu.%02lu\n"
1232 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1233 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1234 "platform string\t\t: %s\n"
1235 "cpus detected\t\t: %d\n",
1236 cpu_name, cpu->variation, cpu->revision,
1237 (char*)cpu->serial_no,
1238 systype_name, sysvariation_name, hwrpb->sys_revision,
1240 est_cycle_freq ? : hwrpb->cycle_freq,
1241 est_cycle_freq ? "est." : "",
1242 hwrpb->intr_freq / 4096,
1243 (100 * hwrpb->intr_freq / 4096) % 100,
1247 loops_per_jiffy / (500000/HZ),
1248 (loops_per_jiffy / (5000/HZ)) % 100,
1249 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1250 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1251 platform_string(), nr_processors);
1254 seq_printf(f, "cpus active\t\t: %d\n"
1255 "cpu active mask\t\t: %016lx\n",
1256 num_online_cpus(), cpus_addr(cpu_possible_map)[0]);
1259 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1260 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1261 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1262 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1268 read_mem_block(int *addr, int stride, int size)
1270 long nloads = size / stride, cnt, tmp;
1272 __asm__ __volatile__(
1276 /* Next two XORs introduce an explicit data dependency between
1277 consecutive loads in the loop, which will give us true load
1285 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1286 : "r" (stride), "1" (nloads), "2" (addr));
1288 return cnt / (size / stride);
1291 #define CSHAPE(totalsize, linesize, assoc) \
1292 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1294 /* ??? EV5 supports up to 64M, but did the systems with more than
1295 16M of BCACHE ever exist? */
1296 #define MAX_BCACHE_SIZE 16*1024*1024
1298 /* Note that the offchip caches are direct mapped on all Alphas. */
1300 external_cache_probe(int minsize, int width)
1302 int cycles, prev_cycles = 1000000;
1303 int stride = 1 << width;
1304 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1306 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1307 maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
1309 /* Get the first block cached. */
1310 read_mem_block(__va(0), stride, size);
1312 while (size < maxsize) {
1313 /* Get an average load latency in cycles. */
1314 cycles = read_mem_block(__va(0), stride, size);
1315 if (cycles > prev_cycles * 2) {
1316 /* Fine, we exceed the cache. */
1317 printk("%ldK Bcache detected; load hit latency %d "
1318 "cycles, load miss latency %d cycles\n",
1319 size >> 11, prev_cycles, cycles);
1320 return CSHAPE(size >> 1, width, 1);
1322 /* Try to get the next block cached. */
1323 read_mem_block(__va(size), stride, size);
1324 prev_cycles = cycles;
1327 return -1; /* No BCACHE found. */
1331 determine_cpu_caches (unsigned int cpu_type)
1333 int L1I, L1D, L2, L3;
1339 if (cpu_type == EV4_CPU)
1340 L1I = CSHAPE(8*1024, 5, 1);
1342 L1I = CSHAPE(16*1024, 5, 1);
1346 /* BIU_CTL is a write-only Abox register. PALcode has a
1347 shadow copy, and may be available from some versions
1348 of the CSERVE PALcall. If we can get it, then
1350 unsigned long biu_ctl, size;
1351 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1352 L2 = CSHAPE (size, 5, 1);
1354 Unfortunately, we can't rely on that.
1356 L2 = external_cache_probe(128*1024, 5);
1362 unsigned long car, size;
1364 L1I = L1D = CSHAPE(8*1024, 5, 1);
1367 car = *(vuip) phys_to_virt (0x120000078UL);
1368 size = 64*1024 * (1 << ((car >> 5) & 7));
1369 /* No typo -- 8 byte cacheline size. Whodathunk. */
1370 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1377 unsigned long sc_ctl, width;
1379 L1I = L1D = CSHAPE(8*1024, 5, 1);
1381 /* Check the line size of the Scache. */
1382 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1383 width = sc_ctl & 0x1000 ? 6 : 5;
1384 L2 = CSHAPE (96*1024, width, 3);
1386 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1387 has a shadow copy, and may be available from some versions
1388 of the CSERVE PALcall. If we can get it, then
1390 unsigned long bc_control, bc_config, size;
1391 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1392 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1394 Unfortunately, we can't rely on that.
1396 L3 = external_cache_probe(1024*1024, width);
1403 unsigned long cbox_config, size;
1405 if (cpu_type == PCA56_CPU) {
1406 L1I = CSHAPE(16*1024, 6, 1);
1407 L1D = CSHAPE(8*1024, 5, 1);
1409 L1I = CSHAPE(32*1024, 6, 2);
1410 L1D = CSHAPE(16*1024, 5, 1);
1414 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1415 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1418 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1420 L2 = external_cache_probe(512*1024, 6);
1431 L1I = L1D = CSHAPE(64*1024, 6, 2);
1432 L2 = external_cache_probe(1024*1024, 6);
1438 L1I = L1D = CSHAPE(64*1024, 6, 2);
1439 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1444 /* Nothing known about this cpu type. */
1445 L1I = L1D = L2 = L3 = 0;
1449 alpha_l1i_cacheshape = L1I;
1450 alpha_l1d_cacheshape = L1D;
1451 alpha_l2_cacheshape = L2;
1452 alpha_l3_cacheshape = L3;
1456 * We show only CPU #0 info.
1459 c_start(struct seq_file *f, loff_t *pos)
1461 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1465 c_next(struct seq_file *f, void *v, loff_t *pos)
1471 c_stop(struct seq_file *f, void *v)
1475 struct seq_operations cpuinfo_op = {
1479 .show = show_cpuinfo,
1484 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1487 /* FIXME FIXME FIXME */
1488 /* If we are using SRM and serial console, just hard halt here. */
1489 if (alpha_using_srm && srmcons_output)
1495 static __init int add_pcspkr(void)
1497 struct platform_device *pd;
1500 pd = platform_device_alloc("pcspkr", -1);
1504 ret = platform_device_add(pd);
1506 platform_device_put(pd);
1510 device_initcall(add_pcspkr);