-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpatch-3.5.1-xbox0.11.1.diff
10957 lines (10905 loc) · 305 KB
/
patch-3.5.1-xbox0.11.1.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -NurpP --minimal linux-3.5.1/arch/powerpc/boot/Makefile linux-3.5.1-xenon/arch/powerpc/boot/Makefile
--- linux-3.5.1/arch/powerpc/boot/Makefile 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/boot/Makefile 2012-10-08 18:45:02.217990519 +0200
@@ -177,6 +177,7 @@ image-$(CONFIG_PPC_POWERNV) += zImage.p
image-$(CONFIG_PPC_MAPLE) += zImage.maple
image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries
image-$(CONFIG_PPC_PS3) += dtbImage.ps3
+image-$(CONFIG_PPC_XENON) += zImage.xenon
image-$(CONFIG_PPC_CELLEB) += zImage.pseries
image-$(CONFIG_PPC_CELL_QPACE) += zImage.pseries
image-$(CONFIG_PPC_CHRP) += zImage.chrp
@@ -310,6 +311,11 @@ $(obj)/dtbImage.%: vmlinux $(wrapperbits
$(obj)/vmlinux.strip: vmlinux
$(STRIP) -s -R .comment $< -o $@
+$(obj)/zImage.xenon: $(obj)/vmlinux.strip
+ $(OBJCOPY) -O elf32-powerpc $< $@
+ @ test -e /mnt/nfsroot/tftpboot && \
+ cp -f $@ /mnt/nfsroot/tftpboot/zImage_2.6.33.xenon || true
+
$(obj)/uImage: vmlinux $(wrapperbits)
$(call if_changed,wrap,uboot)
diff -NurpP --minimal linux-3.5.1/arch/powerpc/include/asm/cputable.h linux-3.5.1-xenon/arch/powerpc/include/asm/cputable.h
--- linux-3.5.1/arch/powerpc/include/asm/cputable.h 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/include/asm/cputable.h 2012-10-08 18:45:02.217990519 +0200
@@ -438,6 +438,10 @@ extern const char *powerpc_base_platform
CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
CPU_FTR_PAUSE_ZERO | CPU_FTR_CELL_TB_BUG | CPU_FTR_CP_USE_DCBTZ | \
CPU_FTR_UNALIGNED_LD_STD)
+#define CPU_FTRS_XENON (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
+ CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
+ CPU_FTR_MMCRA | CPU_FTR_SMT | \
+ CPU_FTR_CELL_TB_BUG )
#define CPU_FTRS_PA6T (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP | \
CPU_FTR_PURR | CPU_FTR_REAL_LE)
@@ -493,6 +497,9 @@ enum {
#ifdef CONFIG_PPC_E500MC
CPU_FTRS_E500MC | CPU_FTRS_E5500 | CPU_FTRS_E6500 |
#endif
+#ifdef CONFIG_PPC_XENON
+ CPU_FTRS_XENON |
+#endif
0,
};
#endif /* __powerpc64__ */
diff -NurpP --minimal linux-3.5.1/arch/powerpc/include/asm/mmu.h linux-3.5.1-xenon/arch/powerpc/include/asm/mmu.h
--- linux-3.5.1/arch/powerpc/include/asm/mmu.h 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/include/asm/mmu.h 2012-10-08 18:45:02.221990593 +0200
@@ -103,6 +103,8 @@
#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
#define MMU_FTRS_CELL MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
MMU_FTR_CI_LARGE_PAGE
+#define MMU_FTRS_XENON MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
+ MMU_FTR_CI_LARGE_PAGE
#define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
MMU_FTR_CI_LARGE_PAGE | MMU_FTR_NO_SLBIE_B
#define MMU_FTRS_A2 MMU_FTR_TYPE_3E | MMU_FTR_USE_TLBILX | \
diff -NurpP --minimal linux-3.5.1/arch/powerpc/Kconfig linux-3.5.1-xenon/arch/powerpc/Kconfig
--- linux-3.5.1/arch/powerpc/Kconfig 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/Kconfig 2012-10-08 18:45:02.221990593 +0200
@@ -120,7 +120,7 @@ config PPC
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
select HAVE_GENERIC_HARDIRQS
- select SPARSE_IRQ
+ select HAVE_SPARSE_IRQ
select IRQ_PER_CPU
select IRQ_DOMAIN
select GENERIC_IRQ_SHOW
@@ -1012,3 +1012,4 @@ config PPC_LIB_RHEAP
bool
source "arch/powerpc/kvm/Kconfig"
+
diff -NurpP --minimal linux-3.5.1/arch/powerpc/kernel/cputable.c linux-3.5.1-xenon/arch/powerpc/kernel/cputable.c
--- linux-3.5.1/arch/powerpc/kernel/cputable.c 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/kernel/cputable.c 2012-10-08 18:45:02.221990593 +0200
@@ -480,6 +480,18 @@ static struct cpu_spec __initdata cpu_sp
.oprofile_type = PPC_OPROFILE_CELL,
.platform = "ppc-cell-be",
},
+ { /* Xenon */
+ .pvr_mask = 0xffff0000,
+ .pvr_value = 0x00710000,
+ .cpu_name = "Xenon",
+ .cpu_features = CPU_FTRS_XENON,
+ .cpu_user_features = COMMON_USER_PPC64 |
+ PPC_FEATURE_SMT,
+ .mmu_features = MMU_FTRS_XENON,
+ .icache_bsize = 128,
+ .dcache_bsize = 128,
+ .platform = "xenon",
+ },
{ /* PA Semi PA6T */
.pvr_mask = 0x7fff0000,
.pvr_value = 0x00900000,
diff -NurpP --minimal linux-3.5.1/arch/powerpc/kernel/crash.c linux-3.5.1-xenon/arch/powerpc/kernel/crash.c
--- linux-3.5.1/arch/powerpc/kernel/crash.c 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/kernel/crash.c 2012-10-08 18:45:02.221990593 +0200
@@ -253,7 +253,7 @@ static inline void crash_kexec_wait_real
*/
int crash_shutdown_register(crash_shutdown_t handler)
{
- unsigned int i, rc;
+ unsigned int i, rc = 0;
spin_lock(&crash_handlers_lock);
for (i = 0 ; i < CRASH_HANDLER_MAX; i++)
diff -NurpP --minimal linux-3.5.1/arch/powerpc/kernel/head_64.S linux-3.5.1-xenon/arch/powerpc/kernel/head_64.S
--- linux-3.5.1/arch/powerpc/kernel/head_64.S 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/kernel/head_64.S 2012-10-08 18:45:02.225990662 +0200
@@ -578,8 +578,11 @@ _GLOBAL(pmac_secondary_start)
.section ".text";
.align 2 ;
+/*
.globl __secondary_start
__secondary_start:
+*/
+_INIT_GLOBAL(__secondary_start)
/* Set thread priority to MEDIUM */
HMT_MEDIUM
@@ -624,7 +627,7 @@ __secondary_start:
* zero the stack back-chain pointer and get the TOC virtual address
* before going into C code.
*/
-_GLOBAL(start_secondary_prolog)
+_INIT_GLOBAL(start_secondary_prolog)
ld r2,PACATOC(r13)
li r3,0
std r3,0(r1) /* Zero the stack frame pointer */
diff -NurpP --minimal linux-3.5.1/arch/powerpc/kernel/misc_64.S linux-3.5.1-xenon/arch/powerpc/kernel/misc_64.S
--- linux-3.5.1/arch/powerpc/kernel/misc_64.S 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/kernel/misc_64.S 2012-10-08 18:45:02.225990662 +0200
@@ -235,7 +235,7 @@ _GLOBAL(__flush_dcache_icache)
blr
-#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
+#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) || defined(CONFIG_PPC_XENON)
/*
* Do an IO access in real mode
*/
diff -NurpP --minimal linux-3.5.1/arch/powerpc/kernel/process.c linux-3.5.1-xenon/arch/powerpc/kernel/process.c
--- linux-3.5.1/arch/powerpc/kernel/process.c 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/kernel/process.c 2012-10-08 18:45:02.237990836 +0200
@@ -1309,3 +1309,8 @@ unsigned long randomize_et_dyn(unsigned
return ret;
}
+
+void arch_trigger_all_cpu_backtrace(void)
+{
+ panic("arch_trigger_all_cpu_backtrace() not implemented yet\n");
+}
diff -NurpP --minimal linux-3.5.1/arch/powerpc/kernel/setup_64.c linux-3.5.1-xenon/arch/powerpc/kernel/setup_64.c
--- linux-3.5.1/arch/powerpc/kernel/setup_64.c 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/kernel/setup_64.c 2012-10-08 18:45:02.249990992 +0200
@@ -230,7 +230,7 @@ void __init early_setup(unsigned long dt
}
#ifdef CONFIG_SMP
-void early_setup_secondary(void)
+void __cpuinit early_setup_secondary(void)
{
/* Mark interrupts enabled in PACA */
get_paca()->soft_enabled = 0;
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/Kconfig linux-3.5.1-xenon/arch/powerpc/platforms/Kconfig
--- linux-3.5.1/arch/powerpc/platforms/Kconfig 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/platforms/Kconfig 2012-10-08 18:45:02.265991223 +0200
@@ -21,6 +21,7 @@ source "arch/powerpc/platforms/44x/Kconf
source "arch/powerpc/platforms/40x/Kconfig"
source "arch/powerpc/platforms/amigaone/Kconfig"
source "arch/powerpc/platforms/wsp/Kconfig"
+source "arch/powerpc/platforms/xenon/Kconfig"
config KVM_GUEST
bool "KVM Guest support"
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/Makefile linux-3.5.1-xenon/arch/powerpc/platforms/Makefile
--- linux-3.5.1/arch/powerpc/platforms/Makefile 2012-08-09 17:23:56.000000000 +0200
+++ linux-3.5.1-xenon/arch/powerpc/platforms/Makefile 2012-10-08 18:45:02.285991500 +0200
@@ -20,6 +20,7 @@ obj-$(CONFIG_PPC_MAPLE) += maple/
obj-$(CONFIG_PPC_PASEMI) += pasemi/
obj-$(CONFIG_PPC_CELL) += cell/
obj-$(CONFIG_PPC_PS3) += ps3/
+obj-$(CONFIG_PPC_XENON) += xenon/
obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/
obj-$(CONFIG_AMIGAONE) += amigaone/
obj-$(CONFIG_PPC_WSP) += wsp/
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/hardware.c linux-3.5.1-xenon/arch/powerpc/platforms/xenon/hardware.c
--- linux-3.5.1/arch/powerpc/platforms/xenon/hardware.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/hardware.c 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,36 @@
+/*
+ * Xenon hardware related routines.
+ *
+ * Copyright (C) 2010 Herbert Poetzl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+
+static int __init xenon_hwmon_init(void)
+{
+ struct platform_device *pdev;
+
+ pdev = platform_device_register_simple("xenon-hwmon", -1, NULL, 0);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
+ return 0;
+}
+
+module_init(xenon_hwmon_init);
+
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/interrupt.c linux-3.5.1-xenon/arch/powerpc/platforms/xenon/interrupt.c
--- linux-3.5.1/arch/powerpc/platforms/xenon/interrupt.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/interrupt.c 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,333 @@
+/*
+ * Xenon interrupt controller,
+ *
+ * Maintained by: Felix Domke <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License v2
+ * as published by the Free Software Foundation.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/percpu.h>
+#include <linux/types.h>
+#include <linux/ioport.h>
+#include <linux/irqdesc.h>
+
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/prom.h>
+#include <asm/ptrace.h>
+#include <asm/machdep.h>
+
+#include "interrupt.h"
+
+static void *iic_base,
+ *bridge_base, // ea000000
+ *biu, // e1000000
+ *graphics; // ec800000
+static struct irq_domain *host;
+
+#define XENON_NR_IRQS 128
+
+#define PRIO_IPI_4 0x08
+#define PRIO_IPI_3 0x10
+#define PRIO_SMM 0x14
+#define PRIO_SFCX 0x18
+#define PRIO_SATA_HDD 0x20
+#define PRIO_SATA_CDROM 0x24
+#define PRIO_OHCI_0 0x2c
+#define PRIO_EHCI_0 0x30
+#define PRIO_OHCI_1 0x34
+#define PRIO_EHCI_1 0x38
+#define PRIO_XMA 0x40
+#define PRIO_AUDIO 0x44
+#define PRIO_ENET 0x4C
+#define PRIO_XPS 0x54
+#define PRIO_GRAPHICS 0x58
+#define PRIO_PROFILER 0x60
+#define PRIO_BIU 0x64
+#define PRIO_IOC 0x68
+#define PRIO_FSB 0x6c
+#define PRIO_IPI_2 0x70
+#define PRIO_CLOCK 0x74
+#define PRIO_IPI_1 0x78
+
+/* bridge (PCI) IRQ -> CPU IRQ */
+static int xenon_pci_irq_map[] = {
+ PRIO_CLOCK, PRIO_SATA_CDROM, PRIO_SATA_HDD, PRIO_SMM,
+ PRIO_OHCI_0, PRIO_EHCI_0, PRIO_OHCI_1, PRIO_EHCI_1,
+ -1, -1, PRIO_ENET, PRIO_XMA,
+ PRIO_AUDIO, PRIO_SFCX, -1, -1};
+
+static void disconnect_pci_irq(int prio)
+{
+ int i;
+
+ printk(KERN_DEBUG "xenon IIC: disconnect irq %i\n", prio);
+
+ for (i=0; i<0x10; ++i)
+ if (xenon_pci_irq_map[i] == prio)
+ writel(0, bridge_base + 0x10 + i * 4);
+}
+
+ /* connects an PCI IRQ to CPU #0 */
+static void connect_pci_irq(int prio)
+{
+ int i;
+
+ printk(KERN_WARNING "xenon IIC: connect irq %i\n", prio);
+
+ for (i=0; i<0x10; ++i)
+ if (xenon_pci_irq_map[i] == prio)
+ writel(0x0800180 | (xenon_pci_irq_map[i]/4), bridge_base + 0x10 + i * 4);
+}
+
+static void iic_mask(struct irq_data *d)
+{
+ disconnect_pci_irq(d->irq);
+}
+
+static void iic_unmask(struct irq_data *d)
+{
+ int i;
+ connect_pci_irq(d->irq);
+ for (i=0; i<6; ++i)
+ out_be64(iic_base + i * 0x1000 + 0x68, 0);
+}
+
+void xenon_init_irq_on_cpu(int cpu)
+{
+ printk(KERN_WARNING "xenon IIC: init on cpu %i\n", cpu);
+ /* init that cpu's interrupt controller */
+ out_be64(iic_base + cpu * 0x1000 + 0x70, 0x7c);
+ out_be64(iic_base + cpu * 0x1000 + 0x8, 0); /* irql */
+ out_be64(iic_base + cpu * 0x1000, 1<<cpu); /* "who am i" */
+
+ /* ack all outstanding interrupts */
+ while (in_be64(iic_base + cpu * 0x1000 + 0x50) != 0x7C);
+ out_be64(iic_base + cpu * 0x1000 + 0x68, 0);
+}
+
+static void iic_eoi(struct irq_data *d)
+{
+ int cpu = hard_smp_processor_id();
+ void *my_iic_base = iic_base + cpu * 0x1000;
+ out_be64(my_iic_base + 0x68, 0);
+ mb();
+ in_be64(my_iic_base + 0x8);
+}
+
+static struct irq_chip xenon_pic = {
+ .name = " XENON-PIC ",
+ .irq_mask = iic_mask,
+ .irq_unmask = iic_unmask,
+ .irq_eoi = iic_eoi,
+};
+
+//struct irq_desc irq_desc[XENON_NR_IRQS];
+
+/* Get an IRQ number from the pending state register of the IIC */
+static unsigned int iic_get_irq(void)
+{
+ int cpu = hard_smp_processor_id();
+ void *my_iic_base;
+ int index;
+
+ my_iic_base = iic_base + cpu * 0x1000;
+
+ index = in_be64(my_iic_base + 0x50) & 0x7F; /* read destructive pending interrupt */
+
+ out_be64(my_iic_base + 0x08, 0x7c); /* current task priority */
+ mb();
+ in_be64(my_iic_base + 0x8);
+
+ /* HACK: we will handle some (otherwise unhandled) interrupts here
+ to prevent them flooding. */
+ switch (index) {
+ case PRIO_GRAPHICS:
+ writel(0, graphics + 0xed0);
+ writel(0, graphics + 0x6540);
+ break;
+ case PRIO_IOC:
+ writel(0, biu + 0x4002c);
+ break;
+ case PRIO_CLOCK:
+ writel(0, bridge_base + 0x106C);
+ break;
+ default:
+ break;
+ }
+
+#if 0
+ /* should be handled */
+ if (index == PRIO_IPI_1)
+ return index;
+ if (index == PRIO_IPI_2)
+ return index;
+ if (index == PRIO_IPI_3)
+ return index;
+ if (index == PRIO_IPI_4)
+ return index;
+#endif
+
+ /* HACK: we need to ACK unhandled interrupts here */
+ if (!irq_desc[index].action) {
+ printk(KERN_WARNING "IRQ 0x%02x unhandled, doing local EOI\n", index);
+ out_be64(my_iic_base + 0x60, 0);
+ iic_eoi(NULL);
+ return NO_IRQ;
+ }
+
+ if (index == 0x7C)
+ return NO_IRQ;
+ else
+ return index;
+}
+
+static int xenon_irq_host_map(struct irq_domain *h, unsigned int virq,
+ irq_hw_number_t hw)
+{
+ irq_set_chip_and_handler(virq, &xenon_pic, handle_percpu_irq);
+ return 0;
+}
+
+static int xenon_irq_host_match(struct irq_domain *h, struct device_node *node)
+{
+ return h->host_data != NULL && node == h->host_data;
+}
+
+static const struct irq_domain_ops xenon_irq_host_ops = {
+ .map = xenon_irq_host_map,
+ .match = xenon_irq_host_match,
+};
+
+void __init xenon_iic_init_IRQ(void)
+{
+ int i;
+ struct device_node *dn;
+ struct resource res;
+
+ printk(KERN_DEBUG "xenon IIC: init\n");
+
+ /* search for our interrupt controller inside the device tree */
+ for (dn = NULL;
+ (dn = of_find_node_by_name(dn, "interrupt-controller")) != NULL;) {
+ if (!of_device_is_compatible(dn, "xenon"))
+ continue;
+
+ if (of_address_to_resource(dn, 0, &res))
+ {
+ printk(KERN_WARNING "xenon IIC: Can't resolve addresses\n");
+ of_node_put(dn);
+ return;
+ }
+
+ iic_base = ioremap_nocache(res.start, 0x10000);
+
+ //host = irq_alloc_host(NULL, IRQ_HOST_MAP_NOMAP, 0, &xenon_irq_host_ops, 0);
+ host = irq_domain_add_nomap(NULL, 0x80, &xenon_irq_host_ops, NULL);
+ host->host_data = of_node_get(dn);
+ BUG_ON(host == NULL);
+ irq_set_default_host(host);
+ }
+
+ ppc_md.get_irq = iic_get_irq;
+
+ bridge_base = ioremap_nocache(0xea000000, 0x10000);
+ biu = ioremap_nocache(0xe1000000, 0x2000000);
+ graphics = ioremap_nocache(0xec800000, 0x10000);
+
+ /* initialize interrupts */
+ writel(0, bridge_base);
+ writel(0x40000000, bridge_base + 4);
+
+ writel(0x40000000, biu + 0x40074);
+ writel(0xea000050, biu + 0x40078);
+
+ writel(0, bridge_base + 0xc);
+ writel(0x3, bridge_base);
+
+ /* disconnect all PCI IRQs until they are requested */
+ for (i=0; i<0x10; ++i)
+ writel(0, bridge_base + 0x10 + i * 4);
+
+ xenon_init_irq_on_cpu(0);
+}
+
+#ifdef CONFIG_SMP
+
+static int ipi_to_prio(int ipi)
+{
+ switch (ipi) {
+ case PPC_MSG_CALL_FUNCTION:
+ return PRIO_IPI_1;
+ break;
+ case PPC_MSG_CALL_FUNC_SINGLE:
+ return PRIO_IPI_2;
+ break;
+ case PPC_MSG_RESCHEDULE:
+ return PRIO_IPI_3;
+ break;
+ case PPC_MSG_DEBUGGER_BREAK:
+ return PRIO_IPI_4;
+ break;
+ default:
+ printk("unhandled ipi %d\n", ipi);
+ BUG();
+ }
+ return 0;
+}
+
+void xenon_cause_IPI(int target, int msg)
+{
+ int ipi_prio;
+
+ ipi_prio = ipi_to_prio(msg);
+
+ out_be64(iic_base + 0x10 + hard_smp_processor_id() * 0x1000, (0x10000<<target) | ipi_prio);
+}
+
+/*
+static irqreturn_t xenon_ipi_action(int irq, void *dev_id)
+{
+ int ipi = (int)(long)dev_id;
+ smp_request_message_ipi(irq, ipi);
+ return IRQ_HANDLED;
+}
+*/
+
+static void xenon_request_ipi(int ipi, const char *name)
+{
+ int prio = ipi_to_prio(ipi), virq;
+
+ virq = irq_create_mapping(host, prio);
+ if (virq == NO_IRQ)
+ {
+ printk(KERN_ERR
+ "xenon_request_ipi: failed to map IPI%d (%s)\n", prio, name);
+ return;
+ }
+
+ smp_request_message_ipi(virq, ipi);
+ /*
+ if (request_irq(prio, xenon_ipi_action, IRQF_DISABLED,
+ name, (void *)(long)ipi))
+ printk(KERN_ERR "request irq for ipi failed!\n");
+ */
+}
+
+void xenon_request_IPIs(void)
+{
+ xenon_request_ipi(PPC_MSG_CALL_FUNCTION, "IPI-call");
+ xenon_request_ipi(PPC_MSG_RESCHEDULE, "IPI-resched");
+ xenon_request_ipi(PPC_MSG_CALL_FUNC_SINGLE, "IPI-call-single");
+#ifdef CONFIG_DEBUGGER
+ xenon_request_ipi(PPC_MSG_DEBUGGER_BREAK, "IPI-debug");
+#endif /* CONFIG_DEBUGGER */
+}
+
+#endif
+
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/interrupt.h linux-3.5.1-xenon/arch/powerpc/platforms/xenon/interrupt.h
--- linux-3.5.1/arch/powerpc/platforms/xenon/interrupt.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/interrupt.h 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,10 @@
+#ifndef XENON_INTERRUPT_H
+#define XENON_INTERRUPT_H
+
+extern void xenon_init_irq_on_cpu(int cpu);
+extern void __init xenon_iic_init_IRQ(void);
+extern void xenon_cause_IPI(int target, int msg);
+extern void xenon_request_IPIs(void);
+
+#endif /* ASM_XENON_PIC_H */
+
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/Kconfig linux-3.5.1-xenon/arch/powerpc/platforms/xenon/Kconfig
--- linux-3.5.1/arch/powerpc/platforms/xenon/Kconfig 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/Kconfig 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,8 @@
+config PPC_XENON
+ bool "Xenon"
+ depends on PPC64
+ select PPC_NATIVE
+ default y
+ help
+ This option enables support for the Xbox 360 game console
+ without a hypervisor.
\ Kein Zeilenumbruch am Dateiende.
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/Makefile linux-3.5.1-xenon/arch/powerpc/platforms/xenon/Makefile
--- linux-3.5.1/arch/powerpc/platforms/xenon/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/Makefile 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,3 @@
+obj-y += setup.o interrupt.o pci.o time.o hardware.o
+
+obj-$(CONFIG_SMP) += smp.o
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/pci.c linux-3.5.1-xenon/arch/powerpc/platforms/xenon/pci.c
--- linux-3.5.1/arch/powerpc/platforms/xenon/pci.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/pci.c 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,313 @@
+/*
+ * Xenon PCI support
+ * Maintained by: Felix Domke <[email protected]>
+ * Minor modification by: wolie <[email protected]>
+ * based on:
+ * Copyright (C) 2004 Benjamin Herrenschmuidt ([email protected]),
+ * IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/bootmem.h>
+
+#include <asm/sections.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/pci-bridge.h>
+#include <asm/machdep.h>
+#include <asm/iommu.h>
+#include <asm/ppc-pci.h>
+
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+#define OFFSET(bus, slot, func) \
+ ((((bus) << 8) + PCI_DEVFN(slot, func)) << 12)
+
+static int xenon_pci_read_config(struct pci_bus *bus, unsigned int devfn,
+ int offset, int len, u32 *val)
+{
+ struct pci_controller *hose;
+ unsigned int slot = PCI_SLOT(devfn);
+ unsigned int func = PCI_FUNC(devfn);
+ void* addr;
+
+ hose = pci_bus_to_host(bus);
+ if (hose == NULL)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+
+ DBG("xenon_pci_read_config, slot %d, func %d\n", slot, func);
+
+#if 0
+ if (PCI_SLOT(devfn) >= 32)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ if (PCI_SLOT(devfn) == 3)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ if (PCI_SLOT(devfn) == 6)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ if (PCI_SLOT(devfn) == 0xB)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ if (PCI_FUNC(devfn) >= 2)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+#endif
+ DBG("xenon_pci_read_config, %p, devfn=%d, offset=%d, len=%d\n", bus, devfn, offset, len);
+
+ addr = ((void*)hose->cfg_addr) + offset;
+
+ /* map GPU to slot 0x0f */
+ if (slot == 0x0f)
+ addr += OFFSET(0, 0x02, func);
+ else
+ addr += OFFSET(1, slot, func);
+
+ /*
+ * Note: the caller has already checked that offset is
+ * suitably aligned and that len is 1, 2 or 4.
+ */
+ switch (len) {
+ case 1:
+ *val = in_8((u8 *)addr);
+ break;
+ case 2:
+ *val = in_le16((u16 *)addr);
+ break;
+ default:
+ *val = in_le32((u32 *)addr);
+ break;
+ }
+ DBG("->%08x\n", (int)*val);
+ return PCIBIOS_SUCCESSFUL;
+}
+
+static int xenon_pci_write_config(struct pci_bus *bus, unsigned int devfn,
+ int offset, int len, u32 val)
+{
+ struct pci_controller *hose;
+ unsigned int slot = PCI_SLOT(devfn);
+ unsigned int func = PCI_FUNC(devfn);
+ void *addr;
+
+ hose = pci_bus_to_host(bus);
+ if (hose == NULL)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+
+ DBG("xenon_pci_write_config, slot %d, func %d\n", slot, func);
+
+ if (PCI_SLOT(devfn) >= 32)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+#if 0
+ if (PCI_SLOT(devfn) == 3)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+#endif
+ DBG("xenon_pci_write_config, %p, devfn=%d, offset=%x, len=%d, val=%08x\n", bus, devfn, offset, len, val);
+
+ addr = ((void*)hose->cfg_addr) + offset;
+
+ /* map GPU to slot 0x0f */
+ if (slot == 0x0f)
+ addr += OFFSET(0, 0x02, func);
+ else
+ addr += OFFSET(1, slot, func);
+
+ if (len == 4)
+ DBG("was: %08x\n", readl(addr));
+ if (len == 2)
+ DBG("was: %04x\n", readw(addr));
+ if (len == 1)
+ DBG("was: %02x\n", readb(addr));
+ /*
+ * Note: the caller has already checked that offset is
+ * suitably aligned and that len is 1, 2 or 4.
+ */
+ switch (len) {
+ case 1:
+ writeb(val, addr);
+ break;
+ case 2:
+ writew(val, addr);
+ break;
+ default:
+ writel(val, addr);
+ break;
+ }
+ return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops xenon_pci_ops =
+{
+ .read = xenon_pci_read_config,
+ .write = xenon_pci_write_config,
+};
+
+
+#if 1
+void __init xenon_pci_init(void)
+{
+ struct pci_controller *hose;
+ struct device_node *np, *root;
+ struct device_node *dev = NULL;
+
+ root = of_find_node_by_path("/");
+ if (root == NULL) {
+ printk(KERN_CRIT "xenon_pci_init: can't find root of device tree\n");
+ return;
+ }
+ for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {
+ if (np->name == NULL)
+ continue;
+ // printk("found node %p %s\n", np, np->name);
+ if (strcmp(np->name, "pci") == 0) {
+ of_node_get(np);
+ dev = np;
+ }
+ }
+ of_node_put(root);
+
+ if (!dev)
+ {
+ printk("couldn't find PCI node!\n");
+ return;
+ }
+
+ hose = pcibios_alloc_controller(dev);
+ if (hose == NULL)
+ {
+ printk("pcibios_alloc_controller failed!\n");
+ return;
+ }
+
+ hose->first_busno = 0;
+ hose->last_busno = 1;
+
+ hose->ops = &xenon_pci_ops;
+ hose->cfg_addr = ioremap(0xd0000000, 0x1000000);
+
+ pci_process_bridge_OF_ranges(hose, dev, 1);
+
+ /* Setup the linkage between OF nodes and PHBs */
+ pci_devs_phb_init();
+
+// of_rescan_bus(root, ci_bus *bus)
+
+ /* Tell pci.c to not change any resource allocations. */
+ pci_set_flags(PCI_PROBE_ONLY);
+
+ of_node_put(dev);
+ DBG("PCI initialized\n");
+
+ pci_io_base = 0;
+
+ // pcibios_scan_phb(hose, dev);
+
+ ppc_md.pci_dma_dev_setup = NULL;
+ ppc_md.pci_dma_bus_setup = NULL;
+ set_pci_dma_ops(&dma_direct_ops);
+}
+
+#else
+
+
+static int __init xenon_add_bridge(struct device_node *dev)
+{
+ int len;
+ struct pci_controller *hose;
+ struct resource rsrc;
+ char *disp_name;
+ const int *bus_range;
+ int primary = 1, has_address = 0;
+
+ printk(KERN_DEBUG "Adding PCI host bridge %s\n", dev->full_name);
+
+ /* Fetch host bridge registers address */
+ has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
+
+ /* Get bus range if any */
+ bus_range = of_get_property(dev, "bus-range", &len);
+ if (bus_range == NULL || len < 2 * sizeof(int)) {
+ printk(KERN_WARNING "Can't get bus-range for %s, assume"
+ " bus 0\n", dev->full_name);
+ }
+
+ hose = pcibios_alloc_controller(dev);
+ if (!hose)
+ return -ENOMEM;
+ hose->first_busno = bus_range ? bus_range[0] : 0;
+ hose->last_busno = bus_range ? bus_range[1] : 0xff;
+
+ hose->ops = &xenon_pci_ops;
+
+ /* FIXME: should come from config */
+ hose->cfg_addr = ioremap(0xd0000000, 0x1000000);
+
+ disp_name = NULL;
+
+ printk(KERN_INFO "Found %s PCI host bridge at 0x%016llx. "
+ "Firmware bus number: %d->%d\n",
+ disp_name, (unsigned long long)rsrc.start, hose->first_busno,
+ hose->last_busno);
+
+ printk(KERN_DEBUG " ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
+ hose, hose->cfg_addr, hose->cfg_data);
+
+ /* Interpret the "ranges" property */
+ /* This also maps the I/O region and sets isa_io/mem_base */
+ pci_process_bridge_OF_ranges(hose, dev, primary);
+
+ /* Fixup "bus-range" OF property */
+ // fixup_bus_range(dev);
+
+ return 0;
+}
+
+void __init xenon_pci_init(void)
+{
+ struct device_node *np, *root;
+
+ ppc_pci_set_flags(PPC_PCI_CAN_SKIP_ISA_ALIGN);
+
+ root = of_find_node_by_path("/");
+ if (root == NULL) {
+ printk(KERN_CRIT "xenon_pci_init: can't find root "
+ "of device tree\n");
+ return;
+ }
+ for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {
+ if (np->name == NULL)
+ continue;
+ if (strcmp(np->name, "pci") == 0) {
+ if (xenon_add_bridge(np) == 0)
+ of_node_get(np);
+ }
+ }
+ of_node_put(root);
+
+ /* Setup the linkage between OF nodes and PHBs */
+ pci_devs_phb_init();
+
+
+ /* We can allocate missing resources if any */
+ pci_probe_only = 0;
+ pci_probe_only = 1;
+
+ /* do we need that? */
+ pci_io_base = 0;
+
+ /* do we need that? */
+ ppc_md.pci_dma_dev_setup = NULL;
+ ppc_md.pci_dma_bus_setup = NULL;
+ set_pci_dma_ops(&dma_direct_ops);
+}
+
+#endif
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/pci.h linux-3.5.1-xenon/arch/powerpc/platforms/xenon/pci.h
--- linux-3.5.1/arch/powerpc/platforms/xenon/pci.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/pci.h 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,7 @@
+#ifndef XENON_PCI_H
+#define XENON_PCI_H
+
+extern void __init xenon_pci_init(void);
+
+#endif
+
diff -NurpP --minimal linux-3.5.1/arch/powerpc/platforms/xenon/setup.c linux-3.5.1-xenon/arch/powerpc/platforms/xenon/setup.c
--- linux-3.5.1/arch/powerpc/platforms/xenon/setup.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.5.1-xenon/arch/powerpc/platforms/xenon/setup.c 2012-10-08 18:45:02.285991500 +0200
@@ -0,0 +1,150 @@
+/*
+ * linux/arch/powerpc/platforms/xenon/xenon_setup.c
+ *
+ * Maintained by: Felix Domke <[email protected]>
+ * Minor modification by: wolie <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/root_dev.h>
+#include <linux/console.h>
+#include <linux/kexec.h>
+
+#include <asm/mmu-hash64.h>
+
+#include <asm/mmu.h>
+#include <asm/prom.h>
+#include <asm/pci-bridge.h>
+#include <asm/ppc-pci.h>
+#include "interrupt.h"
+#include "pci.h"
+#include "smp.h"
+
+static void xenon_show_cpuinfo(struct seq_file *m)
+{
+ struct device_node *root;
+ const char *model = "";
+
+ root = of_find_node_by_path("/");
+ if (root)
+ model = of_get_property(root, "model", NULL);
+ seq_printf(m, "machine\t\t: %s\n", model);
+ of_node_put(root);
+}
+
+static void __init xenon_init_irq(void)
+{
+ xenon_iic_init_IRQ();
+}
+
+static void __init xenon_setup_arch(void)
+{
+#ifdef CONFIG_SMP
+ smp_init_xenon();
+#endif
+ /* init to some ~sane value until calibrate_delay() runs */
+ loops_per_jiffy = 50000000;
+
+ if (ROOT_DEV == 0)
+ ROOT_DEV = Root_SDA1;
+
+ xenon_pci_init();
+#ifdef CONFIG_DUMMY_CONSOLE
+ conswitchp = &dummy_con;
+#endif
+}
+
+static int __init xenon_probe(void)
+{
+ unsigned long root = of_get_flat_dt_root();