-
Notifications
You must be signed in to change notification settings - Fork 9
/
openwrt-metarouter-1.2.patch
5354 lines (5354 loc) · 146 KB
/
openwrt-metarouter-1.2.patch
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
Index: target/linux/mr-ppc/image/Makefile
===================================================================
--- target/linux/mr-ppc/image/Makefile (revision 0)
+++ target/linux/mr-ppc/image/Makefile (revision 0)
@@ -0,0 +1,14 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/image.mk
+
+define Image/BuildKernel
+ cp $(KDIR)/vmlinux.elf $(TARGET_DIR)/kernel
+endef
+
+$(eval $(call BuildImage))
Index: target/linux/mr-ppc/config-2.6.31
===================================================================
--- target/linux/mr-ppc/config-2.6.31 (revision 0)
+++ target/linux/mr-ppc/config-2.6.31 (revision 0)
@@ -0,0 +1,227 @@
+# CONFIG_PPC64 is not set
+
+#
+# Processor support
+#
+# CONFIG_6xx is not set
+# CONFIG_PPC_BOOK3S_32 is not set
+CONFIG_PPC_85xx=y
+# CONFIG_PPC_8xx is not set
+# CONFIG_40x is not set
+# CONFIG_44x is not set
+# CONFIG_E200 is not set
+CONFIG_E500=y
+# CONFIG_PPC_E500MC is not set
+CONFIG_BOOKE=y
+CONFIG_FSL_BOOKE=y
+CONFIG_FSL_EMB_PERFMON=y
+# CONFIG_PHYS_64BIT is not set
+# CONFIG_SPE is not set
+# CONFIG_PPC_MM_SLICES is not set
+CONFIG_PPC32=y
+CONFIG_WORD_SIZE=32
+CONFIG_PPC_MERGE=y
+CONFIG_MMU=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_HARDIRQS=y
+# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
+CONFIG_IRQ_PER_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_ARCH_HAS_ILOG2_U32=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
+CONFIG_PPC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_PPC_OF=y
+CONFIG_OF=y
+
+# CONFIG_PERF_COUNTERS is not set
+
+#
+# Platform support
+#
+# CONFIG_PPC_CELL is not set
+# CONFIG_PPC_CELL_NATIVE is not set
+# CONFIG_PQ2ADS is not set
+CONFIG_MPC85xx=y
+# CONFIG_MPC8540_ADS is not set
+# CONFIG_MPC8560_ADS is not set
+# CONFIG_MPC85xx_CDS is not set
+# CONFIG_MPC85xx_MDS is not set
+# CONFIG_MPC8536_DS is not set
+# CONFIG_MPC85xx_DS is not set
+# CONFIG_SOCRATES is not set
+# CONFIG_KSI8560 is not set
+# CONFIG_XES_MPC85xx is not set
+# CONFIG_STX_GP3 is not set
+# CONFIG_TQM8540 is not set
+# CONFIG_TQM8541 is not set
+# CONFIG_TQM8548 is not set
+# CONFIG_TQM8555 is not set
+# CONFIG_TQM8560 is not set
+# CONFIG_SBC8548 is not set
+# CONFIG_SBC8560 is not set
+CONFIG_METAROUTER=y
+# CONFIG_IPIC is not set
+# CONFIG_MPIC is not set
+# CONFIG_MPIC_WEIRD is not set
+# CONFIG_PPC_I8259 is not set
+# CONFIG_PPC_RTAS is not set
+# CONFIG_MMIO_NVRAM is not set
+# CONFIG_PPC_MPC106 is not set
+# CONFIG_PPC_970_NAP is not set
+# CONFIG_PPC_INDIRECT_IO is not set
+# CONFIG_GENERIC_IOMAP is not set
+# CONFIG_CPU_FREQ is not set
+# CONFIG_QUICC_ENGINE is not set
+# CONFIG_CPM2 is not set
+# CONFIG_MPC8xxx_GPIO is not set
+# CONFIG_FSL_ULI1575 is not set
+
+#
+# Kernel options
+#
+# CONFIG_HIGHMEM is not set
+CONFIG_TICK_ONESHOT=y
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_HZ_100=y
+# CONFIG_HZ_250 is not set
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=100
+CONFIG_SCHED_HRTICK=y
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_MATH_EMULATION=y
+# CONFIG_SWIOTLB is not set
+CONFIG_FORCE_MAX_ZONEORDER=11
+# CONFIG_PROC_DEVICETREE is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_ELF_CORE=y
+CONFIG_COMPAT_BRK=y
+
+#
+# Advanced setup
+#
+CONFIG_ADVANCED_OPTIONS=y
+CONFIG_LOWMEM_SIZE_BOOL=y
+CONFIG_LOWMEM_SIZE=0x60000000
+# CONFIG_LOWMEM_CAM_NUM_BOOL is not set
+# CONFIG_RELOCATABLE is not set
+CONFIG_PAGE_OFFSET_BOOL=y
+CONFIG_PAGE_OFFSET=0x80000000
+CONFIG_KERNEL_START_BOOL=y
+CONFIG_KERNEL_START=0x80000000
+# CONFIG_PHYSICAL_START_BOOL is not set
+CONFIG_PHYSICAL_START=0x00000000
+CONFIG_PHYSICAL_ALIGN=0x10000000
+CONFIG_TASK_SIZE_BOOL=y
+CONFIG_TASK_SIZE=0x80000000
+
+CONFIG_NETDEVICES=y
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+# CONFIG_AX88796 is not set
+CONFIG_MT_VETH=y
+# CONFIG_DM9000 is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_B44 is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+
+# CONFIG_MTD_OF_PARTS is not set
+# CONFIG_MTD_PHYSMAP_OF is not set
+# CONFIG_MACINTOSH_DRIVERS is not set
+# CONFIG_NVRAM is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_EDAC is not set
+# CONFIG_IRQSTACKS is not set
+# CONFIG_PPC_EARLY_DEBUG is not set
+
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+# CONFIG_INPUT_POLLDEV is not set
+
+# CONFIG_VGA_CONSOLE is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_DEVKMEM is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_NOZOMI is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_HVC_DRIVER=y
+CONFIG_HVC_IRQ=y
+CONFIG_HVC_META=y
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_I2C is not set
+# CONFIG_SPI is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
+# CONFIG_WATCHDOG is not set
+
+CONFIG_META_FS=y
+CONFIG_CMDLINE="init=/etc/preinit console=hvc0"
+
+# CONFIG_PPC_DISABLE_WERROR is not set
\ No newline at end of file
Index: target/linux/mr-ppc/base-files/etc/inittab
===================================================================
--- target/linux/mr-ppc/base-files/etc/inittab (revision 0)
+++ target/linux/mr-ppc/base-files/etc/inittab (revision 0)
@@ -0,0 +1,3 @@
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K stop
+hvc0::askfirst:/bin/ash --login
Index: target/linux/mr-ppc/base-files/etc/hotplug2-init.rules
===================================================================
--- target/linux/mr-ppc/base-files/etc/hotplug2-init.rules (revision 0)
+++ target/linux/mr-ppc/base-files/etc/hotplug2-init.rules (revision 0)
@@ -0,0 +1,7 @@
+$include /etc/hotplug2-common.rules
+
+DEVICENAME ~~ (hvc) {
+ nothrottle
+ makedev /dev/%DEVICENAME% 0666
+ next
+}
Index: target/linux/mr-ppc/patches-2.6.31/000-linux-metarouter.patch
===================================================================
--- target/linux/mr-ppc/patches-2.6.31/000-linux-metarouter.patch (revision 0)
+++ target/linux/mr-ppc/patches-2.6.31/000-linux-metarouter.patch (revision 0)
@@ -0,0 +1,2360 @@
+diff -uNr linux-2.6.31.10/arch/mips/include/asm/fixmap.h linux-2.6.31.10.new/arch/mips/include/asm/fixmap.h
+--- linux-2.6.31.10/arch/mips/include/asm/fixmap.h 2010-01-07 00:27:24.000000000 +0200
++++ linux-2.6.31.10.new/arch/mips/include/asm/fixmap.h 2010-04-12 15:54:46.000000000 +0300
+@@ -70,7 +70,11 @@
+ #if defined(CONFIG_CPU_TX39XX) || defined(CONFIG_CPU_TX49XX)
+ #define FIXADDR_TOP ((unsigned long)(long)(int)(0xff000000 - 0x20000))
+ #else
++#ifndef CONFIG_MAPPED_KERNEL
+ #define FIXADDR_TOP ((unsigned long)(long)(int)0xfffe0000)
++#else
++#define FIXADDR_TOP ((unsigned long)(long)(int)0xdffe0000)
++#endif
+ #endif
+ #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
+ #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
+diff -uNr linux-2.6.31.10/arch/mips/include/asm/io.h linux-2.6.31.10.new/arch/mips/include/asm/io.h
+--- linux-2.6.31.10/arch/mips/include/asm/io.h 2010-01-07 00:27:24.000000000 +0200
++++ linux-2.6.31.10.new/arch/mips/include/asm/io.h 2010-04-12 15:54:46.000000000 +0300
+@@ -199,6 +199,7 @@
+ if (!size || last_addr < phys_addr)
+ return NULL;
+
++#ifndef CONFIG_MAPPED_KERNEL
+ /*
+ * Map uncached objects in the low 512MB of address
+ * space using KSEG1.
+@@ -207,6 +208,7 @@
+ flags == _CACHE_UNCACHED)
+ return (void __iomem *)
+ (unsigned long)CKSEG1ADDR(phys_addr);
++#endif
+ }
+
+ return __ioremap(offset, size, flags);
+diff -uNr linux-2.6.31.10/arch/mips/include/asm/mach-metarouter/kernel-entry-init.h linux-2.6.31.10.new/arch/mips/include/asm/mach-metarouter/kernel-entry-init.h
+--- linux-2.6.31.10/arch/mips/include/asm/mach-metarouter/kernel-entry-init.h 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/include/asm/mach-metarouter/kernel-entry-init.h 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,44 @@
++#ifndef __ASM_MACH_METAROUTER_KERNEL_ENTRY_H
++#define __ASM_MACH_METAROUTER_KERNEL_ENTRY_H
++
++.macro kernel_entry_setup
++#ifdef CONFIG_MAPPED_KERNEL
++ .set push
++ .set mips32r2
++ /* check whether we are running under 0xc0000000 address space */
++ lui t0, 0xf000
++ bal 1f
++1: and t1, ra, t0
++ li t0, 0xc0000000
++ beq t0, t1, 2f
++ /* set up 0xc0000000 address space */
++ mtc0 t0, CP0_ENTRYHI
++ li t0, 0x1f
++ mtc0 t0, CP0_ENTRYLO0
++ li t0, 0x0010001f
++ mtc0 t0, CP0_ENTRYLO1
++ li t0, PM_64M
++ mtc0 t0, CP0_PAGEMASK
++ li t0, 0
++ mtc0 t0, CP0_INDEX
++ li t0, 2
++ mtc0 t0, CP0_WIRED
++ ehb
++ tlbwi
++
++ li t0, 0xc8000000
++ mtc0 t0, CP0_ENTRYHI
++ li t0, 0x0020001f
++ mtc0 t0, CP0_ENTRYLO0
++ li t0, 0x0030001f
++ mtc0 t0, CP0_ENTRYLO1
++ li t0, 1
++ mtc0 t0, CP0_INDEX
++ ehb
++ tlbwi
++2:
++ .set pop
++#endif
++.endm
++
++#endif
+diff -uNr linux-2.6.31.10/arch/mips/include/asm/mach-metarouter/spaces.h linux-2.6.31.10.new/arch/mips/include/asm/mach-metarouter/spaces.h
+--- linux-2.6.31.10/arch/mips/include/asm/mach-metarouter/spaces.h 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/include/asm/mach-metarouter/spaces.h 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,24 @@
++#ifndef _ASM_MACH_METAROUTER_SPACES_H
++#define _ASM_MACH_METAROUTER_SPACES_H
++
++#include <linux/const.h>
++
++#define PHYS_OFFSET _AC(0, UL)
++
++#ifdef CONFIG_MAPPED_KERNEL
++#define CAC_BASE _AC(0xc0000000, UL)
++#else
++#define CAC_BASE _AC(0x80000000, UL)
++#endif
++#define IO_BASE _AC(0xa0000000, UL)
++#define UNCAC_BASE _AC(0xa0000000, UL)
++
++#ifndef MAP_BASE
++#define MAP_BASE _AC(0xd0000000, UL)
++#endif
++
++#define HIGHMEM_START _AC(0x20000000, UL)
++
++#define PAGE_OFFSET (CAC_BASE + PHYS_OFFSET)
++
++#endif
+diff -uNr linux-2.6.31.10/arch/mips/include/asm/mach-metarouter/war.h linux-2.6.31.10.new/arch/mips/include/asm/mach-metarouter/war.h
+--- linux-2.6.31.10/arch/mips/include/asm/mach-metarouter/war.h 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/include/asm/mach-metarouter/war.h 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,18 @@
++#ifndef __ASM_MIPS_MACH_METAROUTER_WAR_H
++#define __ASM_MIPS_MACH_METAROUTER_WAR_H
++
++#define R4600_V1_INDEX_ICACHEOP_WAR 0
++#define R4600_V1_HIT_CACHEOP_WAR 0
++#define R4600_V2_HIT_CACHEOP_WAR 0
++#define R5432_CP0_INTERRUPT_WAR 0
++#define BCM1250_M3_WAR 0
++#define SIBYTE_1956_WAR 0
++#define MIPS4K_ICACHE_REFILL_WAR 0
++#define MIPS_CACHE_SYNC_WAR 0
++#define TX49XX_ICACHE_INDEX_INV_WAR 0
++#define RM9000_CDEX_SMP_WAR 0
++#define ICACHE_REFILLS_WORKAROUND_WAR 0
++#define R10000_LLSC_WAR 0
++#define MIPS34K_MISSED_ITLB_WAR 0
++
++#endif
+diff -uNr linux-2.6.31.10/arch/mips/include/asm/vm.h linux-2.6.31.10.new/arch/mips/include/asm/vm.h
+--- linux-2.6.31.10/arch/mips/include/asm/vm.h 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/include/asm/vm.h 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,45 @@
++#ifndef MT_VM_H
++#define MT_VM_H
++
++#define GFP_HYPERVISOR GFP_KERNEL
++
++#define VIRQ_BASE 64
++
++#define hypercall(name, nr, ...) \
++ asm( \
++ ".global " #name ";" \
++ ".align 2;" \
++ ".set push;" \
++ ".set noreorder;" \
++ ".type " #name ",@function;" \
++ ".ent " #name ",0;" \
++ #name ": .frame $sp,0,$ra;" \
++ "li $3, " #nr ";" \
++ "li $2, -22;" \
++ "mtc0 $0, $1;" \
++ "jr $ra;" \
++ "nop;" \
++ ".end " #name ";" \
++ ".size " #name ",.-" #name ";" \
++ ".set pop" \
++ ); \
++ asmlinkage extern int name(__VA_ARGS__);
++
++/* NOTE: do not allow vdma_descr to span multiple pages, so align it */
++struct vdma_descr {
++ unsigned addr;
++ unsigned size;
++ unsigned next;
++} __attribute__((aligned(16)));
++
++#define DONE 0x80000000
++
++static inline unsigned get_virq_nr(unsigned hwirq)
++{
++ return VIRQ_BASE + hwirq;
++}
++
++extern int vm_running(void);
++#define hc_yield() asm volatile ("wait")
++
++#endif
+diff -uNr linux-2.6.31.10/arch/mips/Kconfig linux-2.6.31.10.new/arch/mips/Kconfig
+--- linux-2.6.31.10/arch/mips/Kconfig 2010-01-07 00:27:24.000000000 +0200
++++ linux-2.6.31.10.new/arch/mips/Kconfig 2010-04-12 15:54:46.000000000 +0300
+@@ -591,6 +591,19 @@
+ Support the Mikrotik(tm) RouterBoard 532 series,
+ based on the IDT RC32434 SoC.
+
++config METAROUTER
++ bool "Mikrotik MetaROUTER"
++ select CEVT_R4K
++ select CSRC_R4K
++ select IRQ_CPU
++ select DMA_NONCOHERENT
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select MAPPED_KERNEL
++ help
++ Support the Mikrotik(tm) MetaROUTER.
++
+ config WR_PPMC
+ bool "Wind River PPMC board"
+ select CEVT_R4K
+diff -uNr linux-2.6.31.10/arch/mips/Makefile linux-2.6.31.10.new/arch/mips/Makefile
+--- linux-2.6.31.10/arch/mips/Makefile 2010-04-12 15:51:55.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/Makefile 2010-04-12 15:54:46.000000000 +0300
+@@ -571,6 +571,15 @@
+ endif
+ all-$(CONFIG_SNI_RM) := vmlinux.ecoff
+
++# Mikrotik MetaROUTER
++#
++core-$(CONFIG_METAROUTER) += arch/mips/metarouter/
++cflags-$(CONFIG_METAROUTER) += -I$(srctree)/arch/mips/include/asm/mach-metarouter
++load-$(CONFIG_METAROUTER) += 0xffffffffc0101000
++ifdef CONFIG_METAROUTER
++OBJCOPYFLAGS += --change-addresses=0xc0000000
++endif
++
+ #
+ # Common TXx9
+ #
+diff -uNr linux-2.6.31.10/arch/mips/metarouter/irq.c linux-2.6.31.10.new/arch/mips/metarouter/irq.c
+--- linux-2.6.31.10/arch/mips/metarouter/irq.c 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/metarouter/irq.c 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,97 @@
++#include <linux/init.h>
++#include <linux/linkage.h>
++#include <linux/irq.h>
++#include <linux/interrupt.h>
++#include <linux/bitops.h>
++#include <linux/module.h>
++#include <asm/signal.h>
++#include <asm/mipsregs.h>
++#include <asm/irq_cpu.h>
++#include <asm/bootinfo.h>
++#include <asm/vm.h>
++
++asmlinkage void plat_irq_dispatch(void) {
++ unsigned pending = read_c0_status() & read_c0_cause() & 0xfe00;
++
++ if (pending)
++ do_IRQ(fls(pending) - 9);
++}
++
++volatile unsigned long virqs;
++EXPORT_SYMBOL(virqs);
++
++static void ack_virq(unsigned int irq)
++{
++ clear_bit(irq - VIRQ_BASE, &virqs);
++}
++
++static inline void unmask_virq(unsigned int irq)
++{
++}
++
++static inline void mask_virq(unsigned int irq)
++{
++}
++
++static struct irq_chip virq_controller = {
++ .name = "virq",
++ .ack = ack_virq,
++ .unmask = unmask_virq,
++ .mask = mask_virq,
++};
++
++static irqreturn_t virq_cascade_irq(int irq, void *dev_id)
++{
++ unsigned i;
++ unsigned irqs = virqs;
++
++ for (i = 0; irqs; ++i) {
++ if (irqs & (1 << i)) {
++ do_IRQ(i + VIRQ_BASE);
++ irqs ^= (1 << i);
++ }
++ }
++ return IRQ_HANDLED;
++}
++
++static struct irqaction virq_cascade = {
++ .handler = virq_cascade_irq,
++ .name = "virq-cascade",
++};
++
++static void soft_irq_ack(unsigned int irq)
++{
++ clear_c0_cause(0x100 << (irq - MIPS_CPU_IRQ_BASE));
++}
++
++static inline void unmask_soft_irq(unsigned int irq)
++ {
++ set_c0_status(0x100 << (irq - MIPS_CPU_IRQ_BASE));
++ irq_enable_hazard();
++ }
++
++static inline void mask_soft_irq(unsigned int irq)
++{
++ clear_c0_status(0x100 << (irq - MIPS_CPU_IRQ_BASE));
++ irq_disable_hazard();
++}
++
++static struct irq_chip soft_irq_controller = {
++ .name = "SoftIRQ",
++ .ack = soft_irq_ack,
++ .unmask = unmask_soft_irq,
++ .mask = mask_soft_irq,
++};
++
++void __init arch_init_irq(void)
++{
++ unsigned i;
++
++ mips_cpu_irq_init();
++
++ set_irq_chip_and_handler(1, &soft_irq_controller, handle_percpu_irq);
++ setup_irq(1, &virq_cascade);
++
++ for (i = VIRQ_BASE; i < VIRQ_BASE + 32; ++i)
++ set_irq_chip_and_handler(i, &virq_controller, handle_edge_irq);
++}
+diff -uNr linux-2.6.31.10/arch/mips/metarouter/Makefile linux-2.6.31.10.new/arch/mips/metarouter/Makefile
+--- linux-2.6.31.10/arch/mips/metarouter/Makefile 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/metarouter/Makefile 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1 @@
++obj-y += prom.o irq.o setup.o
+diff -uNr linux-2.6.31.10/arch/mips/metarouter/prom.c linux-2.6.31.10.new/arch/mips/metarouter/prom.c
+--- linux-2.6.31.10/arch/mips/metarouter/prom.c 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/metarouter/prom.c 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,66 @@
++#include <linux/init.h>
++#include <linux/mm.h>
++#include <linux/module.h>
++#include <linux/string.h>
++#include <linux/console.h>
++#include <asm/bootinfo.h>
++#include <linux/bootmem.h>
++#include <linux/ioport.h>
++#include <linux/ctype.h>
++#include <linux/irq.h>
++
++extern char arcs_cmdline[COMMAND_LINE_SIZE];
++
++extern unsigned long totalram_pages;
++extern unsigned long mips_hpt_frequency;
++
++void __init prom_init(void)
++{
++ int argc = fw_arg0;
++ char **argv = (char **) fw_arg1;
++ unsigned i;
++ unsigned offset = strlen(arcs_cmdline);
++ if (offset > 0)
++ offset += snprintf(arcs_cmdline + offset,
++ sizeof(arcs_cmdline) - offset,
++ " ");
++
++ /* HZ must be parsed here because otherwise it's too late */
++ for (i = 0; (i < argc && argv[i] != NULL); i++) {
++ if (strncmp(argv[i], "HZ=", 3) == 0) {
++ mips_hpt_frequency =
++ simple_strtoul(argv[i] + 3, 0, 10);
++ continue;
++ }
++ offset += snprintf(arcs_cmdline + offset,
++ sizeof(arcs_cmdline) - offset,
++ "%s ", argv[i]);
++ }
++}
++
++void __init prom_free_prom_memory(void)
++{
++ unsigned long addr, end;
++ extern char _text;
++
++ /*
++ * Free everything below the kernel itself but leave
++ * the first page reserved for the exception handlers.
++ */
++
++ end = __pa(&_text);
++ addr = PAGE_SIZE;
++
++ while (addr < end) {
++ ClearPageReserved(virt_to_page(__va(addr)));
++ init_page_count(virt_to_page(__va(addr)));
++ free_page((unsigned long)__va(addr));
++ addr += PAGE_SIZE;
++ ++totalram_pages;
++ }
++}
++
++unsigned long long sched_clock(void)
++{
++ return read_c0_count() * 1000000000 / mips_hpt_frequency;
++}
+diff -uNr linux-2.6.31.10/arch/mips/metarouter/setup.c linux-2.6.31.10.new/arch/mips/metarouter/setup.c
+--- linux-2.6.31.10/arch/mips/metarouter/setup.c 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/mips/metarouter/setup.c 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,147 @@
++#include <linux/interrupt.h>
++#include <linux/sched.h>
++#include <asm/reboot.h>
++#include <asm/vm.h>
++
++#define BUF_SIZE 256
++#define BUF_COUNT 4
++
++hypercall(vm_create_queue, 4, unsigned id, unsigned irq,
++ unsigned tx, unsigned rx);
++hypercall(vm_release_queue, 5, unsigned id);
++hypercall(vm_running, 6, void);
++hypercall(vm_setup_irqs, 14, unsigned *irqs, unsigned count);
++
++static volatile struct vdma_descr tx_chain[BUF_COUNT];
++static volatile struct vdma_descr rx_chain[BUF_COUNT];
++static unsigned char tx_buffers[BUF_COUNT][BUF_SIZE];
++static unsigned char rx_buffers[BUF_COUNT][BUF_SIZE];
++
++static unsigned cur_tx;
++static unsigned cur_rx;
++
++static int send_message(const unsigned char *buf, int len)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++
++ /* drop some data if full buffer */
++ while (tx_chain[cur_tx].size & DONE)
++ asm volatile ("wait");
++
++ len = min_t(int, len, BUF_SIZE);
++ memcpy(tx_buffers[cur_tx], buf, len);
++ tx_chain[cur_tx].size = len | DONE;
++
++ cur_tx = (cur_tx + 1) % BUF_COUNT;
++
++ local_irq_restore(flags);
++
++ return len;
++}
++
++static int recv_message(char *buf, int len)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++
++ if (!(rx_chain[cur_rx].size & DONE)) {
++ local_irq_restore(flags);
++ return 0;
++ }
++
++ len = min_t(int, len, rx_chain[cur_rx].size & ~DONE);
++ memcpy(buf, rx_buffers[cur_rx], len);
++
++ rx_chain[cur_rx].size = BUF_SIZE;
++ cur_rx = (cur_rx + 1) % BUF_COUNT;
++
++ local_irq_restore(flags);
++
++ return len;
++}
++
++static irqreturn_t ctrl_interrupt(int irq, void *dev_id)
++{
++ struct task_struct *init;
++ char buf[256];
++ int len;
++
++ len = recv_message(buf, sizeof(buf));
++ if (len <= 0)
++ return IRQ_HANDLED;
++
++ if (strncmp(buf, "restart", len) == 0) {
++ printk("RESTART\n");
++ init = find_task_by_pid_ns(1, &init_pid_ns);
++ if (init)
++ send_sig(SIGINT, init, 1);
++ } else if (strncmp(buf, "halt", len) == 0) {
++ printk("HALT\n");
++ init = find_task_by_pid_ns(1, &init_pid_ns);
++ if (init)
++ send_sig(SIGWINCH, init, 1);
++ }
++
++ return IRQ_HANDLED;
++}
++
++static void rbvm_machine_restart(char *command)
++{
++ char msg[] = "restart";
++
++ send_message(msg, sizeof(msg));
++}
++
++static void rbvm_machine_halt(void)
++{
++ char msg[] = "halt";
++
++ send_message(msg, sizeof(msg));
++}
++
++const char *get_system_type(void)
++{
++ return "Mikrotik MetaROUTER";
++}
++
++void __init plat_mem_setup(void)
++{
++ extern unsigned long virqs;
++ int i;
++
++ vm_setup_irqs((unsigned *) &virqs, 32);
++
++ for (i = 0; i < BUF_COUNT; ++i) {
++ rx_chain[i].addr = (unsigned) rx_buffers[i];
++ rx_chain[i].size = BUF_SIZE;
++ rx_chain[i].next = (unsigned) &rx_chain[i + 1];
++
++ tx_chain[i].addr = (unsigned) tx_buffers[i];
++ tx_chain[i].size = 0;
++ tx_chain[i].next = (unsigned) &tx_chain[i + 1];
++ }
++ rx_chain[BUF_COUNT - 1].next = (unsigned) &rx_chain[0];
++ tx_chain[BUF_COUNT - 1].next = (unsigned) &tx_chain[0];
++
++ vm_create_queue(0, 0, (unsigned) &tx_chain[0],
++ (unsigned) &rx_chain[0]);
++
++ _machine_restart = rbvm_machine_restart;
++ _machine_halt = rbvm_machine_halt;
++}
++
++void __init plat_time_init(void)
++{
++}
++
++int __init init_ctrl_interrupt(void)
++{
++ if (request_irq(VIRQ_BASE + 0, ctrl_interrupt, 0, "ctrl", (void *) 1))
++ return -EBUSY;
++ return 0;
++
++}
++arch_initcall(init_ctrl_interrupt);
+diff -uNr linux-2.6.31.10/arch/powerpc/include/asm/mtvic.h linux-2.6.31.10.new/arch/powerpc/include/asm/mtvic.h
+--- linux-2.6.31.10/arch/powerpc/include/asm/mtvic.h 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/powerpc/include/asm/mtvic.h 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,8 @@
++#ifndef _ASM_POWERPC_MTVIC_H
++#define _ASM_POWERPC_MTVIC_H
++
++void __init mtvic_init(int def);
++unsigned mtvic_get_irq(void);
++unsigned rb_get_irq(void);
++
++#endif
+diff -uNr linux-2.6.31.10/arch/powerpc/include/asm/pgtable-ppc32.h linux-2.6.31.10.new/arch/powerpc/include/asm/pgtable-ppc32.h
+--- linux-2.6.31.10/arch/powerpc/include/asm/pgtable-ppc32.h 2010-01-07 00:27:24.000000000 +0200
++++ linux-2.6.31.10.new/arch/powerpc/include/asm/pgtable-ppc32.h 2010-04-12 15:54:46.000000000 +0300
+@@ -63,7 +63,7 @@
+ #ifdef CONFIG_HIGHMEM
+ #define KVIRT_TOP PKMAP_BASE
+ #else
+-#define KVIRT_TOP (0xfe000000UL) /* for now, could be FIXMAP_BASE ? */
++#define KVIRT_TOP (0xf0000000UL) /* for now, could be FIXMAP_BASE ? */
+ #endif
+
+ /*
+diff -uNr linux-2.6.31.10/arch/powerpc/include/asm/vm.h linux-2.6.31.10.new/arch/powerpc/include/asm/vm.h
+--- linux-2.6.31.10/arch/powerpc/include/asm/vm.h 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/powerpc/include/asm/vm.h 2010-04-12 15:54:46.000000000 +0300
+@@ -0,0 +1,35 @@
++#ifndef MT_VM_H
++#define MT_VM_H
++
++#define hypercall(name, nr, ...) \
++ asm( \
++ ".global " #name ";" \
++ ".align 2;" \
++ ".type " #name ",@function;" \
++ #name ":;" \
++ "li 0, " #nr ";" \
++ "crset so;" \
++ "mtspr 1023, 0;" \
++ "bnslr;" \
++ "li 3, -22;" \
++ "blr" \
++ ); \
++ asmlinkage extern int name(__VA_ARGS__);
++
++/* NOTE: do not allow vdma_descr to span multiple pages, so align it */
++struct vdma_descr {
++ unsigned addr;
++ unsigned size;
++ unsigned next;
++} __attribute__((aligned(16)));
++
++#define DONE 0x80000000
++
++unsigned get_virq_nr(unsigned hwirq);
++int vm_yield(void);
++int vm_running(void);
++
++#define hc_yield() vm_yield()
++
++
++#endif
+diff -uNr linux-2.6.31.10/arch/powerpc/platforms/85xx/Kconfig linux-2.6.31.10.new/arch/powerpc/platforms/85xx/Kconfig
+--- linux-2.6.31.10/arch/powerpc/platforms/85xx/Kconfig 2010-01-07 00:27:24.000000000 +0200
++++ linux-2.6.31.10.new/arch/powerpc/platforms/85xx/Kconfig 2010-04-12 15:54:46.000000000 +0300
+@@ -135,6 +135,12 @@
+ help
+ This option enables support for the Wind River SBC8560 board
+
++config METAROUTER
++ bool "Mikrotik MetaROUTER"
++ select MT_VIC
++ help
++ This option enables support for the Mikrotik MetaROUTER
++
+ endif # MPC85xx
+
+ config TQM85xx
+diff -uNr linux-2.6.31.10/arch/powerpc/platforms/85xx/Makefile linux-2.6.31.10.new/arch/powerpc/platforms/85xx/Makefile
+--- linux-2.6.31.10/arch/powerpc/platforms/85xx/Makefile 2010-01-07 00:27:24.000000000 +0200
++++ linux-2.6.31.10.new/arch/powerpc/platforms/85xx/Makefile 2010-04-12 15:54:46.000000000 +0300
+@@ -9,10 +9,11 @@
+ obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o
+ obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o
+ obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
++obj-$(CONFIG_METAROUTER) += metarouter.o
+ obj-$(CONFIG_STX_GP3) += stx_gp3.o
+ obj-$(CONFIG_TQM85xx) += tqm85xx.o
+ obj-$(CONFIG_SBC8560) += sbc8560.o
+ obj-$(CONFIG_SBC8548) += sbc8548.o
+ obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o
+ obj-$(CONFIG_KSI8560) += ksi8560.o
+-obj-$(CONFIG_XES_MPC85xx) += xes_mpc85xx.o
+\ No newline at end of file
++obj-$(CONFIG_XES_MPC85xx) += xes_mpc85xx.o
+diff -uNr linux-2.6.31.10/arch/powerpc/platforms/85xx/metarouter.c linux-2.6.31.10.new/arch/powerpc/platforms/85xx/metarouter.c
+--- linux-2.6.31.10/arch/powerpc/platforms/85xx/metarouter.c 1970-01-01 03:00:00.000000000 +0300
++++ linux-2.6.31.10.new/arch/powerpc/platforms/85xx/metarouter.c 2010-04-12 15:54:59.000000000 +0300
+@@ -0,0 +1,190 @@
++#include <linux/interrupt.h>
++#include <linux/of_platform.h>
++#include <mm/mmu_decl.h>
++#include <asm/time.h>
++#include <asm/machdep.h>
++#include <asm/mtvic.h>
++#include <asm/vm.h>
++
++#define BUF_SIZE 256
++#define BUF_COUNT 4
++
++hypercall(vm_create_queue, 4, unsigned id, unsigned irq,
++ unsigned tx, unsigned rx);
++hypercall(vm_release_queue, 5, unsigned id);
++hypercall(vm_running, 6, void);
++
++hypercall(vm_setup_irqs, 14, unsigned *irqs, unsigned count);
++hypercall(vm_yield, 16, void);
++
++EXPORT_SYMBOL(vm_yield);
++
++static volatile struct vdma_descr tx_chain[BUF_COUNT];
++static volatile struct vdma_descr rx_chain[BUF_COUNT];
++static unsigned char tx_buffers[BUF_COUNT][BUF_SIZE];
++static unsigned char rx_buffers[BUF_COUNT][BUF_SIZE];
++
++static unsigned cur_tx;
++static unsigned cur_rx;
++
++static int send_message(const unsigned char *buf, int len)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++
++ /* drop some data if full buffer */
++ while (tx_chain[cur_tx].size & DONE)
++ hc_yield();
++
++ len = min_t(int, len, BUF_SIZE);
++ memcpy(tx_buffers[cur_tx], buf, len);
++ tx_chain[cur_tx].size = len | DONE;
++
++ cur_tx = (cur_tx + 1) % BUF_COUNT;
++
++ local_irq_restore(flags);
++
++ return len;
++}
++
++static int recv_message(char *buf, int len)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++
++ if (!(rx_chain[cur_rx].size & DONE)) {
++ local_irq_restore(flags);
++ return 0;
++ }
++
++ len = min_t(int, len, rx_chain[cur_rx].size & ~DONE);
++ memcpy(buf, rx_buffers[cur_rx], len);
++
++ rx_chain[cur_rx].size = BUF_SIZE;
++ cur_rx = (cur_rx + 1) % BUF_COUNT;
++
++ local_irq_restore(flags);
++
++ return len;
++}
++
++static irqreturn_t ctrl_interrupt(int irq, void *dev_id)