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