1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/sched.h>
14#include <linux/kernel.h>
15#include <linux/mm.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>
25#include <linux/mc146818rtc.h>
26#include <linux/console.h>
27#include <linux/errno.h>
28#include <linux/init.h>
29#include <linux/string.h>
30#include <linux/ioport.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#ifdef CONFIG_MAGIC_SYSRQ
38#include <linux/sysrq.h>
39#include <linux/reboot.h>
40#endif
41#include <linux/notifier.h>
42#include <asm/setup.h>
43#include <asm/io.h>
44
45extern struct notifier_block *panic_notifier_list;
46static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
47static struct notifier_block alpha_panic_block = {
48 alpha_panic_event,
49 NULL,
50 INT_MAX
51};
52
53#include <asm/uaccess.h>
54#include <asm/pgtable.h>
55#include <asm/system.h>
56#include <asm/hwrpb.h>
57#include <asm/dma.h>
58#include <asm/io.h>
59#include <asm/mmu_context.h>
60#include <asm/console.h>
61
62#include "proto.h"
63#include "pci_impl.h"
64
65
66struct hwrpb_struct *hwrpb;
67unsigned long srm_hae;
68
69int alpha_l1i_cacheshape;
70int alpha_l1d_cacheshape;
71int alpha_l2_cacheshape;
72int alpha_l3_cacheshape;
73
74#ifdef CONFIG_VERBOSE_MCHECK
75
76
77unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
78#endif
79
80
81int boot_cpuid;
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101int srmcons_output = 0;
102
103
104unsigned long mem_size_limit = 0;
105
106
107unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
108
109#ifdef CONFIG_ALPHA_GENERIC
110struct alpha_machine_vector alpha_mv;
111int alpha_using_srm;
112#endif
113
114unsigned char aux_device_present = 0xaa;
115
116#define N(a) (sizeof(a)/sizeof(a[0]))
117
118static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
119 unsigned long);
120static struct alpha_machine_vector *get_sysvec_byname(const char *);
121static void get_sysnames(unsigned long, unsigned long, unsigned long,
122 char **, char **);
123static void determine_cpu_caches (unsigned int);
124
125static char command_line[COMMAND_LINE_SIZE];
126
127
128
129
130
131
132
133struct screen_info screen_info = {
134 .orig_x = 0,
135 .orig_y = 25,
136 .orig_video_cols = 80,
137 .orig_video_lines = 25,
138 .orig_video_isVGA = 1,
139 .orig_video_points = 16
140};
141
142
143
144
145
146
147unsigned long __direct_map_base;
148unsigned long __direct_map_size;
149
150
151
152
153
154
155
156
157
158#define WEAK(X) \
159 extern struct alpha_machine_vector X; \
160 asm(".weak "#X)
161
162WEAK(alcor_mv);
163WEAK(alphabook1_mv);
164WEAK(avanti_mv);
165WEAK(cabriolet_mv);
166WEAK(clipper_mv);
167WEAK(dp264_mv);
168WEAK(eb164_mv);
169WEAK(eb64p_mv);
170WEAK(eb66_mv);
171WEAK(eb66p_mv);
172WEAK(eiger_mv);
173WEAK(jensen_mv);
174WEAK(lx164_mv);
175WEAK(lynx_mv);
176WEAK(marvel_ev7_mv);
177WEAK(miata_mv);
178WEAK(mikasa_mv);
179WEAK(mikasa_primo_mv);
180WEAK(monet_mv);
181WEAK(nautilus_mv);
182WEAK(noname_mv);
183WEAK(noritake_mv);
184WEAK(noritake_primo_mv);
185WEAK(p2k_mv);
186WEAK(pc164_mv);
187WEAK(privateer_mv);
188WEAK(rawhide_mv);
189WEAK(ruffian_mv);
190WEAK(rx164_mv);
191WEAK(sable_mv);
192WEAK(sable_gamma_mv);
193WEAK(shark_mv);
194WEAK(sx164_mv);
195WEAK(takara_mv);
196WEAK(titan_mv);
197WEAK(webbrick_mv);
198WEAK(wildfire_mv);
199WEAK(xl_mv);
200WEAK(xlt_mv);
201
202#undef WEAK
203
204
205
206
207
208
209
210
211
212static void __init
213reserve_std_resources(void)
214{
215 static struct resource standard_io_resources[] = {
216 { .name = "rtc", .start = -1, .end = -1 },
217 { .name = "dma1", .start = 0x00, .end = 0x1f },
218 { .name = "pic1", .start = 0x20, .end = 0x3f },
219 { .name = "timer", .start = 0x40, .end = 0x5f },
220 { .name = "keyboard", .start = 0x60, .end = 0x6f },
221 { .name = "dma page reg", .start = 0x80, .end = 0x8f },
222 { .name = "pic2", .start = 0xa0, .end = 0xbf },
223 { .name = "dma2", .start = 0xc0, .end = 0xdf },
224 };
225
226 struct resource *io = &ioport_resource;
227 size_t i;
228
229 if (hose_head) {
230 struct pci_controller *hose;
231 for (hose = hose_head; hose; hose = hose->next)
232 if (hose->index == 0) {
233 io = hose->io_space;
234 break;
235 }
236 }
237
238
239 standard_io_resources[0].start = RTC_PORT(0);
240 standard_io_resources[0].end = RTC_PORT(0) + 0x10;
241
242 for (i = 0; i < N(standard_io_resources); ++i)
243 request_resource(io, standard_io_resources+i);
244}
245
246#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
247#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
248#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
249#define PFN_MAX PFN_DOWN(0x80000000)
250#define for_each_mem_cluster(memdesc, cluster, i) \
251 for ((cluster) = (memdesc)->cluster, (i) = 0; \
252 (i) < (memdesc)->numclusters; (i)++, (cluster)++)
253
254static unsigned long __init
255get_mem_size_limit(char *s)
256{
257 unsigned long end = 0;
258 char *from = s;
259
260 end = simple_strtoul(from, &from, 0);
261 if ( *from == 'K' || *from == 'k' ) {
262 end = end << 10;
263 from++;
264 } else if ( *from == 'M' || *from == 'm' ) {
265 end = end << 20;
266 from++;
267 } else if ( *from == 'G' || *from == 'g' ) {
268 end = end << 30;
269 from++;
270 }
271 return end >> PAGE_SHIFT;
272}
273
274#ifdef CONFIG_BLK_DEV_INITRD
275void * __init
276move_initrd(unsigned long mem_limit)
277{
278 void *start;
279 unsigned long size;
280
281 size = initrd_end - initrd_start;
282 start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
283 if (!start || __pa(start) + size > mem_limit) {
284 initrd_start = initrd_end = 0;
285 return NULL;
286 }
287 memmove(start, (void *)initrd_start, size);
288 initrd_start = (unsigned long)start;
289 initrd_end = initrd_start + size;
290 printk("initrd moved to %p\n", start);
291 return start;
292}
293#endif
294
295#ifndef CONFIG_DISCONTIGMEM
296static void __init
297setup_memory(void *kernel_end)
298{
299 struct memclust_struct * cluster;
300 struct memdesc_struct * memdesc;
301 unsigned long start_kernel_pfn, end_kernel_pfn;
302 unsigned long bootmap_size, bootmap_pages, bootmap_start;
303 unsigned long start, end;
304 unsigned long i;
305
306
307 memdesc = (struct memdesc_struct *)
308 (hwrpb->mddt_offset + (unsigned long) hwrpb);
309
310 for_each_mem_cluster(memdesc, cluster, i) {
311 printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
312 i, cluster->usage, cluster->start_pfn,
313 cluster->start_pfn + cluster->numpages);
314
315
316
317
318 if (cluster->usage & 3)
319 continue;
320
321 end = cluster->start_pfn + cluster->numpages;
322 if (end > max_low_pfn)
323 max_low_pfn = end;
324 }
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341 if (!mem_size_limit)
342 mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
343
344 if (mem_size_limit && max_low_pfn >= mem_size_limit)
345 {
346 printk("setup: forcing memory size to %ldK (from %ldK).\n",
347 mem_size_limit << (PAGE_SHIFT - 10),
348 max_low_pfn << (PAGE_SHIFT - 10));
349 max_low_pfn = mem_size_limit;
350 }
351
352
353 start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
354 end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
355 bootmap_start = -1;
356
357 try_again:
358 if (max_low_pfn <= end_kernel_pfn)
359 panic("not enough memory to boot");
360
361
362
363 bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
364
365
366 for_each_mem_cluster(memdesc, cluster, i) {
367 if (cluster->usage & 3)
368 continue;
369
370 start = cluster->start_pfn;
371 end = start + cluster->numpages;
372 if (start >= max_low_pfn)
373 continue;
374 if (end > max_low_pfn)
375 end = max_low_pfn;
376 if (start < start_kernel_pfn) {
377 if (end > end_kernel_pfn
378 && end - end_kernel_pfn >= bootmap_pages) {
379 bootmap_start = end_kernel_pfn;
380 break;
381 } else if (end > start_kernel_pfn)
382 end = start_kernel_pfn;
383 } else if (start < end_kernel_pfn)
384 start = end_kernel_pfn;
385 if (end - start >= bootmap_pages) {
386 bootmap_start = start;
387 break;
388 }
389 }
390
391 if (bootmap_start == ~0UL) {
392 max_low_pfn >>= 1;
393 goto try_again;
394 }
395
396
397 bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
398
399
400 for_each_mem_cluster(memdesc, cluster, i) {
401 if (cluster->usage & 3)
402 continue;
403
404 start = cluster->start_pfn;
405 end = cluster->start_pfn + cluster->numpages;
406 if (start >= max_low_pfn)
407 continue;
408 if (end > max_low_pfn)
409 end = max_low_pfn;
410 if (start < start_kernel_pfn) {
411 if (end > end_kernel_pfn) {
412 free_bootmem(PFN_PHYS(start),
413 (PFN_PHYS(start_kernel_pfn)
414 - PFN_PHYS(start)));
415 printk("freeing pages %ld:%ld\n",
416 start, start_kernel_pfn);
417 start = end_kernel_pfn;
418 } else if (end > start_kernel_pfn)
419 end = start_kernel_pfn;
420 } else if (start < end_kernel_pfn)
421 start = end_kernel_pfn;
422 if (start >= end)
423 continue;
424
425 free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
426 printk("freeing pages %ld:%ld\n", start, end);
427 }
428
429
430 reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size);
431 printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
432
433#ifdef CONFIG_BLK_DEV_INITRD
434 initrd_start = INITRD_START;
435 if (initrd_start) {
436 initrd_end = initrd_start+INITRD_SIZE;
437 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
438 (void *) initrd_start, INITRD_SIZE);
439
440 if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
441 if (!move_initrd(PFN_PHYS(max_low_pfn)))
442 printk("initrd extends beyond end of memory "
443 "(0x%08lx > 0x%p)\ndisabling initrd\n",
444 initrd_end,
445 phys_to_virt(PFN_PHYS(max_low_pfn)));
446 } else {
447 reserve_bootmem(virt_to_phys((void *)initrd_start),
448 INITRD_SIZE);
449 }
450 }
451#endif
452}
453#else
454extern void setup_memory(void *);
455#endif
456
457int __init
458page_is_ram(unsigned long pfn)
459{
460 struct memclust_struct * cluster;
461 struct memdesc_struct * memdesc;
462 unsigned long i;
463
464 memdesc = (struct memdesc_struct *)
465 (hwrpb->mddt_offset + (unsigned long) hwrpb);
466 for_each_mem_cluster(memdesc, cluster, i)
467 {
468 if (pfn >= cluster->start_pfn &&
469 pfn < cluster->start_pfn + cluster->numpages) {
470 return (cluster->usage & 3) ? 0 : 1;
471 }
472 }
473
474 return 0;
475}
476
477#undef PFN_UP
478#undef PFN_DOWN
479#undef PFN_PHYS
480#undef PFN_MAX
481
482void __init
483setup_arch(char **cmdline_p)
484{
485 extern char _end[];
486
487 struct alpha_machine_vector *vec = NULL;
488 struct percpu_struct *cpu;
489 char *type_name, *var_name, *p;
490 void *kernel_end = _end;
491 char *args = command_line;
492
493 hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
494 boot_cpuid = hard_smp_processor_id();
495
496
497
498
499
500
501
502
503
504
505
506 if ((long)hwrpb->sys_type < 0) {
507 hwrpb->sys_type = -((long)hwrpb->sys_type);
508 hwrpb_update_checksum(hwrpb);
509 }
510
511
512 notifier_chain_register(&panic_notifier_list, &alpha_panic_block);
513
514#ifdef CONFIG_ALPHA_GENERIC
515
516
517 alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
518#endif
519
520
521
522
523
524 kernel_end = callback_init(kernel_end);
525
526
527
528
529
530
531
532 if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
533 strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
534 } else {
535 strlcpy(command_line, COMMAND_LINE, sizeof command_line);
536 }
537 strcpy(saved_command_line, command_line);
538 *cmdline_p = command_line;
539
540
541
542
543 while ((p = strsep(&args, " \t")) != NULL) {
544 if (!*p) continue;
545 if (strncmp(p, "alpha_mv=", 9) == 0) {
546 vec = get_sysvec_byname(p+9);
547 continue;
548 }
549 if (strncmp(p, "cycle=", 6) == 0) {
550 est_cycle_freq = simple_strtol(p+6, NULL, 0);
551 continue;
552 }
553 if (strncmp(p, "mem=", 4) == 0) {
554 mem_size_limit = get_mem_size_limit(p+4);
555 continue;
556 }
557 if (strncmp(p, "srmcons", 7) == 0) {
558 srmcons_output |= 1;
559 continue;
560 }
561 if (strncmp(p, "console=srm", 11) == 0) {
562 srmcons_output |= 2;
563 continue;
564 }
565 if (strncmp(p, "gartsize=", 9) == 0) {
566 alpha_agpgart_size =
567 get_mem_size_limit(p+9) << PAGE_SHIFT;
568 continue;
569 }
570#ifdef CONFIG_VERBOSE_MCHECK
571 if (strncmp(p, "verbose_mcheck=", 15) == 0) {
572 alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
573 continue;
574 }
575#endif
576 }
577
578
579 strcpy(command_line, saved_command_line);
580
581
582 if (alpha_using_srm && srmcons_output) {
583 register_srm_console();
584
585
586
587
588
589 if (srmcons_output & 2)
590 srmcons_output = 0;
591 }
592
593#ifdef CONFIG_MAGIC_SYSRQ
594
595
596 if (alpha_using_srm) {
597 struct sysrq_key_op *op = __sysrq_get_key_op('b');
598 op->handler = (void *) machine_halt;
599 }
600#endif
601
602
603
604
605 cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
606
607 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
608 cpu->type, &type_name, &var_name);
609 if (*var_name == '0')
610 var_name = "";
611
612 if (!vec) {
613 vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
614 cpu->type);
615 }
616
617 if (!vec) {
618 panic("Unsupported system type: %s%s%s (%ld %ld)\n",
619 type_name, (*var_name ? " variation " : ""), var_name,
620 hwrpb->sys_type, hwrpb->sys_variation);
621 }
622 if (vec != &alpha_mv) {
623 alpha_mv = *vec;
624 }
625
626 printk("Booting "
627#ifdef CONFIG_ALPHA_GENERIC
628 "GENERIC "
629#endif
630 "on %s%s%s using machine vector %s from %s\n",
631 type_name, (*var_name ? " variation " : ""),
632 var_name, alpha_mv.vector_name,
633 (alpha_using_srm ? "SRM" : "MILO"));
634
635 printk("Major Options: "
636#ifdef CONFIG_SMP
637 "SMP "
638#endif
639#ifdef CONFIG_ALPHA_EV56
640 "EV56 "
641#endif
642#ifdef CONFIG_ALPHA_EV67
643 "EV67 "
644#endif
645#ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
646 "LEGACY_START "
647#endif
648#ifdef CONFIG_VERBOSE_MCHECK
649 "VERBOSE_MCHECK "
650#endif
651
652#ifdef CONFIG_DISCONTIGMEM
653 "DISCONTIGMEM "
654#ifdef CONFIG_NUMA
655 "NUMA "
656#endif
657#endif
658
659#ifdef CONFIG_DEBUG_SPINLOCK
660 "DEBUG_SPINLOCK "
661#endif
662#ifdef CONFIG_MAGIC_SYSRQ
663 "MAGIC_SYSRQ "
664#endif
665 "\n");
666
667 printk("Command line: %s\n", command_line);
668
669
670
671
672
673 srm_hae = *alpha_mv.hae_register;
674 __set_hae(alpha_mv.hae_cache);
675
676
677 wrmces(0x7);
678
679
680 setup_memory(kernel_end);
681
682
683 determine_cpu_caches(cpu->type);
684
685
686
687 if (alpha_mv.init_arch)
688 alpha_mv.init_arch();
689
690
691 reserve_std_resources();
692
693
694
695
696
697
698#ifdef CONFIG_VT
699#if defined(CONFIG_VGA_CONSOLE)
700 conswitchp = &vga_con;
701#elif defined(CONFIG_DUMMY_CONSOLE)
702 conswitchp = &dummy_con;
703#endif
704#endif
705
706
707 ROOT_DEV = Root_SDA2;
708
709#ifdef CONFIG_EISA
710
711 EISA_bus = 1;
712#endif
713
714
715
716
717
718
719
720 if (hwrpb->max_asn != MAX_ASN) {
721 printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
722 }
723
724
725
726
727
728#ifdef CONFIG_SMP
729 setup_smp();
730#endif
731 paging_init();
732}
733
734void __init
735disable_early_printk(void)
736{
737 if (alpha_using_srm && srmcons_output) {
738 unregister_srm_console();
739 srmcons_output = 0;
740 }
741}
742
743static char sys_unknown[] = "Unknown";
744static char systype_names[][16] = {
745 "0",
746 "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
747 "Pelican", "Morgan", "Sable", "Medulla", "Noname",
748 "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
749 "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
750 "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
751 "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
752 "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
753};
754
755static char unofficial_names[][8] = {"100", "Ruffian"};
756
757static char api_names[][16] = {"200", "Nautilus"};
758
759static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
760static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
761
762static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
763static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
764
765static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
766static int eb64p_indices[] = {0,0,1,2};
767
768static char eb66_names[][8] = {"EB66", "EB66+"};
769static int eb66_indices[] = {0,0,1};
770
771static char marvel_names[][16] = {
772 "Marvel/EV7"
773};
774static int marvel_indices[] = { 0 };
775
776static char rawhide_names[][16] = {
777 "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
778};
779static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
780
781static char titan_names[][16] = {
782 "DEFAULT", "Privateer", "Falcon", "Granite"
783};
784static int titan_indices[] = {0,1,2,2,3};
785
786static char tsunami_names[][16] = {
787 "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
788 "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
789 "Flying Clipper", "Shark"
790};
791static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
792
793static struct alpha_machine_vector * __init
794get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
795{
796 static struct alpha_machine_vector *systype_vecs[] __initdata =
797 {
798 NULL,
799 NULL,
800 NULL,
801 NULL,
802 NULL,
803 NULL,
804 &jensen_mv,
805 NULL,
806 NULL,
807 NULL,
808 NULL,
809 &noname_mv,
810 NULL,
811 &avanti_mv,
812 NULL,
813 NULL,
814 NULL,
815 NULL,
816 NULL,
817 NULL,
818 NULL,
819 &alphabook1_mv,
820 &rawhide_mv,
821 NULL,
822 &lynx_mv,
823 &xl_mv,
824 NULL,
825 NULL,
826 NULL,
827 NULL,
828 &miata_mv,
829 NULL,
830 &takara_mv,
831 NULL,
832 NULL,
833 &wildfire_mv,
834 NULL,
835 &eiger_mv,
836 NULL,
837 NULL,
838 };
839
840 static struct alpha_machine_vector *unofficial_vecs[] __initdata =
841 {
842 NULL,
843 &ruffian_mv,
844 };
845
846 static struct alpha_machine_vector *api_vecs[] __initdata =
847 {
848 NULL,
849 &nautilus_mv,
850 };
851
852 static struct alpha_machine_vector *alcor_vecs[] __initdata =
853 {
854 &alcor_mv, &xlt_mv, &xlt_mv
855 };
856
857 static struct alpha_machine_vector *eb164_vecs[] __initdata =
858 {
859 &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
860 };
861
862 static struct alpha_machine_vector *eb64p_vecs[] __initdata =
863 {
864 &eb64p_mv,
865 &cabriolet_mv,
866 &cabriolet_mv
867 };
868
869 static struct alpha_machine_vector *eb66_vecs[] __initdata =
870 {
871 &eb66_mv,
872 &eb66p_mv
873 };
874
875 static struct alpha_machine_vector *marvel_vecs[] __initdata =
876 {
877 &marvel_ev7_mv,
878 };
879
880 static struct alpha_machine_vector *titan_vecs[] __initdata =
881 {
882 &titan_mv,
883 &privateer_mv,
884 &titan_mv,
885 &privateer_mv,
886 };
887
888 static struct alpha_machine_vector *tsunami_vecs[] __initdata =
889 {
890 NULL,
891 &dp264_mv,
892 &dp264_mv,
893 &dp264_mv,
894 &monet_mv,
895 &clipper_mv,
896 &dp264_mv,
897 &webbrick_mv,
898 &dp264_mv,
899 NULL,
900 NULL,
901 NULL,
902 &shark_mv,
903 };
904
905
906
907 struct alpha_machine_vector *vec;
908
909
910 vec = NULL;
911 if (type < N(systype_vecs)) {
912 vec = systype_vecs[type];
913 } else if ((type > ST_API_BIAS) &&
914 (type - ST_API_BIAS) < N(api_vecs)) {
915 vec = api_vecs[type - ST_API_BIAS];
916 } else if ((type > ST_UNOFFICIAL_BIAS) &&
917 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_vecs)) {
918 vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
919 }
920
921
922
923 if (!vec) {
924
925 unsigned long member = (variation >> 10) & 0x3f;
926
927 cpu &= 0xffffffff;
928
929 switch (type) {
930 case ST_DEC_ALCOR:
931 if (member < N(alcor_indices))
932 vec = alcor_vecs[alcor_indices[member]];
933 break;
934 case ST_DEC_EB164:
935 if (member < N(eb164_indices))
936 vec = eb164_vecs[eb164_indices[member]];
937
938
939 if (vec == &eb164_mv && cpu == EV56_CPU)
940 vec = &pc164_mv;
941 break;
942 case ST_DEC_EB64P:
943 if (member < N(eb64p_indices))
944 vec = eb64p_vecs[eb64p_indices[member]];
945 break;
946 case ST_DEC_EB66:
947 if (member < N(eb66_indices))
948 vec = eb66_vecs[eb66_indices[member]];
949 break;
950 case ST_DEC_MARVEL:
951 if (member < N(marvel_indices))
952 vec = marvel_vecs[marvel_indices[member]];
953 break;
954 case ST_DEC_TITAN:
955 vec = titan_vecs[0];
956 if (member < N(titan_indices))
957 vec = titan_vecs[titan_indices[member]];
958 break;
959 case ST_DEC_TSUNAMI:
960 if (member < N(tsunami_indices))
961 vec = tsunami_vecs[tsunami_indices[member]];
962 break;
963 case ST_DEC_1000:
964 if (cpu == EV5_CPU || cpu == EV56_CPU)
965 vec = &mikasa_primo_mv;
966 else
967 vec = &mikasa_mv;
968 break;
969 case ST_DEC_NORITAKE:
970 if (cpu == EV5_CPU || cpu == EV56_CPU)
971 vec = &noritake_primo_mv;
972 else
973 vec = &noritake_mv;
974 break;
975 case ST_DEC_2100_A500:
976 if (cpu == EV5_CPU || cpu == EV56_CPU)
977 vec = &sable_gamma_mv;
978 else
979 vec = &sable_mv;
980 break;
981 }
982 }
983 return vec;
984}
985
986static struct alpha_machine_vector * __init
987get_sysvec_byname(const char *name)
988{
989 static struct alpha_machine_vector *all_vecs[] __initdata =
990 {
991 &alcor_mv,
992 &alphabook1_mv,
993 &avanti_mv,
994 &cabriolet_mv,
995 &clipper_mv,
996 &dp264_mv,
997 &eb164_mv,
998 &eb64p_mv,
999 &eb66_mv,
1000 &eb66p_mv,
1001 &eiger_mv,
1002 &jensen_mv,
1003 &lx164_mv,
1004 &lynx_mv,
1005 &miata_mv,
1006 &mikasa_mv,
1007 &mikasa_primo_mv,
1008 &monet_mv,
1009 &nautilus_mv,
1010 &noname_mv,
1011 &noritake_mv,
1012 &noritake_primo_mv,
1013 &p2k_mv,
1014 &pc164_mv,
1015 &privateer_mv,
1016 &rawhide_mv,
1017 &ruffian_mv,
1018 &rx164_mv,
1019 &sable_mv,
1020 &sable_gamma_mv,
1021 &shark_mv,
1022 &sx164_mv,
1023 &takara_mv,
1024 &webbrick_mv,
1025 &wildfire_mv,
1026 &xl_mv,
1027 &xlt_mv
1028 };
1029
1030 size_t i;
1031
1032 for (i = 0; i < N(all_vecs); ++i) {
1033 struct alpha_machine_vector *mv = all_vecs[i];
1034 if (strcasecmp(mv->vector_name, name) == 0)
1035 return mv;
1036 }
1037 return NULL;
1038}
1039
1040static void
1041get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
1042 char **type_name, char **variation_name)
1043{
1044 unsigned long member;
1045
1046
1047
1048 if (type < N(systype_names)) {
1049 *type_name = systype_names[type];
1050 } else if ((type > ST_API_BIAS) &&
1051 (type - ST_API_BIAS) < N(api_names)) {
1052 *type_name = api_names[type - ST_API_BIAS];
1053 } else if ((type > ST_UNOFFICIAL_BIAS) &&
1054 (type - ST_UNOFFICIAL_BIAS) < N(unofficial_names)) {
1055 *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
1056 } else {
1057 *type_name = sys_unknown;
1058 *variation_name = sys_unknown;
1059 return;
1060 }
1061
1062
1063 *variation_name = systype_names[0];
1064 if (variation == 0) {
1065 return;
1066 }
1067
1068 member = (variation >> 10) & 0x3f;
1069
1070 cpu &= 0xffffffff;
1071
1072 switch (type) {
1073 default:
1074 break;
1075 case ST_DEC_EB164:
1076 if (member < N(eb164_indices))
1077 *variation_name = eb164_names[eb164_indices[member]];
1078
1079
1080 if (eb164_indices[member] == 0 && cpu == EV56_CPU)
1081 *variation_name = eb164_names[1];
1082 break;
1083 case ST_DEC_ALCOR:
1084 if (member < N(alcor_indices))
1085 *variation_name = alcor_names[alcor_indices[member]];
1086 break;
1087 case ST_DEC_EB64P:
1088 if (member < N(eb64p_indices))
1089 *variation_name = eb64p_names[eb64p_indices[member]];
1090 break;
1091 case ST_DEC_EB66:
1092 if (member < N(eb66_indices))
1093 *variation_name = eb66_names[eb66_indices[member]];
1094 break;
1095 case ST_DEC_MARVEL:
1096 if (member < N(marvel_indices))
1097 *variation_name = marvel_names[marvel_indices[member]];
1098 break;
1099 case ST_DEC_RAWHIDE:
1100 if (member < N(rawhide_indices))
1101 *variation_name = rawhide_names[rawhide_indices[member]];
1102 break;
1103 case ST_DEC_TITAN:
1104 *variation_name = titan_names[0];
1105 if (member < N(titan_indices))
1106 *variation_name = titan_names[titan_indices[member]];
1107 break;
1108 case ST_DEC_TSUNAMI:
1109 if (member < N(tsunami_indices))
1110 *variation_name = tsunami_names[tsunami_indices[member]];
1111 break;
1112 }
1113}
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129static char *
1130platform_string(void)
1131{
1132 struct dsr_struct *dsr;
1133 static char unk_system_string[] = "N/A";
1134
1135
1136
1137
1138
1139 if (hwrpb->revision < 5)
1140 return (unk_system_string);
1141 else {
1142
1143
1144
1145
1146 dsr = ((struct dsr_struct *)
1147 ((char *)hwrpb + hwrpb->dsr_offset));
1148 return ((char *)dsr + (dsr->sysname_off +
1149 sizeof(long)));
1150 }
1151}
1152
1153static int
1154get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
1155{
1156 struct percpu_struct *cpu;
1157 unsigned long i;
1158 int count = 0;
1159
1160 for (i = 0; i < num; i++) {
1161 cpu = (struct percpu_struct *)
1162 ((char *)cpubase + i*hwrpb->processor_size);
1163 if ((cpu->flags & 0x1cc) == 0x1cc)
1164 count++;
1165 }
1166 return count;
1167}
1168
1169static void
1170show_cache_size (struct seq_file *f, const char *which, int shape)
1171{
1172 if (shape == -1)
1173 seq_printf (f, "%s\t\t: n/a\n", which);
1174 else if (shape == 0)
1175 seq_printf (f, "%s\t\t: unknown\n", which);
1176 else
1177 seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
1178 which, shape >> 10, shape & 15,
1179 1 << ((shape >> 4) & 15));
1180}
1181
1182static int
1183show_cpuinfo(struct seq_file *f, void *slot)
1184{
1185 extern struct unaligned_stat {
1186 unsigned long count, va, pc;
1187 } unaligned[2];
1188
1189 static char cpu_names[][8] = {
1190 "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
1191 "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
1192 "EV68CX", "EV7", "EV79", "EV69"
1193 };
1194
1195 struct percpu_struct *cpu = slot;
1196 unsigned int cpu_index;
1197 char *cpu_name;
1198 char *systype_name;
1199 char *sysvariation_name;
1200 int nr_processors;
1201
1202 cpu_index = (unsigned) (cpu->type - 1);
1203 cpu_name = "Unknown";
1204 if (cpu_index < N(cpu_names))
1205 cpu_name = cpu_names[cpu_index];
1206
1207 get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
1208 cpu->type, &systype_name, &sysvariation_name);
1209
1210 nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
1211
1212 seq_printf(f, "cpu\t\t\t: Alpha\n"
1213 "cpu model\t\t: %s\n"
1214 "cpu variation\t\t: %ld\n"
1215 "cpu revision\t\t: %ld\n"
1216 "cpu serial number\t: %s\n"
1217 "system type\t\t: %s\n"
1218 "system variation\t: %s\n"
1219 "system revision\t\t: %ld\n"
1220 "system serial number\t: %s\n"
1221 "cycle frequency [Hz]\t: %lu %s\n"
1222 "timer frequency [Hz]\t: %lu.%02lu\n"
1223 "page size [bytes]\t: %ld\n"
1224 "phys. address bits\t: %ld\n"
1225 "max. addr. space #\t: %ld\n"
1226 "BogoMIPS\t\t: %lu.%02lu\n"
1227 "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1228 "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
1229 "platform string\t\t: %s\n"
1230 "cpus detected\t\t: %d\n",
1231 cpu_name, cpu->variation, cpu->revision,
1232 (char*)cpu->serial_no,
1233 systype_name, sysvariation_name, hwrpb->sys_revision,
1234 (char*)hwrpb->ssn,
1235 est_cycle_freq ? : hwrpb->cycle_freq,
1236 est_cycle_freq ? "est." : "",
1237 hwrpb->intr_freq / 4096,
1238 (100 * hwrpb->intr_freq / 4096) % 100,
1239 hwrpb->pagesize,
1240 hwrpb->pa_bits,
1241 hwrpb->max_asn,
1242 loops_per_jiffy / (500000/HZ),
1243 (loops_per_jiffy / (5000/HZ)) % 100,
1244 unaligned[0].count, unaligned[0].pc, unaligned[0].va,
1245 unaligned[1].count, unaligned[1].pc, unaligned[1].va,
1246 platform_string(), nr_processors);
1247
1248#ifdef CONFIG_SMP
1249 seq_printf(f, "cpus active\t\t: %d\n"
1250 "cpu active mask\t\t: %016lx\n",
1251 num_online_cpus(), cpus_addr(cpu_possible_map)[0]);
1252#endif
1253
1254 show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
1255 show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
1256 show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
1257 show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
1258
1259 return 0;
1260}
1261
1262static int __init
1263read_mem_block(int *addr, int stride, int size)
1264{
1265 long nloads = size / stride, cnt, tmp;
1266
1267 __asm__ __volatile__(
1268 " rpcc %0\n"
1269 "1: ldl %3,0(%2)\n"
1270 " subq %1,1,%1\n"
1271
1272
1273
1274 " xor %3,%2,%2\n"
1275 " xor %3,%2,%2\n"
1276 " addq %2,%4,%2\n"
1277 " bne %1,1b\n"
1278 " rpcc %3\n"
1279 " subl %3,%0,%0\n"
1280 : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
1281 : "r" (stride), "1" (nloads), "2" (addr));
1282
1283 return cnt / (size / stride);
1284}
1285
1286#define CSHAPE(totalsize, linesize, assoc) \
1287 ((totalsize & ~0xff) | (linesize << 4) | assoc)
1288
1289
1290
1291#define MAX_BCACHE_SIZE 16*1024*1024
1292
1293
1294static int __init
1295external_cache_probe(int minsize, int width)
1296{
1297 int cycles, prev_cycles = 1000000;
1298 int stride = 1 << width;
1299 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1300
1301 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1302 maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
1303
1304
1305 read_mem_block(__va(0), stride, size);
1306
1307 while (size < maxsize) {
1308
1309 cycles = read_mem_block(__va(0), stride, size);
1310 if (cycles > prev_cycles * 2) {
1311
1312 printk("%ldK Bcache detected; load hit latency %d "
1313 "cycles, load miss latency %d cycles\n",
1314 size >> 11, prev_cycles, cycles);
1315 return CSHAPE(size >> 1, width, 1);
1316 }
1317
1318 read_mem_block(__va(size), stride, size);
1319 prev_cycles = cycles;
1320 size <<= 1;
1321 }
1322 return -1;
1323}
1324
1325static void __init
1326determine_cpu_caches (unsigned int cpu_type)
1327{
1328 int L1I, L1D, L2, L3;
1329
1330 switch (cpu_type) {
1331 case EV4_CPU:
1332 case EV45_CPU:
1333 {
1334 if (cpu_type == EV4_CPU)
1335 L1I = CSHAPE(8*1024, 5, 1);
1336 else
1337 L1I = CSHAPE(16*1024, 5, 1);
1338 L1D = L1I;
1339 L3 = -1;
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351 L2 = external_cache_probe(128*1024, 5);
1352 break;
1353 }
1354
1355 case LCA4_CPU:
1356 {
1357 unsigned long car, size;
1358
1359 L1I = L1D = CSHAPE(8*1024, 5, 1);
1360 L3 = -1;
1361
1362 car = *(vuip) phys_to_virt (0x120000078UL);
1363 size = 64*1024 * (1 << ((car >> 5) & 7));
1364
1365 L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
1366 break;
1367 }
1368
1369 case EV5_CPU:
1370 case EV56_CPU:
1371 {
1372 unsigned long sc_ctl, width;
1373
1374 L1I = L1D = CSHAPE(8*1024, 5, 1);
1375
1376
1377 sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
1378 width = sc_ctl & 0x1000 ? 6 : 5;
1379 L2 = CSHAPE (96*1024, width, 3);
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391 L3 = external_cache_probe(1024*1024, width);
1392 break;
1393 }
1394
1395 case PCA56_CPU:
1396 case PCA57_CPU:
1397 {
1398 unsigned long cbox_config, size;
1399
1400 if (cpu_type == PCA56_CPU) {
1401 L1I = CSHAPE(16*1024, 6, 1);
1402 L1D = CSHAPE(8*1024, 5, 1);
1403 } else {
1404 L1I = CSHAPE(32*1024, 6, 2);
1405 L1D = CSHAPE(16*1024, 5, 1);
1406 }
1407 L3 = -1;
1408
1409 cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
1410 size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
1411
1412#if 0
1413 L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
1414#else
1415 L2 = external_cache_probe(512*1024, 6);
1416#endif
1417 break;
1418 }
1419
1420 case EV6_CPU:
1421 case EV67_CPU:
1422 case EV68CB_CPU:
1423 case EV68AL_CPU:
1424 case EV68CX_CPU:
1425 case EV69_CPU:
1426 L1I = L1D = CSHAPE(64*1024, 6, 2);
1427 L2 = external_cache_probe(1024*1024, 6);
1428 L3 = -1;
1429 break;
1430
1431 case EV7_CPU:
1432 case EV79_CPU:
1433 L1I = L1D = CSHAPE(64*1024, 6, 2);
1434 L2 = CSHAPE(7*1024*1024/4, 6, 7);
1435 L3 = -1;
1436 break;
1437
1438 default:
1439
1440 L1I = L1D = L2 = L3 = 0;
1441 break;
1442 }
1443
1444 alpha_l1i_cacheshape = L1I;
1445 alpha_l1d_cacheshape = L1D;
1446 alpha_l2_cacheshape = L2;
1447 alpha_l3_cacheshape = L3;
1448}
1449
1450
1451
1452
1453static void *
1454c_start(struct seq_file *f, loff_t *pos)
1455{
1456 return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
1457}
1458
1459static void *
1460c_next(struct seq_file *f, void *v, loff_t *pos)
1461{
1462 return NULL;
1463}
1464
1465static void
1466c_stop(struct seq_file *f, void *v)
1467{
1468}
1469
1470struct seq_operations cpuinfo_op = {
1471 .start = c_start,
1472 .next = c_next,
1473 .stop = c_stop,
1474 .show = show_cpuinfo,
1475};
1476
1477
1478static int
1479alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1480{
1481#if 1
1482
1483
1484 if (alpha_using_srm && srmcons_output)
1485 __halt();
1486#endif
1487 return NOTIFY_DONE;
1488}
1489