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>
46 #include <linux/export.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/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
;
120 #ifndef alpha_using_srm
122 EXPORT_SYMBOL(alpha_using_srm
);
125 #ifndef alpha_using_qemu
126 int alpha_using_qemu
;
129 static struct alpha_machine_vector
*get_sysvec(unsigned long, unsigned long,
131 static struct alpha_machine_vector
*get_sysvec_byname(const char *);
132 static void get_sysnames(unsigned long, unsigned long, unsigned long,
134 static void determine_cpu_caches (unsigned int);
136 static char __initdata command_line
[COMMAND_LINE_SIZE
];
139 * The format of "screen_info" is strange, and due to early
140 * i386-setup code. This is just enough to make the console
141 * code think we're on a VGA color display.
144 struct screen_info screen_info
= {
147 .orig_video_cols
= 80,
148 .orig_video_lines
= 25,
149 .orig_video_isVGA
= 1,
150 .orig_video_points
= 16
153 EXPORT_SYMBOL(screen_info
);
156 * The direct map I/O window, if any. This should be the same
157 * for all busses, since it's used by virt_to_bus.
160 unsigned long __direct_map_base
;
161 unsigned long __direct_map_size
;
162 EXPORT_SYMBOL(__direct_map_base
);
163 EXPORT_SYMBOL(__direct_map_size
);
166 * Declare all of the machine vectors.
169 /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
170 __attribute__((weak)) or #pragma weak. Bypass it and talk directly
174 extern struct alpha_machine_vector X; \
194 WEAK(mikasa_primo_mv
);
199 WEAK(noritake_primo_mv
);
207 WEAK(sable_gamma_mv
);
220 * I/O resources inherited from PeeCees. Except for perhaps the
221 * turbochannel alphas, everyone has these on some sort of SuperIO chip.
223 * ??? If this becomes less standard, move the struct out into the
228 reserve_std_resources(void)
230 static struct resource standard_io_resources
[] = {
231 { .name
= "rtc", .start
= -1, .end
= -1 },
232 { .name
= "dma1", .start
= 0x00, .end
= 0x1f },
233 { .name
= "pic1", .start
= 0x20, .end
= 0x3f },
234 { .name
= "timer", .start
= 0x40, .end
= 0x5f },
235 { .name
= "keyboard", .start
= 0x60, .end
= 0x6f },
236 { .name
= "dma page reg", .start
= 0x80, .end
= 0x8f },
237 { .name
= "pic2", .start
= 0xa0, .end
= 0xbf },
238 { .name
= "dma2", .start
= 0xc0, .end
= 0xdf },
241 struct resource
*io
= &ioport_resource
;
245 struct pci_controller
*hose
;
246 for (hose
= hose_head
; hose
; hose
= hose
->next
)
247 if (hose
->index
== 0) {
253 /* Fix up for the Jensen's queer RTC placement. */
254 standard_io_resources
[0].start
= RTC_PORT(0);
255 standard_io_resources
[0].end
= RTC_PORT(0) + 0x10;
257 for (i
= 0; i
< ARRAY_SIZE(standard_io_resources
); ++i
)
258 request_resource(io
, standard_io_resources
+i
);
261 #define PFN_MAX PFN_DOWN(0x80000000)
262 #define for_each_mem_cluster(memdesc, _cluster, i) \
263 for ((_cluster) = (memdesc)->cluster, (i) = 0; \
264 (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
266 static unsigned long __init
267 get_mem_size_limit(char *s
)
269 unsigned long end
= 0;
272 end
= simple_strtoul(from
, &from
, 0);
273 if ( *from
== 'K' || *from
== 'k' ) {
276 } else if ( *from
== 'M' || *from
== 'm' ) {
279 } else if ( *from
== 'G' || *from
== 'g' ) {
283 return end
>> PAGE_SHIFT
; /* Return the PFN of the limit. */
286 #ifdef CONFIG_BLK_DEV_INITRD
288 move_initrd(unsigned long mem_limit
)
293 size
= initrd_end
- initrd_start
;
294 start
= __alloc_bootmem(PAGE_ALIGN(size
), PAGE_SIZE
, 0);
295 if (!start
|| __pa(start
) + size
> mem_limit
) {
296 initrd_start
= initrd_end
= 0;
299 memmove(start
, (void *)initrd_start
, size
);
300 initrd_start
= (unsigned long)start
;
301 initrd_end
= initrd_start
+ size
;
302 printk("initrd moved to %p\n", start
);
307 #ifndef CONFIG_DISCONTIGMEM
309 setup_memory(void *kernel_end
)
311 struct memclust_struct
* cluster
;
312 struct memdesc_struct
* memdesc
;
313 unsigned long start_kernel_pfn
, end_kernel_pfn
;
314 unsigned long bootmap_size
, bootmap_pages
, bootmap_start
;
315 unsigned long start
, end
;
318 /* Find free clusters, and init and free the bootmem accordingly. */
319 memdesc
= (struct memdesc_struct
*)
320 (hwrpb
->mddt_offset
+ (unsigned long) hwrpb
);
322 for_each_mem_cluster(memdesc
, cluster
, i
) {
323 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
324 i
, cluster
->usage
, cluster
->start_pfn
,
325 cluster
->start_pfn
+ cluster
->numpages
);
327 /* Bit 0 is console/PALcode reserved. Bit 1 is
328 non-volatile memory -- we might want to mark
330 if (cluster
->usage
& 3)
333 end
= cluster
->start_pfn
+ cluster
->numpages
;
334 if (end
> max_low_pfn
)
339 * Except for the NUMA systems (wildfire, marvel) all of the
340 * Alpha systems we run on support 32GB of memory or less.
341 * Since the NUMA systems introduce large holes in memory addressing,
342 * we can get into a situation where there is not enough contiguous
343 * memory for the memory map.
345 * Limit memory to the first 32GB to limit the NUMA systems to
346 * memory on their first node (wildfire) or 2 (marvel) to avoid
347 * not being able to produce the memory map. In order to access
348 * all of the memory on the NUMA systems, build with discontiguous
351 * If the user specified a memory limit, let that memory limit stand.
354 mem_size_limit
= (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT
;
356 if (mem_size_limit
&& max_low_pfn
>= mem_size_limit
)
358 printk("setup: forcing memory size to %ldK (from %ldK).\n",
359 mem_size_limit
<< (PAGE_SHIFT
- 10),
360 max_low_pfn
<< (PAGE_SHIFT
- 10));
361 max_low_pfn
= mem_size_limit
;
364 /* Find the bounds of kernel memory. */
365 start_kernel_pfn
= PFN_DOWN(KERNEL_START_PHYS
);
366 end_kernel_pfn
= PFN_UP(virt_to_phys(kernel_end
));
370 if (max_low_pfn
<= end_kernel_pfn
)
371 panic("not enough memory to boot");
373 /* We need to know how many physically contiguous pages
374 we'll need for the bootmap. */
375 bootmap_pages
= bootmem_bootmap_pages(max_low_pfn
);
377 /* Now find a good region where to allocate the bootmap. */
378 for_each_mem_cluster(memdesc
, cluster
, i
) {
379 if (cluster
->usage
& 3)
382 start
= cluster
->start_pfn
;
383 end
= start
+ cluster
->numpages
;
384 if (start
>= max_low_pfn
)
386 if (end
> max_low_pfn
)
388 if (start
< start_kernel_pfn
) {
389 if (end
> end_kernel_pfn
390 && end
- end_kernel_pfn
>= bootmap_pages
) {
391 bootmap_start
= end_kernel_pfn
;
393 } else if (end
> start_kernel_pfn
)
394 end
= start_kernel_pfn
;
395 } else if (start
< end_kernel_pfn
)
396 start
= end_kernel_pfn
;
397 if (end
- start
>= bootmap_pages
) {
398 bootmap_start
= start
;
403 if (bootmap_start
== ~0UL) {
408 /* Allocate the bootmap and mark the whole MM as reserved. */
409 bootmap_size
= init_bootmem(bootmap_start
, max_low_pfn
);
411 /* Mark the free regions. */
412 for_each_mem_cluster(memdesc
, cluster
, i
) {
413 if (cluster
->usage
& 3)
416 start
= cluster
->start_pfn
;
417 end
= cluster
->start_pfn
+ cluster
->numpages
;
418 if (start
>= max_low_pfn
)
420 if (end
> max_low_pfn
)
422 if (start
< start_kernel_pfn
) {
423 if (end
> end_kernel_pfn
) {
424 free_bootmem(PFN_PHYS(start
),
425 (PFN_PHYS(start_kernel_pfn
)
427 printk("freeing pages %ld:%ld\n",
428 start
, start_kernel_pfn
);
429 start
= end_kernel_pfn
;
430 } else if (end
> start_kernel_pfn
)
431 end
= start_kernel_pfn
;
432 } else if (start
< end_kernel_pfn
)
433 start
= end_kernel_pfn
;
437 free_bootmem(PFN_PHYS(start
), PFN_PHYS(end
) - PFN_PHYS(start
));
438 printk("freeing pages %ld:%ld\n", start
, end
);
441 /* Reserve the bootmap memory. */
442 reserve_bootmem(PFN_PHYS(bootmap_start
), bootmap_size
,
444 printk("reserving pages %ld:%ld\n", bootmap_start
, bootmap_start
+PFN_UP(bootmap_size
));
446 #ifdef CONFIG_BLK_DEV_INITRD
447 initrd_start
= INITRD_START
;
449 initrd_end
= initrd_start
+INITRD_SIZE
;
450 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
451 (void *) initrd_start
, INITRD_SIZE
);
453 if ((void *)initrd_end
> phys_to_virt(PFN_PHYS(max_low_pfn
))) {
454 if (!move_initrd(PFN_PHYS(max_low_pfn
)))
455 printk("initrd extends beyond end of memory "
456 "(0x%08lx > 0x%p)\ndisabling initrd\n",
458 phys_to_virt(PFN_PHYS(max_low_pfn
)));
460 reserve_bootmem(virt_to_phys((void *)initrd_start
),
461 INITRD_SIZE
, BOOTMEM_DEFAULT
);
464 #endif /* CONFIG_BLK_DEV_INITRD */
467 extern void setup_memory(void *);
468 #endif /* !CONFIG_DISCONTIGMEM */
471 page_is_ram(unsigned long pfn
)
473 struct memclust_struct
* cluster
;
474 struct memdesc_struct
* memdesc
;
477 memdesc
= (struct memdesc_struct
*)
478 (hwrpb
->mddt_offset
+ (unsigned long) hwrpb
);
479 for_each_mem_cluster(memdesc
, cluster
, i
)
481 if (pfn
>= cluster
->start_pfn
&&
482 pfn
< cluster
->start_pfn
+ cluster
->numpages
) {
483 return (cluster
->usage
& 3) ? 0 : 1;
495 for_each_possible_cpu(i
) {
496 struct cpu
*p
= kzalloc(sizeof(*p
), GFP_KERNEL
);
504 arch_initcall(register_cpus
);
507 setup_arch(char **cmdline_p
)
511 struct alpha_machine_vector
*vec
= NULL
;
512 struct percpu_struct
*cpu
;
513 char *type_name
, *var_name
, *p
;
514 void *kernel_end
= _end
; /* end of kernel */
515 char *args
= command_line
;
517 hwrpb
= (struct hwrpb_struct
*) __va(INIT_HWRPB
->phys_addr
);
518 boot_cpuid
= hard_smp_processor_id();
521 * Pre-process the system type to make sure it will be valid.
523 * This may restore real CABRIO and EB66+ family names, ie
526 * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
527 * and AS1200 (DIGITAL Server 5000 series) have the type as
528 * the negative of the real one.
530 if ((long)hwrpb
->sys_type
< 0) {
531 hwrpb
->sys_type
= -((long)hwrpb
->sys_type
);
532 hwrpb_update_checksum(hwrpb
);
535 /* Register a call for panic conditions. */
536 atomic_notifier_chain_register(&panic_notifier_list
,
539 #ifndef alpha_using_srm
540 /* Assume that we've booted from SRM if we haven't booted from MILO.
541 Detect the later by looking for "MILO" in the system serial nr. */
542 alpha_using_srm
= strncmp((const char *)hwrpb
->ssn
, "MILO", 4) != 0;
544 #ifndef alpha_using_qemu
545 /* Similarly, look for QEMU. */
546 alpha_using_qemu
= strstr((const char *)hwrpb
->ssn
, "QEMU") != 0;
549 /* If we are using SRM, we want to allow callbacks
550 as early as possible, so do this NOW, and then
551 they should work immediately thereafter.
553 kernel_end
= callback_init(kernel_end
);
556 * Locate the command line.
558 /* Hack for Jensen... since we're restricted to 8 or 16 chars for
559 boot flags depending on the boot mode, we need some shorthand.
560 This should do for installation. */
561 if (strcmp(COMMAND_LINE
, "INSTALL") == 0) {
562 strlcpy(command_line
, "root=/dev/fd0 load_ramdisk=1", sizeof command_line
);
564 strlcpy(command_line
, COMMAND_LINE
, sizeof command_line
);
566 strcpy(boot_command_line
, command_line
);
567 *cmdline_p
= command_line
;
570 * Process command-line arguments.
572 while ((p
= strsep(&args
, " \t")) != NULL
) {
574 if (strncmp(p
, "alpha_mv=", 9) == 0) {
575 vec
= get_sysvec_byname(p
+9);
578 if (strncmp(p
, "cycle=", 6) == 0) {
579 est_cycle_freq
= simple_strtol(p
+6, NULL
, 0);
582 if (strncmp(p
, "mem=", 4) == 0) {
583 mem_size_limit
= get_mem_size_limit(p
+4);
586 if (strncmp(p
, "srmcons", 7) == 0) {
590 if (strncmp(p
, "console=srm", 11) == 0) {
594 if (strncmp(p
, "gartsize=", 9) == 0) {
596 get_mem_size_limit(p
+9) << PAGE_SHIFT
;
599 #ifdef CONFIG_VERBOSE_MCHECK
600 if (strncmp(p
, "verbose_mcheck=", 15) == 0) {
601 alpha_verbose_mcheck
= simple_strtol(p
+15, NULL
, 0);
607 /* Replace the command line, now that we've killed it with strsep. */
608 strcpy(command_line
, boot_command_line
);
610 /* If we want SRM console printk echoing early, do it now. */
611 if (alpha_using_srm
&& srmcons_output
) {
612 register_srm_console();
615 * If "console=srm" was specified, clear the srmcons_output
616 * flag now so that time.c won't unregister_srm_console
618 if (srmcons_output
& 2)
622 #ifdef CONFIG_MAGIC_SYSRQ
623 /* If we're using SRM, make sysrq-b halt back to the prom,
625 if (alpha_using_srm
) {
626 struct sysrq_key_op
*op
= __sysrq_get_key_op('b');
627 op
->handler
= (void *) machine_halt
;
632 * Identify and reconfigure for the current system.
634 cpu
= (struct percpu_struct
*)((char*)hwrpb
+ hwrpb
->processor_offset
);
636 get_sysnames(hwrpb
->sys_type
, hwrpb
->sys_variation
,
637 cpu
->type
, &type_name
, &var_name
);
638 if (*var_name
== '0')
642 vec
= get_sysvec(hwrpb
->sys_type
, hwrpb
->sys_variation
,
647 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
648 type_name
, (*var_name
? " variation " : ""), var_name
,
649 hwrpb
->sys_type
, hwrpb
->sys_variation
);
651 if (vec
!= &alpha_mv
) {
656 #ifdef CONFIG_ALPHA_GENERIC
659 "on %s%s%s using machine vector %s from %s\n",
660 type_name
, (*var_name
? " variation " : ""),
661 var_name
, alpha_mv
.vector_name
,
662 (alpha_using_srm
? "SRM" : "MILO"));
664 printk("Major Options: "
668 #ifdef CONFIG_ALPHA_EV56
671 #ifdef CONFIG_ALPHA_EV67
674 #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
677 #ifdef CONFIG_VERBOSE_MCHECK
681 #ifdef CONFIG_DISCONTIGMEM
688 #ifdef CONFIG_DEBUG_SPINLOCK
691 #ifdef CONFIG_MAGIC_SYSRQ
696 printk("Command line: %s\n", command_line
);
700 * Save the SRM's current value for restoration.
702 srm_hae
= *alpha_mv
.hae_register
;
703 __set_hae(alpha_mv
.hae_cache
);
705 /* Reset enable correctable error reports. */
708 /* Find our memory. */
709 setup_memory(kernel_end
);
711 /* First guess at cpu cache sizes. Do this before init_arch. */
712 determine_cpu_caches(cpu
->type
);
714 /* Initialize the machine. Usually has to do with setting up
715 DMA windows and the like. */
716 if (alpha_mv
.init_arch
)
717 alpha_mv
.init_arch();
719 /* Reserve standard resources. */
720 reserve_std_resources();
723 * Give us a default console. TGA users will see nothing until
724 * chr_dev_init is called, rather late in the boot sequence.
728 #if defined(CONFIG_VGA_CONSOLE)
729 conswitchp
= &vga_con
;
730 #elif defined(CONFIG_DUMMY_CONSOLE)
731 conswitchp
= &dummy_con
;
735 /* Default root filesystem to sda2. */
736 ROOT_DEV
= Root_SDA2
;
739 /* FIXME: only set this when we actually have EISA in this box? */
744 * Check ASN in HWRPB for validity, report if bad.
745 * FIXME: how was this failing? Should we trust it instead,
746 * and copy the value into alpha_mv.max_asn?
749 if (hwrpb
->max_asn
!= MAX_ASN
) {
750 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb
->max_asn
);
754 * Identify the flock of penguins.
763 static char sys_unknown
[] = "Unknown";
764 static char systype_names
[][16] = {
766 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
767 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
768 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
769 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
770 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
771 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
772 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
775 static char unofficial_names
[][8] = {"100", "Ruffian"};
777 static char api_names
[][16] = {"200", "Nautilus"};
779 static char eb164_names
[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
780 static int eb164_indices
[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
782 static char alcor_names
[][16] = {"Alcor", "Maverick", "Bret"};
783 static int alcor_indices
[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
785 static char eb64p_names
[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
786 static int eb64p_indices
[] = {0,0,1,2};
788 static char eb66_names
[][8] = {"EB66", "EB66+"};
789 static int eb66_indices
[] = {0,0,1};
791 static char marvel_names
[][16] = {
794 static int marvel_indices
[] = { 0 };
796 static char rawhide_names
[][16] = {
797 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
799 static int rawhide_indices
[] = {0,0,0,1,1,2,2,3,3,4,4};
801 static char titan_names
[][16] = {
802 "DEFAULT", "Privateer", "Falcon", "Granite"
804 static int titan_indices
[] = {0,1,2,2,3};
806 static char tsunami_names
[][16] = {
807 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
808 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
809 "Flying Clipper", "Shark"
811 static int tsunami_indices
[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
813 static struct alpha_machine_vector
* __init
814 get_sysvec(unsigned long type
, unsigned long variation
, unsigned long cpu
)
816 static struct alpha_machine_vector
*systype_vecs
[] __initdata
=
823 NULL
, /* Mannequin */
827 NULL
, /* Sable -- see below. */
830 NULL
, /* Turbolaser */
833 NULL
, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
834 NULL
, /* Tradewind */
835 NULL
, /* Mikasa -- see below. */
837 NULL
, /* EB66 -- see variation. */
838 NULL
, /* EB64+ -- see variation. */
844 NULL
, /* EB164 -- see variation. */
845 NULL
, /* Noritake -- see below. */
852 NULL
, /* Tsunami -- see variation. */
853 &wildfire_mv
, /* Wildfire */
855 &eiger_mv
, /* Eiger */
860 static struct alpha_machine_vector
*unofficial_vecs
[] __initdata
=
866 static struct alpha_machine_vector
*api_vecs
[] __initdata
=
872 static struct alpha_machine_vector
*alcor_vecs
[] __initdata
=
874 &alcor_mv
, &xlt_mv
, &xlt_mv
877 static struct alpha_machine_vector
*eb164_vecs
[] __initdata
=
879 &eb164_mv
, &pc164_mv
, &lx164_mv
, &sx164_mv
, &rx164_mv
882 static struct alpha_machine_vector
*eb64p_vecs
[] __initdata
=
886 &cabriolet_mv
/* AlphaPCI64 */
889 static struct alpha_machine_vector
*eb66_vecs
[] __initdata
=
895 static struct alpha_machine_vector
*marvel_vecs
[] __initdata
=
900 static struct alpha_machine_vector
*titan_vecs
[] __initdata
=
902 &titan_mv
, /* default */
903 &privateer_mv
, /* privateer */
904 &titan_mv
, /* falcon */
905 &privateer_mv
, /* granite */
908 static struct alpha_machine_vector
*tsunami_vecs
[] __initdata
=
911 &dp264_mv
, /* dp264 */
912 &dp264_mv
, /* warhol */
913 &dp264_mv
, /* windjammer */
914 &monet_mv
, /* monet */
915 &clipper_mv
, /* clipper */
916 &dp264_mv
, /* goldrush */
917 &webbrick_mv
, /* webbrick */
918 &dp264_mv
, /* catamaran */
919 NULL
, /* brisbane? */
920 NULL
, /* melbourne? */
921 NULL
, /* flying clipper? */
922 &shark_mv
, /* shark */
925 /* ??? Do we need to distinguish between Rawhides? */
927 struct alpha_machine_vector
*vec
;
929 /* Search the system tables first... */
931 if (type
< ARRAY_SIZE(systype_vecs
)) {
932 vec
= systype_vecs
[type
];
933 } else if ((type
> ST_API_BIAS
) &&
934 (type
- ST_API_BIAS
) < ARRAY_SIZE(api_vecs
)) {
935 vec
= api_vecs
[type
- ST_API_BIAS
];
936 } else if ((type
> ST_UNOFFICIAL_BIAS
) &&
937 (type
- ST_UNOFFICIAL_BIAS
) < ARRAY_SIZE(unofficial_vecs
)) {
938 vec
= unofficial_vecs
[type
- ST_UNOFFICIAL_BIAS
];
941 /* If we've not found one, try for a variation. */
944 /* Member ID is a bit-field. */
945 unsigned long member
= (variation
>> 10) & 0x3f;
947 cpu
&= 0xffffffff; /* make it usable */
951 if (member
< ARRAY_SIZE(alcor_indices
))
952 vec
= alcor_vecs
[alcor_indices
[member
]];
955 if (member
< ARRAY_SIZE(eb164_indices
))
956 vec
= eb164_vecs
[eb164_indices
[member
]];
957 /* PC164 may show as EB164 variation with EV56 CPU,
958 but, since no true EB164 had anything but EV5... */
959 if (vec
== &eb164_mv
&& cpu
== EV56_CPU
)
963 if (member
< ARRAY_SIZE(eb64p_indices
))
964 vec
= eb64p_vecs
[eb64p_indices
[member
]];
967 if (member
< ARRAY_SIZE(eb66_indices
))
968 vec
= eb66_vecs
[eb66_indices
[member
]];
971 if (member
< ARRAY_SIZE(marvel_indices
))
972 vec
= marvel_vecs
[marvel_indices
[member
]];
975 vec
= titan_vecs
[0]; /* default */
976 if (member
< ARRAY_SIZE(titan_indices
))
977 vec
= titan_vecs
[titan_indices
[member
]];
980 if (member
< ARRAY_SIZE(tsunami_indices
))
981 vec
= tsunami_vecs
[tsunami_indices
[member
]];
984 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
985 vec
= &mikasa_primo_mv
;
989 case ST_DEC_NORITAKE
:
990 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
991 vec
= &noritake_primo_mv
;
995 case ST_DEC_2100_A500
:
996 if (cpu
== EV5_CPU
|| cpu
== EV56_CPU
)
997 vec
= &sable_gamma_mv
;
1006 static struct alpha_machine_vector
* __init
1007 get_sysvec_byname(const char *name
)
1009 static struct alpha_machine_vector
*all_vecs
[] __initdata
=
1052 for (i
= 0; i
< ARRAY_SIZE(all_vecs
); ++i
) {
1053 struct alpha_machine_vector
*mv
= all_vecs
[i
];
1054 if (strcasecmp(mv
->vector_name
, name
) == 0)
1061 get_sysnames(unsigned long type
, unsigned long variation
, unsigned long cpu
,
1062 char **type_name
, char **variation_name
)
1064 unsigned long member
;
1066 /* If not in the tables, make it UNKNOWN,
1067 else set type name to family */
1068 if (type
< ARRAY_SIZE(systype_names
)) {
1069 *type_name
= systype_names
[type
];
1070 } else if ((type
> ST_API_BIAS
) &&
1071 (type
- ST_API_BIAS
) < ARRAY_SIZE(api_names
)) {
1072 *type_name
= api_names
[type
- ST_API_BIAS
];
1073 } else if ((type
> ST_UNOFFICIAL_BIAS
) &&
1074 (type
- ST_UNOFFICIAL_BIAS
) < ARRAY_SIZE(unofficial_names
)) {
1075 *type_name
= unofficial_names
[type
- ST_UNOFFICIAL_BIAS
];
1077 *type_name
= sys_unknown
;
1078 *variation_name
= sys_unknown
;
1082 /* Set variation to "0"; if variation is zero, done. */
1083 *variation_name
= systype_names
[0];
1084 if (variation
== 0) {
1088 member
= (variation
>> 10) & 0x3f; /* member ID is a bit-field */
1090 cpu
&= 0xffffffff; /* make it usable */
1092 switch (type
) { /* select by family */
1093 default: /* default to variation "0" for now */
1096 if (member
< ARRAY_SIZE(eb164_indices
))
1097 *variation_name
= eb164_names
[eb164_indices
[member
]];
1098 /* PC164 may show as EB164 variation, but with EV56 CPU,
1099 so, since no true EB164 had anything but EV5... */
1100 if (eb164_indices
[member
] == 0 && cpu
== EV56_CPU
)
1101 *variation_name
= eb164_names
[1]; /* make it PC164 */
1104 if (member
< ARRAY_SIZE(alcor_indices
))
1105 *variation_name
= alcor_names
[alcor_indices
[member
]];
1108 if (member
< ARRAY_SIZE(eb64p_indices
))
1109 *variation_name
= eb64p_names
[eb64p_indices
[member
]];
1112 if (member
< ARRAY_SIZE(eb66_indices
))
1113 *variation_name
= eb66_names
[eb66_indices
[member
]];
1116 if (member
< ARRAY_SIZE(marvel_indices
))
1117 *variation_name
= marvel_names
[marvel_indices
[member
]];
1119 case ST_DEC_RAWHIDE
:
1120 if (member
< ARRAY_SIZE(rawhide_indices
))
1121 *variation_name
= rawhide_names
[rawhide_indices
[member
]];
1124 *variation_name
= titan_names
[0]; /* default */
1125 if (member
< ARRAY_SIZE(titan_indices
))
1126 *variation_name
= titan_names
[titan_indices
[member
]];
1128 case ST_DEC_TSUNAMI
:
1129 if (member
< ARRAY_SIZE(tsunami_indices
))
1130 *variation_name
= tsunami_names
[tsunami_indices
[member
]];
1136 * A change was made to the HWRPB via an ECO and the following code
1137 * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
1138 * was not implemented in the console firmware. If it's revision 5 or
1139 * greater we can get the name of the platform as an ASCII string from
1140 * the HWRPB. That's what this function does. It checks the revision
1141 * level and if the string is in the HWRPB it returns the address of
1142 * the string--a pointer to the name of the platform.
1145 * - Pointer to a ASCII string if it's in the HWRPB
1146 * - Pointer to a blank string if the data is not in the HWRPB.
1150 platform_string(void)
1152 struct dsr_struct
*dsr
;
1153 static char unk_system_string
[] = "N/A";
1155 /* Go to the console for the string pointer.
1156 * If the rpb_vers is not 5 or greater the rpb
1157 * is old and does not have this data in it.
1159 if (hwrpb
->revision
< 5)
1160 return (unk_system_string
);
1162 /* The Dynamic System Recognition struct
1163 * has the system platform name starting
1164 * after the character count of the string.
1166 dsr
= ((struct dsr_struct
*)
1167 ((char *)hwrpb
+ hwrpb
->dsr_offset
));
1168 return ((char *)dsr
+ (dsr
->sysname_off
+
1174 get_nr_processors(struct percpu_struct
*cpubase
, unsigned long num
)
1176 struct percpu_struct
*cpu
;
1180 for (i
= 0; i
< num
; i
++) {
1181 cpu
= (struct percpu_struct
*)
1182 ((char *)cpubase
+ i
*hwrpb
->processor_size
);
1183 if ((cpu
->flags
& 0x1cc) == 0x1cc)
1190 show_cache_size (struct seq_file
*f
, const char *which
, int shape
)
1193 seq_printf (f
, "%s\t\t: n/a\n", which
);
1194 else if (shape
== 0)
1195 seq_printf (f
, "%s\t\t: unknown\n", which
);
1197 seq_printf (f
, "%s\t\t: %dK, %d-way, %db line\n",
1198 which
, shape
>> 10, shape
& 15,
1199 1 << ((shape
>> 4) & 15));
1203 show_cpuinfo(struct seq_file
*f
, void *slot
)
1205 extern struct unaligned_stat
{
1206 unsigned long count
, va
, pc
;
1209 static char cpu_names
[][8] = {
1210 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1211 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1212 "EV68CX", "EV7", "EV79", "EV69"
1215 struct percpu_struct
*cpu
= slot
;
1216 unsigned int cpu_index
;
1219 char *sysvariation_name
;
1221 unsigned long timer_freq
;
1223 cpu_index
= (unsigned) (cpu
->type
- 1);
1224 cpu_name
= "Unknown";
1225 if (cpu_index
< ARRAY_SIZE(cpu_names
))
1226 cpu_name
= cpu_names
[cpu_index
];
1228 get_sysnames(hwrpb
->sys_type
, hwrpb
->sys_variation
,
1229 cpu
->type
, &systype_name
, &sysvariation_name
);
1231 nr_processors
= get_nr_processors(cpu
, hwrpb
->nr_processors
);
1233 #if CONFIG_HZ == 1024 || CONFIG_HZ == 1200
1234 timer_freq
= (100UL * hwrpb
->intr_freq
) / 4096;
1236 timer_freq
= 100UL * CONFIG_HZ
;
1239 seq_printf(f
, "cpu\t\t\t: Alpha\n"
1240 "cpu model\t\t: %s\n"
1241 "cpu variation\t\t: %ld\n"
1242 "cpu revision\t\t: %ld\n"
1243 "cpu serial number\t: %s\n"
1244 "system type\t\t: %s\n"
1245 "system variation\t: %s\n"
1246 "system revision\t\t: %ld\n"
1247 "system serial number\t: %s\n"
1248 "cycle frequency [Hz]\t: %lu %s\n"
1249 "timer frequency [Hz]\t: %lu.%02lu\n"
1250 "page size [bytes]\t: %ld\n"
1251 "phys. address bits\t: %ld\n"
1252 "max. addr. space #\t: %ld\n"
1253 "BogoMIPS\t\t: %lu.%02lu\n"
1254 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1255 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1256 "platform string\t\t: %s\n"
1257 "cpus detected\t\t: %d\n",
1258 cpu_name
, cpu
->variation
, cpu
->revision
,
1259 (char*)cpu
->serial_no
,
1260 systype_name
, sysvariation_name
, hwrpb
->sys_revision
,
1262 est_cycle_freq
? : hwrpb
->cycle_freq
,
1263 est_cycle_freq
? "est." : "",
1264 timer_freq
/ 100, timer_freq
% 100,
1268 loops_per_jiffy
/ (500000/HZ
),
1269 (loops_per_jiffy
/ (5000/HZ
)) % 100,
1270 unaligned
[0].count
, unaligned
[0].pc
, unaligned
[0].va
,
1271 unaligned
[1].count
, unaligned
[1].pc
, unaligned
[1].va
,
1272 platform_string(), nr_processors
);
1275 seq_printf(f
, "cpus active\t\t: %u\n"
1276 "cpu active mask\t\t: %016lx\n",
1277 num_online_cpus(), cpumask_bits(cpu_possible_mask
)[0]);
1280 show_cache_size (f
, "L1 Icache", alpha_l1i_cacheshape
);
1281 show_cache_size (f
, "L1 Dcache", alpha_l1d_cacheshape
);
1282 show_cache_size (f
, "L2 cache", alpha_l2_cacheshape
);
1283 show_cache_size (f
, "L3 cache", alpha_l3_cacheshape
);
1289 read_mem_block(int *addr
, int stride
, int size
)
1291 long nloads
= size
/ stride
, cnt
, tmp
;
1293 __asm__
__volatile__(
1297 /* Next two XORs introduce an explicit data dependency between
1298 consecutive loads in the loop, which will give us true load
1306 : "=&r" (cnt
), "=&r" (nloads
), "=&r" (addr
), "=&r" (tmp
)
1307 : "r" (stride
), "1" (nloads
), "2" (addr
));
1309 return cnt
/ (size
/ stride
);
1312 #define CSHAPE(totalsize, linesize, assoc) \
1313 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1315 /* ??? EV5 supports up to 64M, but did the systems with more than
1316 16M of BCACHE ever exist? */
1317 #define MAX_BCACHE_SIZE 16*1024*1024
1319 /* Note that the offchip caches are direct mapped on all Alphas. */
1321 external_cache_probe(int minsize
, int width
)
1323 int cycles
, prev_cycles
= 1000000;
1324 int stride
= 1 << width
;
1325 long size
= minsize
, maxsize
= MAX_BCACHE_SIZE
* 2;
1327 if (maxsize
> (max_low_pfn
+ 1) << PAGE_SHIFT
)
1328 maxsize
= 1 << (ilog2(max_low_pfn
+ 1) + PAGE_SHIFT
);
1330 /* Get the first block cached. */
1331 read_mem_block(__va(0), stride
, size
);
1333 while (size
< maxsize
) {
1334 /* Get an average load latency in cycles. */
1335 cycles
= read_mem_block(__va(0), stride
, size
);
1336 if (cycles
> prev_cycles
* 2) {
1337 /* Fine, we exceed the cache. */
1338 printk("%ldK Bcache detected; load hit latency %d "
1339 "cycles, load miss latency %d cycles\n",
1340 size
>> 11, prev_cycles
, cycles
);
1341 return CSHAPE(size
>> 1, width
, 1);
1343 /* Try to get the next block cached. */
1344 read_mem_block(__va(size
), stride
, size
);
1345 prev_cycles
= cycles
;
1348 return -1; /* No BCACHE found. */
1352 determine_cpu_caches (unsigned int cpu_type
)
1354 int L1I
, L1D
, L2
, L3
;
1360 if (cpu_type
== EV4_CPU
)
1361 L1I
= CSHAPE(8*1024, 5, 1);
1363 L1I
= CSHAPE(16*1024, 5, 1);
1367 /* BIU_CTL is a write-only Abox register. PALcode has a
1368 shadow copy, and may be available from some versions
1369 of the CSERVE PALcall. If we can get it, then
1371 unsigned long biu_ctl, size;
1372 size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
1373 L2 = CSHAPE (size, 5, 1);
1375 Unfortunately, we can't rely on that.
1377 L2
= external_cache_probe(128*1024, 5);
1383 unsigned long car
, size
;
1385 L1I
= L1D
= CSHAPE(8*1024, 5, 1);
1388 car
= *(vuip
) phys_to_virt (0x120000078UL
);
1389 size
= 64*1024 * (1 << ((car
>> 5) & 7));
1390 /* No typo -- 8 byte cacheline size. Whodathunk. */
1391 L2
= (car
& 1 ? CSHAPE (size
, 3, 1) : -1);
1398 unsigned long sc_ctl
, width
;
1400 L1I
= L1D
= CSHAPE(8*1024, 5, 1);
1402 /* Check the line size of the Scache. */
1403 sc_ctl
= *(vulp
) phys_to_virt (0xfffff000a8UL
);
1404 width
= sc_ctl
& 0x1000 ? 6 : 5;
1405 L2
= CSHAPE (96*1024, width
, 3);
1407 /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
1408 has a shadow copy, and may be available from some versions
1409 of the CSERVE PALcall. If we can get it, then
1411 unsigned long bc_control, bc_config, size;
1412 size = 1024*1024 * (1 << ((bc_config & 7) - 1));
1413 L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
1415 Unfortunately, we can't rely on that.
1417 L3
= external_cache_probe(1024*1024, width
);
1424 if (cpu_type
== PCA56_CPU
) {
1425 L1I
= CSHAPE(16*1024, 6, 1);
1426 L1D
= CSHAPE(8*1024, 5, 1);
1428 L1I
= CSHAPE(32*1024, 6, 2);
1429 L1D
= CSHAPE(16*1024, 5, 1);
1434 unsigned long cbox_config
, size
;
1436 cbox_config
= *(vulp
) phys_to_virt (0xfffff00008UL
);
1437 size
= 512*1024 * (1 << ((cbox_config
>> 12) & 3));
1439 L2
= ((cbox_config
>> 31) & 1 ? CSHAPE (size
, 6, 1) : -1);
1441 L2
= external_cache_probe(512*1024, 6);
1452 L1I
= L1D
= CSHAPE(64*1024, 6, 2);
1453 L2
= external_cache_probe(1024*1024, 6);
1459 L1I
= L1D
= CSHAPE(64*1024, 6, 2);
1460 L2
= CSHAPE(7*1024*1024/4, 6, 7);
1465 /* Nothing known about this cpu type. */
1466 L1I
= L1D
= L2
= L3
= 0;
1470 alpha_l1i_cacheshape
= L1I
;
1471 alpha_l1d_cacheshape
= L1D
;
1472 alpha_l2_cacheshape
= L2
;
1473 alpha_l3_cacheshape
= L3
;
1477 * We show only CPU #0 info.
1480 c_start(struct seq_file
*f
, loff_t
*pos
)
1482 return *pos
? NULL
: (char *)hwrpb
+ hwrpb
->processor_offset
;
1486 c_next(struct seq_file
*f
, void *v
, loff_t
*pos
)
1492 c_stop(struct seq_file
*f
, void *v
)
1496 const struct seq_operations cpuinfo_op
= {
1500 .show
= show_cpuinfo
,
1505 alpha_panic_event(struct notifier_block
*this, unsigned long event
, void *ptr
)
1508 /* FIXME FIXME FIXME */
1509 /* If we are using SRM and serial console, just hard halt here. */
1510 if (alpha_using_srm
&& srmcons_output
)
1516 static __init
int add_pcspkr(void)
1518 struct platform_device
*pd
;
1521 pd
= platform_device_alloc("pcspkr", -1);
1525 ret
= platform_device_add(pd
);
1527 platform_device_put(pd
);
1531 device_initcall(add_pcspkr
);