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/screen_info.h>
22 #include <linux/delay.h>
23 #include <linux/mc146818rtc.h>
24 #include <linux/console.h>
25 #include <linux/cpu.h>
26 #include <linux/errno.h>
27 #include <linux/init.h>
28 #include <linux/string.h>
29 #include <linux/ioport.h>
30 #include <linux/platform_device.h>
31 #include <linux/bootmem.h>
32 #include <linux/pci.h>
33 #include <linux/seq_file.h>
34 #include <linux/root_dev.h>
35 #include <linux/initrd.h>
36 #include <linux/eisa.h>
37 #include <linux/pfn.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>
45 #include <linux/log2.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>
60 #include <asm/mmu_context.h>
61 #include <asm/console.h>
67 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
;
83 struct cpumask node_to_cpumask_map
[MAX_NUMNODES
] __read_mostly
;
84 EXPORT_SYMBOL(node_to_cpumask_map
);
87 /* Which processor we booted from. */
91 * Using SRM callbacks for initial console output. This works from
92 * setup_arch() time through the end of time_init(), as those places
93 * are under our (Alpha) control.
95 * "srmcons" specified in the boot command arguments allows us to
96 * see kernel messages during the period of time before the true
97 * console device is "registered" during console_init().
98 * As of this version (2.5.59), console_init() will call
99 * disable_early_printk() as the last action before initializing
100 * the console drivers. That's the last possible time srmcons can be
101 * unregistered without interfering with console behavior.
103 * By default, OFF; set it with a bootcommand arg of "srmcons" or
104 * "console=srm". The meaning of these two args is:
105 * "srmcons" - early callback prints
106 * "console=srm" - full callback based console, including early prints
108 int srmcons_output
= 0;
110 /* Enforce a memory size limit; useful for testing. By default, none. */
111 unsigned long mem_size_limit
= 0;
113 /* Set AGP GART window size (0 means disabled). */
114 unsigned long alpha_agpgart_size
= DEFAULT_AGP_APER_SIZE
;
116 #ifdef CONFIG_ALPHA_GENERIC
117 struct alpha_machine_vector alpha_mv
;
119 EXPORT_SYMBOL(alpha_using_srm
);
122 static struct alpha_machine_vector
*get_sysvec(unsigned long, unsigned long,
124 static struct alpha_machine_vector
*get_sysvec_byname(const char *);
125 static void get_sysnames(unsigned long, unsigned long, unsigned long,
127 static void determine_cpu_caches (unsigned int);
129 static char __initdata command_line
[COMMAND_LINE_SIZE
];
132 * The format of "screen_info" is strange, and due to early
133 * i386-setup code. This is just enough to make the console
134 * code think we're on a VGA color display.
137 struct screen_info screen_info
= {
140 .orig_video_cols
= 80,
141 .orig_video_lines
= 25,
142 .orig_video_isVGA
= 1,
143 .orig_video_points
= 16
146 EXPORT_SYMBOL(screen_info
);
149 * The direct map I/O window, if any. This should be the same
150 * for all busses, since it's used by virt_to_bus.
153 unsigned long __direct_map_base
;
154 unsigned long __direct_map_size
;
155 EXPORT_SYMBOL(__direct_map_base
);
156 EXPORT_SYMBOL(__direct_map_size
);
159 * Declare all of the machine vectors.
162 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
163 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
167 extern struct alpha_machine_vector X; \
187 WEAK(mikasa_primo_mv
);
192 WEAK(noritake_primo_mv
);
200 WEAK(sable_gamma_mv
);
213 * I/O resources inherited from PeeCees. Except for perhaps the
214 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
216 * ??? If this becomes less standard, move the struct out into the
221 reserve_std_resources(void)
223 static struct resource standard_io_resources
[] = {
224 { .name
= "rtc", .start
= -1, .end
= -1 },
225 { .name
= "dma1", .start
= 0x00, .end
= 0x1f },
226 { .name
= "pic1", .start
= 0x20, .end
= 0x3f },
227 { .name
= "timer", .start
= 0x40, .end
= 0x5f },
228 { .name
= "keyboard", .start
= 0x60, .end
= 0x6f },
229 { .name
= "dma page reg", .start
= 0x80, .end
= 0x8f },
230 { .name
= "pic2", .start
= 0xa0, .end
= 0xbf },
231 { .name
= "dma2", .start
= 0xc0, .end
= 0xdf },
234 struct resource
*io
= &ioport_resource
;
238 struct pci_controller
*hose
;
239 for (hose
= hose_head
; hose
; hose
= hose
->next
)
240 if (hose
->index
== 0) {
246 /* Fix up for the Jensen's queer RTC placement. */
247 standard_io_resources
[0].start
= RTC_PORT(0);
248 standard_io_resources
[0].end
= RTC_PORT(0) + 0x10;
250 for (i
= 0; i
< ARRAY_SIZE(standard_io_resources
); ++i
)
251 request_resource(io
, standard_io_resources
+i
);
254 #define PFN_MAX PFN_DOWN(0x80000000)
255 #define for_each_mem_cluster(memdesc, _cluster, i) \
256 for ((_cluster) = (memdesc)->cluster, (i) = 0; \
257 (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
259 static unsigned long __init
260 get_mem_size_limit(char *s
)
262 unsigned long end
= 0;
265 end
= simple_strtoul(from
, &from
, 0);
266 if ( *from
== 'K' || *from
== 'k' ) {
269 } else if ( *from
== 'M' || *from
== 'm' ) {
272 } else if ( *from
== 'G' || *from
== 'g' ) {
276 return end
>> PAGE_SHIFT
; /* Return the PFN of the limit. */
279 #ifdef CONFIG_BLK_DEV_INITRD
281 move_initrd(unsigned long mem_limit
)
286 size
= initrd_end
- initrd_start
;
287 start
= __alloc_bootmem(PAGE_ALIGN(size
), PAGE_SIZE
, 0);
288 if (!start
|| __pa(start
) + size
> mem_limit
) {
289 initrd_start
= initrd_end
= 0;
292 memmove(start
, (void *)initrd_start
, size
);
293 initrd_start
= (unsigned long)start
;
294 initrd_end
= initrd_start
+ size
;
295 printk("initrd moved to %p\n", start
);
300 #ifndef CONFIG_DISCONTIGMEM
302 setup_memory(void *kernel_end
)
304 struct memclust_struct
* cluster
;
305 struct memdesc_struct
* memdesc
;
306 unsigned long start_kernel_pfn
, end_kernel_pfn
;
307 unsigned long bootmap_size
, bootmap_pages
, bootmap_start
;
308 unsigned long start
, end
;
311 /* Find free clusters, and init and free the bootmem accordingly. */
312 memdesc
= (struct memdesc_struct
*)
313 (hwrpb
->mddt_offset
+ (unsigned long) hwrpb
);
315 for_each_mem_cluster(memdesc
, cluster
, i
) {
316 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
317 i
, cluster
->usage
, cluster
->start_pfn
,
318 cluster
->start_pfn
+ cluster
->numpages
);
320 /* Bit 0 is console/PALcode reserved. Bit 1 is
321 non-volatile memory -- we might want to mark
323 if (cluster
->usage
& 3)
326 end
= cluster
->start_pfn
+ cluster
->numpages
;
327 if (end
> max_low_pfn
)
332 * Except for the NUMA systems (wildfire, marvel) all of the
333 * Alpha systems we run on support 32GB of memory or less.
334 * Since the NUMA systems introduce large holes in memory addressing,
335 * we can get into a situation where there is not enough contiguous
336 * memory for the memory map.
338 * Limit memory to the first 32GB to limit the NUMA systems to
339 * memory on their first node (wildfire) or 2 (marvel) to avoid
340 * not being able to produce the memory map. In order to access
341 * all of the memory on the NUMA systems, build with discontiguous
344 * If the user specified a memory limit, let that memory limit stand.
347 mem_size_limit
= (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT
;
349 if (mem_size_limit
&& max_low_pfn
>= mem_size_limit
)
351 printk("setup: forcing memory size to %ldK (from %ldK).\n",
352 mem_size_limit
<< (PAGE_SHIFT
- 10),
353 max_low_pfn
<< (PAGE_SHIFT
- 10));
354 max_low_pfn
= mem_size_limit
;
357 /* Find the bounds of kernel memory. */
358 start_kernel_pfn
= PFN_DOWN(KERNEL_START_PHYS
);
359 end_kernel_pfn
= PFN_UP(virt_to_phys(kernel_end
));
363 if (max_low_pfn
<= end_kernel_pfn
)
364 panic("not enough memory to boot");
366 /* We need to know how many physically contiguous pages
367 we'll need for the bootmap. */
368 bootmap_pages
= bootmem_bootmap_pages(max_low_pfn
);
370 /* Now find a good region where to allocate the bootmap. */
371 for_each_mem_cluster(memdesc
, cluster
, i
) {
372 if (cluster
->usage
& 3)
375 start
= cluster
->start_pfn
;
376 end
= start
+ cluster
->numpages
;
377 if (start
>= max_low_pfn
)
379 if (end
> max_low_pfn
)
381 if (start
< start_kernel_pfn
) {
382 if (end
> end_kernel_pfn
383 && end
- end_kernel_pfn
>= bootmap_pages
) {
384 bootmap_start
= end_kernel_pfn
;
386 } else if (end
> start_kernel_pfn
)
387 end
= start_kernel_pfn
;
388 } else if (start
< end_kernel_pfn
)
389 start
= end_kernel_pfn
;
390 if (end
- start
>= bootmap_pages
) {
391 bootmap_start
= start
;
396 if (bootmap_start
== ~0UL) {
401 /* Allocate the bootmap and mark the whole MM as reserved. */
402 bootmap_size
= init_bootmem(bootmap_start
, max_low_pfn
);
404 /* Mark the free regions. */
405 for_each_mem_cluster(memdesc
, cluster
, i
) {
406 if (cluster
->usage
& 3)
409 start
= cluster
->start_pfn
;
410 end
= cluster
->start_pfn
+ cluster
->numpages
;
411 if (start
>= max_low_pfn
)
413 if (end
> max_low_pfn
)
415 if (start
< start_kernel_pfn
) {
416 if (end
> end_kernel_pfn
) {
417 free_bootmem(PFN_PHYS(start
),
418 (PFN_PHYS(start_kernel_pfn
)
420 printk("freeing pages %ld:%ld\n",
421 start
, start_kernel_pfn
);
422 start
= end_kernel_pfn
;
423 } else if (end
> start_kernel_pfn
)
424 end
= start_kernel_pfn
;
425 } else if (start
< end_kernel_pfn
)
426 start
= end_kernel_pfn
;
430 free_bootmem(PFN_PHYS(start
), PFN_PHYS(end
) - PFN_PHYS(start
));
431 printk("freeing pages %ld:%ld\n", start
, end
);
434 /* Reserve the bootmap memory. */
435 reserve_bootmem(PFN_PHYS(bootmap_start
), bootmap_size
,
437 printk("reserving pages %ld:%ld\n", bootmap_start
, bootmap_start
+PFN_UP(bootmap_size
));
439 #ifdef CONFIG_BLK_DEV_INITRD
440 initrd_start
= INITRD_START
;
442 initrd_end
= initrd_start
+INITRD_SIZE
;
443 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
444 (void *) initrd_start
, INITRD_SIZE
);
446 if ((void *)initrd_end
> phys_to_virt(PFN_PHYS(max_low_pfn
))) {
447 if (!move_initrd(PFN_PHYS(max_low_pfn
)))
448 printk("initrd extends beyond end of memory "
449 "(0x%08lx > 0x%p)\ndisabling initrd\n",
451 phys_to_virt(PFN_PHYS(max_low_pfn
)));
453 reserve_bootmem(virt_to_phys((void *)initrd_start
),
454 INITRD_SIZE
, BOOTMEM_DEFAULT
);
457 #endif /* CONFIG_BLK_DEV_INITRD */
460 extern void setup_memory(void *);
461 #endif /* !CONFIG_DISCONTIGMEM */
464 page_is_ram(unsigned long pfn
)
466 struct memclust_struct
* cluster
;
467 struct memdesc_struct
* memdesc
;
470 memdesc
= (struct memdesc_struct
*)
471 (hwrpb
->mddt_offset
+ (unsigned long) hwrpb
);
472 for_each_mem_cluster(memdesc
, cluster
, i
)
474 if (pfn
>= cluster
->start_pfn
&&
475 pfn
< cluster
->start_pfn
+ cluster
->numpages
) {
476 return (cluster
->usage
& 3) ? 0 : 1;
488 for_each_possible_cpu(i
) {
489 struct cpu
*p
= kzalloc(sizeof(*p
), GFP_KERNEL
);
497 arch_initcall(register_cpus
);
500 setup_arch(char **cmdline_p
)
504 struct alpha_machine_vector
*vec
= NULL
;
505 struct percpu_struct
*cpu
;
506 char *type_name
, *var_name
, *p
;
507 void *kernel_end
= _end
; /* end of kernel */
508 char *args
= command_line
;
510 hwrpb
= (struct hwrpb_struct
*) __va(INIT_HWRPB
->phys_addr
);
511 boot_cpuid
= hard_smp_processor_id();
514 * Pre-process the system type to make sure it will be valid.
516 * This may restore real CABRIO and EB66+ family names, ie
519 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
520 * and AS1200 (DIGITAL Server 5000 series) have the type as
521 * the negative of the real one.
523 if ((long)hwrpb
->sys_type
< 0) {
524 hwrpb
->sys_type
= -((long)hwrpb
->sys_type
);
525 hwrpb_update_checksum(hwrpb
);
528 /* Register a call for panic conditions. */
529 atomic_notifier_chain_register(&panic_notifier_list
,
532 #ifdef CONFIG_ALPHA_GENERIC
533 /* Assume that we've booted from SRM if we haven't booted from MILO.
534 Detect the later by looking for "MILO" in the system serial nr. */
535 alpha_using_srm
= strncmp((const char *)hwrpb
->ssn
, "MILO", 4) != 0;
538 /* If we are using SRM, we want to allow callbacks
539 as early as possible, so do this NOW, and then
540 they should work immediately thereafter.
542 kernel_end
= callback_init(kernel_end
);
545 * Locate the command line.
547 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
548 boot flags depending on the boot mode, we need some shorthand.
549 This should do for installation. */
550 if (strcmp(COMMAND_LINE
, "INSTALL") == 0) {
551 strlcpy(command_line
, "root=/dev/fd0 load_ramdisk=1", sizeof command_line
);
553 strlcpy(command_line
, COMMAND_LINE
, sizeof command_line
);
555 strcpy(boot_command_line
, command_line
);
556 *cmdline_p
= command_line
;
559 * Process command-line arguments.
561 while ((p
= strsep(&args
, " \t")) != NULL
) {
563 if (strncmp(p
, "alpha_mv=", 9) == 0) {
564 vec
= get_sysvec_byname(p
+9);
567 if (strncmp(p
, "cycle=", 6) == 0) {
568 est_cycle_freq
= simple_strtol(p
+6, NULL
, 0);
571 if (strncmp(p
, "mem=", 4) == 0) {
572 mem_size_limit
= get_mem_size_limit(p
+4);
575 if (strncmp(p
, "srmcons", 7) == 0) {
579 if (strncmp(p
, "console=srm", 11) == 0) {
583 if (strncmp(p
, "gartsize=", 9) == 0) {
585 get_mem_size_limit(p
+9) << PAGE_SHIFT
;
588 #ifdef CONFIG_VERBOSE_MCHECK
589 if (strncmp(p
, "verbose_mcheck=", 15) == 0) {
590 alpha_verbose_mcheck
= simple_strtol(p
+15, NULL
, 0);
596 /* Replace the command line, now that we've killed it with strsep. */
597 strcpy(command_line
, boot_command_line
);
599 /* If we want SRM console printk echoing early, do it now. */
600 if (alpha_using_srm
&& srmcons_output
) {
601 register_srm_console();
604 * If "console=srm" was specified, clear the srmcons_output
605 * flag now so that time.c won't unregister_srm_console
607 if (srmcons_output
& 2)
611 #ifdef CONFIG_MAGIC_SYSRQ
612 /* If we're using SRM, make sysrq-b halt back to the prom,
614 if (alpha_using_srm
) {
615 struct sysrq_key_op
*op
= __sysrq_get_key_op('b');
616 op
->handler
= (void *) machine_halt
;
621 * Identify and reconfigure for the current system.
623 cpu
= (struct percpu_struct
*)((char*)hwrpb
+ hwrpb
->processor_offset
);
625 get_sysnames(hwrpb
->sys_type
, hwrpb
->sys_variation
,
626 cpu
->type
, &type_name
, &var_name
);
627 if (*var_name
== '0')
631 vec
= get_sysvec(hwrpb
->sys_type
, hwrpb
->sys_variation
,
636 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
637 type_name
, (*var_name
? " variation " : ""), var_name
,
638 hwrpb
->sys_type
, hwrpb
->sys_variation
);
640 if (vec
!= &alpha_mv
) {
645 #ifdef CONFIG_ALPHA_GENERIC
648 "on %s%s%s using machine vector %s from %s\n",
649 type_name
, (*var_name
? " variation " : ""),
650 var_name
, alpha_mv
.vector_name
,
651 (alpha_using_srm
? "SRM" : "MILO"));
653 printk("Major Options: "
657 #ifdef CONFIG_ALPHA_EV56
660 #ifdef CONFIG_ALPHA_EV67
663 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
666 #ifdef CONFIG_VERBOSE_MCHECK
670 #ifdef CONFIG_DISCONTIGMEM
677 #ifdef CONFIG_DEBUG_SPINLOCK
680 #ifdef CONFIG_MAGIC_SYSRQ
685 printk("Command line: %s\n", command_line
);
689 * Save the SRM's current value for restoration.
691 srm_hae
= *alpha_mv
.hae_register
;
692 __set_hae(alpha_mv
.hae_cache
);
694 /* Reset enable correctable error reports. */
697 /* Find our memory. */
698 setup_memory(kernel_end
);
700 /* First guess at cpu cache sizes. Do this before init_arch. */
701 determine_cpu_caches(cpu
->type
);
703 /* Initialize the machine. Usually has to do with setting up
704 DMA windows and the like. */
705 if (alpha_mv
.init_arch
)
706 alpha_mv
.init_arch();
708 /* Reserve standard resources. */
709 reserve_std_resources();
712 * Give us a default console. TGA users will see nothing until
713 * chr_dev_init is called, rather late in the boot sequence.
717 #if defined(CONFIG_VGA_CONSOLE)
718 conswitchp
= &vga_con
;
719 #elif defined(CONFIG_DUMMY_CONSOLE)
720 conswitchp
= &dummy_con
;
724 /* Default root filesystem to sda2. */
725 ROOT_DEV
= Root_SDA2
;
728 /* FIXME: only set this when we actually have EISA in this box? */
733 * Check ASN in HWRPB for validity, report if bad.
734 * FIXME: how was this failing? Should we trust it instead,
735 * and copy the value into alpha_mv.max_asn?
738 if (hwrpb
->max_asn
!= MAX_ASN
) {
739 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb
->max_asn
);
743 * Identify the flock of penguins.
752 static char sys_unknown
[] = "Unknown";
753 static char systype_names
[][16] = {
755 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
756 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
757 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
758 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
759 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
760 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
761 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
764 static char unofficial_names
[][8] = {"100", "Ruffian"};
766 static char api_names
[][16] = {"200", "Nautilus"};
768 static char eb164_names
[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
769 static int eb164_indices
[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
771 static char alcor_names
[][16] = {"Alcor", "Maverick", "Bret"};
772 static int alcor_indices
[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
774 static char eb64p_names
[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
775 static int eb64p_indices
[] = {0,0,1,2};
777 static char eb66_names
[][8] = {"EB66", "EB66+"};
778 static int eb66_indices
[] = {0,0,1};
780 static char marvel_names
[][16] = {
783 static int marvel_indices
[] = { 0 };
785 static char rawhide_names
[][16] = {
786 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
788 static int rawhide_indices
[] = {0,0,0,1,1,2,2,3,3,4,4};
790 static char titan_names
[][16] = {
791 "DEFAULT", "Privateer", "Falcon", "Granite"
793 static int titan_indices
[] = {0,1,2,2,3};
795 static char tsunami_names
[][16] = {
796 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
797 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
798 "Flying Clipper", "Shark"
800 static int tsunami_indices
[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
802 static struct alpha_machine_vector
* __init
803 get_sysvec(unsigned long type
, unsigned long variation
, unsigned long cpu
)
805 static struct alpha_machine_vector
*systype_vecs
[] __initdata
=
812 NULL
, /* Mannequin */
816 NULL
, /* Sable -- see below. */
819 NULL
, /* Turbolaser */
822 NULL
, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
823 NULL
, /* Tradewind */
824 NULL
, /* Mikasa -- see below. */
826 NULL
, /* EB66 -- see variation. */
827 NULL
, /* EB64+ -- see variation. */
833 NULL
, /* EB164 -- see variation. */
834 NULL
, /* Noritake -- see below. */
841 NULL
, /* Tsunami -- see variation. */
842 &wildfire_mv
, /* Wildfire */
844 &eiger_mv
, /* Eiger */
849 static struct alpha_machine_vector
*unofficial_vecs
[] __initdata
=
855 static struct alpha_machine_vector
*api_vecs
[] __initdata
=
861 static struct alpha_machine_vector
*alcor_vecs
[] __initdata
=
863 &alcor_mv
, &xlt_mv
, &xlt_mv
866 static struct alpha_machine_vector
*eb164_vecs
[] __initdata
=
868 &eb164_mv
, &pc164_mv
, &lx164_mv
, &sx164_mv
, &rx164_mv
871 static struct alpha_machine_vector
*eb64p_vecs
[] __initdata
=
875 &cabriolet_mv
/* AlphaPCI64 */
878 static struct alpha_machine_vector
*eb66_vecs
[] __initdata
=
884 static struct alpha_machine_vector
*marvel_vecs
[] __initdata
=
889 static struct alpha_machine_vector
*titan_vecs
[] __initdata
=
891 &titan_mv
, /* default */
892 &privateer_mv
, /* privateer */
893 &titan_mv
, /* falcon */
894 &privateer_mv
, /* granite */
897 static struct alpha_machine_vector
*tsunami_vecs
[] __initdata
=
900 &dp264_mv
, /* dp264 */
901 &dp264_mv
, /* warhol */
902 &dp264_mv
, /* windjammer */
903 &monet_mv
, /* monet */
904 &clipper_mv
, /* clipper */
905 &dp264_mv
, /* goldrush */
906 &webbrick_mv
, /* webbrick */
907 &dp264_mv
, /* catamaran */
908 NULL
, /* brisbane? */
909 NULL
, /* melbourne? */
910 NULL
, /* flying clipper? */
911 &shark_mv
, /* shark */
914 /* ??? Do we need to distinguish between Rawhides? */
916 struct alpha_machine_vector
*vec
;
918 /* Search the system tables first... */
920 if (type
< ARRAY_SIZE(systype_vecs
)) {
921 vec
= systype_vecs
[type
];
922 } else if ((type
> ST_API_BIAS
) &&
923 (type
- ST_API_BIAS
) < ARRAY_SIZE(api_vecs
)) {
924 vec
= api_vecs
[type
- ST_API_BIAS
];
925 } else if ((type
> ST_UNOFFICIAL_BIAS
) &&
926 (type
- ST_UNOFFICIAL_BIAS
) < ARRAY_SIZE(unofficial_vecs
)) {
927 vec
= unofficial_vecs
[type
- ST_UNOFFICIAL_BIAS
];
930 /* If we've not found one, try for a variation. */
933 /* Member ID is a bit-field. */
934 unsigned long member
= (variation
>> 10) & 0x3f;
936 cpu
&= 0xffffffff; /* make it usable */
940 if (member
< ARRAY_SIZE(alcor_indices
))
941 vec
= alcor_vecs
[alcor_indices
[member
]];
944 if (member
< ARRAY_SIZE(eb164_indices
))
945 vec
= eb164_vecs
[eb164_indices
[member
]];
946 /* PC164 may show as EB164 variation with EV56 CPU,
947 but, since no true EB164 had anything but EV5... */
948 if (vec
== &eb164_mv
&& cpu
== EV56_CPU
)
952 if (member
< ARRAY_SIZE(eb64p_indices
))
953 vec
= eb64p_vecs
[eb64p_indices
[member
]];
956 if (member
< ARRAY_SIZE(eb66_indices
))
957 vec
= eb66_vecs
[eb66_indices
[member
]];
960 if (member
< ARRAY_SIZE(marvel_indices
))
961 vec
= marvel_vecs
[marvel_indices
[member
]];
964 vec
= titan_vecs
[0]; /* default */
965 if (member
< ARRAY_SIZE(titan_indices
))
966 vec
= titan_vecs
[titan_indices
[member
]];
969 if (member
< ARRAY_SIZE(tsunami_indices
))
970 vec
= tsunami_vecs
[tsunami_indices
[member
]];
973 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
974 vec
= &mikasa_primo_mv
;
978 case ST_DEC_NORITAKE
:
979 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
980 vec
= &noritake_primo_mv
;
984 case ST_DEC_2100_A500
:
985 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
986 vec
= &sable_gamma_mv
;
995 static struct alpha_machine_vector
* __init
996 get_sysvec_byname(const char *name
)
998 static struct alpha_machine_vector
*all_vecs
[] __initdata
=
1041 for (i
= 0; i
< ARRAY_SIZE(all_vecs
); ++i
) {
1042 struct alpha_machine_vector
*mv
= all_vecs
[i
];
1043 if (strcasecmp(mv
->vector_name
, name
) == 0)
1050 get_sysnames(unsigned long type
, unsigned long variation
, unsigned long cpu
,
1051 char **type_name
, char **variation_name
)
1053 unsigned long member
;
1055 /* If not in the tables, make it UNKNOWN,
1056 else set type name to family */
1057 if (type
< ARRAY_SIZE(systype_names
)) {
1058 *type_name
= systype_names
[type
];
1059 } else if ((type
> ST_API_BIAS
) &&
1060 (type
- ST_API_BIAS
) < ARRAY_SIZE(api_names
)) {
1061 *type_name
= api_names
[type
- ST_API_BIAS
];
1062 } else if ((type
> ST_UNOFFICIAL_BIAS
) &&
1063 (type
- ST_UNOFFICIAL_BIAS
) < ARRAY_SIZE(unofficial_names
)) {
1064 *type_name
= unofficial_names
[type
- ST_UNOFFICIAL_BIAS
];
1066 *type_name
= sys_unknown
;
1067 *variation_name
= sys_unknown
;
1071 /* Set variation to "0"; if variation is zero, done. */
1072 *variation_name
= systype_names
[0];
1073 if (variation
== 0) {
1077 member
= (variation
>> 10) & 0x3f; /* member ID is a bit-field */
1079 cpu
&= 0xffffffff; /* make it usable */
1081 switch (type
) { /* select by family */
1082 default: /* default to variation "0" for now */
1085 if (member
< ARRAY_SIZE(eb164_indices
))
1086 *variation_name
= eb164_names
[eb164_indices
[member
]];
1087 /* PC164 may show as EB164 variation, but with EV56 CPU,
1088 so, since no true EB164 had anything but EV5... */
1089 if (eb164_indices
[member
] == 0 && cpu
== EV56_CPU
)
1090 *variation_name
= eb164_names
[1]; /* make it PC164 */
1093 if (member
< ARRAY_SIZE(alcor_indices
))
1094 *variation_name
= alcor_names
[alcor_indices
[member
]];
1097 if (member
< ARRAY_SIZE(eb64p_indices
))
1098 *variation_name
= eb64p_names
[eb64p_indices
[member
]];
1101 if (member
< ARRAY_SIZE(eb66_indices
))
1102 *variation_name
= eb66_names
[eb66_indices
[member
]];
1105 if (member
< ARRAY_SIZE(marvel_indices
))
1106 *variation_name
= marvel_names
[marvel_indices
[member
]];
1108 case ST_DEC_RAWHIDE
:
1109 if (member
< ARRAY_SIZE(rawhide_indices
))
1110 *variation_name
= rawhide_names
[rawhide_indices
[member
]];
1113 *variation_name
= titan_names
[0]; /* default */
1114 if (member
< ARRAY_SIZE(titan_indices
))
1115 *variation_name
= titan_names
[titan_indices
[member
]];
1117 case ST_DEC_TSUNAMI
:
1118 if (member
< ARRAY_SIZE(tsunami_indices
))
1119 *variation_name
= tsunami_names
[tsunami_indices
[member
]];
1125 * A change was made to the HWRPB via an ECO and the following code
1126 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1127 * was not implemented in the console firmware. If it's revision 5 or
1128 * greater we can get the name of the platform as an ASCII string from
1129 * the HWRPB. That's what this function does. It checks the revision
1130 * level and if the string is in the HWRPB it returns the address of
1131 * the string--a pointer to the name of the platform.
1134 * - Pointer to a ASCII string if it's in the HWRPB
1135 * - Pointer to a blank string if the data is not in the HWRPB.
1139 platform_string(void)
1141 struct dsr_struct
*dsr
;
1142 static char unk_system_string
[] = "N/A";
1144 /* Go to the console for the string pointer.
1145 * If the rpb_vers is not 5 or greater the rpb
1146 * is old and does not have this data in it.
1148 if (hwrpb
->revision
< 5)
1149 return (unk_system_string
);
1151 /* The Dynamic System Recognition struct
1152 * has the system platform name starting
1153 * after the character count of the string.
1155 dsr
= ((struct dsr_struct
*)
1156 ((char *)hwrpb
+ hwrpb
->dsr_offset
));
1157 return ((char *)dsr
+ (dsr
->sysname_off
+
1163 get_nr_processors(struct percpu_struct
*cpubase
, unsigned long num
)
1165 struct percpu_struct
*cpu
;
1169 for (i
= 0; i
< num
; i
++) {
1170 cpu
= (struct percpu_struct
*)
1171 ((char *)cpubase
+ i
*hwrpb
->processor_size
);
1172 if ((cpu
->flags
& 0x1cc) == 0x1cc)
1179 show_cache_size (struct seq_file
*f
, const char *which
, int shape
)
1182 seq_printf (f
, "%s\t\t: n/a\n", which
);
1183 else if (shape
== 0)
1184 seq_printf (f
, "%s\t\t: unknown\n", which
);
1186 seq_printf (f
, "%s\t\t: %dK, %d-way, %db line\n",
1187 which
, shape
>> 10, shape
& 15,
1188 1 << ((shape
>> 4) & 15));
1192 show_cpuinfo(struct seq_file
*f
, void *slot
)
1194 extern struct unaligned_stat
{
1195 unsigned long count
, va
, pc
;
1198 static char cpu_names
[][8] = {
1199 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1200 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1201 "EV68CX", "EV7", "EV79", "EV69"
1204 struct percpu_struct
*cpu
= slot
;
1205 unsigned int cpu_index
;
1208 char *sysvariation_name
;
1211 cpu_index
= (unsigned) (cpu
->type
- 1);
1212 cpu_name
= "Unknown";
1213 if (cpu_index
< ARRAY_SIZE(cpu_names
))
1214 cpu_name
= cpu_names
[cpu_index
];
1216 get_sysnames(hwrpb
->sys_type
, hwrpb
->sys_variation
,
1217 cpu
->type
, &systype_name
, &sysvariation_name
);
1219 nr_processors
= get_nr_processors(cpu
, hwrpb
->nr_processors
);
1221 seq_printf(f
, "cpu\t\t\t: Alpha\n"
1222 "cpu model\t\t: %s\n"
1223 "cpu variation\t\t: %ld\n"
1224 "cpu revision\t\t: %ld\n"
1225 "cpu serial number\t: %s\n"
1226 "system type\t\t: %s\n"
1227 "system variation\t: %s\n"
1228 "system revision\t\t: %ld\n"
1229 "system serial number\t: %s\n"
1230 "cycle frequency [Hz]\t: %lu %s\n"
1231 "timer frequency [Hz]\t: %lu.%02lu\n"
1232 "page size [bytes]\t: %ld\n"
1233 "phys. address bits\t: %ld\n"
1234 "max. addr. space #\t: %ld\n"
1235 "BogoMIPS\t\t: %lu.%02lu\n"
1236 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1237 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1238 "platform string\t\t: %s\n"
1239 "cpus detected\t\t: %d\n",
1240 cpu_name
, cpu
->variation
, cpu
->revision
,
1241 (char*)cpu
->serial_no
,
1242 systype_name
, sysvariation_name
, hwrpb
->sys_revision
,
1244 est_cycle_freq
? : hwrpb
->cycle_freq
,
1245 est_cycle_freq
? "est." : "",
1246 hwrpb
->intr_freq
/ 4096,
1247 (100 * hwrpb
->intr_freq
/ 4096) % 100,
1251 loops_per_jiffy
/ (500000/HZ
),
1252 (loops_per_jiffy
/ (5000/HZ
)) % 100,
1253 unaligned
[0].count
, unaligned
[0].pc
, unaligned
[0].va
,
1254 unaligned
[1].count
, unaligned
[1].pc
, unaligned
[1].va
,
1255 platform_string(), nr_processors
);
1258 seq_printf(f
, "cpus active\t\t: %u\n"
1259 "cpu active mask\t\t: %016lx\n",
1260 num_online_cpus(), cpus_addr(cpu_possible_map
)[0]);
1263 show_cache_size (f
, "L1 Icache", alpha_l1i_cacheshape
);
1264 show_cache_size (f
, "L1 Dcache", alpha_l1d_cacheshape
);
1265 show_cache_size (f
, "L2 cache", alpha_l2_cacheshape
);
1266 show_cache_size (f
, "L3 cache", alpha_l3_cacheshape
);
1272 read_mem_block(int *addr
, int stride
, int size
)
1274 long nloads
= size
/ stride
, cnt
, tmp
;
1276 __asm__
__volatile__(
1280 /* Next two XORs introduce an explicit data dependency between
1281 consecutive loads in the loop, which will give us true load
1289 : "=&r" (cnt
), "=&r" (nloads
), "=&r" (addr
), "=&r" (tmp
)
1290 : "r" (stride
), "1" (nloads
), "2" (addr
));
1292 return cnt
/ (size
/ stride
);
1295 #define CSHAPE(totalsize, linesize, assoc) \
1296 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1298 /* ??? EV5 supports up to 64M, but did the systems with more than
1299 16M of BCACHE ever exist? */
1300 #define MAX_BCACHE_SIZE 16*1024*1024
1302 /* Note that the offchip caches are direct mapped on all Alphas. */
1304 external_cache_probe(int minsize
, int width
)
1306 int cycles
, prev_cycles
= 1000000;
1307 int stride
= 1 << width
;
1308 long size
= minsize
, maxsize
= MAX_BCACHE_SIZE
* 2;
1310 if (maxsize
> (max_low_pfn
+ 1) << PAGE_SHIFT
)
1311 maxsize
= 1 << (ilog2(max_low_pfn
+ 1) + PAGE_SHIFT
);
1313 /* Get the first block cached. */
1314 read_mem_block(__va(0), stride
, size
);
1316 while (size
< maxsize
) {
1317 /* Get an average load latency in cycles. */
1318 cycles
= read_mem_block(__va(0), stride
, size
);
1319 if (cycles
> prev_cycles
* 2) {
1320 /* Fine, we exceed the cache. */
1321 printk("%ldK Bcache detected; load hit latency %d "
1322 "cycles, load miss latency %d cycles\n",
1323 size
>> 11, prev_cycles
, cycles
);
1324 return CSHAPE(size
>> 1, width
, 1);
1326 /* Try to get the next block cached. */
1327 read_mem_block(__va(size
), stride
, size
);
1328 prev_cycles
= cycles
;
1331 return -1; /* No BCACHE found. */
1335 determine_cpu_caches (unsigned int cpu_type
)
1337 int L1I
, L1D
, L2
, L3
;
1343 if (cpu_type
== EV4_CPU
)
1344 L1I
= CSHAPE(8*1024, 5, 1);
1346 L1I
= CSHAPE(16*1024, 5, 1);
1350 /* BIU_CTL is a write-only Abox register. PALcode has a
1351 shadow copy, and may be available from some versions
1352 of the CSERVE PALcall. If we can get it, then
1354 unsigned long biu_ctl, size;
1355 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1356 L2 = CSHAPE (size, 5, 1);
1358 Unfortunately, we can't rely on that.
1360 L2
= external_cache_probe(128*1024, 5);
1366 unsigned long car
, size
;
1368 L1I
= L1D
= CSHAPE(8*1024, 5, 1);
1371 car
= *(vuip
) phys_to_virt (0x120000078UL
);
1372 size
= 64*1024 * (1 << ((car
>> 5) & 7));
1373 /* No typo -- 8 byte cacheline size. Whodathunk. */
1374 L2
= (car
& 1 ? CSHAPE (size
, 3, 1) : -1);
1381 unsigned long sc_ctl
, width
;
1383 L1I
= L1D
= CSHAPE(8*1024, 5, 1);
1385 /* Check the line size of the Scache. */
1386 sc_ctl
= *(vulp
) phys_to_virt (0xfffff000a8UL
);
1387 width
= sc_ctl
& 0x1000 ? 6 : 5;
1388 L2
= CSHAPE (96*1024, width
, 3);
1390 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1391 has a shadow copy, and may be available from some versions
1392 of the CSERVE PALcall. If we can get it, then
1394 unsigned long bc_control, bc_config, size;
1395 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1396 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1398 Unfortunately, we can't rely on that.
1400 L3
= external_cache_probe(1024*1024, width
);
1407 unsigned long cbox_config
, size
;
1409 if (cpu_type
== PCA56_CPU
) {
1410 L1I
= CSHAPE(16*1024, 6, 1);
1411 L1D
= CSHAPE(8*1024, 5, 1);
1413 L1I
= CSHAPE(32*1024, 6, 2);
1414 L1D
= CSHAPE(16*1024, 5, 1);
1418 cbox_config
= *(vulp
) phys_to_virt (0xfffff00008UL
);
1419 size
= 512*1024 * (1 << ((cbox_config
>> 12) & 3));
1422 L2
= ((cbox_config
>> 31) & 1 ? CSHAPE (size
, 6, 1) : -1);
1424 L2
= external_cache_probe(512*1024, 6);
1435 L1I
= L1D
= CSHAPE(64*1024, 6, 2);
1436 L2
= external_cache_probe(1024*1024, 6);
1442 L1I
= L1D
= CSHAPE(64*1024, 6, 2);
1443 L2
= CSHAPE(7*1024*1024/4, 6, 7);
1448 /* Nothing known about this cpu type. */
1449 L1I
= L1D
= L2
= L3
= 0;
1453 alpha_l1i_cacheshape
= L1I
;
1454 alpha_l1d_cacheshape
= L1D
;
1455 alpha_l2_cacheshape
= L2
;
1456 alpha_l3_cacheshape
= L3
;
1460 * We show only CPU #0 info.
1463 c_start(struct seq_file
*f
, loff_t
*pos
)
1465 return *pos
? NULL
: (char *)hwrpb
+ hwrpb
->processor_offset
;
1469 c_next(struct seq_file
*f
, void *v
, loff_t
*pos
)
1475 c_stop(struct seq_file
*f
, void *v
)
1479 const struct seq_operations cpuinfo_op
= {
1483 .show
= show_cpuinfo
,
1488 alpha_panic_event(struct notifier_block
*this, unsigned long event
, void *ptr
)
1491 /* FIXME FIXME FIXME */
1492 /* If we are using SRM and serial console, just hard halt here. */
1493 if (alpha_using_srm
&& srmcons_output
)
1499 static __init
int add_pcspkr(void)
1501 struct platform_device
*pd
;
1504 pd
= platform_device_alloc("pcspkr", -1);
1508 ret
= platform_device_add(pd
);
1510 platform_device_put(pd
);
1514 device_initcall(add_pcspkr
);