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/cpu.h>
28 #include <linux/errno.h>
29 #include <linux/init.h>
30 #include <linux/string.h>
31 #include <linux/ioport.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 #ifdef CONFIG_MAGIC_SYSRQ
39 #include <linux/sysrq.h>
40 #include <linux/reboot.h>
42 #include <linux/notifier.h>
43 #include <asm/setup.h>
46 extern struct notifier_block *panic_notifier_list;
47 static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
48 static struct notifier_block alpha_panic_block = {
51 INT_MAX /* try to do it first */
54 #include <asm/uaccess.h>
55 #include <asm/pgtable.h>
56 #include <asm/system.h>
57 #include <asm/hwrpb.h>
60 #include <asm/mmu_context.h>
61 #include <asm/console.h>
67 struct hwrpb_struct *hwrpb;
68 unsigned long srm_hae;
70 int alpha_l1i_cacheshape;
71 int alpha_l1d_cacheshape;
72 int alpha_l2_cacheshape;
73 int alpha_l3_cacheshape;
75 #ifdef CONFIG_VERBOSE_MCHECK
76 /* 0=minimum, 1=verbose, 2=all */
77 /* These can be overridden via the command line, ie "verbose_mcheck=2") */
78 unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
81 /* Which processor we booted from. */
85 * Using SRM callbacks for initial console output. This works from
86 * setup_arch() time through the end of time_init(), as those places
87 * are under our (Alpha) control.
89 * "srmcons" specified in the boot command arguments allows us to
90 * see kernel messages during the period of time before the true
91 * console device is "registered" during console_init().
92 * As of this version (2.5.59), console_init() will call
93 * disable_early_printk() as the last action before initializing
94 * the console drivers. That's the last possible time srmcons can be
95 * unregistered without interfering with console behavior.
97 * By default, OFF; set it with a bootcommand arg of "srmcons" or
98 * "console=srm". The meaning of these two args is:
99 * "srmcons" - early callback prints
100 * "console=srm" - full callback based console, including early prints
102 int srmcons_output = 0;
104 /* Enforce a memory size limit; useful for testing. By default, none. */
105 unsigned long mem_size_limit = 0;
107 /* Set AGP GART window size (0 means disabled). */
108 unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
110 #ifdef CONFIG_ALPHA_GENERIC
111 struct alpha_machine_vector alpha_mv;
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];
127 * The format of "screen_info" is strange, and due to early
128 * i386-setup code. This is just enough to make the console
129 * code think we're on a VGA color display.
132 struct screen_info screen_info = {
135 .orig_video_cols = 80,
136 .orig_video_lines = 25,
137 .orig_video_isVGA = 1,
138 .orig_video_points = 16
142 * The direct map I/O window, if any. This should be the same
143 * for all busses, since it's used by virt_to_bus.
146 unsigned long __direct_map_base;
147 unsigned long __direct_map_size;
150 * Declare all of the machine vectors.
153 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
154 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
158 extern struct alpha_machine_vector X; \
178 WEAK(mikasa_primo_mv);
183 WEAK(noritake_primo_mv);
191 WEAK(sable_gamma_mv);
204 * I/O resources inherited from PeeCees. Except for perhaps the
205 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
207 * ??? If this becomes less standard, move the struct out into the
212 reserve_std_resources(void)
214 static struct resource standard_io_resources[] = {
215 { .name = "rtc", .start = -1, .end = -1 },
216 { .name = "dma1", .start = 0x00, .end = 0x1f },
217 { .name = "pic1", .start = 0x20, .end = 0x3f },
218 { .name = "timer", .start = 0x40, .end = 0x5f },
219 { .name = "keyboard", .start = 0x60, .end = 0x6f },
220 { .name = "dma page reg", .start = 0x80, .end = 0x8f },
221 { .name = "pic2", .start = 0xa0, .end = 0xbf },
222 { .name = "dma2", .start = 0xc0, .end = 0xdf },
225 struct resource *io = &ioport_resource;
229 struct pci_controller *hose;
230 for (hose = hose_head; hose; hose = hose->next)
231 if (hose->index == 0) {
237 /* Fix up for the Jensen's queer RTC placement. */
238 standard_io_resources[0].start = RTC_PORT(0);
239 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
241 for (i = 0; i < N(standard_io_resources); ++i)
242 request_resource(io, standard_io_resources+i);
245 #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
246 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
247 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
248 #define PFN_MAX PFN_DOWN(0x80000000)
249 #define for_each_mem_cluster(memdesc, cluster, i) \
250 for ((cluster) = (memdesc)->cluster, (i) = 0; \
251 (i) < (memdesc)->numclusters; (i)++, (cluster)++)
253 static unsigned long __init
254 get_mem_size_limit(char *s)
256 unsigned long end = 0;
259 end = simple_strtoul(from, &from, 0);
260 if ( *from == 'K' || *from == 'k' ) {
263 } else if ( *from == 'M' || *from == 'm' ) {
266 } else if ( *from == 'G' || *from == 'g' ) {
270 return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
273 #ifdef CONFIG_BLK_DEV_INITRD
275 move_initrd(unsigned long mem_limit)
280 size = initrd_end - initrd_start;
281 start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
282 if (!start || __pa(start) + size > mem_limit) {
283 initrd_start = initrd_end = 0;
286 memmove(start, (void *)initrd_start, size);
287 initrd_start = (unsigned long)start;
288 initrd_end = initrd_start + size;
289 printk("initrd moved to %p\n", start);
294 #ifndef CONFIG_DISCONTIGMEM
296 setup_memory(void *kernel_end)
298 struct memclust_struct * cluster;
299 struct memdesc_struct * memdesc;
300 unsigned long start_kernel_pfn, end_kernel_pfn;
301 unsigned long bootmap_size, bootmap_pages, bootmap_start;
302 unsigned long start, end;
305 /* Find free clusters, and init and free the bootmem accordingly. */
306 memdesc = (struct memdesc_struct *)
307 (hwrpb->mddt_offset + (unsigned long) hwrpb);
309 for_each_mem_cluster(memdesc, cluster, i) {
310 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
311 i, cluster->usage, cluster->start_pfn,
312 cluster->start_pfn + cluster->numpages);
314 /* Bit 0 is console/PALcode reserved. Bit 1 is
315 non-volatile memory -- we might want to mark
317 if (cluster->usage & 3)
320 end = cluster->start_pfn + cluster->numpages;
321 if (end > max_low_pfn)
326 * Except for the NUMA systems (wildfire, marvel) all of the
327 * Alpha systems we run on support 32GB of memory or less.
328 * Since the NUMA systems introduce large holes in memory addressing,
329 * we can get into a situation where there is not enough contiguous
330 * memory for the memory map.
332 * Limit memory to the first 32GB to limit the NUMA systems to
333 * memory on their first node (wildfire) or 2 (marvel) to avoid
334 * not being able to produce the memory map. In order to access
335 * all of the memory on the NUMA systems, build with discontiguous
338 * If the user specified a memory limit, let that memory limit stand.
341 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
343 if (mem_size_limit && max_low_pfn >= mem_size_limit)
345 printk("setup: forcing memory size to %ldK (from %ldK).\n",
346 mem_size_limit << (PAGE_SHIFT - 10),
347 max_low_pfn << (PAGE_SHIFT - 10));
348 max_low_pfn = mem_size_limit;
351 /* Find the bounds of kernel memory. */
352 start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
353 end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
357 if (max_low_pfn <= end_kernel_pfn)
358 panic("not enough memory to boot");
360 /* We need to know how many physically contiguous pages
361 we'll need for the bootmap. */
362 bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
364 /* Now find a good region where to allocate the bootmap. */
365 for_each_mem_cluster(memdesc, cluster, i) {
366 if (cluster->usage & 3)
369 start = cluster->start_pfn;
370 end = start + cluster->numpages;
371 if (start >= max_low_pfn)
373 if (end > max_low_pfn)
375 if (start < start_kernel_pfn) {
376 if (end > end_kernel_pfn
377 && end - end_kernel_pfn >= bootmap_pages) {
378 bootmap_start = end_kernel_pfn;
380 } else if (end > start_kernel_pfn)
381 end = start_kernel_pfn;
382 } else if (start < end_kernel_pfn)
383 start = end_kernel_pfn;
384 if (end - start >= bootmap_pages) {
385 bootmap_start = start;
390 if (bootmap_start == ~0UL) {
395 /* Allocate the bootmap and mark the whole MM as reserved. */
396 bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
398 /* Mark the free regions. */
399 for_each_mem_cluster(memdesc, cluster, i) {
400 if (cluster->usage & 3)
403 start = cluster->start_pfn;
404 end = cluster->start_pfn + cluster->numpages;
405 if (start >= max_low_pfn)
407 if (end > max_low_pfn)
409 if (start < start_kernel_pfn) {
410 if (end > end_kernel_pfn) {
411 free_bootmem(PFN_PHYS(start),
412 (PFN_PHYS(start_kernel_pfn)
414 printk("freeing pages %ld:%ld\n",
415 start, start_kernel_pfn);
416 start = end_kernel_pfn;
417 } else if (end > start_kernel_pfn)
418 end = start_kernel_pfn;
419 } else if (start < end_kernel_pfn)
420 start = end_kernel_pfn;
424 free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
425 printk("freeing pages %ld:%ld\n", start, end);
428 /* Reserve the bootmap memory. */
429 reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size);
430 printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
432 #ifdef CONFIG_BLK_DEV_INITRD
433 initrd_start = INITRD_START;
435 initrd_end = initrd_start+INITRD_SIZE;
436 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
437 (void *) initrd_start, INITRD_SIZE);
439 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
440 if (!move_initrd(PFN_PHYS(max_low_pfn)))
441 printk("initrd extends beyond end of memory "
442 "(0x%08lx > 0x%p)\ndisabling initrd\n",
444 phys_to_virt(PFN_PHYS(max_low_pfn)));
446 reserve_bootmem(virt_to_phys((void *)initrd_start),
450 #endif /* CONFIG_BLK_DEV_INITRD */
453 extern void setup_memory(void *);
454 #endif /* !CONFIG_DISCONTIGMEM */
457 page_is_ram(unsigned long pfn)
459 struct memclust_struct * cluster;
460 struct memdesc_struct * memdesc;
463 memdesc = (struct memdesc_struct *)
464 (hwrpb->mddt_offset + (unsigned long) hwrpb);
465 for_each_mem_cluster(memdesc, cluster, i)
467 if (pfn >= cluster->start_pfn &&
468 pfn < cluster->start_pfn + cluster->numpages) {
469 return (cluster->usage & 3) ? 0 : 1;
486 for_each_possible_cpu(i) {
487 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
490 register_cpu(p, i, NULL);
495 arch_initcall(register_cpus);
498 setup_arch(char **cmdline_p)
502 struct alpha_machine_vector *vec = NULL;
503 struct percpu_struct *cpu;
504 char *type_name, *var_name, *p;
505 void *kernel_end = _end; /* end of kernel */
506 char *args = command_line;
508 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
509 boot_cpuid = hard_smp_processor_id();
512 * Pre-process the system type to make sure it will be valid.
514 * This may restore real CABRIO and EB66+ family names, ie
517 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
518 * and AS1200 (DIGITAL Server 5000 series) have the type as
519 * the negative of the real one.
521 if ((long)hwrpb->sys_type < 0) {
522 hwrpb->sys_type = -((long)hwrpb->sys_type);
523 hwrpb_update_checksum(hwrpb);
526 /* Register a call for panic conditions. */
527 notifier_chain_register(&panic_notifier_list, &alpha_panic_block);
529 #ifdef CONFIG_ALPHA_GENERIC
530 /* Assume that we've booted from SRM if we haven't booted from MILO.
531 Detect the later by looking for "MILO" in the system serial nr. */
532 alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
535 /* If we are using SRM, we want to allow callbacks
536 as early as possible, so do this NOW, and then
537 they should work immediately thereafter.
539 kernel_end = callback_init(kernel_end);
542 * Locate the command line.
544 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
545 boot flags depending on the boot mode, we need some shorthand.
546 This should do for installation. */
547 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
548 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
550 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
552 strcpy(saved_command_line, command_line);
553 *cmdline_p = command_line;
556 * Process command-line arguments.
558 while ((p = strsep(&args, " \t")) != NULL) {
560 if (strncmp(p, "alpha_mv=", 9) == 0) {
561 vec = get_sysvec_byname(p+9);
564 if (strncmp(p, "cycle=", 6) == 0) {
565 est_cycle_freq = simple_strtol(p+6, NULL, 0);
568 if (strncmp(p, "mem=", 4) == 0) {
569 mem_size_limit = get_mem_size_limit(p+4);
572 if (strncmp(p, "srmcons", 7) == 0) {
576 if (strncmp(p, "console=srm", 11) == 0) {
580 if (strncmp(p, "gartsize=", 9) == 0) {
582 get_mem_size_limit(p+9) << PAGE_SHIFT;
585 #ifdef CONFIG_VERBOSE_MCHECK
586 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
587 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
593 /* Replace the command line, now that we've killed it with strsep. */
594 strcpy(command_line, saved_command_line);
596 /* If we want SRM console printk echoing early, do it now. */
597 if (alpha_using_srm && srmcons_output) {
598 register_srm_console();
601 * If "console=srm" was specified, clear the srmcons_output
602 * flag now so that time.c won't unregister_srm_console
604 if (srmcons_output & 2)
608 #ifdef CONFIG_MAGIC_SYSRQ
609 /* If we're using SRM, make sysrq-b halt back to the prom,
611 if (alpha_using_srm) {
612 struct sysrq_key_op *op = __sysrq_get_key_op('b');
613 op->handler = (void *) machine_halt;
618 * Identify and reconfigure for the current system.
620 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
622 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
623 cpu->type, &type_name, &var_name);
624 if (*var_name == '0')
628 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
633 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
634 type_name, (*var_name ? " variation " : ""), var_name,
635 hwrpb->sys_type, hwrpb->sys_variation);
637 if (vec != &alpha_mv) {
642 #ifdef CONFIG_ALPHA_GENERIC
645 "on %s%s%s using machine vector %s from %s\n",
646 type_name, (*var_name ? " variation " : ""),
647 var_name, alpha_mv.vector_name,
648 (alpha_using_srm ? "SRM" : "MILO"));
650 printk("Major Options: "
654 #ifdef CONFIG_ALPHA_EV56
657 #ifdef CONFIG_ALPHA_EV67
660 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
663 #ifdef CONFIG_VERBOSE_MCHECK
667 #ifdef CONFIG_DISCONTIGMEM
674 #ifdef CONFIG_DEBUG_SPINLOCK
677 #ifdef CONFIG_MAGIC_SYSRQ
682 printk("Command line: %s\n", command_line);
686 * Save the SRM's current value for restoration.
688 srm_hae = *alpha_mv.hae_register;
689 __set_hae(alpha_mv.hae_cache);
691 /* Reset enable correctable error reports. */
694 /* Find our memory. */
695 setup_memory(kernel_end);
697 /* First guess at cpu cache sizes. Do this before init_arch. */
698 determine_cpu_caches(cpu->type);
700 /* Initialize the machine. Usually has to do with setting up
701 DMA windows and the like. */
702 if (alpha_mv.init_arch)
703 alpha_mv.init_arch();
705 /* Reserve standard resources. */
706 reserve_std_resources();
709 * Give us a default console. TGA users will see nothing until
710 * chr_dev_init is called, rather late in the boot sequence.
714 #if defined(CONFIG_VGA_CONSOLE)
715 conswitchp = &vga_con;
716 #elif defined(CONFIG_DUMMY_CONSOLE)
717 conswitchp = &dummy_con;
721 /* Default root filesystem to sda2. */
722 ROOT_DEV = Root_SDA2;
725 /* FIXME: only set this when we actually have EISA in this box? */
730 * Check ASN in HWRPB for validity, report if bad.
731 * FIXME: how was this failing? Should we trust it instead,
732 * and copy the value into alpha_mv.max_asn?
735 if (hwrpb->max_asn != MAX_ASN) {
736 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
740 * Identify the flock of penguins.
750 disable_early_printk(void)
752 if (alpha_using_srm && srmcons_output) {
753 unregister_srm_console();
758 static char sys_unknown[] = "Unknown";
759 static char systype_names[][16] = {
761 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
762 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
763 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
764 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
765 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
766 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
767 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
770 static char unofficial_names[][8] = {"100", "Ruffian"};
772 static char api_names[][16] = {"200", "Nautilus"};
774 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
775 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
777 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
778 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
780 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
781 static int eb64p_indices[] = {0,0,1,2};
783 static char eb66_names[][8] = {"EB66", "EB66+"};
784 static int eb66_indices[] = {0,0,1};
786 static char marvel_names[][16] = {
789 static int marvel_indices[] = { 0 };
791 static char rawhide_names[][16] = {
792 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
794 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
796 static char titan_names[][16] = {
797 "DEFAULT", "Privateer", "Falcon", "Granite"
799 static int titan_indices[] = {0,1,2,2,3};
801 static char tsunami_names[][16] = {
802 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
803 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
804 "Flying Clipper", "Shark"
806 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
808 static struct alpha_machine_vector * __init
809 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
811 static struct alpha_machine_vector *systype_vecs[] __initdata =
818 NULL, /* Mannequin */
822 NULL, /* Sable -- see below. */
825 NULL, /* Turbolaser */
828 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
829 NULL, /* Tradewind */
830 NULL, /* Mikasa -- see below. */
832 NULL, /* EB66 -- see variation. */
833 NULL, /* EB64+ -- see variation. */
839 NULL, /* EB164 -- see variation. */
840 NULL, /* Noritake -- see below. */
847 NULL, /* Tsunami -- see variation. */
848 &wildfire_mv, /* Wildfire */
850 &eiger_mv, /* Eiger */
855 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
861 static struct alpha_machine_vector *api_vecs[] __initdata =
867 static struct alpha_machine_vector *alcor_vecs[] __initdata =
869 &alcor_mv, &xlt_mv, &xlt_mv
872 static struct alpha_machine_vector *eb164_vecs[] __initdata =
874 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
877 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
881 &cabriolet_mv /* AlphaPCI64 */
884 static struct alpha_machine_vector *eb66_vecs[] __initdata =
890 static struct alpha_machine_vector *marvel_vecs[] __initdata =
895 static struct alpha_machine_vector *titan_vecs[] __initdata =
897 &titan_mv, /* default */
898 &privateer_mv, /* privateer */
899 &titan_mv, /* falcon */
900 &privateer_mv, /* granite */
903 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
906 &dp264_mv, /* dp264 */
907 &dp264_mv, /* warhol */
908 &dp264_mv, /* windjammer */
909 &monet_mv, /* monet */
910 &clipper_mv, /* clipper */
911 &dp264_mv, /* goldrush */
912 &webbrick_mv, /* webbrick */
913 &dp264_mv, /* catamaran */
914 NULL, /* brisbane? */
915 NULL, /* melbourne? */
916 NULL, /* flying clipper? */
917 &shark_mv, /* shark */
920 /* ??? Do we need to distinguish between Rawhides? */
922 struct alpha_machine_vector *vec;
924 /* Search the system tables first... */
926 if (type < N(systype_vecs)) {
927 vec = systype_vecs[type];
928 } else if ((type > ST_API_BIAS) &&
929 (type - ST_API_BIAS) < N(api_vecs)) {
930 vec = api_vecs[type - ST_API_BIAS];
931 } else if ((type > ST_UNOFFICIAL_BIAS) &&
932 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_vecs)) {
933 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
936 /* If we've not found one, try for a variation. */
939 /* Member ID is a bit-field. */
940 unsigned long member = (variation >> 10) & 0x3f;
942 cpu &= 0xffffffff; /* make it usable */
946 if (member < N(alcor_indices))
947 vec = alcor_vecs[alcor_indices[member]];
950 if (member < N(eb164_indices))
951 vec = eb164_vecs[eb164_indices[member]];
952 /* PC164 may show as EB164 variation with EV56 CPU,
953 but, since no true EB164 had anything but EV5... */
954 if (vec == &eb164_mv && cpu == EV56_CPU)
958 if (member < N(eb64p_indices))
959 vec = eb64p_vecs[eb64p_indices[member]];
962 if (member < N(eb66_indices))
963 vec = eb66_vecs[eb66_indices[member]];
966 if (member < N(marvel_indices))
967 vec = marvel_vecs[marvel_indices[member]];
970 vec = titan_vecs[0]; /* default */
971 if (member < N(titan_indices))
972 vec = titan_vecs[titan_indices[member]];
975 if (member < N(tsunami_indices))
976 vec = tsunami_vecs[tsunami_indices[member]];
979 if (cpu == EV5_CPU || cpu == EV56_CPU)
980 vec = &mikasa_primo_mv;
984 case ST_DEC_NORITAKE:
985 if (cpu == EV5_CPU || cpu == EV56_CPU)
986 vec = &noritake_primo_mv;
990 case ST_DEC_2100_A500:
991 if (cpu == EV5_CPU || cpu == EV56_CPU)
992 vec = &sable_gamma_mv;
1001 static struct alpha_machine_vector * __init
1002 get_sysvec_byname(const char *name)
1004 static struct alpha_machine_vector *all_vecs[] __initdata =
1047 for (i = 0; i < N(all_vecs); ++i) {
1048 struct alpha_machine_vector *mv = all_vecs[i];
1049 if (strcasecmp(mv->vector_name, name) == 0)
1056 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
1057 char **type_name, char **variation_name)
1059 unsigned long member;
1061 /* If not in the tables, make it UNKNOWN,
1062 else set type name to family */
1063 if (type < N(systype_names)) {
1064 *type_name = systype_names[type];
1065 } else if ((type > ST_API_BIAS) &&
1066 (type - ST_API_BIAS) < N(api_names)) {
1067 *type_name = api_names[type - ST_API_BIAS];
1068 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1069 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_names)) {
1070 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1072 *type_name = sys_unknown;
1073 *variation_name = sys_unknown;
1077 /* Set variation to "0"; if variation is zero, done. */
1078 *variation_name = systype_names[0];
1079 if (variation == 0) {
1083 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1085 cpu &= 0xffffffff; /* make it usable */
1087 switch (type) { /* select by family */
1088 default: /* default to variation "0" for now */
1091 if (member < N(eb164_indices))
1092 *variation_name = eb164_names[eb164_indices[member]];
1093 /* PC164 may show as EB164 variation, but with EV56 CPU,
1094 so, since no true EB164 had anything but EV5... */
1095 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1096 *variation_name = eb164_names[1]; /* make it PC164 */
1099 if (member < N(alcor_indices))
1100 *variation_name = alcor_names[alcor_indices[member]];
1103 if (member < N(eb64p_indices))
1104 *variation_name = eb64p_names[eb64p_indices[member]];
1107 if (member < N(eb66_indices))
1108 *variation_name = eb66_names[eb66_indices[member]];
1111 if (member < N(marvel_indices))
1112 *variation_name = marvel_names[marvel_indices[member]];
1114 case ST_DEC_RAWHIDE:
1115 if (member < N(rawhide_indices))
1116 *variation_name = rawhide_names[rawhide_indices[member]];
1119 *variation_name = titan_names[0]; /* default */
1120 if (member < N(titan_indices))
1121 *variation_name = titan_names[titan_indices[member]];
1123 case ST_DEC_TSUNAMI:
1124 if (member < N(tsunami_indices))
1125 *variation_name = tsunami_names[tsunami_indices[member]];
1131 * A change was made to the HWRPB via an ECO and the following code
1132 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1133 * was not implemented in the console firmware. If it's revision 5 or
1134 * greater we can get the name of the platform as an ASCII string from
1135 * the HWRPB. That's what this function does. It checks the revision
1136 * level and if the string is in the HWRPB it returns the address of
1137 * the string--a pointer to the name of the platform.
1140 * - Pointer to a ASCII string if it's in the HWRPB
1141 * - Pointer to a blank string if the data is not in the HWRPB.
1145 platform_string(void)
1147 struct dsr_struct *dsr;
1148 static char unk_system_string[] = "N/A";
1150 /* Go to the console for the string pointer.
1151 * If the rpb_vers is not 5 or greater the rpb
1152 * is old and does not have this data in it.
1154 if (hwrpb->revision < 5)
1155 return (unk_system_string);
1157 /* The Dynamic System Recognition struct
1158 * has the system platform name starting
1159 * after the character count of the string.
1161 dsr = ((struct dsr_struct *)
1162 ((char *)hwrpb + hwrpb->dsr_offset));
1163 return ((char *)dsr + (dsr->sysname_off +
1169 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1171 struct percpu_struct *cpu;
1175 for (i = 0; i < num; i++) {
1176 cpu = (struct percpu_struct *)
1177 ((char *)cpubase + i*hwrpb->processor_size);
1178 if ((cpu->flags & 0x1cc) == 0x1cc)
1185 show_cache_size (struct seq_file *f, const char *which, int shape)
1188 seq_printf (f, "%s\t\t: n/a\n", which);
1189 else if (shape == 0)
1190 seq_printf (f, "%s\t\t: unknown\n", which);
1192 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1193 which, shape >> 10, shape & 15,
1194 1 << ((shape >> 4) & 15));
1198 show_cpuinfo(struct seq_file *f, void *slot)
1200 extern struct unaligned_stat {
1201 unsigned long count, va, pc;
1204 static char cpu_names[][8] = {
1205 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1206 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1207 "EV68CX", "EV7", "EV79", "EV69"
1210 struct percpu_struct *cpu = slot;
1211 unsigned int cpu_index;
1214 char *sysvariation_name;
1217 cpu_index = (unsigned) (cpu->type - 1);
1218 cpu_name = "Unknown";
1219 if (cpu_index < N(cpu_names))
1220 cpu_name = cpu_names[cpu_index];
1222 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1223 cpu->type, &systype_name, &sysvariation_name);
1225 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1227 seq_printf(f, "cpu\t\t\t: Alpha\n"
1228 "cpu model\t\t: %s\n"
1229 "cpu variation\t\t: %ld\n"
1230 "cpu revision\t\t: %ld\n"
1231 "cpu serial number\t: %s\n"
1232 "system type\t\t: %s\n"
1233 "system variation\t: %s\n"
1234 "system revision\t\t: %ld\n"
1235 "system serial number\t: %s\n"
1236 "cycle frequency [Hz]\t: %lu %s\n"
1237 "timer frequency [Hz]\t: %lu.%02lu\n"
1238 "page size [bytes]\t: %ld\n"
1239 "phys. address bits\t: %ld\n"
1240 "max. addr. space #\t: %ld\n"
1241 "BogoMIPS\t\t: %lu.%02lu\n"
1242 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1243 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1244 "platform string\t\t: %s\n"
1245 "cpus detected\t\t: %d\n",
1246 cpu_name, cpu->variation, cpu->revision,
1247 (char*)cpu->serial_no,
1248 systype_name, sysvariation_name, hwrpb->sys_revision,
1250 est_cycle_freq ? : hwrpb->cycle_freq,
1251 est_cycle_freq ? "est." : "",
1252 hwrpb->intr_freq / 4096,
1253 (100 * hwrpb->intr_freq / 4096) % 100,
1257 loops_per_jiffy / (500000/HZ),
1258 (loops_per_jiffy / (5000/HZ)) % 100,
1259 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1260 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1261 platform_string(), nr_processors);
1264 seq_printf(f, "cpus active\t\t: %d\n"
1265 "cpu active mask\t\t: %016lx\n",
1266 num_online_cpus(), cpus_addr(cpu_possible_map)[0]);
1269 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1270 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1271 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1272 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1278 read_mem_block(int *addr, int stride, int size)
1280 long nloads = size / stride, cnt, tmp;
1282 __asm__ __volatile__(
1286 /* Next two XORs introduce an explicit data dependency between
1287 consecutive loads in the loop, which will give us true load
1295 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1296 : "r" (stride), "1" (nloads), "2" (addr));
1298 return cnt / (size / stride);
1301 #define CSHAPE(totalsize, linesize, assoc) \
1302 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1304 /* ??? EV5 supports up to 64M, but did the systems with more than
1305 16M of BCACHE ever exist? */
1306 #define MAX_BCACHE_SIZE 16*1024*1024
1308 /* Note that the offchip caches are direct mapped on all Alphas. */
1310 external_cache_probe(int minsize, int width)
1312 int cycles, prev_cycles = 1000000;
1313 int stride = 1 << width;
1314 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1316 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1317 maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
1319 /* Get the first block cached. */
1320 read_mem_block(__va(0), stride, size);
1322 while (size < maxsize) {
1323 /* Get an average load latency in cycles. */
1324 cycles = read_mem_block(__va(0), stride, size);
1325 if (cycles > prev_cycles * 2) {
1326 /* Fine, we exceed the cache. */
1327 printk("%ldK Bcache detected; load hit latency %d "
1328 "cycles, load miss latency %d cycles\n",
1329 size >> 11, prev_cycles, cycles);
1330 return CSHAPE(size >> 1, width, 1);
1332 /* Try to get the next block cached. */
1333 read_mem_block(__va(size), stride, size);
1334 prev_cycles = cycles;
1337 return -1; /* No BCACHE found. */
1341 determine_cpu_caches (unsigned int cpu_type)
1343 int L1I, L1D, L2, L3;
1349 if (cpu_type == EV4_CPU)
1350 L1I = CSHAPE(8*1024, 5, 1);
1352 L1I = CSHAPE(16*1024, 5, 1);
1356 /* BIU_CTL is a write-only Abox register. PALcode has a
1357 shadow copy, and may be available from some versions
1358 of the CSERVE PALcall. If we can get it, then
1360 unsigned long biu_ctl, size;
1361 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1362 L2 = CSHAPE (size, 5, 1);
1364 Unfortunately, we can't rely on that.
1366 L2 = external_cache_probe(128*1024, 5);
1372 unsigned long car, size;
1374 L1I = L1D = CSHAPE(8*1024, 5, 1);
1377 car = *(vuip) phys_to_virt (0x120000078UL);
1378 size = 64*1024 * (1 << ((car >> 5) & 7));
1379 /* No typo -- 8 byte cacheline size. Whodathunk. */
1380 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1387 unsigned long sc_ctl, width;
1389 L1I = L1D = CSHAPE(8*1024, 5, 1);
1391 /* Check the line size of the Scache. */
1392 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1393 width = sc_ctl & 0x1000 ? 6 : 5;
1394 L2 = CSHAPE (96*1024, width, 3);
1396 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1397 has a shadow copy, and may be available from some versions
1398 of the CSERVE PALcall. If we can get it, then
1400 unsigned long bc_control, bc_config, size;
1401 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1402 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1404 Unfortunately, we can't rely on that.
1406 L3 = external_cache_probe(1024*1024, width);
1413 unsigned long cbox_config, size;
1415 if (cpu_type == PCA56_CPU) {
1416 L1I = CSHAPE(16*1024, 6, 1);
1417 L1D = CSHAPE(8*1024, 5, 1);
1419 L1I = CSHAPE(32*1024, 6, 2);
1420 L1D = CSHAPE(16*1024, 5, 1);
1424 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1425 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1428 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1430 L2 = external_cache_probe(512*1024, 6);
1441 L1I = L1D = CSHAPE(64*1024, 6, 2);
1442 L2 = external_cache_probe(1024*1024, 6);
1448 L1I = L1D = CSHAPE(64*1024, 6, 2);
1449 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1454 /* Nothing known about this cpu type. */
1455 L1I = L1D = L2 = L3 = 0;
1459 alpha_l1i_cacheshape = L1I;
1460 alpha_l1d_cacheshape = L1D;
1461 alpha_l2_cacheshape = L2;
1462 alpha_l3_cacheshape = L3;
1466 * We show only CPU #0 info.
1469 c_start(struct seq_file *f, loff_t *pos)
1471 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1475 c_next(struct seq_file *f, void *v, loff_t *pos)
1481 c_stop(struct seq_file *f, void *v)
1485 struct seq_operations cpuinfo_op = {
1489 .show = show_cpuinfo,
1494 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1497 /* FIXME FIXME FIXME */
1498 /* If we are using SRM and serial console, just hard halt here. */
1499 if (alpha_using_srm && srmcons_output)