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>
47 extern struct atomic_notifier_head panic_notifier_list;
48 static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
49 static struct notifier_block alpha_panic_block = {
52 INT_MAX /* try to do it first */
55 #include <asm/uaccess.h>
56 #include <asm/pgtable.h>
57 #include <asm/system.h>
58 #include <asm/hwrpb.h>
61 #include <asm/mmu_context.h>
62 #include <asm/console.h>
68 struct hwrpb_struct *hwrpb;
69 unsigned long srm_hae;
71 int alpha_l1i_cacheshape;
72 int alpha_l1d_cacheshape;
73 int alpha_l2_cacheshape;
74 int alpha_l3_cacheshape;
76 #ifdef CONFIG_VERBOSE_MCHECK
77 /* 0=minimum, 1=verbose, 2=all */
78 /* These can be overridden via the command line, ie "verbose_mcheck=2") */
79 unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
82 /* Which processor we booted from. */
86 * Using SRM callbacks for initial console output. This works from
87 * setup_arch() time through the end of time_init(), as those places
88 * are under our (Alpha) control.
90 * "srmcons" specified in the boot command arguments allows us to
91 * see kernel messages during the period of time before the true
92 * console device is "registered" during console_init().
93 * As of this version (2.5.59), console_init() will call
94 * disable_early_printk() as the last action before initializing
95 * the console drivers. That's the last possible time srmcons can be
96 * unregistered without interfering with console behavior.
98 * By default, OFF; set it with a bootcommand arg of "srmcons" or
99 * "console=srm". The meaning of these two args is:
100 * "srmcons" - early callback prints
101 * "console=srm" - full callback based console, including early prints
103 int srmcons_output = 0;
105 /* Enforce a memory size limit; useful for testing. By default, none. */
106 unsigned long mem_size_limit = 0;
108 /* Set AGP GART window size (0 means disabled). */
109 unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
111 #ifdef CONFIG_ALPHA_GENERIC
112 struct alpha_machine_vector alpha_mv;
116 static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
118 static struct alpha_machine_vector *get_sysvec_byname(const char *);
119 static void get_sysnames(unsigned long, unsigned long, unsigned long,
121 static void determine_cpu_caches (unsigned int);
123 static char command_line[COMMAND_LINE_SIZE];
126 * The format of "screen_info" is strange, and due to early
127 * i386-setup code. This is just enough to make the console
128 * code think we're on a VGA color display.
131 struct screen_info screen_info = {
134 .orig_video_cols = 80,
135 .orig_video_lines = 25,
136 .orig_video_isVGA = 1,
137 .orig_video_points = 16
141 * The direct map I/O window, if any. This should be the same
142 * for all busses, since it's used by virt_to_bus.
145 unsigned long __direct_map_base;
146 unsigned long __direct_map_size;
149 * Declare all of the machine vectors.
152 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
153 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
157 extern struct alpha_machine_vector X; \
177 WEAK(mikasa_primo_mv);
182 WEAK(noritake_primo_mv);
190 WEAK(sable_gamma_mv);
203 * I/O resources inherited from PeeCees. Except for perhaps the
204 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
206 * ??? If this becomes less standard, move the struct out into the
211 reserve_std_resources(void)
213 static struct resource standard_io_resources[] = {
214 { .name = "rtc", .start = -1, .end = -1 },
215 { .name = "dma1", .start = 0x00, .end = 0x1f },
216 { .name = "pic1", .start = 0x20, .end = 0x3f },
217 { .name = "timer", .start = 0x40, .end = 0x5f },
218 { .name = "keyboard", .start = 0x60, .end = 0x6f },
219 { .name = "dma page reg", .start = 0x80, .end = 0x8f },
220 { .name = "pic2", .start = 0xa0, .end = 0xbf },
221 { .name = "dma2", .start = 0xc0, .end = 0xdf },
224 struct resource *io = &ioport_resource;
228 struct pci_controller *hose;
229 for (hose = hose_head; hose; hose = hose->next)
230 if (hose->index == 0) {
236 /* Fix up for the Jensen's queer RTC placement. */
237 standard_io_resources[0].start = RTC_PORT(0);
238 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
240 for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i)
241 request_resource(io, standard_io_resources+i);
244 #define PFN_MAX PFN_DOWN(0x80000000)
245 #define for_each_mem_cluster(memdesc, cluster, i) \
246 for ((cluster) = (memdesc)->cluster, (i) = 0; \
247 (i) < (memdesc)->numclusters; (i)++, (cluster)++)
249 static unsigned long __init
250 get_mem_size_limit(char *s)
252 unsigned long end = 0;
255 end = simple_strtoul(from, &from, 0);
256 if ( *from == 'K' || *from == 'k' ) {
259 } else if ( *from == 'M' || *from == 'm' ) {
262 } else if ( *from == 'G' || *from == 'g' ) {
266 return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
269 #ifdef CONFIG_BLK_DEV_INITRD
271 move_initrd(unsigned long mem_limit)
276 size = initrd_end - initrd_start;
277 start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
278 if (!start || __pa(start) + size > mem_limit) {
279 initrd_start = initrd_end = 0;
282 memmove(start, (void *)initrd_start, size);
283 initrd_start = (unsigned long)start;
284 initrd_end = initrd_start + size;
285 printk("initrd moved to %p\n", start);
290 #ifndef CONFIG_DISCONTIGMEM
292 setup_memory(void *kernel_end)
294 struct memclust_struct * cluster;
295 struct memdesc_struct * memdesc;
296 unsigned long start_kernel_pfn, end_kernel_pfn;
297 unsigned long bootmap_size, bootmap_pages, bootmap_start;
298 unsigned long start, end;
301 /* Find free clusters, and init and free the bootmem accordingly. */
302 memdesc = (struct memdesc_struct *)
303 (hwrpb->mddt_offset + (unsigned long) hwrpb);
305 for_each_mem_cluster(memdesc, cluster, i) {
306 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
307 i, cluster->usage, cluster->start_pfn,
308 cluster->start_pfn + cluster->numpages);
310 /* Bit 0 is console/PALcode reserved. Bit 1 is
311 non-volatile memory -- we might want to mark
313 if (cluster->usage & 3)
316 end = cluster->start_pfn + cluster->numpages;
317 if (end > max_low_pfn)
322 * Except for the NUMA systems (wildfire, marvel) all of the
323 * Alpha systems we run on support 32GB of memory or less.
324 * Since the NUMA systems introduce large holes in memory addressing,
325 * we can get into a situation where there is not enough contiguous
326 * memory for the memory map.
328 * Limit memory to the first 32GB to limit the NUMA systems to
329 * memory on their first node (wildfire) or 2 (marvel) to avoid
330 * not being able to produce the memory map. In order to access
331 * all of the memory on the NUMA systems, build with discontiguous
334 * If the user specified a memory limit, let that memory limit stand.
337 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
339 if (mem_size_limit && max_low_pfn >= mem_size_limit)
341 printk("setup: forcing memory size to %ldK (from %ldK).\n",
342 mem_size_limit << (PAGE_SHIFT - 10),
343 max_low_pfn << (PAGE_SHIFT - 10));
344 max_low_pfn = mem_size_limit;
347 /* Find the bounds of kernel memory. */
348 start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
349 end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
353 if (max_low_pfn <= end_kernel_pfn)
354 panic("not enough memory to boot");
356 /* We need to know how many physically contiguous pages
357 we'll need for the bootmap. */
358 bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
360 /* Now find a good region where to allocate the bootmap. */
361 for_each_mem_cluster(memdesc, cluster, i) {
362 if (cluster->usage & 3)
365 start = cluster->start_pfn;
366 end = start + cluster->numpages;
367 if (start >= max_low_pfn)
369 if (end > max_low_pfn)
371 if (start < start_kernel_pfn) {
372 if (end > end_kernel_pfn
373 && end - end_kernel_pfn >= bootmap_pages) {
374 bootmap_start = end_kernel_pfn;
376 } else if (end > start_kernel_pfn)
377 end = start_kernel_pfn;
378 } else if (start < end_kernel_pfn)
379 start = end_kernel_pfn;
380 if (end - start >= bootmap_pages) {
381 bootmap_start = start;
386 if (bootmap_start == ~0UL) {
391 /* Allocate the bootmap and mark the whole MM as reserved. */
392 bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
394 /* Mark the free regions. */
395 for_each_mem_cluster(memdesc, cluster, i) {
396 if (cluster->usage & 3)
399 start = cluster->start_pfn;
400 end = cluster->start_pfn + cluster->numpages;
401 if (start >= max_low_pfn)
403 if (end > max_low_pfn)
405 if (start < start_kernel_pfn) {
406 if (end > end_kernel_pfn) {
407 free_bootmem(PFN_PHYS(start),
408 (PFN_PHYS(start_kernel_pfn)
410 printk("freeing pages %ld:%ld\n",
411 start, start_kernel_pfn);
412 start = end_kernel_pfn;
413 } else if (end > start_kernel_pfn)
414 end = start_kernel_pfn;
415 } else if (start < end_kernel_pfn)
416 start = end_kernel_pfn;
420 free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
421 printk("freeing pages %ld:%ld\n", start, end);
424 /* Reserve the bootmap memory. */
425 reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size);
426 printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
428 #ifdef CONFIG_BLK_DEV_INITRD
429 initrd_start = INITRD_START;
431 initrd_end = initrd_start+INITRD_SIZE;
432 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
433 (void *) initrd_start, INITRD_SIZE);
435 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
436 if (!move_initrd(PFN_PHYS(max_low_pfn)))
437 printk("initrd extends beyond end of memory "
438 "(0x%08lx > 0x%p)\ndisabling initrd\n",
440 phys_to_virt(PFN_PHYS(max_low_pfn)));
442 reserve_bootmem(virt_to_phys((void *)initrd_start),
446 #endif /* CONFIG_BLK_DEV_INITRD */
449 extern void setup_memory(void *);
450 #endif /* !CONFIG_DISCONTIGMEM */
453 page_is_ram(unsigned long pfn)
455 struct memclust_struct * cluster;
456 struct memdesc_struct * memdesc;
459 memdesc = (struct memdesc_struct *)
460 (hwrpb->mddt_offset + (unsigned long) hwrpb);
461 for_each_mem_cluster(memdesc, cluster, i)
463 if (pfn >= cluster->start_pfn &&
464 pfn < cluster->start_pfn + cluster->numpages) {
465 return (cluster->usage & 3) ? 0 : 1;
477 for_each_possible_cpu(i) {
478 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
486 arch_initcall(register_cpus);
489 setup_arch(char **cmdline_p)
493 struct alpha_machine_vector *vec = NULL;
494 struct percpu_struct *cpu;
495 char *type_name, *var_name, *p;
496 void *kernel_end = _end; /* end of kernel */
497 char *args = command_line;
499 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
500 boot_cpuid = hard_smp_processor_id();
503 * Pre-process the system type to make sure it will be valid.
505 * This may restore real CABRIO and EB66+ family names, ie
508 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
509 * and AS1200 (DIGITAL Server 5000 series) have the type as
510 * the negative of the real one.
512 if ((long)hwrpb->sys_type < 0) {
513 hwrpb->sys_type = -((long)hwrpb->sys_type);
514 hwrpb_update_checksum(hwrpb);
517 /* Register a call for panic conditions. */
518 atomic_notifier_chain_register(&panic_notifier_list,
521 #ifdef CONFIG_ALPHA_GENERIC
522 /* Assume that we've booted from SRM if we haven't booted from MILO.
523 Detect the later by looking for "MILO" in the system serial nr. */
524 alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
527 /* If we are using SRM, we want to allow callbacks
528 as early as possible, so do this NOW, and then
529 they should work immediately thereafter.
531 kernel_end = callback_init(kernel_end);
534 * Locate the command line.
536 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
537 boot flags depending on the boot mode, we need some shorthand.
538 This should do for installation. */
539 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
540 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
542 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
544 strcpy(saved_command_line, command_line);
545 *cmdline_p = command_line;
548 * Process command-line arguments.
550 while ((p = strsep(&args, " \t")) != NULL) {
552 if (strncmp(p, "alpha_mv=", 9) == 0) {
553 vec = get_sysvec_byname(p+9);
556 if (strncmp(p, "cycle=", 6) == 0) {
557 est_cycle_freq = simple_strtol(p+6, NULL, 0);
560 if (strncmp(p, "mem=", 4) == 0) {
561 mem_size_limit = get_mem_size_limit(p+4);
564 if (strncmp(p, "srmcons", 7) == 0) {
568 if (strncmp(p, "console=srm", 11) == 0) {
572 if (strncmp(p, "gartsize=", 9) == 0) {
574 get_mem_size_limit(p+9) << PAGE_SHIFT;
577 #ifdef CONFIG_VERBOSE_MCHECK
578 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
579 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
585 /* Replace the command line, now that we've killed it with strsep. */
586 strcpy(command_line, saved_command_line);
588 /* If we want SRM console printk echoing early, do it now. */
589 if (alpha_using_srm && srmcons_output) {
590 register_srm_console();
593 * If "console=srm" was specified, clear the srmcons_output
594 * flag now so that time.c won't unregister_srm_console
596 if (srmcons_output & 2)
600 #ifdef CONFIG_MAGIC_SYSRQ
601 /* If we're using SRM, make sysrq-b halt back to the prom,
603 if (alpha_using_srm) {
604 struct sysrq_key_op *op = __sysrq_get_key_op('b');
605 op->handler = (void *) machine_halt;
610 * Identify and reconfigure for the current system.
612 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
614 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
615 cpu->type, &type_name, &var_name);
616 if (*var_name == '0')
620 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
625 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
626 type_name, (*var_name ? " variation " : ""), var_name,
627 hwrpb->sys_type, hwrpb->sys_variation);
629 if (vec != &alpha_mv) {
634 #ifdef CONFIG_ALPHA_GENERIC
637 "on %s%s%s using machine vector %s from %s\n",
638 type_name, (*var_name ? " variation " : ""),
639 var_name, alpha_mv.vector_name,
640 (alpha_using_srm ? "SRM" : "MILO"));
642 printk("Major Options: "
646 #ifdef CONFIG_ALPHA_EV56
649 #ifdef CONFIG_ALPHA_EV67
652 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
655 #ifdef CONFIG_VERBOSE_MCHECK
659 #ifdef CONFIG_DISCONTIGMEM
666 #ifdef CONFIG_DEBUG_SPINLOCK
669 #ifdef CONFIG_MAGIC_SYSRQ
674 printk("Command line: %s\n", command_line);
678 * Save the SRM's current value for restoration.
680 srm_hae = *alpha_mv.hae_register;
681 __set_hae(alpha_mv.hae_cache);
683 /* Reset enable correctable error reports. */
686 /* Find our memory. */
687 setup_memory(kernel_end);
689 /* First guess at cpu cache sizes. Do this before init_arch. */
690 determine_cpu_caches(cpu->type);
692 /* Initialize the machine. Usually has to do with setting up
693 DMA windows and the like. */
694 if (alpha_mv.init_arch)
695 alpha_mv.init_arch();
697 /* Reserve standard resources. */
698 reserve_std_resources();
701 * Give us a default console. TGA users will see nothing until
702 * chr_dev_init is called, rather late in the boot sequence.
706 #if defined(CONFIG_VGA_CONSOLE)
707 conswitchp = &vga_con;
708 #elif defined(CONFIG_DUMMY_CONSOLE)
709 conswitchp = &dummy_con;
713 /* Default root filesystem to sda2. */
714 ROOT_DEV = Root_SDA2;
717 /* FIXME: only set this when we actually have EISA in this box? */
722 * Check ASN in HWRPB for validity, report if bad.
723 * FIXME: how was this failing? Should we trust it instead,
724 * and copy the value into alpha_mv.max_asn?
727 if (hwrpb->max_asn != MAX_ASN) {
728 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
732 * Identify the flock of penguins.
742 disable_early_printk(void)
744 if (alpha_using_srm && srmcons_output) {
745 unregister_srm_console();
750 static char sys_unknown[] = "Unknown";
751 static char systype_names[][16] = {
753 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
754 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
755 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
756 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
757 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
758 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
759 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
762 static char unofficial_names[][8] = {"100", "Ruffian"};
764 static char api_names[][16] = {"200", "Nautilus"};
766 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
767 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
769 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
770 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
772 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
773 static int eb64p_indices[] = {0,0,1,2};
775 static char eb66_names[][8] = {"EB66", "EB66+"};
776 static int eb66_indices[] = {0,0,1};
778 static char marvel_names[][16] = {
781 static int marvel_indices[] = { 0 };
783 static char rawhide_names[][16] = {
784 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
786 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
788 static char titan_names[][16] = {
789 "DEFAULT", "Privateer", "Falcon", "Granite"
791 static int titan_indices[] = {0,1,2,2,3};
793 static char tsunami_names[][16] = {
794 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
795 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
796 "Flying Clipper", "Shark"
798 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
800 static struct alpha_machine_vector * __init
801 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
803 static struct alpha_machine_vector *systype_vecs[] __initdata =
810 NULL, /* Mannequin */
814 NULL, /* Sable -- see below. */
817 NULL, /* Turbolaser */
820 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
821 NULL, /* Tradewind */
822 NULL, /* Mikasa -- see below. */
824 NULL, /* EB66 -- see variation. */
825 NULL, /* EB64+ -- see variation. */
831 NULL, /* EB164 -- see variation. */
832 NULL, /* Noritake -- see below. */
839 NULL, /* Tsunami -- see variation. */
840 &wildfire_mv, /* Wildfire */
842 &eiger_mv, /* Eiger */
847 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
853 static struct alpha_machine_vector *api_vecs[] __initdata =
859 static struct alpha_machine_vector *alcor_vecs[] __initdata =
861 &alcor_mv, &xlt_mv, &xlt_mv
864 static struct alpha_machine_vector *eb164_vecs[] __initdata =
866 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
869 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
873 &cabriolet_mv /* AlphaPCI64 */
876 static struct alpha_machine_vector *eb66_vecs[] __initdata =
882 static struct alpha_machine_vector *marvel_vecs[] __initdata =
887 static struct alpha_machine_vector *titan_vecs[] __initdata =
889 &titan_mv, /* default */
890 &privateer_mv, /* privateer */
891 &titan_mv, /* falcon */
892 &privateer_mv, /* granite */
895 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
898 &dp264_mv, /* dp264 */
899 &dp264_mv, /* warhol */
900 &dp264_mv, /* windjammer */
901 &monet_mv, /* monet */
902 &clipper_mv, /* clipper */
903 &dp264_mv, /* goldrush */
904 &webbrick_mv, /* webbrick */
905 &dp264_mv, /* catamaran */
906 NULL, /* brisbane? */
907 NULL, /* melbourne? */
908 NULL, /* flying clipper? */
909 &shark_mv, /* shark */
912 /* ??? Do we need to distinguish between Rawhides? */
914 struct alpha_machine_vector *vec;
916 /* Search the system tables first... */
918 if (type < ARRAY_SIZE(systype_vecs)) {
919 vec = systype_vecs[type];
920 } else if ((type > ST_API_BIAS) &&
921 (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
922 vec = api_vecs[type - ST_API_BIAS];
923 } else if ((type > ST_UNOFFICIAL_BIAS) &&
924 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
925 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
928 /* If we've not found one, try for a variation. */
931 /* Member ID is a bit-field. */
932 unsigned long member = (variation >> 10) & 0x3f;
934 cpu &= 0xffffffff; /* make it usable */
938 if (member < ARRAY_SIZE(alcor_indices))
939 vec = alcor_vecs[alcor_indices[member]];
942 if (member < ARRAY_SIZE(eb164_indices))
943 vec = eb164_vecs[eb164_indices[member]];
944 /* PC164 may show as EB164 variation with EV56 CPU,
945 but, since no true EB164 had anything but EV5... */
946 if (vec == &eb164_mv && cpu == EV56_CPU)
950 if (member < ARRAY_SIZE(eb64p_indices))
951 vec = eb64p_vecs[eb64p_indices[member]];
954 if (member < ARRAY_SIZE(eb66_indices))
955 vec = eb66_vecs[eb66_indices[member]];
958 if (member < ARRAY_SIZE(marvel_indices))
959 vec = marvel_vecs[marvel_indices[member]];
962 vec = titan_vecs[0]; /* default */
963 if (member < ARRAY_SIZE(titan_indices))
964 vec = titan_vecs[titan_indices[member]];
967 if (member < ARRAY_SIZE(tsunami_indices))
968 vec = tsunami_vecs[tsunami_indices[member]];
971 if (cpu == EV5_CPU || cpu == EV56_CPU)
972 vec = &mikasa_primo_mv;
976 case ST_DEC_NORITAKE:
977 if (cpu == EV5_CPU || cpu == EV56_CPU)
978 vec = &noritake_primo_mv;
982 case ST_DEC_2100_A500:
983 if (cpu == EV5_CPU || cpu == EV56_CPU)
984 vec = &sable_gamma_mv;
993 static struct alpha_machine_vector * __init
994 get_sysvec_byname(const char *name)
996 static struct alpha_machine_vector *all_vecs[] __initdata =
1039 for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
1040 struct alpha_machine_vector *mv = all_vecs[i];
1041 if (strcasecmp(mv->vector_name, name) == 0)
1048 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
1049 char **type_name, char **variation_name)
1051 unsigned long member;
1053 /* If not in the tables, make it UNKNOWN,
1054 else set type name to family */
1055 if (type < ARRAY_SIZE(systype_names)) {
1056 *type_name = systype_names[type];
1057 } else if ((type > ST_API_BIAS) &&
1058 (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
1059 *type_name = api_names[type - ST_API_BIAS];
1060 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1061 (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
1062 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1064 *type_name = sys_unknown;
1065 *variation_name = sys_unknown;
1069 /* Set variation to "0"; if variation is zero, done. */
1070 *variation_name = systype_names[0];
1071 if (variation == 0) {
1075 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1077 cpu &= 0xffffffff; /* make it usable */
1079 switch (type) { /* select by family */
1080 default: /* default to variation "0" for now */
1083 if (member < ARRAY_SIZE(eb164_indices))
1084 *variation_name = eb164_names[eb164_indices[member]];
1085 /* PC164 may show as EB164 variation, but with EV56 CPU,
1086 so, since no true EB164 had anything but EV5... */
1087 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1088 *variation_name = eb164_names[1]; /* make it PC164 */
1091 if (member < ARRAY_SIZE(alcor_indices))
1092 *variation_name = alcor_names[alcor_indices[member]];
1095 if (member < ARRAY_SIZE(eb64p_indices))
1096 *variation_name = eb64p_names[eb64p_indices[member]];
1099 if (member < ARRAY_SIZE(eb66_indices))
1100 *variation_name = eb66_names[eb66_indices[member]];
1103 if (member < ARRAY_SIZE(marvel_indices))
1104 *variation_name = marvel_names[marvel_indices[member]];
1106 case ST_DEC_RAWHIDE:
1107 if (member < ARRAY_SIZE(rawhide_indices))
1108 *variation_name = rawhide_names[rawhide_indices[member]];
1111 *variation_name = titan_names[0]; /* default */
1112 if (member < ARRAY_SIZE(titan_indices))
1113 *variation_name = titan_names[titan_indices[member]];
1115 case ST_DEC_TSUNAMI:
1116 if (member < ARRAY_SIZE(tsunami_indices))
1117 *variation_name = tsunami_names[tsunami_indices[member]];
1123 * A change was made to the HWRPB via an ECO and the following code
1124 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1125 * was not implemented in the console firmware. If it's revision 5 or
1126 * greater we can get the name of the platform as an ASCII string from
1127 * the HWRPB. That's what this function does. It checks the revision
1128 * level and if the string is in the HWRPB it returns the address of
1129 * the string--a pointer to the name of the platform.
1132 * - Pointer to a ASCII string if it's in the HWRPB
1133 * - Pointer to a blank string if the data is not in the HWRPB.
1137 platform_string(void)
1139 struct dsr_struct *dsr;
1140 static char unk_system_string[] = "N/A";
1142 /* Go to the console for the string pointer.
1143 * If the rpb_vers is not 5 or greater the rpb
1144 * is old and does not have this data in it.
1146 if (hwrpb->revision < 5)
1147 return (unk_system_string);
1149 /* The Dynamic System Recognition struct
1150 * has the system platform name starting
1151 * after the character count of the string.
1153 dsr = ((struct dsr_struct *)
1154 ((char *)hwrpb + hwrpb->dsr_offset));
1155 return ((char *)dsr + (dsr->sysname_off +
1161 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1163 struct percpu_struct *cpu;
1167 for (i = 0; i < num; i++) {
1168 cpu = (struct percpu_struct *)
1169 ((char *)cpubase + i*hwrpb->processor_size);
1170 if ((cpu->flags & 0x1cc) == 0x1cc)
1177 show_cache_size (struct seq_file *f, const char *which, int shape)
1180 seq_printf (f, "%s\t\t: n/a\n", which);
1181 else if (shape == 0)
1182 seq_printf (f, "%s\t\t: unknown\n", which);
1184 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1185 which, shape >> 10, shape & 15,
1186 1 << ((shape >> 4) & 15));
1190 show_cpuinfo(struct seq_file *f, void *slot)
1192 extern struct unaligned_stat {
1193 unsigned long count, va, pc;
1196 static char cpu_names[][8] = {
1197 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1198 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1199 "EV68CX", "EV7", "EV79", "EV69"
1202 struct percpu_struct *cpu = slot;
1203 unsigned int cpu_index;
1206 char *sysvariation_name;
1209 cpu_index = (unsigned) (cpu->type - 1);
1210 cpu_name = "Unknown";
1211 if (cpu_index < ARRAY_SIZE(cpu_names))
1212 cpu_name = cpu_names[cpu_index];
1214 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1215 cpu->type, &systype_name, &sysvariation_name);
1217 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1219 seq_printf(f, "cpu\t\t\t: Alpha\n"
1220 "cpu model\t\t: %s\n"
1221 "cpu variation\t\t: %ld\n"
1222 "cpu revision\t\t: %ld\n"
1223 "cpu serial number\t: %s\n"
1224 "system type\t\t: %s\n"
1225 "system variation\t: %s\n"
1226 "system revision\t\t: %ld\n"
1227 "system serial number\t: %s\n"
1228 "cycle frequency [Hz]\t: %lu %s\n"
1229 "timer frequency [Hz]\t: %lu.%02lu\n"
1230 "page size [bytes]\t: %ld\n"
1231 "phys. address bits\t: %ld\n"
1232 "max. addr. space #\t: %ld\n"
1233 "BogoMIPS\t\t: %lu.%02lu\n"
1234 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1235 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1236 "platform string\t\t: %s\n"
1237 "cpus detected\t\t: %d\n",
1238 cpu_name, cpu->variation, cpu->revision,
1239 (char*)cpu->serial_no,
1240 systype_name, sysvariation_name, hwrpb->sys_revision,
1242 est_cycle_freq ? : hwrpb->cycle_freq,
1243 est_cycle_freq ? "est." : "",
1244 hwrpb->intr_freq / 4096,
1245 (100 * hwrpb->intr_freq / 4096) % 100,
1249 loops_per_jiffy / (500000/HZ),
1250 (loops_per_jiffy / (5000/HZ)) % 100,
1251 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1252 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1253 platform_string(), nr_processors);
1256 seq_printf(f, "cpus active\t\t: %d\n"
1257 "cpu active mask\t\t: %016lx\n",
1258 num_online_cpus(), cpus_addr(cpu_possible_map)[0]);
1261 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1262 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1263 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1264 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1270 read_mem_block(int *addr, int stride, int size)
1272 long nloads = size / stride, cnt, tmp;
1274 __asm__ __volatile__(
1278 /* Next two XORs introduce an explicit data dependency between
1279 consecutive loads in the loop, which will give us true load
1287 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1288 : "r" (stride), "1" (nloads), "2" (addr));
1290 return cnt / (size / stride);
1293 #define CSHAPE(totalsize, linesize, assoc) \
1294 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1296 /* ??? EV5 supports up to 64M, but did the systems with more than
1297 16M of BCACHE ever exist? */
1298 #define MAX_BCACHE_SIZE 16*1024*1024
1300 /* Note that the offchip caches are direct mapped on all Alphas. */
1302 external_cache_probe(int minsize, int width)
1304 int cycles, prev_cycles = 1000000;
1305 int stride = 1 << width;
1306 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1308 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1309 maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
1311 /* Get the first block cached. */
1312 read_mem_block(__va(0), stride, size);
1314 while (size < maxsize) {
1315 /* Get an average load latency in cycles. */
1316 cycles = read_mem_block(__va(0), stride, size);
1317 if (cycles > prev_cycles * 2) {
1318 /* Fine, we exceed the cache. */
1319 printk("%ldK Bcache detected; load hit latency %d "
1320 "cycles, load miss latency %d cycles\n",
1321 size >> 11, prev_cycles, cycles);
1322 return CSHAPE(size >> 1, width, 1);
1324 /* Try to get the next block cached. */
1325 read_mem_block(__va(size), stride, size);
1326 prev_cycles = cycles;
1329 return -1; /* No BCACHE found. */
1333 determine_cpu_caches (unsigned int cpu_type)
1335 int L1I, L1D, L2, L3;
1341 if (cpu_type == EV4_CPU)
1342 L1I = CSHAPE(8*1024, 5, 1);
1344 L1I = CSHAPE(16*1024, 5, 1);
1348 /* BIU_CTL is a write-only Abox register. PALcode has a
1349 shadow copy, and may be available from some versions
1350 of the CSERVE PALcall. If we can get it, then
1352 unsigned long biu_ctl, size;
1353 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1354 L2 = CSHAPE (size, 5, 1);
1356 Unfortunately, we can't rely on that.
1358 L2 = external_cache_probe(128*1024, 5);
1364 unsigned long car, size;
1366 L1I = L1D = CSHAPE(8*1024, 5, 1);
1369 car = *(vuip) phys_to_virt (0x120000078UL);
1370 size = 64*1024 * (1 << ((car >> 5) & 7));
1371 /* No typo -- 8 byte cacheline size. Whodathunk. */
1372 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1379 unsigned long sc_ctl, width;
1381 L1I = L1D = CSHAPE(8*1024, 5, 1);
1383 /* Check the line size of the Scache. */
1384 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1385 width = sc_ctl & 0x1000 ? 6 : 5;
1386 L2 = CSHAPE (96*1024, width, 3);
1388 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1389 has a shadow copy, and may be available from some versions
1390 of the CSERVE PALcall. If we can get it, then
1392 unsigned long bc_control, bc_config, size;
1393 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1394 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1396 Unfortunately, we can't rely on that.
1398 L3 = external_cache_probe(1024*1024, width);
1405 unsigned long cbox_config, size;
1407 if (cpu_type == PCA56_CPU) {
1408 L1I = CSHAPE(16*1024, 6, 1);
1409 L1D = CSHAPE(8*1024, 5, 1);
1411 L1I = CSHAPE(32*1024, 6, 2);
1412 L1D = CSHAPE(16*1024, 5, 1);
1416 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1417 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1420 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1422 L2 = external_cache_probe(512*1024, 6);
1433 L1I = L1D = CSHAPE(64*1024, 6, 2);
1434 L2 = external_cache_probe(1024*1024, 6);
1440 L1I = L1D = CSHAPE(64*1024, 6, 2);
1441 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1446 /* Nothing known about this cpu type. */
1447 L1I = L1D = L2 = L3 = 0;
1451 alpha_l1i_cacheshape = L1I;
1452 alpha_l1d_cacheshape = L1D;
1453 alpha_l2_cacheshape = L2;
1454 alpha_l3_cacheshape = L3;
1458 * We show only CPU #0 info.
1461 c_start(struct seq_file *f, loff_t *pos)
1463 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1467 c_next(struct seq_file *f, void *v, loff_t *pos)
1473 c_stop(struct seq_file *f, void *v)
1477 struct seq_operations cpuinfo_op = {
1481 .show = show_cpuinfo,
1486 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1489 /* FIXME FIXME FIXME */
1490 /* If we are using SRM and serial console, just hard halt here. */
1491 if (alpha_using_srm && srmcons_output)
1497 static __init int add_pcspkr(void)
1499 struct platform_device *pd;
1502 pd = platform_device_alloc("pcspkr", -1);
1506 ret = platform_device_add(pd);
1508 platform_device_put(pd);
1512 device_initcall(add_pcspkr);