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/platform_device.h>
33 #include <linux/bootmem.h>
34 #include <linux/pci.h>
35 #include <linux/seq_file.h>
36 #include <linux/root_dev.h>
37 #include <linux/initrd.h>
38 #include <linux/eisa.h>
39 #include <linux/pfn.h>
40 #ifdef CONFIG_MAGIC_SYSRQ
41 #include <linux/sysrq.h>
42 #include <linux/reboot.h>
44 #include <linux/notifier.h>
45 #include <asm/setup.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;
70 unsigned long srm_hae;
72 int alpha_l1i_cacheshape;
73 int alpha_l1d_cacheshape;
74 int alpha_l2_cacheshape;
75 int alpha_l3_cacheshape;
77 #ifdef CONFIG_VERBOSE_MCHECK
78 /* 0=minimum, 1=verbose, 2=all */
79 /* These can be overridden via the command line, ie "verbose_mcheck=2") */
80 unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
83 /* Which processor we booted from. */
87 * Using SRM callbacks for initial console output. This works from
88 * setup_arch() time through the end of time_init(), as those places
89 * are under our (Alpha) control.
91 * "srmcons" specified in the boot command arguments allows us to
92 * see kernel messages during the period of time before the true
93 * console device is "registered" during console_init().
94 * As of this version (2.5.59), console_init() will call
95 * disable_early_printk() as the last action before initializing
96 * the console drivers. That's the last possible time srmcons can be
97 * unregistered without interfering with console behavior.
99 * By default, OFF; set it with a bootcommand arg of "srmcons" or
100 * "console=srm". The meaning of these two args is:
101 * "srmcons" - early callback prints
102 * "console=srm" - full callback based console, including early prints
104 int srmcons_output = 0;
106 /* Enforce a memory size limit; useful for testing. By default, none. */
107 unsigned long mem_size_limit = 0;
109 /* Set AGP GART window size (0 means disabled). */
110 unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
112 #ifdef CONFIG_ALPHA_GENERIC
113 struct alpha_machine_vector alpha_mv;
117 #define N(a) (sizeof(a)/sizeof(a[0]))
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 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
144 * The direct map I/O window, if any. This should be the same
145 * for all busses, since it's used by virt_to_bus.
148 unsigned long __direct_map_base;
149 unsigned long __direct_map_size;
152 * Declare all of the machine vectors.
155 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
156 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
160 extern struct alpha_machine_vector X; \
180 WEAK(mikasa_primo_mv);
185 WEAK(noritake_primo_mv);
193 WEAK(sable_gamma_mv);
206 * I/O resources inherited from PeeCees. Except for perhaps the
207 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
209 * ??? If this becomes less standard, move the struct out into the
214 reserve_std_resources(void)
216 static struct resource standard_io_resources[] = {
217 { .name = "rtc", .start = -1, .end = -1 },
218 { .name = "dma1", .start = 0x00, .end = 0x1f },
219 { .name = "pic1", .start = 0x20, .end = 0x3f },
220 { .name = "timer", .start = 0x40, .end = 0x5f },
221 { .name = "keyboard", .start = 0x60, .end = 0x6f },
222 { .name = "dma page reg", .start = 0x80, .end = 0x8f },
223 { .name = "pic2", .start = 0xa0, .end = 0xbf },
224 { .name = "dma2", .start = 0xc0, .end = 0xdf },
227 struct resource *io = &ioport_resource;
231 struct pci_controller *hose;
232 for (hose = hose_head; hose; hose = hose->next)
233 if (hose->index == 0) {
239 /* Fix up for the Jensen's queer RTC placement. */
240 standard_io_resources[0].start = RTC_PORT(0);
241 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
243 for (i = 0; i < N(standard_io_resources); ++i)
244 request_resource(io, standard_io_resources+i);
247 #define PFN_MAX PFN_DOWN(0x80000000)
248 #define for_each_mem_cluster(memdesc, cluster, i) \
249 for ((cluster) = (memdesc)->cluster, (i) = 0; \
250 (i) < (memdesc)->numclusters; (i)++, (cluster)++)
252 static unsigned long __init
253 get_mem_size_limit(char *s)
255 unsigned long end = 0;
258 end = simple_strtoul(from, &from, 0);
259 if ( *from == 'K' || *from == 'k' ) {
262 } else if ( *from == 'M' || *from == 'm' ) {
265 } else if ( *from == 'G' || *from == 'g' ) {
269 return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
272 #ifdef CONFIG_BLK_DEV_INITRD
274 move_initrd(unsigned long mem_limit)
279 size = initrd_end - initrd_start;
280 start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
281 if (!start || __pa(start) + size > mem_limit) {
282 initrd_start = initrd_end = 0;
285 memmove(start, (void *)initrd_start, size);
286 initrd_start = (unsigned long)start;
287 initrd_end = initrd_start + size;
288 printk("initrd moved to %p\n", start);
293 #ifndef CONFIG_DISCONTIGMEM
295 setup_memory(void *kernel_end)
297 struct memclust_struct * cluster;
298 struct memdesc_struct * memdesc;
299 unsigned long start_kernel_pfn, end_kernel_pfn;
300 unsigned long bootmap_size, bootmap_pages, bootmap_start;
301 unsigned long start, end;
304 /* Find free clusters, and init and free the bootmem accordingly. */
305 memdesc = (struct memdesc_struct *)
306 (hwrpb->mddt_offset + (unsigned long) hwrpb);
308 for_each_mem_cluster(memdesc, cluster, i) {
309 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
310 i, cluster->usage, cluster->start_pfn,
311 cluster->start_pfn + cluster->numpages);
313 /* Bit 0 is console/PALcode reserved. Bit 1 is
314 non-volatile memory -- we might want to mark
316 if (cluster->usage & 3)
319 end = cluster->start_pfn + cluster->numpages;
320 if (end > max_low_pfn)
325 * Except for the NUMA systems (wildfire, marvel) all of the
326 * Alpha systems we run on support 32GB of memory or less.
327 * Since the NUMA systems introduce large holes in memory addressing,
328 * we can get into a situation where there is not enough contiguous
329 * memory for the memory map.
331 * Limit memory to the first 32GB to limit the NUMA systems to
332 * memory on their first node (wildfire) or 2 (marvel) to avoid
333 * not being able to produce the memory map. In order to access
334 * all of the memory on the NUMA systems, build with discontiguous
337 * If the user specified a memory limit, let that memory limit stand.
340 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
342 if (mem_size_limit && max_low_pfn >= mem_size_limit)
344 printk("setup: forcing memory size to %ldK (from %ldK).\n",
345 mem_size_limit << (PAGE_SHIFT - 10),
346 max_low_pfn << (PAGE_SHIFT - 10));
347 max_low_pfn = mem_size_limit;
350 /* Find the bounds of kernel memory. */
351 start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
352 end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
356 if (max_low_pfn <= end_kernel_pfn)
357 panic("not enough memory to boot");
359 /* We need to know how many physically contiguous pages
360 we'll need for the bootmap. */
361 bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
363 /* Now find a good region where to allocate the bootmap. */
364 for_each_mem_cluster(memdesc, cluster, i) {
365 if (cluster->usage & 3)
368 start = cluster->start_pfn;
369 end = start + cluster->numpages;
370 if (start >= max_low_pfn)
372 if (end > max_low_pfn)
374 if (start < start_kernel_pfn) {
375 if (end > end_kernel_pfn
376 && end - end_kernel_pfn >= bootmap_pages) {
377 bootmap_start = end_kernel_pfn;
379 } else if (end > start_kernel_pfn)
380 end = start_kernel_pfn;
381 } else if (start < end_kernel_pfn)
382 start = end_kernel_pfn;
383 if (end - start >= bootmap_pages) {
384 bootmap_start = start;
389 if (bootmap_start == ~0UL) {
394 /* Allocate the bootmap and mark the whole MM as reserved. */
395 bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
397 /* Mark the free regions. */
398 for_each_mem_cluster(memdesc, cluster, i) {
399 if (cluster->usage & 3)
402 start = cluster->start_pfn;
403 end = cluster->start_pfn + cluster->numpages;
404 if (start >= max_low_pfn)
406 if (end > max_low_pfn)
408 if (start < start_kernel_pfn) {
409 if (end > end_kernel_pfn) {
410 free_bootmem(PFN_PHYS(start),
411 (PFN_PHYS(start_kernel_pfn)
413 printk("freeing pages %ld:%ld\n",
414 start, start_kernel_pfn);
415 start = end_kernel_pfn;
416 } else if (end > start_kernel_pfn)
417 end = start_kernel_pfn;
418 } else if (start < end_kernel_pfn)
419 start = end_kernel_pfn;
423 free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
424 printk("freeing pages %ld:%ld\n", start, end);
427 /* Reserve the bootmap memory. */
428 reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size);
429 printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
431 #ifdef CONFIG_BLK_DEV_INITRD
432 initrd_start = INITRD_START;
434 initrd_end = initrd_start+INITRD_SIZE;
435 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
436 (void *) initrd_start, INITRD_SIZE);
438 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
439 if (!move_initrd(PFN_PHYS(max_low_pfn)))
440 printk("initrd extends beyond end of memory "
441 "(0x%08lx > 0x%p)\ndisabling initrd\n",
443 phys_to_virt(PFN_PHYS(max_low_pfn)));
445 reserve_bootmem(virt_to_phys((void *)initrd_start),
449 #endif /* CONFIG_BLK_DEV_INITRD */
452 extern void setup_memory(void *);
453 #endif /* !CONFIG_DISCONTIGMEM */
456 page_is_ram(unsigned long pfn)
458 struct memclust_struct * cluster;
459 struct memdesc_struct * memdesc;
462 memdesc = (struct memdesc_struct *)
463 (hwrpb->mddt_offset + (unsigned long) hwrpb);
464 for_each_mem_cluster(memdesc, cluster, i)
466 if (pfn >= cluster->start_pfn &&
467 pfn < cluster->start_pfn + cluster->numpages) {
468 return (cluster->usage & 3) ? 0 : 1;
480 for_each_possible_cpu(i) {
481 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
484 register_cpu(p, i, NULL);
489 arch_initcall(register_cpus);
492 setup_arch(char **cmdline_p)
496 struct alpha_machine_vector *vec = NULL;
497 struct percpu_struct *cpu;
498 char *type_name, *var_name, *p;
499 void *kernel_end = _end; /* end of kernel */
500 char *args = command_line;
502 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
503 boot_cpuid = hard_smp_processor_id();
506 * Pre-process the system type to make sure it will be valid.
508 * This may restore real CABRIO and EB66+ family names, ie
511 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
512 * and AS1200 (DIGITAL Server 5000 series) have the type as
513 * the negative of the real one.
515 if ((long)hwrpb->sys_type < 0) {
516 hwrpb->sys_type = -((long)hwrpb->sys_type);
517 hwrpb_update_checksum(hwrpb);
520 /* Register a call for panic conditions. */
521 atomic_notifier_chain_register(&panic_notifier_list,
524 #ifdef CONFIG_ALPHA_GENERIC
525 /* Assume that we've booted from SRM if we haven't booted from MILO.
526 Detect the later by looking for "MILO" in the system serial nr. */
527 alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
530 /* If we are using SRM, we want to allow callbacks
531 as early as possible, so do this NOW, and then
532 they should work immediately thereafter.
534 kernel_end = callback_init(kernel_end);
537 * Locate the command line.
539 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
540 boot flags depending on the boot mode, we need some shorthand.
541 This should do for installation. */
542 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
543 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
545 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
547 strcpy(saved_command_line, command_line);
548 *cmdline_p = command_line;
551 * Process command-line arguments.
553 while ((p = strsep(&args, " \t")) != NULL) {
555 if (strncmp(p, "alpha_mv=", 9) == 0) {
556 vec = get_sysvec_byname(p+9);
559 if (strncmp(p, "cycle=", 6) == 0) {
560 est_cycle_freq = simple_strtol(p+6, NULL, 0);
563 if (strncmp(p, "mem=", 4) == 0) {
564 mem_size_limit = get_mem_size_limit(p+4);
567 if (strncmp(p, "srmcons", 7) == 0) {
571 if (strncmp(p, "console=srm", 11) == 0) {
575 if (strncmp(p, "gartsize=", 9) == 0) {
577 get_mem_size_limit(p+9) << PAGE_SHIFT;
580 #ifdef CONFIG_VERBOSE_MCHECK
581 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
582 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
588 /* Replace the command line, now that we've killed it with strsep. */
589 strcpy(command_line, saved_command_line);
591 /* If we want SRM console printk echoing early, do it now. */
592 if (alpha_using_srm && srmcons_output) {
593 register_srm_console();
596 * If "console=srm" was specified, clear the srmcons_output
597 * flag now so that time.c won't unregister_srm_console
599 if (srmcons_output & 2)
603 #ifdef CONFIG_MAGIC_SYSRQ
604 /* If we're using SRM, make sysrq-b halt back to the prom,
606 if (alpha_using_srm) {
607 struct sysrq_key_op *op = __sysrq_get_key_op('b');
608 op->handler = (void *) machine_halt;
613 * Identify and reconfigure for the current system.
615 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
617 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
618 cpu->type, &type_name, &var_name);
619 if (*var_name == '0')
623 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
628 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
629 type_name, (*var_name ? " variation " : ""), var_name,
630 hwrpb->sys_type, hwrpb->sys_variation);
632 if (vec != &alpha_mv) {
637 #ifdef CONFIG_ALPHA_GENERIC
640 "on %s%s%s using machine vector %s from %s\n",
641 type_name, (*var_name ? " variation " : ""),
642 var_name, alpha_mv.vector_name,
643 (alpha_using_srm ? "SRM" : "MILO"));
645 printk("Major Options: "
649 #ifdef CONFIG_ALPHA_EV56
652 #ifdef CONFIG_ALPHA_EV67
655 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
658 #ifdef CONFIG_VERBOSE_MCHECK
662 #ifdef CONFIG_DISCONTIGMEM
669 #ifdef CONFIG_DEBUG_SPINLOCK
672 #ifdef CONFIG_MAGIC_SYSRQ
677 printk("Command line: %s\n", command_line);
681 * Save the SRM's current value for restoration.
683 srm_hae = *alpha_mv.hae_register;
684 __set_hae(alpha_mv.hae_cache);
686 /* Reset enable correctable error reports. */
689 /* Find our memory. */
690 setup_memory(kernel_end);
692 /* First guess at cpu cache sizes. Do this before init_arch. */
693 determine_cpu_caches(cpu->type);
695 /* Initialize the machine. Usually has to do with setting up
696 DMA windows and the like. */
697 if (alpha_mv.init_arch)
698 alpha_mv.init_arch();
700 /* Reserve standard resources. */
701 reserve_std_resources();
704 * Give us a default console. TGA users will see nothing until
705 * chr_dev_init is called, rather late in the boot sequence.
709 #if defined(CONFIG_VGA_CONSOLE)
710 conswitchp = &vga_con;
711 #elif defined(CONFIG_DUMMY_CONSOLE)
712 conswitchp = &dummy_con;
716 /* Default root filesystem to sda2. */
717 ROOT_DEV = Root_SDA2;
720 /* FIXME: only set this when we actually have EISA in this box? */
725 * Check ASN in HWRPB for validity, report if bad.
726 * FIXME: how was this failing? Should we trust it instead,
727 * and copy the value into alpha_mv.max_asn?
730 if (hwrpb->max_asn != MAX_ASN) {
731 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
735 * Identify the flock of penguins.
745 disable_early_printk(void)
747 if (alpha_using_srm && srmcons_output) {
748 unregister_srm_console();
753 static char sys_unknown[] = "Unknown";
754 static char systype_names[][16] = {
756 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
757 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
758 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
759 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
760 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
761 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
762 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
765 static char unofficial_names[][8] = {"100", "Ruffian"};
767 static char api_names[][16] = {"200", "Nautilus"};
769 static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
770 static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
772 static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
773 static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
775 static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
776 static int eb64p_indices[] = {0,0,1,2};
778 static char eb66_names[][8] = {"EB66", "EB66+"};
779 static int eb66_indices[] = {0,0,1};
781 static char marvel_names[][16] = {
784 static int marvel_indices[] = { 0 };
786 static char rawhide_names[][16] = {
787 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
789 static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
791 static char titan_names[][16] = {
792 "DEFAULT", "Privateer", "Falcon", "Granite"
794 static int titan_indices[] = {0,1,2,2,3};
796 static char tsunami_names[][16] = {
797 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
798 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
799 "Flying Clipper", "Shark"
801 static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
803 static struct alpha_machine_vector * __init
804 get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
806 static struct alpha_machine_vector *systype_vecs[] __initdata =
813 NULL, /* Mannequin */
817 NULL, /* Sable -- see below. */
820 NULL, /* Turbolaser */
823 NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
824 NULL, /* Tradewind */
825 NULL, /* Mikasa -- see below. */
827 NULL, /* EB66 -- see variation. */
828 NULL, /* EB64+ -- see variation. */
834 NULL, /* EB164 -- see variation. */
835 NULL, /* Noritake -- see below. */
842 NULL, /* Tsunami -- see variation. */
843 &wildfire_mv, /* Wildfire */
845 &eiger_mv, /* Eiger */
850 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
856 static struct alpha_machine_vector *api_vecs[] __initdata =
862 static struct alpha_machine_vector *alcor_vecs[] __initdata =
864 &alcor_mv, &xlt_mv, &xlt_mv
867 static struct alpha_machine_vector *eb164_vecs[] __initdata =
869 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
872 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
876 &cabriolet_mv /* AlphaPCI64 */
879 static struct alpha_machine_vector *eb66_vecs[] __initdata =
885 static struct alpha_machine_vector *marvel_vecs[] __initdata =
890 static struct alpha_machine_vector *titan_vecs[] __initdata =
892 &titan_mv, /* default */
893 &privateer_mv, /* privateer */
894 &titan_mv, /* falcon */
895 &privateer_mv, /* granite */
898 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
901 &dp264_mv, /* dp264 */
902 &dp264_mv, /* warhol */
903 &dp264_mv, /* windjammer */
904 &monet_mv, /* monet */
905 &clipper_mv, /* clipper */
906 &dp264_mv, /* goldrush */
907 &webbrick_mv, /* webbrick */
908 &dp264_mv, /* catamaran */
909 NULL, /* brisbane? */
910 NULL, /* melbourne? */
911 NULL, /* flying clipper? */
912 &shark_mv, /* shark */
915 /* ??? Do we need to distinguish between Rawhides? */
917 struct alpha_machine_vector *vec;
919 /* Search the system tables first... */
921 if (type < N(systype_vecs)) {
922 vec = systype_vecs[type];
923 } else if ((type > ST_API_BIAS) &&
924 (type - ST_API_BIAS) < N(api_vecs)) {
925 vec = api_vecs[type - ST_API_BIAS];
926 } else if ((type > ST_UNOFFICIAL_BIAS) &&
927 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_vecs)) {
928 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
931 /* If we've not found one, try for a variation. */
934 /* Member ID is a bit-field. */
935 unsigned long member = (variation >> 10) & 0x3f;
937 cpu &= 0xffffffff; /* make it usable */
941 if (member < N(alcor_indices))
942 vec = alcor_vecs[alcor_indices[member]];
945 if (member < N(eb164_indices))
946 vec = eb164_vecs[eb164_indices[member]];
947 /* PC164 may show as EB164 variation with EV56 CPU,
948 but, since no true EB164 had anything but EV5... */
949 if (vec == &eb164_mv && cpu == EV56_CPU)
953 if (member < N(eb64p_indices))
954 vec = eb64p_vecs[eb64p_indices[member]];
957 if (member < N(eb66_indices))
958 vec = eb66_vecs[eb66_indices[member]];
961 if (member < N(marvel_indices))
962 vec = marvel_vecs[marvel_indices[member]];
965 vec = titan_vecs[0]; /* default */
966 if (member < N(titan_indices))
967 vec = titan_vecs[titan_indices[member]];
970 if (member < N(tsunami_indices))
971 vec = tsunami_vecs[tsunami_indices[member]];
974 if (cpu == EV5_CPU || cpu == EV56_CPU)
975 vec = &mikasa_primo_mv;
979 case ST_DEC_NORITAKE:
980 if (cpu == EV5_CPU || cpu == EV56_CPU)
981 vec = &noritake_primo_mv;
985 case ST_DEC_2100_A500:
986 if (cpu == EV5_CPU || cpu == EV56_CPU)
987 vec = &sable_gamma_mv;
996 static struct alpha_machine_vector * __init
997 get_sysvec_byname(const char *name)
999 static struct alpha_machine_vector *all_vecs[] __initdata =
1042 for (i = 0; i < N(all_vecs); ++i) {
1043 struct alpha_machine_vector *mv = all_vecs[i];
1044 if (strcasecmp(mv->vector_name, name) == 0)
1051 get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
1052 char **type_name, char **variation_name)
1054 unsigned long member;
1056 /* If not in the tables, make it UNKNOWN,
1057 else set type name to family */
1058 if (type < N(systype_names)) {
1059 *type_name = systype_names[type];
1060 } else if ((type > ST_API_BIAS) &&
1061 (type - ST_API_BIAS) < N(api_names)) {
1062 *type_name = api_names[type - ST_API_BIAS];
1063 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1064 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_names)) {
1065 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1067 *type_name = sys_unknown;
1068 *variation_name = sys_unknown;
1072 /* Set variation to "0"; if variation is zero, done. */
1073 *variation_name = systype_names[0];
1074 if (variation == 0) {
1078 member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
1080 cpu &= 0xffffffff; /* make it usable */
1082 switch (type) { /* select by family */
1083 default: /* default to variation "0" for now */
1086 if (member < N(eb164_indices))
1087 *variation_name = eb164_names[eb164_indices[member]];
1088 /* PC164 may show as EB164 variation, but with EV56 CPU,
1089 so, since no true EB164 had anything but EV5... */
1090 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1091 *variation_name = eb164_names[1]; /* make it PC164 */
1094 if (member < N(alcor_indices))
1095 *variation_name = alcor_names[alcor_indices[member]];
1098 if (member < N(eb64p_indices))
1099 *variation_name = eb64p_names[eb64p_indices[member]];
1102 if (member < N(eb66_indices))
1103 *variation_name = eb66_names[eb66_indices[member]];
1106 if (member < N(marvel_indices))
1107 *variation_name = marvel_names[marvel_indices[member]];
1109 case ST_DEC_RAWHIDE:
1110 if (member < N(rawhide_indices))
1111 *variation_name = rawhide_names[rawhide_indices[member]];
1114 *variation_name = titan_names[0]; /* default */
1115 if (member < N(titan_indices))
1116 *variation_name = titan_names[titan_indices[member]];
1118 case ST_DEC_TSUNAMI:
1119 if (member < N(tsunami_indices))
1120 *variation_name = tsunami_names[tsunami_indices[member]];
1126 * A change was made to the HWRPB via an ECO and the following code
1127 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1128 * was not implemented in the console firmware. If it's revision 5 or
1129 * greater we can get the name of the platform as an ASCII string from
1130 * the HWRPB. That's what this function does. It checks the revision
1131 * level and if the string is in the HWRPB it returns the address of
1132 * the string--a pointer to the name of the platform.
1135 * - Pointer to a ASCII string if it's in the HWRPB
1136 * - Pointer to a blank string if the data is not in the HWRPB.
1140 platform_string(void)
1142 struct dsr_struct *dsr;
1143 static char unk_system_string[] = "N/A";
1145 /* Go to the console for the string pointer.
1146 * If the rpb_vers is not 5 or greater the rpb
1147 * is old and does not have this data in it.
1149 if (hwrpb->revision < 5)
1150 return (unk_system_string);
1152 /* The Dynamic System Recognition struct
1153 * has the system platform name starting
1154 * after the character count of the string.
1156 dsr = ((struct dsr_struct *)
1157 ((char *)hwrpb + hwrpb->dsr_offset));
1158 return ((char *)dsr + (dsr->sysname_off +
1164 get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1166 struct percpu_struct *cpu;
1170 for (i = 0; i < num; i++) {
1171 cpu = (struct percpu_struct *)
1172 ((char *)cpubase + i*hwrpb->processor_size);
1173 if ((cpu->flags & 0x1cc) == 0x1cc)
1180 show_cache_size (struct seq_file *f, const char *which, int shape)
1183 seq_printf (f, "%s\t\t: n/a\n", which);
1184 else if (shape == 0)
1185 seq_printf (f, "%s\t\t: unknown\n", which);
1187 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1188 which, shape >> 10, shape & 15,
1189 1 << ((shape >> 4) & 15));
1193 show_cpuinfo(struct seq_file *f, void *slot)
1195 extern struct unaligned_stat {
1196 unsigned long count, va, pc;
1199 static char cpu_names[][8] = {
1200 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1201 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1202 "EV68CX", "EV7", "EV79", "EV69"
1205 struct percpu_struct *cpu = slot;
1206 unsigned int cpu_index;
1209 char *sysvariation_name;
1212 cpu_index = (unsigned) (cpu->type - 1);
1213 cpu_name = "Unknown";
1214 if (cpu_index < N(cpu_names))
1215 cpu_name = cpu_names[cpu_index];
1217 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1218 cpu->type, &systype_name, &sysvariation_name);
1220 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1222 seq_printf(f, "cpu\t\t\t: Alpha\n"
1223 "cpu model\t\t: %s\n"
1224 "cpu variation\t\t: %ld\n"
1225 "cpu revision\t\t: %ld\n"
1226 "cpu serial number\t: %s\n"
1227 "system type\t\t: %s\n"
1228 "system variation\t: %s\n"
1229 "system revision\t\t: %ld\n"
1230 "system serial number\t: %s\n"
1231 "cycle frequency [Hz]\t: %lu %s\n"
1232 "timer frequency [Hz]\t: %lu.%02lu\n"
1233 "page size [bytes]\t: %ld\n"
1234 "phys. address bits\t: %ld\n"
1235 "max. addr. space #\t: %ld\n"
1236 "BogoMIPS\t\t: %lu.%02lu\n"
1237 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1238 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1239 "platform string\t\t: %s\n"
1240 "cpus detected\t\t: %d\n",
1241 cpu_name, cpu->variation, cpu->revision,
1242 (char*)cpu->serial_no,
1243 systype_name, sysvariation_name, hwrpb->sys_revision,
1245 est_cycle_freq ? : hwrpb->cycle_freq,
1246 est_cycle_freq ? "est." : "",
1247 hwrpb->intr_freq / 4096,
1248 (100 * hwrpb->intr_freq / 4096) % 100,
1252 loops_per_jiffy / (500000/HZ),
1253 (loops_per_jiffy / (5000/HZ)) % 100,
1254 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1255 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1256 platform_string(), nr_processors);
1259 seq_printf(f, "cpus active\t\t: %d\n"
1260 "cpu active mask\t\t: %016lx\n",
1261 num_online_cpus(), cpus_addr(cpu_possible_map)[0]);
1264 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1265 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1266 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1267 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1273 read_mem_block(int *addr, int stride, int size)
1275 long nloads = size / stride, cnt, tmp;
1277 __asm__ __volatile__(
1281 /* Next two XORs introduce an explicit data dependency between
1282 consecutive loads in the loop, which will give us true load
1290 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1291 : "r" (stride), "1" (nloads), "2" (addr));
1293 return cnt / (size / stride);
1296 #define CSHAPE(totalsize, linesize, assoc) \
1297 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1299 /* ??? EV5 supports up to 64M, but did the systems with more than
1300 16M of BCACHE ever exist? */
1301 #define MAX_BCACHE_SIZE 16*1024*1024
1303 /* Note that the offchip caches are direct mapped on all Alphas. */
1305 external_cache_probe(int minsize, int width)
1307 int cycles, prev_cycles = 1000000;
1308 int stride = 1 << width;
1309 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1311 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1312 maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
1314 /* Get the first block cached. */
1315 read_mem_block(__va(0), stride, size);
1317 while (size < maxsize) {
1318 /* Get an average load latency in cycles. */
1319 cycles = read_mem_block(__va(0), stride, size);
1320 if (cycles > prev_cycles * 2) {
1321 /* Fine, we exceed the cache. */
1322 printk("%ldK Bcache detected; load hit latency %d "
1323 "cycles, load miss latency %d cycles\n",
1324 size >> 11, prev_cycles, cycles);
1325 return CSHAPE(size >> 1, width, 1);
1327 /* Try to get the next block cached. */
1328 read_mem_block(__va(size), stride, size);
1329 prev_cycles = cycles;
1332 return -1; /* No BCACHE found. */
1336 determine_cpu_caches (unsigned int cpu_type)
1338 int L1I, L1D, L2, L3;
1344 if (cpu_type == EV4_CPU)
1345 L1I = CSHAPE(8*1024, 5, 1);
1347 L1I = CSHAPE(16*1024, 5, 1);
1351 /* BIU_CTL is a write-only Abox register. PALcode has a
1352 shadow copy, and may be available from some versions
1353 of the CSERVE PALcall. If we can get it, then
1355 unsigned long biu_ctl, size;
1356 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1357 L2 = CSHAPE (size, 5, 1);
1359 Unfortunately, we can't rely on that.
1361 L2 = external_cache_probe(128*1024, 5);
1367 unsigned long car, size;
1369 L1I = L1D = CSHAPE(8*1024, 5, 1);
1372 car = *(vuip) phys_to_virt (0x120000078UL);
1373 size = 64*1024 * (1 << ((car >> 5) & 7));
1374 /* No typo -- 8 byte cacheline size. Whodathunk. */
1375 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1382 unsigned long sc_ctl, width;
1384 L1I = L1D = CSHAPE(8*1024, 5, 1);
1386 /* Check the line size of the Scache. */
1387 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1388 width = sc_ctl & 0x1000 ? 6 : 5;
1389 L2 = CSHAPE (96*1024, width, 3);
1391 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1392 has a shadow copy, and may be available from some versions
1393 of the CSERVE PALcall. If we can get it, then
1395 unsigned long bc_control, bc_config, size;
1396 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1397 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1399 Unfortunately, we can't rely on that.
1401 L3 = external_cache_probe(1024*1024, width);
1408 unsigned long cbox_config, size;
1410 if (cpu_type == PCA56_CPU) {
1411 L1I = CSHAPE(16*1024, 6, 1);
1412 L1D = CSHAPE(8*1024, 5, 1);
1414 L1I = CSHAPE(32*1024, 6, 2);
1415 L1D = CSHAPE(16*1024, 5, 1);
1419 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1420 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1423 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1425 L2 = external_cache_probe(512*1024, 6);
1436 L1I = L1D = CSHAPE(64*1024, 6, 2);
1437 L2 = external_cache_probe(1024*1024, 6);
1443 L1I = L1D = CSHAPE(64*1024, 6, 2);
1444 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1449 /* Nothing known about this cpu type. */
1450 L1I = L1D = L2 = L3 = 0;
1454 alpha_l1i_cacheshape = L1I;
1455 alpha_l1d_cacheshape = L1D;
1456 alpha_l2_cacheshape = L2;
1457 alpha_l3_cacheshape = L3;
1461 * We show only CPU #0 info.
1464 c_start(struct seq_file *f, loff_t *pos)
1466 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1470 c_next(struct seq_file *f, void *v, loff_t *pos)
1476 c_stop(struct seq_file *f, void *v)
1480 struct seq_operations cpuinfo_op = {
1484 .show = show_cpuinfo,
1489 alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1492 /* FIXME FIXME FIXME */
1493 /* If we are using SRM and serial console, just hard halt here. */
1494 if (alpha_using_srm && srmcons_output)
1500 static __init int add_pcspkr(void)
1502 struct platform_device *pd;
1505 pd = platform_device_alloc("pcspkr", -1);
1509 ret = platform_device_add(pd);
1511 platform_device_put(pd);
1515 device_initcall(add_pcspkr);