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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
|
diff --git a/arch/nios2nommu/ChangeLog b/arch/nios2nommu/ChangeLog
new file mode 100644
index 0000000..039c010
--- /dev/null
+++ b/arch/nios2nommu/ChangeLog
@@ -0,0 +1,4 @@
+2004-06-15 Ken Hill <khill@microtronix.com>
+
+ * Kconfig: Add Microtronix uKit support.
+
diff --git a/arch/nios2nommu/Kconfig b/arch/nios2nommu/Kconfig
new file mode 100644
index 0000000..525c77b
--- /dev/null
+++ b/arch/nios2nommu/Kconfig
@@ -0,0 +1,403 @@
+#
+# For a description of the syntax of this configuration file,
+# see the Configure script.
+#
+mainmenu 'uClinux/Nios2 (w/o MMU) Kernel Configuration'
+
+config MMU
+ bool
+ default n
+
+config FPU
+ bool
+ default n
+
+config ZONE_DMA
+ bool
+ default y
+
+config UID16
+ bool
+ default y
+
+config RWSEM_GENERIC_SPINLOCK
+ bool
+ default y
+
+config RWSEM_XCHGADD_ALGORITHM
+ bool
+ default n
+
+config GENERIC_FIND_NEXT_BIT
+ bool
+ default y
+
+config GENERIC_HWEIGHT
+ bool
+ default y
+
+config GENERIC_CALIBRATE_DELAY
+ bool
+ default y
+
+source "init/Kconfig"
+
+menu "Processor type and features"
+
+comment 'Platform dependant setup'
+
+choice
+ prompt "CPU"
+ default NIOS2
+
+config NIOS2
+ bool "NIOS2"
+ help
+ Altera Nios2 softcore processor.
+
+endchoice
+
+choice
+ prompt "Platform"
+ default ALTERA_STRATIX
+
+config MICROTRONIX_UKIT
+ bool "Microtronix uKit board support"
+ depends on NIOS2
+ help
+ Support for the Microtronix uKit development board. Includes support
+ for Sodimm SDRAM/FLASH, soft ethernet MAC & PHY.
+
+config MICROTRONIX_STRATIX
+ bool "Microtronix Stratix board support"
+ depends on NIOS2
+ help
+ Support for the Microtronix Stratix board. Includes support
+ for Sodimm SDRAM/FLASH, soft ethernet MAC & PHY, USB, LVDS
+ & analog/digital converters.
+
+config MICROTRONIX_CYCLONE
+ bool "Microtronix Cyclone board support"
+ depends on NIOS2
+ help
+ Support for the Microtronix Cyclone board. Includes support
+ for SDRAM, FLASH, soft ethernet MAC & PHY, USB,
+ & analog/digital converters.
+
+config MICROTRONIX_PSK
+ bool "Microtronix PSK (Product Starter Kit) support"
+ depends on NIOS2
+ help
+ Support for the Microtronix PSK (Product Starter Kit), which
+ features firefly module (EP1C4 or EP1C12). Includes support
+ for SDRAM, FLASH, and a variety of product expansion kits such
+ as USB, Ethernet etc.
+
+config ALTERA_STRATIX
+ bool "Altera Stratix Development board support"
+ depends on NIOS2
+ help
+ Support for the Altera Stratix Development board. Includes
+ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
+
+config ALTERA_STRATIX_PRO
+ bool "Altera Stratix Pro Development board support"
+ depends on NIOS2
+ help
+ Support for the Altera Stratix 1s40 Development board. Includes
+ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
+
+config ALTERA_STRATIX_II
+ bool "Altera Stratix II Development board support"
+ depends on NIOS2
+ help
+ Support for the Altera Stratix II Development board. Includes
+ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
+
+config ALTERA_CYCLONE
+ bool "Altera Cyclone Development board support"
+ depends on NIOS2
+ help
+ Support for the Altera Cyclone Development board. Includes
+ support for 10/100 ethernet, FLASH, SDRAM, compact flash.
+
+config ALTERA_CYCLONE_1C12_EVAL
+ bool "Altera Cyclone 1C12 Evaluation board support"
+ depends on NIOS2
+ help
+ Support for the Altera Cyclone 1C12 Evaluation board (with the
+ embedded processor module).
+
+config ALTERA_DE2
+ bool "Altera DE2 Development board support"
+ depends on NIOS2
+ help
+ Support for the Altera Cyclone Development board. Includes
+ support for 10/100 ethernet, FLASH, SDRAM, VGA, I2C.
+
+endchoice
+
+choice
+ prompt "Nios II Hardware Multiply Support"
+ default NIOS2_HW_MULX
+ help
+ This option enables various assembler instructions based on your
+ selection. The choice depends on what target hardware you'll be
+ running your applications on. The default is
+ "Enable mulx instruction".
+
+ Here is an explanation of each option:
+ None = -mno-hw-mul -mno-hw-mulx
+ (no mul or mulx instructions used)
+ Enable mul instruction = -mhw-mul -mno-hw-mulx
+ (use mul instructions)
+ Enable mul and mulx instructions = -mhw-mul -mhw-mulx
+ (use mul and mulx instructions)
+
+ If you don't know what to choose, select "Enable mulx instruction".
+
+config NIOS2_HW_MUL_OFF
+ bool "None"
+
+config NIOS2_HW_MUL
+ bool "Enable mul instruction"
+
+config NIOS2_HW_MULX
+ bool "Enable mul and mulx instructions"
+
+endchoice
+
+comment 'Platform drivers Options'
+
+config AVALON_DMA
+ bool "Support of DMA controller with Avalon interface"
+ default y
+ help
+ This enables support of Altera's DMA controller with Avalon
+ interface, so that drivers of DMA-able device can use this
+ interface.
+
+config PIO_DEVICES
+ bool "Enable leds, seven segment display"
+ default y
+ depends on (ALTERA_STRATIX || ALTERA_STRATIX_PRO || ALTERA_CYCLONE)
+ help
+ This enables example code to support leds, and seven segment
+ display as PIO devices. Once enabled, the kernel will show a
+ counter (increas once a second) on these devices.
+
+source "arch/nios2nommu/drivers/Kconfig"
+
+comment 'Miscellaneous Options'
+
+config EXCALIBUR
+ bool
+ default y
+ depends on (NIOS2)
+
+config BREAK_ON_START
+ bool "Include breakpoint trap on kernel startup"
+ help
+ Configures the kernel to trap to the GDB client on startup
+ before the kernel starts initialization. This allows you to
+ debug the kernel startup.
+
+config LARGE_ALLOCS
+ bool "Allow allocating large blocks (> 1MB) of memory"
+ help
+ Allow the slab memory allocator to keep chains for very large
+ memory sizes - upto 32MB. You may need this if your system has
+ a lot of RAM, and you need to able to allocate very large
+ contiguous chunks. If unsure, say N.
+
+choice
+ prompt "Kernel executes from"
+ ---help---
+ Choose the memory type that the kernel will be running in.
+
+config RAMKERNEL
+ bool "RAM"
+ help
+ The kernel will be resident in RAM when running.
+
+#config ROMKERNEL
+# bool "ROM"
+# help
+# The kernel will be resident in FLASH/ROM when running.
+
+#config HIMEMKERNEL
+# bool "HIMEM"
+# help
+# The kernel will be resident in high memory when running.
+
+endchoice
+
+config PREEMPT
+ bool "Preemptible Kernel"
+ help
+ This option reduces the latency of the kernel when reacting to
+ real-time or interactive events by allowing a low priority process to
+ be preempted even if it is in kernel mode executing a system call.
+ This allows applications to run more reliably even when the system is
+ under load.
+
+ Say Y here if you are building a kernel for a desktop, embedded
+ or real-time system. Say N if you are unsure.
+
+config PREEMPT_TIMES
+ bool "Collect preemption latency times"
+ depends on PREEMPT
+ help
+ Allow collection for preemption latency times.
+
+config CMDLINE
+ string "Default kernel command string"
+ default "CONSOLE=/dev/ttyS0 root=/dev/rom0 ro"
+ help
+ On some architectures, there is currently no way
+ for the boot loader to pass arguments to the kernel. For these
+ architectures, you should supply some command-line options at build
+ time by entering them here. As a minimum, you should specify the
+ memory size and the root device (e.g., mem=64M root=/dev/nfs).
+
+config PASS_CMDLINE
+ bool "Passed kernel command line from u-boot"
+ default n
+ help
+ Use bootargs env variable from u-boot for kernel command line.
+ will override "Default kernel command string".
+ Say N if you are unsure.
+
+source "mm/Kconfig"
+
+config BOOT_LINK_OFFSET
+ hex "Link address offset for booting"
+ default "0x00800000"
+ help
+ This option allows you to set the link address offset of the zImage.
+ This can be useful if you are on a board which has a small amount of
+ memory.
+
+endmenu
+
+menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
+
+config PCI
+ bool "PCI support"
+ help
+ Support for PCI bus.
+
+source "drivers/pci/Kconfig"
+
+config HOTPLUG
+ bool "Support for hot-pluggable device"
+ ---help---
+ Say Y here if you want to plug devices into your computer while
+ the system is running, and be able to use them quickly. In many
+ cases, the devices can likewise be unplugged at any time too.
+
+ One well known example of this is PCMCIA- or PC-cards, credit-card
+ size devices such as network cards, modems or hard drives which are
+ plugged into slots found on all modern laptop computers. Another
+ example, used on modern desktops as well as laptops, is USB.
+
+ Enable HOTPLUG and KMOD, and build a modular kernel. Get agent
+ software (at <http://linux-hotplug.sourceforge.net/>) and install it.
+ Then your kernel will automatically call out to a user mode "policy
+ agent" (/sbin/hotplug) to load modules and set up software needed
+ to use devices as you hotplug them.
+
+source "drivers/pcmcia/Kconfig"
+
+source "drivers/pci/hotplug/Kconfig"
+
+endmenu
+
+menu "Executable file formats"
+
+config KCORE_AOUT
+ bool
+ default y
+
+config KCORE_ELF
+ bool
+ default y
+
+source "fs/Kconfig.binfmt"
+
+endmenu
+
+menu "Power management options"
+
+config PM
+ bool "Power Management support"
+ help
+ Support processor power management modes
+
+endmenu
+
+
+source "net/Kconfig"
+
+source "drivers/Kconfig"
+
+source "fs/Kconfig"
+
+source "arch/nios2nommu/Kconfig.debug"
+
+menu "Kernel hacking"
+
+config FULLDEBUG
+ bool "Full Symbolic/Source Debugging support"
+ help
+ Enable debuging symbols on kernel build.
+
+config FRAME_POINTER
+ bool "Compile the kernel with frame pointers"
+ help
+ If you say Y here the resulting kernel image will be slightly larger
+ and slower, but it will give very useful debugging information.
+ If you don't debug the kernel, you can say N, but we may not be able
+ to solve problems without frame pointers.
+
+config MAGIC_SYSRQ
+ bool "Magic SysRq key"
+ help
+ Enables console device to interpret special characters as
+ commands to dump state information.
+
+config HIGHPROFILE
+ bool "Use fast second timer for profiling"
+ depends on COLDFIRE
+ help
+ Use a fast secondary clock to produce profiling information.
+
+config NO_KERNEL_MSG
+ bool "Suppress Kernel BUG Messages"
+ help
+ Do not output any debug BUG messages within the kernel.
+
+config LOG_BUF_SHIFT
+ int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
+ range 12 21
+ default 17 if ARCH_S390
+ default 16 if X86_NUMAQ || IA64
+ default 15 if SMP
+ default 14
+ help
+ Select kernel log buffer size as a power of 2.
+ Defaults and Examples:
+ 17 => 128 KB for S/390
+ 16 => 64 KB for x86 NUMAQ or IA-64
+ 15 => 32 KB for SMP
+ 14 => 16 KB for uniprocessor
+ 13 => 8 KB
+ 12 => 4 KB
+
+endmenu
+
+source "security/Kconfig"
+
+source "crypto/Kconfig"
+
+source "lib/Kconfig"
diff --git a/arch/nios2nommu/Kconfig.debug b/arch/nios2nommu/Kconfig.debug
new file mode 100644
index 0000000..b188c4a
--- /dev/null
+++ b/arch/nios2nommu/Kconfig.debug
@@ -0,0 +1,35 @@
+menu "Kernel hacking"
+
+source "lib/Kconfig.debug"
+
+config FULLDEBUG
+ bool "Full Symbolic/Source Debugging support"
+ help
+ Enable debuging symbols on kernel build.
+
+config FRAME_POINTER
+ bool "Compile the kernel with frame pointers"
+ help
+ If you say Y here the resulting kernel image will be slightly larger
+ and slower, but it will give very useful debugging information.
+ If you don't debug the kernel, you can say N, but we may not be able
+ to solve problems without frame pointers.
+
+config MAGIC_SYSRQ
+ bool "Magic SysRq key"
+ help
+ Enables console device to interpret special characters as
+ commands to dump state information.
+
+config HIGHPROFILE
+ bool "Use fast second timer for profiling"
+ depends on COLDFIRE
+ help
+ Use a fast secondary clock to produce profiling information.
+
+config NO_KERNEL_MSG
+ bool "Suppress Kernel BUG Messages"
+ help
+ Do not output any debug BUG messages within the kernel.
+
+endmenu
diff --git a/arch/nios2nommu/Makefile b/arch/nios2nommu/Makefile
new file mode 100644
index 0000000..ca139b6
--- /dev/null
+++ b/arch/nios2nommu/Makefile
@@ -0,0 +1,181 @@
+# arch/niosnommu/Makefile
+#
+# Makefile for the architecture dependent flags and dependencies on the
+# nios.
+#
+# Copyright (C) 2001 Vic Phillips (vic@microtronix.com)
+#
+# based on sparcnommu/Makefile:
+#
+# Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
+#
+KERNELLOAD = ${shell echo `grep "nasys_program_mem " include/asm/nios.h | sed 's/^.*\*)//' | sed 's/)//'`}
+
+HARDWARE_MK = arch/$(ARCH)/hardware.mk
+
+platform-$(CONFIG_NIOS) := NIOS2
+PLATFORM := $(platform-y)
+
+board-$(CONFIG_ALTERA_STRATIX) := altera_stratix
+board-$(CONFIG_ALTERA_STRATIX_PRO) := altera_stratix_pro
+board-$(CONFIG_ALTERA_STRATIX_II) := altera_stratix_ii
+board-$(CONFIG_ALTERA_CYCLONE) := altera_cyclone
+board-$(CONFIG_ALTERA_CYCLONE_1C12_EVAL) := altera_cyclone_1c12_eval
+board-$(CONFIG_MICROTRONIX_STRATIX) := microtronix_stratix
+board-$(CONFIG_MICROTRONIX_CYCLONE) := microtronix_cyclone
+board-$(CONFIG_MICROTRONIX_UKIT) := microtronix_ukit
+board-$(CONFIG_MICROTRONIX_PSK) := microtronix_psk
+BOARD := $(board-y)
+
+model-$(CONFIG_RAMKERNEL) := ram
+model-$(CONFIG_ROMKERNEL) := rom
+model-$(CONFIG_HIMEMKERNEL) := himem
+MODEL := $(model-y)
+
+export PLATFORM BOARD MODEL
+
+CFLAGS += -DNO_MM -pipe -D__linux__ -D__ELF__
+#CFLAGS += -DNO_MM -save-temps -D__linux__ -D__ELF__
+
+# Uncomment this if you are doing gdb source level
+# debugging of the kernel to get the proper debugging information.
+#
+#CFLAGS += -DDEBUG
+
+# Turn on/off various hardware multiply options
+cpu-cflags-$(CONFIG_NIOS2_HW_MUL_OFF) += -mno-hw-mul -mno-hw-mulx
+cpu-cflags-$(CONFIG_NIOS2_HW_MUL) += -mhw-mul -mno-hw-mulx
+cpu-cflags-$(CONFIG_NIOS2_HW_MULX) += -mhw-mul -mhw-mulx
+CFLAGS += $(cpu-cflags-y)
+
+# mulx flags currently cause older version of nios2-elf-gcc to fail
+# The following line ensures that all mulx flags are removed before
+# it is passed to the compiler.
+mulx_help_text:= $(shell $(CC) --target-help | grep mulx)
+ifeq "$(mulx_help_text)" ""
+CFLAGS := $(filter-out -mhw-mulx -mno-hw-mulx, $(CFLAGS))
+endif
+
+# Temporary workaround for nios2-elf-gcc bug
+# First noticed in v3.4.1 (Altera Nios II 1.1 b131)
+# To be removed at a later date when bug is resolved.
+CFLAGS += -fno-optimize-sibling-calls
+
+# This undefines the "__init" type used in defining initialization
+# procedures. When defined, the procedures are put into an 'init' data
+# section that GDB doesn't recognize as source.
+#
+CFLAGS += -DNO_TEXT_SECTIONS
+CFLAGS += -fno-builtin
+CFLAGS += -O2 -g -G 0
+CFLAGS += -DUTS_SYSNAME=\"uClinux\"
+
+CFLAGS_GCC_INC := $(shell $(CC) -print-file-name=include)
+CFLAGS += -I$(CFLAGS_GCC_INC)
+
+AFLAGS += -DNO_MM -g
+#AFLAGS += -DNO_MM -g -save-temps
+
+# vic - add this to get name of nios gcc library
+LIBGCC_CFLAGS = $(if $(CONFIG_NIOS2_HW_MUL_OFF),-mno-hw-mul)
+LIBGCC := `$(CC) --print-libgcc-file-name $(LIBGCC_CFLAGS)`
+
+# add this to avoid multiple '_stack' and '_vecbase' definition errors
+#
+ifdef niosgnu
+# Include the path to the lib directory where the ldscripts are found to fix
+# a problem with the cygwin/bash environment.
+
+#cygwhack: kenw - this following section could be a possible problem
+# due to the O= option on the command line.
+LDSCRIPTS:=$(shell nios2-elf-gcc -print-file-name=ldscripts)
+LDFLAGS += -mnios2elf -L $(LDSCRIPTS)/..
+else
+LDFLAGS += -mnios2elf
+LDLIBS := -L `$(CC) -print-file-name=m32` -l gcc
+endif
+
+head-y := arch/nios2nommu/kernel/head.o arch/nios2nommu/kernel/init_task.o
+
+CLEAN_FILES := include/asm-$(ARCH)/asm-offsets.h \
+ $(HARDWARE_MK) \
+ arch/$(ARCH)/kernel/asm-offsets.s \
+ linux.srec \
+ linux.flash \
+ linux.bin \
+ linux.bin.srec
+
+core-y += arch/nios2nommu/kernel/ \
+ arch/nios2nommu/mm/ \
+ arch/nios2nommu/drivers/
+
+libs-y += arch/nios2nommu/lib/
+
+libs-y += $(LIBGCC)
+####;dgt2;tmp;
+
+# force user to configure hardware before building kernel
+
+pardoned_targets = clean mrproper sgmldocs psdocs pdfdocs \
+ htmldocs mandocs headers_install
+
+-include $(HARDWARE_MK)
+build_targets = $(filter-out $(pardoned_targets), $(MAKECMDGOALS))
+ifneq '$(strip $(build_targets))' ''
+ ifndef SYSPTF
+ ifneq '$(firstword $(MAKECMDGOALS))' 'hwselect'
+ $(error Run "make hwselect SYSPTF=<system.ptf>" first)
+ endif
+ endif
+endif
+
+quiet_cmd_gen_mk = ' RUNNING $@'
+define cmd_gen_mk
+ mkdir -p $(dir $(objtree)/$(HARDWARE_MK)); \
+ perl -I$(TOPDIR)/arch/$(ARCH)/scripts \
+ $(srctree)/arch/$(ARCH)/scripts/hwselect.pl $(SYSPTF) \
+ $(objtree)/$(HARDWARE_MK)
+endef
+
+.PHONY: hwselect
+hwselect:
+ @echo $($(quiet)cmd_gen_mk);
+ @$(cmd_gen_mk)
+
+prepare: include/nios2_system.h
+
+archclean:
+ $(call descend arch/$(ARCH)/boot, subdirclean)
+
+define filechk_nios2_system.h
+ # call perl script that will build nios2_system.h file
+ perl -I$(TOPDIR)/arch/$(ARCH)/scripts \
+ $(TOPDIR)/arch/$(ARCH)/scripts/gen_nios2_system.h.pl $(CPU) $(EXEMEM) $(UPLMEM)
+endef
+
+include/nios2_system.h: $(SYSPTF) FORCE
+ $(call filechk,nios2_system.h)
+
+quiet_cmd_touch = ' TOUCH $@'
+ cmd_touch = touch $(TOPDIR)/$@
+
+arch/$(ARCH)/kernel/vmlinux.lds.S: FORCE
+ @echo $($(quiet)cmd_touch);
+ @$(cmd_touch)
+
+linuxsrec: linux
+ $(OBJCOPY) -O srec $(LINUX) linux.srec
+
+boot := arch/nios2nommu/boot
+
+zImage: vmlinux
+ $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
+
+compressed: zImage
+
+CLEAN_FILES += include/nios2_system.h
+
+archmrproper:
+
+archdep:
+
diff --git a/arch/nios2nommu/boot/Makefile b/arch/nios2nommu/boot/Makefile
new file mode 100644
index 0000000..fd25b72
--- /dev/null
+++ b/arch/nios2nommu/boot/Makefile
@@ -0,0 +1,17 @@
+#
+# arch/nios2nommu/boot/Makefile
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License. See the file "COPYING" in the main directory of this archive
+# for more details.
+
+targets := zImage
+subdir- := compressed
+
+$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
+ $(call if_changed,objcopy)
+ @echo 'Kernel: $@ is ready'
+
+$(obj)/compressed/vmlinux: FORCE
+ $(Q)$(MAKE) $(build)=$(obj)/compressed $@
+
diff --git a/arch/nios2nommu/boot/compressed/Makefile b/arch/nios2nommu/boot/compressed/Makefile
new file mode 100644
index 0000000..2002471
--- /dev/null
+++ b/arch/nios2nommu/boot/compressed/Makefile
@@ -0,0 +1,36 @@
+#
+# linux/arch/sh/boot/compressed/Makefile
+#
+# create a compressed vmlinux image from the original vmlinux
+#
+
+targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o \
+ piggy.o vmlinux.lds
+EXTRA_AFLAGS :=
+
+OBJECTS = $(obj)/head.o $(obj)/misc.o
+
+#
+# IMAGE_OFFSET is the load offset of the compression loader
+#
+#IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_MEMORY_START)+0x2000])
+#IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_MEMORY_START)+0x00400000])
+
+LDFLAGS_vmlinux := -T
+
+$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE
+ $(call if_changed,ld)
+ @:
+
+$(obj)/vmlinux.bin: vmlinux FORCE
+ $(call if_changed,objcopy)
+
+$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
+ $(call if_changed,gzip)
+
+LDFLAGS_piggy.o := -r --format binary --oformat elf32-littlenios2 -T
+
+OBJCOPYFLAGS += -O binary
+
+$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
+ $(call if_changed,ld)
diff --git a/arch/nios2nommu/boot/compressed/head.S b/arch/nios2nommu/boot/compressed/head.S
new file mode 100644
index 0000000..accadd0
--- /dev/null
+++ b/arch/nios2nommu/boot/compressed/head.S
@@ -0,0 +1,100 @@
+/*
+ * linux/arch/nios2nommu/boot/compressed/head.S
+ *
+ */
+
+ .text
+ .set noat
+#include <asm/asm-offsets.h>
+#include <asm/asm-macros.h>
+
+ /*
+ * This code can be loaded anywhere, as long as output will not
+ * overlap it.
+ *
+ */
+
+ .global _start
+_start:
+ // disable interrupt
+ wrctl status, r0
+ // flush the instruction cache
+ movia r1,NIOS2_ICACHE_SIZE
+ movi r2,NIOS2_ICACHE_LINE_SIZE
+text_init:
+ initi r1
+ sub r1, r1, r2
+ bgt r1, zero, text_init
+ // then flush the pipeline
+ flushp
+ // flush the data cache
+ movia r1,NIOS2_DCACHE_SIZE
+ movi r2,NIOS2_DCACHE_LINE_SIZE
+data_init:
+ initd (r1)
+ sub r1, r1, r2
+ bgt r1, zero, data_init
+ //------------------------------------------------------
+ // Zero out the .bss segment (uninitialized common data)
+ //
+ movia r2,__bss_start // presume nothing is between
+ movia r1,_end // the .bss and _end.
+1:
+ stb r0,0(r2)
+ addi r2,r2,1
+ bne r1,r2,1b
+ // set up the stack pointer, some where higher than _end. The stack space must be greater than 32K for decompress.
+ movia sp, 0x10000
+ add sp,sp,r1
+ // save args passed from u-boot
+ addi sp,sp,-16
+ stw r4,0(sp)
+ stw r5,4(sp)
+ stw r6,8(sp)
+ stw r7,12(sp)
+/*
+ * decompress the kernel
+ */
+ call decompress_kernel
+
+flush_cache:
+ // flush all cache after loading
+ // flush the data cache
+ movia r1,NIOS2_DCACHE_SIZE
+ movi r2,NIOS2_DCACHE_LINE_SIZE
+data_flush:
+ flushd (r1)
+ sub r1, r1, r2
+ bgt r1, zero, data_flush
+ // flush the instruction cache
+ movia r1,NIOS2_ICACHE_SIZE
+ movi r2,NIOS2_ICACHE_LINE_SIZE
+text_flush:
+ flushi r1
+ sub r1, r1, r2
+ bgt r1, zero, text_flush
+ // then flush the pipeline
+ flushp
+ // pass saved args to kernel
+ ldw r4,0(sp)
+ ldw r5,4(sp)
+ ldw r6,8(sp)
+ ldw r7,12(sp)
+ movia r1,LINUX_SDRAM_START
+ jmp r1
+
+ .balign 512
+fake_headers_as_bzImage:
+ .short 0
+ .ascii "HdrS"
+ .short 0x0202
+ .short 0
+ .short 0
+ .byte 0x00, 0x10
+ .short 0
+ .byte 0
+ .byte 1
+ .byte 0x00, 0x80
+ .long 0
+ .long 0
+
diff --git a/arch/nios2nommu/boot/compressed/install.sh b/arch/nios2nommu/boot/compressed/install.sh
new file mode 100644
index 0000000..6d72e9e
--- /dev/null
+++ b/arch/nios2nommu/boot/compressed/install.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# arch/sh/boot/install.sh
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License. See the file "COPYING" in the main directory of this archive
+# for more details.
+#
+# Copyright (C) 1995 by Linus Torvalds
+#
+# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
+# Adapted from code in arch/i386/boot/install.sh by Russell King
+# Adapted from code in arch/arm/boot/install.sh by Stuart Menefy
+# Adapted from code in arch/sh/boot/install.sh by Takeo Takahashi
+#
+# "make install" script for sh architecture
+#
+# Arguments:
+# $1 - kernel version
+# $2 - kernel image file
+# $3 - kernel map file
+# $4 - default install path (blank if root directory)
+#
+
+# User may have a custom install script
+
+if [ -x /sbin/installkernel ]; then
+ exec /sbin/installkernel "$@"
+fi
+
+if [ "$2" = "zImage" ]; then
+# Compressed install
+ echo "Installing compressed kernel"
+ if [ -f $4/vmlinuz-$1 ]; then
+ mv $4/vmlinuz-$1 $4/vmlinuz.old
+ fi
+
+ if [ -f $4/System.map-$1 ]; then
+ mv $4/System.map-$1 $4/System.old
+ fi
+
+ cat $2 > $4/vmlinuz-$1
+ cp $3 $4/System.map-$1
+else
+# Normal install
+ echo "Installing normal kernel"
+ if [ -f $4/vmlinux-$1 ]; then
+ mv $4/vmlinux-$1 $4/vmlinux.old
+ fi
+
+ if [ -f $4/System.map ]; then
+ mv $4/System.map $4/System.old
+ fi
+
+ cat $2 > $4/vmlinux-$1
+ cp $3 $4/System.map
+fi
diff --git a/arch/nios2nommu/boot/compressed/misc.c b/arch/nios2nommu/boot/compressed/misc.c
new file mode 100644
index 0000000..c513e6e
--- /dev/null
+++ b/arch/nios2nommu/boot/compressed/misc.c
@@ -0,0 +1,208 @@
+/*
+ * arch/nios2nommu/boot/compressed/misc.c
+ *
+ * This is a collection of several routines from gzip-1.0.3
+ * adapted for Linux.
+ *
+ * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
+ *
+ * Adapted for SH by Stuart Menefy, Aug 1999
+ *
+ * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
+ */
+
+#include <linux/string.h>
+
+/*
+ * gzip declarations
+ */
+
+#define OF(args) args
+#define STATIC static
+
+#undef memset
+#undef memcpy
+#define memzero(s, n) memset ((s), 0, (n))
+
+typedef unsigned char uch;
+typedef unsigned short ush;
+typedef unsigned long ulg;
+
+#define WSIZE 0x8000 /* Window size must be at least 32k, */
+ /* and a power of two */
+
+static uch *inbuf; /* input buffer */
+static uch window[WSIZE]; /* Sliding window buffer */
+
+static unsigned insize = 0; /* valid bytes in inbuf */
+static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
+static unsigned outcnt = 0; /* bytes in output buffer */
+
+/* gzip flag byte */
+#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
+#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
+#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
+#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
+#define COMMENT 0x10 /* bit 4 set: file comment present */
+#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
+#define RESERVED 0xC0 /* bit 6,7: reserved */
+
+#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
+
+/* Diagnostic functions */
+#ifdef DEBUG
+# define Assert(cond,msg) {if(!(cond)) error(msg);}
+# define Trace(x) fprintf x
+# define Tracev(x) {if (verbose) fprintf x ;}
+# define Tracevv(x) {if (verbose>1) fprintf x ;}
+# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
+# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
+#else
+# define Assert(cond,msg)
+# define Trace(x)
+# define Tracev(x)
+# define Tracevv(x)
+# define Tracec(c,x)
+# define Tracecv(c,x)
+#endif
+
+static int fill_inbuf(void);
+static void flush_window(void);
+static void error(char *m);
+static void gzip_mark(void **);
+static void gzip_release(void **);
+
+extern char input_data[];
+extern int input_len;
+
+static long bytes_out = 0;
+static uch *output_data;
+static unsigned long output_ptr = 0;
+
+#include "nios2_sio.c"
+
+static void *malloc(int size);
+static void free(void *where);
+static void error(char *m);
+static void gzip_mark(void **);
+static void gzip_release(void **);
+
+int puts(const char *);
+
+extern int _end;
+static unsigned long free_mem_ptr;
+static unsigned long free_mem_end_ptr;
+
+#define HEAP_SIZE 0x10000
+
+#include "../../../../lib/inflate.c"
+
+static void *malloc(int size)
+{
+ void *p;
+
+ if (size <0) error("Malloc error");
+ if (free_mem_ptr == 0) error("Memory error");
+
+ free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
+
+ p = (void *)free_mem_ptr;
+ free_mem_ptr += size;
+
+ if (free_mem_ptr >= free_mem_end_ptr)
+ error("Out of memory");
+
+ return p;
+}
+
+static void free(void *where)
+{ /* Don't care */
+}
+
+static void gzip_mark(void **ptr)
+{
+ *ptr = (void *) free_mem_ptr;
+}
+
+static void gzip_release(void **ptr)
+{
+ free_mem_ptr = (long) *ptr;
+}
+
+void* memset(void* s, int c, size_t n)
+{
+ int i;
+ char *ss = (char*)s;
+
+ for (i=0;i<n;i++) ss[i] = c;
+ return s;
+}
+
+void* memcpy(void* __dest, __const void* __src,
+ size_t __n)
+{
+ int i;
+ char *d = (char *)__dest, *s = (char *)__src;
+
+ for (i=0;i<__n;i++) d[i] = s[i];
+ return __dest;
+}
+
+/* ===========================================================================
+ * Fill the input buffer. This is called only when the buffer is empty
+ * and at least one byte is really needed.
+ */
+static int fill_inbuf(void)
+{
+ if (insize != 0) {
+ error("ran out of input data");
+ }
+
+ inbuf = input_data;
+ insize = input_len;
+ inptr = 1;
+ return inbuf[0];
+}
+
+/* ===========================================================================
+ * Write the output window window[0..outcnt-1] and update crc and bytes_out.
+ * (Used for the decompressed data only.)
+ */
+static void flush_window(void)
+{
+ ulg c = crc; /* temporary variable */
+ unsigned n;
+ uch *in, *out, ch;
+ in = window;
+ out = &output_data[output_ptr];
+ for (n = 0; n < outcnt; n++) {
+ ch = *out++ = *in++;
+ c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
+ }
+ crc = c;
+ bytes_out += (ulg)outcnt;
+ output_ptr += (ulg)outcnt;
+ outcnt = 0;
+}
+
+static void error(char *x)
+{
+ puts("\nERROR\n");
+ puts(x);
+ puts("\n\n -- System halted");
+
+ while(1); /* Halt */
+}
+
+void decompress_kernel(void)
+{
+ output_data = (void *)nasys_program_mem;
+ output_ptr = 0;
+ free_mem_ptr = (unsigned long)&_end;
+ free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
+
+ makecrc();
+ puts("Uncompressing Linux... ");
+ gunzip();
+ puts("Ok, booting the kernel.\n");
+}
diff --git a/arch/nios2nommu/boot/compressed/nios2_sio.c b/arch/nios2nommu/boot/compressed/nios2_sio.c
new file mode 100644
index 0000000..8630c8f
--- /dev/null
+++ b/arch/nios2nommu/boot/compressed/nios2_sio.c
@@ -0,0 +1,57 @@
+
+static int putchar(int ch);
+
+static int puts(const char *s)
+ {
+ while(*s)
+ putchar(*s++);
+ return 0;
+ }
+
+#include <asm/nios.h>
+#include <asm/io.h>
+
+#if defined(CONFIG_SERIAL_AJUART_CONSOLE)
+
+#define IORD_ALTERA_AVALON_JTAG_UART_DATA(base) inl(base)
+#define IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, data) outl(data, base)
+#define IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) inl(base+4)
+#define IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(base, data) outl(data, base+4)
+#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK (0xFFFF0000u)
+#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_OFST (16)
+
+static void jtag_putc(int ch)
+{
+ unsigned base = na_jtag_uart;
+ while ((IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
+ IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, ch);
+}
+
+static int putchar(int ch)
+{
+ jtag_putc( ch );
+ return ch;
+}
+
+#elif defined(CONFIG_NIOS_SERIAL_CONSOLE)
+
+static void nr_txchar(int ch)
+{
+ while ((na_uart0->np_uartstatus & np_uartstatus_trdy_mask) == 0);
+ na_uart0->np_uarttxdata = ch;
+}
+
+static int putchar(int ch)
+{
+ nr_txchar( ch ); if (ch=='\n') nr_txchar( '\r' );
+ return ch;
+}
+
+#else
+
+static int putchar(int ch)
+{
+ return ch;
+}
+
+#endif
diff --git a/arch/nios2nommu/boot/compressed/vmlinux.lds.S b/arch/nios2nommu/boot/compressed/vmlinux.lds.S
new file mode 100644
index 0000000..08bb3e2
--- /dev/null
+++ b/arch/nios2nommu/boot/compressed/vmlinux.lds.S
@@ -0,0 +1,34 @@
+#include <asm-generic/vmlinux.lds.h>
+#include <asm/nios.h>
+
+OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
+
+OUTPUT_ARCH(nios)
+ENTRY(_start) /* Defined in head.S */
+
+SECTIONS
+{
+ . =nasys_program_mem + CONFIG_BOOT_LINK_OFFSET;
+
+ _text = .;
+ .text : { *(.text) } = 0
+ .rodata : { *(.rodata) *(.rodata.*) }
+ _etext = .;
+
+ . = ALIGN(32 / 8);
+ .data : { *(.data) }
+ . = ALIGN(32 / 8);
+ _got = .;
+ .got : { *(.got) _egot = .; *(.got.*) }
+ _edata = .;
+
+ . = ALIGN(32 / 8);
+ __bss_start = .;
+ .bss : { *(.bss) *(.sbss) }
+ . = ALIGN(32 / 8);
+ _ebss = .;
+ end = . ;
+ _end = . ;
+
+ got_len = (_egot - _got);
+}
diff --git a/arch/nios2nommu/defconfig b/arch/nios2nommu/defconfig
new file mode 100644
index 0000000..40629cb
--- /dev/null
+++ b/arch/nios2nommu/defconfig
@@ -0,0 +1,690 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.19-uc1
+#
+# CONFIG_MMU is not set
+# CONFIG_FPU is not set
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+# CONFIG_SYSVIPC is not set
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
+# CONFIG_AUDIT is not set
+# CONFIG_IKCONFIG is not set
+# CONFIG_RELAY is not set
+CONFIG_INITRAMFS_SOURCE="../romfs ../vendors/Altera/nios2nommu/romfs_list"
+CONFIG_INITRAMFS_ROOT_UID=500
+CONFIG_INITRAMFS_ROOT_GID=500
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_EMBEDDED=y
+# CONFIG_SYSCTL_SYSCALL is not set
+# CONFIG_KALLSYMS is not set
+# CONFIG_HOTPLUG is not set
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+# CONFIG_ELF_CORE is not set
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+# CONFIG_EPOLL is not set
+CONFIG_SLAB=y
+# CONFIG_VM_EVENT_COUNTERS is not set
+CONFIG_RT_MUTEXES=y
+CONFIG_TINY_SHMEM=y
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+CONFIG_IOSCHED_DEADLINE=y
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+
+#
+# Processor type and features
+#
+
+#
+# Platform dependant setup
+#
+CONFIG_NIOS2=y
+# CONFIG_MICROTRONIX_UKIT is not set
+# CONFIG_MICROTRONIX_STRATIX is not set
+# CONFIG_MICROTRONIX_CYCLONE is not set
+# CONFIG_MICROTRONIX_PSK is not set
+CONFIG_ALTERA_STRATIX=y
+# CONFIG_ALTERA_STRATIX_PRO is not set
+# CONFIG_ALTERA_STRATIX_II is not set
+# CONFIG_ALTERA_CYCLONE is not set
+# CONFIG_ALTERA_CYCLONE_1C12_EVAL is not set
+# CONFIG_ALTERA_DE2 is not set
+# CONFIG_NIOS2_HW_MUL_OFF is not set
+CONFIG_NIOS2_HW_MUL=y
+# CONFIG_NIOS2_HW_MULX is not set
+
+#
+# Platform drivers Options
+#
+# CONFIG_AVALON_DMA is not set
+# CONFIG_PIO_DEVICES is not set
+# CONFIG_PCI is not set
+# CONFIG_FB_ALTERA is not set
+# CONFIG_SERIO_ALTPS2 is not set
+# CONFIG_I2C_GPIO is not set
+
+#
+# Miscellaneous Options
+#
+CONFIG_EXCALIBUR=y
+# CONFIG_BREAK_ON_START is not set
+CONFIG_LARGE_ALLOCS=y
+CONFIG_RAMKERNEL=y
+CONFIG_PREEMPT=y
+# CONFIG_PREEMPT_TIMES is not set
+CONFIG_CMDLINE=""
+# CONFIG_PASS_CMDLINE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_BOOT_LINK_OFFSET=0x00500000
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+
+#
+# PCI Hotplug Support
+#
+
+#
+# Executable file formats
+#
+CONFIG_KCORE_AOUT=y
+CONFIG_KCORE_ELF=y
+CONFIG_BINFMT_FLAT=y
+CONFIG_BINFMT_ZFLAT=y
+# CONFIG_BINFMT_SHARED_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Power management options
+#
+# CONFIG_PM is not set
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_IPSEC_NAT_TRAVERSAL is not set
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_KLIPS is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_COW_COMMON is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_BLK_DEV_INITRD is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# Misc devices
+#
+# CONFIG_TIFM_CORE is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_NETLINK is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+# CONFIG_ATA is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# PHY device support
+#
+# CONFIG_PHYLIB is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_OPEN_ETH is not set
+# CONFIG_MTIP1000_ETH is not set
+# CONFIG_NE2000 is not set
+# CONFIG_NET_PCI is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT 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_SERIAL_NONSTANDARD is not set
+# CONFIG_NIOS_LCD_16207 is not set
+# CONFIG_NIOS_BUTTON is not set
+# CONFIG_LEDMAN is not set
+# CONFIG_SNAPDOG is not set
+# CONFIG_FAST_TIMER is not set
+# CONFIG_RESETSWITCH is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_NIOS_SERIAL is not set
+CONFIG_SERIAL_AJUART=y
+CONFIG_SERIAL_AJUART_CONSOLE=y
+# CONFIG_UNIX98_PTYS is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=10
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+# CONFIG_M41T11M6 is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+
+#
+# InfiniBand support
+#
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+
+#
+# Real Time Clock
+#
+# CONFIG_RTC_CLASS is not set
+
+#
+# DMA Engine support
+#
+# CONFIG_DMA_ENGINE is not set
+
+#
+# DMA Clients
+#
+
+#
+# DMA Devices
+#
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4DEV_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_INOTIFY is not set
+# CONFIG_QUOTA is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+# CONFIG_DIRECTIO is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_SYSCTL is not set
+CONFIG_SYSFS=y
+# CONFIG_TMPFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+# CONFIG_NLS is not set
+
+#
+# Debug
+#
+# CONFIG_COREDUMP_PRINTK is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_FULLDEBUG is not set
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_NO_KERNEL_MSG is not set
+CONFIG_LOG_BUF_SHIFT=14
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_PLIST=y
diff --git a/arch/nios2nommu/drivers/Kconfig b/arch/nios2nommu/drivers/Kconfig
new file mode 100644
index 0000000..2fde3a8
--- /dev/null
+++ b/arch/nios2nommu/drivers/Kconfig
@@ -0,0 +1,45 @@
+# Platfrom drivers configuration
+
+source "arch/nios2nommu/drivers/pci/Kconfig"
+
+config FB_ALTERA
+ tristate "Avalon VGA controller support"
+ default N
+ select FB
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
+ help
+ This is the frame buffer device driver for the VGA controller
+ in SOPC Builder.
+
+config SERIO_ALTPS2
+ tristate "PS2 controller"
+ select VT
+ default N
+ select SERIO
+
+config I2C_NIOS2_GPIO
+ tristate "GPIO-Based I2C Interface"
+ default N
+ select I2C
+ select I2C_ALGOBIT
+ help
+ Say Y here if you use GPIO lines for an I2C bus.
+
+config BLK_DEV_ALTCF
+ tristate "Altera CF (IDE mode) interface (Avalon bus) support"
+ select IDE
+ select BLK_DEV_IDE
+ default N
+ help
+ This driver provides support for the Altera Compact flash core (with
+ Avalon interface) support. If you have an Altera or Microtronix
+ development board you can build support into the FPGA device for this.
+
+config NIOS_SPI
+ bool "Nios SPI device support"
+ depends on NIOS || NIOS2
+ help
+ This driver supports the Nios softcore SPI device.
+
diff --git a/arch/nios2nommu/drivers/Makefile b/arch/nios2nommu/drivers/Makefile
new file mode 100644
index 0000000..f6a273e
--- /dev/null
+++ b/arch/nios2nommu/drivers/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the Linux nios2-specific device drivers.
+#
+
+obj-$(CONFIG_PCI) += pci/
+obj-$(CONFIG_FB_ALTERA) += altfb.o
+obj-$(CONFIG_SERIO_ALTPS2) += altps2.o
+obj-$(CONFIG_I2C_NIOS2_GPIO) += i2c-gpio.o
+obj-$(CONFIG_BLK_DEV_ALTCF) += altcf.o
+obj-$(CONFIG_NIOS_SPI) += spi.o
diff --git a/arch/nios2nommu/drivers/altcf.c b/arch/nios2nommu/drivers/altcf.c
new file mode 100644
index 0000000..80275c6
--- /dev/null
+++ b/arch/nios2nommu/drivers/altcf.c
@@ -0,0 +1,266 @@
+/*
+ * linux/drivers/ide/altcf.c
+ * Support for Altera CompactFlash core with Avalon interface.
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/io.h>
+#include <asm/nios.h>
+
+MODULE_AUTHOR("Microtronix Datacom Ltd.");
+MODULE_DESCRIPTION("Driver of Altera CompactFlash core with Avalon interface");
+MODULE_LICENSE("GPL");
+
+#define PDEBUG printk
+/* Altera Avalon Compact Flash core registers */
+#define REG_CFCTL 0
+#define REG_IDECTL 4
+
+/* CFCTL bits */
+#define CFCTL_DET 1 /* detect status */
+#define CFCTL_PWR 2 /* Power */
+#define CFCTL_RST 4 /* Reset */
+#define CFCTL_IDET 8 /* Detect int enable*/
+
+/* IDECTL bits */
+#define IDECTL_IIDE 1 /* IDE int enable */
+
+struct cf_dev {
+ int base;
+ int irq;
+ int ide_base;
+ int ide_irq;
+ int configured;
+ ide_hwif_t *hwif;
+ struct delayed_work wcf;
+};
+
+static struct cf_dev cf_devices[MAX_HWIFS] = {
+#if MAX_HWIFS > 0
+ {na_ide_ctl, na_ide_ctl_irq, na_ide_ide, na_ide_ide_irq, 0, NULL},
+#endif
+#if MAX_HWIFS > 1
+ {na_ctl_base1, na_ctl_irq1, na_ide_base1, na_ide_irq1, 0, NULL},
+#endif
+#if MAX_HWIFS > 2
+ {na_ctl_base2, na_ctl_irq2, na_ide_base2, na_ide_irq2, 0, NULL},
+#endif
+#if MAX_HWIFS > 3
+ {na_ctl_base3, na_ctl_irq3, na_ide_base3, na_ide_irq3, 0, NULL},
+#endif
+};
+
+static inline void cf_init_hwif_ports(hw_regs_t *hw,
+ unsigned long io_addr,
+ unsigned long ctl_addr,
+ int *irq)
+{
+ unsigned int i;
+
+ for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
+ hw->io_ports[i] = io_addr + 4*(i-IDE_DATA_OFFSET);
+
+ hw->io_ports[IDE_CONTROL_OFFSET] = ctl_addr;
+
+ if (irq)
+ *irq = 0;
+
+ hw->io_ports[IDE_IRQ_OFFSET] = 0;
+
+}
+
+static int cf_release(struct cf_dev* dev)
+{
+ if (dev) {
+ if ((dev->configured) && (dev->hwif)) {
+ /* disable IDE interrupts */
+ outl(0, dev->base + REG_IDECTL);
+ /* power off the card */
+ //outl(0, dev->base + REG_CFCTL);
+
+ ide_unregister(dev->hwif->index);
+ dev->configured = 0;
+ dev->hwif = NULL;
+ PDEBUG("CF released\n");
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static int cf_config(struct cf_dev* dev)
+{
+ hw_regs_t hw;
+ int index;
+ ide_hwif_t *hwif;
+
+ if (!dev)
+ return -1;
+
+ if (!dev->configured) {
+ int i;
+ for (i=1; i<=10; i++) {
+ cf_init_hwif_ports(&hw, dev->ide_base, 0, NULL);
+ hw.irq = dev->ide_irq;
+ hw.chipset = ide_generic;
+ outl(IDECTL_IIDE, dev->base + REG_IDECTL);
+ index = ide_register_hw(&hw, 1, &hwif);
+ if (index >=0) {
+ dev->configured = 1;
+ dev->hwif = hwif;
+ return index;
+ }
+
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ/10);
+ }
+ /* register fails */
+ PDEBUG("CF:fail to register\n");
+ /* disable IDE interrupt */
+ outl(0, dev->base + REG_IDECTL);
+ return -1;
+ }
+ return -2; /* already configured */
+}
+
+static irqreturn_t cf_intr(int irq, void *dev_id)
+{
+ unsigned int cfctl;
+ struct cf_dev* dev = (struct cf_dev *)dev_id;
+
+ if (!dev)
+ return IRQ_NONE;
+
+ cfctl=inl(dev->base + REG_CFCTL);
+ /* unpower the card */
+ outl((cfctl & ~(CFCTL_PWR)), dev->base + REG_CFCTL);
+
+ if ((cfctl & CFCTL_DET))
+ schedule_delayed_work(&dev->wcf, HZ/2);
+ else
+ schedule_work(&dev->wcf.work);
+ return IRQ_HANDLED;
+}
+
+static void cf_event(struct work_struct *work)
+{
+ struct cf_dev* dev = container_of(work, struct cf_dev, wcf.work);
+
+ if (dev) {
+ unsigned int cfctl;
+
+ cfctl=inl(dev->base + REG_CFCTL);
+ if ((cfctl & CFCTL_DET)) {
+ /* a CF card is inserted, power on the card */
+ outl(((cfctl | CFCTL_PWR) & ~(CFCTL_RST) ), dev->base + REG_CFCTL);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ);
+ cf_config(dev);
+ }
+ else {
+ /* a CF card is removed */
+ cf_release(dev);
+ }
+ }
+}
+
+int __init altcf_init(void)
+{
+ unsigned int cfctl;
+ int i;
+ ide_hwif_t *hwif;
+ hw_regs_t hw;
+ extern ide_hwif_t ide_hwifs[];
+
+ for (i=0; i<MAX_HWIFS; i++) {
+ cfctl=inl(cf_devices[i].base + REG_CFCTL);
+ PDEBUG("CF: ctl=%d\n", cfctl);
+ if (cfctl & CFCTL_DET)
+ {
+ /* power off the card */
+ outl(CFCTL_RST, cf_devices[i].base + REG_CFCTL);
+ mdelay(500);
+ cfctl=inl(cf_devices[i].base + REG_CFCTL);
+
+ /* power on the card */
+ outl(((cfctl | CFCTL_PWR) & ~(CFCTL_RST) ), cf_devices[i].base + REG_CFCTL);
+ mdelay(2000);
+ inl(cf_devices[i].base + REG_CFCTL);
+
+ /* check if card is in right mode */
+ outb(0xa0, cf_devices[i].ide_base+IDE_SELECT_OFFSET*4);
+ mdelay(50);
+ if (inb(cf_devices[i].ide_base+IDE_SELECT_OFFSET*4) == 0xa0) {
+ /* enable IDE interrupt */
+ outl(IDECTL_IIDE, cf_devices[i].base + REG_IDECTL);
+ ide_hwifs[i].chipset = ide_generic;
+ cf_devices[i].hwif = &ide_hwifs[i];
+
+ memset(&hw, 0, sizeof hw);
+ cf_init_hwif_ports(&hw, cf_devices[i].ide_base, 0, NULL);
+ hw.chipset = ide_generic;
+ hw.irq = cf_devices[i].ide_irq;
+ if (ide_register_hw(&hw, 1, &hwif)>=0) {
+ cf_devices[i].configured = 1;
+ cf_devices[i].hwif = hwif;
+ }
+ else
+ printk("CF register fails\n");
+ }
+ else printk("Unable to initialize compact flash card. Please re-insert\n");
+ }
+
+ /* register the detection interrupt */
+ if (request_irq(cf_devices[i].irq, cf_intr, IRQF_DISABLED, "cf", &cf_devices[i])) {
+ PDEBUG("CF: unable to get interrupt %d for detecting inf %d\n",
+ cf_devices[i].irq, i );
+ } else {
+ INIT_DELAYED_WORK(&cf_devices[i].wcf, cf_event);
+ /* enable the detection interrupt */
+ cfctl=inl(cf_devices[i].base + REG_CFCTL);
+ outl(cfctl | CFCTL_IDET, cf_devices[i].base + REG_CFCTL);
+ }
+ }
+
+ return 0;
+}
+
+#ifdef MODULE
+static void __exit altcf_exit(void)
+{
+ unsigned int cfctl;
+ for (i=0; i<MAX_HWIFS; i++) {
+ /* disable detection irq */
+ cfctl=inl(cf_devices[i].base + REG_CFCTL);
+ outl(cfctl & ~CFCTL_IDET, cf_devices[i].base + REG_CFCTL);
+
+ /* free the detection irq */
+ free_irq(cf_devices[i].irq, &cf_devices[i]);
+
+ /* release the device */
+ cf_release(&cf_devices[i]);
+ }
+}
+
+module_init(altcf_init);
+module_exit(altcf_exit);
+#endif
diff --git a/arch/nios2nommu/drivers/altfb.c b/arch/nios2nommu/drivers/altfb.c
new file mode 100644
index 0000000..cebd659
--- /dev/null
+++ b/arch/nios2nommu/drivers/altfb.c
@@ -0,0 +1,234 @@
+/*
+ * Altera VGA controller
+ *
+ * linux/drivers/video/vfb.c -- Virtual frame buffer device
+ *
+ * Copyright (C) 2002 James Simmons
+ *
+ * Copyright (C) 1997 Geert Uytterhoeven
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive for
+ * more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
+
+#include <asm/uaccess.h>
+#include <linux/fb.h>
+#include <linux/init.h>
+
+#define vgabase na_vga_controller_0
+#define XRES 640
+#define YRES 480
+#define BPX 16
+
+ /*
+ * RAM we reserve for the frame buffer. This defines the maximum screen
+ * size
+ *
+ * The default can be overridden if the driver is compiled as a module
+ */
+
+#define VIDEOMEMSIZE (XRES * YRES * (BPX>>3))
+
+static void *videomemory;
+static u_long videomemorysize = VIDEOMEMSIZE;
+module_param(videomemorysize, ulong, 0);
+
+static struct fb_var_screeninfo altfb_default __initdata = {
+ .xres = XRES,
+ .yres = YRES,
+ .xres_virtual = XRES,
+ .yres_virtual = YRES,
+ .bits_per_pixel = BPX,
+#if (BPX == 16)
+ .red = { 11, 5, 0 },
+ .green = { 5, 6, 0 },
+ .blue = { 0, 5, 0 },
+#else // BPX == 24
+ .red = { 16, 8, 0 },
+ .green = { 8, 8, 0 },
+ .blue = { 0, 8, 0 },
+#endif
+ .activate = FB_ACTIVATE_NOW,
+ .height = -1,
+ .width = -1,
+ // timing useless ?
+ .pixclock = 20000,
+ .left_margin = 64,
+ .right_margin = 64,
+ .upper_margin = 32,
+ .lower_margin = 32,
+ .hsync_len = 64,
+ .vsync_len = 2,
+ .vmode = FB_VMODE_NONINTERLACED,
+};
+
+static struct fb_fix_screeninfo altfb_fix __initdata = {
+ .id = "Altera FB",
+ .type = FB_TYPE_PACKED_PIXELS,
+ .visual = FB_VISUAL_TRUECOLOR,
+ .line_length = (XRES * (BPX>>3)),
+ .xpanstep = 0,
+ .ypanstep = 0,
+ .ywrapstep = 0,
+ .accel = FB_ACCEL_NONE,
+};
+
+static int altfb_mmap(struct fb_info *info,
+ struct vm_area_struct *vma);
+
+static struct fb_ops altfb_ops = {
+ .fb_fillrect = cfb_fillrect,
+ .fb_copyarea = cfb_copyarea,
+ .fb_imageblit = cfb_imageblit,
+ .fb_mmap = altfb_mmap,
+};
+
+
+ /*
+ * Most drivers don't need their own mmap function
+ */
+
+static int altfb_mmap(struct fb_info *info,
+ struct vm_area_struct *vma)
+{
+ /* this is uClinux (no MMU) specific code */
+ vma->vm_flags |= (VM_RESERVED | VM_MAYSHARE);
+ vma->vm_start = (unsigned) videomemory;
+ return 0;
+}
+
+ /*
+ * Initialisation
+ */
+
+static void altfb_platform_release(struct device *device)
+{
+ // This is called when the reference count goes to zero.
+ dev_err(device, "This driver is broken, please bug the authors so they will fix it.\n");
+}
+
+static int __init altfb_probe(struct platform_device *dev)
+{
+ struct fb_info *info;
+ int retval = -ENOMEM;
+ dma_addr_t handle;
+
+ /*
+ * For real video cards we use ioremap.
+ */
+ if (!(videomemory = dma_alloc_coherent(&dev->dev, PAGE_ALIGN(videomemorysize), &handle, GFP_KERNEL))) {
+ printk(KERN_ERR "altfb: unable to allocate screen memory\n");
+ return retval;
+ }
+ altfb_fix.smem_start = handle;
+ altfb_fix.smem_len = videomemorysize;
+
+ info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
+ if (!info)
+ goto err;
+
+ info->screen_base = (char __iomem *)videomemory;
+ info->fbops = &altfb_ops;
+ info->var = altfb_default;
+ info->fix = altfb_fix;
+ info->pseudo_palette = info->par;
+ info->par = NULL;
+ info->flags = FBINFO_FLAG_DEFAULT;
+
+ retval = fb_alloc_cmap(&info->cmap, 256, 0);
+ if (retval < 0)
+ goto err1;
+
+ retval = register_framebuffer(info);
+ if (retval < 0)
+ goto err2;
+ platform_set_drvdata(dev, info);
+
+ outl(0x0,vgabase+0); // Reset the VGA controller
+ outl(videomemory,vgabase+4); // Where our frame buffer starts
+ outl(videomemorysize,vgabase+8); // amount of memory needed
+ outl(0x1,vgabase+0); // Set the go bit
+
+ printk(KERN_INFO
+ "fb%d: Altera frame buffer device, using %ldK of video memory\n",
+ info->node, videomemorysize >> 10);
+ // printk("vga %08x, video %08x+%08x\n",vgabase,videomemory,videomemorysize);
+ return 0;
+err2:
+ fb_dealloc_cmap(&info->cmap);
+err1:
+ framebuffer_release(info);
+err:
+ dma_free_noncoherent(&dev->dev, videomemorysize, videomemory, handle);
+ return retval;
+}
+
+static int altfb_remove(struct platform_device *dev)
+{
+ struct fb_info *info = platform_get_drvdata(dev);
+
+ if (info) {
+ unregister_framebuffer(info);
+ dma_free_noncoherent(&dev->dev, videomemorysize, videomemory, altfb_fix.smem_start);
+ framebuffer_release(info);
+ }
+ return 0;
+}
+
+static struct platform_driver altfb_driver = {
+ .probe = altfb_probe,
+ .remove = altfb_remove,
+ .driver = {
+ .name = "altfb",
+ },
+};
+
+static struct platform_device altfb_device = {
+ .name = "altfb",
+ .id = 0,
+ .dev = {
+ .release = altfb_platform_release,
+ }
+};
+
+static int __init altfb_init(void)
+{
+ int ret = 0;
+
+ ret = platform_driver_register(&altfb_driver);
+
+ if (!ret) {
+ ret = platform_device_register(&altfb_device);
+ if (ret)
+ platform_driver_unregister(&altfb_driver);
+ }
+ return ret;
+}
+
+module_init(altfb_init);
+
+#ifdef MODULE
+static void __exit altfb_exit(void)
+{
+ platform_device_unregister(&altfb_device);
+ platform_driver_unregister(&altfb_driver);
+}
+
+module_exit(altfb_exit);
+
+MODULE_LICENSE("GPL");
+#endif /* MODULE */
diff --git a/arch/nios2nommu/drivers/altps2.c b/arch/nios2nommu/drivers/altps2.c
new file mode 100644
index 0000000..4a6523c
--- /dev/null
+++ b/arch/nios2nommu/drivers/altps2.c
@@ -0,0 +1,193 @@
+/*
+ * altera DE2 PS/2
+ *
+ * linux/drivers/input/serio/sa1111ps2.c
+ *
+ * Copyright (C) 2002 Russell King
+ *
+ * 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.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/serio.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <asm/io.h>
+#include <asm/system.h>
+
+
+struct ps2if {
+ struct serio *io;
+ struct platform_device *dev;
+ unsigned base;
+ unsigned irq;
+};
+
+/*
+ * Read all bytes waiting in the PS2 port. There should be
+ * at the most one, but we loop for safety. If there was a
+ * framing error, we have to manually clear the status.
+ */
+static irqreturn_t ps2_rxint(int irq, void *dev_id)
+{
+ struct ps2if *ps2if = dev_id;
+ unsigned int status;
+ int handled = IRQ_NONE;
+
+ while ((status = inl(ps2if->base)) & 0xffff0000) {
+ serio_interrupt(ps2if->io, status & 0xff, 0);
+ handled = IRQ_HANDLED;
+ }
+ return handled;
+}
+
+/*
+ * Write a byte to the PS2 port. We have to wait for the
+ * port to indicate that the transmitter is empty.
+ */
+static int ps2_write(struct serio *io, unsigned char val)
+{
+ struct ps2if *ps2if = io->port_data;
+ outl(val,ps2if->base);
+ // should check command send error
+ if (inl(ps2if->base+4) & (1<<10))
+ {
+ // printk("ps2 write error %02x\n",val);
+ }
+ return 0;
+}
+
+static int ps2_open(struct serio *io)
+{
+ struct ps2if *ps2if = io->port_data;
+ int ret;
+
+ ret = request_irq(ps2if->irq, ps2_rxint, 0,
+ "altps2", ps2if);
+ if (ret) {
+ printk(KERN_ERR "altps2: could not allocate IRQ%d: %d\n",
+ ps2if->irq, ret);
+ return ret;
+ }
+ outl(1,ps2if->base+4); // enable rx irq
+ return 0;
+}
+
+static void ps2_close(struct serio *io)
+{
+ struct ps2if *ps2if = io->port_data;
+ outl(0,ps2if->base); // disable rx irq
+ free_irq(ps2if->irq, ps2if);
+}
+
+/*
+ * Add one device to this driver.
+ */
+static int ps2_probe(struct platform_device *dev)
+{
+ struct ps2if *ps2if;
+ struct serio *serio;
+ unsigned int status;
+ int ret;
+
+ ps2if = kmalloc(sizeof(struct ps2if), GFP_KERNEL);
+ serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+ if (!ps2if || !serio) {
+ ret = -ENOMEM;
+ goto free;
+ }
+
+ memset(ps2if, 0, sizeof(struct ps2if));
+ memset(serio, 0, sizeof(struct serio));
+
+ serio->id.type = SERIO_8042;
+ serio->write = ps2_write;
+ serio->open = ps2_open;
+ serio->close = ps2_close;
+ strlcpy(serio->name, dev->dev.bus_id, sizeof(serio->name));
+ strlcpy(serio->phys, dev->dev.bus_id, sizeof(serio->phys));
+ serio->port_data = ps2if;
+ serio->dev.parent = &dev->dev;
+ ps2if->io = serio;
+ ps2if->dev = dev;
+ platform_set_drvdata(dev, ps2if);
+
+ /*
+ * Request the physical region for this PS2 port.
+ */
+ if (dev->num_resources < 2) {
+ ret = -ENODEV;
+ goto out;
+ }
+ if (!request_mem_region(dev->resource[0].start,
+ 4,
+ "altps2")) {
+ ret = -EBUSY;
+ goto free;
+ }
+ ps2if->base = dev->resource[0].start;
+ ps2if->irq = dev->resource[1].start;
+ printk("altps2 : base %08x irq %d\n",ps2if->base,ps2if->irq);
+ // clear fifo
+ while ((status = inl(ps2if->base)) & 0xffff0000) {
+ }
+
+ serio_register_port(ps2if->io);
+ return 0;
+
+ out:
+ release_mem_region(dev->resource[0].start,4);
+ free:
+ platform_set_drvdata(dev, NULL);
+ kfree(ps2if);
+ kfree(serio);
+ return ret;
+}
+
+/*
+ * Remove one device from this driver.
+ */
+static int ps2_remove(struct platform_device *dev)
+{
+ struct ps2if *ps2if = platform_get_drvdata(dev);
+
+ platform_set_drvdata(dev, NULL);
+ serio_unregister_port(ps2if->io);
+ release_mem_region(dev->resource[0].start,4);
+
+ kfree(ps2if);
+
+ return 0;
+}
+
+/*
+ * Our device driver structure
+ */
+static struct platform_driver ps2_driver = {
+ .probe = ps2_probe,
+ .remove = ps2_remove,
+ .driver = {
+ .name = "altps2",
+ },
+};
+
+static int __init ps2_init(void)
+{
+ return platform_driver_register(&ps2_driver);
+}
+
+static void __exit ps2_exit(void)
+{
+ platform_driver_unregister(&ps2_driver);
+}
+
+module_init(ps2_init);
+module_exit(ps2_exit);
diff --git a/arch/nios2nommu/drivers/i2c-gpio.c b/arch/nios2nommu/drivers/i2c-gpio.c
new file mode 100644
index 0000000..3f5e51a
--- /dev/null
+++ b/arch/nios2nommu/drivers/i2c-gpio.c
@@ -0,0 +1,166 @@
+/*
+ * drivers/i2c/busses/i2c-gpio.c for Nios2
+ *
+ * drivers/i2c/busses/i2c-ixp2000.c
+ *
+ * I2C adapter for IXP2000 systems using GPIOs for I2C bus
+ *
+ * Author: Deepak Saxena <dsaxena@plexity.net>
+ * Based on IXDP2400 code by: Naeem M. Afzal <naeem.m.afzal@intel.com>
+ * Made generic by: Jeff Daly <jeffrey.daly@intel.com>
+ *
+ * Copyright (c) 2003-2004 MontaVista Software Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ *
+ * From Jeff Daly:
+ *
+ * I2C adapter driver for Intel IXDP2xxx platforms. This should work for any
+ * IXP2000 platform if it uses the HW GPIO in the same manner. Basically,
+ * SDA and SCL GPIOs have external pullups. Setting the respective GPIO to
+ * an input will make the signal a '1' via the pullup. Setting them to
+ * outputs will pull them down.
+ *
+ * The GPIOs are open drain signals and are used as configuration strap inputs
+ * during power-up so there's generally a buffer on the board that needs to be
+ * 'enabled' to drive the GPIOs.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+#include <linux/i2c-id.h>
+
+#include <asm/io.h>
+#include <asm/gpio.h>
+
+static inline int gpio_scl_pin(void *data)
+{
+ return ((struct gpio_i2c_pins*)data)->scl_pin;
+}
+
+static inline int gpio_sda_pin(void *data)
+{
+ return ((struct gpio_i2c_pins*)data)->sda_pin;
+}
+
+
+static void gpio_bit_setscl(void *data, int val)
+{
+ int i = 5000;
+
+ if (val) {
+ outl(3,gpio_scl_pin(data));
+ while(!(inl(gpio_scl_pin(data)) & 1) && i--);
+ } else {
+ outl(2,gpio_scl_pin(data));
+ }
+}
+
+static void gpio_bit_setsda(void *data, int val)
+{
+ if (val) {
+ outl(1,gpio_sda_pin(data));
+ } else {
+ outl(0,gpio_sda_pin(data));
+ }
+}
+
+static int gpio_bit_getscl(void *data)
+{
+ return inl(gpio_scl_pin(data)) & 1;
+}
+
+static int gpio_bit_getsda(void *data)
+{
+ return inl(gpio_sda_pin(data)) & 1;
+}
+
+struct gpio_i2c_data {
+ struct gpio_i2c_pins *gpio_pins;
+ struct i2c_adapter adapter;
+ struct i2c_algo_bit_data algo_data;
+};
+
+static int gpio_i2c_remove(struct platform_device *plat_dev)
+{
+ struct gpio_i2c_data *drv_data = platform_get_drvdata(plat_dev);
+
+ platform_set_drvdata(plat_dev, NULL);
+
+ i2c_del_adapter(&drv_data->adapter);
+
+ kfree(drv_data);
+
+ return 0;
+}
+
+static int gpio_i2c_probe(struct platform_device *plat_dev)
+{
+ int err;
+ struct gpio_i2c_pins *gpio = plat_dev->dev.platform_data;
+ struct gpio_i2c_data *drv_data =
+ kzalloc(sizeof(struct gpio_i2c_data), GFP_KERNEL);
+
+ if (!drv_data)
+ return -ENOMEM;
+ drv_data->gpio_pins = gpio;
+
+ drv_data->algo_data.data = gpio;
+ drv_data->algo_data.setsda = gpio_bit_setsda;
+ drv_data->algo_data.setscl = gpio_bit_setscl;
+ drv_data->algo_data.getsda = gpio_bit_getsda;
+ drv_data->algo_data.getscl = gpio_bit_getscl;
+ drv_data->algo_data.udelay = 6;
+ drv_data->algo_data.timeout = 100;
+
+ drv_data->adapter.id = I2C_HW_B_IXP2000, // borrowed,
+ strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
+ I2C_NAME_SIZE);
+ drv_data->adapter.algo_data = &drv_data->algo_data,
+
+ drv_data->adapter.dev.parent = &plat_dev->dev;
+ drv_data->adapter.class = I2C_CLASS_ALL;
+
+ outl(1,gpio->sda_pin);
+ outl(1,gpio->scl_pin);
+
+ if ((err = i2c_bit_add_bus(&drv_data->adapter)) != 0) {
+ dev_err(&plat_dev->dev, "Could not install, error %d\n", err);
+ kfree(drv_data);
+ return err;
+ }
+
+ platform_set_drvdata(plat_dev, drv_data);
+ printk("i2c-gpio driver at %08x\n",gpio->sda_pin);
+
+ return 0;
+}
+
+static struct platform_driver gpio_i2c_driver = {
+ .probe = gpio_i2c_probe,
+ .remove = gpio_i2c_remove,
+ .driver = {
+ .name = "GPIO-I2C",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init gpio_i2c_init(void)
+{
+ return platform_driver_register(&gpio_i2c_driver);
+}
+
+static void __exit gpio_i2c_exit(void)
+{
+ platform_driver_unregister(&gpio_i2c_driver);
+}
+
+module_init(gpio_i2c_init);
+module_exit(gpio_i2c_exit);
+
diff --git a/arch/nios2nommu/drivers/pci/Kconfig b/arch/nios2nommu/drivers/pci/Kconfig
new file mode 100644
index 0000000..6c3b175
--- /dev/null
+++ b/arch/nios2nommu/drivers/pci/Kconfig
@@ -0,0 +1,4 @@
+config PCI_ALTPCI
+ bool "Altera PCI host bridge"
+ select PCI
+ default n
diff --git a/arch/nios2nommu/drivers/pci/Makefile b/arch/nios2nommu/drivers/pci/Makefile
new file mode 100644
index 0000000..b027e1e
--- /dev/null
+++ b/arch/nios2nommu/drivers/pci/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the PCI specific kernel interface routines under Linux.
+#
+
+obj-y += pci.o
+obj-$(CONFIG_PCI_ALTPCI) += altpci.o setup-irq.o pci-auto.o
diff --git a/arch/nios2nommu/drivers/pci/altpci.c b/arch/nios2nommu/drivers/pci/altpci.c
new file mode 100644
index 0000000..85959ea
--- /dev/null
+++ b/arch/nios2nommu/drivers/pci/altpci.c
@@ -0,0 +1,204 @@
+/* arch/sh/kernel/pci.c
+ * $Id: altpci.c,v 1.1 2006/07/05 06:23:17 gerg Exp $
+ *
+ * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
+ *
+ *
+ * These functions are collected here to reduce duplication of common
+ * code amongst the many platform-specific PCI support code files.
+ *
+ * These routines require the following board-specific routines:
+ * void pcibios_fixup_irqs();
+ *
+ * See include/asm-sh/pci.h for more information.
+ */
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+/*
+ * Direct access to PCI hardware...
+ */
+#define pcicfg_space (na_pci_compiler_0_PCI_Bus_Access) // avalon space
+#define pciio (pcicfg_space+0x100000) // pci io device base in avalon space
+#define pcimm (pcicfg_space+0x200000) // pci mem device base in avalon space
+ // idsel of ad11=dev0,ad12=dev1 , using type 0 config request
+#define pcicfg(dev,fun,reg) (pcicfg_space | ((dev)<<11) | ((fun)<<8) | (reg)) // cfg space
+
+// FIX ME for your board, dram device for external pci masters access
+static int __init alt_pci_init(void)
+{
+ unsigned dev,fun;
+ // setup dram bar
+ dev=0; fun=0;
+ outl(nasys_program_mem,pcicfg(dev,fun,0x10)); // mem space
+ outw(0x0006,pcicfg(dev,fun,0x04)); // enable master, mem space
+ return 0;
+}
+
+subsys_initcall(alt_pci_init);
+
+#define PCICFG(bus, devfn, where) (pcicfg_space | (bus->number << 16) | (devfn << 8) | (where & ~3))
+#define ALT_PCI_IO_BASE (pciio)
+#define ALT_PCI_IO_SIZE 0x100000
+#define ALT_PCI_MEMORY_BASE (pcimm)
+#define ALT_PCI_MEM_SIZE 0x100000
+
+/*
+ * Functions for accessing PCI configuration space with type 1 accesses
+ */
+
+// FIX ME for your board, number of pci bus, and number of devices
+static inline int pci_range_ck(struct pci_bus *bus, unsigned int devfn)
+{
+ if (bus->number > 0 || PCI_SLOT(devfn) == 0 || PCI_SLOT(devfn) > 2)
+ return -1;
+
+ return 0;
+}
+
+static int alt_pci_read(struct pci_bus *bus, unsigned int devfn,
+ int where, int size, u32 *val)
+{
+ u32 data;
+
+ if (pci_range_ck(bus, devfn))
+ return PCIBIOS_DEVICE_NOT_FOUND;
+
+ // local_irq_save(flags);
+ data = inl(PCICFG(bus, devfn, where));
+ // local_irq_restore(flags);
+
+ switch (size) {
+ case 1:
+ *val = (data >> ((where & 3) << 3)) & 0xff;
+ break;
+ case 2:
+ *val = (data >> ((where & 2) << 3)) & 0xffff;
+ break;
+ case 4:
+ *val = data;
+ break;
+ default:
+ return PCIBIOS_FUNC_NOT_SUPPORTED;
+ }
+
+ return PCIBIOS_SUCCESSFUL;
+}
+
+/*
+ * we'll do a read,
+ * mask,write operation.
+ * We'll allow an odd byte offset, though it should be illegal.
+ */
+static int alt_pci_write(struct pci_bus *bus, unsigned int devfn,
+ int where, int size, u32 val)
+{
+ int shift;
+ u32 data;
+
+ if (pci_range_ck(bus, devfn))
+ return PCIBIOS_DEVICE_NOT_FOUND;
+
+ // local_irq_save(flags);
+ data = inl(PCICFG(bus, devfn, where));
+ // local_irq_restore(flags);
+
+ switch (size) {
+ case 1:
+ shift = (where & 3) << 3;
+ data &= ~(0xff << shift);
+ data |= ((val & 0xff) << shift);
+ break;
+ case 2:
+ shift = (where & 2) << 3;
+ data &= ~(0xffff << shift);
+ data |= ((val & 0xffff) << shift);
+ break;
+ case 4:
+ data = val;
+ break;
+ default:
+ return PCIBIOS_FUNC_NOT_SUPPORTED;
+ }
+
+ outl(data, PCICFG(bus, devfn, where));
+
+ return PCIBIOS_SUCCESSFUL;
+}
+
+struct pci_ops alt_pci_ops = {
+ .read = alt_pci_read,
+ .write = alt_pci_write,
+};
+
+static struct resource alt_io_resource = {
+ .name = "ALTPCI IO",
+ .start = ALT_PCI_IO_BASE,
+ .end = ALT_PCI_IO_BASE + ALT_PCI_IO_SIZE - 1,
+ .flags = IORESOURCE_IO
+};
+
+static struct resource alt_mem_resource = {
+ .name = "ALTPCI mem",
+ .start = ALT_PCI_MEMORY_BASE,
+ .end = ALT_PCI_MEMORY_BASE + ALT_PCI_MEM_SIZE - 1,
+ .flags = IORESOURCE_MEM
+};
+
+extern struct pci_ops alt_pci_ops;
+
+struct pci_channel board_pci_channels[] = {
+ { &alt_pci_ops, &alt_io_resource, &alt_mem_resource, 0, 0xff },
+ { NULL, NULL, NULL, 0, 0 },
+};
+
+char *pcibios_setup(char *option)
+{
+ /* Nothing for us to handle. */
+ return(option);
+}
+
+void pcibios_fixup_bus(struct pci_bus *b)
+{
+}
+
+/*
+ * IRQ functions
+ */
+static u8 __init altpci_no_swizzle(struct pci_dev *dev, u8 *pin)
+{
+ /* no swizzling */
+ return PCI_SLOT(dev->devfn);
+}
+
+// FIX ME for your board, nios2 irqn mapping
+int __init pcibios_map_platform_irq(u8 slot, u8 pin)
+{
+ int irq = na_irqn_0_irq + ((slot-1)*4) + (pin-1);
+ // printk("map slot %d pin %d irq %d\n",slot,pin,irq);
+ return irq;
+}
+
+static int altpci_pci_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+ int irq = -1;
+
+ /* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
+ irq = pcibios_map_platform_irq(slot,pin);
+ if( irq < 0 ) {
+ // printk("PCI: Error mapping IRQ on device %s\n", pci_name(dev));
+ return irq;
+ }
+
+ // printk("Setting IRQ for slot %s to %d\n", pci_name(dev), irq);
+
+ return irq;
+}
+
+void __init pcibios_fixup_irqs(void)
+{
+ pci_fixup_irqs(altpci_no_swizzle, altpci_pci_lookup_irq);
+}
+
diff --git a/arch/nios2nommu/drivers/pci/pci-auto.c b/arch/nios2nommu/drivers/pci/pci-auto.c
new file mode 100644
index 0000000..e1cdfdc
--- /dev/null
+++ b/arch/nios2nommu/drivers/pci/pci-auto.c
@@ -0,0 +1,559 @@
+/*
+ * PCI autoconfiguration library
+ *
+ * Author: Matt Porter <mporter@mvista.com>
+ *
+ * Copyright 2000, 2001 MontaVista Software Inc.
+ * Copyright 2001 Bradley D. LaRonde <brad@ltc.com>
+ * Copyright 2003 Paul Mundt <lethal@linux-sh.org>
+ *
+ * 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.
+ */
+
+/*
+ * Modified for MIPS by Jun Sun, jsun@mvista.com
+ *
+ * . Simplify the interface between pci_auto and the rest: a single function.
+ * . Assign resources from low address to upper address.
+ * . change most int to u32.
+ *
+ * Further modified to include it as mips generic code, ppopov@mvista.com.
+ *
+ * 2001-10-26 Bradley D. LaRonde <brad@ltc.com>
+ * - Add a top_bus argument to the "early config" functions so that
+ * they can set a fake parent bus pointer to convince the underlying
+ * pci ops to use type 1 configuration for sub busses.
+ * - Set bridge base and limit registers correctly.
+ * - Align io and memory base properly before and after bridge setup.
+ * - Don't fall through to pci_setup_bars for bridge.
+ * - Reformat the debug output to look more like lspci's output.
+ *
+ * Cloned for SuperH by M. R. Brown, mrbrown@0xd6.org
+ *
+ * 2003-08-05 Paul Mundt <lethal@linux-sh.org>
+ * - Don't update the BAR values on systems that already have valid addresses
+ * and don't want these updated for whatever reason, by way of a new config
+ * option check. However, we still read in the old BAR values so that they
+ * can still be reported through the debug output.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#undef DEBUG
+#define DEBUG // you can remove debug message here
+
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+/*
+ * These functions are used early on before PCI scanning is done
+ * and all of the pci_dev and pci_bus structures have been created.
+ */
+static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
+ int top_bus, int busnr, int devfn)
+{
+ static struct pci_dev dev;
+ static struct pci_bus bus;
+
+ dev.bus = &bus;
+ dev.sysdata = hose;
+ dev.devfn = devfn;
+ bus.number = busnr;
+ bus.ops = hose->pci_ops;
+
+ if(busnr != top_bus)
+ /* Fake a parent bus structure. */
+ bus.parent = &bus;
+ else
+ bus.parent = NULL;
+
+ return &dev;
+}
+
+#define EARLY_PCI_OP(rw, size, type) \
+int early_##rw##_config_##size(struct pci_channel *hose, \
+ int top_bus, int bus, int devfn, int offset, type value) \
+{ \
+ return pci_##rw##_config_##size( \
+ fake_pci_dev(hose, top_bus, bus, devfn), \
+ offset, value); \
+}
+
+EARLY_PCI_OP(read, byte, u8 *)
+EARLY_PCI_OP(read, word, u16 *)
+EARLY_PCI_OP(read, dword, u32 *)
+EARLY_PCI_OP(write, byte, u8)
+EARLY_PCI_OP(write, word, u16)
+EARLY_PCI_OP(write, dword, u32)
+
+static struct resource *io_resource_inuse;
+static struct resource *mem_resource_inuse;
+
+static u32 pciauto_lower_iospc;
+static u32 pciauto_upper_iospc;
+
+static u32 pciauto_lower_memspc;
+static u32 pciauto_upper_memspc;
+
+static void __init
+pciauto_setup_bars(struct pci_channel *hose,
+ int top_bus,
+ int current_bus,
+ int pci_devfn,
+ int bar_limit)
+{
+ u32 bar_response, bar_size, bar_value;
+ u32 bar, addr_mask, bar_nr = 0;
+ u32 * upper_limit;
+ u32 * lower_limit;
+ int found_mem64 = 0;
+
+ for (bar = PCI_BASE_ADDRESS_0; bar <= bar_limit; bar+=4) {
+#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
+ u32 bar_addr;
+
+ /* Read the old BAR value */
+ early_read_config_dword(hose, top_bus,
+ current_bus,
+ pci_devfn,
+ bar,
+ &bar_addr);
+#endif
+
+ /* Tickle the BAR and get the response */
+ early_write_config_dword(hose, top_bus,
+ current_bus,
+ pci_devfn,
+ bar,
+ 0xffffffff);
+
+ early_read_config_dword(hose, top_bus,
+ current_bus,
+ pci_devfn,
+ bar,
+ &bar_response);
+
+#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
+ /*
+ * Write the old BAR value back out, only update the BAR
+ * if we implicitly want resources to be updated, which
+ * is done by the generic code further down. -- PFM.
+ */
+ early_write_config_dword(hose, top_bus,
+ current_bus,
+ pci_devfn,
+ bar,
+ bar_addr);
+#endif
+
+ /* If BAR is not implemented go to the next BAR */
+ if (!bar_response)
+ continue;
+
+ /*
+ * Workaround for a BAR that doesn't use its upper word,
+ * like the ALi 1535D+ PCI DC-97 Controller Modem (M5457).
+ * bdl <brad@ltc.com>
+ */
+ if (!(bar_response & 0xffff0000))
+ bar_response |= 0xffff0000;
+
+retry:
+ /* Check the BAR type and set our address mask */
+ if (bar_response & PCI_BASE_ADDRESS_SPACE) {
+ addr_mask = PCI_BASE_ADDRESS_IO_MASK;
+ upper_limit = &pciauto_upper_iospc;
+ lower_limit = &pciauto_lower_iospc;
+ DBG(" I/O");
+ } else {
+ if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
+ PCI_BASE_ADDRESS_MEM_TYPE_64)
+ found_mem64 = 1;
+
+ addr_mask = PCI_BASE_ADDRESS_MEM_MASK;
+ upper_limit = &pciauto_upper_memspc;
+ lower_limit = &pciauto_lower_memspc;
+ DBG(" Mem");
+ }
+
+
+ /* Calculate requested size */
+ bar_size = ~(bar_response & addr_mask) + 1;
+
+ /* Allocate a base address */
+ bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size;
+
+ if ((bar_value + bar_size) > *upper_limit) {
+ if (bar_response & PCI_BASE_ADDRESS_SPACE) {
+ if (io_resource_inuse->child) {
+ io_resource_inuse =
+ io_resource_inuse->child;
+ pciauto_lower_iospc =
+ io_resource_inuse->start;
+ pciauto_upper_iospc =
+ io_resource_inuse->end + 1;
+ goto retry;
+ }
+
+ } else {
+ if (mem_resource_inuse->child) {
+ mem_resource_inuse =
+ mem_resource_inuse->child;
+ pciauto_lower_memspc =
+ mem_resource_inuse->start;
+ pciauto_upper_memspc =
+ mem_resource_inuse->end + 1;
+ goto retry;
+ }
+ }
+ DBG(" unavailable -- skipping, value %x size %x\n",
+ bar_value, bar_size);
+ continue;
+ }
+
+#if 1
+ /* Write it out and update our limit */
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ bar, bar_value);
+#endif
+
+ *lower_limit = bar_value + bar_size;
+
+ /*
+ * If we are a 64-bit decoder then increment to the
+ * upper 32 bits of the bar and force it to locate
+ * in the lower 4GB of memory.
+ */
+ if (found_mem64) {
+ bar += 4;
+ early_write_config_dword(hose, top_bus,
+ current_bus,
+ pci_devfn,
+ bar,
+ 0x00000000);
+ }
+
+ DBG(" at 0x%.8x [size=0x%x]\n", bar_value, bar_size);
+
+ bar_nr++;
+ }
+
+}
+
+static void __init
+pciauto_prescan_setup_bridge(struct pci_channel *hose,
+ int top_bus,
+ int current_bus,
+ int pci_devfn,
+ int sub_bus)
+{
+ /* Configure bus number registers */
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_PRIMARY_BUS, current_bus);
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_SECONDARY_BUS, sub_bus + 1);
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_SUBORDINATE_BUS, 0xff);
+
+ /* Align memory and I/O to 1MB and 4KB boundaries. */
+ pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
+ & ~(0x100000 - 1);
+ pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
+ & ~(0x1000 - 1);
+
+ /* Set base (lower limit) of address range behind bridge. */
+ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_MEMORY_BASE, pciauto_lower_memspc >> 16);
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_IO_BASE, (pciauto_lower_iospc & 0x0000f000) >> 8);
+ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_IO_BASE_UPPER16, pciauto_lower_iospc >> 16);
+
+ /* We don't support prefetchable memory for now, so disable */
+ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_PREF_MEMORY_BASE, 0);
+ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_PREF_MEMORY_LIMIT, 0);
+}
+
+static void __init
+pciauto_postscan_setup_bridge(struct pci_channel *hose,
+ int top_bus,
+ int current_bus,
+ int pci_devfn,
+ int sub_bus)
+{
+ u32 temp;
+
+ /*
+ * [jsun] we always bump up baselines a little, so that if there
+ * nothing behind P2P bridge, we don't wind up overlapping IO/MEM
+ * spaces.
+ */
+ pciauto_lower_memspc += 1;
+ pciauto_lower_iospc += 1;
+
+ /* Configure bus number registers */
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_SUBORDINATE_BUS, sub_bus);
+
+ /* Set upper limit of address range behind bridge. */
+ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_MEMORY_LIMIT, pciauto_lower_memspc >> 16);
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_IO_LIMIT, (pciauto_lower_iospc & 0x0000f000) >> 8);
+ early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_IO_LIMIT_UPPER16, pciauto_lower_iospc >> 16);
+
+ /* Align memory and I/O to 1MB and 4KB boundaries. */
+ pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
+ & ~(0x100000 - 1);
+ pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
+ & ~(0x1000 - 1);
+
+ /* Enable memory and I/O accesses, enable bus master */
+ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_COMMAND, &temp);
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY
+ | PCI_COMMAND_MASTER);
+}
+
+static void __init
+pciauto_prescan_setup_cardbus_bridge(struct pci_channel *hose,
+ int top_bus,
+ int current_bus,
+ int pci_devfn,
+ int sub_bus)
+{
+ /* Configure bus number registers */
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_PRIMARY_BUS, current_bus);
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_SECONDARY_BUS, sub_bus + 1);
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_SUBORDINATE_BUS, 0xff);
+
+ /* Align memory and I/O to 4KB and 4 byte boundaries. */
+ pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
+ & ~(0x1000 - 1);
+ pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
+ & ~(0x4 - 1);
+
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_CB_MEMORY_BASE_0, pciauto_lower_memspc);
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_CB_IO_BASE_0, pciauto_lower_iospc);
+}
+
+static void __init
+pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
+ int top_bus,
+ int current_bus,
+ int pci_devfn,
+ int sub_bus)
+{
+ u32 temp;
+
+#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
+ /*
+ * [jsun] we always bump up baselines a little, so that if there
+ * nothing behind P2P bridge, we don't wind up overlapping IO/MEM
+ * spaces.
+ */
+ pciauto_lower_memspc += 1;
+ pciauto_lower_iospc += 1;
+#endif
+
+ /*
+ * Configure subordinate bus number. The PCI subsystem
+ * bus scan will renumber buses (reserving three additional
+ * for this PCI<->CardBus bridge for the case where a CardBus
+ * adapter contains a P2P or CB2CB bridge.
+ */
+
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_SUBORDINATE_BUS, sub_bus);
+
+ /*
+ * Reserve an additional 4MB for mem space and 16KB for
+ * I/O space. This should cover any additional space
+ * requirement of unusual CardBus devices with
+ * additional bridges that can consume more address space.
+ *
+ * Although pcmcia-cs currently will reprogram bridge
+ * windows, the goal is to add an option to leave them
+ * alone and use the bridge window ranges as the regions
+ * that are searched for free resources upon hot-insertion
+ * of a device. This will allow a PCI<->CardBus bridge
+ * configured by this routine to happily live behind a
+ * P2P bridge in a system.
+ */
+#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
+ pciauto_lower_memspc += 0x00400000;
+ pciauto_lower_iospc += 0x00004000;
+#endif
+
+ /* Align memory and I/O to 4KB and 4 byte boundaries. */
+ pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
+ & ~(0x1000 - 1);
+ pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
+ & ~(0x4 - 1);
+ /* Set up memory and I/O filter limits, assume 32-bit I/O space */
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_CB_MEMORY_LIMIT_0, pciauto_lower_memspc - 1);
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_CB_IO_LIMIT_0, pciauto_lower_iospc - 1);
+
+ /* Enable memory and I/O accesses, enable bus master */
+ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_COMMAND, &temp);
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
+ PCI_COMMAND_MASTER);
+}
+
+#define PCIAUTO_IDE_MODE_MASK 0x05
+
+static int __init
+pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
+{
+ int sub_bus;
+ u32 pci_devfn, pci_class, cmdstat, found_multi=0;
+ unsigned short vid, did;
+ unsigned char header_type;
+ int devfn_start = 0;
+ int devfn_stop = 0xff;
+
+ sub_bus = current_bus;
+
+ if (hose->first_devfn)
+ devfn_start = hose->first_devfn;
+ if (hose->last_devfn)
+ devfn_stop = hose->last_devfn;
+
+ for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
+
+ if (PCI_FUNC(pci_devfn) && !found_multi)
+ continue;
+
+ early_read_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_VENDOR_ID, &vid);
+
+ if (vid == 0xffff) continue;
+
+ early_read_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_HEADER_TYPE, &header_type);
+
+ if (!PCI_FUNC(pci_devfn))
+ found_multi = header_type & 0x80;
+
+ early_read_config_word(hose, top_bus, current_bus, pci_devfn,
+ PCI_DEVICE_ID, &did);
+
+ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_CLASS_REVISION, &pci_class);
+
+ if ((pci_class & 0xff000000)==0) continue; // devices before pci 2.0
+
+ DBG("%.2x:%.2x.%x Class %.4x: %.4x:%.4x",
+ current_bus, PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn),
+ pci_class >> 16, vid, did);
+ if (pci_class & 0xff)
+ DBG(" (rev %.2x)", pci_class & 0xff);
+ DBG("\n");
+
+ if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) {
+ DBG(" Bridge: primary=%.2x, secondary=%.2x\n",
+ current_bus, sub_bus + 1);
+#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
+ pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_1);
+#endif
+ pciauto_prescan_setup_bridge(hose, top_bus, current_bus,
+ pci_devfn, sub_bus);
+ DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
+ sub_bus + 1,
+ pciauto_lower_iospc, pciauto_lower_memspc);
+ sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
+ DBG("Back to bus %.2x\n", current_bus);
+ pciauto_postscan_setup_bridge(hose, top_bus, current_bus,
+ pci_devfn, sub_bus);
+ continue;
+ } else if ((pci_class >> 16) == PCI_CLASS_BRIDGE_CARDBUS) {
+ DBG(" CARDBUS Bridge: primary=%.2x, secondary=%.2x\n",
+ current_bus, sub_bus + 1);
+ DBG("PCI Autoconfig: Found CardBus bridge, device %d function %d\n", PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn));
+ /* Place CardBus Socket/ExCA registers */
+ pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_0);
+
+ pciauto_prescan_setup_cardbus_bridge(hose, top_bus,
+ current_bus, pci_devfn, sub_bus);
+
+ DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
+ sub_bus + 1,
+ pciauto_lower_iospc, pciauto_lower_memspc);
+ sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
+ DBG("Back to bus %.2x, sub_bus is %x\n", current_bus, sub_bus);
+ pciauto_postscan_setup_cardbus_bridge(hose, top_bus,
+ current_bus, pci_devfn, sub_bus);
+ continue;
+ } else if ((pci_class >> 16) == PCI_CLASS_STORAGE_IDE) {
+
+ unsigned char prg_iface;
+
+ early_read_config_byte(hose, top_bus, current_bus,
+ pci_devfn, PCI_CLASS_PROG, &prg_iface);
+ if (!(prg_iface & PCIAUTO_IDE_MODE_MASK)) {
+ DBG("Skipping legacy mode IDE controller\n");
+ continue;
+ }
+ }
+
+ /*
+ * Found a peripheral, enable some standard
+ * settings
+ */
+ early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_COMMAND, &cmdstat);
+ early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+ PCI_COMMAND, cmdstat | PCI_COMMAND_IO |
+ PCI_COMMAND_MEMORY |
+ PCI_COMMAND_MASTER);
+#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
+ early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+ PCI_LATENCY_TIMER, 0x80);
+#endif
+
+ /* Allocate PCI I/O and/or memory space */
+ pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_5);
+ }
+ return sub_bus;
+}
+
+int __init
+pciauto_assign_resources(int busno, struct pci_channel *hose)
+{
+ /* setup resource limits */
+ io_resource_inuse = hose->io_resource;
+ mem_resource_inuse = hose->mem_resource;
+
+ pciauto_lower_iospc = io_resource_inuse->start;
+ pciauto_upper_iospc = io_resource_inuse->end + 1;
+ pciauto_lower_memspc = mem_resource_inuse->start;
+ pciauto_upper_memspc = mem_resource_inuse->end + 1;
+ DBG("Autoconfig PCI channel 0x%p\n", hose);
+ DBG("Scanning bus %.2x, I/O 0x%.8x:0x%.8x, Mem 0x%.8x:0x%.8x\n",
+ busno, pciauto_lower_iospc, pciauto_upper_iospc,
+ pciauto_lower_memspc, pciauto_upper_memspc);
+
+ return pciauto_bus_scan(hose, busno, busno);
+}
diff --git a/arch/nios2nommu/drivers/pci/pci.c b/arch/nios2nommu/drivers/pci/pci.c
new file mode 100644
index 0000000..83436df
--- /dev/null
+++ b/arch/nios2nommu/drivers/pci/pci.c
@@ -0,0 +1,151 @@
+/* arch/sh/kernel/pci.c
+ * $Id: pci.c,v 1.2 2007/01/25 01:26:48 gerg Exp $
+ *
+ * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
+ *
+ *
+ * These functions are collected here to reduce duplication of common
+ * code amongst the many platform-specific PCI support code files.
+ *
+ * These routines require the following board-specific routines:
+ * void pcibios_fixup_irqs();
+ *
+ * See include/asm-sh/pci.h for more information.
+ */
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+static int __init pcibios_init(void)
+{
+ struct pci_channel *p;
+ struct pci_bus *bus;
+ int busno;
+
+#if 1
+ /* assign resources */
+ busno = 0;
+ for (p = board_pci_channels; p->pci_ops != NULL; p++) {
+ busno = pciauto_assign_resources(busno, p) + 1;
+ }
+#endif
+
+ /* scan the buses */
+ busno = 0;
+ for (p= board_pci_channels; p->pci_ops != NULL; p++) {
+ bus = pci_scan_bus(busno, p->pci_ops, p);
+ busno = bus->subordinate+1;
+ }
+
+ /* board-specific fixups */
+ pcibios_fixup_irqs();
+
+ return 0;
+}
+
+subsys_initcall(pcibios_init);
+
+void
+pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+ struct resource *res, int resource)
+{
+ u32 new, check;
+ int reg;
+
+ new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
+ if (resource < 6) {
+ reg = PCI_BASE_ADDRESS_0 + 4*resource;
+ } else if (resource == PCI_ROM_RESOURCE) {
+ res->flags |= IORESOURCE_ROM_ENABLE;
+ new |= PCI_ROM_ADDRESS_ENABLE;
+ reg = dev->rom_base_reg;
+ } else {
+ /* Somebody might have asked allocation of a non-standard resource */
+ return;
+ }
+
+ pci_write_config_dword(dev, reg, new);
+ pci_read_config_dword(dev, reg, &check);
+ if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
+ printk(KERN_ERR "PCI: Error while updating region "
+ "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
+ new, check);
+ }
+}
+
+/*
+ * We need to avoid collisions with `mirrored' VGA ports
+ * and other strange ISA hardware, so we always want the
+ * addresses to be allocated in the 0x000-0x0ff region
+ * modulo 0x400.
+ */
+void pcibios_align_resource(void *data, struct resource *res,
+ resource_size_t size, resource_size_t align)
+{
+ if (res->flags & IORESOURCE_IO) {
+ unsigned long start = res->start;
+
+ if (start & 0x300) {
+ start = (start + 0x3ff) & ~0x3ff;
+ res->start = start;
+ }
+ }
+}
+
+int pcibios_enable_device(struct pci_dev *dev, int mask)
+{
+ u16 cmd, old_cmd;
+ int idx;
+ struct resource *r;
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ old_cmd = cmd;
+ for(idx=0; idx<6; idx++) {
+ if (!(mask & (1 << idx)))
+ continue;
+ r = &dev->resource[idx];
+ if (!r->start && r->end) {
+ printk(KERN_ERR "PCI: Device %s not available because "
+ "of resource collisions\n", pci_name(dev));
+ return -EINVAL;
+ }
+ if (r->flags & IORESOURCE_IO)
+ cmd |= PCI_COMMAND_IO;
+ if (r->flags & IORESOURCE_MEM)
+ cmd |= PCI_COMMAND_MEMORY;
+ }
+ if (dev->resource[PCI_ROM_RESOURCE].start)
+ cmd |= PCI_COMMAND_MEMORY;
+ if (cmd != old_cmd) {
+ printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n",
+ pci_name(dev), old_cmd, cmd);
+ pci_write_config_word(dev, PCI_COMMAND, cmd);
+ }
+ return 0;
+}
+
+/*
+ * If we set up a device for bus mastering, we need to check and set
+ * the latency timer as it may not be properly set.
+ */
+unsigned int pcibios_max_latency = 255;
+
+void pcibios_set_master(struct pci_dev *dev)
+{
+ u8 lat;
+ pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
+ if (lat < 16)
+ lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
+ else if (lat > pcibios_max_latency)
+ lat = pcibios_max_latency;
+ else
+ return;
+ printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat);
+ pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
+}
+
+void __init pcibios_update_irq(struct pci_dev *dev, int irq)
+{
+ pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
+}
diff --git a/arch/nios2nommu/drivers/pci/setup-irq.c b/arch/nios2nommu/drivers/pci/setup-irq.c
new file mode 100644
index 0000000..0fa8f98
--- /dev/null
+++ b/arch/nios2nommu/drivers/pci/setup-irq.c
@@ -0,0 +1 @@
+#include "../../../../drivers/pci/setup-irq.c"
diff --git a/arch/nios2nommu/drivers/spi.c b/arch/nios2nommu/drivers/spi.c
new file mode 100644
index 0000000..72a2519
--- /dev/null
+++ b/arch/nios2nommu/drivers/spi.c
@@ -0,0 +1,315 @@
+#ifdef MODULE
+#include <linux/module.h>
+#include <linux/version.h>
+#else
+#define MOD_INC_USE_COUNT
+#define MOD_DEC_USE_COUNT
+#endif
+
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/major.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/fcntl.h>
+#include <linux/unistd.h>
+#include <linux/init.h>
+
+
+#include <asm/io.h>
+#include <asm/segment.h>
+#include <asm/system.h>
+#include <asm/spi.h>
+
+#if !defined(SEEK_SET)
+#define SEEK_SET 0
+#endif
+
+
+static unsigned int spi_major = 60; /* a local major, can be overwritten */
+static int openflag = 0;
+static np_spi * const spi_ptr = na_spi;
+
+ /*******************************/
+ /* SPI data transfer routines. */
+ /*******************************/
+
+#define SPI_XMIT_READY np_spistatus_trdy_mask
+#define SPI_RECV_READY np_spistatus_rrdy_mask
+
+#define SPI_BUSYPOLL_TIMEOUT 1000
+
+// returns -1 if there is no data present, otherwise returns
+// the value
+inline int SPI_Recv_Byte(char *pdata )
+{
+ if (spi_ptr->np_spistatus & SPI_RECV_READY){
+ *pdata = spi_ptr->np_spirxdata & 0xff;
+ return 0;
+ }
+ return -1;
+}
+
+
+// Sends the 16 bit address+data
+inline int SPI_Send_Byte( unsigned char address, char data )
+{
+ u16 value = ((address & 0xFF) << 8) | (data & 0xFF);
+
+ if ( spi_ptr->np_spistatus & SPI_XMIT_READY ) {
+ spi_ptr->np_spitxdata = value;
+ return 0;
+ }
+
+ return -1;
+}
+
+
+
+ /*************************/
+ /* SPI Driver functions. */
+ /*************************/
+
+int spi_reset( void )
+{
+ // Nothing to do: The Nios does _not_
+ // support burst xfers. Chip Enables
+ // (Selects) are inactive after each xfer.
+ return 0;
+}
+
+
+/***************************************************/
+/* The SPI Write routine. The first 16 bits are */
+/* the device register, and the rest of the buffer */
+/* is data. */
+/***************************************************/
+
+ssize_t spi_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
+{
+ int i;
+ unsigned char addr;
+ int timeout;
+ char temp;
+
+ if ( count < 3 )
+ return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
+
+ addr = buf[0]; /* chip register address. */
+ spi_ptr->np_spistatus=0;
+
+ for ( i = sizeof(u16); i<count; i++ )
+ {
+ timeout=SPI_BUSYPOLL_TIMEOUT;
+ while (SPI_Send_Byte(addr, buf[i])==-1)
+ {
+ if (--timeout==0)
+ {
+ printk("spi_write time out\n");
+ return i; /* return the number of bytes sent */
+ }
+ }
+ /* read the data */
+ timeout=SPI_BUSYPOLL_TIMEOUT;
+ while (SPI_Recv_Byte(&temp)==-1)
+ {
+ if (--timeout==0)
+ break;
+ }
+ }
+ return i;
+// unsigned char *temp; /* Our pointer to the buffer */
+// int i;
+// int addr;
+//
+// if ( count < 3 )
+// return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
+//
+// temp = (char *)buf;
+// addr = (int)*((u16 *)temp); /* chip register address. */
+// temp += sizeof(u16);
+//
+// for ( i = count - sizeof(u16); i; i--, temp++ )
+// *temp = (unsigned char)SPI_Transfer( addr, (int)*temp );
+//
+//
+// return count; /* we can always send all data */
+}
+
+//int spi_read( struct inode *inode, struct file *file, char *buf, int count )
+ssize_t spi_read(struct file *filp, char *buf, size_t count, loff_t *ppos)
+{
+ int i;
+ unsigned char addr;
+ int timeout;
+ char temp;
+
+ if ( count < 3 )
+ return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
+
+ addr = buf[0]; /* chip register address. */
+ spi_ptr->np_spistatus=0;
+
+ /* empty the np_spirxdata register */
+ SPI_Recv_Byte(&temp);
+
+ for ( i = sizeof(u16); i<count; i++ )
+ {
+ /* send the address */
+ timeout=SPI_BUSYPOLL_TIMEOUT;
+ while (SPI_Send_Byte(addr, 0)==-1)
+ {
+ if (--timeout==0)
+ {
+ printk("spi_read write address time out\n");
+ return i;
+ }
+ }
+
+ /* read the data */
+ timeout=SPI_BUSYPOLL_TIMEOUT;
+ while (SPI_Recv_Byte(&buf[i])==-1)
+ {
+ if (--timeout==0)
+ {
+ printk("spi_read read data time out\n");
+ return i;
+ }
+ }
+#if 0
+ printk("spi_read time left %d\n", timeout);
+#endif
+ }
+ return i;
+}
+
+loff_t spi_lseek(struct file *filp, loff_t offset, int origin)
+{
+#if 0
+ int bit_count, i;
+#endif
+
+ if ( origin != SEEK_SET || offset != (offset & 0xFFFF) )
+ {
+ errno = -EINVAL;
+ return -1;
+ }
+
+#if 0
+ /****************************************/
+ /* Nios SPI implementation safeguard: */
+ /* It is possible to have more than */
+ /* one CS active at a time. Check that */
+ /* the given address is a power of two. */
+ /****************************************/
+ bit_count = 0;
+ for ( i = 0; i < sizeof(u16); i++ )
+ {
+ if ( (1 << i) & offset )
+ {
+ if ( ++bit_count > 1 )
+ {
+ errno = -EINVAL;
+ return -1;
+ }
+ }
+ }
+#endif
+ spi_ptr->np_spislaveselect = offset;
+ return 0;
+}
+
+int spi_open(struct inode *inode, struct file *filp)
+{
+ preempt_disable();
+ if (openflag) {
+ preempt_enable();
+ return -EBUSY;
+ }
+
+ MOD_INC_USE_COUNT;
+ openflag = 1;
+ preempt_enable();
+
+ return 0;
+}
+
+int spi_release(struct inode *inode, struct file *filp)
+{
+ openflag = 0;
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+
+/* static struct file_operations spi_fops */
+
+static struct file_operations spi_fops = {
+ llseek: spi_lseek, /* Set chip-select line. The offset is used as an address. */
+ read: spi_read,
+ write: spi_write,
+ open: spi_open,
+ release: spi_release,
+};
+
+
+int register_NIOS_SPI( void )
+{
+ int result = register_chrdev( spi_major, "spi", &spi_fops );
+ if ( result < 0 )
+ {
+ printk( "SPI: unable to get major %d for SPI bus \n", spi_major );
+ return result;
+ }/*end-if*/
+
+ if ( spi_major == 0 )
+ spi_major = result; /* here we got our major dynamically */
+
+ /* reserve our port, but check first if free */
+ if ( check_region( (unsigned int)na_spi, sizeof(np_spi) ) )
+ {
+ printk( "SPI: port at adr 0x%08x already occupied\n", (unsigned int)na_spi );
+ unregister_chrdev( spi_major, "spi" );
+
+ return result;
+ }/*end-if*/
+
+ return 0;
+}
+
+void unregister_NIOS_SPI( void )
+{
+ if ( spi_major > 0 )
+ unregister_chrdev( spi_major, "spi" );
+
+ release_region( (unsigned int)na_spi, sizeof(np_spi) );
+}
+
+
+#ifdef MODULE
+void cleanup_module( void )
+{
+ unregister_NIOS_SPI();
+}
+
+
+
+int init_module( void )
+{
+ return register_NIOS_SPI();
+}
+#endif
+
+
+static int __init nios_spi_init(void)
+{
+ printk("SPI: Nios SPI bus device version 0.1\n");
+ return register_NIOS_SPI();
+// if ( register_NIOS_SPI() )
+// printk("*** Cannot initialize SPI device.\n");
+}
+
+__initcall(nios_spi_init);
diff --git a/arch/nios2nommu/kernel/ChangeLog b/arch/nios2nommu/kernel/ChangeLog
new file mode 100644
index 0000000..7f1449d
--- /dev/null
+++ b/arch/nios2nommu/kernel/ChangeLog
@@ -0,0 +1,27 @@
+2004-06-17 Ken Hill <khill@microtronix.com>
+
+ * process.c (machine_restart): Add code to disable interrups and
+ jump to the cpu reset address.
+ (machine_halt): Add code to disable interrupts and spinlock.
+ (machine_power_off): Add code to disable interrupts and spinlock.
+
+2004-06-16 Ken Hill <khill@microtronix.com>
+
+ * nios2_ksyms.c: Remove hard_reset_now.
+
+2004-06-10 Ken Hill <khill@microtronix.com>
+
+ * nios2_ksyms.c: Add EXPORT_SYMBOL_NOVERS(__down) to solve insmod for
+ some modules.
+
+2004-06-02 Ken Hill <khill@microtronix.com>
+
+ * entry.S (software_exception): Add a safety catch for old applications that may
+ have been linked against an older library. This does not add any overhead to
+ system call processing.
+
+2004-04-15 Ken Hill <khill@microtronix.com>
+
+ * setup.c (setup_arch): Remove ROMFS message from debug printk kernel message.
+ Add copyright and GNU license notice.
+
diff --git a/arch/nios2nommu/kernel/Makefile b/arch/nios2nommu/kernel/Makefile
new file mode 100644
index 0000000..a056ff1
--- /dev/null
+++ b/arch/nios2nommu/kernel/Makefile
@@ -0,0 +1,22 @@
+#
+# Makefile for the linux kernel.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+extra-y := head.o init_task.o vmlinux.lds
+
+obj-y := entry.o traps.o irq.o syscalltable.o \
+ process.o signal.o setup.o sys_nios2.o \
+ semaphore.o io.o usb.o\
+ time.o ptrace.o start.o nios2_ksyms.o
+
+obj-$(CONFIG_MODULES) += module.o
+obj-$(CONFIG_CONSOLE) += console.o
+obj-$(CONFIG_PIO_DEVICES) += pio.o
+obj-$(CONFIG_AVALON_DMA) += dma.o
+
+
diff --git a/arch/nios2nommu/kernel/asm-offsets.c b/arch/nios2nommu/kernel/asm-offsets.c
new file mode 100644
index 0000000..4877eba
--- /dev/null
+++ b/arch/nios2nommu/kernel/asm-offsets.c
@@ -0,0 +1,201 @@
+/*
+ * This program is used to generate definitions needed by
+ * assembly language modules.
+ *
+ * We use the technique used in the OSF Mach kernel code:
+ * generate asm statements containing #defines,
+ * compile this file to assembler, and then extract the
+ * #defines from the assembly-language output.
+ */
+
+#include <linux/stddef.h>
+#include <linux/sched.h>
+#include <linux/kernel_stat.h>
+#include <linux/ptrace.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/hardirq.h>
+#include <asm/nios.h>
+
+#define DEFINE(sym, val) \
+ asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+
+#define BLANK() asm volatile("\n->" : : )
+
+int main(void)
+{
+
+ /* offsets into the task struct */
+ DEFINE(TASK_STATE, offsetof(struct task_struct, state));
+ DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
+ DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
+ DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
+ DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
+ DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, stack));
+ DEFINE(TASK_MM, offsetof(struct task_struct, mm));
+ DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
+
+ /* offsets into the kernel_stat struct */
+ DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
+
+ /* offsets into the irq_cpustat_t struct */
+ DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
+
+ /* offsets into the irq_node struct */
+ DEFINE(IRQ_HANDLER, offsetof(struct irq_hand, handler));
+ DEFINE(IRQ_FLAGS, offsetof(struct irq_hand, flags));
+ DEFINE(IRQ_DEV_ID, offsetof(struct irq_hand, dev_id));
+ DEFINE(IRQ_DEVNAME, offsetof(struct irq_hand, devname));
+
+ /* offsets into the thread struct */
+ DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
+ DEFINE(THREAD_KPSR, offsetof(struct thread_struct, kpsr));
+ DEFINE(THREAD_KESR, offsetof(struct thread_struct, kesr));
+ DEFINE(THREAD_FLAGS, offsetof(struct thread_struct, flags));
+
+ /* offsets into the pt_regs */
+ DEFINE(PT_ORIG_R2, offsetof(struct pt_regs, orig_r2));
+ DEFINE(PT_R1, offsetof(struct pt_regs, r1));
+ DEFINE(PT_R2, offsetof(struct pt_regs, r2));
+ DEFINE(PT_R3, offsetof(struct pt_regs, r3));
+ DEFINE(PT_R4, offsetof(struct pt_regs, r4));
+ DEFINE(PT_R5, offsetof(struct pt_regs, r5));
+ DEFINE(PT_R6, offsetof(struct pt_regs, r6));
+ DEFINE(PT_R7, offsetof(struct pt_regs, r7));
+ DEFINE(PT_R8, offsetof(struct pt_regs, r8));
+ DEFINE(PT_R9, offsetof(struct pt_regs, r9));
+ DEFINE(PT_R10, offsetof(struct pt_regs, r10));
+ DEFINE(PT_R11, offsetof(struct pt_regs, r11));
+ DEFINE(PT_R12, offsetof(struct pt_regs, r12));
+ DEFINE(PT_R13, offsetof(struct pt_regs, r13));
+ DEFINE(PT_R14, offsetof(struct pt_regs, r14));
+ DEFINE(PT_R15, offsetof(struct pt_regs, r15));
+ DEFINE(PT_EA, offsetof(struct pt_regs, ea));
+ DEFINE(PT_RA, offsetof(struct pt_regs, ra));
+ DEFINE(PT_FP, offsetof(struct pt_regs, fp));
+ DEFINE(PT_SP, offsetof(struct pt_regs, sp));
+ DEFINE(PT_GP, offsetof(struct pt_regs, gp));
+ DEFINE(PT_ESTATUS, offsetof(struct pt_regs, estatus));
+ DEFINE(PT_STATUS_EXTENSION, offsetof(struct pt_regs, status_extension));
+ DEFINE(PT_REGS_SIZE, sizeof(struct pt_regs));
+
+ /* offsets into the switch_stack */
+ DEFINE(SW_R16, offsetof(struct switch_stack, r16));
+ DEFINE(SW_R17, offsetof(struct switch_stack, r17));
+ DEFINE(SW_R18, offsetof(struct switch_stack, r18));
+ DEFINE(SW_R19, offsetof(struct switch_stack, r19));
+ DEFINE(SW_R20, offsetof(struct switch_stack, r20));
+ DEFINE(SW_R21, offsetof(struct switch_stack, r21));
+ DEFINE(SW_R22, offsetof(struct switch_stack, r22));
+ DEFINE(SW_R23, offsetof(struct switch_stack, r23));
+ DEFINE(SW_FP, offsetof(struct switch_stack, fp));
+ DEFINE(SW_GP, offsetof(struct switch_stack, gp));
+ DEFINE(SW_RA, offsetof(struct switch_stack, ra));
+ DEFINE(SWITCH_STACK_SIZE, sizeof(struct switch_stack));
+
+ DEFINE(PS_S_ASM, PS_S);
+
+ DEFINE(NIOS2_STATUS_PIE_MSK_ASM, NIOS2_STATUS_PIE_MSK);
+ DEFINE(NIOS2_STATUS_PIE_OFST_ASM, NIOS2_STATUS_PIE_OFST);
+ DEFINE(NIOS2_STATUS_U_MSK_ASM, NIOS2_STATUS_U_MSK);
+ DEFINE(NIOS2_STATUS_U_OFST_ASM, NIOS2_STATUS_U_OFST);
+
+ /* offsets into the kernel_stat struct */
+ DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
+
+ /* Offsets in thread_info structure, used in assembly code */
+ DEFINE(TI_TASK, offsetof(struct thread_info, task));
+ DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
+ DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
+ DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
+ DEFINE(TI_PREEMPT_COUNT, offsetof(struct thread_info, preempt_count));
+
+ DEFINE(PREEMPT_ACTIVE_ASM, PREEMPT_ACTIVE);
+
+ DEFINE(THREAD_SIZE_ASM, THREAD_SIZE);
+
+ DEFINE(TIF_SYSCALL_TRACE_ASM, TIF_SYSCALL_TRACE);
+ DEFINE(TIF_NOTIFY_RESUME_ASM, TIF_NOTIFY_RESUME);
+ DEFINE(TIF_SIGPENDING_ASM, TIF_SIGPENDING);
+ DEFINE(TIF_NEED_RESCHED_ASM, TIF_NEED_RESCHED);
+ DEFINE(TIF_POLLING_NRFLAG_ASM, TIF_POLLING_NRFLAG);
+
+ DEFINE(_TIF_SYSCALL_TRACE_ASM, _TIF_SYSCALL_TRACE);
+ DEFINE(_TIF_NOTIFY_RESUME_ASM, _TIF_NOTIFY_RESUME);
+ DEFINE(_TIF_SIGPENDING_ASM, _TIF_SIGPENDING);
+ DEFINE(_TIF_NEED_RESCHED_ASM, _TIF_NEED_RESCHED);
+ DEFINE(_TIF_POLLING_NRFLAG_ASM, _TIF_POLLING_NRFLAG);
+
+ DEFINE(_TIF_WORK_MASK_ASM, _TIF_WORK_MASK);
+
+#if defined(na_flash_kernel) && defined(na_flash_kernel_end)
+ /* the flash chip */
+ DEFINE(NIOS_FLASH_START, na_flash_kernel);
+ DEFINE(NIOS_FLASH_END, na_flash_kernel_end);
+
+ /* the kernel placement in the flash*/
+ DEFINE(KERNEL_FLASH_START, na_flash_kernel);
+ DEFINE(KERNEL_FLASH_LEN, 0x200000);
+
+ /* the romdisk placement in the flash */
+ DEFINE(LINUX_ROMFS_START, na_flash_kernel+0x200000);
+ DEFINE(LINUX_ROMFS_END, na_flash_kernel_end);
+#else
+#error Sorry,you dont have na_flash_kernel or na_flash_kernel_end defined in the core.
+#endif
+
+#if defined(nasys_program_mem) && defined(nasys_program_mem_end)
+ /* the sdram */
+ DEFINE(LINUX_SDRAM_START, nasys_program_mem);
+ DEFINE(LINUX_SDRAM_END, nasys_program_mem_end);
+#else
+#error Sorry,you dont have nasys_program_mem or nasys_program_mem_end defined in the core.
+#endif
+
+ DEFINE(NIOS2_ICACHE_SIZE, nasys_icache_size);
+ DEFINE(NIOS2_ICACHE_LINE_SIZE, nasys_icache_line_size);
+ DEFINE(NIOS2_DCACHE_SIZE, nasys_dcache_size);
+ DEFINE(NIOS2_DCACHE_LINE_SIZE, nasys_dcache_line_size);
+
+#if defined(na_enet)
+ DEFINE(NA_ENET_ASM, na_enet);
+#endif
+
+#if defined(na_enet_reset)
+ DEFINE(NA_ENET_RESET_ASM, na_enet_reset);
+#endif
+
+#if defined(na_enet_reset_n)
+ DEFINE(NA_ENET_RESET_N_ASM, na_enet_reset_n);
+#endif
+
+#if defined(na_ide_interface)
+ DEFINE(NA_IDE_INTERFACE_ASM, na_ide_interface);
+#endif
+
+#if defined(na_timer0)
+ DEFINE(NA_TIMER0_ASM, na_timer0);
+ DEFINE(NP_TIMERCONTROL_ASM, offsetof(np_timer, np_timercontrol));
+ DEFINE(NP_TIMERSTATUS_ASM, offsetof(np_timer, np_timerstatus));
+#endif
+
+#if defined(na_uart0)
+ DEFINE(NA_UART0_ASM, na_uart0);
+ DEFINE(NP_UARTCONTROL_ASM, offsetof(np_uart, np_uartcontrol));
+ DEFINE(NP_UARTSTATUS_ASM, offsetof(np_uart, np_uartstatus));
+#endif
+
+#if defined(na_uart1)
+ DEFINE(NA_UART1_ASM, na_uart1);
+#endif
+
+#if defined(na_uart2)
+ DEFINE(NA_UART2_ASM, na_uart2);
+#endif
+
+#if defined(na_uart3)
+ DEFINE(NA_UART3_ASM, na_uart3);
+#endif
+
+ return 0;
+}
diff --git a/arch/nios2nommu/kernel/dma.c b/arch/nios2nommu/kernel/dma.c
new file mode 100644
index 0000000..f23323b
--- /dev/null
+++ b/arch/nios2nommu/kernel/dma.c
@@ -0,0 +1,342 @@
+/*
+ * arch/nios2nommu/kernel/dma.c
+ *
+ * Copyright (C) 2005 Microtronix Datacom Ltd
+ *
+ * PC like DMA API for Nios's DMAC.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ */
+
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/seq_file.h>
+#include <linux/proc_fs.h>
+#include <asm/io.h>
+#include <asm/dma.h>
+
+/* nios2 dma controller register map */
+#define REG_DMA_STATUS 0
+#define REG_DMA_READADDR 4
+#define REG_DMA_WRITEADDR 8
+#define REG_DMA_LENGTH 12
+#define REG_DMA_CONTROL 24
+
+/* status register bits definition */
+#define ST_DONE 0x01
+#define ST_BUSY 0x02
+#define ST_REOP 0x04
+#define ST_WROP 0x08
+#define ST_LEN 0x10
+
+/* control register bits definition */
+#define CT_BYTE 0x01
+#define CT_HW 0x02
+#define CT_WORD 0x04
+#define CT_GO 0x08
+#define CT_IEEN 0x10
+#define CT_REEN 0x20
+#define CT_WEEN 0x40
+#define CT_LEEN 0x80
+#define CT_RCON 0x100
+#define CT_WCON 0x200
+#define CT_DOUBLE 0x400
+#define CT_QUAD 0x800
+
+struct dma_channel {
+ unsigned int addr; /* control address */
+ unsigned int irq; /* interrupt number */
+ atomic_t idle;
+ unsigned int mode; /* dma mode: width, stream etc */
+ int (*handler)(void*, int );
+ void* user;
+
+ char id[16];
+ char dev_id[16];
+};
+static struct dma_channel dma_channels[]={
+#ifdef na_dma_0
+ {
+ .addr = na_dma_0,
+ .irq = na_dma_0_irq,
+ .idle = ATOMIC_INIT(1),
+ },
+#endif
+#ifdef na_dma_1
+ {
+ .addr = na_dma_1,
+ .irq = na_dma_1_irq,
+ .idle = ATOMIC_INIT(1),
+ },
+#endif
+};
+#define MAX_DMA_CHANNELS sizeof(dma_channels)/sizeof(struct dma_channel)
+
+void enable_dma(unsigned int dmanr)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ unsigned int ctl = dma_channels[dmanr].mode;
+ ctl |= CT_GO | CT_IEEN;
+ outl(ctl, dma_channels[dmanr].addr+REG_DMA_CONTROL);
+ }
+}
+
+void disable_dma(unsigned int dmanr)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ unsigned int ctl = dma_channels[dmanr].mode;
+ ctl &= ~(CT_GO | CT_IEEN);
+ outl(ctl, dma_channels[dmanr].addr+REG_DMA_CONTROL);
+ }
+}
+
+void set_dma_count(unsigned int dmanr, unsigned int count)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ dma_channels[dmanr].mode |= CT_LEEN;
+ outl(count, dma_channels[dmanr].addr+REG_DMA_LENGTH);
+ }
+}
+
+int get_dma_residue(unsigned int dmanr)
+{
+ int result =-1;
+ if (dmanr < MAX_DMA_CHANNELS) {
+ result = inl(dma_channels[dmanr].addr+REG_DMA_LENGTH);
+ }
+ return result;
+}
+
+int request_dma(unsigned int chan, const char *dev_id)
+{
+ struct dma_channel *channel;
+
+ if ( chan >= MAX_DMA_CHANNELS) {
+ return -EINVAL;
+ }
+
+ channel = &dma_channels[chan];
+
+ if (!atomic_dec_and_test(&channel->idle)) {
+ return -EBUSY;
+ }
+
+ strlcpy(channel->dev_id, dev_id, sizeof(channel->dev_id));
+ channel->handler=NULL;
+ channel->user=NULL;
+ channel->mode =0;
+
+ return 0;
+}
+
+void free_dma(unsigned int chan)
+{
+ if ( chan < MAX_DMA_CHANNELS) {
+ dma_channels[chan].handler=NULL;
+ dma_channels[chan].user=NULL;
+ atomic_set(&dma_channels[chan].idle, 1);
+ }
+}
+
+int nios2_request_dma(const char *dev_id)
+{
+ int chann;
+
+ for ( chann=0; chann < MAX_DMA_CHANNELS; chann++) {
+ if (request_dma(chann, dev_id)==0)
+ return chann;
+ }
+
+ return -EINVAL;
+}
+void nios2_set_dma_handler(unsigned int dmanr, int (*handler)(void*, int), void* user)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ dma_channels[dmanr].handler=handler;
+ dma_channels[dmanr].user=user;
+ }
+}
+#define NIOS2_DMA_WIDTH_MASK (CT_BYTE | CT_HW | CT_WORD | CT_DOUBLE | CT_QUAD)
+#define NIOS2_MODE_MASK (NIOS2_DMA_WIDTH_MASK | CT_REEN | CT_WEEN | CT_LEEN | CT_RCON | CT_WCON)
+void nios2_set_dma_data_width(unsigned int dmanr, unsigned int width)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ dma_channels[dmanr].mode &= ~NIOS2_DMA_WIDTH_MASK;
+ switch (width) {
+ case 1:
+ dma_channels[dmanr].mode |= CT_BYTE;
+ break;
+ case 2:
+ dma_channels[dmanr].mode |= CT_HW;
+ break;
+ case 8:
+ dma_channels[dmanr].mode |= CT_DOUBLE;
+ break;
+ case 16:
+ dma_channels[dmanr].mode |= CT_QUAD;
+ break;
+ case 4:
+ default:
+ dma_channels[dmanr].mode |= CT_WORD;
+ break;
+ }
+ }
+}
+
+void nios2_set_dma_rcon(unsigned int dmanr,unsigned int set)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ dma_channels[dmanr].mode &= ~(CT_REEN | CT_RCON);
+ if (set)
+ dma_channels[dmanr].mode |= (CT_REEN | CT_RCON);
+ }
+}
+void nios2_set_dma_wcon(unsigned int dmanr,unsigned int set)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ dma_channels[dmanr].mode &= ~(CT_WEEN | CT_WCON);
+ if (set)
+ dma_channels[dmanr].mode |= (CT_WEEN | CT_WCON);
+ }
+}
+void nios2_set_dma_mode(unsigned int dmanr, unsigned int mode)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ /* set_dma_mode is only allowed to change the bus width,
+ stream setting, etc.
+ */
+ mode &= NIOS2_MODE_MASK;
+ dma_channels[dmanr].mode &= ~NIOS2_MODE_MASK;
+ dma_channels[dmanr].mode |= mode;
+ }
+}
+
+void nios2_set_dma_raddr(unsigned int dmanr, unsigned int a)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ outl(a, dma_channels[dmanr].addr+REG_DMA_READADDR);
+ }
+}
+void nios2_set_dma_waddr(unsigned int dmanr, unsigned int a)
+{
+ if (dmanr < MAX_DMA_CHANNELS) {
+ outl(a, dma_channels[dmanr].addr+REG_DMA_WRITEADDR);
+ }
+}
+
+
+static irqreturn_t dma_isr(int irq, void *dev_id)
+{
+ struct dma_channel *chann=(struct dma_channel*)dev_id;
+
+ if (chann) {
+ int status = inl(chann->addr+REG_DMA_STATUS);
+ /* ack the interrupt, and clear the DONE bit */
+ outl(0, chann->addr+REG_DMA_STATUS);
+ /* call the peripheral callback */
+ if (chann->handler)
+ chann->handler(chann->user, status);
+ }
+
+ return IRQ_HANDLED;
+}
+
+
+
+#ifdef CONFIG_PROC_FS
+static int proc_dma_show(struct seq_file *m, void *v)
+{
+ int i;
+
+ for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
+ if (!atomic_read(&dma_channels[i].idle)) {
+ seq_printf(m, "%2d: %s\n", i,
+ dma_channels[i].dev_id);
+ }
+ }
+ return 0;
+}
+
+static int proc_dma_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, proc_dma_show, NULL);
+}
+static struct file_operations proc_dma_operations = {
+ .open = proc_dma_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static int __init proc_dma_init(void)
+{
+ struct proc_dir_entry *e;
+
+ e = create_proc_entry("dma", 0, NULL);
+ if (e)
+ e->proc_fops = &proc_dma_operations;
+
+ return 0;
+}
+
+__initcall(proc_dma_init);
+
+#endif /* CONFIG_PROC_FS */
+
+int __init init_dma(void)
+{
+ int i;
+
+ for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
+ sprintf(dma_channels[i].id, "dmac-%d", i);
+ /* disable the dmac channel */
+ disable_dma(i);
+ /* request irq*/
+ if (request_irq(dma_channels[i].irq, dma_isr, 0, dma_channels[i].id, (void*)&dma_channels[i])){
+ printk("DMA controller %d failed to get irq %d\n", i, dma_channels[i].irq);
+ atomic_set(&dma_channels[i].idle, 0);
+ }
+ }
+ return 0;
+}
+
+static void __exit exit_dma(void)
+{
+ int i;
+
+ for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
+ /* disable the dmac channel */
+ disable_dma(i);
+ free_irq(dma_channels[i].irq, dma_channels[i].id);
+ }
+}
+
+module_init(init_dma);
+module_exit(exit_dma);
+
+MODULE_LICENSE("GPL");
+
+//EXPORT_SYMBOL(claim_dma_lock);
+//EXPORT_SYMBOL(release_dma_lock);
+EXPORT_SYMBOL(enable_dma);
+EXPORT_SYMBOL(disable_dma);
+EXPORT_SYMBOL(set_dma_count);
+EXPORT_SYMBOL(get_dma_residue);
+EXPORT_SYMBOL(request_dma);
+EXPORT_SYMBOL(free_dma);
+EXPORT_SYMBOL(nios2_request_dma);
+EXPORT_SYMBOL(nios2_set_dma_handler);
+EXPORT_SYMBOL(nios2_set_dma_data_width);
+EXPORT_SYMBOL(nios2_set_dma_rcon);
+EXPORT_SYMBOL(nios2_set_dma_wcon);
+EXPORT_SYMBOL(nios2_set_dma_mode);
+EXPORT_SYMBOL(nios2_set_dma_raddr);
+EXPORT_SYMBOL(nios2_set_dma_waddr);
+
diff --git a/arch/nios2nommu/kernel/entry.S b/arch/nios2nommu/kernel/entry.S
new file mode 100644
index 0000000..7f71a01
--- /dev/null
+++ b/arch/nios2nommu/kernel/entry.S
@@ -0,0 +1,898 @@
+/*
+ * linux/arch/nios2nommu/kernel/entry.S
+ *
+ * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
+ * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
+ * Kenneth Albanowski <kjahds@kjahds.com>,
+ * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * Based on:
+ *
+ * linux/arch/m68knommu/kernel/entry.S
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file README.legal in the main directory of this archive
+ * for more details.
+ *
+ * Linux/m68k support by Hamish Macdonald
+ *
+ * 68060 fixes by Jesper Skov
+ * ColdFire support by Greg Ungerer (gerg@snapgear.com)
+ * 5307 fixes by David W. Miller
+ * linux 2.4 support David McCullough <davidm@snapgear.com>
+ */
+
+#include <linux/sys.h>
+#include <linux/linkage.h>
+#include <asm/asm-offsets.h>
+#include <asm/asm-macros.h>
+#include <asm/thread_info.h>
+#include <asm/errno.h>
+#include <asm/setup.h>
+#include <asm/segment.h>
+#include <asm/entry.h>
+#include <asm/unistd.h>
+#include <asm/traps.h>
+#include <asm/processor.h>
+
+.text
+.set noat
+.set nobreak
+
+ENTRY(system_call)
+/* SAVE_ALL */
+ rdctl r10,status /* enable intrs again */
+ ori r10,r10,0x0001
+ wrctl status,r10
+
+ movi r2,-LENOSYS
+ stw r2,PT_R2(sp) /* default return value in r2 */
+ /* original r2 is in orig_r2 */
+
+ movui r1,NR_syscalls
+ bgtu r3,r1,ret_from_exception
+ slli r1,r3,2
+ movhi r11,%hiadj(sys_call_table)
+ add r1,r1,r11
+ ldw r1,%lo(sys_call_table)(r1)
+ beq r1,r0,ret_from_exception
+
+ movi r11,%lo(0xffffe000) /* Get thread info pointer */
+ and r11,sp,r11
+ ldw r11,TI_FLAGS(r11)
+ BTBNZ r11,r11,TIF_SYSCALL_TRACE_ASM,1f
+
+ callr r1
+ stw r2,PT_R2(sp) /* save the return value */
+ br ret_from_exception
+1:
+ SAVE_SWITCH_STACK
+ call syscall_trace
+ RESTORE_SWITCH_STACK
+ /* wentao: restore r4-9, since they are trashed by syscall_trace */
+ ldw r4,PT_R4(sp)
+ ldw r5,PT_R5(sp)
+ ldw r6,PT_R6(sp)
+ ldw r7,PT_R7(sp)
+ ldw r8,PT_R8(sp)
+ ldw r9,PT_R9(sp)
+ callr r1
+ stw r2,PT_R2(sp) /* save the return value */
+ SAVE_SWITCH_STACK
+ call syscall_trace
+ RESTORE_SWITCH_STACK
+
+ret_from_exception:
+ ldw r1,PT_STATUS_EXTENSION(sp) /* check if returning to kernel */
+ TSTBZ r1,r1,PS_S_ASM,Luser_return /* if so, skip resched, signals */
+
+restore_all:
+ rdctl r10,status /* disable intrs */
+ andi r10,r10,0xfffe
+ wrctl status, r10
+ RESTORE_ALL
+ eret
+
+Luser_return:
+ GET_THREAD_INFO r24 /* get thread_info pointer */
+ ldw r10,TI_FLAGS(r24) /* get thread_info->flags */
+ ANDI32 r11,r10,_TIF_WORK_MASK_ASM
+ beq r11,r0,restore_all /* Nothing to do */
+ BTBZ r1,r10,TIF_NEED_RESCHED_ASM,Lsignal_return
+
+Lwork_resched:
+ call schedule
+ br ret_from_exception
+
+Lsignal_return:
+ BTBZ r1,r10,TIF_SIGPENDING_ASM,restore_all
+ mov r5,sp /* pt_regs */
+ SAVE_SWITCH_STACK
+ CLR r4 /* oldset = 0 */
+ call do_signal
+ RESTORE_SWITCH_STACK
+ br restore_all
+
+/*
+ * Handle software exceptions. Put here so external interrupts
+ * can fall throught to ret_from_interrupt.
+ */
+
+software_exception:
+ ldw r24,-4(ea) // instruction that caused the exception
+ xorhi r24,r24,0x003b // upper half of trap opcode
+ xori r24,r24,0x683a // lower half of trap opcode
+ bne r24,r0,instruction_trap /* N - check for instruction trap */
+ cmpeqi r11,r2,TRAP_ID_SYSCALL /* ? Is this a syscall */
+ bne r11,r0,system_call /* Y - handle syscall */
+ cmpeqi r11,r2,TRAP_ID_APPDEBUG /* ? Is this an application debug */
+ bne r11,r0,app_debug /* Y - handle app_debug */
+ cmpeqi r11,r2,63 /* ? Is this the old syscall number */
+ bne r11,r0,system_call /* Y - handle syscall to catch older apps*/
+ br restore_all /* N - everything else is ignored for now */
+
+app_debug:
+ GET_THREAD_INFO r24 /* get thread_info */
+ ldw r1,TI_TASK(r24) /* get thread_info->task */
+ ldw r24,(TASK_THREAD + THREAD_FLAGS)(r1) /* get thread_info->task->thread.flags */
+ ORI32 r24, r24, NIOS2_FLAG_DEBUG /* set the debug flag */
+ stw r24,(TASK_THREAD + THREAD_FLAGS)(r1) /* save thread_info->task->thread.flags */
+ br restore_all
+
+/*
+ * This is the generic interrupt handler (for all hardware interrupt
+ * sources). It figures out the vector number and calls the appropriate
+ * interrupt service routine directly.
+ */
+ENTRY(inthandler)
+ SAVE_ALL
+ /*
+ * Test to see if the exception was a software exception or caused by an
+ * external interrupt, and vector accordingly.
+ */
+
+ rdctl r24,estatus
+ andi r24,r24,1
+ beq r24,r0,software_exception
+ rdctl r12,ipending
+ beq r12,r0,software_exception
+
+ movi r24,-1
+ stw r24,PT_ORIG_R2(sp)
+
+ /*
+ * Process an external hardware interrupt.
+ */
+
+ addi ea,ea,-4 /* re-issue the interrupted instruction */
+ stw ea,PT_EA(sp)
+ rdctl r9,ienable /* Isolate possible interrupts */
+ and r12,r12,r9
+ beq r12,r0,ret_from_interrupt /* No one to service done */
+ movi r4,%lo(-1) /* Start from bit position 0, highest priority */
+ /* This is the IRQ # for handler call */
+1: addi r4,r4,1
+ srl r10,r12,r4
+ andi r10,r10,1 /* Isolate bit we are interested in */
+ cmpeqi r11,r4,32 /* ? End of the register */
+ bne r11,r0,ret_from_interrupt /* Y - out of here */
+ beq r10,r0,1b
+ mov r5,sp /* Setup pt_regs pointer for handler call */
+ PUSH r4 /* Save state for return */
+ PUSH r12
+ call process_int
+ POP r12
+ POP r4
+ br 1b /* Check for other interrupts while here */
+
+ENTRY(ret_from_interrupt)
+ ldw r4,PT_STATUS_EXTENSION(sp)
+ TSTBZ r4,r4,PS_S_ASM,Luser_return // Returning to user
+
+#ifdef CONFIG_PREEMPT
+ GET_THREAD_INFO r1
+ ldw r4,TI_PREEMPT_COUNT(r1)
+ bne r4,r0,restore_all
+
+need_resched:
+ ldw r4,TI_FLAGS(r1) // ? Need resched set
+ BTBZ r10,r4,TIF_NEED_RESCHED_ASM,restore_all
+ ldw r4,PT_ESTATUS(sp) // ? Interrupts off
+ BTBZ r10,r4,NIOS2_STATUS_PIE_OFST_ASM,restore_all
+ movia r4,PREEMPT_ACTIVE_ASM
+ stw r4,TI_PREEMPT_COUNT(r1)
+ rdctl r10,status /* enable intrs again */
+ ori r10,r10,0x0001
+ wrctl status,r10
+ PUSH r1
+ call schedule
+ POP r1
+ mov r4,r0
+ stw r4,TI_PREEMPT_COUNT(r1)
+ rdctl r10,status /* disable intrs */
+ andi r10,r10,0xfffe
+ wrctl status, r10
+ br need_resched
+#else
+ br restore_all
+#endif
+
+
+/*
+ * Beware - when entering resume, prev (the current task) is
+ * in r4, next (the new task) is in r5, don't change these
+ * registers.
+ */
+ENTRY(resume)
+
+ rdctl r7,status /* save thread status reg */
+ stw r7,TASK_THREAD+THREAD_KPSR(r4)
+
+ andi r7,r7,0x0fffe /* disable interrupts */
+ wrctl status,r7
+
+ movia r8,status_extension /* save status extension */
+ ldw r7,0(r8)
+ stw r7,TASK_THREAD+THREAD_KESR(r4)
+
+ SAVE_SWITCH_STACK
+ stw sp,TASK_THREAD+THREAD_KSP(r4) /* save kernel stack pointer */
+ ldw sp,TASK_THREAD+THREAD_KSP(r5) /* restore new thread stack */
+ movia r24,_current_thread /* save thread */
+ GET_THREAD_INFO r1
+ stw r1,0(r24)
+ RESTORE_SWITCH_STACK
+
+ ldw r7,TASK_THREAD+THREAD_KESR(r5) /* restore extended status reg */
+ stw r7,0(r8)
+
+ ldw r7,TASK_THREAD+THREAD_KPSR(r5) /* restore thread status reg */
+ wrctl status,r7
+ ret
+
+ENTRY(ret_from_fork)
+ call schedule_tail
+ br ret_from_exception
+
+ENTRY(sys_fork)
+ mov r4,sp
+ SAVE_SWITCH_STACK
+ call nios2_vfork
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_vfork)
+ mov r4,sp
+ SAVE_SWITCH_STACK
+ call nios2_vfork
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_execve)
+ mov r4,sp
+ SAVE_SWITCH_STACK
+ call nios2_execve
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_clone)
+ mov r4,sp
+ SAVE_SWITCH_STACK
+ call nios2_clone
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_sigsuspend)
+ mov r4,sp
+ SAVE_SWITCH_STACK
+ call do_sigsuspend
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_rt_sigsuspend)
+ mov r4,sp
+ SAVE_SWITCH_STACK
+ call do_rt_sigsuspend
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_sigreturn)
+ mov r4,sp
+ SAVE_SWITCH_STACK
+ call do_sigreturn
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_sigaltstack)
+ ldw r4,PT_R4(sp)
+ ldw r5,PT_R5(sp)
+ ldw r6,PT_SP(sp)
+ SAVE_SWITCH_STACK
+ call do_sigaltstack
+ RESTORE_SWITCH_STACK
+ ret
+
+ENTRY(sys_rt_sigreturn)
+ SAVE_SWITCH_STACK
+ call do_rt_sigreturn
+ RESTORE_SWITCH_STACK
+ ret
+
+/******************************************************************************
+* *
+* License Agreement *
+* *
+* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
+* All rights reserved. *
+* *
+* Permission is hereby granted, free of charge, to any person obtaining a *
+* copy of this software and associated documentation files (the "Software"), *
+* to deal in the Software without restriction, including without limitation *
+* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
+* and/or sell copies of the Software, and to permit persons to whom the *
+* Software is furnished to do so, subject to the following conditions: *
+* *
+* The above copyright notice and this permission notice shall be included in *
+* all copies or substantial portions of the Software. *
+* *
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
+* DEALINGS IN THE SOFTWARE. *
+* *
+* This agreement shall be governed in all respects by the laws of the State *
+* of California and by the laws of the United States of America. *
+* *
+******************************************************************************/
+
+ /*
+ * This is the software exception handler for Nios2.
+ */
+
+ /*
+ * Explicitly allow the use of r1 (the assembler temporary register)
+ * within this code. This register is normally reserved for the use of
+ * the compiler.
+ */
+
+ENTRY(instruction_trap)
+ RESTORE_ALL // Clean off our save & setup for emulation
+
+ /* INSTRUCTION EMULATION
+ * ---------------------
+ *
+ * Nios II processors generate exceptions for unimplemented instructions.
+ * The routines below emulate these instructions. Depending on the
+ * processor core, the only instructions that might need to be emulated
+ * are div, divu, mul, muli, mulxss, mulxsu, and mulxuu.
+ *
+ * The emulations match the instructions, except for the following
+ * limitations:
+ *
+ * 1) The emulation routines do not emulate the use of the exception
+ * temporary register (et) as a source operand because the exception
+ * handler already has modified it.
+ *
+ * 2) The routines do not emulate the use of the stack pointer (sp) or the
+ * exception return address register (ea) as a destination because
+ * modifying these registers crashes the exception handler or the
+ * interrupted routine.
+ *
+ * Detailed Design
+ * ---------------
+ *
+ * The emulation routines expect the contents of integer registers r0-r31
+ * to be on the stack at addresses sp, 4(sp), 8(sp), ... 124(sp). The
+ * routines retrieve source operands from the stack and modify the
+ * destination register's value on the stack prior to the end of the
+ * exception handler. Then all registers except the destination register
+ * are restored to their previous values.
+ *
+ * The instruction that causes the exception is found at address -4(ea).
+ * The instruction's OP and OPX fields identify the operation to be
+ * performed.
+ *
+ * One instruction, muli, is an I-type instruction that is identified by
+ * an OP field of 0x24.
+ *
+ * muli AAAAA,BBBBB,IIIIIIIIIIIIIIII,-0x24-
+ * 27 22 6 0 <-- LSB of field
+ *
+ * The remaining emulated instructions are R-type and have an OP field
+ * of 0x3a. Their OPX fields identify them.
+ *
+ * R-type AAAAA,BBBBB,CCCCC,XXXXXX,NNNNN,-0x3a-
+ * 27 22 17 11 6 0 <-- LSB of field
+ *
+ *
+ * Opcode Encoding. muli is identified by its OP value. Then OPX & 0x02
+ * is used to differentiate between the division opcodes and the remaining
+ * multiplication opcodes.
+ *
+ * Instruction OP OPX OPX & 0x02
+ * ----------- ---- ---- ----------
+ * muli 0x24
+ * divu 0x3a 0x24 0
+ * div 0x3a 0x25 0
+ * mul 0x3a 0x27 != 0
+ * mulxuu 0x3a 0x07 != 0
+ * mulxsu 0x3a 0x17 != 0
+ * mulxss 0x3a 0x1f != 0
+ */
+
+
+ /*
+ * Save everything on the stack to make it easy for the emulation routines
+ * to retrieve the source register operands.
+ */
+
+ addi sp, sp, -128
+ stw zero, 0(sp) // Save zero on stack to avoid special case for r0.
+ stw r1, 4(sp)
+ stw r2, 8(sp)
+ stw r3, 12(sp)
+ stw r4, 16(sp)
+ stw r5, 20(sp)
+ stw r6, 24(sp)
+ stw r7, 28(sp)
+ stw r8, 32(sp)
+ stw r9, 36(sp)
+ stw r10, 40(sp)
+ stw r11, 44(sp)
+ stw r12, 48(sp)
+ stw r13, 52(sp)
+ stw r14, 56(sp)
+ stw r15, 60(sp)
+ stw r16, 64(sp)
+ stw r17, 68(sp)
+ stw r18, 72(sp)
+ stw r19, 76(sp)
+ stw r20, 80(sp)
+ stw r21, 84(sp)
+ stw r22, 88(sp)
+ stw r23, 92(sp)
+ // Don't bother to save et. It's already been changed.
+ stw bt, 100(sp)
+ stw gp, 104(sp)
+ stw sp, 108(sp)
+ stw fp, 112(sp)
+ // Don't bother to save ea. It's already been changed.
+ stw ba, 120(sp)
+ stw ra, 124(sp)
+
+
+ /*
+ * Split the instruction into its fields. We need 4*A, 4*B, and 4*C as
+ * offsets to the stack pointer for access to the stored register values.
+ */
+ ldw r2,-4(ea) // r2 = AAAAA,BBBBB,IIIIIIIIIIIIIIII,PPPPPP
+ roli r3,r2,7 // r3 = BBB,IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BB
+ roli r4,r3,3 // r4 = IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB
+ roli r5,r4,2 // r5 = IIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB,II
+ srai r4,r4,16 // r4 = (sign-extended) IMM16
+ roli r6,r5,5 // r6 = XXXX,NNNNN,PPPPPP,AAAAA,BBBBB,CCCCC,XX
+ andi r2,r2,0x3f // r2 = 00000000000000000000000000,PPPPPP
+ andi r3,r3,0x7c // r3 = 0000000000000000000000000,AAAAA,00
+ andi r5,r5,0x7c // r5 = 0000000000000000000000000,BBBBB,00
+ andi r6,r6,0x7c // r6 = 0000000000000000000000000,CCCCC,00
+
+ /* Now
+ * r2 = OP
+ * r3 = 4*A
+ * r4 = IMM16 (sign extended)
+ * r5 = 4*B
+ * r6 = 4*C
+ */
+
+
+ /*
+ * Get the operands.
+ *
+ * It is necessary to check for muli because it uses an I-type instruction
+ * format, while the other instructions are have an R-type format.
+ *
+ * Prepare for either multiplication or division loop.
+ * They both loop 32 times.
+ */
+ movi r14,32
+
+ add r3,r3,sp // r3 = address of A-operand.
+ ldw r3,0(r3) // r3 = A-operand.
+ movi r7,0x24 // muli opcode (I-type instruction format)
+ beq r2,r7,mul_immed // muli doesn't use the B register as a source
+
+ add r5,r5,sp // r5 = address of B-operand.
+ ldw r5,0(r5) // r5 = B-operand.
+ // r4 = SSSSSSSSSSSSSSSS,-----IMM16------
+ // IMM16 not needed, align OPX portion
+ // r4 = SSSSSSSSSSSSSSSS,CCCCC,-OPX--,00000
+ srli r4,r4,5 // r4 = 00000,SSSSSSSSSSSSSSSS,CCCCC,-OPX--
+ andi r4,r4,0x3f // r4 = 00000000000000000000000000,-OPX--
+
+ /* Now
+ * r2 = OP
+ * r3 = src1
+ * r5 = src2
+ * r4 = OPX (no longer can be muli)
+ * r6 = 4*C
+ */
+
+
+
+ /*
+ * Multiply or Divide?
+ */
+ andi r7,r4,0x02 // For R-type multiply instructions, OPX & 0x02 != 0
+ bne r7,zero,multiply
+
+
+ /* DIVISION
+ *
+ * Divide an unsigned dividend by an unsigned divisor using
+ * a shift-and-subtract algorithm. The example below shows
+ * 43 div 7 = 6 for 8-bit integers. This classic algorithm uses a
+ * single register to store both the dividend and the quotient,
+ * allowing both values to be shifted with a single instruction.
+ *
+ * remainder dividend:quotient
+ * --------- -----------------
+ * initialize 00000000 00101011:
+ * shift 00000000 0101011:_
+ * remainder >= divisor? no 00000000 0101011:0
+ * shift 00000000 101011:0_
+ * remainder >= divisor? no 00000000 101011:00
+ * shift 00000001 01011:00_
+ * remainder >= divisor? no 00000001 01011:000
+ * shift 00000010 1011:000_
+ * remainder >= divisor? no 00000010 1011:0000
+ * shift 00000101 011:0000_
+ * remainder >= divisor? no 00000101 011:00000
+ * shift 00001010 11:00000_
+ * remainder >= divisor? yes 00001010 11:000001
+ * remainder -= divisor - 00000111
+ * ----------
+ * 00000011 11:000001
+ * shift 00000111 1:000001_
+ * remainder >= divisor? yes 00000111 1:0000011
+ * remainder -= divisor - 00000111
+ * ----------
+ * 00000000 1:0000011
+ * shift 00000001 :0000011_
+ * remainder >= divisor? no 00000001 :00000110
+ *
+ * The quotient is 00000110.
+ */
+
+divide:
+ /*
+ * Prepare for division by assuming the result
+ * is unsigned, and storing its "sign" as 0.
+ */
+ movi r17,0
+
+
+ // Which division opcode?
+ xori r7,r4,0x25 // OPX of div
+ bne r7,zero,unsigned_division
+
+
+ /*
+ * OPX is div. Determine and store the sign of the quotient.
+ * Then take the absolute value of both operands.
+ */
+ xor r17,r3,r5 // MSB contains sign of quotient
+ bge r3,zero,dividend_is_nonnegative
+ sub r3,zero,r3 // -r3
+dividend_is_nonnegative:
+ bge r5,zero,divisor_is_nonnegative
+ sub r5,zero,r5 // -r5
+divisor_is_nonnegative:
+
+
+unsigned_division:
+ // Initialize the unsigned-division loop.
+ movi r13,0 // remainder = 0
+
+ /* Now
+ * r3 = dividend : quotient
+ * r4 = 0x25 for div, 0x24 for divu
+ * r5 = divisor
+ * r13 = remainder
+ * r14 = loop counter (already initialized to 32)
+ * r17 = MSB contains sign of quotient
+ */
+
+
+ /*
+ * for (count = 32; count > 0; --count)
+ * {
+ */
+divide_loop:
+
+ /*
+ * Division:
+ *
+ * (remainder:dividend:quotient) <<= 1;
+ */
+ slli r13,r13,1
+ cmplt r7,r3,zero // r7 = MSB of r3
+ or r13,r13,r7
+ slli r3,r3,1
+
+
+ /*
+ * if (remainder >= divisor)
+ * {
+ * set LSB of quotient
+ * remainder -= divisor;
+ * }
+ */
+ bltu r13,r5,div_skip
+ ori r3,r3,1
+ sub r13,r13,r5
+div_skip:
+
+ /*
+ * }
+ */
+ subi r14,r14,1
+ bne r14,zero,divide_loop
+
+
+ /* Now
+ * r3 = quotient
+ * r4 = 0x25 for div, 0x24 for divu
+ * r6 = 4*C
+ * r17 = MSB contains sign of quotient
+ */
+
+
+ /*
+ * Conditionally negate signed quotient. If quotient is unsigned,
+ * the sign already is initialized to 0.
+ */
+ bge r17,zero,quotient_is_nonnegative
+ sub r3,zero,r3 // -r3
+quotient_is_nonnegative:
+
+
+ /*
+ * Final quotient is in r3.
+ */
+ add r6,r6,sp
+ stw r3,0(r6) // write quotient to stack
+ br restore_registers
+
+
+
+
+ /* MULTIPLICATION
+ *
+ * A "product" is the number that one gets by summing a "multiplicand"
+ * several times. The "multiplier" specifies the number of copies of the
+ * multiplicand that are summed.
+ *
+ * Actual multiplication algorithms don't use repeated addition, however.
+ * Shift-and-add algorithms get the same answer as repeated addition, and
+ * they are faster. To compute the lower half of a product (pppp below)
+ * one shifts the product left before adding in each of the partial products
+ * (a * mmmm) through (d * mmmm).
+ *
+ * To compute the upper half of a product (PPPP below), one adds in the
+ * partial products (d * mmmm) through (a * mmmm), each time following the
+ * add by a right shift of the product.
+ *
+ * mmmm
+ * * abcd
+ * ------
+ * #### = d * mmmm
+ * #### = c * mmmm
+ * #### = b * mmmm
+ * #### = a * mmmm
+ * --------
+ * PPPPpppp
+ *
+ * The example above shows 4 partial products. Computing actual Nios II
+ * products requires 32 partials.
+ *
+ * It is possible to compute the result of mulxsu from the result of mulxuu
+ * because the only difference between the results of these two opcodes is
+ * the value of the partial product associated with the sign bit of rA.
+ *
+ * mulxsu = mulxuu - (rA < 0) ? rB : 0;
+ *
+ * It is possible to compute the result of mulxss from the result of mulxsu
+ * because the only difference between the results of these two opcodes is
+ * the value of the partial product associated with the sign bit of rB.
+ *
+ * mulxss = mulxsu - (rB < 0) ? rA : 0;
+ *
+ */
+
+mul_immed:
+ // Opcode is muli. Change it into mul for remainder of algorithm.
+ mov r6,r5 // Field B is dest register, not field C.
+ mov r5,r4 // Field IMM16 is src2, not field B.
+ movi r4,0x27 // OPX of mul is 0x27
+
+multiply:
+ // Initialize the multiplication loop.
+ movi r9,0 // mul_product = 0
+ movi r10,0 // mulxuu_product = 0
+ mov r11,r5 // save original multiplier for mulxsu and mulxss
+ mov r12,r5 // mulxuu_multiplier (will be shifted)
+ movi r16,1 // used to create "rori B,A,1" from "ror B,A,r16"
+
+ /* Now
+ * r3 = multiplicand
+ * r5 = mul_multiplier
+ * r6 = 4 * dest_register (used later as offset to sp)
+ * r7 = temp
+ * r9 = mul_product
+ * r10 = mulxuu_product
+ * r11 = original multiplier
+ * r12 = mulxuu_multiplier
+ * r14 = loop counter (already initialized)
+ * r16 = 1
+ */
+
+
+ /*
+ * for (count = 32; count > 0; --count)
+ * {
+ */
+multiply_loop:
+
+ /*
+ * mul_product <<= 1;
+ * lsb = multiplier & 1;
+ */
+ slli r9,r9,1
+ andi r7,r12,1
+
+ /*
+ * if (lsb == 1)
+ * {
+ * mulxuu_product += multiplicand;
+ * }
+ */
+ beq r7,zero,mulx_skip
+ add r10,r10,r3
+ cmpltu r7,r10,r3 // Save the carry from the MSB of mulxuu_product.
+ ror r7,r7,r16 // r7 = 0x80000000 on carry, or else 0x00000000
+mulx_skip:
+
+ /*
+ * if (MSB of mul_multiplier == 1)
+ * {
+ * mul_product += multiplicand;
+ * }
+ */
+ bge r5,zero,mul_skip
+ add r9,r9,r3
+mul_skip:
+
+ /*
+ * mulxuu_product >>= 1; logical shift
+ * mul_multiplier <<= 1; done with MSB
+ * mulx_multiplier >>= 1; done with LSB
+ */
+ srli r10,r10,1
+ or r10,r10,r7 // OR in the saved carry bit.
+ slli r5,r5,1
+ srli r12,r12,1
+
+
+ /*
+ * }
+ */
+ subi r14,r14,1
+ bne r14,zero,multiply_loop
+
+
+ /*
+ * Multiply emulation loop done.
+ */
+
+ /* Now
+ * r3 = multiplicand
+ * r4 = OPX
+ * r6 = 4 * dest_register (used later as offset to sp)
+ * r7 = temp
+ * r9 = mul_product
+ * r10 = mulxuu_product
+ * r11 = original multiplier
+ */
+
+
+ // Calculate address for result from 4 * dest_register
+ add r6,r6,sp
+
+
+ /*
+ * Select/compute the result based on OPX.
+ */
+
+
+ // OPX == mul? Then store.
+ xori r7,r4,0x27
+ beq r7,zero,store_product
+
+ // It's one of the mulx.. opcodes. Move over the result.
+ mov r9,r10
+
+ // OPX == mulxuu? Then store.
+ xori r7,r4,0x07
+ beq r7,zero,store_product
+
+ // Compute mulxsu
+ //
+ // mulxsu = mulxuu - (rA < 0) ? rB : 0;
+ //
+ bge r3,zero,mulxsu_skip
+ sub r9,r9,r11
+mulxsu_skip:
+
+ // OPX == mulxsu? Then store.
+ xori r7,r4,0x17
+ beq r7,zero,store_product
+
+ // Compute mulxss
+ //
+ // mulxss = mulxsu - (rB < 0) ? rA : 0;
+ //
+ bge r11,zero,mulxss_skip
+ sub r9,r9,r3
+mulxss_skip:
+ // At this point, assume that OPX is mulxss, so store
+
+
+store_product:
+ stw r9,0(r6)
+
+
+restore_registers:
+ // No need to restore r0.
+ ldw r1, 4(sp)
+ ldw r2, 8(sp)
+ ldw r3, 12(sp)
+ ldw r4, 16(sp)
+ ldw r5, 20(sp)
+ ldw r6, 24(sp)
+ ldw r7, 28(sp)
+ ldw r8, 32(sp)
+ ldw r9, 36(sp)
+ ldw r10, 40(sp)
+ ldw r11, 44(sp)
+ ldw r12, 48(sp)
+ ldw r13, 52(sp)
+ ldw r14, 56(sp)
+ ldw r15, 60(sp)
+ ldw r16, 64(sp)
+ ldw r17, 68(sp)
+ ldw r18, 72(sp)
+ ldw r19, 76(sp)
+ ldw r20, 80(sp)
+ ldw r21, 84(sp)
+ ldw r22, 88(sp)
+ ldw r23, 92(sp)
+ ldw et, 96(sp)
+ ldw bt, 100(sp)
+ ldw gp, 104(sp)
+ // Don't corrupt sp.
+ ldw fp, 112(sp)
+ // Don't corrupt ea.
+ ldw ba, 120(sp)
+ ldw ra, 124(sp)
+ addi sp, sp, 128
+ eret
+
+.set at
+.set break
+
diff --git a/arch/nios2nommu/kernel/head.S b/arch/nios2nommu/kernel/head.S
new file mode 100644
index 0000000..f1cba65
--- /dev/null
+++ b/arch/nios2nommu/kernel/head.S
@@ -0,0 +1,228 @@
+/*
+ * head.S for Altera's Excalibur development board with nios processor
+ *
+ * (c) Vic Phillips, Microtronix Datacom Ltd., 2001
+ * (C) Copyright 2004 Microtronix Datacom Ltd
+ *
+ * Based on the following from the Excalibur sdk distribution:
+ * NA_MemoryMap.s, NR_JumpToStart.s, NR_Setup.s, NR_CWPManager.s
+ *
+ * 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.
+ *
+ * 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., 675
+ * Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <asm/asm-offsets.h>
+#include <asm/asm-macros.h>
+
+
+#ifdef CONFIG_CRC_CHECK
+/**********************************************/
+/* Define where the CRC table lives in flash. */
+/* The __CRC_Sector_Size is the flash sector */
+/* size for the address range. */
+/**********************************************/
+
+ GEQU __CRC_Table_Begin,(na_flash)+0x4000 /* Second sector of main board flash */
+ GEQU __CRC_Sector_Size,0x2000
+#endif
+
+/*
+ * This global variable is used as an extension to the nios'
+ * STATUS register to emulate a user/supervisor mode.
+ */
+ .data
+ .align 2
+ .set noat
+ .global status_extension
+status_extension:
+ .long 0
+
+ .global _current_thread
+_current_thread:
+ .long 0
+/*
+ * Input(s): passed from u-boot
+ * r4 - Optional pointer to a board information structure.
+ * r5 - Optional pointer to the physical starting address of the init RAM
+ * disk.
+ * r6 - Optional pointer to the physical ending address of the init RAM
+ * disk.
+ * r7 - Optional pointer to the physical starting address of any kernel
+ * command-line parameters.
+ */
+
+/*
+ * First executable code - detected and jumped to by the ROM bootstrap
+ * if the code resides in flash (looks for "Nios" at offset 0x0c from
+ * the potential executable image).
+ */
+ .text
+ .global _start
+_start:
+ wrctl status,r0 /* Disable interrupts */
+
+ /* Flush all cache lines within the instruction cache */
+
+ movia r1,NIOS2_ICACHE_SIZE
+ movui r2,NIOS2_ICACHE_LINE_SIZE
+
+text_flush:
+ flushi r1
+ sub r1,r1,r2
+ bgt r1,r0,text_flush
+ br 1f
+
+ /* This is the default location for the exception
+ * handler. Code in jump to our handler
+ */
+
+ movia r24,inthandler
+ jmp r24
+1:
+ /*
+ * After flushing the instruction cache, we must flush the data
+ * cache.
+ */
+
+ movia r1,NIOS2_DCACHE_SIZE
+ movi r2,NIOS2_DCACHE_LINE_SIZE
+
+data_flush:
+ flushd 0(r1)
+ sub r1,r1,r2
+ bgt r1,r0,data_flush
+
+NR_MoveStart:
+#ifdef CONFIG_BREAK_ON_START
+ break
+#endif //CONFIG_BREAK_ON_START
+ nextpc r1 /* Find out where we are */
+chkadr:
+ movia r2,chkadr
+ beq r1,r2,finish_move /* We are running in RAM done */
+ addi r1,r1,(_start - chkadr) /* Source */
+ movia r2,_start /* Destination */
+ movia r3,__bss_start /* End of copy */
+
+loop_move: // r1: src, r2: dest, r3: last dest
+ ldw r8,0(r1) // load a word from [r1]
+ stw r8,0(r2) // stort a word to dest [r2]
+ flushd 0(r2) // Flush cache for safty
+ addi r1,r1,4 // inc the src addr
+ addi r2,r2,4 // inc the dest addr
+ blt r2,r3,loop_move
+
+ movia r1,finish_move // VMA(_start)->l1
+ jmp r1 // jmp to _start
+
+finish_move:
+
+ //------------------------------------
+ // Disable interrupts on known devices
+ //
+#ifdef NA_ENET_ASM
+#ifdef NA_ENET_RESET_ASM
+ movia r1,NA_ENET_RESET_ASM // ethernet reset address
+ stwio r0,0(r1) // reset
+#endif
+#ifdef NA_ENET_RESET_N_ASM
+ movia r1,NA_ENET_RESET_N_ASM // ethernet reset address
+ stwio r0,0(r1) // reset
+#endif
+ nop // give it some time
+ nop //
+ nop //
+ nop //
+#endif
+#ifdef NA_TIMER0_ASM
+ movia r1,NA_TIMER0_ASM // get timer address
+ stwio r0,NP_TIMERCONTROL_ASM(r1) // clear interrupt enable
+ stwio r0,NP_TIMERSTATUS_ASM(r1) // clear interrupt condition
+#endif
+#ifdef NA_UART0_ASM
+ movia r1,NA_UART0_ASM
+ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
+ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
+#endif
+#ifdef NA_UART1_ASM
+ movia r1,NA_UART1_ASM
+ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
+ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
+#endif
+#ifdef NA_UART2_ASM
+ movia r1,NA_UART2_ASM
+ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
+ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
+#endif
+#ifdef NA_UART3_ASM
+ movia r1,NA_UART3_ASM
+ stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
+ stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
+#endif
+#ifdef NA_IDE_INTERFACE_ASM
+ movia r1,NA_IDE_INTERFACE_ASM // ATA reset
+ stwio r0,0(r1) // write to control register
+#endif
+#ifdef NA_ENET_ASM
+#ifdef NA_ENET_RESET_ASM
+ movia r1,NA_ENET_RESET_ASM // ethernet reset address
+ movui r2,1 // reset
+ stwio r2,0(r1) //
+#endif
+#ifdef NA_ENET_RESET_N_ASM
+ movia r1,NA_ENET_RESET_N_ASM // ethernet reset address
+ movui r2,1 // reset
+ stwio r2,0(r1) //
+#endif
+#endif
+ wrctl ienable,r0 // Mask off all possible interrupts
+
+ //------------------------------------------------------
+ // Zero out the .bss segment (uninitialized common data)
+ //
+ movia r2,__bss_start // presume nothing is between
+ movia r1,_end // the .bss and _end.
+1:
+ stb r0,0(r2)
+ addi r2,r2,1
+ bne r1,r2,1b
+
+ //------------------------------------------------------
+ // Call main() with interrupts disabled
+ //
+ movia r1,status_extension // get the STATUS extension address
+ movi r2,PS_S_ASM // set initial mode = supervisor
+ stw r2,0(r1)
+
+ movia r1,init_thread_union // set stack at top of the task union
+ addi sp,r1,THREAD_SIZE_ASM
+ movia r2,_current_thread // Remember current thread
+ stw r1,0(r2)
+
+ movia r1,nios2_boot_init // save args r4-r7 passed from u-boot
+ callr r1
+
+ movia r1,main // call main as a subroutine
+ callr r1
+
+ //------------------------------------------------------------------
+ // If we return from main, break to the oci debugger and buggered we are
+ //
+ break
+
+ /* End of startup code */
+.set at
+
+
diff --git a/arch/nios2nommu/kernel/init_task.c b/arch/nios2nommu/kernel/init_task.c
new file mode 100644
index 0000000..867e8fb
--- /dev/null
+++ b/arch/nios2nommu/kernel/init_task.c
@@ -0,0 +1,69 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/kernel/init_task.c
+ *
+ * Ported from arch/m68knommu/kernel/init_task.c
+ *
+ * Copyright (C) 2003, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/init.h>
+#include <linux/init_task.h>
+#include <linux/fs.h>
+#include <linux/mqueue.h>
+
+#include <asm/uaccess.h>
+#include <asm/pgtable.h>
+
+static struct fs_struct init_fs = INIT_FS;
+static struct files_struct init_files = INIT_FILES;
+static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
+static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
+struct mm_struct init_mm = INIT_MM(init_mm);
+
+EXPORT_SYMBOL(init_mm);
+
+/*
+ * Initial task structure.
+ *
+ * All other task structs will be allocated on slabs in fork.c
+ */
+__asm__(".align 2");
+struct task_struct init_task = INIT_TASK(init_task);
+
+
+/*
+ * Initial thread structure.
+ *
+ * We need to make sure that this is 8192-byte aligned due to the
+ * way process stacks are handled. This is done by having a special
+ * "init_task" linker map entry..
+ */
+union thread_union init_thread_union
+ __attribute__((__section__(".data.init_task"))) =
+ { INIT_THREAD_INFO(init_task) };
+
diff --git a/arch/nios2nommu/kernel/io.c b/arch/nios2nommu/kernel/io.c
new file mode 100644
index 0000000..e1b0b12
--- /dev/null
+++ b/arch/nios2nommu/kernel/io.c
@@ -0,0 +1,143 @@
+/*--------------------------------------------------------------------
+ *
+ * Optimized IO string functions.
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/io.h>
+
+void insl(unsigned long port, void *dst, unsigned long count)
+{
+ unsigned long read32;
+
+ if ((unsigned long)dst & 2){
+ /* Unaligned destination pointer, need to do
+ * two 16 bit writes for each read.
+ */
+ unsigned short *p=(unsigned short*)dst;
+ while (count--){
+ read32 = inl(port);
+ *p++ = read32 & 0xFFFF;
+ *p++ = read32 >> 16;
+ }
+ }
+ else {
+ unsigned long *p=(unsigned long*)dst;
+ while (count--)
+ *p++ = inl(port);
+ }
+}
+
+void insw(unsigned long port, void *dst, unsigned long count)
+{
+ unsigned long dst1=(unsigned long)dst;
+ if (count > 8) {
+ /* Long word align buffer ptr */
+ if (dst1 & 2) {
+ *(unsigned short*)dst1 = inw(port);
+ dst1 += sizeof(unsigned short);
+ count--;
+ }
+
+ /* Input pairs of short and store as longs */
+ while (count >= 8) {
+ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
+ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
+ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
+ *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
+ count -= 8;
+ }
+ }
+
+ /* Input remaining shorts */
+ while (count--) {
+ *((unsigned short *)dst1) = inw(port);
+ dst1 += sizeof(unsigned short);
+ }
+}
+
+
+void outsl(unsigned long port, void *src, unsigned long count)
+{
+ unsigned long src1=(unsigned long)src;
+ unsigned long write32;
+
+ if (src1 & 2){
+ /* Unaligned source pointer, need to read
+ * two 16 bit shorts before writing to register.
+ */
+ while (count--){
+ write32 = *(unsigned short *)src1;
+ src1+=sizeof(unsigned short);
+ write32 |= *((unsigned short *)src1) << 16;
+ src1+=sizeof(unsigned short);
+ outl(write32,port);
+ }
+ }
+ else {
+ while (count--) {
+ outl(*(unsigned long *)src1,port);
+ src1+=sizeof(unsigned long);
+ }
+ }
+}
+
+void outsw(unsigned long port, void *src, unsigned long count)
+{
+ unsigned int lw;
+ unsigned long src1=(unsigned long)src;
+
+ if (count > 8) {
+ /* Long word align buffer ptr */
+ if (src1 & 2) {
+ outw( *(unsigned short *)src1, port );
+ count--;
+ src1 += sizeof(unsigned short);
+ }
+
+ /* Read long words and output as pairs of short */
+ while (count >= 8) {
+ lw = *(unsigned long *)src1;
+ src1+=sizeof(unsigned long);
+ outw(lw, port);
+ outw((lw >> 16), port);
+ lw = *(unsigned long *)src1;
+ src1+=sizeof(unsigned long);
+ outw(lw, port);
+ outw((lw >> 16), port);
+ lw = *(unsigned long *)src1;
+ src1+=sizeof(unsigned long);
+ outw(lw, port);
+ outw((lw >> 16), port);
+ lw = *(unsigned long *)src1;
+ src1+=sizeof(unsigned long);
+ outw(lw, port);
+ outw((lw >> 16), port);
+ count -= 8;
+ }
+ }
+
+ /* Output remaining shorts */
+ while (count--) {
+ outw( *(unsigned short *)src1, port );
+ src1 += sizeof(unsigned short);
+ }
+}
diff --git a/arch/nios2nommu/kernel/irq.c b/arch/nios2nommu/kernel/irq.c
new file mode 100644
index 0000000..f1b2347
--- /dev/null
+++ b/arch/nios2nommu/kernel/irq.c
@@ -0,0 +1,245 @@
+/*
+ * linux/arch/$(ARCH)/irq.c -- general exception handling code
+ *
+ * Cloned from Linux/m68k.
+ *
+ * No original Copyright holder listed,
+ * Probabily original (C) Roman Zippel (assigned DJD, 1999)
+ *
+ * Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/kernel_stat.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/seq_file.h>
+
+#include <asm/system.h>
+#include <asm/irq.h>
+#include <asm/page.h>
+#include <asm/nios.h>
+#include <asm/hardirq.h>
+
+/* table for system interrupt handlers */
+irq_hand_t irq_list[NR_IRQS];
+
+/* The number of spurious interrupts */
+volatile unsigned int num_spurious;
+
+#define NUM_IRQ_NODES 16
+static irq_node_t nodes[NUM_IRQ_NODES];
+
+void __init init_irq_proc(void)
+{
+ /* Insert /proc/irq driver here */
+}
+
+static irqreturn_t default_irq_handler(int irq, void *ptr)
+{
+#if 1
+ printk(KERN_INFO "%s(%d): default irq handler vec=%d [0x%x]\n",
+ __FILE__, __LINE__, irq, irq);
+#endif
+ disable_irq(irq);
+ return(IRQ_NONE);
+}
+
+/*
+ * void init_IRQ(void)
+ *
+ * Parameters: None
+ *
+ * Returns: Nothing
+ *
+ * This function should be called during kernel startup to initialize
+ * the IRQ handling routines.
+ */
+
+void __init init_IRQ(void)
+{
+ int i;
+
+ for (i = 0; i < NR_IRQS; i++) {
+ irq_list[i].handler = default_irq_handler;
+ irq_list[i].flags = IRQ_FLG_STD;
+ irq_list[i].dev_id = NULL;
+ irq_list[i].devname = NULL;
+ }
+
+ for (i = 0; i < NUM_IRQ_NODES; i++)
+ nodes[i].handler = NULL;
+
+ /* turn off all interrupts */
+ clrimr(0);
+
+#ifdef DEBUG
+ printk("init_IRQ done\n");
+#endif
+}
+
+irq_node_t *new_irq_node(void)
+{
+ irq_node_t *node;
+ short i;
+
+ for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
+ if (!node->handler)
+ return node;
+
+ printk (KERN_INFO "new_irq_node: out of nodes\n");
+ return NULL;
+}
+
+int request_irq(unsigned int irq,
+ irq_handler_t handler,
+ unsigned long flags,
+ const char *devname,
+ void *dev_id)
+{
+ if (irq >= NR_IRQS) {
+ printk (KERN_ERR "%s: Unknown IRQ %d from %s\n", __FUNCTION__, irq, devname);
+ return -ENXIO;
+ }
+
+ if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
+ if (irq_list[irq].flags & IRQ_FLG_LOCK) {
+ printk(KERN_ERR "%s: IRQ %d from %s is not replaceable\n",
+ __FUNCTION__, irq, irq_list[irq].devname);
+ return -EBUSY;
+ }
+ if (flags & IRQ_FLG_REPLACE) {
+ printk(KERN_ERR "%s: %s can't replace IRQ %d from %s\n",
+ __FUNCTION__, devname, irq, irq_list[irq].devname);
+ return -EBUSY;
+ }
+ }
+ irq_list[irq].handler = handler;
+ irq_list[irq].flags = flags;
+ irq_list[irq].dev_id = dev_id;
+ irq_list[irq].devname = devname;
+
+ setimr(1<<irq);
+
+ return 0;
+}
+
+void free_irq(unsigned int irq, void *dev_id)
+{
+ if (irq >= NR_IRQS) {
+ printk (KERN_ERR "%s: Unknown IRQ %d\n", __FUNCTION__, irq);
+ return;
+ }
+
+ if (irq_list[irq].dev_id != dev_id)
+ printk(KERN_ERR "%s: Removing probably wrong IRQ %d from %s\n",
+ __FUNCTION__, irq, irq_list[irq].devname);
+
+ irq_list[irq].handler = default_irq_handler;
+ irq_list[irq].flags = IRQ_FLG_STD;
+ irq_list[irq].dev_id = NULL;
+ irq_list[irq].devname = NULL;
+
+ clrimr(~(1<<irq));
+}
+
+/* usually not useful in embedded systems */
+unsigned long probe_irq_on (void)
+{
+ return 0;
+}
+
+int probe_irq_off (unsigned long irqs)
+{
+ return 0;
+}
+
+void enable_irq(unsigned int irq)
+{
+ setimr(1<<irq);
+}
+
+void disable_irq(unsigned int irq)
+{
+ clrimr(~(1<<irq));
+}
+
+int show_interrupts(struct seq_file *p, void *v)
+{
+ int i = *(loff_t *) v;
+
+ if (i == 0) {
+ seq_printf(p, " : %10u spurious\n", num_spurious);
+ }
+
+ if ((i < NR_IRQS) && (!(irq_list[i].flags & IRQ_FLG_STD))) {
+ seq_printf(p, "%3d: %10u ", i, kstat_cpu(0).irqs[i]);
+ if (irq_list[i].flags & IRQ_FLG_LOCK)
+ seq_printf(p, "L ");
+ else
+ seq_printf(p, " ");
+ seq_printf(p, "%s\n", irq_list[i].devname);
+ }
+
+ return 0;
+}
+
+#ifdef CONFIG_PREEMPT_TIMES
+extern void latency_cause(int,int);
+#else
+#define latency_cause(a, b)
+#endif
+asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
+{
+
+ /* give the machine specific code a crack at it first */
+ irq_enter();
+ kstat_cpu(0).irqs[vec]++;
+ latency_cause(-99,~vec);
+
+ if (irq_list[vec].handler) {
+ if ((irq_list[vec].handler(vec, irq_list[vec].dev_id))==IRQ_NONE)
+ ;
+ } else
+#ifdef DEBUG
+ {
+ printk(KERN_ERR "No interrupt handler for level %ld\n", vec);
+//// asm("trap 5");
+ }
+#else
+ #if 1
+ printk(KERN_ERR "Ignoring interrupt %ld: no handler\n", vec);
+ #else
+ panic("No interrupt handler for level %ld\n", vec);
+ #endif
+#endif
+
+ irq_exit();
+}
+
+int get_irq_list(char *buf)
+{
+ int i, len = 0;
+
+ /* autovector interrupts */
+ for (i = 0; i < NR_IRQS; i++) {
+ if (irq_list[i].handler) {
+ len += sprintf(buf+len, "auto %2d: %10u ", i,
+ i ? kstat_cpu(0).irqs[i] : num_spurious);
+ if (irq_list[i].flags & IRQ_FLG_LOCK)
+ len += sprintf(buf+len, "L ");
+ else
+ len += sprintf(buf+len, " ");
+ len += sprintf(buf+len, "%s\n", irq_list[i].devname);
+ }
+ }
+ return len;
+}
+EXPORT_SYMBOL(request_irq);
+EXPORT_SYMBOL(free_irq);
diff --git a/arch/nios2nommu/kernel/module.c b/arch/nios2nommu/kernel/module.c
new file mode 100644
index 0000000..99b270f
--- /dev/null
+++ b/arch/nios2nommu/kernel/module.c
@@ -0,0 +1,173 @@
+/* Kernel module help for Nios2.
+ Copyright (C) 2004 Microtronix Datacom Ltd.
+ Copyright (C) 2001,03 Rusty Russell
+
+ 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.
+
+ 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
+
+ Written by Wentao Xu <xuwentao@microtronix.com>
+*/
+#include <linux/moduleloader.h>
+#include <linux/elf.h>
+#include <linux/vmalloc.h>
+#include <linux/fs.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+
+#if 0
+#define DEBUGP printk
+#else
+#define DEBUGP(fmt , ...)
+#endif
+
+void *module_alloc(unsigned long size)
+{
+ if (size == 0)
+ return NULL;
+ return vmalloc(size);
+}
+
+
+/* Free memory returned from module_alloc */
+void module_free(struct module *mod, void *module_region)
+{
+ vfree(module_region);
+ /* FIXME: If module_region == mod->init_region, trim exception
+ table entries. */
+}
+
+/* We don't need anything special. */
+int module_frob_arch_sections(Elf_Ehdr *hdr,
+ Elf_Shdr *sechdrs,
+ char *secstrings,
+ struct module *mod)
+{
+ return 0;
+}
+
+int apply_relocate(Elf32_Shdr *sechdrs,
+ const char *strtab,
+ unsigned int symindex,
+ unsigned int relsec,
+ struct module *me)
+{
+ printk(KERN_ERR "module %s: NO-ADD RELOCATION unsupported\n",
+ me->name);
+ return -ENOEXEC;
+}
+
+
+int apply_relocate_add (Elf32_Shdr *sechdrs, const char *strtab,
+ unsigned int symindex, unsigned int relsec,
+ struct module *mod)
+{
+ unsigned int i;
+ Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;
+
+ DEBUGP ("Applying relocate section %u to %u\n", relsec,
+ sechdrs[relsec].sh_info);
+
+ for (i = 0; i < sechdrs[relsec].sh_size / sizeof (*rela); i++) {
+ /* This is where to make the change */
+ uint32_t word;
+ uint32_t *loc
+ = ((void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+ + rela[i].r_offset);
+ /* This is the symbol it is referring to. Note that all
+ undefined symbols have been resolved. */
+ Elf32_Sym *sym
+ = ((Elf32_Sym *)sechdrs[symindex].sh_addr
+ + ELF32_R_SYM (rela[i].r_info));
+ uint32_t v = sym->st_value + rela[i].r_addend;
+
+ switch (ELF32_R_TYPE (rela[i].r_info)) {
+ case R_NIOS2_NONE:
+ break;
+
+ case R_NIOS2_BFD_RELOC_32:
+ *loc += v;
+ break;
+
+ case R_NIOS2_PCREL16:
+ v -= (uint32_t)loc + 4;
+ if ((int32_t)v > 0x7fff ||
+ (int32_t)v < -(int32_t)0x8000) {
+ printk(KERN_ERR
+ "module %s: relocation overflow\n",
+ mod->name);
+ return -ENOEXEC;
+ }
+ word = *loc;
+ *loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) | (word & 0x3f);
+ break;
+
+ case R_NIOS2_CALL26:
+ if (v & 3) {
+ printk(KERN_ERR
+ "module %s: dangerous relocation\n",
+ mod->name);
+ return -ENOEXEC;
+ }
+ if ((v >> 28) != ((uint32_t)loc >> 28)) {
+ printk(KERN_ERR
+ "module %s: relocation overflow\n",
+ mod->name);
+ return -ENOEXEC;
+ }
+ *loc = (*loc & 0x3f) | ((v >> 2) << 6);
+ break;
+
+ case R_NIOS2_HI16:
+ word = *loc;
+ *loc = ((((word >> 22) << 16) | ((v >>16) & 0xffff)) << 6) |
+ (word & 0x3f);
+ break;
+
+ case R_NIOS2_LO16:
+ word = *loc;
+ *loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) |
+ (word & 0x3f);
+ break;
+
+ case R_NIOS2_HIADJ16:
+ {
+ Elf32_Addr word2;
+
+ word = *loc;
+ word2 = ((v >> 16) + ((v >> 15) & 1)) & 0xffff;
+ *loc = ((((word >> 22) << 16) | word2) << 6) |
+ (word & 0x3f);
+ }
+ break;
+
+ default:
+ printk (KERN_ERR "module %s: Unknown reloc: %u\n",
+ mod->name, ELF32_R_TYPE (rela[i].r_info));
+ return -ENOEXEC;
+ }
+ }
+
+ return 0;
+}
+
+int module_finalize(const Elf_Ehdr *hdr,
+ const Elf_Shdr *sechdrs,
+ struct module *me)
+{
+ return 0;
+}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff --git a/arch/nios2nommu/kernel/nios2_ksyms.c b/arch/nios2nommu/kernel/nios2_ksyms.c
new file mode 100644
index 0000000..720f007
--- /dev/null
+++ b/arch/nios2nommu/kernel/nios2_ksyms.c
@@ -0,0 +1,113 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/kernel/nios_ksyms.c
+ *
+ * Derived from Nios1
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * vic - copied from v850
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+//;dgt2;tmp;
+
+#include <linux/module.h>
+#include <linux/linkage.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/user.h>
+#include <linux/elfcore.h>
+#include <linux/in6.h>
+#include <linux/interrupt.h>
+
+#include <asm/setup.h>
+#include <asm/pgalloc.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/semaphore.h>
+#include <asm/checksum.h>
+#include <asm/hardirq.h>
+#include <asm/current.h>
+
+extern void dump_thread(struct pt_regs *, struct user *);
+/* platform dependent support */
+
+EXPORT_SYMBOL(__ioremap);
+EXPORT_SYMBOL(iounmap);
+EXPORT_SYMBOL(dump_fpu);
+EXPORT_SYMBOL(dump_thread);
+
+EXPORT_SYMBOL(kernel_thread);
+
+/* Networking helper routines. */
+EXPORT_SYMBOL(csum_partial_copy);
+
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memset);
+EXPORT_SYMBOL(memmove);
+
+EXPORT_SYMBOL(__down);
+EXPORT_SYMBOL(__down_interruptible);
+EXPORT_SYMBOL(__down_trylock);
+EXPORT_SYMBOL(__up);
+
+EXPORT_SYMBOL(get_wchan);
+
+/*
+ * libgcc functions - functions that are used internally by the
+ * compiler... (prototypes are not correct though, but that
+ * doesn't really matter since they're not versioned).
+ */
+extern void __gcc_bcmp(void);
+extern void __ashldi3(void);
+extern void __ashrdi3(void);
+extern void __cmpdi2(void);
+extern void __divdi3(void);
+extern void __divsi3(void);
+extern void __lshrdi3(void);
+extern void __moddi3(void);
+extern void __modsi3(void);
+extern void __muldi3(void);
+extern void __mulsi3(void);
+extern void __negdi2(void);
+extern void __ucmpdi2(void);
+extern void __udivdi3(void);
+extern void __udivmoddi4(void);
+extern void __udivsi3(void);
+extern void __umoddi3(void);
+extern void __umodsi3(void);
+
+ /* gcc lib functions */
+EXPORT_SYMBOL(__gcc_bcmp);
+EXPORT_SYMBOL(__ashldi3);
+EXPORT_SYMBOL(__ashrdi3);
+EXPORT_SYMBOL(__cmpdi2);
+EXPORT_SYMBOL(__divdi3);
+EXPORT_SYMBOL(__divsi3);
+EXPORT_SYMBOL(__lshrdi3);
+EXPORT_SYMBOL(__moddi3);
+EXPORT_SYMBOL(__modsi3);
+EXPORT_SYMBOL(__muldi3);
+EXPORT_SYMBOL(__mulsi3);
+EXPORT_SYMBOL(__negdi2);
+EXPORT_SYMBOL(__ucmpdi2);
+EXPORT_SYMBOL(__udivdi3);
+EXPORT_SYMBOL(__udivmoddi4);
+EXPORT_SYMBOL(__udivsi3);
+EXPORT_SYMBOL(__umoddi3);
+EXPORT_SYMBOL(__umodsi3);
diff --git a/arch/nios2nommu/kernel/nios_gdb_stub.c b/arch/nios2nommu/kernel/nios_gdb_stub.c
new file mode 100644
index 0000000..103925b
--- /dev/null
+++ b/arch/nios2nommu/kernel/nios_gdb_stub.c
@@ -0,0 +1,1456 @@
+// Modified for uClinux - Vic - Apr 2002
+// From:
+
+// File: nios_gdb_stub.c
+// Date: 2000 June 20
+// Author dvb \ Altera Santa Cruz
+
+#ifndef __KERNEL__
+#include "nios.h"
+#else
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <asm/nios.h>
+#endif
+
+#include "nios_gdb_stub.h"
+
+#define na_debug_peripheral_irq 8
+
+enum
+{
+ na_BreakpointTrap = 3,
+ na_SingleStepTrap = 4,
+ na_StartGDBTrap = 5
+};
+
+
+#ifdef __KERNEL__
+
+extern int _etext;
+
+static void puts( unsigned char *s )
+{
+ while(*s) {
+ while (!(nasys_printf_uart->np_uartstatus & np_uartstatus_trdy_mask));
+ nasys_printf_uart->np_uarttxdata = *s++;
+ }
+}
+
+#endif // __KERNEL__
+
+// --------------------------------
+// Local Prototypes
+
+#if GDB_DEBUG_PRINT
+
+static void StringFit(char *s,int w);
+
+// --------------------------------
+// Debugging The Debugger
+
+void GDB_RawMessage(char *s)
+ {
+ StringFit(s,32);
+ nr_pio_lcdwritescreen(s);
+ }
+#else
+ #define GDB_RawMessage(a,b,c) // define away to nothing
+#endif
+
+#if GDB_DEBUG_PRINT
+void GDB_Print2(char *s,int n1,int n2)
+ {
+ char st[1000];
+
+ sprintf(st,s,n1,n2);
+ GDB_RawMessage(st);
+ }
+#else
+ #define GDB_Print2(a,b,c) // define away to nothing
+#endif
+
+// If string is longer than w, cut out the middle.
+
+#if GDB_DEBUG_PRINT
+int StringLen(char *s)
+ {
+ int l = 0;
+
+ while(*s++)
+ l++;
+ return l;
+ }
+
+static void StringFit(char *s,int w)
+ {
+ if(StringLen(s) > w)
+ {
+ int i;
+
+
+ w = w / 2;
+
+ for(i = 0; i < w; i++)
+ {
+ s[i + w] = s[StringLen(s) - w + i];
+ }
+ s[w + w] = 0;
+ }
+ }
+#endif
+
+// ---------------------------------------------
+// Generic routines for dealing with
+// hex input, output, and parsing
+// (Adapted from other stubs.)
+
+NiosGDBGlobals gdb = {0}; // not static: the ISR uses it!
+
+static char dHexChars[16] = "0123456789abcdef";
+
+/*
+ * HexCharToValue -- convert a characters
+ * to its hex value, or -1 if not.
+ */
+char HexCharToValue(char c)
+{
+ char result=0;
+
+ if(c >= '0' && c <= '9')
+ result = c - '0';
+ else if(c >= 'a' && c <= 'f')
+ result = c - 'a' + 10;
+ else if(c >= 'A' && c <= 'F')
+ result = c - 'A' + 10;
+ else
+ result = -1;
+ return result;
+}
+
+/*
+ * HexStringToValue -- convert a 2*byte_width string of characters
+ * to its little endian hex value,
+ * or -1 if not.
+ * This routine is for strings of hex values
+ */
+unsigned long HexStringToValue(char *c, int byte_width)
+{
+ unsigned long result=0;
+ unsigned char a,b;
+ int i=0;
+
+ while (i < byte_width)
+ {
+ a = HexCharToValue(*c++);
+ if (a & 0x80) return a;
+ b = HexCharToValue(*c++);
+ if (b & 0x80) return b;
+ b = (a<<4) | (b&0x0f);
+ result |= b << (i*8);
+ i++;
+ }
+ return result;
+}
+
+/*
+ * Hex2Value -- convert a non-hex char delimited string
+ * to its big endian hex value.
+ * This routine is for address and byte count values
+ */
+
+char *Hex2Value(char *hexIn, int *valueOut)
+ {
+ char c;
+ int digitValue;
+ int value = 0;
+
+ while(1)
+ {
+ c = *hexIn;
+ digitValue = HexCharToValue(c);
+ if(digitValue < 0)
+ {
+ *valueOut = value;
+ return hexIn;
+ }
+ hexIn++;
+ value = (value << 4) + digitValue;
+ }
+ }
+
+/*
+ * HexToMem -- convert a string to a specified
+ * number of bytes in memory.
+ *
+ * JMB -- make this thing a bit smarter so
+ * that it selects the byte width to
+ * write based on the number of bytes
+ * and the destination address alignment.
+ * This is to support writes to non-byte enabled
+ * peripheral registers...I don't like it.
+ * Beware! there are cases where it wont work
+ */
+char *HexToMem(char *hexIn, char *memOut, int memByteCount)
+{
+ int i;
+ unsigned long x;
+ short *memOutS=0;
+ long *memOutL=0;
+ int byte_width;
+
+ //determine maximum byte width
+ if (((memByteCount%2) != 0) || (((unsigned int)memOut%2) != 0))
+ byte_width = 1;
+ else if (((memByteCount % 4) != 0) || (((unsigned int)memOut % 4) != 0))
+ {
+ byte_width = 2;
+ memOutS = (short *)memOut;
+ }
+ else
+ {
+ byte_width = 4;
+ memOutL = (long *)memOut;
+ }
+ for(i = 0; i < memByteCount; i+=byte_width)
+ {
+ x = HexStringToValue(hexIn,byte_width);
+ hexIn += byte_width*2;
+ switch (byte_width)
+ {
+ case 1:
+ *memOut++ = (unsigned char) 0x000000ff & x;
+ break;
+ case 2:
+ *memOutS++ = (unsigned short) 0x0000ffff & x;
+ break;
+ case 4:
+ *memOutL++ = x;
+ break;
+ default:
+ //How could this ever happen???
+ break;
+ }
+ }
+
+ return hexIn;
+}
+
+char *MemToHex(char *memIn, char *hexOut, int memByteCount)
+{
+ int i,j;
+ int byte_width;
+ unsigned long x=0;
+ unsigned short *memInS=0;
+ unsigned long *memInL=0;
+
+ //determine maximum byte width
+ if (((memByteCount % 2) != 0) || (((unsigned int)memIn % 2) != 0))
+ byte_width = 1;
+ else if (((memByteCount % 4) != 0) || (((unsigned int)memIn % 4) != 0))
+ {
+ byte_width = 2;
+ memInS = (short *)memIn;
+ }
+ else
+ {
+ byte_width = 4;
+ memInL = (long *)memIn;
+ }
+
+ for(i = 0; i < memByteCount; i+=byte_width)
+ {
+ switch (byte_width)
+ {
+ case 1:
+ x = *memIn++;
+ break;
+ case 2:
+ x = *memInS++;
+ break;
+ case 4:
+ x = *memInL++;
+ break;
+ default:
+ //How would we get here?
+ break;
+ }
+
+ for (j=0; j<byte_width; j++)
+ {
+ *hexOut++ = dHexChars[(x&0x000000f0)>>4];
+ *hexOut++ = dHexChars[x&0x0000000f];
+ x = x>>8;
+ }
+ }
+
+ *hexOut = 0;
+
+ return hexOut;
+}
+
+//Send just the + or - to indicate
+//ACK or NACK
+void GDBPutAck (char ack)
+{
+ if (gdb.comlink == ne_gdb_serial)
+ GDBPutChar (ack);
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+ else
+ {
+ if (gdb.host_ip_address != 0)
+ nr_plugs_send_to (gdb.gdb_eth_plug, &ack, 1, 0,
+ gdb.host_ip_address,
+ gdb.host_port_number);
+ }
+#endif
+#endif
+}
+
+/*
+ * Once a $ comes in, use GetGDBPacket to
+ * retrieve a full gdb packet, and verify
+ * checksum, and reply + or -.
+ */
+int GetGDBPacket(char *aBuffer)
+{
+ int checksum=0;
+ int length=0;
+ char c;
+ int x=0;
+
+ if (gdb.comlink == ne_gdb_serial)
+ {
+ while ((c = GDBGetChar ()) != '$') ;
+
+startPacket:
+ length = 0;
+ checksum = 0;
+ while(((c = GDBGetChar()) != '#') && (length < kTextBufferSize))
+ {
+ if(c == '$')
+ goto startPacket;
+ checksum += c;
+ aBuffer[length++] = c;
+ aBuffer[length] = 0;
+ }
+
+ c = GDBGetChar();
+ x = HexCharToValue(c) << 4;
+ c = GDBGetChar();
+ x += HexCharToValue(c);
+
+
+ checksum &= 0xff;
+
+ GDB_Print2("GetPacket %d",length,0);
+ }
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+ else
+ {
+ int srcidx;
+ // wait till beginning of packet
+ while (gdb.textBuffer[0] != '$') nr_plugs_idle();
+startEPacket:
+ length = 0;
+ checksum = 0;
+ srcidx = 1;
+
+ //loop until packet terminator
+ //leave enough room for the checksum at the end
+ while (((c = gdb.textBuffer[srcidx++]) != '#') && (srcidx < kTextBufferSize-2))
+ {
+ if (c == '$')
+ goto startEPacket;
+
+ checksum += c;
+ aBuffer[length++] = c;
+ }
+
+ c = gdb.textBuffer[srcidx++];
+ x = HexCharToValue(c) << 4;
+ c = gdb.textBuffer[srcidx++];
+ x += HexCharToValue (c);
+
+ aBuffer[length++] = 0;
+
+ checksum &= 0xff;
+
+ GDB_Print2("GetPacket %d",length,0);
+ }
+#endif
+#endif
+
+ if(checksum != x)
+ {
+ GDBPutAck('-');
+ length = 0;
+ }
+ else
+ {
+ GDBPutAck('+');
+ }
+ return length;
+}
+
+//Wait for acknowledgement
+//Should we have some way of timing out???
+//return TRUE if ACK
+//return FALSE if NACK
+int GDBGetACK (void)
+{
+ char c;
+ if (gdb.comlink == ne_gdb_serial)
+ {
+ while (1)
+ {
+ c = GDBGetChar ();
+ if (c == '+') return (1);
+ else if (c == '-') return (0);
+ }
+
+ }
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+ else
+ {
+ gdb.ACKstatus = ne_gdb_ack_waiting;
+ while (1)
+ {
+ nr_plugs_idle ();
+ if (gdb.ACKstatus == ne_gdb_ack_acked)
+ {
+ gdb.ACKstatus = ne_gdb_ack_notwaiting;
+ return (1);
+ }
+ else if (gdb.ACKstatus == ne_gdb_ack_nacked)
+ {
+ gdb.ACKstatus = ne_gdb_ack_notwaiting;
+ return (0);
+ }
+ }
+ }
+#endif
+#endif
+ return(0);
+}
+
+/*
+ * Send a packet, preceded by $,
+ * and followed by #checksum.
+ */
+void PutGDBPacket(char *aBuffer)
+{
+ int checksum;
+ char c;
+ char *origPtr;
+ int cnt=0;
+
+ origPtr = aBuffer; // Remember in case we get a NACK
+ if (gdb.comlink == ne_gdb_serial)
+ {
+startPutSerial:
+ GDBPutChar('$');
+ checksum = 0;
+ while((c = *aBuffer++) != 0)
+ {
+ checksum += c;
+ GDBPutChar(c);
+ }
+ GDBPutChar('#');
+ GDBPutChar(dHexChars[(checksum >> 4) & 15]);
+ GDBPutChar(dHexChars[checksum & 15]);
+
+ if (!GDBGetACK ())
+ {
+ aBuffer = origPtr;
+ if (++cnt < GDB_RETRY_CNT) goto startPutSerial;
+ }
+ }
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+ else
+ {
+ if (gdb.host_ip_address != 0)
+ {
+ int i;
+ int result;
+ char c1;
+
+ i = 0;
+ c = aBuffer[i];
+ if (c==0) return; //there is no data in packet, so why bother sending
+ aBuffer[i++] = '$';
+ checksum = 0;
+ do
+ {
+ checksum += c;
+ c1 = aBuffer[i];
+ aBuffer[i++] = c;
+ c = c1;
+ } while (c != 0);
+
+ aBuffer[i++] = '#';
+ aBuffer[i++] = dHexChars[(checksum >> 4) & 15];
+ aBuffer[i++] = dHexChars[checksum & 15];
+ aBuffer[i++] = 0;
+startPutEth:
+ result = nr_plugs_send_to (gdb.gdb_eth_plug, aBuffer, i, 0,
+ gdb.host_ip_address,
+ gdb.host_port_number);
+
+ if (!GDBGetACK ())
+ {
+ if (++cnt < GDB_RETRY_CNT) goto startPutEth;
+ }
+ aBuffer[0] = 0; //clear packet to
+ }
+ }
+#endif
+#endif
+}
+
+int PutTracePacket(char *aBuffer, int size)
+{
+ int checksum;
+#ifdef ethernet_exists
+ char c;
+#endif
+ int i;
+ int cnt=0;
+
+ if (gdb.comlink == ne_gdb_serial)
+ {
+startPutSerial:
+ GDBPutChar('$');
+ checksum = 0;
+ for (i=0; i<size; i++)
+ {
+ checksum += aBuffer[i];
+ GDBPutChar (aBuffer[i]);
+ }
+ GDBPutChar('#');
+ GDBPutChar(dHexChars[(checksum >> 4) & 15]);
+ GDBPutChar(dHexChars[checksum & 15]);
+
+ if (!GDBGetACK ())
+ {
+ if (++cnt < GDB_RETRY_CNT) goto startPutSerial;
+ }
+ }
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+ else
+ {
+ int result;
+ char c1;
+
+ checksum = 0;
+ c = '$';
+ for (i=0; i<size; i++)
+ {
+ checksum += aBuffer[i];
+ c1 = aBuffer[i];
+ aBuffer[i] = c;
+ c = c1;
+ }
+ aBuffer[i++] = c;
+
+ aBuffer[i++] = '#';
+ aBuffer[i++] = dHexChars[(checksum >> 4) & 15];
+ aBuffer[i++] = dHexChars[checksum & 15];
+ aBuffer[i++] = 0;
+ethResend:
+ if (gdb.host_ip_address != 0)
+ {
+ result = nr_plugs_send_to (gdb.gdb_eth_plug, aBuffer, i, 0,
+ gdb.host_ip_address,
+ gdb.host_port_number);
+ }
+ if (!GDBGetACK ())
+ {
+ if (++cnt < GDB_RETRY_CNT) goto ethResend;
+ }
+ aBuffer[0]=0;
+ }
+#endif
+#endif
+ if (cnt < GDB_RETRY_CNT) return 1;
+ else return 0;
+}
+
+void PutGDBOKPacket(char *aBuffer)
+ {
+ aBuffer[0] = 'O';
+ aBuffer[1] = 'K';
+ aBuffer[2] = 0;
+ PutGDBPacket(aBuffer);
+ }
+
+#if nasys_debug_core
+
+//some defines used exclusively for TRACE data xfer
+//stepsize is the ascii hex step value i.e. twice the binary length
+#define stepsize (2*(2*sizeof(int) + sizeof (char)))
+#define MAX_TRACE_BYTES (((int)((2*MAX_DATA_SIZE-2)/stepsize))*stepsize)
+
+int Trace_Read_Intercept (char *aBuffer)
+{
+ int cnt=0;
+ unsigned int data;
+ unsigned char code;
+ int byteCount;
+ unsigned char *w;
+ unsigned short dataAccumulate;
+ int status;
+
+ w = aBuffer;
+ w++; //skip past the m
+ if (*w++ == 't') //see if this is a special "memory trace" packet
+ {
+ w = Hex2Value(w,&byteCount); //get the number of bytes to transfer
+
+ //turn byteCount to a multiple of stepsize
+ byteCount = ((int)(byteCount/stepsize))*stepsize;
+
+ //wait until fifo empties
+ nm_debug_get_reg(status, np_debug_write_status);
+ while (status&np_debug_write_status_writing_mask) nm_debug_get_reg(status,np_debug_write_status);
+
+ // loop through total size
+ while (byteCount > 0)
+ {
+ w=aBuffer; //reset w to beginning of buffer
+
+ //calculate the number of bytes in this packet
+ if (byteCount > MAX_TRACE_BYTES) dataAccumulate = MAX_TRACE_BYTES;
+ else dataAccumulate = byteCount;
+
+ //insert data size at beginning of packet
+ w = MemToHex((char *)&dataAccumulate, w, sizeof (dataAccumulate));
+
+ byteCount -= dataAccumulate; //decrement byteCount
+
+ // accumulate a full buffer
+ for (cnt=0; cnt<dataAccumulate; cnt+=stepsize)
+ {
+ int valid;
+ nm_debug_set_reg (1, np_debug_read_sample); //begin transaction
+
+ //wait until data is ready
+ nm_debug_get_reg (valid, np_debug_data_valid);
+ while (!valid) nm_debug_get_reg(valid,np_debug_data_valid) ;
+
+ nm_debug_get_reg (data, np_debug_trace_address);
+ w = MemToHex ((char *)&data, w, sizeof (int));
+
+ nm_debug_get_reg (data, np_debug_trace_data);
+ w = MemToHex ((char *)&data, w, sizeof (int));
+
+ nm_debug_get_reg (data, np_debug_trace_code);
+ w = MemToHex ((char *)&data, w, sizeof (char));
+ }
+
+ //if one of our data packets doesn't make it, stop sending them
+ //if (PutTracePacket (aBuffer,dataAccumulate+4) != 1) //+4 for size filed
+ // byteCount = 0;
+ /* kenw - My module can't handle the incoming data fast enough. So
+ * send this one packet, and wait for another mt command.
+ */
+ PutTracePacket (aBuffer,dataAccumulate+4);
+ byteCount = 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+#undef stepsize
+#undef MAX_TRACE_BYTES
+*/
+
+#endif
+
+void DoGDBCommand_m(char *aBuffer)
+ {
+ char *w;
+ int startAddr,byteCount;
+
+#if nasys_debug_core
+ /* intercept some access to the dbg peripheral */
+ if (Trace_Read_Intercept (aBuffer)) return;
+#endif
+
+ w = aBuffer;
+ w++; // past 'm'
+ w = Hex2Value(w,&startAddr);
+ w++; // past ','
+ w = Hex2Value(w,&byteCount);
+
+ if (byteCount > MAX_DATA_SIZE) byteCount = MAX_DATA_SIZE;
+
+ // mA,L -- request memory
+ w = aBuffer;
+ w = MemToHex((char *)startAddr,w,byteCount);
+ PutGDBPacket(aBuffer);
+ }
+
+void DoGDBCommand_M(char *aBuffer)
+ {
+ char *w;
+ int startAddr,byteCount;
+
+ w = aBuffer;
+ w++; // past 'M'
+ w = Hex2Value(w,&startAddr);
+ w++; // past ','
+ w = Hex2Value(w,&byteCount);
+ w++; // past ':'
+
+ GDB_Print2("M from %x to %x",startAddr,byteCount);
+
+ // MA,L:values -- write to memory
+
+ w = HexToMem(w,(char *)startAddr,byteCount);
+
+ // Send "OK"
+ PutGDBOKPacket(aBuffer);
+ }
+
+int Debug_Read_Intercept (char *aBuffer)
+{
+ unsigned int data;
+ int index;
+ unsigned char *w;
+
+ w = aBuffer;
+ w++; //skip past the g
+ if (*w++ == 'g') //see if this is a special "register read" packet
+ {
+ w = Hex2Value(w,&index); //get the index of the register to be read
+
+ nm_debug_get_reg (data, index);
+
+ //assemble the output packet
+ w=aBuffer; //reset w to beginning of buffer
+ w = MemToHex((char *)&data, w, sizeof (data));
+ *w++ = 0;
+
+ //now send it
+ PutTracePacket (aBuffer,sizeof (data) * 2);
+
+ return 1;
+ }
+ return 0;
+}
+
+// Return the values of all the registers
+void DoGDBCommand_g(NiosGDBGlobals *g)
+ {
+ char *w;
+
+ if (Debug_Read_Intercept (g->textBuffer)) return;
+
+ w = g->textBuffer;
+
+ w = MemToHex((char *)(&g->registers),w,sizeof(g->registers));
+ PutGDBPacket(g->textBuffer);
+ GDB_Print2("Sent Registers",0,0);
+ }
+
+int Debug_Write_Intercept (char *aBuffer)
+{
+ unsigned int data;
+ int index;
+ unsigned char *w;
+
+ w = aBuffer;
+ w++; //skip past the g
+ if (*w++ == 'g') //see if this is a special "register read" packet
+ {
+ w = Hex2Value(w,&index); //get the index of the register to be written
+ w++; // past ','
+ w = Hex2Value(w,&data);
+
+ nm_debug_set_reg (data, index);
+
+ //now send it
+ // Send "OK"
+ PutGDBOKPacket(aBuffer);
+
+ return 1;
+ }
+ return 0;
+}
+
+void DoGDBCommand_G(NiosGDBGlobals *g)
+ {
+ char *w;
+
+ if (Debug_Write_Intercept (g->textBuffer)) return;
+
+ w = g->textBuffer;
+ w++; // skip past 'G'
+ w = HexToMem(w,(char *)(&g->registers), sizeof(g->registers) );
+
+ // Send "OK"
+ PutGDBOKPacket(g->textBuffer);
+
+ GDB_Print2("Received Registers",0,0);
+ }
+
+// Return last signal value
+void DoGDBCommand_qm(NiosGDBGlobals *g)
+ {
+ char *w;
+
+ w = g->textBuffer;
+
+ *w++ = 'S';
+ *w++ = '2';
+ *w++ = '3'; // make up a signal for now...
+ *w++ = 0;
+ PutGDBPacket(g->textBuffer);
+ }
+
+void DoGDBCommand_q(NiosGDBGlobals *g)
+{
+#ifdef na_ssram_detect_in
+ short int* ssram_exists;
+#endif
+ char *w;
+ w = g->textBuffer;
+
+ w++; /* skip past the q */
+ switch (*w) {
+ case ('A'):
+ w = g->textBuffer;
+
+ /* handle intialization information */
+ /* is nios_ocd available? */
+#ifdef nasys_debug_core
+ *w++ = nasys_debug_core + '0';
+#else
+ *w++ = '0';
+#endif
+ *w++ = ',';
+
+ /* determine if the SSRAM debugger board is
+ * physically present */
+#ifdef na_ssram_detect_in
+ ssram_exists = (short int*) na_ssram_detect_in;
+ *w++ = !(*ssram_exists) + '0';
+#else
+ *w++ = '0';
+#endif
+ *w++ = ',';
+
+ /* print out the max size of a trace packet */
+#if nasys_debug_core
+ sprintf (w, "%04x", MAX_TRACE_BYTES);
+#else
+ sprintf (w, "0000");
+#endif
+
+ break;
+ case ('B'):
+ w = g->textBuffer;
+
+ /* returns 1 if it was an OCD interrupt
+ * returns 0 if it was software breakpoint */
+ if (gdb.trapNumber == nasys_debug_core_irq) {
+ *w++ = '1';
+ } else {
+ *w++ = '0';
+ }
+
+ *w++ = 0;
+ break;
+ default:
+ w = g->textBuffer;
+
+ *w = 0;
+ break;
+ }
+
+ PutGDBPacket(g->textBuffer);
+}
+
+
+void GDBInsertBreakpoint(NiosGDBGlobals *g,short *address)
+ {
+ NiosGDBBreakpoint *b;
+
+ GDB_Print2("breakpoint 0x%x",(int)address,0);
+ if(g->breakpointCount < kMaximumBreakpoints)
+ {
+ b = &g->breakpoint[g->breakpointCount++];
+ b->address = address;
+ b->oldContents = *b->address;
+ *b->address = 0x7904;
+ }
+ }
+
+void GDBRemoveBreakpoints(NiosGDBGlobals *g)
+ {
+ NiosGDBBreakpoint *b;
+ int i;
+
+ for(i = 0; i < g->breakpointCount; i++)
+ {
+ b = &g->breakpoint[i];
+ *b->address = b->oldContents;
+ b->address = 0;
+ }
+
+ g->breakpointCount = 0;
+ }
+
+int NiosInstructionIsTrap5(unsigned short instruction)
+ {
+ return instruction == 0x7905;
+ }
+
+int NiosInstructionIsPrefix(unsigned short instruction)
+ {
+ return (instruction >> 11) == 0x13;
+ }
+
+int NiosInstructionIsSkip(unsigned short instruction)
+ {
+ int op6;
+ int op11;
+
+ op6 = (instruction >> 10);
+ op11 = (instruction >> 5);
+
+ return (op6 == 0x14 // SKP0
+ || op6 == 0x15 // SKP1
+ || op11 == 0x3f6 // SKPRz
+ || op11 == 0x3f7 // SKPS
+ || op11 == 0x3fa); // SKPRnz
+ }
+
+int NiosInstructionIsBranch(unsigned short instruction,short *pc,short **branchTargetOut)
+ {
+ int op4;
+ int op7;
+ int op10;
+ short *branchTarget = 0;
+ int result = 0;
+
+ op4 = (instruction >> 12);
+ op7 = (instruction >> 9);
+ op10 = (instruction >> 6);
+
+ if(op4 == 0x08) // BR, BSR
+ {
+ int offset;
+
+ result = 1;
+ offset = instruction & 0x07ff;
+ if(offset & 0x400) // sign extend
+ offset |= 0xffffF800;
+ branchTarget = pc + offset + 1; // short * gets x2 scaling automatically
+ }
+ else if(op10 == 0x1ff) // JMP, CALL
+ {
+ result = 1;
+ branchTarget = (short *)(gdb.registers.r[instruction & 31] * 2);
+ }
+ else if(op7 == 0x3d) // JMPC, CALLC
+ {
+ result = 1;
+ branchTarget = pc + 1 + (instruction & 0x0ffff);
+#ifdef __nios32__
+ branchTarget = (short *)((int)branchTarget & 0xffffFFFc); // align 32...
+#else
+ branchTarget = (short *)((int)branchTarget & 0xFFFe); // align 16...
+#endif
+ branchTarget = (short *)(*(int *)branchTarget);
+ }
+
+ if(branchTargetOut)
+ *branchTargetOut = branchTarget;
+
+ return result;
+ }
+
+// -------------------------
+// Step at address
+//
+// "stepping" involves inserting a
+// breakpoint at some reasonable
+// spot later than the current program
+// counter
+//
+// On the Nios processor, this is
+// nontrivial. For example, we should
+// not break up a PFX instruction.
+
+void DoGDBCommand_s(NiosGDBGlobals *g)
+ {
+ char *w;
+ int x;
+ short *pc;
+ short *branchTarget;
+ unsigned short instruction;
+ int stepType;
+
+ /*
+ * First, if there's an argument to the packet,
+ * set the new program-counter value
+ */
+
+ w = g->textBuffer;
+ w++;
+ if(HexCharToValue(*w) >= 0)
+ {
+ w = Hex2Value(w,&x);
+ g->registers.pc = x;
+ }
+
+ /*
+ * Scan forward to see what the
+ * most appropriate location(s) for
+ * a breakpoint will be.
+ *
+ * The rules are:
+ * 1. If *pc == PFX, break after modified instruction.
+ * 2. If *pc == BR,BSR,JMP,CALL, break at destination
+ * 3. If *pc == SKIP, break right after SKIP AND after optional instruction,
+ which might, of course, be prefixed.
+ * 4. Anything else, just drop in the breakpoint.
+ */
+
+ pc = (short *)(int)g->registers.pc;
+
+ instruction = *pc;
+ stepType = 0;
+
+ if(NiosInstructionIsPrefix(instruction))
+ {
+ /*
+ * PFX instruction: skip til after it
+ */
+ while(NiosInstructionIsPrefix(instruction))
+ {
+ pc++;
+ instruction = *pc;
+ }
+
+ GDBInsertBreakpoint(g,pc + 1);
+ stepType = 1;
+ }
+ else if(NiosInstructionIsBranch(instruction,pc,&branchTarget))
+ {
+ GDBInsertBreakpoint(g,branchTarget);
+ stepType = 2;
+ }
+ else if(NiosInstructionIsSkip(instruction))
+ {
+ short *pc2;
+ stepType = 3;
+
+ /*
+ * Skip gets to breaks: one after the skippable instruction,
+ * and the skippable instruction itself.
+ *
+ * Since Skips know how to skip over PFX's, we have to, too.
+ */
+ pc2 = pc; // the Skip instruction
+ do
+ {
+ pc2++;
+ } while(NiosInstructionIsPrefix(*pc2));
+ // pc2 now points to first non-PFX after Skip
+ GDBInsertBreakpoint(g,pc2+1);
+ GDBInsertBreakpoint(g,pc+1);
+ }
+ else
+ GDBInsertBreakpoint(g,pc+1); // the genericest case
+
+ GDB_Print2("Program Steppingat 0x%x (%d)",g->registers.pc,stepType);
+ }
+
+// -----------------------------
+// Continue at address
+
+void DoGDBCommand_c(NiosGDBGlobals *g)
+ {
+ char *w;
+ int x;
+ w = g->textBuffer;
+
+ w++; // past command
+
+ // Anything in the packet? if so,
+ // use it to set the PC value
+
+ if(HexCharToValue(*w) >= 0)
+ {
+ w = Hex2Value(w,&x);
+ g->registers.pc = x;
+ }
+
+ GDB_Print2("Program Running at 0x%x",g->registers.pc,0);
+ }
+
+// ----------------------
+// Kill
+
+void DoGDBCommand_k(NiosGDBGlobals *g)
+ {
+ return;
+ }
+
+
+/*
+ * If we've somehow skidded
+ * to a stop just after a PFX instruction
+ * back up the program counter by one.
+ *
+ * That way, we can't end up with an accidentally-unprefixed
+ * instruction.
+ *
+ * We do this just before we begin running
+ * again, so that when the host queries our
+ * registers, we report the place we actually
+ * stopped.
+ */
+
+void MaybeAdjustProgramCounter(NiosGDBGlobals *g)
+ {
+ short instruction;
+ if(g->registers.pc)
+ {
+ instruction = *(short *)(int)(g->registers.pc - 2);
+ if(NiosInstructionIsPrefix(instruction))
+ g->registers.pc -= 2;
+ else
+ {
+ // If the *current* instruction is Trap5, we must skip it!
+ instruction = *(short *)(int)(g->registers.pc);
+ if(NiosInstructionIsTrap5(instruction))
+ g->registers.pc += 2;
+ }
+ }
+ }
+
+/*
+ * GDBMainLoop - this is the main processing loop
+ * for the GDB stub.
+ */
+void GDBMainLoop (void)
+{
+ while(1)
+ {
+ if (GetGDBPacket(gdb.textBuffer) > 0)
+ {
+
+ GDB_Print2(gdb.textBuffer,0,0);
+ switch(gdb.textBuffer[0])
+ {
+ case 's':
+ DoGDBCommand_s(&gdb);
+ goto startRunning;
+ break;
+
+ case 'c': // continue
+ DoGDBCommand_c(&gdb);
+
+ // if the PC is something other than 0, it's
+ // probably ok to exit and go there
+
+ startRunning:
+ if(gdb.registers.pc)
+ {
+ MaybeAdjustProgramCounter(&gdb);
+ return;
+ }
+ break;
+
+ case 'm': // memory read
+ DoGDBCommand_m(gdb.textBuffer);
+ break;
+
+ case 'M': // memory set
+ DoGDBCommand_M(gdb.textBuffer);
+ break;
+
+ case 'g': // registers read
+ DoGDBCommand_g(&gdb);
+ break;
+
+ case 'G': //registers set
+ DoGDBCommand_G(&gdb);
+ break;
+
+ case 'k': //kill process
+ DoGDBCommand_k(&gdb);
+ break;
+
+ case '?': // last exception value
+ DoGDBCommand_qm(&gdb);
+ break;
+
+ case 'q':
+ DoGDBCommand_q(&gdb);
+ break;
+
+ default: // return empty packet, means "yeah yeah".
+ gdb.textBuffer[0] = 0;
+ PutGDBPacket(gdb.textBuffer);
+ break;
+ }
+ }
+ }
+
+}
+
+// ----------main------------
+void GDBMain(void)
+{
+ int i;
+
+ for(i = 0; i < kTextBufferSize; i++)
+ gdb.textBuffer[i] = i;
+
+ GDBRemoveBreakpoints(&gdb);
+
+#ifdef __KERNEL__
+/*
+ * Inform the user that they need to add the symbol file for the application
+ * that is just starting up. Display the .text .data .bss regions.
+ */
+ if (gdb.trapNumber == 5) {
+ extern struct task_struct *_current_task;
+ sprintf(gdb.textBuffer,
+ "\r\n\nGDB: trap 5 at 0x%08lX", gdb.registers.pc);
+ puts(gdb.textBuffer);
+ if (_current_task) {
+ if ( _current_task->mm->start_code > _etext )
+ sprintf(gdb.textBuffer,
+ "\r\nGDB: Enter the following command in the nios-elf-gdb Console Window:"
+ "\r\nGDB: add-symbol-file %s.abself 0x%08lX 0x%08lX 0x%08lX\r\n\n",
+ _current_task->comm,
+ (unsigned long)_current_task->mm->start_code,
+ (unsigned long)_current_task->mm->start_data,
+ (unsigned long)_current_task->mm->end_data );
+ else
+ sprintf(gdb.textBuffer,
+ ", kernel process: %s\r\n", _current_task->comm );
+ } else
+ sprintf(gdb.textBuffer,
+ ", kernel process unknown\r\n" );
+ puts(gdb.textBuffer);
+ }
+#endif
+
+ // Send trapnumber for breakpoint encountered. No other signals.
+
+ gdb.textBuffer[0] = 'S';
+ gdb.textBuffer[1] = '0';
+
+#if nasys_debug_core
+ if (gdb.trapNumber == nasys_debug_core_irq)
+ {
+ /* gdb.textBuffer[2] = '8'; */
+ gdb.textBuffer[2] = '5';
+ }
+ else
+ {
+ gdb.textBuffer[2] = '5';
+ }
+#else
+ gdb.textBuffer[2] = '5';
+#endif
+ gdb.textBuffer[3] = 0;
+ PutGDBPacket(gdb.textBuffer);
+
+ GDB_Print2("Trap %2d At 0x%x",
+ gdb.trapNumber,gdb.registers.pc);
+// printf ("Trap %d at 0x%x\n",gdb.trapNumber,gdb.registers.pc);
+// for (i=0;i<32;i++) printf (" register[%d] = 0x%x\n",i,gdb.registers.r[i]);
+
+ GDBMainLoop ();
+}
+
+// +----------------------------------
+// | gdb_eth_proc -- gets called for udp packets
+// | from the host bound for gdb stub
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+int gdb_eth_proc(int plug_handle,
+ void *context,
+ ns_plugs_packet *p,
+ void *payload,
+ int payload_length)
+{
+ int i;
+ char *buf = (char *)payload;
+ // if this is a stop request, set a flag to stop after nr_plugs_idle
+ // leave it up to the host to prevent stops from being sent while stub is running???
+
+ if (*buf == 3) gdb.stop = 1;
+
+ // if we're waiting for an ack, check that here
+ if (gdb.ACKstatus == ne_gdb_ack_waiting)
+ {
+ if (buf[0] == '+')
+ {
+ gdb.ACKstatus = ne_gdb_ack_acked;
+ return 0;
+ }
+ else if (buf[0] == '-')
+ {
+ gdb.ACKstatus = ne_gdb_ack_nacked;
+ return 0;
+ }
+ }
+ strcpy (gdb.textBuffer, buf); //all commands should be zero terminated strings
+
+ gdb.textBuffer[payload_length] = 0; //terminate string
+
+ gdb.host_ip_address=((ns_plugs_ip_packet *)(p[ne_plugs_ip].header))->source_ip_address;
+ gdb.host_port_number=((ns_plugs_udp_packet *)(p[ne_plugs_udp].header))->source_port;
+
+ return 0;
+}
+
+int nr_dbg_plugs_idle (void)
+{
+ int result;
+
+ result = nr_plugs_idle ();
+ if (gdb.stop)
+ {
+ gdb.stop = 0;
+//;dgt2;tmp; asm ("TRAP #5");
+ }
+ return result;
+}
+#endif
+#endif
+
+
+/*
+ * int main(void)
+ *
+ * All we really do here is install our trap # 3,
+ * and call it once, so that we're living down in
+ * the GDBMain, trap handler.
+ */
+
+extern int StubBreakpointHandler;
+extern int StubHarmlessHandler;
+#if nasys_debug_core
+extern int StubHWBreakpointHandler;
+#endif
+#ifdef nasys_debug_uart
+extern int StubUartHandler;
+#endif
+
+void gdb_local_install(int active)
+{
+ unsigned int *vectorTable;
+ unsigned int stubBreakpointHandler;
+ unsigned int stubHarmlessHandler;
+#if nasys_debug_core
+ unsigned int stubHWBreakpointHandler;
+#endif
+
+ gdb.breakpointCount = 0;
+ gdb.textBuffer[0] = 0;
+
+ vectorTable = (int *)nasys_vector_table;
+ stubBreakpointHandler = ( (unsigned int)(&StubBreakpointHandler) ) >> 1;
+ stubHarmlessHandler = ( (unsigned int)(&StubHarmlessHandler) ) >> 1;
+#if nasys_debug_core
+ stubHWBreakpointHandler = ( (unsigned int)(&StubHWBreakpointHandler) ) >> 1;
+#endif
+
+ /*
+ * Breakpoint & single step both go here
+ */
+ vectorTable[na_BreakpointTrap] = stubBreakpointHandler;
+ vectorTable[na_SingleStepTrap] = stubBreakpointHandler;
+ vectorTable[na_StartGDBTrap] = active ? stubBreakpointHandler : stubHarmlessHandler;
+ /*
+ * If it exists, Hardware Breakpoint has a different entry point
+ */
+#if nasys_debug_core
+ vectorTable[na_debug_peripheral_irq] = stubHWBreakpointHandler;
+#endif
+
+#ifndef __KERNEL__
+#ifdef nasys_debug_uart
+ if (gdb.comlink == ne_gdb_serial)
+ {
+ np_uart *uart = (np_uart *)nasys_debug_uart;
+ unsigned int stubUartHandler = ((unsigned int)(&StubUartHandler)) >> 1;
+
+ vectorTable[nasys_debug_uart_irq] = stubUartHandler; //set Uart int vector
+ uart->np_uartcontrol = np_uartcontrol_irrdy_mask; //enable Rx intr
+ }
+#endif
+#endif
+}
+
+void nios_gdb_install(int active)
+{
+ gdb.comlink = ne_gdb_serial;
+ gdb_local_install (active);
+}
+
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+void nios_gdb_install_ethernet (int active)
+{
+ int result;
+ host_16 host_port = GDB_ETH_PORT;
+
+ gdb.comlink = ne_gdb_ethernet;
+ gdb_local_install (active);
+
+ result = nr_plugs_create (&gdb.gdb_eth_plug, ne_plugs_udp, host_port, gdb_eth_proc, 0, 0);
+ //if unabled to open ethernet plug, switch back to default serial interface
+ if (result)
+ {
+ printf ("nr_plugs_create failed %d\n",result);
+ gdb.comlink = ne_gdb_serial;
+ return;
+ }
+ result = nr_plugs_connect (gdb.gdb_eth_plug, 0, -1, -1);
+ if (result)
+ {
+ printf ("nr_plugs_connect fialed %d\n",result);
+ gdb.comlink = ne_gdb_serial;
+ return;
+ }
+}
+#endif
+#endif
+
+#ifdef nios_gdb_breakpoint
+ #undef nios_gdb_breakpoint
+#endif
+
+void nios_gdb_breakpoint(void)
+ {
+ /*
+ * If you arrived here, you didn't include
+ * the file "nios_peripherals.h", which
+ * defines nios_gdb_breakpoint as a
+ * macro that expands to TRAP 5.
+ *
+ * (No problem, you can step out
+ * of this routine.)
+ */
+//;dgt2;tmp; asm("TRAP 5");
+ }
+
+// end of file
diff --git a/arch/nios2nommu/kernel/nios_gdb_stub.h b/arch/nios2nommu/kernel/nios_gdb_stub.h
new file mode 100644
index 0000000..3900109
--- /dev/null
+++ b/arch/nios2nommu/kernel/nios_gdb_stub.h
@@ -0,0 +1,105 @@
+// file: nios_gdb_stub.h
+// Author: Altera Santa Cruz \ 2000
+//
+// You can modify this header file to
+// enable some features useful for
+// debugging the debugger. They're
+// good features also to just show
+// signs of life on your Nios board.
+// But they consume valuable peripherals!
+//
+// The 'GDB_DEBUG_PRINT' option ties
+// up the LCD living on the 5v port,
+// showing useful internals of the stub.
+//
+// dvb@altera.com
+//
+
+#ifdef ETHER_DEBUG
+#ifdef na_enet
+#define ethernet_exists
+#endif
+#endif
+
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+#include "plugs.h"
+#endif
+#endif
+
+#define MAX_DATA_SIZE 650
+#define kTextBufferSize ((2*MAX_DATA_SIZE)+4)
+#define kMaximumBreakpoints 4
+#define GDB_ETH_PORT 7070
+#define GDB_WHOLE_PACKET 0
+#define GDB_SKIP_FIRST 1
+#define GDB_RETRY_CNT 3
+
+/*
+ * This register structure must match
+ * its counterpart in the GDB host, since
+ * it is blasted across in byte notation.
+ */
+typedef struct
+ {
+ int r[32];
+ long pc;
+ short ctl0;
+ short ctl1;
+ short ctl2;
+ short ctl3;
+ } NiosGDBRegisters;
+
+typedef struct
+ {
+ short *address;
+ short oldContents;
+ } NiosGDBBreakpoint;
+
+typedef struct
+ {
+ NiosGDBRegisters registers;
+ int trapNumber; // stashed by ISR, to distinguish types
+ char textBuffer[kTextBufferSize];
+ int breakpointCount; // breakpoints used for stepping
+ int comlink;
+ int stop;
+ int gdb_eth_plug;
+ NiosGDBBreakpoint breakpoint[kMaximumBreakpoints];
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+ volatile int ACKstatus;
+ net_32 host_ip_address;
+ net_16 host_port_number;
+#endif
+#endif
+ } NiosGDBGlobals;
+
+#ifdef ETHER_DEBUG
+#ifdef ethernet_exists
+enum
+{
+ ne_gdb_ack_notwaiting,
+ ne_gdb_ack_waiting,
+ ne_gdb_ack_acked,
+ ne_gdb_ack_nacked
+};
+#endif
+#endif
+
+enum
+{
+ ne_gdb_serial,
+ ne_gdb_ethernet
+};
+
+#ifndef GDB_DEBUG_PRINT
+ #define GDB_DEBUG_PRINT 0
+#endif
+
+void GDB_Main(void); // initialize gdb and begin.
+
+char GDBGetChar(void);
+void GDBPutChar(char c);
+void GDB_Print2(char *s,int v1,int v2);
+
diff --git a/arch/nios2nommu/kernel/nios_gdb_stub_io.c b/arch/nios2nommu/kernel/nios_gdb_stub_io.c
new file mode 100644
index 0000000..e0d8f82
--- /dev/null
+++ b/arch/nios2nommu/kernel/nios_gdb_stub_io.c
@@ -0,0 +1,39 @@
+// Modified for uClinux - Vic - Apr 2002
+// From:
+
+// file: nios_gdb_stub_IO.c
+//
+// Single character I/O for Nios GDB Stub
+
+#ifndef __KERNEL__
+#include "nios.h"
+#else
+#include <asm/nios.h>
+#endif
+
+#include "nios_gdb_stub.h"
+
+#ifdef nasys_debug_uart
+ #define GDB_UART nasys_debug_uart
+#endif
+
+char GDBGetChar(void)
+{
+ char c = 0;
+
+#ifdef GDB_UART
+ while( (c = (char)nr_uart_rxchar(GDB_UART)) < 0 )
+ ;
+#endif
+
+ return c;
+}
+
+void GDBPutChar(char c)
+{
+#ifdef GDB_UART
+ nr_uart_txchar(c, GDB_UART);
+#endif
+}
+
+// End of file
diff --git a/arch/nios2nommu/kernel/nios_gdb_stub_isr.S b/arch/nios2nommu/kernel/nios_gdb_stub_isr.S
new file mode 100644
index 0000000..c4af09a
--- /dev/null
+++ b/arch/nios2nommu/kernel/nios_gdb_stub_isr.S
@@ -0,0 +1,99 @@
+/*--------------------------------------------------------------------
+ *
+ * Assembly language portions of Nios GDB Stub
+ *
+ * arch\nios2nommu\kernel\switch.S
+ *
+ * Derived from Nios1
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Modified for uClinux - Vic - Apr 2002
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+//;dgt2;tmp;
+
+ .equ ethernet_exists, 1
+
+
+ .equ gdbRegistersGeneral,0
+ .equ gdbRegistersPC,32
+ .equ gdbRegistersCtl0Ctl1,33
+ .equ gdbRegistersCtl2Ctl3,34
+ .equ gdbTrapNumber,35 ; ISR can report trap number here
+
+
+ .text
+
+ .global StubBreakpointHandler
+ .global StubHarmlessHandler
+ .global StubButtonHandler
+ .global StubHWBreakpointHandler
+ .global GDBMain
+
+ .comm _gdb_stub_stack,1024,4 ; Local stack, statically allocated.
+ .equ gdbStubStacktop,_gdb_stub_stack+992
+
+
+StubHarmlessHandler:
+//;dgt2;tmp
+
+ .equ gdbBreakChar,0x3
+ .global StubUartHandler
+
+StubUartHandler:
+//;dgt2;tmp
+
+StubUartRx:
+//;dgt2;tmp
+
+StubHWBreakpointHandler:
+//;dgt2;tmp
+
+StubBreakpointHandler:
+//;dgt2;tmp
+
+#ifdef __KERNEL__
+;----------------------------------------
+; Name: nr_uart_rxchar
+; Description: Read character if available
+; Input: %o0: UART base to use
+; Output: %o0 = character 0-0xff, or -1 if none present
+; Side Effects: %g0 & %g1 altered
+; CWP Depth: 0
+;
+
+ .global nr_uart_rxchar
+nr_uart_rxchar:
+//;dgt2;tmp
+
+
+;----------------------------------------
+; Name: nr_uart_txchar
+; Description: Send a single byte out the UART
+; Input: %o0 = A character
+; %o1 = the UART to use, 0 for default
+; Output: none
+; Side Effects: %g0 & %g1 altered, CPU waits for UART
+; CWP Depth: 0
+;
+
+; nr_uart_txchar
+ .global nr_uart_txchar
+nr_uart_txchar:
+//;dgt2;tmp
+
+#endif
diff --git a/arch/nios2nommu/kernel/pio.c b/arch/nios2nommu/kernel/pio.c
new file mode 100644
index 0000000..013a64b
--- /dev/null
+++ b/arch/nios2nommu/kernel/pio.c
@@ -0,0 +1,154 @@
+/*
+ * linux/arch/nios2nommu/kernel/pio.c
+ * "Example" drivers(LEDs and 7 seg displays) of the PIO interface
+ * on Nios Development Kit.
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <asm/io.h>
+
+MODULE_AUTHOR("Microtronix Datacom Ltd.");
+MODULE_DESCRIPTION("Drivers of PIO devices (LEDs and 7 seg) on Nios kit");
+MODULE_LICENSE("GPL");
+
+#undef CONFIG_PIO_SEG
+#ifdef na_seven_seg_pio
+#define CONFIG_PIO_SEG
+#define PIO_SEG_IO na_seven_seg_pio
+#endif
+
+#undef CONFIG_PIO_LED
+#ifdef na_led_pio
+#define CONFIG_PIO_LED
+#define PIO_LED_IO na_led_pio
+#endif
+
+#define PDEBUG printk
+
+/* routines for 7-segment hex display */
+#ifdef CONFIG_PIO_SEG
+static unsigned char _hex_digits_data[] = {
+ 0x01, 0x4f, 0x12, 0x06, 0x4c, /* 0-4 */
+ 0x24, 0x20, 0x0f, 0x00, 0x04, /* 5-9 */
+ 0x08, 0x60, 0x72, 0x42, 0x30, /* a-e */
+ 0x38 /* f */
+};
+
+void pio_seg_write(int value)
+{
+ int led_value;
+
+ /* Left Hand Digit, goes to PIO bits 8-14 */
+ led_value = _hex_digits_data[value & 0xF];
+ led_value |= (_hex_digits_data[(value >> 4) & 0xF]) << 8;
+
+ outl(led_value, &(PIO_SEG_IO->np_piodata));
+}
+
+static void __init pio_seg_init(void)
+{
+ pio_seg_write(0);
+}
+#endif
+
+
+/* routines for LED display */
+#ifdef CONFIG_PIO_LED
+void pio_led_write(int value)
+{
+ np_pio *pio=(np_pio *)(PIO_LED_IO);
+
+ //outl(-1, &pio->np_piodirection);
+ outl(value, &pio->np_piodata);
+}
+
+static void __init pio_led_init(void)
+{
+ np_pio *pio=(np_pio *)(PIO_LED_IO);
+
+ outl(-1, &pio->np_piodirection);
+ outl(0x0, &pio->np_piodata);
+}
+#endif
+
+/* timing routines */
+#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
+static struct timer_list display_timer;
+static int restart_timer=1;
+static int timer_counter=0;
+static void display_timeout(unsigned long unused)
+{
+#ifdef CONFIG_PIO_SEG
+ pio_seg_write(++timer_counter);
+#endif
+
+#ifdef CONFIG_PIO_LED
+ pio_led_write(timer_counter);
+#endif
+ if (restart_timer) {
+ display_timer.expires = jiffies + HZ; /* one second */
+ add_timer(&display_timer);
+ }
+}
+#endif
+
+int __init pio_init(void)
+{
+#ifdef CONFIG_PIO_SEG
+ request_mem_region((unsigned long)PIO_SEG_IO, sizeof(np_pio), "pio_7seg");
+ pio_seg_init();
+#endif
+
+#ifdef CONFIG_PIO_LED
+ request_mem_region((unsigned long)PIO_LED_IO, sizeof(np_pio), "pio_led");
+ pio_led_init();
+#endif
+
+#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
+ /* init timer */
+ init_timer(&display_timer);
+ display_timer.function = display_timeout;
+ display_timer.data = 0;
+ display_timer.expires = jiffies + HZ * 10; /* 10 seconds */
+ add_timer(&display_timer);
+#endif
+
+ return 0;
+}
+
+static void __exit pio_exit(void)
+{
+#ifdef CONFIG_PIO_SEG
+ pio_seg_write(0);
+ release_mem_region((unsigned long)PIO_SEG_IO, sizeof(np_pio));
+#endif
+
+#ifdef CONFIG_PIO_LED
+ pio_led_write(0);
+ release_mem_region((unsigned long)PIO_LED_IO, sizeof(np_pio));
+#endif
+
+#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
+ restart_timer=0;
+ del_timer_sync(&display_timer);
+#endif
+}
+module_init(pio_init);
+module_exit(pio_exit);
+
diff --git a/arch/nios2nommu/kernel/process.c b/arch/nios2nommu/kernel/process.c
new file mode 100644
index 0000000..4cd353c
--- /dev/null
+++ b/arch/nios2nommu/kernel/process.c
@@ -0,0 +1,578 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/kernel/process.c
+ *
+ * Derived from M68knommu
+ *
+ * Copyright (C) 1995 Hamish Macdonald
+ * Copyright (C) 2000-2002, David McCullough <davidm@snapgear.com>
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * 68060 fixes by Jesper Skov
+ * Jan/20/2004 dgt NiosII
+ * rdusp() === (pt_regs *) regs->sp
+ * Monday:
+ * asm-nios2nommu\processor.h now bears
+ * inline thread_saved_pc
+ * (struct thread_struct *t)
+ * Friday: it's back here now
+ *
+ ---------------------------------------------------------------------*/
+
+
+/*
+ * This file handles the architecture-dependent parts of process handling..
+ */
+
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/stddef.h>
+#include <linux/unistd.h>
+#include <linux/ptrace.h>
+#include <linux/slab.h>
+#include <linux/user.h>
+#include <linux/a.out.h>
+#include <linux/interrupt.h>
+#include <linux/reboot.h>
+#include <linux/uaccess.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+
+#include <asm/system.h>
+#include <asm/traps.h>
+#include <asm/setup.h>
+#include <asm/pgtable.h>
+#include <asm/cacheflush.h>
+
+asmlinkage void ret_from_fork(void);
+
+/*
+ * The following aren't currently used.
+ */
+void (*pm_idle)(void) = NULL;
+EXPORT_SYMBOL(pm_idle);
+
+void (*pm_power_off)(void) = NULL;
+EXPORT_SYMBOL(pm_power_off);
+
+void default_idle(void)
+{
+ local_irq_disable();
+ if (!need_resched()) {
+ local_irq_enable();
+ __asm__("nop"); // was asm sleep
+ } else
+ local_irq_enable();
+}
+
+void (*idle)(void) = default_idle;
+
+/*
+ * The idle thread. There's no useful work to be
+ * done, so just try to conserve power and have a
+ * low exit latency (ie sit in a loop waiting for
+ * somebody to say that they'd like to reschedule)
+ */
+void cpu_idle(void)
+{
+ while (1) {
+ while (!need_resched())
+ idle();
+ preempt_enable_no_resched();
+ schedule();
+ preempt_disable();
+ }
+}
+
+/*
+ * The development boards have no way to pull a board
+ * reset. Just jump to the cpu reset address and let
+ * the code in head.S take care of disabling peripherals.
+ */
+
+void machine_restart(char * __unused)
+{
+ local_irq_disable();
+ __asm__ __volatile__ (
+ "jmp %0\n\t"
+ :
+ : "r" (CPU_RESET_ADDRESS)
+ : "r4");
+}
+
+EXPORT_SYMBOL(machine_restart);
+
+void machine_halt(void)
+{
+ local_irq_disable();
+ for (;;);
+}
+
+EXPORT_SYMBOL(machine_halt);
+
+void exit_thread(void)
+{
+}
+
+void release_thread(struct task_struct *dead_task)
+{
+ /* nothing to do ... */
+}
+
+/*
+ * There is no way to power off the development
+ * boards. So just spin lock for now. If you have
+ * your own board with power down circuits add you
+ * specific code here.
+ */
+
+void machine_power_off(void)
+{
+ local_irq_disable();
+ for (;;);
+}
+
+EXPORT_SYMBOL(machine_power_off);
+
+void show_regs(struct pt_regs * regs)
+{
+ printk(KERN_NOTICE "\n");
+
+ printk(KERN_NOTICE "r1: %08lx r2: %08lx r3: %08lx r4: %08lx\n",
+ regs->r1, regs->r2, regs->r3, regs->r4);
+
+ printk(KERN_NOTICE "r5: %08lx r6: %08lx r7: %08lx r8: %08lx\n",
+ regs->r5, regs->r6, regs->r7, regs->r8);
+
+ printk(KERN_NOTICE "r9: %08lx r10: %08lx r11: %08lx r12: %08lx\n",
+ regs->r9, regs->r10, regs->r11, regs->r12);
+
+ printk(KERN_NOTICE "r13: %08lx r14: %08lx r15: %08lx\n",
+ regs->r13, regs->r14, regs->r15);
+
+ printk(KERN_NOTICE "ra: %08lx fp: %08lx sp: %08lx gp: %08lx\n",
+ regs->ra, regs->fp, regs->sp, regs->gp);
+
+ printk(KERN_NOTICE "ea: %08lx estatus: %08lx statusx: %08lx\n",
+ regs->ea, regs->estatus, regs->status_extension);
+}
+
+/*
+ * Create a kernel thread
+ */
+int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
+{
+ long retval;
+ long clone_arg = flags | CLONE_VM;
+ mm_segment_t fs;
+
+ fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ __asm__ __volatile(
+
+ " movi r2, %6\n\t" /* TRAP_ID_SYSCALL */
+ " movi r3, %1\n\t" /* __NR_clone */
+ " mov r4, %5\n\t" /* (clone_arg */
+ /* (flags | CLONE_VM)) */
+ " movia r5, -1\n\t" /* usp: -1 */
+ " trap\n\t" /* sys_clone */
+ "\n\t"
+ " cmpeq r4, r3, zero\n\t"/*2nd return valu in r3 */
+ " bne r4, zero, 1f\n\t"/* 0: parent, just return. */
+ /* See copy_thread, called */
+ /* by do_fork, called by */
+ /* nios2_clone, called by */
+ /* sys_clone, called by */
+ /* syscall trap handler. */
+
+ " mov r4, %4\n\t" /* fn's parameter (arg) */
+ "\n\t"
+ "\n\t"
+ " callr %3\n\t" /* Call function (fn) */
+ "\n\t"
+ " mov r4, r2\n\t" /* fn's rtn code//;dgt2;tmp;*/
+ " movi r2, %6\n\t" /* TRAP_ID_SYSCALL */
+ " movi r3, %2\n\t" /* __NR_exit */
+ " trap\n\t" /* sys_exit() */
+
+ /* Not reached by child. */
+ "1:\n\t"
+ " mov %0, r2\n\t" /* error rtn code (retval) */
+
+ : "=r" (retval) /* %0 */
+
+ : "i" (__NR_clone) /* %1 */
+ , "i" (__NR_exit) /* %2 */
+ , "r" (fn) /* %3 */
+ , "r" (arg) /* %4 */
+ , "r" (clone_arg) /* %5 (flags | CLONE_VM) */
+ , "i" (TRAP_ID_SYSCALL) /* %6 */
+
+ : "r2" /* Clobbered */
+ , "r3" /* Clobbered */
+ , "r4" /* Clobbered */
+ , "r5" /* Clobbered */
+ , "ra" /* Clobbered //;mex1 */
+ );
+
+ set_fs(fs);
+ return retval;
+}
+
+void flush_thread(void)
+{
+ /* Now, this task is no longer a kernel thread. */
+ current->thread.flags &= ~NIOS2_FLAG_KTHREAD;
+
+#ifdef CONFIG_FPU
+ unsigned long zero = 0;
+#endif
+ set_fs(USER_DS);
+#ifdef CONFIG_FPU
+ if (!FPU_IS_EMU)
+...;dgt2;
+ asm volatile (".chip 68k/68881\n\t"
+ "frestore %0@\n\t"
+ ".chip 68k" : : "a" (&zero));
+#endif
+}
+
+/*
+ * "nios2_fork()".. By the time we get here, the
+ * non-volatile registers have also been saved on the
+ * stack. We do some ugly pointer stuff here.. (see
+ * also copy_thread)
+ */
+
+asmlinkage int nios2_fork(struct pt_regs *regs)
+{
+ /* fork almost works, enough to trick you into looking elsewhere :-( */
+ return(-EINVAL);
+}
+
+/*
+ * nios2_execve() executes a new program.
+ */
+asmlinkage int nios2_execve(struct pt_regs *regs)
+{
+ int error;
+ char * filename;
+
+ lock_kernel();
+ filename = getname((char *) regs->r4);
+ error = PTR_ERR(filename);
+ if (IS_ERR(filename))
+ goto out;
+ error = do_execve(filename,
+ (char **) regs->r5,
+ (char **) regs->r6,
+ regs);
+ putname(filename);
+out:
+ unlock_kernel();
+ return error;
+}
+
+asmlinkage int nios2_vfork(struct pt_regs *regs)
+{
+ return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0, NULL, NULL);
+}
+
+asmlinkage int nios2_clone(struct pt_regs *regs)
+{
+ /* r4: clone_flags, r5: child_stack (usp) */
+
+ unsigned long clone_flags;
+ unsigned long newsp;
+
+ clone_flags = regs->r4;
+ newsp = regs->r5;
+ if (!newsp)
+ newsp = regs->sp;
+ return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
+}
+
+int copy_thread(int nr, unsigned long clone_flags,
+ unsigned long usp, unsigned long topstk,
+ struct task_struct * p, struct pt_regs * regs)
+{
+ struct pt_regs * childregs;
+ struct switch_stack * childstack, *stack;
+ unsigned long stack_offset, *retp;
+
+ stack_offset = THREAD_SIZE - sizeof(struct pt_regs);
+ childregs = (struct pt_regs *) ((unsigned long) p->stack + stack_offset);
+ p->thread.kregs = childregs;
+
+ *childregs = *regs;
+ childregs->r2 = 0; //;dgt2;...redundant?...see "rtnvals" below
+
+ retp = ((unsigned long *) regs);
+ stack = ((struct switch_stack *) retp) - 1;
+
+ childstack = ((struct switch_stack *) childregs) - 1;
+ *childstack = *stack;
+ childstack->ra = (unsigned long)ret_from_fork;
+
+ if (usp == -1)
+ p->thread.kregs->sp = (unsigned long) childstack;
+ else
+ p->thread.kregs->sp = usp;
+
+ p->thread.ksp = (unsigned long)childstack;
+
+#ifdef CONFIG_FPU
+ if (!FPU_IS_EMU) {
+ /* Copy the current fpu state */
+...;dgt2;
+ asm volatile ("fsave %0" : : "m" (p->thread.fpstate[0]) : "memory");
+
+ if (p->thread.fpstate[0])
+ asm volatile ("fmovemx %/fp0-%/fp7,%0\n\t"
+ "fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
+ : : "m" (p->thread.fp[0]), "m" (p->thread.fpcntl[0])
+ : "memory");
+ /* Restore the state in case the fpu was busy */
+ asm volatile ("frestore %0" : : "m" (p->thread.fpstate[0]));
+ }
+#endif
+
+ /* Set the return value for the child. */
+ childregs->r2 = 0; //;dgt2;...redundant?...see childregs->r2 above
+ childregs->r3 = 1; //;dgt2;...eg: kernel_thread parent test
+
+ /* Set the return value for the parent. */
+ regs->r2 = p->pid; // Return child pid to parent
+ regs->r3 = 0; //;dgt2;...eg: kernel_thread parent test
+
+ return 0;
+}
+
+/* Fill in the fpu structure for a core dump. */
+
+int dump_fpu(struct pt_regs *regs, struct user_m68kfp_struct *fpu)
+{
+#ifdef CONFIG_FPU
+ char fpustate[216];
+
+ if (FPU_IS_EMU) {
+ int i;
+
+ memcpy(fpu->fpcntl, current->thread.fpcntl, 12);
+ memcpy(fpu->fpregs, current->thread.fp, 96);
+ /* Convert internal fpu reg representation
+ * into long double format
+ */
+ for (i = 0; i < 24; i += 3)
+ fpu->fpregs[i] = ((fpu->fpregs[i] & 0xffff0000) << 15) |
+ ((fpu->fpregs[i] & 0x0000ffff) << 16);
+ return 1;
+ }
+
+ /* First dump the fpu context to avoid protocol violation. */
+...;dgt2;tmp;
+ asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
+ if (!fpustate[0])
+ return 0;
+
+ asm volatile ("fmovem %/fpiar/%/fpcr/%/fpsr,%0"
+ :: "m" (fpu->fpcntl[0])
+ : "memory");
+ asm volatile ("fmovemx %/fp0-%/fp7,%0"
+ :: "m" (fpu->fpregs[0])
+ : "memory");
+#endif
+ return 1;
+}
+
+/*
+ * fill in the user structure for a core dump..
+ */
+void dump_thread(struct pt_regs * regs, struct user * dump)
+{
+ struct switch_stack *sw;
+
+ /* changed the size calculations - should hopefully work better. lbt */
+ dump->magic = CMAGIC;
+ dump->start_code = 0;
+ dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
+ dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
+ dump->u_dsize = ((unsigned long) (current->mm->brk +
+ (PAGE_SIZE-1))) >> PAGE_SHIFT;
+ dump->u_dsize -= dump->u_tsize;
+ dump->u_ssize = 0;
+
+ if (dump->start_stack < TASK_SIZE)
+ dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
+
+ dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump);
+ sw = ((struct switch_stack *)regs) - 1;
+ dump->regs.r1 = regs->r1;
+ dump->regs.r2 = regs->r2;
+ dump->regs.r3 = regs->r3;
+ dump->regs.r4 = regs->r4;
+ dump->regs.r5 = regs->r5;
+ dump->regs.r6 = regs->r6;
+ dump->regs.r7 = regs->r7;
+ dump->regs.r8 = regs->r8;
+ dump->regs.r9 = regs->r9;
+ dump->regs.r10 = regs->r10;
+ dump->regs.r11 = regs->r11;
+ dump->regs.r12 = regs->r12;
+ dump->regs.r13 = regs->r13;
+ dump->regs.r14 = regs->r14;
+ dump->regs.r15 = regs->r15;
+ dump->regs.r16 = sw->r16;
+ dump->regs.r17 = sw->r17;
+ dump->regs.r18 = sw->r18;
+ dump->regs.r19 = sw->r19;
+ dump->regs.r20 = sw->r20;
+ dump->regs.r21 = sw->r21;
+ dump->regs.r22 = sw->r22;
+ dump->regs.r23 = sw->r23;
+ dump->regs.ra = sw->ra;
+ dump->regs.fp = sw->fp;
+ dump->regs.gp = sw->gp;
+ dump->regs.sp = regs->sp;
+ dump->regs.orig_r2 = regs->orig_r2;
+ dump->regs.estatus = regs->estatus;
+ dump->regs.ea = regs->ea;
+ /* dump floating point stuff */
+ // dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
+}
+
+/*
+ * Generic dumping code. Used for panic and debug.
+ */
+void dump(struct pt_regs *fp)
+{
+ unsigned long *sp;
+ unsigned char *tp;
+ int i;
+
+ printk(KERN_EMERG "\nCURRENT PROCESS:\n\n");
+ printk(KERN_EMERG "COMM=%s PID=%d\n", current->comm, current->pid);
+
+ if (current->mm) {
+ printk(KERN_EMERG "TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
+ (int) current->mm->start_code,
+ (int) current->mm->end_code,
+ (int) current->mm->start_data,
+ (int) current->mm->end_data,
+ (int) current->mm->end_data,
+ (int) current->mm->brk);
+ printk(KERN_EMERG "USER-STACK=%08x KERNEL-STACK=%08x\n\n",
+ (int) current->mm->start_stack,
+ (int)(((unsigned long) current) + THREAD_SIZE));
+ }
+
+ printk(KERN_EMERG "PC: %08lx\n", fp->ea);
+ printk(KERN_EMERG "SR: %08lx SP: %08lx\n", (long) fp->estatus, (long) fp);
+ printk(KERN_EMERG "r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
+ fp->r4, fp->r5, fp->r6, fp->r7);
+ printk(KERN_EMERG "r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
+ fp->r8, fp->r9, fp->r10, fp->r11);
+ printk(KERN_EMERG "\nUSP: %08x TRAPFRAME: %08x\n", (unsigned int) fp->sp,
+ (unsigned int) fp);
+
+ printk(KERN_EMERG "\nCODE:");
+ tp = ((unsigned char *) fp->ea) - 0x20;
+ for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
+ if ((i % 0x10) == 0)
+ printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
+ printk(KERN_EMERG "%08x ", (int) *sp++);
+ }
+ printk(KERN_EMERG "\n");
+
+ printk(KERN_EMERG "\nKERNEL STACK:");
+ tp = ((unsigned char *) fp) - 0x40;
+ for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
+ if ((i % 0x10) == 0)
+ printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
+ printk(KERN_EMERG "%08x ", (int) *sp++);
+ }
+ printk(KERN_EMERG "\n");
+ printk(KERN_EMERG "\n");
+
+ printk(KERN_EMERG "\nUSER STACK:");
+ tp = (unsigned char *) (fp->sp - 0x10);
+ for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) {
+ if ((i % 0x10) == 0)
+ printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
+ printk(KERN_EMERG "%08x ", (int) *sp++);
+ }
+ printk(KERN_EMERG "\n\n");
+}
+
+/*
+ * These bracket the sleeping functions..
+ */
+extern void scheduling_functions_start_here(void);
+extern void scheduling_functions_end_here(void);
+#define first_sched ((unsigned long) scheduling_functions_start_here)
+#define last_sched ((unsigned long) scheduling_functions_end_here)
+
+unsigned long get_wchan(struct task_struct *p)
+{
+ unsigned long fp, pc;
+ unsigned long stack_page;
+ int count = 0;
+ if (!p || p == current || p->state == TASK_RUNNING)
+ return 0;
+
+ stack_page = (unsigned long)p;
+ fp = ((struct switch_stack *)p->thread.ksp)->fp; //;dgt2
+ do {
+ if (fp < stack_page+sizeof(struct task_struct) ||
+ fp >= 8184+stack_page) //;dgt2;tmp
+ return 0;
+ pc = ((unsigned long *)fp)[1];
+ if (!in_sched_functions(pc))
+ return pc;
+ fp = *(unsigned long *) fp;
+ } while (count++ < 16); //;dgt2;tmp
+ return 0;
+}
+
+/* Return saved PC of a blocked thread. */
+unsigned long thread_saved_pc(struct task_struct *t)
+{
+ return (t->thread.kregs->ea);
+}
+
+/*
+ * Do necessary setup to start up a newly executed thread.
+ * Will statup in user mode (status_extension = 0).
+ */
+void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
+{
+ memset((void *) regs, 0, sizeof(struct pt_regs));
+ regs->estatus = NIOS2_STATUS_PIE_MSK; // No user mode setting, at least not for now
+ regs->ea = pc;
+ regs->sp = sp;
+
+ /* check if debug flag is set */
+ if (current->thread.flags & NIOS2_FLAG_DEBUG ) {
+ if ( *(u32*)pc == NIOS2_OP_NOP ) {
+ *(u32*)pc = NIOS2_OP_BREAK;
+ flush_icache_range(pc, pc+4);
+ }
+ }
+}
diff --git a/arch/nios2nommu/kernel/ptrace.c b/arch/nios2nommu/kernel/ptrace.c
new file mode 100644
index 0000000..e6ff3b3
--- /dev/null
+++ b/arch/nios2nommu/kernel/ptrace.c
@@ -0,0 +1,352 @@
+/*
+ * linux/arch/m68knommu/kernel/ptrace.c
+ *
+ * Copyright (C) 1994 by Hamish Macdonald
+ * Taken from linux/kernel/ptrace.c and modified for M680x0.
+ * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of
+ * this archive for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/errno.h>
+#include <linux/ptrace.h>
+#include <linux/user.h>
+
+#include <asm/uaccess.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/system.h>
+#include <asm/processor.h>
+
+/*
+ * does not yet catch signals sent when the child dies.
+ * in exit.c or in signal.c.
+ */
+
+/* determines which bits in the SR the user has access to. */
+/* 1 = access 0 = no access */
+#define SR_MASK 0x00000000
+
+/* Find the stack offset for a register, relative to thread.ksp. */
+#define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg)
+#define SW_REG(reg) ((long)&((struct switch_stack *)0)->reg \
+ - sizeof(struct switch_stack))
+/* Mapping from PT_xxx to the stack offset at which the register is
+ saved. Notice that usp has no stack-slot and needs to be treated
+ specially (see get_reg/put_reg below). */
+static int regoff[] = {
+ -1, PT_REG(r1), PT_REG(r2), PT_REG(r3), PT_REG(r4),
+ PT_REG(r5), PT_REG(r6), PT_REG(r7), PT_REG(r8),
+ PT_REG(r9), PT_REG(r10), PT_REG(r11), PT_REG(r12),
+ PT_REG(r13), PT_REG(r14), PT_REG(r15), SW_REG(r16),
+ SW_REG(r17), SW_REG(r18), SW_REG(r19), SW_REG(r20),
+ SW_REG(r21), SW_REG(r22), SW_REG(r23), -1, -1,
+ PT_REG(gp), PT_REG(sp), -1, -1, PT_REG(ra), -1,
+ PT_REG(estatus), -1, -1, -1
+};
+
+/*
+ * Get contents of register REGNO in task TASK.
+ */
+static inline long get_reg(struct task_struct *task, int regno)
+{
+ unsigned long *addr;
+
+ if (regno == PTR_R0)
+ return 0;
+ else if (regno == PTR_BA)
+ return 0;
+ else if (regno == PTR_STATUS)
+ return 0;
+ else if (regno == PTR_IENABLE)
+ return 0;
+ else if (regno == PTR_IPENDING)
+ return 0;
+ else if (regno < sizeof(regoff)/sizeof(regoff[0]))
+ addr = (unsigned long *)(task->thread.kregs + regoff[regno]);
+ else
+ return 0;
+ return *addr;
+}
+
+/*
+ * Write contents of register REGNO in task TASK.
+ */
+static inline int put_reg(struct task_struct *task, int regno,
+ unsigned long data)
+{
+ unsigned long *addr;
+
+ if (regno == PTR_R0)
+ return -1;
+ else if (regno == PTR_BA)
+ return -1;
+ else if (regno == PTR_STATUS)
+ return -1;
+ else if (regno == PTR_IENABLE)
+ return -1;
+ else if (regno == PTR_IPENDING)
+ return -1;
+ else if (regno < sizeof(regoff)/sizeof(regoff[0]))
+ addr = (unsigned long *) (task->thread.kregs + regoff[regno]);
+ else
+ return -1;
+ *addr = data;
+ return 0;
+}
+
+/*
+ * Called by kernel/ptrace.c when detaching..
+ *
+ * Nothing special to do here, no processor debug support.
+ */
+void ptrace_disable(struct task_struct *child)
+{
+}
+
+long arch_ptrace(struct task_struct *child, long request, long addr, long data)
+{
+ int ret;
+
+ switch (request) {
+ /* when I and D space are separate, these will need to be fixed. */
+ case PTRACE_PEEKTEXT: /* read word at location addr. */
+ case PTRACE_PEEKDATA: {
+ unsigned long tmp;
+ int copied;
+
+ copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
+ ret = -EIO;
+ if (copied != sizeof(tmp))
+ break;
+ ret = put_user(tmp,(unsigned long *) data);
+ break;
+ }
+
+ /* read the word at location addr in the USER area. */
+ case PTRACE_PEEKUSR: {
+ unsigned long tmp;
+
+ ret = -EIO;
+ if ((addr & 3) || addr < 0 ||
+ addr > sizeof(struct user) - 3)
+ break;
+
+ tmp = 0; /* Default return condition */
+ addr = addr >> 2; /* temporary hack. */
+ ret = -EIO;
+ if (addr < 19) {
+ tmp = get_reg(child, addr);
+#if 0 // No FPU stuff
+ } else if (addr >= 21 && addr < 49) {
+ tmp = child->thread.fp[addr - 21];
+#ifdef CONFIG_M68KFPU_EMU
+ /* Convert internal fpu reg representation
+ * into long double format
+ */
+ if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
+ tmp = ((tmp & 0xffff0000) << 15) |
+ ((tmp & 0x0000ffff) << 16);
+#endif
+#endif
+ } else if (addr == 49) {
+ tmp = child->mm->start_code;
+ } else if (addr == 50) {
+ tmp = child->mm->start_data;
+ } else if (addr == 51) {
+ tmp = child->mm->end_code;
+ } else
+ break;
+ ret = put_user(tmp,(unsigned long *) data);
+ break;
+ }
+
+ /* when I and D space are separate, this will have to be fixed. */
+ case PTRACE_POKETEXT: /* write the word at location addr. */
+ case PTRACE_POKEDATA:
+ ret = 0;
+ if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))
+ break;
+ ret = -EIO;
+ break;
+
+ case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
+ ret = -EIO;
+ if ((addr & 3) || addr < 0 ||
+ addr > sizeof(struct user) - 3)
+ break;
+
+ addr = addr >> 2; /* temporary hack. */
+
+ if (addr == PTR_ESTATUS) {
+ data &= SR_MASK;
+ data |= get_reg(child, PTR_ESTATUS) & ~(SR_MASK);
+ }
+ if (addr < 19) {
+ if (put_reg(child, addr, data))
+ break;
+ ret = 0;
+ break;
+ }
+#if 0 // No FPU stuff
+ if (addr >= 21 && addr < 48)
+ {
+#ifdef CONFIG_M68KFPU_EMU
+ /* Convert long double format
+ * into internal fpu reg representation
+ */
+ if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
+ data = (unsigned long)data << 15;
+ data = (data & 0xffff0000) |
+ ((data & 0x0000ffff) >> 1);
+ }
+#endif
+ child->thread.fp[addr - 21] = data;
+ ret = 0;
+ }
+#endif
+ break;
+
+ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
+ case PTRACE_CONT: { /* restart after signal. */
+
+ ret = -EIO;
+ if ((unsigned long) data > _NSIG)
+ break;
+ if (request == PTRACE_SYSCALL)
+ set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+ else
+ clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+ child->exit_code = data;
+ wake_up_process(child);
+ ret = 0;
+ break;
+ }
+
+ /*
+ * make the child exit. Best I can do is send it a sigkill.
+ * perhaps it should be put in the status that it wants to
+ * exit.
+ */
+ case PTRACE_KILL: {
+
+ ret = 0;
+ if (child->state == EXIT_ZOMBIE) /* already dead */
+ break;
+ child->exit_code = SIGKILL;
+ wake_up_process(child);
+ break;
+ }
+
+ /*
+ * Single stepping requires placing break instructions in
+ * the code to break back. If you are stepping through a
+ * conditional branch you need to decode the test and put
+ * the break in the correct location.
+ */
+ case PTRACE_SINGLESTEP: { /* set the trap flag. */
+
+ ret = -EIO;
+ if ((unsigned long) data > _NSIG)
+ break;
+ clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+
+ child->exit_code = data;
+ /* give it a chance to run. */
+ wake_up_process(child);
+ ret = 0;
+ break;
+ }
+
+ case PTRACE_DETACH: /* detach a process that was attached. */
+ ret = ptrace_detach(child, data);
+ break;
+
+ case PTRACE_GETREGS: { /* Get all gp regs from the child. */
+ int i;
+ unsigned long tmp;
+ for (i = 0; i < 19; i++) {
+ tmp = get_reg(child, i);
+ if (put_user(tmp, (unsigned long *) data)) {
+ ret = -EFAULT;
+ break;
+ }
+ data += sizeof(long);
+ }
+ ret = 0;
+ break;
+ }
+
+ case PTRACE_SETREGS: { /* Set all gp regs in the child. */
+ int i;
+ unsigned long tmp;
+ for (i = 0; i < 19; i++) {
+ if (get_user(tmp, (unsigned long *) data)) {
+ ret = -EFAULT;
+ break;
+ }
+ if (i == PTR_ESTATUS) {
+ tmp &= SR_MASK;
+ tmp |= get_reg(child, PTR_ESTATUS) & ~(SR_MASK);
+ }
+ put_reg(child, i, tmp);
+ data += sizeof(long);
+ }
+ ret = 0;
+ break;
+ }
+
+#ifdef PTRACE_GETFPREGS
+ case PTRACE_GETFPREGS: { /* Get the child FPU state. */
+ ret = 0;
+ if (copy_to_user((void *)data, &child->thread.fp,
+ sizeof(struct user_m68kfp_struct)))
+ ret = -EFAULT;
+ break;
+ }
+#endif
+
+#ifdef PTRACE_SETFPREGS
+ case PTRACE_SETFPREGS: { /* Set the child FPU state. */
+ ret = 0;
+ if (copy_from_user(&child->thread.fp, (void *)data,
+ sizeof(struct user_m68kfp_struct)))
+ ret = -EFAULT;
+ break;
+ }
+#endif
+
+ default:
+ ret = -EIO;
+ break;
+ }
+ return ret;
+}
+
+asmlinkage void syscall_trace(void)
+{
+ if (!test_thread_flag(TIF_SYSCALL_TRACE))
+ return;
+ if (!(current->ptrace & PT_PTRACED))
+ return;
+ current->exit_code = SIGTRAP;
+ current->state = TASK_STOPPED;
+ ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
+ ? 0x80 : 0));
+ /*
+ * this isn't the same as continuing with a signal, but it will do
+ * for normal use. strace only continues with a signal if the
+ * stopping signal is not SIGTRAP. -brl
+ */
+ if (current->exit_code) {
+ send_sig(current->exit_code, current, 1);
+ current->exit_code = 0;
+ }
+}
diff --git a/arch/nios2nommu/kernel/semaphore.c b/arch/nios2nommu/kernel/semaphore.c
new file mode 100644
index 0000000..0c7d11b
--- /dev/null
+++ b/arch/nios2nommu/kernel/semaphore.c
@@ -0,0 +1,155 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/kernel/semaphore.c
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+/*
+ * Generic semaphore code. Buyer beware. Do your own
+ * specific changes in <asm/semaphore-helper.h>
+ */
+
+#include <linux/sched.h>
+#include <linux/err.h>
+#include <asm/semaphore-helper.h>
+
+#ifndef CONFIG_RMW_INSNS
+spinlock_t semaphore_wake_lock;
+#endif
+
+/*
+ * Semaphores are implemented using a two-way counter:
+ * The "count" variable is decremented for each process
+ * that tries to sleep, while the "waking" variable is
+ * incremented when the "up()" code goes to wake up waiting
+ * processes.
+ *
+ * Notably, the inline "up()" and "down()" functions can
+ * efficiently test if they need to do any extra work (up
+ * needs to do something only if count was negative before
+ * the increment operation.
+ *
+ * waking_non_zero() (from asm/semaphore.h) must execute
+ * atomically.
+ *
+ * When __up() is called, the count was negative before
+ * incrementing it, and we need to wake up somebody.
+ *
+ * This routine adds one to the count of processes that need to
+ * wake up and exit. ALL waiting processes actually wake up but
+ * only the one that gets to the "waking" field first will gate
+ * through and acquire the semaphore. The others will go back
+ * to sleep.
+ *
+ * Note that these functions are only called when there is
+ * contention on the lock, and as such all this is the
+ * "non-critical" part of the whole semaphore business. The
+ * critical part is the inline stuff in <asm/semaphore.h>
+ * where we want to avoid any extra jumps and calls.
+ */
+asmlinkage void __up(struct semaphore *sem)
+{
+ wake_one_more(sem);
+ wake_up(&sem->wait);
+}
+
+/*
+ * Perform the "down" function. Return zero for semaphore acquired,
+ * return negative for signalled out of the function.
+ *
+ * If called from __down, the return is ignored and the wait loop is
+ * not interruptible. This means that a task waiting on a semaphore
+ * using "down()" cannot be killed until someone does an "up()" on
+ * the semaphore.
+ *
+ * If called from __down_interruptible, the return value gets checked
+ * upon return. If the return value is negative then the task continues
+ * with the negative value in the return register (it can be tested by
+ * the caller).
+ *
+ * Either form may be used in conjunction with "up()".
+ *
+ */
+
+
+#define DOWN_HEAD(task_state) \
+ \
+ \
+ current->state = (task_state); \
+ add_wait_queue(&sem->wait, &wait); \
+ \
+ /* \
+ * Ok, we're set up. sem->count is known to be less than zero \
+ * so we must wait. \
+ * \
+ * We can let go the lock for purposes of waiting. \
+ * We re-acquire it after awaking so as to protect \
+ * all semaphore operations. \
+ * \
+ * If "up()" is called before we call waking_non_zero() then \
+ * we will catch it right away. If it is called later then \
+ * we will have to go through a wakeup cycle to catch it. \
+ * \
+ * Multiple waiters contend for the semaphore lock to see \
+ * who gets to gate through and who has to wait some more. \
+ */ \
+ for (;;) {
+
+#define DOWN_TAIL(task_state) \
+ current->state = (task_state); \
+ } \
+ current->state = TASK_RUNNING; \
+ remove_wait_queue(&sem->wait, &wait);
+
+void __sched __down(struct semaphore * sem)
+{
+ DECLARE_WAITQUEUE(wait, current);
+
+ DOWN_HEAD(TASK_UNINTERRUPTIBLE)
+ if (waking_non_zero(sem))
+ break;
+ schedule();
+ DOWN_TAIL(TASK_UNINTERRUPTIBLE)
+}
+
+int __sched __down_interruptible(struct semaphore * sem)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ int ret = 0;
+
+ DOWN_HEAD(TASK_INTERRUPTIBLE)
+
+ ret = waking_non_zero_interruptible(sem, current);
+ if (ret)
+ {
+ if (ret == 1)
+ /* ret != 0 only if we get interrupted -arca */
+ ret = 0;
+ break;
+ }
+ schedule();
+ DOWN_TAIL(TASK_INTERRUPTIBLE)
+ return ret;
+}
+
+int __down_trylock(struct semaphore * sem)
+{
+ return waking_non_zero_trylock(sem);
+}
diff --git a/arch/nios2nommu/kernel/setup.c b/arch/nios2nommu/kernel/setup.c
new file mode 100644
index 0000000..1f1627b
--- /dev/null
+++ b/arch/nios2nommu/kernel/setup.c
@@ -0,0 +1,663 @@
+/*
+ 21Mar2001 1.1 dgt/microtronix: Altera Excalibur/Nios32 port
+ 30Jun2003 kenw/microtronix: Remove cmdline check in flash
+*/
+
+/*
+ * linux/arch/niosnommu/kernel/setup.c
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ * Copyright (C) 2001 Vic Phillips {vic@microtronix.com}
+ * Copyleft (C) 2000 James D. Schettine {james@telos-systems.com}
+ * Copyright (C) 1999 Greg Ungerer (gerg@moreton.com.au)
+ * Copyright (C) 1998,2000 D. Jeff Dionne <jeff@lineo.ca>
+ * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
+ * Copyright (C) 1995 Hamish Macdonald
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/*
+ * This file handles the architecture-dependent parts of system setup
+ */
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/fs.h>
+#include <linux/fb.h>
+#include <linux/module.h>
+#include <linux/console.h>
+#include <linux/genhd.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/major.h>
+#include <linux/bootmem.h>
+#include <linux/initrd.h>
+#include <linux/seq_file.h>
+
+#include <asm/irq.h>
+#include <asm/byteorder.h>
+#include <asm/asm-offsets.h>
+#include <asm/pgtable.h>
+
+#ifdef CONFIG_BLK_DEV_INITRD
+#include <linux/blk.h>
+#endif
+
+#ifdef CONFIG_NIOS_SPI
+#include <asm/spi.h>
+extern ssize_t spi_write(struct file *filp, const char *buf, size_t count, loff_t *ppos);
+extern ssize_t spi_read (struct file *filp, char *buf, size_t count, loff_t *ppos);
+extern loff_t spi_lseek (struct file *filp, loff_t offset, int origin);
+extern int spi_open (struct inode *inode, struct file *filp);
+extern int spi_release (struct inode *inode, struct file *filp);
+#endif
+
+#ifdef CONFIG_CONSOLE
+extern struct consw *conswitchp;
+#endif
+
+unsigned long rom_length;
+unsigned long memory_start;
+unsigned long memory_end;
+
+EXPORT_SYMBOL(memory_start);
+EXPORT_SYMBOL(memory_end);
+
+#ifndef CONFIG_CMDLINE
+#define CONFIG_CMDLINE "CONSOLE=/dev/ttyS0 root=/dev/rom0 ro"
+#endif
+
+#ifndef CONFIG_PASS_CMDLINE
+static char default_command_line[] = CONFIG_CMDLINE;
+#endif
+static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };
+
+
+/* r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11*/
+/* r12 r13 r14 r15 or2 ra fp sp gp es ste ea*/
+static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
+ 0, 0, 0, 0, 0, (unsigned long)cpu_idle, 0, 0, 0, 0, 0, 0};
+
+#define CPU "NIOS2"
+
+#if defined (CONFIG_CS89x0) || defined (CONFIG_SMC91111) || defined (CONFIG_OPEN_ETH) || defined (CONFIG_MTIP1000_ETH) || defined (CONFIG_DM9000_ETH) || defined (CONFIG_SMC91X) || defined (CONFIG_DM9000) || defined (CONFIG_DM9KS)
+ #if defined (CONFIG_MTIP1000_ETH) //;dgt3;
+ #include <../drivers/net/mtip1000.h> //;dgt3;
+ #endif //;dgt3;
+
+ unsigned char *excalibur_enet_hwaddr;
+ unsigned char excalibur_enet_hwaddr_array[6];
+#endif
+
+// save args passed from u-boot, called from head.S
+void nios2_boot_init(unsigned r4,unsigned r5,unsigned r6,unsigned r7)
+{
+#if defined(CONFIG_PASS_CMDLINE)
+ if (r4 == 0x534f494e) // r4 is magic NIOS, to become board info check in the future
+ {
+#if defined(CONFIG_BLK_DEV_INITRD)
+ /*
+ * If the init RAM disk has been configured in, and there's a valid
+ * starting address for it, set it up.
+ */
+ if (r5) {
+ initrd_start = r5;
+ initrd_end = r6;
+ }
+#endif /* CONFIG_BLK_DEV_INITRD */
+ if (r7)
+ strncpy(command_line, (char *)r7, COMMAND_LINE_SIZE);
+ }
+#endif
+}
+
+inline void flash_command(int base, int offset, short data)
+{
+ volatile unsigned short * ptr=(unsigned short*) (base);
+
+ ptr[0x555]=0xaa;
+ ptr[0x2aa]=0x55;
+ ptr[offset]=data;
+}
+
+inline void exit_se_flash(int base)
+{
+ flash_command(base, 0x555, 0x90);
+ *(unsigned short*)base=0;
+}
+
+void __init setup_arch(char **cmdline_p)
+{
+ int bootmap_size;
+ extern int _stext, _etext;
+ extern int _edata, _end;
+#ifdef DEBUG
+ extern int _sdata, _sbss, _ebss;
+#ifdef CONFIG_BLK_DEV_BLKMEM
+ extern int *romarray;
+#endif
+#endif
+#if 0 // krh
+ unsigned char *psrc=(unsigned char *)((NIOS_FLASH_START + NIOS_FLASH_END)>>1);
+ int i=0;
+#endif // krh
+
+ memory_start = PAGE_ALIGN((unsigned long)&_end);
+ memory_end = (unsigned long) nasys_program_mem_end;
+
+#if 0 //;kenw;
+ /* copy the command line from booting paramter region */
+ #if defined (nasys_am29lv065d_flash_0) //;dgt;
+ { //;dgt;
+ // ...TBA... //;dgt;
+ } //;dgt;
+ #else //;dgt;
+ flash_command((int)psrc, 0x555, 0x88);
+ while ((*psrc!=0xFF) && (i<sizeof(command_line))) {
+ command_line[i++]=*psrc++;
+ }
+ command_line[i]=0;
+ exit_se_flash(((NIOS_FLASH_START + NIOS_FLASH_END)>>1) );
+ if (command_line[0]==0)
+ #endif //;dgt;
+#endif //;kenw;
+#ifndef CONFIG_PASS_CMDLINE
+ memcpy(command_line, default_command_line, sizeof(default_command_line));
+#endif
+
+ printk("\x0F\r\n\nuClinux/Nios II\n");
+ printk("Altera Nios II support (C) 2004 Microtronix Datacom Ltd.\n");
+
+#ifdef DEBUG
+ printk("KERNEL -> TEXT=0x%08x-0x%08x DATA=0x%08x-0x%08x "
+ "BSS=0x%08x-0x%08x\n", (int) &_stext, (int) &_etext,
+ (int) &_sdata, (int) &_edata,
+ (int) &_sbss, (int) &_ebss);
+ printk("KERNEL -> MEM=0x%06x-0x%06x STACK=0x%06x-0x%06x\n",
+ (int) memory_start, (int) memory_end,
+ (int) memory_end, (int) nasys_program_mem_end);
+#endif
+
+ init_mm.start_code = (unsigned long) &_stext;
+ init_mm.end_code = (unsigned long) &_etext;
+ init_mm.end_data = (unsigned long) &_edata;
+ init_mm.brk = (unsigned long) 0;
+ init_task.thread.kregs = &fake_regs;
+
+#if 0
+ ROOT_DEV = MKDEV(BLKMEM_MAJOR,0);
+#endif
+
+ /* Keep a copy of command line */
+ *cmdline_p = &command_line[0];
+
+ memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
+ saved_command_line[COMMAND_LINE_SIZE-1] = 0;
+
+#ifdef DEBUG
+ if (strlen(*cmdline_p))
+ printk("Command line: '%s'\n", *cmdline_p);
+ else
+ printk("No Command line passed\n");
+#endif
+
+
+#if defined (CONFIG_CS89x0) || defined (CONFIG_SMC91111) || defined (CONFIG_OPEN_ETH) || defined (CONFIG_MTIP1000_ETH) || defined (CONFIG_DM9000_ETH) || defined (CONFIG_SMC91X) || defined (CONFIG_DM9000) || defined (CONFIG_DM9KS)
+
+ #if defined (CONFIG_MTIP1000_ETH) //;dgt3;
+ (*((np_mtip_mac *) //;dgt3;
+ (na_mtip_mac_control_port))). //;dgt3;
+ COMMAND_CONFIG = 0; //;dgt3;
+ #endif //;dgt3;
+
+ /* now read the hwaddr of the ethernet --wentao*/
+
+ #if 1 //;dgt2;
+// #if defined (nasys_am29lv065d_flash_0) //;dgt;
+ { //;dgt;
+ unsigned char *flashptr = //;dgt;
+ ((unsigned char *) //;dgt;
+ (( //;dgt;
+ #if defined (na_flash_kernel_end) //;dgt2;
+ na_flash_kernel_end //;dgt2;
+ #else //;dgt2;
+ #if defined (na_flash_kernel_base) //;dgt2;
+ na_flash_kernel_base + //;dgt;
+ #else //;dgt2;
+ na_flash_kernel + //;dgt2;
+ #endif //;dgt2;
+ na_flash_kernel_size //;dgt2;
+ #endif //;dgt2;
+ - 0x00010000))); //;dgt;
+ // last 64K of Altera stratix/cyclone flash //;dgt;
+ //;dgt;
+ if((*((unsigned long *) flashptr)) == 0x00005AFE) //;dgt;
+ { //;dgt;
+ memcpy(excalibur_enet_hwaddr_array, //;dgt;
+ ((void*) (flashptr+4)),6); //;dgt;
+ } //;dgt;
+ else //;dgt;
+ { //;dgt;
+ printk("\nsetup_arch: No persistant network" //;dgt;
+ " settings signature at %08lX\n", //;dgt;
+ ((unsigned long) flashptr)); //;dgt;
+ *((unsigned long *) //;dgt;
+ (&(excalibur_enet_hwaddr_array[0]))) = //;dgt;
+ 0x00ED0700; //;dgt2;
+ /* 0x00-07-ED: Altera Corporation. //;dgt; */
+ *((unsigned short *) //;dgt;
+ (&(excalibur_enet_hwaddr_array[4]))) = //;dgt;
+ 0x0000; //;dgt;
+ /* Should be: 0x-00-07-ED-0A-03-(Random# 0-256) //;dgt2; */
+ /* 0x-00-07-ED-0A-xx-yy Vermont boards //;dgt2; */
+ /* 0x-00-07-ED-0B-xx-yy Rhode Island boards //;dgt2; */
+ /* 0x-00-07-ED-0C-xx-yy Delaware boards //;dgt2; */
+ /* 00 Internal Altera //;dgt2; */
+ /* 01 Beta, pre-production//;dgt2; */
+ /* 02 Beta, pre-production//;dgt2; */
+ /* 03 Customer use //;dgt2; */
+ } //;dgt;
+ } //;dgt;
+ #else //;dgt;
+ flash_command(NIOS_FLASH_START, 0x555, 0x88);
+ memcpy(excalibur_enet_hwaddr_array,(void*)NIOS_FLASH_START,6);
+ exit_se_flash(NIOS_FLASH_START);;
+ #endif //;dgt;
+
+ /* now do the checking, make sure we got a valid addr */
+ if (excalibur_enet_hwaddr_array[0] & (unsigned char)1)
+ {
+ printk("Ethernet hardware address:Clearing invalid bit #0\n");
+ excalibur_enet_hwaddr_array[0] ^= (unsigned char)1;
+ }
+ excalibur_enet_hwaddr=excalibur_enet_hwaddr_array;
+#ifdef DEBUG
+ printk("Setup the hardware addr for ethernet\n\t %02x %02x %02x %02x %02x %02x\n",
+ excalibur_enet_hwaddr[0],excalibur_enet_hwaddr[1],
+ excalibur_enet_hwaddr[2],excalibur_enet_hwaddr[3],
+ excalibur_enet_hwaddr[4],excalibur_enet_hwaddr[5]);
+#endif
+#endif
+
+
+ /*
+ * give all the memory to the bootmap allocator, tell it to put the
+ * boot mem_map at the start of memory
+ */
+ bootmap_size = init_bootmem_node(
+ NODE_DATA(0),
+ memory_start >> PAGE_SHIFT, /* map goes here */
+ PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
+ memory_end >> PAGE_SHIFT);
+ /*
+ * free the usable memory, we have to make sure we do not free
+ * the bootmem bitmap so we then reserve it after freeing it :-)
+ */
+ free_bootmem(memory_start, memory_end - memory_start);
+ reserve_bootmem(memory_start, bootmap_size);
+#ifdef CONFIG_BLK_DEV_INITRD
+ if (initrd_start) reserve_bootmem(virt_to_phys((void *)initrd_start), initrd_end - initrd_start);
+#endif /* CONFIG_BLK_DEV_INITRD */
+ /*
+ * get kmalloc into gear
+ */
+ paging_init();
+#ifdef CONFIG_VT
+#if defined(CONFIG_DUMMY_CONSOLE)
+ conswitchp = &dummy_con;
+#endif
+#endif
+
+#ifdef DEBUG
+ printk("Done setup_arch\n");
+#endif
+
+}
+
+int get_cpuinfo(char * buffer)
+{
+ char *cpu, *mmu, *fpu;
+ u_long clockfreq;
+
+ cpu = CPU;
+ mmu = "none";
+ fpu = "none";
+
+ clockfreq = nasys_clock_freq;
+
+ return(sprintf(buffer, "CPU:\t\t%s\n"
+ "MMU:\t\t%s\n"
+ "FPU:\t\t%s\n"
+ "Clocking:\t%lu.%1luMHz\n"
+ "BogoMips:\t%lu.%02lu\n"
+ "Calibration:\t%lu loops\n",
+ cpu, mmu, fpu,
+ clockfreq/1000000,(clockfreq/100000)%10,
+ (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
+ (loops_per_jiffy*HZ)));
+
+}
+
+/*
+ * Get CPU information for use by the procfs.
+ */
+
+static int show_cpuinfo(struct seq_file *m, void *v)
+{
+ char *cpu, *mmu, *fpu;
+ u_long clockfreq;
+
+ cpu = CPU;
+ mmu = "none";
+ fpu = "none";
+
+ clockfreq = nasys_clock_freq;
+
+ seq_printf(m, "CPU:\t\t%s\n"
+ "MMU:\t\t%s\n"
+ "FPU:\t\t%s\n"
+ "Clocking:\t%lu.%1luMHz\n"
+ "BogoMips:\t%lu.%02lu\n"
+ "Calibration:\t%lu loops\n",
+ cpu, mmu, fpu,
+ clockfreq/1000000,(clockfreq/100000)%10,
+ (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
+ (loops_per_jiffy*HZ));
+
+ return 0;
+}
+
+#ifdef CONFIG_NIOS_SPI
+
+static int bcd2char( int x )
+{
+ if ( (x & 0xF) > 0x90 || (x & 0x0F) > 0x09 )
+ return 99;
+
+ return (((x & 0xF0) >> 4) * 10) + (x & 0x0F);
+}
+
+#endif // CONFIG_NIOS_SPI
+
+
+void arch_gettod(int *year, int *month, int *date, int *hour, int *min, int *sec)
+{
+#ifdef CONFIG_NIOS_SPI
+ /********************************************************************/
+ /* Read the CMOS clock on the Microtronix Datacom O/S Support card. */
+ /* Use the SPI driver code, but circumvent the file system by using */
+ /* its internal functions. */
+ /********************************************************************/
+ int hr;
+
+ struct /*********************************/
+ { /* The SPI payload. Warning: the */
+ unsigned short register_addr; /* sizeof() operator will return */
+ unsigned char value; /* a length of 4 instead of 3! */
+ } spi_data; /*********************************/
+
+
+ if ( spi_open( NULL, NULL ) )
+ {
+ printk( "Cannot open SPI driver to read system CMOS clock.\n" );
+ *year = *month = *date = *hour = *min = *sec = 0;
+ return;
+ }
+
+ spi_lseek( NULL, clockCS, 0 /* == SEEK_SET */ );
+
+ spi_data.register_addr = clock_write_control;
+ spi_data.value = 0x40; // Write protect
+ spi_write( NULL, (const char *)&spi_data, 3, NULL );
+
+ spi_data.register_addr = clock_read_sec;
+ spi_data.value = 0;
+ spi_read( NULL, (char *)&spi_data, 3, NULL );
+ *sec = (int)bcd2char( spi_data.value );
+
+ spi_data.register_addr = clock_read_min;
+ spi_data.value = 0;
+ spi_read( NULL, (char *)&spi_data, 3, NULL );
+ *min = (int)bcd2char( spi_data.value );
+
+ spi_data.register_addr = clock_read_hour;
+ spi_data.value = 0;
+ spi_read( NULL, (char *)&spi_data, 3, NULL );
+ hr = (int)bcd2char( spi_data.value );
+ if ( hr & 0x40 ) // Check 24-hr bit
+ hr = (hr & 0x3F) + 12; // Convert to 24-hr
+
+ *hour = hr;
+
+
+
+ spi_data.register_addr = clock_read_date;
+ spi_data.value = 0;
+ spi_read( NULL, (char *)&spi_data, 3, NULL );
+ *date = (int)bcd2char( spi_data.value );
+
+ spi_data.register_addr = clock_read_month;
+ spi_data.value = 0;
+ spi_read( NULL, (char *)&spi_data, 3, NULL );
+ *month = (int)bcd2char( spi_data.value );
+
+ spi_data.register_addr = clock_read_year;
+ spi_data.value = 0;
+ spi_read( NULL, (char *)&spi_data, 3, NULL );
+ *year = (int)bcd2char( spi_data.value );
+
+
+ spi_release( NULL, NULL );
+#else
+ *year = *month = *date = *hour = *min = *sec = 0;
+
+#endif
+}
+
+static void *cpuinfo_start (struct seq_file *m, loff_t *pos)
+{
+ return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
+}
+
+static void *cpuinfo_next (struct seq_file *m, void *v, loff_t *pos)
+{
+ ++*pos;
+ return cpuinfo_start (m, pos);
+}
+
+static void cpuinfo_stop (struct seq_file *m, void *v)
+{
+}
+
+struct seq_operations cpuinfo_op = {
+ start: cpuinfo_start,
+ next: cpuinfo_next,
+ stop: cpuinfo_stop,
+ show: show_cpuinfo
+};
+
+
+// adapted from linux/arch/arm/mach-versatile/core.c and mach-bast
+// note, hardware MAC address is still undefined
+
+#if defined(CONFIG_SMC91X) && defined(na_enet)
+
+#ifndef LAN91C111_REGISTERS_OFFSET
+#define LAN91C111_REGISTERS_OFFSET 0x300
+#endif
+
+static struct resource smc91x_resources[] = {
+ [0] = {
+ .start = na_enet + LAN91C111_REGISTERS_OFFSET,
+ .end = na_enet + LAN91C111_REGISTERS_OFFSET + 0x100 - 1, // 32bits,64k, LAN91C111_REGISTERS_OFFSET 0x0300 ?
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = na_enet_irq,
+ .end = na_enet_irq,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device smc91x_device = {
+ .name = "smc91x",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(smc91x_resources),
+ .resource = smc91x_resources,
+};
+static int __init smc91x_device_init(void)
+{
+ /* customizes platform devices, or adds new ones */
+ platform_device_register(&smc91x_device);
+ return 0;
+}
+arch_initcall(smc91x_device_init);
+#endif // CONFIG_SMC91X
+
+
+#if defined(na_DM9000A) && !defined(na_dm9000) // defs for DE2
+#define na_dm9000 na_DM9000A
+#define na_dm9000_irq na_DM9000A_irq
+#endif
+
+#if defined(CONFIG_DM9000) && defined(na_dm9000)
+#include <linux/dm9000.h>
+static struct resource dm9k_resource[] = {
+ [0] = {
+ .start = na_dm9000,
+ .end = na_dm9000 + 3,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = na_dm9000 + 4,
+ .end = na_dm9000 + 4 + 3,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = {
+ .start = na_dm9000_irq,
+ .end = na_dm9000_irq,
+ .flags = IORESOURCE_IRQ,
+ }
+
+};
+static struct dm9000_plat_data dm9k_platdata = {
+ .flags = DM9000_PLATF_16BITONLY,
+};
+static struct platform_device dm9k_device = {
+ .name = "dm9000",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(dm9k_resource),
+ .resource = dm9k_resource,
+ .dev = {
+ .platform_data = &dm9k_platdata,
+ }
+};
+static int __init dm9k_device_init(void)
+{
+ /* customizes platform devices, or adds new ones */
+ platform_device_register(&dm9k_device);
+ return 0;
+}
+arch_initcall(dm9k_device_init);
+#endif // CONFIG_DM9000
+
+
+#if defined(CONFIG_SERIO_ALTPS2) && defined(na_ps2_0)
+
+static struct resource altps2_0_resources[] = {
+ [0] = {
+ .start = na_ps2_0,
+ .end = na_ps2_0 + 0x8 - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = na_ps2_0_irq,
+ .end = na_ps2_0_irq,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device altps2_0_device = {
+ .name = "altps2",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(altps2_0_resources),
+ .resource = altps2_0_resources,
+};
+
+#if defined(na_ps2_1)
+static struct resource altps2_1_resources[] = {
+ [0] = {
+ .start = na_ps2_1,
+ .end = na_ps2_1 + 0x8 - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = na_ps2_1_irq,
+ .end = na_ps2_1_irq,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device altps2_1_device = {
+ .name = "altps2",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(altps2_1_resources),
+ .resource = altps2_1_resources,
+};
+#endif // na_ps2_1
+
+static int __init altps2_device_init(void)
+{
+ /* customizes platform devices, or adds new ones */
+ platform_device_register(&altps2_0_device);
+#if defined(na_ps2_1)
+ platform_device_register(&altps2_1_device);
+#endif // na_ps2_1
+ return 0;
+}
+arch_initcall(altps2_device_init);
+#endif // CONFIG_SERIO_ALTPS2
+
+#if defined(CONFIG_I2C_NIOS2_GPIO) && defined(na_gpio_0)
+#include <asm/gpio.h>
+
+static struct gpio_i2c_pins i2c_gpio_0_pins = {
+ .sda_pin = (na_gpio_0+(0<<2)),
+ .scl_pin = (na_gpio_0+(1<<2)),
+};
+
+static struct platform_device i2c_gpio_0_controller = {
+ .name = "GPIO-I2C",
+ .id = 0,
+ .dev = {
+ .platform_data = &i2c_gpio_0_pins,
+ },
+ .num_resources = 0
+};
+
+static int __init i2c_gpio_device_init(void)
+{
+ /* customizes platform devices, or adds new ones */
+ platform_device_register(&i2c_gpio_0_controller);
+ return 0;
+}
+arch_initcall(i2c_gpio_device_init);
+
+#endif // CONFIG_I2C_NIOS2_GPIO
diff --git a/arch/nios2nommu/kernel/signal.c b/arch/nios2nommu/kernel/signal.c
new file mode 100644
index 0000000..d8c30dc
--- /dev/null
+++ b/arch/nios2nommu/kernel/signal.c
@@ -0,0 +1,738 @@
+/*
+ * linux/arch/nios2nommu/kernel/signal.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive
+ * for more details.
+ *
+ * Linux/m68k support by Hamish Macdonald
+ *
+ * 68060 fixes by Jesper Skov
+ *
+ * 1997-12-01 Modified for POSIX.1b signals by Andreas Schwab
+ *
+ * mathemu support by Roman Zippel
+ * (Note: fpstate in the signal context is completely ignored for the emulator
+ * and the internal floating point format is put on stack)
+ *
+ * ++roman (07/09/96): implemented signal stacks (specially for tosemu on
+ * Atari :-) Current limitation: Only one sigstack can be active at one time.
+ * If a second signal with SA_ONSTACK set arrives while working on a sigstack,
+ * SA_ONSTACK is ignored. This behaviour avoids lots of trouble with nested
+ * signal handlers!
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ */
+
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/kernel.h>
+#include <linux/signal.h>
+#include <linux/errno.h>
+#include <linux/wait.h>
+#include <linux/ptrace.h>
+#include <linux/unistd.h>
+#include <linux/stddef.h>
+#include <linux/highuid.h>
+#include <linux/tty.h>
+#include <linux/personality.h>
+#include <linux/binfmts.h>
+
+#include <asm/setup.h>
+#include <asm/uaccess.h>
+#include <asm/pgtable.h>
+#include <asm/traps.h>
+#include <asm/ucontext.h>
+
+#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
+
+asmlinkage long sys_wait4(pid_t pid, unsigned int * stat_addr, int options,
+ struct rusage * ru);
+asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs);
+
+/*
+ * Atomically swap in the new signal mask, and wait for a signal.
+ */
+asmlinkage int do_sigsuspend(struct pt_regs *regs)
+{
+ old_sigset_t mask = regs->r4; // Verify correct syscall reg
+ sigset_t saveset;
+
+ mask &= _BLOCKABLE;
+ spin_lock_irq(¤t->sighand->siglock);
+ saveset = current->blocked;
+ siginitset(¤t->blocked, mask);
+ recalc_sigpending();
+ spin_unlock_irq(¤t->sighand->siglock);
+
+ regs->r2 = -EINTR;
+ while (1) {
+ current->state = TASK_INTERRUPTIBLE;
+ schedule();
+ if (do_signal(&saveset, regs))
+ return -EINTR;
+ }
+}
+
+asmlinkage int
+do_rt_sigsuspend(struct pt_regs *regs)
+{
+ sigset_t *unewset = (sigset_t *)regs->r4;
+ size_t sigsetsize = (size_t)regs->r5;
+ sigset_t saveset, newset;
+
+ /* XXX: Don't preclude handling different sized sigset_t's. */
+ if (sigsetsize != sizeof(sigset_t))
+ return -EINVAL;
+
+ if (copy_from_user(&newset, unewset, sizeof(newset)))
+ return -EFAULT;
+ sigdelsetmask(&newset, ~_BLOCKABLE);
+
+ spin_lock_irq(¤t->sighand->siglock);
+ saveset = current->blocked;
+ current->blocked = newset;
+ recalc_sigpending();
+ spin_unlock_irq(¤t->sighand->siglock);
+
+ regs->r2 = -EINTR;
+ while (1) {
+ current->state = TASK_INTERRUPTIBLE;
+ schedule();
+ if (do_signal(&saveset, regs))
+ return -EINTR;
+ }
+}
+
+asmlinkage int
+sys_sigaction(int sig, const struct old_sigaction *act,
+ struct old_sigaction *oact)
+{
+ struct k_sigaction new_ka, old_ka;
+ int ret;
+
+ if (act) {
+ old_sigset_t mask;
+ if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
+ __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
+ __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
+ return -EFAULT;
+ __get_user(new_ka.sa.sa_flags, &act->sa_flags);
+ __get_user(mask, &act->sa_mask);
+ siginitset(&new_ka.sa.sa_mask, mask);
+ }
+
+ ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
+
+ if (!ret && oact) {
+ if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
+ __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
+ __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
+ return -EFAULT;
+ __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
+ __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
+ }
+
+ return ret;
+}
+
+/*
+ * Do a signal return; undo the signal stack.
+ *
+ * Keep the return code on the stack quadword aligned!
+ * That makes the cache flush below easier.
+ */
+
+
+struct sigframe
+{
+ char retcode[12];
+ unsigned long extramask[_NSIG_WORDS-1];
+ struct sigcontext sc;
+};
+
+struct rt_sigframe
+{
+ char retcode[12];
+ struct siginfo info;
+ struct ucontext uc;
+};
+
+#ifdef CONFIG_FPU
+
+static unsigned char fpu_version = 0; /* version number of fpu, set by setup_frame */
+
+static inline int restore_fpu_state(struct sigcontext *sc)
+{
+ int err = 1;
+
+ if (FPU_IS_EMU) {
+ /* restore registers */
+ memcpy(current->thread.fpcntl, sc->sc_fpcntl, 12);
+ memcpy(current->thread.fp, sc->sc_fpregs, 24);
+ return 0;
+ }
+
+ if (sc->sc_fpstate[0]) {
+ /* Verify the frame format. */
+ if (sc->sc_fpstate[0] != fpu_version)
+ goto out;
+
+ __asm__ volatile ("Nios II FPU"
+ : /* no outputs */
+ : );
+ }
+ __asm__ volatile ("Nios II FPU"
+ : : );
+ err = 0;
+
+out:
+ return err;
+}
+
+#define FPCONTEXT_SIZE 216
+#define uc_fpstate uc_filler[0]
+#define uc_formatvec uc_filler[FPCONTEXT_SIZE/4]
+#define uc_extra uc_filler[FPCONTEXT_SIZE/4+1]
+
+static inline int rt_restore_fpu_state(struct ucontext *uc)
+{
+ unsigned char fpstate[FPCONTEXT_SIZE];
+ int context_size = 0;
+ fpregset_t fpregs;
+ int err = 1;
+
+ if (FPU_IS_EMU) {
+ /* restore fpu control register */
+ if (__copy_from_user(current->thread.fpcntl,
+ &uc->uc_mcontext.fpregs.f_pcr, 12))
+ goto out;
+ /* restore all other fpu register */
+ if (__copy_from_user(current->thread.fp,
+ uc->uc_mcontext.fpregs.f_fpregs, 96))
+ goto out;
+ return 0;
+ }
+
+ if (__get_user(*(long *)fpstate, (long *)&uc->uc_fpstate))
+ goto out;
+ if (fpstate[0]) {
+ context_size = fpstate[1];
+
+ /* Verify the frame format. */
+ if (fpstate[0] != fpu_version)
+ goto out;
+ if (__copy_from_user(&fpregs, &uc->uc_mcontext.fpregs,
+ sizeof(fpregs)))
+ goto out;
+ __asm__ volatile ("Nios II FPU"
+ : /* no outputs */
+ : );
+ }
+ if (context_size &&
+ __copy_from_user(fpstate + 4, (long *)&uc->uc_fpstate + 1,
+ context_size))
+ goto out;
+ __asm__ volatile ("Nios II FPU"
+ : : );
+ err = 0;
+
+out:
+ return err;
+}
+
+#endif
+
+static inline int
+restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp,
+ int *pr2)
+{
+ int err = 0;
+ int estatus;
+
+ estatus = regs->estatus;
+
+ /* get previous pt_regs */
+ if (copy_from_user(regs, &usc->regs, sizeof(*regs)))
+ goto badframe;
+
+ /* Prevent user from being able to change
+ * certain processor status bits. Currently nothing.
+ */
+ regs->estatus = (estatus & 0xffffffff) | (regs->estatus & 0);
+
+ *pr2 = regs->r2;
+ regs->orig_r2 = -1; /* disable syscall checks */
+
+#ifdef CONFIG_FPU
+ err |= restore_fpu_state(&context);
+#endif
+
+ return err;
+
+badframe:
+ return 1;
+}
+
+static inline int
+rt_restore_ucontext(struct pt_regs *regs, struct switch_stack *sw,
+ struct ucontext *uc, int *pr2)
+{
+ int temp;
+ greg_t *gregs = uc->uc_mcontext.gregs;
+ unsigned long usp;
+ int err;
+
+ err = __get_user(temp, &uc->uc_mcontext.version);
+ if (temp != MCONTEXT_VERSION)
+ goto badframe;
+ /* restore passed registers */
+ err |= __get_user(regs->r1, &gregs[0]);
+ err |= __get_user(regs->r2, &gregs[1]);
+ err |= __get_user(regs->r3, &gregs[2]);
+ err |= __get_user(regs->r4, &gregs[3]);
+ err |= __get_user(regs->r5, &gregs[4]);
+ err |= __get_user(regs->r6, &gregs[5]);
+ err |= __get_user(regs->r7, &gregs[6]);
+ err |= __get_user(regs->r8, &gregs[7]);
+ err |= __get_user(regs->r9, &gregs[8]);
+ err |= __get_user(regs->r10, &gregs[9]);
+ err |= __get_user(regs->r11, &gregs[10]);
+ err |= __get_user(regs->r12, &gregs[11]);
+ err |= __get_user(regs->r13, &gregs[12]);
+ err |= __get_user(regs->r14, &gregs[13]);
+ err |= __get_user(regs->r15, &gregs[14]);
+ err |= __get_user(sw->r16, &gregs[15]);
+ err |= __get_user(sw->r17, &gregs[16]);
+ err |= __get_user(sw->r18, &gregs[17]);
+ err |= __get_user(sw->r19, &gregs[18]);
+ err |= __get_user(sw->r20, &gregs[19]);
+ err |= __get_user(sw->r21, &gregs[20]);
+ err |= __get_user(sw->r22, &gregs[21]);
+ err |= __get_user(sw->r23, &gregs[22]);
+ err |= __get_user(usp, &gregs[23]);
+ err |= __get_user(sw->fp, &gregs[24]); // Verify, should this be settable
+ err |= __get_user(sw->gp, &gregs[25]); // Verify, should this be settable
+
+ err |= __get_user(temp, &gregs[26]); // Not really necessary no user settable bits
+ regs->estatus = (regs->estatus & 0xffffffff) | (temp & 0x0);
+ err |= __get_user(regs->status_extension,
+ &uc->uc_mcontext.status_extension);
+ regs->orig_r2 = -1; /* disable syscall checks */
+
+ if (do_sigaltstack(&uc->uc_stack, NULL, usp) == -EFAULT)
+ goto badframe;
+
+ *pr2 = regs->r2;
+ return err;
+
+badframe:
+ return 1;
+}
+
+asmlinkage int do_sigreturn(struct pt_regs *regs)
+{
+ struct sigframe *frame = (struct sigframe *) regs->sp;
+ sigset_t set;
+ int rval;
+
+ if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
+ goto badframe;
+ if (__get_user(set.sig[0], &frame->sc.sc_mask) ||
+ (_NSIG_WORDS > 1 &&
+ __copy_from_user(&set.sig[1], &frame->extramask,
+ sizeof(frame->extramask))))
+ goto badframe;
+
+ sigdelsetmask(&set, ~_BLOCKABLE);
+ spin_lock_irq(¤t->sighand->siglock);
+ current->blocked = set;
+ recalc_sigpending();
+ spin_unlock_irq(¤t->sighand->siglock);
+
+ if (restore_sigcontext(regs, &frame->sc, frame + 1, &rval))
+ goto badframe;
+ return rval;
+
+badframe:
+ force_sig(SIGSEGV, current);
+ return 0;
+}
+
+asmlinkage int do_rt_sigreturn(struct switch_stack *sw)
+{
+ struct pt_regs *regs = (struct pt_regs *) sw + 1;
+ struct rt_sigframe *frame = (struct rt_sigframe *) regs->sp; // Verify, can we follow the stack back
+ sigset_t set;
+ int rval;
+
+ if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
+ goto badframe;
+ if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
+ goto badframe;
+
+ sigdelsetmask(&set, ~_BLOCKABLE);
+ spin_lock_irq(¤t->sighand->siglock);
+ current->blocked = set;
+ recalc_sigpending();
+ spin_unlock_irq(¤t->sighand->siglock);
+
+ if (rt_restore_ucontext(regs, sw, &frame->uc, &rval))
+ goto badframe;
+ return rval;
+
+badframe:
+ force_sig(SIGSEGV, current);
+ return 0;
+}
+
+#ifdef CONFIG_FPU
+/*
+ * Set up a signal frame.
+ *
+ * Not converted, no FPU support at moment.
+ */
+
+static inline int save_fpu_state(struct sigcontext *sc, struct pt_regs *regs)
+{
+ int err = 0;
+
+ if (FPU_IS_EMU) {
+ /* save registers */
+ err |= copy_to_user(&sc->sc_fpcntl, current->thread.fpcntl, 12);
+ err |= copy_to_user(&sc->sc_fpregs, current->thread.fp, 24);
+ return err;
+ }
+
+ __asm__ volatile ("Nios II FPUt"
+ : : );
+
+ if (sc->sc_fpstate[0]) {
+ fpu_version = sc->sc_fpstate[0];
+ __asm__ volatile ("Nios II FPU"
+ : /* no outputs */
+ :
+ : );
+ }
+ return err;
+}
+
+static inline int rt_save_fpu_state(struct ucontext *uc, struct pt_regs *regs)
+{
+ unsigned char fpstate[FPCONTEXT_SIZE];
+ int context_size = 0;
+ int err = 0;
+
+ if (FPU_IS_EMU) {
+ /* save fpu control register */
+ err |= copy_to_user(&uc->uc_mcontext.fpregs.f_pcr,
+ current->thread.fpcntl, 12);
+ /* save all other fpu register */
+ err |= copy_to_user(uc->uc_mcontext.fpregs.f_fpregs,
+ current->thread.fp, 96);
+ return err;
+ }
+
+ __asm__ volatile ("Nios II FPU"
+ : : : );
+
+ err |= __put_user(*(long *)fpstate, (long *)&uc->uc_fpstate);
+ if (fpstate[0]) {
+ fpregset_t fpregs;
+ context_size = fpstate[1];
+ fpu_version = fpstate[0];
+ __asm__ volatile ("Nios II FPU"
+ : /* no outputs */
+ :
+ : );
+ err |= copy_to_user(&uc->uc_mcontext.fpregs, &fpregs,
+ sizeof(fpregs));
+ }
+ if (context_size)
+ err |= copy_to_user((long *)&uc->uc_fpstate + 1, fpstate + 4,
+ context_size);
+ return err;
+}
+
+#endif
+
+static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
+ unsigned long mask)
+{
+ int err = 0;
+
+ err |= __put_user(mask, &sc->sc_mask);
+ err |= copy_to_user(&sc->regs, regs, sizeof(*regs));
+#ifdef CONFIG_FPU
+ err |= save_fpu_state(sc, regs);
+#endif
+ return err;
+}
+
+static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)
+{
+ struct switch_stack *sw = (struct switch_stack *)regs - 1;
+ greg_t *gregs = uc->uc_mcontext.gregs;
+ int err = 0;
+
+ err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);
+ err |= __put_user(regs->status_extension,
+ &uc->uc_mcontext.status_extension);
+ err |= __put_user(regs->r1, &gregs[0]);
+ err |= __put_user(regs->r2, &gregs[1]);
+ err |= __put_user(regs->r3, &gregs[2]);
+ err |= __put_user(regs->r4, &gregs[3]);
+ err |= __put_user(regs->r5, &gregs[4]);
+ err |= __put_user(regs->r6, &gregs[5]);
+ err |= __put_user(regs->r7, &gregs[6]);
+ err |= __put_user(regs->r8, &gregs[7]);
+ err |= __put_user(regs->r9, &gregs[8]);
+ err |= __put_user(regs->r10, &gregs[9]);
+ err |= __put_user(regs->r11, &gregs[10]);
+ err |= __put_user(regs->r12, &gregs[11]);
+ err |= __put_user(regs->r13, &gregs[12]);
+ err |= __put_user(regs->r14, &gregs[13]);
+ err |= __put_user(regs->r15, &gregs[14]);
+ err |= __put_user(sw->r16, &gregs[15]);
+ err |= __put_user(sw->r17, &gregs[16]);
+ err |= __put_user(sw->r18, &gregs[17]);
+ err |= __put_user(sw->r19, &gregs[18]);
+ err |= __put_user(sw->r20, &gregs[19]);
+ err |= __put_user(sw->r21, &gregs[20]);
+ err |= __put_user(sw->r22, &gregs[21]);
+ err |= __put_user(sw->r23, &gregs[22]);
+ err |= __put_user(regs->sp, &gregs[23]);
+ err |= __put_user(sw->fp, &gregs[24]);
+ err |= __put_user(sw->gp, &gregs[25]);
+#ifdef CONFIG_FPU
+ err |= rt_save_fpu_state(uc, regs);
+#endif
+ return err;
+}
+
+extern void cache_push_v (unsigned long vaddr, int len);
+
+static inline void push_cache (unsigned long vaddr)
+{
+ cache_push_v(vaddr,12);
+}
+
+static inline void *
+get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
+{
+ unsigned long usp;
+
+ /* Default to using normal stack. */
+ usp = regs->sp;
+
+ /* This is the X/Open sanctioned signal stack switching. */
+ if (ka->sa.sa_flags & SA_ONSTACK) {
+ if (!on_sig_stack(usp))
+ usp = current->sas_ss_sp + current->sas_ss_size;
+ }
+ return (void *)((usp - frame_size) & -8UL); // Verify, is it 32 or 64 bit aligned
+}
+
+static void setup_frame (int sig, struct k_sigaction *ka,
+ sigset_t *set, struct pt_regs *regs)
+{
+ struct sigframe *frame;
+ int err = 0;
+
+ frame = get_sigframe(ka, regs, sizeof(*frame));
+
+ if (_NSIG_WORDS > 1)
+ err |= copy_to_user(frame->extramask, &set->sig[1],
+ sizeof(frame->extramask));
+
+ err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
+
+ /* Set up to return from userspace. */
+ regs->ra = (unsigned long) &frame->retcode[0];
+ /* movi r3,__NR_sigreturn */
+ err |= __put_user(0x00c00004 + (__NR_sigreturn << 6), (long *)(frame->retcode));
+ /* mov r2,r0 */
+ err |= __put_user(0x0005883a, (long *)(frame->retcode + 4));
+ /* trap */
+ err |= __put_user(0x003b683a, (long *)(frame->retcode + 8));
+
+ if (err)
+ goto give_sigsegv;
+
+ push_cache ((unsigned long) &frame->retcode);
+
+ /* Set up registers for signal handler */
+ regs->sp = (unsigned long) frame;
+ regs->r4 = (unsigned long) (current_thread_info()->exec_domain
+ && current_thread_info()->exec_domain->signal_invmap
+ && sig < 32
+ ? current_thread_info()->exec_domain->signal_invmap[sig]
+ : sig);
+ regs->ea = (unsigned long) ka->sa.sa_handler;
+ return;
+
+give_sigsegv:
+ if (sig == SIGSEGV)
+ ka->sa.sa_handler = SIG_DFL;
+ force_sig(SIGSEGV, current);
+}
+
+static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
+ sigset_t *set, struct pt_regs *regs)
+{
+ struct rt_sigframe *frame;
+ int err = 0;
+
+ frame = get_sigframe(ka, regs, sizeof(*frame));
+
+ err |= copy_siginfo_to_user(&frame->info, info);
+
+ /* Create the ucontext. */
+ err |= __put_user(0, &frame->uc.uc_flags);
+ err |= __put_user(0, &frame->uc.uc_link);
+ err |= __put_user((void *)current->sas_ss_sp,
+ &frame->uc.uc_stack.ss_sp);
+ err |= __put_user(sas_ss_flags(regs->sp),
+ &frame->uc.uc_stack.ss_flags);
+ err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
+ err |= rt_setup_ucontext(&frame->uc, regs);
+ err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set));
+
+ /* Set up to return from userspace. */
+ regs->ra = (unsigned long) &frame->retcode[0];
+ /* movi r3,__NR_rt_sigreturn */
+ err |= __put_user(0x00c00004 + (__NR_rt_sigreturn << 6), (long *)(frame->retcode));
+ /* mov r2,r0 */
+ err |= __put_user(0x0005883a, (long *)(frame->retcode + 4));
+ /* trap */
+ err |= __put_user(0x003b683a, (long *)(frame->retcode + 8));
+
+ if (err)
+ goto give_sigsegv;
+
+ push_cache ((unsigned long) &frame->retcode);
+
+ /* Set up registers for signal handler */
+ regs->sp = (unsigned long) frame;
+ regs->r4 = (unsigned long) (current_thread_info()->exec_domain
+ && current_thread_info()->exec_domain->signal_invmap
+ && sig < 32
+ ? current_thread_info()->exec_domain->signal_invmap[sig]
+ : sig);
+ regs->r5 = (unsigned long) &frame->info;
+ regs->r6 = (unsigned long) &frame->uc;
+ regs->ea = (unsigned long) ka->sa.sa_handler;
+ return;
+
+give_sigsegv:
+ if (sig == SIGSEGV)
+ ka->sa.sa_handler = SIG_DFL;
+ force_sig(SIGSEGV, current);
+}
+
+static inline void
+handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
+{
+ switch (regs->r2) {
+ case -ERESTARTNOHAND:
+ if (!has_handler)
+ goto do_restart;
+ regs->r2 = -EINTR;
+ break;
+
+ case -ERESTARTSYS:
+ if (has_handler && !(ka->sa.sa_flags & SA_RESTART)) {
+ regs->r2 = -EINTR;
+ break;
+ }
+ /* fallthrough */
+ case -ERESTARTNOINTR:
+ do_restart:
+ regs->r2 = regs->orig_r2;
+ regs->ea -= 4;
+ break;
+ }
+}
+
+/*
+ * OK, we're invoking a handler
+ */
+static void
+handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
+ sigset_t *oldset, struct pt_regs *regs)
+{
+ /* are we from a system call? */
+ if (regs->orig_r2 >= 0)
+ /* If so, check system call restarting.. */
+ handle_restart(regs, ka, 1);
+
+ /* set up the stack frame */
+ if (ka->sa.sa_flags & SA_SIGINFO)
+ setup_rt_frame(sig, ka, info, oldset, regs);
+ else
+ setup_frame(sig, ka, oldset, regs);
+
+ if (ka->sa.sa_flags & SA_ONESHOT)
+ ka->sa.sa_handler = SIG_DFL;
+
+ if (!(ka->sa.sa_flags & SA_NODEFER)) {
+ spin_lock_irq(¤t->sighand->siglock);
+ sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
+ sigaddset(¤t->blocked,sig);
+ recalc_sigpending();
+ spin_unlock_irq(¤t->sighand->siglock);
+ }
+}
+
+/*
+ * Note that 'init' is a special process: it doesn't get signals it doesn't
+ * want to handle. Thus you cannot kill init even with a SIGKILL even by
+ * mistake.
+ */
+asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs)
+{
+ struct k_sigaction ka;
+ siginfo_t info;
+ int signr;
+
+ /*
+ * We want the common case to go fast, which
+ * is why we may in certain cases get here from
+ * kernel mode. Just return without doing anything
+ * if so.
+ */
+ if (!user_mode(regs))
+ return 1;
+
+ /* FIXME - Do we still need to do this ? */
+ current->thread.kregs = regs;
+
+ if (!oldset)
+ oldset = ¤t->blocked;
+
+ signr = get_signal_to_deliver(&info, &ka, regs, NULL);
+ if (signr > 0) {
+ /* Whee! Actually deliver the signal. */
+ handle_signal(signr, &ka, &info, oldset, regs);
+ return 1;
+ }
+
+ /* Did we come from a system call? */
+ if (regs->orig_r2 >= 0){
+ /* Restart the system call - no handlers present */
+ if (regs->r2 == -ERESTARTNOHAND
+ || regs->r2 == -ERESTARTSYS
+ || regs->r2 == -ERESTARTNOINTR) {
+ regs->r2 = regs->orig_r2;
+ regs->ea -= 4;
+ } else if (regs->r2 == -ERESTART_RESTARTBLOCK) {
+ regs->r2 = __NR_restart_syscall;
+ regs->ea -= 4;
+ }
+ }
+ return 0;
+}
diff --git a/arch/nios2nommu/kernel/start.c b/arch/nios2nommu/kernel/start.c
new file mode 100644
index 0000000..bca81fc
--- /dev/null
+++ b/arch/nios2nommu/kernel/start.c
@@ -0,0 +1,502 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/kernel/start.c
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ * May/20/2005 dgt Altera NiosII Custom shift instr(s)
+ * possibly assumed by memcpy, etc; ensure
+ * "correct" core loaded therefore if so.
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/system.h>
+#include <asm/nios.h>
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/time.h>
+#include <linux/start_kernel.h>
+
+ #ifdef CONFIG_SERIAL_AJUART //;dgt;20may05;
+ #ifdef CONFIG_SERIAL_AJUART_CONSOLE //;dgt;20may05;
+
+ #include <linux/console.h> //;dgt;20may05;
+ #include <asm/altera_juart.h> //;dgt;20may05;
+
+ extern struct console juart_console; //;dgt;20may05;
+
+ #endif // CONFIG_SERIAL_AJUART //;dgt;20may05;
+ #endif // CONFIG_SERIAL_AJUART_CONSOLE //;dgt;20may05;
+
+//;dgt;20may05; #ifdef CONFIG_CRC_CHECK
+
+// #if defined(CONFIG_NIOS_SERIAL) //;dgt;20may05;
+// #if defined(CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;20may05;
+ #if defined(nasys_printf_uart) //;dgt;20may05;
+ static void putsNoNewLine( unsigned char *s )
+ {
+ while(*s) {
+ while (!(nasys_printf_uart->np_uartstatus &
+ np_uartstatus_trdy_mask));
+ nasys_printf_uart->np_uarttxdata = *s++;
+ }
+ }
+
+ #define NL "\r\n"
+ static void puts(unsigned char *s)
+ {
+ putsNoNewLine( s );
+ putsNoNewLine( NL );
+ }
+ #endif // nasys_printf_uart //;dgt;20may05;
+// #endif // CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;20may05;
+// #endif // CONFIG_NIOS_SERIAL) //;dgt;20may05;
+
+#ifdef CONFIG_CRC_CHECK //;dgt;20may05;
+
+#if 1
+#define outchar(X) { \
+ while (!(nasys_printf_uart->np_uartstatus & np_uartstatus_trdy_mask)); \
+ nasys_printf_uart->np_uarttxdata = (X); }
+#else
+#define outchar(X) putchar(X)
+#endif
+#define outhex(X,Y) { \
+ unsigned long __w; \
+ __w = ((X) >> (Y)) & 0xf; \
+ __w = __w > 0x9 ? 'A' + __w - 0xa : '0' + __w; \
+ outchar(__w); }
+#define outhex8(X) { \
+ outhex(X,4); \
+ outhex(X,0); }
+#define outhex16(X) { \
+ outhex(X,12); \
+ outhex(X,8); \
+ outhex(X,4); \
+ outhex(X,0); }
+#define outhex32(X) { \
+ outhex(X,28); \
+ outhex(X,24); \
+ outhex(X,20); \
+ outhex(X,16); \
+ outhex(X,12); \
+ outhex(X,8); \
+ outhex(X,4); \
+ outhex(X,0); }
+#endif
+
+#if 0
+static unsigned long testvar = 0xdeadbeef;
+#endif
+
+#ifdef CONFIG_CRC_CHECK
+
+
+/******************************************************/
+
+
+extern unsigned long __CRC_Table_Begin;
+
+typedef unsigned char U8;
+typedef unsigned long U32;
+
+/* Table of CRC-32's of all single byte values */
+const U32 crc_32_tab[] = {
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+};
+
+U32 Calc_CRC( const U8 *p, U32 len )
+{
+ U32 crc = (U32)~0L;
+ while (len--)
+ crc = crc_32_tab[0xFF & (crc ^ *p++)] ^ (crc >> 8);
+
+ return crc ^ (U32)~0L;
+}
+
+
+
+/******************************************************/
+
+
+/* hjz: Following time stuff is hacked and modified from uC-libc (various files), which in turn was... */
+/* This is adapted from glibc */
+/* Copyright (C) 1991, 1993 Free Software Foundation, Inc */
+
+#define SECS_PER_HOUR 3600L
+#define SECS_PER_DAY 86400L
+typedef unsigned long time_t;
+
+
+static const unsigned short int __mon_lengths[2][12] = {
+ /* Normal years. */
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+ /* Leap years. */
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
+};
+/* This global is exported to the wide world in keeping
+ * with the interface in time.h */
+long int timezone = 0;
+
+static const char *dayOfWeek[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+static const char *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+
+/* Nonzero if YEAR is a leap year (every 4 years,
+ except every 100th isn't, and every 400th is). */
+# define __isleap(year) ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
+
+struct tm
+{
+ int tm_sec; /* Seconds. [0-60] (1 leap second) */
+ int tm_min; /* Minutes. [0-59] */
+ int tm_hour; /* Hours. [0-23] */
+ int tm_mday; /* Day. [1-31] */
+ int tm_mon; /* Month. [0-11] */
+ int tm_year; /* Year - 1900. */
+ int tm_wday; /* Day of week. [0-6] */
+ int tm_yday; /* Days in year.[0-365] */
+ int tm_isdst; /* DST. [-1/0/1]*/
+
+# ifdef __USE_BSD
+ long int tm_gmtoff; /* Seconds east of UTC. */
+ __const char *tm_zone; /* Timezone abbreviation. */
+# else
+ long int __tm_gmtoff; /* Seconds east of UTC. */
+ __const char *__tm_zone; /* Timezone abbreviation. */
+# endif
+};
+
+void __tm_conv(struct tm *tmbuf, time_t *t, time_t offset)
+{
+ long days, rem;
+ register int y;
+ register const unsigned short int *ip;
+
+ timezone = -offset;
+
+ days = *t / SECS_PER_DAY;
+ rem = *t % SECS_PER_DAY;
+ rem += offset;
+ while (rem < 0)
+ {
+ rem += SECS_PER_DAY;
+ days--;
+ }
+ while (rem >= SECS_PER_DAY)
+ {
+ rem -= SECS_PER_DAY;
+ days++;
+ }
+
+ tmbuf->tm_hour = rem / SECS_PER_HOUR;
+ rem %= SECS_PER_HOUR;
+ tmbuf->tm_min = rem / 60;
+ tmbuf->tm_sec = rem % 60;
+
+ /* January 1, 1970 was a Thursday. */
+ tmbuf->tm_wday = (4 + days) % 7;
+ if (tmbuf->tm_wday < 0)
+ tmbuf->tm_wday += 7;
+
+ y = 1970;
+ while (days >= (rem = __isleap(y) ? 366 : 365))
+ {
+ y++;
+ days -= rem;
+ }
+
+ while (days < 0)
+ {
+ y--;
+ days += __isleap(y) ? 366 : 365;
+ }
+
+ tmbuf->tm_year = y - 1900;
+ tmbuf->tm_yday = days;
+
+ ip = __mon_lengths[__isleap(y)];
+ for (y = 0; days >= ip[y]; ++y)
+ days -= ip[y];
+
+ tmbuf->tm_mon = y;
+ tmbuf->tm_mday = days + 1;
+ tmbuf->tm_isdst = -1;
+}
+
+
+
+/* hjz: NOT your traditional ctime: This one includes timezone */
+/* (UTC) and excludes the traditional trailing newline. */
+char *CTime( time_t *t )
+{
+ static char theTime[29];
+ struct tm tm;
+
+ __tm_conv( &tm, t, 0 );
+ sprintf( theTime, "%s %s %02d %02d:%02d:%02d UTC %04d",
+ dayOfWeek[tm.tm_wday], month[tm.tm_mon], tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year + 1900 );
+
+ return theTime;
+}
+
+/******************************************************/
+
+
+/* hjz: polled-I/O: Get a char if one is ready, or return -1 */
+int getc( void )
+{
+ if ( nasys_printf_uart->np_uartstatus & np_uartstatus_rrdy_mask )
+ return nasys_printf_uart->np_uartrxdata;
+ else
+ return -1;
+}
+
+
+typedef unsigned long off_t;
+typedef struct
+{
+ U8 *startAddr;
+ U8 *endAddr;
+ U32 CRC;
+ time_t mtime;
+ off_t size; // File size
+ char id[44]; // Filename. If path exceeds available size, name is "..." + last 40 chars of given filename
+ char host[32]; // hostname. If name exceeds available size name is first 28 chars of hostname + "..."
+} FLASH_REGION_DESC;
+
+
+int Test_Flash_Regions(void)
+{
+ FLASH_REGION_DESC *pRegion = (FLASH_REGION_DESC *)&__CRC_Table_Begin;
+ U32 crc;
+ char cBuff[256];
+ int nrFailedRegions = 0;
+ int regionStatus;
+ int i;
+ unsigned int startAddr = (int) pRegion->startAddr;
+ unsigned int endAddr = (int) pRegion->endAddr;
+
+ puts( "***Checking flash CRC's" );
+ if ( (startAddr == -1) || (startAddr >= endAddr)
+ || !( ((startAddr >= (int) NIOS_FLASH_START) && (endAddr < (int) NIOS_FLASH_END))
+ || ((startAddr >= (int) na_flash) && (endAddr < (int) na_flash_end)) ) )
+ {
+ puts( " No Flash regions defined." );
+ return -1;
+ }
+
+
+ for ( i = 0; pRegion->startAddr && pRegion->startAddr != (U8 *)~0L; pRegion++, i++ )
+ {
+ crc = Calc_CRC( pRegion->startAddr, pRegion->endAddr - pRegion->startAddr );
+ if ( crc != pRegion->CRC )
+ {
+ regionStatus = 1;
+ nrFailedRegions++;
+ }
+ else
+ regionStatus = 0;
+
+ sprintf( cBuff, " Region %d: 0x%08lX - 0x%08lX, CRC = 0x%08lX --> %s" NL
+ " From file `%s' on host `%s'" NL
+ " Dated %s, size = %lu bytes",
+ i, (U32)pRegion->startAddr, (U32)pRegion->endAddr, pRegion->CRC,
+ regionStatus ? "***Failed" : "Passed",
+ pRegion->id, pRegion->host, CTime( &pRegion->mtime ), pRegion->size
+ );
+ puts( cBuff );
+ }
+
+ return nrFailedRegions;
+}
+#endif /* CONFIG_CRC_CHECK */
+
+
+int main(void) {
+
+#ifdef DEBUG
+ puts("MAIN: starting c\n");
+#endif
+
+#ifdef CONFIG_KGDB /* builtin GDB stub */
+
+/* Set up GDB stub, and make the first trap into it */
+ nios_gdb_install(1);
+#ifdef CONFIG_BREAK_ON_START
+ puts( "MAIN: trapping to debugger - make sure nios-elf-gdb is running on host." );
+ nios_gdb_breakpoint();
+ nop();
+#endif
+
+#endif /* CONFIG_KGDB */
+
+#ifdef CONFIG_CRC_CHECK
+ #ifdef CONFIG_PROMPT_ON_MISSING_CRC_TABLES
+ if ( Test_Flash_Regions() )
+ #else
+ if ( Test_Flash_Regions() > 0 )
+ #endif
+ {
+ int c;
+ char tmp[3];
+ while ( getc() != -1 ) // flush input
+ ;
+
+ putsNoNewLine( " Do you wish to continue (Y/N) ? " );
+ while ( 1 )
+ {
+ c = getc();
+ if ( c == -1 )
+ continue;
+
+ if ( !isprint( c ) )
+ c = '?';
+
+ sprintf( tmp, "\b%c", c );
+ putsNoNewLine( tmp );
+ c = toupper( c );
+ if ( c == 'Y' )
+ {
+ puts( "" );
+ break;
+ }
+
+ if ( c == 'N' )
+ {
+ puts( NL "***Trapping to monitor..." );
+ return -1;
+ }
+ }
+ }
+ puts( "***Starting kernel..." );
+
+#endif
+
+ // Altera NiosII Custom shift instr(s) possibly //;dgt;
+ // assumed by memcpy, etc; ensure "correct" core //;dgt;
+ // loaded therefore if so. //;dgt;
+
+ #if defined(ALT_CI_ALIGN_32_N) //;dgt;
+ if(ALT_CI_ALIGN_32(1, 0xA9876543, //;dgt;
+ 0xB210FEDC) != 0x10FEDCA9) //;dgt;
+ { //;dgt;
+ goto badshiftci_label; //;dgt;
+ } //;dgt;
+ if(ALT_CI_ALIGN_32(2, 0xA9876543, //;dgt;
+ 0xB210FEDC) != 0xFEDCA987) //;dgt;
+ { //;dgt;
+ goto badshiftci_label; //;dgt;
+ } //;dgt;
+ if(ALT_CI_ALIGN_32(3, 0xA9876543, //;dgt;
+ 0xB210FEDC) != 0xDCA98765) //;dgt;
+ { //;dgt;
+ goto badshiftci_label; //;dgt;
+ } //;dgt;
+ #endif //;dgt;
+ goto gudshiftci_label; //;dgt;
+badshiftci_label: //;dgt;
+ { //;dgt;
+ unsigned char BadCImsg[] = //;dgt;
+ "?...ALT_CI_ALIGNn_321() NOT expected" //;dgt;
+ " NiosII custom instruction\n"; //;dgt;
+ unsigned char CIabortMsg[] = //;dgt;
+ " ...aborting uClinux startup..."; //;dgt;
+
+ #ifdef CONFIG_SERIAL_AJUART //;dgt;
+ #ifdef CONFIG_SERIAL_AJUART_CONSOLE //;dgt;
+ juart_console.index = 0; //;dgt;
+ jtaguart_console_write(&(juart_console), //;dgt;
+ BadCImsg, //;dgt;
+ strlen(BadCImsg)); //;dgt;
+ jtaguart_console_write(&(juart_console), //;dgt;
+ CIabortMsg, //;dgt;
+ strlen(CIabortMsg)); //;dgt;
+ #endif // CONFIG_SERIAL_AJUART //;dgt;
+ #endif // CONFIG_SERIAL_AJUART_CONSOLE //;dgt;
+
+// #if defined(CONFIG_NIOS_SERIAL) //;dgt;
+// #if defined(CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;
+ #if defined(nasys_printf_uart) //;dgt;
+ puts(BadCImsg); //;dgt;
+ puts(CIabortMsg); //;dgt;
+ #endif // nasys_printf_uart //;dgt;
+// #endif // CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;
+// #endif // CONFIG_NIOS_SERIAL) //;dgt;
+
+ panic(" ...wrong fpga core?..."); //;dgt;
+ } //;dgt;
+
+gudshiftci_label: //;dgt;
+
+ start_kernel();
+ return 0;
+}
diff --git a/arch/nios2nommu/kernel/sys_nios2.c b/arch/nios2nommu/kernel/sys_nios2.c
new file mode 100644
index 0000000..8018fb0
--- /dev/null
+++ b/arch/nios2nommu/kernel/sys_nios2.c
@@ -0,0 +1,248 @@
+/*
+ * linux/arch/nios2nommu/kernel/sys_nios2.c
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * This file contains various random system calls that
+ * have a non-standard calling sequence on the Linux/nios2nommu
+ * platform.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+*/
+
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/sem.h>
+#include <linux/msg.h>
+#include <linux/shm.h>
+#include <linux/stat.h>
+#include <linux/syscalls.h>
+#include <linux/mman.h>
+#include <linux/file.h>
+#include <linux/utsname.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/ipc.h>
+#include <linux/unistd.h>
+
+#include <asm/setup.h>
+#include <asm/cachectl.h>
+#include <asm/traps.h>
+#include <asm/ipc.h>
+#include <asm/cacheflush.h>
+
+/*
+ * sys_pipe() is the normal C calling standard for creating
+ * a pipe. It's not the way unix traditionally does this, though.
+ */
+asmlinkage int sys_pipe(unsigned long * fildes)
+{
+ int fd[2];
+ int error;
+
+ error = do_pipe(fd);
+ if (!error) {
+ if (copy_to_user(fildes, fd, 2*sizeof(int)))
+ error = -EFAULT;
+ }
+ return error;
+}
+
+/* common code for old and new mmaps */
+static inline long do_mmap2(
+ unsigned long addr, unsigned long len,
+ unsigned long prot, unsigned long flags,
+ unsigned long fd, unsigned long pgoff)
+{
+ int error = -EBADF;
+ struct file * file = NULL;
+
+ flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+ if (!(flags & MAP_ANONYMOUS)) {
+ file = fget(fd);
+ if (!file)
+ goto out;
+ }
+
+ down_write(¤t->mm->mmap_sem);
+ error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+ up_write(¤t->mm->mmap_sem);
+
+ if (file)
+ fput(file);
+out:
+ return error;
+}
+
+asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
+ unsigned long prot, unsigned long flags,
+ unsigned long fd, unsigned long pgoff)
+{
+ return do_mmap2(addr, len, prot, flags, fd, pgoff);
+}
+
+/*
+ * Perform the select(nd, in, out, ex, tv) and mmap() system
+ * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
+ * handle more than 4 system call parameters, so these system calls
+ * used a memory block for parameter passing..
+ */
+
+struct mmap_arg_struct {
+ unsigned long addr;
+ unsigned long len;
+ unsigned long prot;
+ unsigned long flags;
+ unsigned long fd;
+ unsigned long offset;
+};
+
+asmlinkage int old_mmap(struct mmap_arg_struct *arg)
+{
+ struct mmap_arg_struct a;
+ int error = -EFAULT;
+
+ if (copy_from_user(&a, arg, sizeof(a)))
+ goto out;
+
+ error = -EINVAL;
+ if (a.offset & ~PAGE_MASK)
+ goto out;
+
+ a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
+ error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
+out:
+ return error;
+}
+
+struct sel_arg_struct {
+ unsigned long n;
+ fd_set *inp, *outp, *exp;
+ struct timeval *tvp;
+};
+
+asmlinkage int old_select(struct sel_arg_struct *arg)
+{
+ struct sel_arg_struct a;
+
+ if (copy_from_user(&a, arg, sizeof(a)))
+ return -EFAULT;
+ /* sys_select() does the appropriate kernel locking */
+ return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
+}
+
+/*
+ * sys_ipc() is the de-multiplexer for the SysV IPC calls..
+ *
+ * This is really horribly ugly.
+ */
+asmlinkage int sys_ipc (uint call, int first, int second,
+ int third, void *ptr, long fifth)
+{
+ int version;
+
+ version = call >> 16; /* hack for backward compatibility */
+ call &= 0xffff;
+
+ if (call <= SEMCTL)
+ switch (call) {
+ case SEMOP:
+ return sys_semop (first, (struct sembuf *)ptr, second);
+ case SEMGET:
+ return sys_semget (first, second, third);
+ case SEMCTL: {
+ union semun fourth;
+ if (!ptr)
+ return -EINVAL;
+ if (get_user(fourth.__pad, (void **) ptr))
+ return -EFAULT;
+ return sys_semctl (first, second, third, fourth);
+ }
+ default:
+ return -EINVAL;
+ }
+ if (call <= MSGCTL)
+ switch (call) {
+ case MSGSND:
+ return sys_msgsnd (first, (struct msgbuf *) ptr,
+ second, third);
+ case MSGRCV:
+ switch (version) {
+ case 0: {
+ struct ipc_kludge tmp;
+ if (!ptr)
+ return -EINVAL;
+ if (copy_from_user (&tmp,
+ (struct ipc_kludge *)ptr,
+ sizeof (tmp)))
+ return -EFAULT;
+ return sys_msgrcv (first, tmp.msgp, second,
+ tmp.msgtyp, third);
+ }
+ default:
+ return sys_msgrcv (first,
+ (struct msgbuf *) ptr,
+ second, fifth, third);
+ }
+ case MSGGET:
+ return sys_msgget ((key_t) first, second);
+ case MSGCTL:
+ return sys_msgctl (first, second,
+ (struct msqid_ds *) ptr);
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+/* sys_cacheflush -- flush the processor cache. */
+asmlinkage int
+sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
+{
+ flush_cache_all();
+ return(0);
+}
+
+asmlinkage int sys_getpagesize(void)
+{
+ return PAGE_SIZE;
+}
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+ register long __res __asm__ ("r2") = TRAP_ID_SYSCALL;
+ register long __sc __asm__ ("r3") = __NR_execve;
+ register long __a __asm__ ("r4") = (long) filename;
+ register long __b __asm__ ("r5") = (long) argv;
+ register long __c __asm__ ("r6") = (long) envp;
+ __asm__ __volatile__ ("trap" : "=r" (__res)
+ : "0" (__res), "r" (__sc), "r" (__a), "r" (__b), "r" (__c)
+ : "memory");
+
+ return __res;
+}
diff --git a/arch/nios2nommu/kernel/syscalltable.S b/arch/nios2nommu/kernel/syscalltable.S
new file mode 100644
index 0000000..3507e24
--- /dev/null
+++ b/arch/nios2nommu/kernel/syscalltable.S
@@ -0,0 +1,362 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/kernel/syscalltable.S
+ *
+ * Derived from M68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com)
+ * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
+ * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
+ * Kenneth Albanowski <kjahds@kjahds.com>,
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+#include <linux/sys.h>
+#include <linux/linkage.h>
+#include <asm/unistd.h>
+#include <asm/asm-macros.h>
+
+.text
+ALIGN
+ENTRY(sys_call_table)
+ .long sys_ni_syscall /* 0 - old "setup()" system call*/
+ .long sys_exit
+ .long sys_fork
+ .long sys_read
+ .long sys_write
+ .long sys_open /* 5 */
+ .long sys_close
+ .long sys_waitpid
+ .long sys_creat
+ .long sys_link
+ .long sys_unlink /* 10 */
+ .long sys_execve
+ .long sys_chdir
+ .long sys_time
+ .long sys_mknod
+ .long sys_chmod /* 15 */
+ .long sys_chown16
+ .long sys_ni_syscall /* old break syscall holder */
+ .long sys_stat
+ .long sys_lseek
+ .long sys_getpid /* 20 */
+ .long sys_mount
+ .long sys_oldumount
+ .long sys_setuid16
+ .long sys_getuid16
+ .long sys_stime /* 25 */
+ .long sys_ptrace
+ .long sys_alarm
+ .long sys_fstat
+ .long sys_pause
+ .long sys_utime /* 30 */
+ .long sys_ni_syscall /* old stty syscall holder */
+ .long sys_ni_syscall /* old gtty syscall holder */
+ .long sys_access
+ .long sys_nice
+ .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
+ .long sys_sync
+ .long sys_kill
+ .long sys_rename
+ .long sys_mkdir
+ .long sys_rmdir /* 40 */
+ .long sys_dup
+ .long sys_pipe
+ .long sys_times
+ .long sys_ni_syscall /* old prof syscall holder */
+ .long sys_brk /* 45 */
+ .long sys_setgid16
+ .long sys_getgid16
+ .long sys_signal
+ .long sys_geteuid16
+ .long sys_getegid16 /* 50 */
+ .long sys_acct
+ .long sys_umount /* recycled never used phys() */
+ .long sys_ni_syscall /* old lock syscall holder */
+ .long sys_ioctl
+ .long sys_fcntl /* 55 */
+ .long sys_ni_syscall /* old mpx syscall holder */
+ .long sys_setpgid
+ .long sys_ni_syscall /* old ulimit syscall holder */
+ .long sys_ni_syscall
+ .long sys_umask /* 60 */
+ .long sys_chroot
+ .long sys_ustat
+ .long sys_dup2
+ .long sys_getppid
+ .long sys_getpgrp /* 65 */
+ .long sys_setsid
+ .long sys_sigaction
+ .long sys_sgetmask
+ .long sys_ssetmask
+ .long sys_setreuid16 /* 70 */
+ .long sys_setregid16
+ .long sys_sigsuspend
+ .long sys_sigpending
+ .long sys_sethostname
+ .long sys_setrlimit /* 75 */
+ .long sys_old_getrlimit
+ .long sys_getrusage
+ .long sys_gettimeofday
+ .long sys_settimeofday
+ .long sys_getgroups16 /* 80 */
+ .long sys_setgroups16
+ .long old_select
+ .long sys_symlink
+ .long sys_lstat
+ .long sys_readlink /* 85 */
+ .long sys_uselib
+ .long sys_ni_syscall /* sys_swapon */
+ .long sys_reboot
+ .long old_readdir
+ .long old_mmap /* 90 */
+ .long sys_munmap
+ .long sys_truncate
+ .long sys_ftruncate
+ .long sys_fchmod
+ .long sys_fchown16 /* 95 */
+ .long sys_getpriority
+ .long sys_setpriority
+ .long sys_ni_syscall /* old profil syscall holder */
+ .long sys_statfs
+ .long sys_fstatfs /* 100 */
+ .long sys_ni_syscall /* was ioperm */
+ .long sys_socketcall
+ .long sys_syslog
+ .long sys_setitimer
+ .long sys_getitimer /* 105 */
+ .long sys_newstat
+ .long sys_newlstat
+ .long sys_newfstat
+ .long sys_ni_syscall
+ .long sys_ni_syscall /* iopl for i386 */ /* 110 */
+ .long sys_vhangup
+ .long sys_ni_syscall /* obsolete idle() syscall */
+ .long sys_ni_syscall /* vm86old for i386 */
+ .long sys_wait4
+ .long sys_ni_syscall /* 115 */ /* sys_swapoff */
+ .long sys_sysinfo
+ .long sys_ipc
+ .long sys_fsync
+ .long sys_sigreturn
+ .long sys_clone /* 120 */
+ .long sys_setdomainname
+ .long sys_newuname
+ .long sys_cacheflush /* modify_ldt for i386 */
+ .long sys_adjtimex
+ .long sys_ni_syscall /* 125 */ /* sys_mprotect */
+ .long sys_sigprocmask
+ .long sys_ni_syscall /* old "creat_module" */
+ .long sys_init_module
+ .long sys_delete_module
+ .long sys_ni_syscall /* 130: old "get_kernel_syms" */
+ .long sys_quotactl
+ .long sys_getpgid
+ .long sys_fchdir
+ .long sys_bdflush
+ .long sys_sysfs /* 135 */
+ .long sys_personality
+ .long sys_ni_syscall /* for afs_syscall */
+ .long sys_setfsuid16
+ .long sys_setfsgid16
+ .long sys_llseek /* 140 */
+ .long sys_getdents
+ .long sys_select
+ .long sys_flock
+ .long sys_ni_syscall /* sys_msync */
+ .long sys_readv /* 145 */
+ .long sys_writev
+ .long sys_getsid
+ .long sys_fdatasync
+ .long sys_sysctl
+ .long sys_ni_syscall /* 150 */ /* sys_mlock */
+ .long sys_ni_syscall /* sys_munlock */
+ .long sys_ni_syscall /* sys_mlockall */
+ .long sys_ni_syscall /* sys_munlockall */
+ .long sys_sched_setparam
+ .long sys_sched_getparam /* 155 */
+ .long sys_sched_setscheduler
+ .long sys_sched_getscheduler
+ .long sys_sched_yield
+ .long sys_sched_get_priority_max
+ .long sys_sched_get_priority_min /* 160 */
+ .long sys_sched_rr_get_interval
+ .long sys_nanosleep
+ .long sys_ni_syscall /* sys_mremap */
+ .long sys_setresuid16
+ .long sys_getresuid16 /* 165 */
+ .long sys_getpagesize /* sys_getpagesize */
+ .long sys_ni_syscall /* old "query_module" */
+ .long sys_poll
+ .long sys_ni_syscall /* sys_nfsservctl */
+ .long sys_setresgid16 /* 170 */
+ .long sys_getresgid16
+ .long sys_prctl
+ .long sys_rt_sigreturn
+ .long sys_rt_sigaction
+ .long sys_rt_sigprocmask /* 175 */
+ .long sys_rt_sigpending
+ .long sys_rt_sigtimedwait
+ .long sys_rt_sigqueueinfo
+ .long sys_rt_sigsuspend
+ .long sys_pread64 /* 180 */
+ .long sys_pwrite64
+ .long sys_lchown16
+ .long sys_getcwd
+ .long sys_capget
+ .long sys_capset /* 185 */
+ .long sys_sigaltstack
+ .long sys_sendfile
+ .long sys_ni_syscall /* streams1 */
+ .long sys_ni_syscall /* streams2 */
+ .long sys_vfork /* 190 */
+ .long sys_getrlimit
+ .long sys_mmap2
+ .long sys_truncate64
+ .long sys_ftruncate64
+ .long sys_stat64 /* 195 */
+ .long sys_lstat64
+ .long sys_fstat64
+ .long sys_chown
+ .long sys_getuid
+ .long sys_getgid /* 200 */
+ .long sys_geteuid
+ .long sys_getegid
+ .long sys_setreuid
+ .long sys_setregid
+ .long sys_getgroups /* 205 */
+ .long sys_setgroups
+ .long sys_fchown
+ .long sys_setresuid
+ .long sys_getresuid
+ .long sys_setresgid /* 210 */
+ .long sys_getresgid
+ .long sys_lchown
+ .long sys_setuid
+ .long sys_setgid
+ .long sys_setfsuid /* 215 */
+ .long sys_setfsgid
+ .long sys_pivot_root
+ .long sys_ni_syscall
+ .long sys_ni_syscall
+ .long sys_getdents64 /* 220 */
+ .long sys_gettid
+ .long sys_tkill
+ .long sys_setxattr
+ .long sys_lsetxattr
+ .long sys_fsetxattr /* 225 */
+ .long sys_getxattr
+ .long sys_lgetxattr
+ .long sys_fgetxattr
+ .long sys_listxattr
+ .long sys_llistxattr /* 230 */
+ .long sys_flistxattr
+ .long sys_removexattr
+ .long sys_lremovexattr
+ .long sys_fremovexattr
+ .long sys_futex /* 235 */
+ .long sys_sendfile64
+ .long sys_ni_syscall /* sys_mincore */
+ .long sys_ni_syscall /* sys_madvise */
+ .long sys_fcntl64
+ .long sys_readahead /* 240 */
+ .long sys_io_setup
+ .long sys_io_destroy
+ .long sys_io_getevents
+ .long sys_io_submit
+ .long sys_io_cancel /* 245 */
+ .long sys_fadvise64
+ .long sys_exit_group
+ .long sys_lookup_dcookie
+ .long sys_epoll_create
+ .long sys_epoll_ctl /* 250 */
+ .long sys_epoll_wait
+ .long sys_ni_syscall /* sys_remap_file_pages */
+ .long sys_set_tid_address
+ .long sys_timer_create
+ .long sys_timer_settime /* 255 */
+ .long sys_timer_gettime
+ .long sys_timer_getoverrun
+ .long sys_timer_delete
+ .long sys_clock_settime
+ .long sys_clock_gettime /* 260 */
+ .long sys_clock_getres
+ .long sys_clock_nanosleep
+ .long sys_statfs64
+ .long sys_fstatfs64
+ .long sys_tgkill /* 265 */
+ .long sys_utimes
+ .long sys_fadvise64_64
+ .long sys_mbind
+ .long sys_get_mempolicy
+ .long sys_set_mempolicy /* 270 */
+ .long sys_mq_open
+ .long sys_mq_unlink
+ .long sys_mq_timedsend
+ .long sys_mq_timedreceive
+ .long sys_mq_notify /* 275 */
+ .long sys_mq_getsetattr
+ .long sys_waitid
+ .long sys_ni_syscall /* sys_setaltroot */
+ .long sys_ni_syscall /* sys_add_key */
+ .long sys_ni_syscall /* 280 */ /* sys_request_key */
+ .long sys_ni_syscall /* sys_keyctl */
+ .long sys_ioprio_set
+ .long sys_ioprio_get
+ .long sys_inotify_init
+ .long sys_inotify_add_watch /* 285 */
+ .long sys_inotify_rm_watch
+ .long sys_migrate_pages
+ .long sys_openat
+ .long sys_mkdirat
+ .long sys_mknodat /* 290 */
+ .long sys_fchownat
+ .long sys_futimesat
+ .long sys_fstatat64
+ .long sys_unlinkat
+ .long sys_renameat /* 295 */
+ .long sys_linkat
+ .long sys_symlinkat
+ .long sys_readlinkat
+ .long sys_fchmodat
+ .long sys_faccessat /* 300 */
+ .long sys_ni_syscall /* Reserved for pselect6 */
+ .long sys_ni_syscall /* Reserved for ppoll */
+ .long sys_unshare
+ .long sys_set_robust_list
+ .long sys_get_robust_list /* 305 */
+ .long sys_splice
+ .long sys_sync_file_range
+ .long sys_tee
+ .long sys_vmsplice
+ .long sys_move_pages /* 310 */
+ .long sys_sched_setaffinity
+ .long sys_sched_getaffinity
+ .long sys_kexec_load
+ .long sys_getcpu
+ .long sys_epoll_pwait /* 315 */
+ .long sys_utimensat
+ .long sys_signalfd
+ .long sys_timerfd
+ .long sys_eventfd
+ .long sys_pread64
+ .long sys_pwrite64 /* 321 */
+
+ .rept NR_syscalls - 322
+ .long sys_ni_syscall
+ .endr
+
diff --git a/arch/nios2nommu/kernel/time.c b/arch/nios2nommu/kernel/time.c
new file mode 100644
index 0000000..3b536fe
--- /dev/null
+++ b/arch/nios2nommu/kernel/time.c
@@ -0,0 +1,219 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/kernel/time.c
+ *
+ * Architecture specific time handling details.
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Most of the stuff is located in the machine specific files.
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ * Copyright (C) 1998-2000 D. Jeff Dionne <jeff@lineo.ca>,
+ * Kenneth Albanowski <kjahds@kjahds.com>,
+ * Copyright (C) 1991, 1992, 1995 Linus Torvalds
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/time.h>
+#include <linux/timex.h>
+#include <linux/profile.h>
+#include <linux/module.h>
+#include <linux/irq.h>
+
+#include <asm/segment.h>
+#include <asm/io.h>
+#include <asm/nios.h>
+
+#define TICK_SIZE (tick_nsec / 1000)
+
+unsigned long cpu_khz;
+static inline int set_rtc_mmss(unsigned long nowtime)
+{
+ return 0;
+}
+
+/* Timer timeout status */
+#define nios2_timer_TO (inw(&na_timer0->np_timerstatus) & np_timerstatus_to_mask)
+
+/* Timer snapshot */
+static inline unsigned long nios2_read_timercount(void)
+{
+ unsigned long count;
+
+ outw(0, &na_timer0->np_timersnapl);
+ count = inw(&na_timer0->np_timersnaph) << 16 | inw(&na_timer0->np_timersnapl);
+
+ return count;
+}
+
+/*
+ * Should return useconds since last timer tick
+ */
+static unsigned long gettimeoffset(void)
+{
+ unsigned long offset;
+ unsigned long count;
+
+ count = nios2_read_timercount();
+ offset = ((nasys_clock_freq/HZ)-1 - nios2_read_timercount()) \
+ / (nasys_clock_freq / USEC_PER_SEC);
+
+ /* Check if we just wrapped the counters and maybe missed a tick */
+ if (nios2_timer_TO && (offset < (100000 / HZ / 2)))
+ offset += (USEC_PER_SEC / HZ);
+
+ return offset;
+}
+
+/*
+ * timer_interrupt() needs to keep up the real-time clock,
+ * as well as call the "do_timer()" routine every clocktick
+ */
+irqreturn_t timer_interrupt(int irq, void *dummy)
+{
+ /* last time the cmos clock got updated */
+ static long last_rtc_update=0;
+
+ write_seqlock(&xtime_lock);
+ na_timer0->np_timerstatus = 0; /* Clear the interrupt condition */
+
+ do_timer(1);
+#ifndef CONFIG_SMP
+ update_process_times(user_mode(get_irq_regs()));
+#endif
+ profile_tick(CPU_PROFILING);
+ /*
+ * If we have an externally synchronized Linux clock, then update
+ * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
+ * called as close as possible to 500 ms before the new second starts.
+ */
+ if (ntp_synced() &&
+ xtime.tv_sec > last_rtc_update + 660 &&
+ (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
+ (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
+ if (set_rtc_mmss(xtime.tv_sec) == 0)
+ last_rtc_update = xtime.tv_sec;
+ else
+ last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
+ }
+
+ write_sequnlock(&xtime_lock);
+ return(IRQ_HANDLED);
+}
+
+void __init time_init(void)
+{
+ unsigned int year, mon, day, hour, min, sec;
+ int err;
+
+ extern void arch_gettod(int *year, int *mon, int *day, int *hour,
+ int *min, int *sec);
+
+ cpu_khz=nasys_clock_freq_1000;
+ arch_gettod(&year, &mon, &day, &hour, &min, &sec);
+
+ if ((year += 1900) < 1970)
+ year += 100;
+ xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
+ xtime.tv_nsec = 0;
+ wall_to_monotonic.tv_sec = -xtime.tv_sec;
+
+ err = request_irq(na_timer0_irq, timer_interrupt, IRQ_FLG_LOCK, "timer", NULL);
+ if(err)
+ printk(KERN_ERR "%s() failed - errno = %d\n", __FUNCTION__, -err);
+ na_timer0->np_timerperiodl = (nasys_clock_freq/HZ)-1;
+ na_timer0->np_timerperiodh = ((nasys_clock_freq/HZ)-1) >> 16;
+
+ /* interrupt enable + continuous + start */
+ na_timer0->np_timercontrol = np_timercontrol_start_mask
+ + np_timercontrol_cont_mask
+ + np_timercontrol_ito_mask;
+}
+
+/*
+ * This version of gettimeofday has near microsecond resolution.
+ */
+void do_gettimeofday(struct timeval *tv)
+{
+ unsigned long flags;
+ unsigned long seq;
+ unsigned long usec, sec;
+
+ do {
+ seq = read_seqbegin_irqsave(&xtime_lock, flags);
+ usec = gettimeoffset();
+ sec = xtime.tv_sec;
+ usec += (xtime.tv_nsec / 1000);
+ } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
+
+ while (usec >= 1000000) {
+ usec -= 1000000;
+ sec++;
+ }
+
+ tv->tv_sec = sec;
+ tv->tv_usec = usec;
+}
+EXPORT_SYMBOL(do_gettimeofday);
+
+int do_settimeofday(struct timespec *tv)
+{
+ time_t wtm_sec, sec = tv->tv_sec;
+ long wtm_nsec, nsec = tv->tv_nsec;
+
+ if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
+ return -EINVAL;
+
+ write_seqlock_irq(&xtime_lock);
+ /*
+ * This is revolting. We need to set "xtime" correctly. However, the
+ * value in this location is the value at the last tick.
+ * Discover what correction gettimeofday() would have
+ * made, and then undo it!
+ */
+ nsec -= gettimeoffset() * NSEC_PER_USEC;
+
+ wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
+ wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
+
+ set_normalized_timespec(&xtime, sec, nsec);
+ set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
+
+ ntp_clear();
+
+ write_sequnlock_irq(&xtime_lock);
+ clock_was_set();
+
+ return 0;
+}
+EXPORT_SYMBOL(do_settimeofday);
+
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ */
+unsigned long long sched_clock(void)
+{
+ return (unsigned long long)jiffies * (1000000000 / HZ);
+}
diff --git a/arch/nios2nommu/kernel/traps.c b/arch/nios2nommu/kernel/traps.c
new file mode 100644
index 0000000..14b7e4c
--- /dev/null
+++ b/arch/nios2nommu/kernel/traps.c
@@ -0,0 +1,178 @@
+/*
+ * arch/niosnommu/kernel/traps.c
+ *
+ * Copyright 2004 Microtronix Datacom Ltd.
+ * Copyright 2001 Vic Phillips
+ * Copyright 1995 David S. Miller (davem@caip.rutgers.edu)
+ *
+ * hacked from:
+ *
+ * arch/sparcnommu/kernel/traps.c
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/sched.h> /* for jiffies */
+#include <linux/kernel.h>
+#include <linux/signal.h>
+#include <linux/module.h>
+
+#include <asm/delay.h>
+#include <asm/system.h>
+#include <asm/ptrace.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/unistd.h>
+
+#include <asm/nios.h>
+
+/* #define TRAP_DEBUG */
+
+#if 0
+void dumpit(unsigned long l1, unsigned long l2)
+{
+ printk("0x%08x l1 0x%08x l2\n");
+ while(1);
+}
+
+struct trap_trace_entry {
+ unsigned long pc;
+ unsigned long type;
+};
+
+int trap_curbuf = 0;
+struct trap_trace_entry trapbuf[1024];
+
+void syscall_trace_entry(struct pt_regs *regs)
+{
+ printk("%s[%d]: ", current->comm, current->pid);
+ printk("scall<%d> (could be %d)\n", (int) regs->r3,
+ (int) regs->r4);
+}
+
+void syscall_trace_exit(struct pt_regs *regs)
+{
+}
+#endif
+
+/*
+ * The architecture-independent backtrace generator
+ */
+void dump_stack(void)
+{
+ unsigned long stack;
+
+ show_stack(current, &stack);
+}
+
+EXPORT_SYMBOL(dump_stack);
+
+/*
+ * The show_stack is an external API which we do not use ourselves.
+ * The oops is printed in die_if_kernel.
+ */
+
+int kstack_depth_to_print = 48;
+
+void show_stack(struct task_struct *task, unsigned long *stack)
+{
+ unsigned long *endstack, addr;
+ extern char _start, _etext;
+ int i;
+
+ if (!stack) {
+ if (task)
+ stack = (unsigned long *)task->thread.ksp;
+ else
+ stack = (unsigned long *)&stack;
+ }
+
+ addr = (unsigned long) stack;
+ endstack = (unsigned long *) PAGE_ALIGN(addr);
+
+ printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
+ for (i = 0; i < kstack_depth_to_print; i++) {
+ if (stack + 1 > endstack)
+ break;
+ if (i % 8 == 0)
+ printk(KERN_EMERG "\n ");
+ printk(KERN_EMERG " %08lx", *stack++);
+ }
+
+ printk(KERN_EMERG "\nCall Trace:");
+ i = 0;
+ while (stack + 1 <= endstack) {
+ addr = *stack++;
+ /*
+ * If the address is either in the text segment of the
+ * kernel, or in the region which contains vmalloc'ed
+ * memory, it *may* be the address of a calling
+ * routine; if so, print it so that someone tracing
+ * down the cause of the crash will be able to figure
+ * out the call path that was taken.
+ */
+ if (((addr >= (unsigned long) &_start) &&
+ (addr <= (unsigned long) &_etext))) {
+ if (i % 4 == 0)
+ printk(KERN_EMERG "\n ");
+ printk(KERN_EMERG " [<%08lx>]", addr);
+ i++;
+ }
+ }
+ printk(KERN_EMERG "\n");
+}
+
+void die_if_kernel(char *str, struct pt_regs *pregs)
+{
+ unsigned long pc;
+
+ pc = pregs->ra;
+ printk("0x%08lx\n trapped to die_if_kernel\n",pregs->ra);
+ show_regs(pregs);
+ if(pregs->status_extension & PS_S)
+ do_exit(SIGKILL);
+ do_exit(SIGSEGV);
+}
+
+void do_hw_interrupt(unsigned long type, unsigned long psr, unsigned long pc)
+{
+ if(type < 0x10) {
+ printk("Unimplemented Nios2 TRAP, type = %02lx\n", type);
+ die_if_kernel("Whee... Hello Mr. Penguin", current->thread.kregs);
+ }
+}
+
+#if 0
+void handle_watchpoint(struct pt_regs *regs, unsigned long pc, unsigned long psr)
+{
+#ifdef TRAP_DEBUG
+ printk("Watchpoint detected at PC %08lx PSR %08lx\n", pc, psr);
+#endif
+ if(psr & PSR_SUPERVISOR)
+ panic("Tell me what a watchpoint trap is, and I'll then deal "
+ "with such a beast...");
+}
+#endif
+
+void trap_init(void)
+{
+#ifdef DEBUG
+ printk("trap_init reached\n");
+#endif
+}
diff --git a/arch/nios2nommu/kernel/usb.c b/arch/nios2nommu/kernel/usb.c
new file mode 100644
index 0000000..65655b6
--- /dev/null
+++ b/arch/nios2nommu/kernel/usb.c
@@ -0,0 +1,341 @@
+/*
+ * arch/nios2nommu/kernel/usb.c -- platform level USB initialization
+ *
+ * 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.
+ *
+ * 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
+ */
+
+#undef DEBUG
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/nios.h>
+
+#if defined(CONFIG_USB_SL811_HCD) || defined (CONFIG_USB_SL811_HCD_MODULE)
+#if defined(CONFIG_MICROTRONIX_STRATIX) || defined (CONFIG_MICROTRONIX_CYCLONE)
+
+#include <linux/usb/sl811.h>
+#define SL811_ADDR ((unsigned int)na_usb)
+#define SL811_IRQ na_usb_irq
+
+static void sl811_port_power(struct device *dev, int is_on)
+{
+}
+
+static void sl811_port_reset(struct device *dev)
+{
+ writeb(0xA, (SL811_ADDR+8));
+ mdelay(10);
+ writeb(4, (SL811_ADDR+8));
+}
+
+static struct resource sl811hs_resources[] = {
+ {
+ .start = (SL811_ADDR),
+ .end = (SL811_ADDR + 3),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = (SL811_ADDR + 4),
+ .end = (SL811_ADDR + 7),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = SL811_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct sl811_platform_data sl811_data = {
+ .can_wakeup = 0,
+ .potpg = 0,
+ .power = 250,
+ .port_power = sl811_port_power,
+ .reset = sl811_port_reset,
+};
+
+static struct platform_device sl811hs_device = {
+ .name = "sl811-hcd",
+ .id = -1,
+ .dev = {
+ //.release = usb_release,
+ //.dma_mask = &ohci_dmamask,
+ .coherent_dma_mask = 0x0fffffff,
+ .platform_data = &sl811_data,
+ },
+ .num_resources = ARRAY_SIZE(sl811hs_resources),
+ .resource = sl811hs_resources,
+};
+
+
+static int __init mtx_kit_usb_init(void)
+{
+ int status;
+
+ status = platform_device_register(&sl811hs_device);
+ if (status) {
+ pr_debug("can't register sl811hs device, %d\n", status);
+ return -1;
+ }
+
+ writeb(4, (SL811_ADDR+8));
+ return 0;
+}
+
+subsys_initcall(mtx_kit_usb_init);
+#endif /* (CONFIG_MICROTRONIX_STRATIX) || (CONFIG_MICROTRONIX_CYCLONE)*/
+#endif /*(CONFIG_USB_SL811_HCD) ||(CONFIG_USB_SL811_HCD_MODULE) */
+
+#if defined(CONFIG_USB_ISP116X_HCD) || defined (CONFIG_USB_ISP116X_HCD_MODULE)
+
+#include <linux/usb/isp116x.h>
+
+#define ISP116X_HCD_ADDR ((unsigned int)na_usb)
+#define ISP116X_HCD_IRQ na_usb_irq
+
+static void isp116x_delay(struct device *dev, int delay)
+{
+ ndelay(delay);
+}
+
+static struct resource isp116x_hcd_resources[] = {
+ {
+ .start = (ISP116X_HCD_ADDR),
+ .end = (ISP116X_HCD_ADDR + 3),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = (ISP116X_HCD_ADDR + 4),
+ .end = (ISP116X_HCD_ADDR + 7),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = ISP116X_HCD_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct isp116x_platform_data isp116x_data = {
+ // Enable internal resistors on downstream ports
+ .sel15Kres = 1,
+ // On-chip overcurrent protection
+ .oc_enable = 1,
+ // INT output polarity
+ .int_act_high = 0,
+ // INT edge or level triggered
+ .int_edge_triggered = 0,
+ // Wakeup by devices on usb bus enabled
+ .remote_wakeup_enable = 0,
+ .delay = isp116x_delay,
+};
+
+static struct platform_device isp116x_hcd = {
+ .name = "isp116x-hcd",
+ .id = -1,
+ .dev = {
+ //.release = usb_release,
+ //.dma_mask = &ohci_dmamask,
+ .coherent_dma_mask = 0x0fffffff,
+ .platform_data = &isp116x_data,
+ },
+ .num_resources = ARRAY_SIZE(isp116x_hcd_resources),
+ .resource = isp116x_hcd_resources,
+};
+
+static int __init usb_hcd_init(void)
+{
+ int status;
+
+ status = platform_device_register(&isp116x_hcd);
+ if (status) {
+ pr_debug("can't register isp116x host controller, %d\n", status);
+ return -1;
+ }
+
+ return 0;
+}
+subsys_initcall(usb_hcd_init);
+#endif /*(CONFIG_USB_ISP116X_HCD) ||(CONFIG_USB_ISP116X_HCD_MODULE) */
+
+#if defined(CONFIG_USB_ISP1161X) || defined(CONFIG_USB_ISP1161X_MODULE)
+#include <linux/usb_isp116x_dc.h>
+
+#define ISP116X_UDC_ADDR ((unsigned int)na_usb+8)
+#define ISP116X_UDC_IRQ na_int2_usb_irq
+
+static struct resource isp116x_udc_resources[] = {
+ {
+ .start = (ISP116X_UDC_ADDR),
+ .end = (ISP116X_UDC_ADDR + 3),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = (ISP116X_UDC_ADDR + 4),
+ .end = (ISP116X_UDC_ADDR + 7),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = ISP116X_UDC_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static void isp116x_udc_delay()
+{
+ __asm__ __volatile__(
+ "1: \n\t"
+ " beq %0,zero,2f\n\t"
+ " addi %0, %0, -1\n\t"
+ " br 1b\n\t"
+ "2: \n\t"
+ :
+ : "r" (nasys_clock_freq_1000 * 180 / 2000000)
+ );
+
+}
+struct isp116x_dc_platform_data isp116x_udc_data = {
+ .ext_pullup_enable =0,
+ .no_lazy =1,
+ .eot_act_high =0,
+ .remote_wakeup_enable=1,
+ .power_off_enable =1,
+ .int_edge_triggered =0,
+ .int_act_high =0,
+ .clkout_freq =12,
+ .delay = isp116x_udc_delay
+};
+
+static struct platform_device isp116x_udc = {
+ .name = "isp1161a_udc",
+ .id = -1,
+ .dev = {
+ //.release = usb_release,
+ //.dma_mask = &ohci_dmamask,
+ .coherent_dma_mask = 0x0fffffff,
+ .platform_data = &isp116x_udc_data,
+ },
+ .num_resources = ARRAY_SIZE(isp116x_udc_resources),
+ .resource = isp116x_udc_resources,
+};
+
+static int __init usb_udc_init(void)
+{
+ int status;
+ np_pio* pio;
+
+ status = platform_device_register(&isp116x_udc);
+ if (status) {
+ pr_debug("can't register isp116x device controller, %d\n", status);
+ return -1;
+ }
+
+ /* enable interrupts */
+ pio = (np_pio*)na_int2_usb;
+ //outw(0, &pio->np_piodata);
+ //outw(0, &pio->np_pioedgecapture);
+ outw(1, &pio->np_piointerruptmask);
+
+ return 0;
+}
+subsys_initcall(usb_udc_init);
+#endif
+
+#if defined(na_ISP1362_avalonS) // for DE2 dev board, FIX ME otehrwise
+#define na_usb na_ISP1362_avalonS
+#define na_usb_irq na_ISP1362_avalonS_irq
+#endif
+
+#if defined(na_ISP1362_avalon_slave_0) // for DE2 dev board, FIX ME otehrwise
+#define na_usb na_ISP1362_avalon_slave_0
+#define na_usb_irq na_ISP1362_avalon_slave_0_irq
+#endif
+
+#if defined(CONFIG_USB_ISP1362_HCD) && defined(na_usb)
+
+#include <linux/usb_isp1362.h>
+#define ISP1362_HCD_ADDR ((unsigned int)na_usb)
+#define ISP1362_HCD_IRQ na_usb_irq
+
+static struct resource isp1362_hcd_resources[] = {
+ {
+ .start = (ISP1362_HCD_ADDR),
+ .end = (ISP1362_HCD_ADDR + 3),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = (ISP1362_HCD_ADDR + 4),
+ .end = (ISP1362_HCD_ADDR + 7),
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = ISP1362_HCD_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct isp1362_platform_data isp1362_data = {
+ // Enable internal resistors on downstream ports
+ .sel15Kres = 1,
+ // Clock cannot be stopped
+ .clknotstop = 0,
+ // On-chip overcurrent protection
+ .oc_enable = 0,
+ // INT output polarity
+ .int_act_high = 0,
+ // INT edge or level triggered
+ .int_edge_triggered = 0,
+ // WAKEUP pin connected
+ .remote_wakeup_connected = 0,
+ // Switch or not to switch (keep always powered)
+ .no_power_switching = 1,
+ // Ganged port power switching (0) or individual port power switching (1)
+ .power_switching_mode = 0,
+};
+
+static struct platform_device isp1362_hcd = {
+ .name = "isp1362-hcd",
+ .id = -1,
+ .dev = {
+ //.release = usb_release,
+ //.dma_mask = &ohci_dmamask,
+ .coherent_dma_mask = 0x0fffffff,
+ .platform_data = &isp1362_data,
+ },
+ .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
+ .resource = isp1362_hcd_resources,
+};
+
+static int __init usb_hcd_init(void)
+{
+ int status;
+
+ status = platform_device_register(&isp1362_hcd);
+ if (status) {
+ pr_debug("can't register isp1362 host controller, %d\n", status);
+ return -1;
+ }
+
+ return 0;
+}
+subsys_initcall(usb_hcd_init);
+#endif
+
diff --git a/arch/nios2nommu/kernel/vmlinux.lds.S b/arch/nios2nommu/kernel/vmlinux.lds.S
new file mode 100644
index 0000000..491901c
--- /dev/null
+++ b/arch/nios2nommu/kernel/vmlinux.lds.S
@@ -0,0 +1,141 @@
+#include <asm-generic/vmlinux.lds.h>
+#include <asm/nios.h>
+
+OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
+
+OUTPUT_ARCH(nios)
+ENTRY(_start) /* Defined in head.S */
+
+jiffies = jiffies_64;
+
+SECTIONS
+{
+ . = nasys_program_mem;
+ /* read-only */
+ _stext = . ;
+ _text = .; /* Text and read-only data */
+ .text : {
+ TEXT_TEXT
+ SCHED_TEXT
+ LOCK_TEXT
+ *(.fixup)
+ *(.gnu.warning)
+ } =0
+
+ . = ALIGN(4) ;
+ _etext = .; /* End of text section */
+
+ . = ALIGN(32); /* Exception table */
+ __start___ex_table = .;
+ __ex_table : { *(__ex_table) }
+ __stop___ex_table = .;
+
+ RODATA
+
+ /* writeable */
+ .data : { /* Data */
+ /*
+ * This ALIGN is needed as a workaround for a bug a gcc bug upto 4.1 which
+ * limits the maximum alignment to at most 32kB and results in the following
+ * warning:
+ *
+ * CC arch/mips/kernel/init_task.o
+ * arch/mips/kernel/init_task.c:30: warning: alignment of ‘init_thread_union’
+ * is greater than maximum object file alignment. Using 32768
+ */
+ . = ALIGN(4096);
+ *(.data.init_task)
+
+ *(.data)
+
+ CONSTRUCTORS
+ }
+
+ .lit8 : { *(.lit8) }
+ .lit4 : { *(.lit4) }
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+ .sdata : { *(.sdata) }
+
+ . = ALIGN(4096);
+ __nosave_begin = .;
+ .data_nosave : { *(.data.nosave) }
+ . = ALIGN(4096);
+ __nosave_end = .;
+
+ . = ALIGN(32);
+ .data.cacheline_aligned : { *(.data.cacheline_aligned) }
+
+ _edata = .; /* End of data section */
+
+ /* will be freed after init */
+ . = ALIGN(4096); /* Init code and data */
+ __init_begin = .;
+ .init.text : {
+ _sinittext = .;
+ *(.init.text)
+ _einittext = .;
+ }
+ .init.data : { *(.init.data) }
+ . = ALIGN(16);
+ __setup_start = .;
+ .init.setup : { *(.init.setup) }
+ __setup_end = .;
+
+ __initcall_start = .;
+ .initcall.init : {
+ INITCALLS
+ }
+ __initcall_end = .;
+
+ __con_initcall_start = .;
+ .con_initcall.init : { *(.con_initcall.init) }
+ __con_initcall_end = .;
+ SECURITY_INIT
+ /* .exit.text is discarded at runtime, not link time, to deal with
+ references from .rodata */
+ .exit.text : { *(.exit.text) }
+ .exit.data : { *(.exit.data) }
+ . = ALIGN(4096);
+ __initramfs_start = .;
+ .init.ramfs : { *(.init.ramfs) }
+ __initramfs_end = .;
+ . = ALIGN(32);
+ __per_cpu_start = .;
+ .data.percpu : { *(.data.percpu) }
+ __per_cpu_end = .;
+ . = ALIGN(4096);
+ __init_end = .;
+ /* freed after init ends here */
+
+ __bss_start = .; /* BSS */
+ .sbss : {
+ *(.sbss)
+ *(.scommon)
+ }
+ .bss : {
+ *(.bss)
+ *(COMMON)
+ }
+ __bss_stop = .;
+
+ _end = . ;
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.exit.text)
+ *(.exit.data)
+ *(.exitcall.exit)
+ }
+
+
+ STABS_DEBUG
+
+ DWARF_DEBUG
+
+ /* These must appear regardless of . */
+ .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+ .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+ .note : { *(.note) }
+}
diff --git a/arch/nios2nommu/lib/Makefile b/arch/nios2nommu/lib/Makefile
new file mode 100644
index 0000000..1315c57
--- /dev/null
+++ b/arch/nios2nommu/lib/Makefile
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2005 Microtronix Datacom Ltd
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# 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 Library General Public License for more
+# details.
+
+####CSRC := $(wildcard *.c)
+####lib-y =$(patsubst %.c,%.o, $(CSRC))
+####wapos!
+lib-y =checksum.o string.o memcpy.o
diff --git a/arch/nios2nommu/lib/checksum.c b/arch/nios2nommu/lib/checksum.c
new file mode 100644
index 0000000..475f1a3
--- /dev/null
+++ b/arch/nios2nommu/lib/checksum.c
@@ -0,0 +1,73 @@
+/*--------------------------------------------------------------------
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+#include <net/checksum.h>
+#include <asm/checksum.h>
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+/*
+ * computes the checksum of a memory block at buff, length len,
+ * and adds in "sum" (32-bit)
+ *
+ * returns a 32-bit number suitable for feeding into itself
+ * or csum_tcpudp_magic
+ *
+ * this function must be called with even lengths, except
+ * for the last fragment, which may be odd
+ *
+ * it's best to have buff aligned on a 32-bit boundary
+ */
+
+unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
+{
+#if 0
+ __asm__ __volatile__ ...//;dgt2;tmp;not (yet) available...
+ ...//;dgt2;tmp;NiosI didn't offer either...
+#else
+ unsigned int result = do_csum(buff, len);
+
+ /* add in old sum, and carry.. */
+ result += sum;
+ if (sum > result)
+ result += 1;
+ return result;
+#endif
+}
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+
+/*
+ * the same as csum_partial, but copies from fs:src while it
+ * checksums
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+
+unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum)
+{
+ memcpy(dst, src, len);
+ return csum_partial(dst, len, sum);
+
+}
diff --git a/arch/nios2nommu/lib/memcpy.c b/arch/nios2nommu/lib/memcpy.c
new file mode 100644
index 0000000..6586b99
--- /dev/null
+++ b/arch/nios2nommu/lib/memcpy.c
@@ -0,0 +1,62 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/lib/memcpy.c
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jun/09/2004 dgt Split out separate source file from string.c
+ *
+ ---------------------------------------------------------------------*/
+
+#include <linux/types.h>
+#include <linux/autoconf.h>
+#include <asm/nios.h>
+#include <asm/string.h>
+
+#ifdef __HAVE_ARCH_MEMCPY
+ void * memcpy(void * d, const void * s, size_t count)
+ {
+ unsigned long dst, src;
+ dst = (unsigned long) d;
+ src = (unsigned long) s;
+
+ if ((count < 8) || ((dst ^ src) & 3))
+ goto restup;
+
+ if (dst & 1) {
+ *(char*)dst++=*(char*)src++;
+ count--;
+ }
+ if (dst & 2) {
+ *(short*)dst=*(short*)src;
+ src += 2;
+ dst += 2;
+ count -= 2;
+ }
+ while (count > 3) {
+ *(long*)dst=*(long*)src;
+ src += 4;
+ dst += 4;
+ count -= 4;
+ }
+
+ restup:
+ while (count--)
+ *(char*)dst++=*(char*)src++;
+
+ return d;
+ }
+#endif
diff --git a/arch/nios2nommu/lib/string.c b/arch/nios2nommu/lib/string.c
new file mode 100644
index 0000000..b87c195
--- /dev/null
+++ b/arch/nios2nommu/lib/string.c
@@ -0,0 +1,180 @@
+/*--------------------------------------------------------------------
+ *
+ * arch/nios2nommu/lib/string.c
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ * Jun/09/2004 dgt Split out memcpy into separate source file
+ *
+ ---------------------------------------------------------------------*/
+
+#include <linux/types.h>
+#include <linux/autoconf.h>
+#include <asm/nios.h>
+#include <asm/string.h>
+
+#ifdef __HAVE_ARCH_MEMSET
+void * memset(void * s,int c,size_t count)
+{
+
+ if (count > 8) {
+ int destptr, charcnt, dwordcnt, fill8reg, wrkrega;
+ __asm__ __volatile__ (
+ // fill8 %3, %5 (c & 0xff)\n\t"
+ //
+ " slli %4, %5, 8\n\t"
+ " or %4, %4, %5\n\t"
+ " slli %3, %4, 16\n\t"
+ " or %3, %3, %4\n\t"
+ //
+ // Word-align %0 (s) if necessary
+ //
+ " andi %4, %0, 0x01\n\t"
+ " beq %4, zero, 1f\n\t"
+ " addi %1, %1, -1\n\t"
+ " stb %3, 0(%0)\n\t"
+ " addi %0, %0, 1\n\t"
+ "1: \n\t"
+ " mov %2, %1\n\t"
+ //
+ // Dword-align %0 (s) if necessary
+ //
+ " andi %4, %0, 0x02\n\t"
+ " beq %4, zero, 2f\n\t"
+ " addi %1, %1, -2\n\t"
+ " sth %3, 0(%0)\n\t"
+ " addi %0, %0, 2\n\t"
+ " mov %2, %1\n\t"
+ "2: \n\t"
+ // %1 and %2 are how many more bytes to set
+ //
+ " srli %2, %2, 2\n\t"
+ //
+ // %2 is how many dwords to set
+ //
+ "3: ;\n\t"
+ " stw %3, 0(%0)\n\t"
+ " addi %0, %0, 4\n\t"
+ " addi %2, %2, -1\n\t"
+ " bne %2, zero, 3b\n\t"
+ //
+ // store residual word and/or byte if necessary
+ //
+ " andi %4, %1, 0x02\n\t"
+ " beq %4, zero, 4f\n\t"
+ " sth %3, 0(%0)\n\t"
+ " addi %0, %0, 2\n\t"
+ "4: \n\t"
+ // store residual byte if necessary
+ //
+ " andi %4, %1, 0x01\n\t"
+ " beq %4, zero, 5f\n\t"
+ " stb %3, 0(%0)\n\t"
+ "5: \n\t"
+
+ : "=r" (destptr), /* %0 Output */
+ "=r" (charcnt), /* %1 Output */
+ "=r" (dwordcnt), /* %2 Output */
+ "=r" (fill8reg), /* %3 Output */
+ "=r" (wrkrega) /* %4 Output */
+
+ : "r" (c & 0xff), /* %5 Input */
+ "0" (s), /* %0 Input/Output */
+ "1" (count) /* %1 Input/Output */
+
+ : "memory" /* clobbered */
+ );
+ }
+ else {
+ char* xs=(char*)s;
+ while (count--)
+ *xs++ = c;
+ }
+ return s;
+}
+#endif
+
+#ifdef __HAVE_ARCH_MEMMOVE
+void * memmove(void * d, const void * s, size_t count)
+{
+ unsigned long dst, src;
+
+ if (d < s) {
+ dst = (unsigned long) d;
+ src = (unsigned long) s;
+
+ if ((count < 8) || ((dst ^ src) & 3))
+ goto restup;
+
+ if (dst & 1) {
+ *(char*)dst++=*(char*)src++;
+ count--;
+ }
+ if (dst & 2) {
+ *(short*)dst=*(short*)src;
+ src += 2;
+ dst += 2;
+ count -= 2;
+ }
+ while (count > 3) {
+ *(long*)dst=*(long*)src;
+ src += 4;
+ dst += 4;
+ count -= 4;
+ }
+
+ restup:
+ while (count--)
+ *(char*)dst++=*(char*)src++;
+ } else {
+ dst = (unsigned long) d + count;
+ src = (unsigned long) s + count;
+
+ if ((count < 8) || ((dst ^ src) & 3))
+ goto restdown;
+
+ if (dst & 1) {
+ src--;
+ dst--;
+ count--;
+ *(char*)dst=*(char*)src;
+ }
+ if (dst & 2) {
+ src -= 2;
+ dst -= 2;
+ count -= 2;
+ *(short*)dst=*(short*)src;
+ }
+ while (count > 3) {
+ src -= 4;
+ dst -= 4;
+ count -= 4;
+ *(long*)dst=*(long*)src;
+ }
+
+ restdown:
+ while (count--) {
+ src--;
+ dst--;
+ *(char*)dst=*(char*)src;
+ }
+ }
+
+ return d;
+
+}
+#endif
diff --git a/arch/nios2nommu/mm/Makefile b/arch/nios2nommu/mm/Makefile
new file mode 100644
index 0000000..b007a11
--- /dev/null
+++ b/arch/nios2nommu/mm/Makefile
@@ -0,0 +1,12 @@
+# $Id: Makefile,v 1.1 2006/07/05 06:23:18 gerg Exp $
+# Makefile for the linux Sparc-specific parts of the memory manager.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definition is now in the main makefile...
+
+obj-y := init.o ioremap.o extable.o memory.o
+obj-y += dma-noncoherent.o
+
diff --git a/arch/nios2nommu/mm/dma-noncoherent.c b/arch/nios2nommu/mm/dma-noncoherent.c
new file mode 100644
index 0000000..5649940
--- /dev/null
+++ b/arch/nios2nommu/mm/dma-noncoherent.c
@@ -0,0 +1,373 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
+ * Copyright (C) 2000, 2001 Ralf Baechle <ralf@gnu.org>
+ * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
+ */
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/cache.h>
+#include <asm/cacheflush.h>
+#include <asm/io.h>
+
+#define UNCAC_ADDR(addr) ((void *)((unsigned long)(addr) | 0x80000000))
+#define CAC_ADDR(addr) ((void *)((unsigned long)(addr) & ~0x80000000))
+
+/*
+ * Warning on the terminology - Linux calls an uncached area coherent;
+ * MIPS terminology calls memory areas with hardware maintained coherency
+ * coherent.
+ */
+
+void *dma_alloc_noncoherent(struct device *dev, size_t size,
+ dma_addr_t * dma_handle, gfp_t gfp)
+{
+ void *ret;
+ /* ignore region specifiers */
+ gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
+
+ if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
+ gfp |= GFP_DMA;
+ ret = (void *) __get_free_pages(gfp, get_order(size));
+
+ if (ret != NULL) {
+ memset(ret, 0, size);
+ *dma_handle = virt_to_phys(ret);
+ }
+
+ return ret;
+}
+
+EXPORT_SYMBOL(dma_alloc_noncoherent);
+
+void *dma_alloc_coherent(struct device *dev, size_t size,
+ dma_addr_t * dma_handle, gfp_t gfp)
+{
+ void *ret;
+
+ ret = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
+ if (ret) {
+ dma_cache_wback_inv((unsigned long) ret, size);
+ ret = UNCAC_ADDR(ret);
+ }
+
+ return ret;
+}
+
+EXPORT_SYMBOL(dma_alloc_coherent);
+
+void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
+ dma_addr_t dma_handle)
+{
+ free_pages((unsigned long) vaddr, get_order(size));
+}
+
+EXPORT_SYMBOL(dma_free_noncoherent);
+
+void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
+ dma_addr_t dma_handle)
+{
+ unsigned long addr = (unsigned long) vaddr;
+
+ addr = (unsigned long) CAC_ADDR(addr);
+ free_pages(addr, get_order(size));
+}
+
+EXPORT_SYMBOL(dma_free_coherent);
+
+static inline void __dma_sync(unsigned long addr, size_t size,
+ enum dma_data_direction direction)
+{
+ switch (direction) {
+ case DMA_TO_DEVICE:
+ dma_cache_wback(addr, size);
+ break;
+
+ case DMA_FROM_DEVICE:
+ dma_cache_inv(addr, size);
+ break;
+
+ case DMA_BIDIRECTIONAL:
+ dma_cache_wback_inv(addr, size);
+ break;
+
+ default:
+ BUG();
+ }
+}
+
+dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
+ enum dma_data_direction direction)
+{
+ unsigned long addr = (unsigned long) ptr;
+
+ __dma_sync(addr, size, direction);
+
+ return virt_to_phys(ptr);
+}
+
+EXPORT_SYMBOL(dma_map_single);
+
+void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
+ enum dma_data_direction direction)
+{
+ unsigned long addr;
+ addr = dma_addr + PAGE_OFFSET;
+
+ //__dma_sync(addr, size, direction);
+}
+
+EXPORT_SYMBOL(dma_unmap_single);
+
+int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction)
+{
+ int i;
+
+ BUG_ON(direction == DMA_NONE);
+
+ for (i = 0; i < nents; i++, sg++) {
+ unsigned long addr;
+
+ addr = (unsigned long) page_address(sg->page);
+ if (addr) {
+ __dma_sync(addr + sg->offset, sg->length, direction);
+ sg->dma_address = (dma_addr_t)page_to_phys(sg->page)
+ + sg->offset;
+ }
+ }
+
+ return nents;
+}
+
+EXPORT_SYMBOL(dma_map_sg);
+
+dma_addr_t dma_map_page(struct device *dev, struct page *page,
+ unsigned long offset, size_t size, enum dma_data_direction direction)
+{
+ unsigned long addr;
+
+ BUG_ON(direction == DMA_NONE);
+
+ addr = (unsigned long) page_address(page) + offset;
+ dma_cache_wback_inv(addr, size);
+
+ return page_to_phys(page) + offset;
+}
+
+EXPORT_SYMBOL(dma_map_page);
+
+void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
+ enum dma_data_direction direction)
+{
+ BUG_ON(direction == DMA_NONE);
+
+ if (direction != DMA_TO_DEVICE) {
+ unsigned long addr;
+
+ addr = dma_address + PAGE_OFFSET;
+ dma_cache_wback_inv(addr, size);
+ }
+}
+
+EXPORT_SYMBOL(dma_unmap_page);
+
+void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
+ enum dma_data_direction direction)
+{
+ unsigned long addr;
+ int i;
+
+ BUG_ON(direction == DMA_NONE);
+
+ if (direction == DMA_TO_DEVICE)
+ return;
+
+ for (i = 0; i < nhwentries; i++, sg++) {
+ addr = (unsigned long) page_address(sg->page);
+ if (addr)
+ __dma_sync(addr + sg->offset, sg->length, direction);
+ }
+}
+
+EXPORT_SYMBOL(dma_unmap_sg);
+
+void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+ size_t size, enum dma_data_direction direction)
+{
+ unsigned long addr;
+
+ BUG_ON(direction == DMA_NONE);
+
+ addr = dma_handle + PAGE_OFFSET;
+ __dma_sync(addr, size, direction);
+}
+
+EXPORT_SYMBOL(dma_sync_single_for_cpu);
+
+void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+ size_t size, enum dma_data_direction direction)
+{
+ unsigned long addr;
+
+ BUG_ON(direction == DMA_NONE);
+
+ addr = dma_handle + PAGE_OFFSET;
+ __dma_sync(addr, size, direction);
+}
+
+EXPORT_SYMBOL(dma_sync_single_for_device);
+
+void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
+ unsigned long offset, size_t size, enum dma_data_direction direction)
+{
+ unsigned long addr;
+
+ BUG_ON(direction == DMA_NONE);
+
+ addr = dma_handle + offset + PAGE_OFFSET;
+ __dma_sync(addr, size, direction);
+}
+
+EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
+
+void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
+ unsigned long offset, size_t size, enum dma_data_direction direction)
+{
+ unsigned long addr;
+
+ BUG_ON(direction == DMA_NONE);
+
+ addr = dma_handle + offset + PAGE_OFFSET;
+ __dma_sync(addr, size, direction);
+}
+
+EXPORT_SYMBOL(dma_sync_single_range_for_device);
+
+void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
+ enum dma_data_direction direction)
+{
+ int i;
+
+ BUG_ON(direction == DMA_NONE);
+
+ /* Make sure that gcc doesn't leave the empty loop body. */
+ for (i = 0; i < nelems; i++, sg++)
+ __dma_sync((unsigned long)page_address(sg->page),
+ sg->length, direction);
+}
+
+EXPORT_SYMBOL(dma_sync_sg_for_cpu);
+
+void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
+ enum dma_data_direction direction)
+{
+ int i;
+
+ BUG_ON(direction == DMA_NONE);
+
+ /* Make sure that gcc doesn't leave the empty loop body. */
+ for (i = 0; i < nelems; i++, sg++)
+ __dma_sync((unsigned long)page_address(sg->page),
+ sg->length, direction);
+}
+
+EXPORT_SYMBOL(dma_sync_sg_for_device);
+
+int dma_mapping_error(dma_addr_t dma_addr)
+{
+ return 0;
+}
+
+EXPORT_SYMBOL(dma_mapping_error);
+
+int dma_supported(struct device *dev, u64 mask)
+{
+ /*
+ * we fall back to GFP_DMA when the mask isn't all 1s,
+ * so we can't guarantee allocations that must be
+ * within a tighter range than GFP_DMA..
+ */
+ if (mask < 0x00ffffff)
+ return 0;
+
+ return 1;
+}
+
+EXPORT_SYMBOL(dma_supported);
+
+int dma_is_consistent(dma_addr_t dma_addr)
+{
+ return 1;
+}
+
+EXPORT_SYMBOL(dma_is_consistent);
+
+void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction)
+{
+ if (direction == DMA_NONE)
+ return;
+
+ dma_cache_wback_inv((unsigned long)vaddr, size);
+}
+
+EXPORT_SYMBOL(dma_cache_sync);
+
+/* The DAC routines are a PCIism.. */
+
+#ifdef CONFIG_PCI
+
+#include <linux/pci.h>
+
+dma64_addr_t pci_dac_page_to_dma(struct pci_dev *pdev,
+ struct page *page, unsigned long offset, int direction)
+{
+ return (dma64_addr_t)page_to_phys(page) + offset;
+}
+
+EXPORT_SYMBOL(pci_dac_page_to_dma);
+
+struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
+ dma64_addr_t dma_addr)
+{
+ return mem_map + (dma_addr >> PAGE_SHIFT);
+}
+
+EXPORT_SYMBOL(pci_dac_dma_to_page);
+
+unsigned long pci_dac_dma_to_offset(struct pci_dev *pdev,
+ dma64_addr_t dma_addr)
+{
+ return dma_addr & ~PAGE_MASK;
+}
+
+EXPORT_SYMBOL(pci_dac_dma_to_offset);
+
+void pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev,
+ dma64_addr_t dma_addr, size_t len, int direction)
+{
+ BUG_ON(direction == PCI_DMA_NONE);
+
+ dma_cache_wback_inv(dma_addr + PAGE_OFFSET, len);
+}
+
+EXPORT_SYMBOL(pci_dac_dma_sync_single_for_cpu);
+
+void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev,
+ dma64_addr_t dma_addr, size_t len, int direction)
+{
+ BUG_ON(direction == PCI_DMA_NONE);
+
+ dma_cache_wback_inv(dma_addr + PAGE_OFFSET, len);
+}
+
+EXPORT_SYMBOL(pci_dac_dma_sync_single_for_device);
+
+#endif /* CONFIG_PCI */
diff --git a/arch/nios2nommu/mm/extable.c b/arch/nios2nommu/mm/extable.c
new file mode 100644
index 0000000..e23778f
--- /dev/null
+++ b/arch/nios2nommu/mm/extable.c
@@ -0,0 +1,29 @@
+/*
+ * linux/arch/niosnommu/mm/extable.c
+ */
+
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <asm/uaccess.h>
+
+/* Simple binary search */
+const struct exception_table_entry *
+search_extable(const struct exception_table_entry *first,
+ const struct exception_table_entry *last,
+ unsigned long value)
+{
+ while (first <= last) {
+ const struct exception_table_entry *mid;
+ long diff;
+
+ mid = (last - first) / 2 + first;
+ diff = mid->insn - value;
+ if (diff == 0)
+ return mid;
+ else if (diff < 0)
+ first = mid+1;
+ else
+ last = mid-1;
+ }
+ return NULL;
+}
diff --git a/arch/nios2nommu/mm/init.c b/arch/nios2nommu/mm/init.c
new file mode 100644
index 0000000..21fe61b
--- /dev/null
+++ b/arch/nios2nommu/mm/init.c
@@ -0,0 +1,231 @@
+/*
+ * linux/arch/nios2nommu/mm/init.c
+ *
+ * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
+ * Kenneth Albanowski <kjahds@kjahds.com>,
+ * Copyright (C) 2000 Lineo, Inc. (www.lineo.com)
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * Based on:
+ *
+ * linux/arch/m68k/mm/init.c
+ *
+ * Copyright (C) 1995 Hamish Macdonald
+ *
+ * JAN/1999 -- hacked to support ColdFire (gerg@snapgear.com)
+ * DEC/2000 -- linux 2.4 support <davidm@snapgear.com>
+ * Jan/20/2004 dgt NiosII
+ *
+ */
+
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/ptrace.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/init.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
+#include <linux/bootmem.h>
+#include <linux/slab.h>
+
+#include <asm/setup.h>
+#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/system.h>
+//;dgt2;#include <asm/machdep.h>
+//;dgt2;#include <asm/shglcore.h>
+
+#undef DEBUG
+
+extern void die_if_kernel(char *,struct pt_regs *,long);
+extern void free_initmem(void);
+
+/*
+ * BAD_PAGE is the page that is used for page faults when linux
+ * is out-of-memory. Older versions of linux just did a
+ * do_exit(), but using this instead means there is less risk
+ * for a process dying in kernel mode, possibly leaving a inode
+ * unused etc..
+ *
+ * BAD_PAGETABLE is the accompanying page-table: it is initialized
+ * to point to BAD_PAGE entries.
+ *
+ * ZERO_PAGE is a special page that is used for zero-initialized
+ * data and COW.
+ */
+static unsigned long empty_bad_page_table;
+
+static unsigned long empty_bad_page;
+
+unsigned long empty_zero_page;
+
+extern unsigned long rom_length;
+
+void show_mem(void)
+{
+ unsigned long i;
+ int free = 0, total = 0, reserved = 0, shared = 0;
+ int cached = 0;
+
+ printk(KERN_INFO "\nMem-info:\n");
+ show_free_areas();
+ i = max_mapnr;
+ while (i-- > 0) {
+ total++;
+ if (PageReserved(mem_map+i))
+ reserved++;
+ else if (PageSwapCache(mem_map+i))
+ cached++;
+ else if (!page_count(mem_map+i))
+ free++;
+ else
+ shared += page_count(mem_map+i) - 1;
+ }
+ printk(KERN_INFO "%d pages of RAM\n",total);
+ printk(KERN_INFO "%d free pages\n",free);
+ printk(KERN_INFO "%d reserved pages\n",reserved);
+ printk(KERN_INFO "%d pages shared\n",shared);
+ printk(KERN_INFO "%d pages swap cached\n",cached);
+}
+
+extern unsigned long memory_start;
+extern unsigned long memory_end;
+
+/*
+ * paging_init() continues the virtual memory environment setup which
+ * was begun by the code in arch/head.S.
+ * The parameters are pointers to where to stick the starting and ending
+ * addresses of available kernel virtual memory.
+ */
+void __init paging_init(void)
+{
+ /*
+ * Make sure start_mem is page aligned, otherwise bootmem and
+ * page_alloc get different views of the world.
+ */
+#ifdef DEBUG
+ unsigned long start_mem = PAGE_ALIGN(memory_start);
+#endif
+ unsigned long end_mem = memory_end & PAGE_MASK;
+
+#ifdef DEBUG
+ printk (KERN_DEBUG "start_mem is %#lx\nvirtual_end is %#lx\n",
+ start_mem, end_mem);
+#endif
+
+ /*
+ * Initialize the bad page table and bad page to point
+ * to a couple of allocated pages.
+ */
+ empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+ empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+ empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+ memset((void *)empty_zero_page, 0, PAGE_SIZE);
+
+ /*
+ * Set up SFC/DFC registers (user data space).
+ */
+ set_fs (USER_DS);
+
+#ifdef DEBUG
+ printk (KERN_DEBUG "before free_area_init\n");
+
+ printk (KERN_DEBUG "free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n",
+ start_mem, end_mem);
+#endif
+
+ {
+ unsigned long zones_size[MAX_NR_ZONES] = {0, };
+
+ zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
+ zones_size[ZONE_NORMAL] = 0;
+#ifdef CONFIG_HIGHMEM
+ zones_size[ZONE_HIGHMEM] = 0;
+#endif
+ free_area_init(zones_size);
+ }
+}
+
+void __init mem_init(void)
+{
+ int codek = 0, datak = 0, initk = 0;
+ unsigned long tmp;
+ extern char _etext, _stext, __init_begin, __init_end, _end;
+ unsigned long start_mem = memory_start; /* DAVIDM - these must start at end of kernel */
+ unsigned long end_mem = memory_end; /* DAVIDM - this must not include kernel stack at top */
+
+#ifdef DEBUG
+ printk(KERN_DEBUG "Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
+#endif
+
+ end_mem &= PAGE_MASK;
+ high_memory = (void *) end_mem;
+
+ start_mem = PAGE_ALIGN(start_mem);
+ max_mapnr = num_physpages = MAP_NR(high_memory);
+
+ /* this will put all memory onto the freelists */
+ totalram_pages = free_all_bootmem();
+
+ codek = (&_etext - &_stext) >> 10;
+ datak = (&_end - &_etext) >> 10;
+ initk = (&__init_begin - &__init_end) >> 10;
+
+ tmp = nr_free_pages() << PAGE_SHIFT;
+ printk(KERN_INFO "Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel code, %dk data)\n",
+ tmp >> 10,
+ (&_end - &_stext) >> 10,
+ (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
+ rom_length >> 10,
+ codek,
+ datak
+ );
+}
+
+
+#ifdef CONFIG_BLK_DEV_INITRD
+void __init free_initrd_mem(unsigned long start, unsigned long end)
+{
+ int pages = 0;
+ for (; start < end; start += PAGE_SIZE) {
+ ClearPageReserved(virt_to_page(start));
+ init_page_count(virt_to_page(start));
+ free_page(start);
+ totalram_pages++;
+ pages++;
+ }
+ printk (KERN_NOTICE "Freeing initrd memory: %dk freed\n", pages);
+}
+#endif
+
+void free_initmem(void)
+{
+#ifdef CONFIG_RAMKERNEL
+ unsigned long addr;
+ extern char __init_begin, __init_end;
+ /*
+ * The following code should be cool even if these sections
+ * are not page aligned.
+ */
+ addr = PAGE_ALIGN((unsigned long)(&__init_begin));
+ /* next to check that the page we free is not a partial page */
+ for (; addr + PAGE_SIZE < (unsigned long)(&__init_end); addr +=PAGE_SIZE) {
+ ClearPageReserved(virt_to_page(addr));
+ init_page_count(virt_to_page(addr));
+ free_page(addr);
+ totalram_pages++;
+ }
+ printk(KERN_NOTICE "Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
+ (addr - PAGE_ALIGN((long) &__init_begin)) >> 10,
+ (int)(PAGE_ALIGN((unsigned long)(&__init_begin))),
+ (int)(addr - PAGE_SIZE));
+#endif
+}
+
diff --git a/arch/nios2nommu/mm/ioremap.c b/arch/nios2nommu/mm/ioremap.c
new file mode 100644
index 0000000..1c8b172
--- /dev/null
+++ b/arch/nios2nommu/mm/ioremap.c
@@ -0,0 +1,65 @@
+/* linux/arch/nios2nommu/mm/ioremap.c, based on:
+ *
+ * linux/arch/m68knommu/mm/kmap.c
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ * Copyright (C) 2000 Lineo, <davidm@lineo.com>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/mm.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+
+#include <asm/setup.h>
+#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/pgalloc.h>
+#include <asm/io.h>
+#include <asm/system.h>
+
+/*
+ * Map some physical address range into the kernel address space.
+ */
+
+void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
+{
+ return (void *)physaddr;
+}
+
+/*
+ * Unmap a ioremap()ed region again
+ */
+void iounmap(void *addr)
+{
+}
+
+/*
+ * __iounmap unmaps nearly everything, so be careful
+ * it doesn't free currently pointer/page tables anymore but it
+ * wans't used anyway and might be added later.
+ */
+void __iounmap(void *addr, unsigned long size)
+{
+}
+
diff --git a/arch/nios2nommu/mm/memory.c b/arch/nios2nommu/mm/memory.c
new file mode 100644
index 0000000..76d60d9
--- /dev/null
+++ b/arch/nios2nommu/mm/memory.c
@@ -0,0 +1,212 @@
+/*
+ * linux/arch/nio2nommu/mm/memory.c
+ *
+ * Copyright (C) 1995 Hamish Macdonald
+ * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
+ * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * Based on:
+ *
+ * linux/arch/m68k/mm/memory.c
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/mm.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+
+#include <asm/setup.h>
+#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/system.h>
+#include <asm/traps.h>
+#include <asm/io.h>
+
+/*
+ * cache_clear() semantics: Clear any cache entries for the area in question,
+ * without writing back dirty entries first. This is useful if the data will
+ * be overwritten anyway, e.g. by DMA to memory. The range is defined by a
+ * _physical_ address.
+ */
+
+void cache_clear (unsigned long paddr, int len)
+{
+}
+
+
+/*
+ * Define cache invalidate functions. The instruction and data cache
+ * will need to be flushed. Write back the dirty data cache and invalidate
+ * the instruction cache for the range.
+ *
+ */
+
+static __inline__ void cache_invalidate_inst(unsigned long paddr, int len)
+{
+ unsigned long sset, eset;
+
+ sset = (paddr & (nasys_icache_size - 1)) & (~(nasys_icache_line_size - 1));
+ eset = (((paddr & (nasys_icache_size - 1)) + len) & (~(nasys_icache_line_size - 1))) + nasys_icache_line_size;
+
+ __asm__ __volatile__ (
+ "1:\n\t"
+ "flushi %0\n\t"
+ "add %0,%0,%2\n\t"
+ "blt %0,%1,1b\n\t"
+ "flushp\n\t"
+ : : "r" (sset), "r" (eset), "r" (nasys_icache_line_size));
+
+}
+
+static __inline__ void cache_invalidate_data(unsigned long paddr, int len)
+{
+ unsigned long sset, eset;
+
+ sset = (paddr & (nasys_dcache_size - 1)) & (~(nasys_dcache_line_size - 1));
+ eset = (((paddr & (nasys_dcache_size - 1)) + len) & (~(nasys_dcache_line_size - 1))) + nasys_dcache_line_size;
+
+ __asm__ __volatile__ (
+ "1:\n\t"
+ "flushd 0(%0)\n\t"
+ "add %0,%0,%2\n\t"
+ "blt %0,%1,1b\n\t"
+ : : "r" (sset),"r" (eset), "r" (nasys_dcache_line_size));
+
+}
+
+static __inline__ void cache_invalidate_lines(unsigned long paddr, int len)
+{
+ unsigned long sset, eset;
+
+ sset = (paddr & (nasys_dcache_size - 1)) & (~(nasys_dcache_line_size - 1));
+ eset = (((paddr & (nasys_dcache_size - 1)) + len) & (~(nasys_dcache_line_size - 1))) + nasys_dcache_line_size;
+
+ __asm__ __volatile__ (
+ "1:\n\t"
+ "flushd 0(%0)\n\t"
+ "add %0,%0,%2\n\t"
+ "blt %0,%1,1b\n\t"
+ : : "r" (sset),"r" (eset), "r" (nasys_dcache_line_size));
+
+ sset = (paddr & (nasys_icache_size - 1)) & (~(nasys_icache_line_size - 1));
+ eset = (((paddr & (nasys_icache_size - 1)) + len) & (~(nasys_icache_line_size - 1))) + nasys_icache_line_size;
+
+ __asm__ __volatile__ (
+ "1:\n\t"
+ "flushi %0\n\t"
+ "add %0,%0,%2\n\t"
+ "blt %0,%1,1b\n\t"
+ "flushp\n\t"
+ : : "r" (sset), "r" (eset), "r" (nasys_icache_line_size));
+
+}
+
+/*
+ * cache_push() semantics: Write back any dirty cache data in the given area,
+ * and invalidate the range in the instruction cache. It needs not (but may)
+ * invalidate those entries also in the data cache. The range is defined by a
+ * _physical_ address.
+ */
+
+void cache_push (unsigned long paddr, int len)
+{
+ cache_invalidate_lines(paddr, len);
+}
+
+
+/*
+ * cache_push_v() semantics: Write back any dirty cache data in the given
+ * area, and invalidate those entries at least in the instruction cache. This
+ * is intended to be used after data has been written that can be executed as
+ * code later. The range is defined by a _user_mode_ _virtual_ address.
+ */
+
+void cache_push_v (unsigned long vaddr, int len)
+{
+ cache_invalidate_lines(vaddr, len);
+}
+
+/*
+ * cache_push_all() semantics: Invalidate instruction cache and write back
+ * dirty data cache & invalidate.
+ */
+void cache_push_all (void)
+{
+ __asm__ __volatile__ (
+ "1:\n\t"
+ "flushd 0(%0)\n\t"
+ "sub %0,%0,%1\n\t"
+ "bgt %0,r0,1b\n\t"
+ : : "r" (nasys_dcache_size), "r" (nasys_dcache_line_size));
+
+ __asm__ __volatile__ (
+ "1:\n\t"
+ "flushi %0\n\t"
+ "sub %0,%0,%1\n\t"
+ "bgt %0,r0,1b\n\t"
+ "flushp\n\t"
+ : : "r" (nasys_icache_size), "r" (nasys_icache_line_size));
+
+}
+
+/*
+ * dcache_push() semantics: Write back and dirty data cache and invalidate
+ * the range.
+ */
+void dcache_push (unsigned long vaddr, int len)
+{
+ cache_invalidate_data(vaddr, len);
+}
+
+/*
+ * icache_push() semantics: Invalidate instruction cache in the range.
+ */
+void icache_push (unsigned long vaddr, int len)
+{
+ cache_invalidate_inst(vaddr, len);
+}
+
+/* Map some physical address range into the kernel address space. The
+ * code is copied and adapted from map_chunk().
+ */
+
+unsigned long kernel_map(unsigned long paddr, unsigned long size,
+ int nocacheflag, unsigned long *memavailp )
+{
+ return paddr;
+}
+
+
+int is_in_rom(unsigned long addr)
+{
+ /* Default case, not in ROM */
+ return(0);
+}
+
+int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
+ unsigned long address, int write_access)
+{
+ BUG();
+ return VM_FAULT_OOM;
+}
diff --git a/arch/nios2nommu/scripts/PTF/PTFParser.pm b/arch/nios2nommu/scripts/PTF/PTFParser.pm
new file mode 100644
index 0000000..c243c7b
--- /dev/null
+++ b/arch/nios2nommu/scripts/PTF/PTFParser.pm
@@ -0,0 +1,873 @@
+####################################################################
+#
+# This file was generated using Parse::Yapp version 1.05.
+#
+# Don't edit this file, use source file instead.
+#
+# ANY CHANGE MADE HERE WILL BE LOST !
+#
+####################################################################
+package PTFParser;
+use vars qw ( @ISA );
+use strict;
+
+@ISA= qw ( Parse::Yapp::Driver );
+#Included Parse/Yapp/Driver.pm file----------------------------------------
+{
+#
+# Module Parse::Yapp::Driver
+#
+# This module is part of the Parse::Yapp package available on your
+# nearest CPAN
+#
+# Any use of this module in a standalone parser make the included
+# text under the same copyright as the Parse::Yapp module itself.
+#
+# This notice should remain unchanged.
+#
+# (c) Copyright 1998-2001 Francois Desarmenien, all rights reserved.
+# (see the pod text in Parse::Yapp module for use and distribution rights)
+#
+
+package Parse::Yapp::Driver;
+
+require 5.004;
+
+use strict;
+
+use vars qw ( $VERSION $COMPATIBLE $FILENAME );
+
+$VERSION = '1.05';
+$COMPATIBLE = '0.07';
+$FILENAME=__FILE__;
+
+use Carp;
+
+#Known parameters, all starting with YY (leading YY will be discarded)
+my(%params)=(YYLEX => 'CODE', 'YYERROR' => 'CODE', YYVERSION => '',
+ YYRULES => 'ARRAY', YYSTATES => 'ARRAY', YYDEBUG => '');
+#Mandatory parameters
+my(@params)=('LEX','RULES','STATES');
+
+sub new {
+ my($class)=shift;
+ my($errst,$nberr,$token,$value,$check,$dotpos);
+ my($self)={ ERROR => \&_Error,
+ ERRST => \$errst,
+ NBERR => \$nberr,
+ TOKEN => \$token,
+ VALUE => \$value,
+ DOTPOS => \$dotpos,
+ STACK => [],
+ DEBUG => 0,
+ CHECK => \$check };
+
+ _CheckParams( [], \%params, \@_, $self );
+
+ exists($$self{VERSION})
+ and $$self{VERSION} < $COMPATIBLE
+ and croak "Yapp driver version $VERSION ".
+ "incompatible with version $$self{VERSION}:\n".
+ "Please recompile parser module.";
+
+ ref($class)
+ and $class=ref($class);
+
+ bless($self,$class);
+}
+
+sub YYParse {
+ my($self)=shift;
+ my($retval);
+
+ _CheckParams( \@params, \%params, \@_, $self );
+
+ if($$self{DEBUG}) {
+ _DBLoad();
+ $retval = eval '$self->_DBParse()';#Do not create stab entry on compile
+ $@ and die $@;
+ }
+ else {
+ $retval = $self->_Parse();
+ }
+ $retval
+}
+
+sub YYData {
+ my($self)=shift;
+
+ exists($$self{USER})
+ or $$self{USER}={};
+
+ $$self{USER};
+
+}
+
+sub YYErrok {
+ my($self)=shift;
+
+ ${$$self{ERRST}}=0;
+ undef;
+}
+
+sub YYNberr {
+ my($self)=shift;
+
+ ${$$self{NBERR}};
+}
+
+sub YYRecovering {
+ my($self)=shift;
+
+ ${$$self{ERRST}} != 0;
+}
+
+sub YYAbort {
+ my($self)=shift;
+
+ ${$$self{CHECK}}='ABORT';
+ undef;
+}
+
+sub YYAccept {
+ my($self)=shift;
+
+ ${$$self{CHECK}}='ACCEPT';
+ undef;
+}
+
+sub YYError {
+ my($self)=shift;
+
+ ${$$self{CHECK}}='ERROR';
+ undef;
+}
+
+sub YYSemval {
+ my($self)=shift;
+ my($index)= $_[0] - ${$$self{DOTPOS}} - 1;
+
+ $index < 0
+ and -$index <= @{$$self{STACK}}
+ and return $$self{STACK}[$index][1];
+
+ undef; #Invalid index
+}
+
+sub YYCurtok {
+ my($self)=shift;
+
+ @_
+ and ${$$self{TOKEN}}=$_[0];
+ ${$$self{TOKEN}};
+}
+
+sub YYCurval {
+ my($self)=shift;
+
+ @_
+ and ${$$self{VALUE}}=$_[0];
+ ${$$self{VALUE}};
+}
+
+sub YYExpect {
+ my($self)=shift;
+
+ keys %{$self->{STATES}[$self->{STACK}[-1][0]]{ACTIONS}}
+}
+
+sub YYLexer {
+ my($self)=shift;
+
+ $$self{LEX};
+}
+
+
+#################
+# Private stuff #
+#################
+
+
+sub _CheckParams {
+ my($mandatory,$checklist,$inarray,$outhash)=@_;
+ my($prm,$value);
+ my($prmlst)={};
+
+ while(($prm,$value)=splice(@$inarray,0,2)) {
+ $prm=uc($prm);
+ exists($$checklist{$prm})
+ or croak("Unknow parameter '$prm'");
+ ref($value) eq $$checklist{$prm}
+ or croak("Invalid value for parameter '$prm'");
+ $prm=unpack('@2A*',$prm);
+ $$outhash{$prm}=$value;
+ }
+ for (@$mandatory) {
+ exists($$outhash{$_})
+ or croak("Missing mandatory parameter '".lc($_)."'");
+ }
+}
+
+sub _Error {
+ print "Parse error.\n";
+}
+
+sub _DBLoad {
+ {
+ no strict 'refs';
+
+ exists(${__PACKAGE__.'::'}{_DBParse})#Already loaded ?
+ and return;
+ }
+ my($fname)=__FILE__;
+ my(@drv);
+ open(DRV,"<$fname") or die "Report this as a BUG: Cannot open $fname";
+ while(<DRV>) {
+ /^\s*sub\s+_Parse\s*{\s*$/ .. /^\s*}\s*#\s*_Parse\s*$/
+ and do {
+ s/^#DBG>//;
+ push(@drv,$_);
+ }
+ }
+ close(DRV);
+
+ $drv[0]=~s/_P/_DBP/;
+ eval join('',@drv);
+}
+
+#Note that for loading debugging version of the driver,
+#this file will be parsed from 'sub _Parse' up to '}#_Parse' inclusive.
+#So, DO NOT remove comment at end of sub !!!
+sub _Parse {
+ my($self)=shift;
+
+ my($rules,$states,$lex,$error)
+ = @$self{ 'RULES', 'STATES', 'LEX', 'ERROR' };
+ my($errstatus,$nberror,$token,$value,$stack,$check,$dotpos)
+ = @$self{ 'ERRST', 'NBERR', 'TOKEN', 'VALUE', 'STACK', 'CHECK', 'DOTPOS' };
+
+#DBG> my($debug)=$$self{DEBUG};
+#DBG> my($dbgerror)=0;
+
+#DBG> my($ShowCurToken) = sub {
+#DBG> my($tok)='>';
+#DBG> for (split('',$$token)) {
+#DBG> $tok.= (ord($_) < 32 or ord($_) > 126)
+#DBG> ? sprintf('<%02X>',ord($_))
+#DBG> : $_;
+#DBG> }
+#DBG> $tok.='<';
+#DBG> };
+
+ $$errstatus=0;
+ $$nberror=0;
+ ($$token,$$value)=(undef,undef);
+ @$stack=( [ 0, undef ] );
+ $$check='';
+
+ while(1) {
+ my($actions,$act,$stateno);
+
+ $stateno=$$stack[-1][0];
+ $actions=$$states[$stateno];
+
+#DBG> print STDERR ('-' x 40),"\n";
+#DBG> $debug & 0x2
+#DBG> and print STDERR "In state $stateno:\n";
+#DBG> $debug & 0x08
+#DBG> and print STDERR "Stack:[".
+#DBG> join(',',map { $$_[0] } @$stack).
+#DBG> "]\n";
+
+
+ if (exists($$actions{ACTIONS})) {
+
+ defined($$token)
+ or do {
+ ($$token,$$value)=&$lex($self);
+#DBG> $debug & 0x01
+#DBG> and print STDERR "Need token. Got ".&$ShowCurToken."\n";
+ };
+
+ $act= exists($$actions{ACTIONS}{$$token})
+ ? $$actions{ACTIONS}{$$token}
+ : exists($$actions{DEFAULT})
+ ? $$actions{DEFAULT}
+ : undef;
+ }
+ else {
+ $act=$$actions{DEFAULT};
+#DBG> $debug & 0x01
+#DBG> and print STDERR "Don't need token.\n";
+ }
+
+ defined($act)
+ and do {
+
+ $act > 0
+ and do { #shift
+
+#DBG> $debug & 0x04
+#DBG> and print STDERR "Shift and go to state $act.\n";
+
+ $$errstatus
+ and do {
+ --$$errstatus;
+
+#DBG> $debug & 0x10
+#DBG> and $dbgerror
+#DBG> and $$errstatus == 0
+#DBG> and do {
+#DBG> print STDERR "**End of Error recovery.\n";
+#DBG> $dbgerror=0;
+#DBG> };
+ };
+
+
+ push(@$stack,[ $act, $$value ]);
+
+ $$token ne '' #Don't eat the eof
+ and $$token=$$value=undef;
+ next;
+ };
+
+ #reduce
+ my($lhs,$len,$code,@sempar,$semval);
+ ($lhs,$len,$code)=@{$$rules[-$act]};
+
+#DBG> $debug & 0x04
+#DBG> and $act
+#DBG> and print STDERR "Reduce using rule ".-$act." ($lhs,$len): ";
+
+ $act
+ or $self->YYAccept();
+
+ $$dotpos=$len;
+
+ unpack('A1',$lhs) eq '@' #In line rule
+ and do {
+ $lhs =~ /^\@[0-9]+\-([0-9]+)$/
+ or die "In line rule name '$lhs' ill formed: ".
+ "report it as a BUG.\n";
+ $$dotpos = $1;
+ };
+
+ @sempar = $$dotpos
+ ? map { $$_[1] } @$stack[ -$$dotpos .. -1 ]
+ : ();
+
+ $semval = $code ? &$code( $self, @sempar )
+ : @sempar ? $sempar[0] : undef;
+
+ splice(@$stack,-$len,$len);
+
+ $$check eq 'ACCEPT'
+ and do {
+
+#DBG> $debug & 0x04
+#DBG> and print STDERR "Accept.\n";
+
+ return($semval);
+ };
+
+ $$check eq 'ABORT'
+ and do {
+
+#DBG> $debug & 0x04
+#DBG> and print STDERR "Abort.\n";
+
+ return(undef);
+
+ };
+
+#DBG> $debug & 0x04
+#DBG> and print STDERR "Back to state $$stack[-1][0], then ";
+
+ $$check eq 'ERROR'
+ or do {
+#DBG> $debug & 0x04
+#DBG> and print STDERR
+#DBG> "go to state $$states[$$stack[-1][0]]{GOTOS}{$lhs}.\n";
+
+#DBG> $debug & 0x10
+#DBG> and $dbgerror
+#DBG> and $$errstatus == 0
+#DBG> and do {
+#DBG> print STDERR "**End of Error recovery.\n";
+#DBG> $dbgerror=0;
+#DBG> };
+
+ push(@$stack,
+ [ $$states[$$stack[-1][0]]{GOTOS}{$lhs}, $semval ]);
+ $$check='';
+ next;
+ };
+
+#DBG> $debug & 0x04
+#DBG> and print STDERR "Forced Error recovery.\n";
+
+ $$check='';
+
+ };
+
+ #Error
+ $$errstatus
+ or do {
+
+ $$errstatus = 1;
+ &$error($self);
+ $$errstatus # if 0, then YYErrok has been called
+ or next; # so continue parsing
+
+#DBG> $debug & 0x10
+#DBG> and do {
+#DBG> print STDERR "**Entering Error recovery.\n";
+#DBG> ++$dbgerror;
+#DBG> };
+
+ ++$$nberror;
+
+ };
+
+ $$errstatus == 3 #The next token is not valid: discard it
+ and do {
+ $$token eq '' # End of input: no hope
+ and do {
+#DBG> $debug & 0x10
+#DBG> and print STDERR "**At eof: aborting.\n";
+ return(undef);
+ };
+
+#DBG> $debug & 0x10
+#DBG> and print STDERR "**Dicard invalid token ".&$ShowCurToken.".\n";
+
+ $$token=$$value=undef;
+ };
+
+ $$errstatus=3;
+
+ while( @$stack
+ and ( not exists($$states[$$stack[-1][0]]{ACTIONS})
+ or not exists($$states[$$stack[-1][0]]{ACTIONS}{error})
+ or $$states[$$stack[-1][0]]{ACTIONS}{error} <= 0)) {
+
+#DBG> $debug & 0x10
+#DBG> and print STDERR "**Pop state $$stack[-1][0].\n";
+
+ pop(@$stack);
+ }
+
+ @$stack
+ or do {
+
+#DBG> $debug & 0x10
+#DBG> and print STDERR "**No state left on stack: aborting.\n";
+
+ return(undef);
+ };
+
+ #shift the error token
+
+#DBG> $debug & 0x10
+#DBG> and print STDERR "**Shift \$error token and go to state ".
+#DBG> $$states[$$stack[-1][0]]{ACTIONS}{error}.
+#DBG> ".\n";
+
+ push(@$stack, [ $$states[$$stack[-1][0]]{ACTIONS}{error}, undef ]);
+
+ }
+
+ #never reached
+ croak("Error in driver logic. Please, report it as a BUG");
+
+}#_Parse
+#DO NOT remove comment
+
+1;
+
+}
+#End of include--------------------------------------------------
+
+
+#line 1 "PTFParser.yp"
+#
+# Altera PTF file parser
+#
+# Copyright (c) 2004 Microtronix Datacom Ltd.
+#
+
+package PTFParser;
+
+use PTF::PTFSection;
+
+#global variables should go here.
+
+#my $line = 0; # for error messages
+#my @sectionStack = (); # used to keep track of ptf sections
+#my $root;
+
+my $fh;
+
+sub new {
+ my($class)=shift;
+ ref($class)
+ and $class=ref($class);
+
+ my($self)=$class->SUPER::new( yyversion => '1.05',
+ yystates =>
+[
+ {#State 0
+ ACTIONS => {
+ 'IDENTIFIER' => 1
+ },
+ GOTOS => {
+ 'section' => 2,
+ 'section_title' => 3
+ }
+ },
+ {#State 1
+ ACTIONS => {
+ 'IDENTIFIER' => 4,
+ 'STRING_LITERAL' => 6,
+ 'NUMBER' => 7
+ },
+ DEFAULT => -3,
+ GOTOS => {
+ 'section_name' => 5
+ }
+ },
+ {#State 2
+ ACTIONS => {
+ '' => 8
+ }
+ },
+ {#State 3
+ ACTIONS => {
+ "{" => 9
+ }
+ },
+ {#State 4
+ DEFAULT => -4
+ },
+ {#State 5
+ DEFAULT => -2
+ },
+ {#State 6
+ DEFAULT => -6
+ },
+ {#State 7
+ DEFAULT => -5
+ },
+ {#State 8
+ DEFAULT => 0
+ },
+ {#State 9
+ ACTIONS => {
+ 'IDENTIFIER' => 11,
+ 'HIERARCHICAL_NAME' => 13
+ },
+ DEFAULT => -7,
+ GOTOS => {
+ 'assignment_name' => 10,
+ 'assignment' => 12,
+ 'section_element' => 14,
+ 'section' => 15,
+ 'section_title' => 3
+ }
+ },
+ {#State 10
+ ACTIONS => {
+ "=" => 16
+ }
+ },
+ {#State 11
+ ACTIONS => {
+ 'IDENTIFIER' => 4,
+ 'STRING_LITERAL' => 6,
+ 'NUMBER' => 7,
+ "=" => -11
+ },
+ DEFAULT => -3,
+ GOTOS => {
+ 'section_name' => 5
+ }
+ },
+ {#State 12
+ ACTIONS => {
+ 'IDENTIFIER' => 11,
+ 'HIERARCHICAL_NAME' => 13
+ },
+ DEFAULT => -7,
+ GOTOS => {
+ 'assignment_name' => 10,
+ 'assignment' => 12,
+ 'section_element' => 17,
+ 'section' => 15,
+ 'section_title' => 3
+ }
+ },
+ {#State 13
+ DEFAULT => -12
+ },
+ {#State 14
+ ACTIONS => {
+ "}" => 18
+ }
+ },
+ {#State 15
+ ACTIONS => {
+ 'IDENTIFIER' => 11,
+ 'HIERARCHICAL_NAME' => 13
+ },
+ DEFAULT => -7,
+ GOTOS => {
+ 'assignment_name' => 10,
+ 'assignment' => 12,
+ 'section_element' => 19,
+ 'section' => 15,
+ 'section_title' => 3
+ }
+ },
+ {#State 16
+ ACTIONS => {
+ 'STRING_LITERAL' => 20,
+ 'NUMBER' => 22
+ },
+ GOTOS => {
+ 'assignment_value' => 21
+ }
+ },
+ {#State 17
+ DEFAULT => -8
+ },
+ {#State 18
+ DEFAULT => -1
+ },
+ {#State 19
+ DEFAULT => -9
+ },
+ {#State 20
+ DEFAULT => -13
+ },
+ {#State 21
+ ACTIONS => {
+ ";" => 23
+ }
+ },
+ {#State 22
+ DEFAULT => -14
+ },
+ {#State 23
+ DEFAULT => -10
+ }
+],
+ yyrules =>
+[
+ [#Rule 0
+ '$start', 2, undef
+ ],
+ [#Rule 1
+ 'section', 4,
+sub
+#line 20 "PTFParser.yp"
+{
+ my $sectionStack = $_[0]->YYData->{sectionStack};
+ pop @{$sectionStack};
+ }
+ ],
+ [#Rule 2
+ 'section_title', 2,
+sub
+#line 26 "PTFParser.yp"
+{
+ my $section = PTFSection->new (type => $_[1], name => $_[2]);
+ my $sectionStack = $_[0]->YYData->{sectionStack};
+
+ if (scalar(@{$sectionStack}) == 0) {
+ $_[0]->YYData->{root} = $section;
+ } else {
+ my $parent = $sectionStack->[$#{$sectionStack}];
+ $parent->addSection ($section);
+ }
+
+ push @{$sectionStack}, $section;
+ }
+ ],
+ [#Rule 3
+ 'section_name', 0, undef
+ ],
+ [#Rule 4
+ 'section_name', 1, undef
+ ],
+ [#Rule 5
+ 'section_name', 1, undef
+ ],
+ [#Rule 6
+ 'section_name', 1, undef
+ ],
+ [#Rule 7
+ 'section_element', 0, undef
+ ],
+ [#Rule 8
+ 'section_element', 2, undef
+ ],
+ [#Rule 9
+ 'section_element', 2, undef
+ ],
+ [#Rule 10
+ 'assignment', 4,
+sub
+#line 52 "PTFParser.yp"
+{
+ my $sectionStack = $_[0]->YYData->{sectionStack};
+ my $parent= $sectionStack->[$#{$sectionStack}];
+ $parent->addAssignment ($_[1], $_[3]);
+ }
+ ],
+ [#Rule 11
+ 'assignment_name', 1, undef
+ ],
+ [#Rule 12
+ 'assignment_name', 1, undef
+ ],
+ [#Rule 13
+ 'assignment_value', 1, undef
+ ],
+ [#Rule 14
+ 'assignment_value', 1, undef
+ ]
+],
+ @_);
+ bless($self,$class);
+}
+
+#line 67 "PTFParser.yp"
+
+
+sub _Error {
+# TODO: update this error function to be more useful
+ exists $_[0]->YYData->{ERRMSG}
+ and do {
+ print $_[0]->YYData->{ERRMSG};
+ delete $_[0]->YYData->{ERRMSG};
+ return;
+ };
+ print "Syntax error on line $_[0]->YYData->{line}.\n";
+}
+
+sub _Lexer {
+ my($parser)=shift;
+
+ if (! $parser->YYData->{INPUT}) {
+ if ($parser->YYData->{INPUT} = <$fh>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ }
+
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+
+ while (1) {
+
+ # skip blank lines
+ if ($parser->YYData->{INPUT} =~ s/^[ \t\r\n]*$//) {
+ if ($parser->YYData->{INPUT} = <$fh>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+ next;
+ }
+
+ # Skip comments
+ if ($parser->YYData->{INPUT} =~ s/^#.*//) {
+ if ($parser->YYData->{INPUT} = <$fh>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+ next;
+ }
+
+ # Don't continue if the line length is 0;
+ if (length $parser->YYData->{INPUT} == 0) {
+ if ($parser->YYData->{INPUT} = <$fh>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+ next;
+ }
+
+ # tokenize input
+ $parser->YYData->{INPUT} =~ s/^([a-zA-Z_][a-zA-Z_0-9\/]*)//
+ and return('IDENTIFIER',$1);
+ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)"//
+ and return('STRING_LITERAL',$1);
+ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)//
+ and do {
+ my $literal = $1;
+
+ do {
+ if ($parser->YYData->{INPUT} = <$fh>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+
+ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)"//
+ and do {
+ $literal .= $1;
+ return ('STRING_LITERAL', $literal);
+ };
+
+ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)//
+ and $literal .= $1;
+ } while (1);
+ };
+ $parser->YYData->{INPUT} =~ s/^([0-9]+)//
+ and return('NUMBER',$1);
+ $parser->YYData->{INPUT} =~ s/^([\$]{1,2}[a-zA-Z0-9 \/_]+)//
+ and return('HIERARCHICAL_NAME',$1);
+ $parser->YYData->{INPUT} =~ s/^(.)//
+ and return($1,$1);
+ }
+}
+
+sub readPTF {
+ my $self = shift;
+ my $filename = shift;
+
+ # store information for later use
+ $self->YYData->{line} = 0;
+ $self->YYData->{sectionStack} = [];
+ undef $self->YYData->{root};
+
+ if (-e $filename) {
+ open (PTFFILE, $filename);
+ $fh = \*PTFFILE;
+ } else {
+ $fh = \*STDIN;
+ }
+
+ $self->YYParse (
+ yylex => \&_Lexer,
+ yyerror => \&_Error,
+ );
+
+ if (-e $filename) {
+ close PTFFILE;
+ }
+
+ return $self->YYData->{root};
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/PTF/PTFParser.yp b/arch/nios2nommu/scripts/PTF/PTFParser.yp
new file mode 100644
index 0000000..e105e6a
--- /dev/null
+++ b/arch/nios2nommu/scripts/PTF/PTFParser.yp
@@ -0,0 +1,178 @@
+%{#
+# Altera PTF file parser
+#
+# Copyright (c) 2004 Microtronix Datacom Ltd.
+#
+
+package PTFParser;
+
+use PTF::PTFSection;
+
+%}
+
+%%
+section: section_title '{' section_element '}' {
+ my $sectionStack = $_[0]->YYData->{sectionStack};
+ pop @{$sectionStack};
+ }
+;
+
+section_title: IDENTIFIER section_name {
+ my $section = PTFSection->new (type => $_[1], name => $_[2]);
+ my $sectionStack = $_[0]->YYData->{sectionStack};
+
+ if (scalar(@{$sectionStack}) == 0) {
+ $_[0]->YYData->{root} = $section;
+ } else {
+ my $parent = $sectionStack->[$#{$sectionStack}];
+ $parent->addSection ($section);
+ }
+
+ push @{$sectionStack}, $section;
+ }
+;
+
+section_name: # empty string
+ | IDENTIFIER
+ | NUMBER
+ | STRING_LITERAL
+;
+
+section_element: # empty element
+ | assignment section_element
+ | section section_element
+;
+
+assignment: assignment_name '=' assignment_value ';' {
+ my $sectionStack = $_[0]->YYData->{sectionStack};
+ my $parent= $sectionStack->[$#{$sectionStack}];
+ $parent->addAssignment ($_[1], $_[3]);
+ }
+;
+
+assignment_name: IDENTIFIER
+ | HIERARCHICAL_NAME
+;
+
+assignment_value: STRING_LITERAL
+ | NUMBER
+;
+
+%%
+
+sub _Error {
+# TODO: update this error function to be more useful
+ exists $_[0]->YYData->{ERRMSG}
+ and do {
+ print $_[0]->YYData->{ERRMSG};
+ delete $_[0]->YYData->{ERRMSG};
+ return;
+ };
+ print "Syntax error on line $_[0]->YYData->{line}.\n";
+}
+
+sub _Lexer {
+ my($parser)=shift;
+
+ if (! $parser->YYData->{INPUT}) {
+ if ($parser->YYData->{INPUT} = <PTFFILE>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ }
+
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+
+ while (1) {
+
+ # skip blank lines
+ if ($parser->YYData->{INPUT} =~ s/^[ \t\r\n]*$//) {
+ if ($parser->YYData->{INPUT} = <PTFFILE>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+ next;
+ }
+
+ # Skip comments
+ if ($parser->YYData->{INPUT} =~ s/^#.*//) {
+ if ($parser->YYData->{INPUT} = <PTFFILE>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+ next;
+ }
+
+ # Don't continue if the line length is 0;
+ if (length $parser->YYData->{INPUT} == 0) {
+ if ($parser->YYData->{INPUT} = <PTFFILE>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+ $parser->YYData->{INPUT} and
+ $parser->YYData->{INPUT} =~ s/^\s*//;
+ next;
+ }
+
+ # tokenize input
+ $parser->YYData->{INPUT} =~ s/^([a-zA-Z_][a-zA-Z_0-9\/]*)//
+ and return('IDENTIFIER',$1);
+ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)"//
+ and return('STRING_LITERAL',$1);
+ $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)//
+ and do {
+ my $literal = $1;
+
+ do {
+ if ($parser->YYData->{INPUT} = <PTFFILE>) {
+ $parser->YYData->{line} += 1;
+ } else {
+ return ('', undef);
+ }
+
+ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)"//
+ and do {
+ $literal .= $1;
+ return ('STRING_LITERAL', $literal);
+ };
+
+ $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)//
+ and $literal .= $1;
+ } while (1);
+ };
+ $parser->YYData->{INPUT} =~ s/^([0-9]+)//
+ and return('NUMBER',$1);
+ $parser->YYData->{INPUT} =~ s/^([\$]{1,2}[a-zA-Z0-9 \/_]+)//
+ and return('HIERARCHICAL_NAME',$1);
+ $parser->YYData->{INPUT} =~ s/^(.)//
+ and return($1,$1);
+ }
+}
+
+sub readPTF {
+ my $self = shift;
+ my $filename = shift;
+
+ # store information for later use
+ $self->YYData->{line} = 0;
+ $self->YYData->{sectionStack} = [];
+ undef $self->YYData->{root};
+
+ open (PTFFILE, $filename) or return undef;
+ $self->YYParse (
+ yylex => \&_Lexer,
+ yyerror => \&_Error,
+ );
+ close PTFFILE;
+
+ return $self->YYData->{root};
+}
diff --git a/arch/nios2nommu/scripts/PTF/PTFSection.pm b/arch/nios2nommu/scripts/PTF/PTFSection.pm
new file mode 100644
index 0000000..a88d340
--- /dev/null
+++ b/arch/nios2nommu/scripts/PTF/PTFSection.pm
@@ -0,0 +1,81 @@
+package PTFSection;
+
+use strict;
+
+# Fields:
+# type = type of PTF Section
+# name = name of PTF Section (can be blank)
+# sections = array of section references
+# assignments = hash of assignments
+
+sub new {
+ my $invocant = shift;
+ my $class = ref($invocant) || $invocant;
+ my $self = {
+ @_,
+ sections => [],
+ assignments => {},
+ };
+ bless ($self, $class);
+ return $self;
+}
+
+sub addSection {
+ my ($self, $section) = @_;
+ push @{$self->{sections}}, $section;
+}
+
+sub getSections {
+ my ($self, $type) = @_;
+
+ if (! $type) {
+ return @{$self->{sections}};
+ }
+
+ my @matchedSections;
+ foreach my $section (@{$self->{sections}}) {
+ if ($section->type eq $type) {
+ push @matchedSections, $section;
+ }
+ }
+
+ return @matchedSections;
+}
+
+sub getSection {
+ my ($self, $type, $name) = @_;
+
+ if (! $name) {
+ $name = "";
+ }
+
+ foreach my $section (@{$self->{sections}}) {
+ if ($section->type eq $type and $section->name eq $name) {
+ return $section;
+ }
+ }
+
+}
+
+sub addAssignment {
+ my ($self, $name, $value) = @_;
+ $self->{assignments}{$name} = $value;
+}
+
+sub getAssignment {
+ my ($self, $name) = @_;
+ return $self->{assignments}{$name};
+}
+
+sub type {
+ my $self = shift;
+ return $self->{type};
+}
+
+sub name {
+ my $self = shift;
+ return $self->{name};
+}
+
+
+1;
diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF.pm b/arch/nios2nommu/scripts/PTF/SystemPTF.pm
new file mode 100644
index 0000000..9f44cfe
--- /dev/null
+++ b/arch/nios2nommu/scripts/PTF/SystemPTF.pm
@@ -0,0 +1,149 @@
+package SystemPTF;
+
+use strict;
+
+use PTF::PTFParser;
+use PTF::PTFSection;
+use PTF::SystemPTF::CPU;
+use PTF::SystemPTF::Board;
+use PTF::SystemPTF::Module;
+
+# Fields:
+
+my %module_order;
+
+sub new {
+ my $invocant = shift;
+ my $class = ref($invocant) || $invocant;
+ my $self = {
+ filename => "",
+ @_,
+ };
+
+ my $parser = PTFParser->new;
+ $self->{root} = $parser->readPTF($self->{filename});
+
+ # if the specified PTF file could not be read properly, return undef;
+ $self->{root} or return;
+
+ # if the specified PTF file is not a SYSTEM, return undef.
+ if ($self->{root}->type ne 'SYSTEM') {
+ return;
+ }
+
+ # initialize the modulemap
+ my @modules = $self->{root}->getSections ("MODULE");
+ my $index = 0;
+ foreach my $module (@modules) {
+ # if the module is not enabled then do not add
+ my $SBI = $module->getSection ('SYSTEM_BUILDER_INFO', '');
+ if ($SBI->getAssignment ('Is_Enabled') eq "1") {
+ $self->{modules}->{$module->name} = $module;
+ $module_order{$module->name} = $index;
+ $index += 1;
+ }
+ }
+
+ bless ($self, $class);
+ return $self;
+}
+
+sub getName {
+ my ($self) = @_;
+ return $self->{root}->name;
+}
+
+sub getCPUList {
+ my ($self, @classes) = @_;
+ my @cpulist = ();
+
+ foreach my $module_name (keys (%{$self->{modules}})) {
+ my $module = $self->{modules}->{$module_name};
+ my $module_class = $module->getAssignment ('class');
+ foreach my $class (@classes) {
+ if ($module_class eq $class) {
+ push @cpulist, $module->name;
+ }
+ }
+ }
+
+ return @cpulist;
+}
+
+sub getCPU {
+ my ($self, $name) = @_;
+
+ my $cpu = CPU->new (ptf => $self->{modules}->{$name});
+}
+
+sub getModule {
+ my ($self, $name) = @_;
+
+ my $module = Module->new (ptf => $self->{modules}->{$name});
+}
+
+sub getSlaveModules {
+ my ($self, $master, $type) = @_;
+
+ # create %connected set with just the master
+ # value of hash key is inconsequential
+ my %connected;
+ $connected{$master} = ( );
+
+ # create %pool set with all modules
+ # value of hash key is inconsequential
+ my %pool;
+ @pool{keys (%{$self->{modules}})} = ( );
+
+ my $dirty = 1;
+ while ($dirty) {
+ # %pool = difference (%pool, %connected)
+ delete @pool{ keys %connected };
+
+ $dirty = 0;
+
+ foreach my $name (keys %pool) {
+ my $mod = $self->getModule ($name);
+ my %mod_masters;
+ @mod_masters{ $mod->getMasters ($type) } = ( );
+
+ # if intersection (%masters, %connected) is not empty
+ delete @mod_masters{
+ grep ( ! exists $connected{ $_ },
+ keys %mod_masters) };
+
+ if (scalar(keys(%mod_masters)) > 0) {
+ $connected{$name} = ( );
+ $dirty = 1;
+ }
+ }
+ }
+
+ delete $connected{$master};
+
+ return sort module_comparison keys (%connected);
+}
+
+sub getClockFreq () {
+ my ($self) = @_;
+
+ my $wsa = $self->{root}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
+ $wsa or return;
+
+ my $result = $wsa->getAssignment ('clock_freq');
+ return $result;
+}
+
+# This is not really a class method... more of a helper function really...
+sub module_comparison {
+ if ($module_order{$a} > $module_order{$b}) {
+ return 1;
+ } elsif ($module_order{$a} < $module_order{$b}) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+
+1;
diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm
new file mode 100644
index 0000000..fe2bbc8
--- /dev/null
+++ b/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm
@@ -0,0 +1,2 @@
+1;
+
diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm
new file mode 100644
index 0000000..ea10598
--- /dev/null
+++ b/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm
@@ -0,0 +1,89 @@
+package CPU;
+
+use PTF::PTFSection;
+
+sub new {
+ my $invocant = shift;
+ my $class = ref($invocant) || $invocant;
+ my $self = {
+ @_,
+ };
+
+ # if no ptf section was passed in, then return undef
+ $self->{ptf} or return;
+
+ bless ($self, $class);
+ return $self;
+}
+
+sub getClass {
+ my ($self) = @_;
+
+ return $self->{ptf}->getAssignment ('class');
+}
+
+sub getVersion {
+ my ($self) = @_;
+
+ return $self->{ptf}->getAssignment ('class_version');
+}
+
+sub getConstant {
+ my ($self, $name) = @_;
+
+ # get WSA
+ $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
+ $wsa or return;
+
+ # get constants section
+ $constants = $wsa->getSection('CONSTANTS', '');
+ $constants or return;
+
+ # get section for specific constant
+ $constant = $constants->getSection ('CONSTANT', $name);
+ $constant or return;
+
+ # get value of constant
+ $value = $constant->getAssignment ('value');
+ return $value;
+}
+
+sub getWSAAssignment {
+ my ($self, $name) = @_;
+
+ # get WSA
+ $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
+ $wsa or return;
+
+ # get value of WSA Assignment
+ $value = $wsa->getAssignment ($name);
+ return $value;
+}
+
+sub getResetLocationOffset {
+ my ($self) = @_;
+
+ $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
+ $wsa or return;
+
+ my $location = $wsa->getAssignment ('reset_slave');
+ my $offset = $wsa->getAssignment ('reset_offset');
+
+ return ($location, $offset);
+}
+
+sub isEnabled {
+ my ($self) = @_;
+
+ $sbi = $self->{ptf}->getSection('SYSTEM_BUILDER_INFO', '');
+ $sbi or return;
+
+ my $enabled = $sbi->getAssignment ('Is_Enabled');
+ if ($enabled eq "1") {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm
new file mode 100644
index 0000000..48d246b
--- /dev/null
+++ b/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm
@@ -0,0 +1,267 @@
+package Module;
+
+use PTF::PTFSection;
+
+sub new {
+ my $invocant = shift;
+ my $class = ref($invocant) || $invocant;
+ my $self = {
+ @_,
+ };
+
+ # if no ptf section was passed in, then return undef
+ $self->{ptf} or return;
+
+ bless ($self, $class);
+ return $self;
+}
+
+sub getClass {
+ my ($self) = @_;
+
+ return $self->{ptf}->getAssignment ('class');
+}
+
+sub getPorts {
+ my ($self) = @_;
+
+ my @port_names;
+
+ my @ports = $self->{ptf}->getSections ('SLAVE');
+ foreach $port (@ports) {
+ push @port_names, $port->name;
+ }
+
+ return @port_names;
+}
+
+sub getPort {
+ my ($self, $port_name) = @_;
+
+ my $port;
+
+ if (! $port_name) {
+ # use first port found
+ my @port_names = $self->getPorts ();
+ $port = $self->{ptf}->getSection ('SLAVE', $port_names[0]);
+ } else {
+ $port = $self->{ptf}->getSection ('SLAVE', $port_name);
+ if (! $port) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+ }
+
+ return $port;
+}
+
+sub getWSAAssignment {
+ my ($self, $assignment) = @_;
+
+ my $WSA = $self->{ptf}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
+ if (! $WSA) {
+ # return undef if the WSA section doesn't exist.
+ return;
+ }
+
+ my $result = $WSA->getAssignment ($assignment);
+
+ return $result;
+
+}
+
+sub getWSAConstant {
+ my ($self, $name) = @_;
+
+ my $WSA = $self->{ptf}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
+ if (! $WSA) {
+ # return undef if the WSA section doesn't exist.
+ return;
+ }
+
+ my $constants = $WSA->getSection ('CONSTANTS', '');
+ if (! $constants) {
+ # return undef if the CONSTANTS section doesn't exist.
+ return;
+ }
+
+ my $constant = $constants->getSection ('CONSTANT', $name);
+ if (! $constant) {
+ # return undef if the CONSTANT $name section doesn't exist.
+ return;
+ }
+
+ my $result = $constant->getAssignment ('value');
+ return $result;
+
+}
+
+sub isMemoryDevice {
+ my ($self, $port_name) = @_;
+
+ my $port = $self->getPort ($port_name);
+ if (! $port) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
+ if (! $SBI) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $result = $SBI->getAssignment('Is_Memory_Device');
+
+ return $result;
+}
+
+sub isCustomInstruction {
+ my ($self, $port_name) = @_;
+
+ my $port = $self->getPort ($port_name);
+ if (! $port) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
+ if (! $SBI) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $result = $SBI->getAssignment('Is_Custom_Instruction');
+
+ return $result;
+}
+
+sub getBaseAddress {
+ my ($self, $port_name) = @_;
+
+ my $port = $self->getPort ($port_name);
+ if (! $port) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
+ if (! $SBI) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $result = $SBI->getAssignment('Base_Address');
+ if ($result eq 'N/A') {
+ return;
+ }
+ return $result;
+}
+
+sub getSize {
+ my ($self, $port_name) = @_;
+
+ my $port = $self->getPort ($port_name);
+ $port or return; #return undef if the ptf section doesn't exist
+
+ my $SBI = $port->getSection ('SYSTEM_BUILDER_INFO', '');
+ my $data_width = $SBI->getAssignment ('Data_Width');
+ my $addr_width = $SBI->getAssignment ('Address_Width');
+
+ if ($data_width == 8) {
+ $size = 1 << $addr_width;
+ } elsif ($data_width == 16) {
+ $size = 1 << ($addr_width + 1);
+ } elsif ($data_width == 32) {
+ $size = 1 << ($addr_width + 2);
+ } elsif ($data_width == 64) {
+ $size = 1 << ($addr_width + 3);
+ } elsif ($data_width == 128) {
+ $size = 1 << ($addr_width + 4);
+ } else {
+ return;
+ }
+
+ $size_text = sprintf ("%#010x", $size);
+ return $size_text;
+}
+
+sub getIRQ {
+ my ($self, $port_name) = @_;
+
+ my $port = $self->getPort ($port_name);
+ if (! $port) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
+ if (! $SBI) {
+ # return undef if the PTF section doesn't exist
+ return;
+ }
+
+ my $result = $SBI->getAssignment('Has_IRQ');
+ if ($result ne "1") {
+ # this device has no associated IRQ
+ return;
+ }
+
+ my @irq_masters = $SBI->getSections('IRQ_MASTER');
+ return $irq_masters[0]->getAssignment('IRQ_Number');
+}
+
+sub getMasters {
+ my ($self, $type) = @_;
+ my %masters = ();
+
+ # get list of all slave for device
+ my @slaves = $self->{ptf}->getSections ('SLAVE');
+
+ # get list of masters of relevant type for all slaves
+ foreach my $slave (@slaves) {
+ # get SBI for slave
+ my $SBI = $slave->getSection ('SYSTEM_BUILDER_INFO', '');
+
+ # get list of all MASTERED_BY and IRQ_MASTER sections
+ my @mastered_bys = $SBI->getSections ('MASTERED_BY');
+ my @irq_masters = $SBI->getSections ('IRQ_MASTER');
+
+ # start adding masters to the list
+ foreach my $master (@mastered_bys, @irq_masters) {
+ my $section_name = $master->name;
+ $section_name =~ /(.*)\/(.*)/;
+ my $master_name = $1;
+ my $master_type = $2;
+
+ if (! $type) {
+ $masters{$master_name} = ();
+ } else {
+ if ($master_type eq $type) {
+ $masters{$master_name} = ();
+ }
+ }
+
+ }
+
+ }
+
+ return keys (%masters);
+}
+
+sub isEnabled {
+ my ($self) = @_;
+
+ $sbi = $self->{ptf}->getSection('SYSTEM_BUILDER_INFO', '');
+ $sbi or return;
+
+ my $enabled = $sbi->getAssignment ('Is_Enabled');
+ if ($enabled eq "1") {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+1;
+
diff --git a/arch/nios2nommu/scripts/gen_nios2_system.h.pl b/arch/nios2nommu/scripts/gen_nios2_system.h.pl
new file mode 100644
index 0000000..b7bcff5
--- /dev/null
+++ b/arch/nios2nommu/scripts/gen_nios2_system.h.pl
@@ -0,0 +1,314 @@
+# This script generates an appropriate hardware.h file for Nios II Linux based
+# on information within the target hardware's system.ptf file. This script
+# outputs everything to stdout.
+#
+# usage:
+#
+# [SOPC Builder]$ perl gen_hardware.h.pl <target cpu> <exec location> \
+# <upload location>
+#
+
+use PTF::SystemPTF;
+use strict;
+use integer;
+
+my $target_cpu;
+my $exec_location;
+my $upload_location;
+
+if (scalar (@ARGV) != 3) {
+ print STDERR "ERROR: Invalid number of parameters.\n";
+ print ("#error Invalid number of parameters.\n");
+ exit;
+} else {
+ $target_cpu = $ARGV[0];
+ $exec_location = $ARGV[1];
+ $upload_location = $ARGV[2];
+}
+
+#
+# startup the parser.
+#
+my $system = SystemPTF->new;
+if (!$system) {
+ print STDERR "ERROR: Specified file is not a SYSTEM ptf file.\n";
+ print ("#error Specified file is not a SYSTEM ptf file.\n");
+ exit;
+}
+
+#
+# print header for nios2_system.h
+#
+print <<ENDOFHEADER;
+#ifndef __NIOS2_SYSTEM_H__
+#define __NIOS2_SYSTEM_H__
+
+/*
+ * This file contains hardware information about the target platform.
+ * The nios2_system.h file is being phased out and will be removed in a
+ * later release.
+ *
+ * All base addresses for non memory devices have their high bit turned on to
+ * bypass the cache.
+ *
+ * This file is automatically generated. Do not modify.
+ */
+
+ENDOFHEADER
+
+#
+# generate contents for nios2_system.h
+#
+my $result; # dummy variable
+my $cpu = $system->getCPU ($target_cpu);
+if (! $cpu) {
+ print STDERR "ERROR: $target_cpu is not a valid CPU in system: " . $system->getName () . ".\n";
+ print "#error $target_cpu is not a valid CPU in system: " . $system->getName () . ".\n";
+ exit 1;
+}
+
+my $exec_module = $system->getModule ($exec_location);
+if (! $exec_module) {
+ print STDERR "ERROR: $exec_location is not a valid module in the system: " . $system->getName() . ".\n";
+ print "#error $exec_location is not a valid module in system: " . $system->getName () . ".\n";
+ exit 1;
+}
+
+my $upload_module = $system->getModule ($upload_location);
+if (! $upload_module) {
+ print STDERR "ERROR: $upload_location is not a valid module in the system: " . $system->getName() . ".\n";
+ print "#error $upload_location is not a valid module in system: " . $system->getName () . ".\n";
+ exit 1;
+}
+
+my %found_classes;
+my @found_classes_order;
+
+# the SYSPTF environment variable is set by kernel build process.
+if ($ENV{SYSPTF} ne "") {
+ print "/* Input System: " . $ENV{SYSPTF} . ":" . $system->getName () . " */\n";
+} else {
+ print "/* Input System: " . $system->getName () . " */\n";
+}
+print "/* Target CPU: " . $target_cpu . " */\n";
+
+print "\n";
+
+print <<ENDOFCONSTANTS;
+/* Nios II Constants */
+#define NIOS2_STATUS_PIE_MSK 0x1
+#define NIOS2_STATUS_PIE_OFST 0
+#define NIOS2_STATUS_U_MSK 0x2
+#define NIOS2_STATUS_U_OFST 1
+ENDOFCONSTANTS
+
+print "\n";
+
+print "/*\n";
+print " * Outputting basic values from system.ptf.\n";
+print " */\n\n";
+
+#
+# Start outputing information about each module.
+#
+my @module_names = $system->getSlaveModules ($target_cpu);
+foreach my $module_name (@module_names) {
+ my $module = $system->getModule ($module_name);
+ my $module_class = $module->getClass ();
+ my @module_ports = $module->getPorts ();
+ my $mask = 0;
+ my $text_printed = 0;
+ my $output = "";
+
+ # $output .= "/* $module_name (of type $module_class) */\n";
+
+ if (! exists $found_classes{$module_class}) {
+ push @found_classes_order, $module_class;
+ }
+ push @{$found_classes{$module_class}}, $module_name;
+
+ if (! $module->isMemoryDevice () && ! $module->isCustomInstruction ()) {
+ # turn on high bit for base address
+ $mask = 0x80000000;
+ }
+
+ if (scalar (@module_ports) == 1) {
+ my $base_address;
+ my $mem_size;
+ my $mem_end;
+
+ # base address information
+ $base_address = $module->getBaseAddress ();
+ if ($base_address) {
+ $output .= sprintf ("#define na_%-50s %#010x\n",
+ ($module_name, hex ($base_address) | $mask));
+ $text_printed = 1;
+ }
+ if ($module->isMemoryDevice()) {
+ # output size and end address
+ $mem_size = $module->getSize();
+ $output .= sprintf ("#define na_%-50s %#010x\n",
+ ($module_name . "_size", hex ($mem_size)));
+ $mem_end = hex ($mem_size) + hex($base_address);
+ $output .= sprintf ("#define na_%-50s %#010x\n",
+ ($module_name . "_end", $mem_end));
+
+ $text_printed = 1;
+ }
+
+ # irq information
+ $result = $module->getIRQ ();
+ if (defined ($result)) {
+ $output .= sprintf ("#define na_%-30s %30s\n",
+ ($module_name . "_irq", $result));
+ $text_printed = 1;
+ }
+
+ } else {
+ # if device has multiple ports
+ foreach my $port_name (@module_ports) {
+ # base address information
+ $result = $module->getBaseAddress ($port_name);
+ if ($result) {
+ $output .= sprintf ("#define na_%-50s %#010x\n",
+ ($module_name . "_" . $port_name, hex ($result) | $mask));
+ $text_printed = 1;
+ }
+
+ # irq information
+ $result = $module->getIRQ ($port_name);
+ if (defined ($result)) {
+ $output .= sprintf ("#define na_%-30s %30s\n",
+ ($module_name . "_" . $port_name . "_irq", $result));
+ $text_printed = 1;
+ }
+ }
+ }
+
+ if ($text_printed == 1) {
+ # $output .= "\n";
+ print $output;
+ }
+}
+
+print "\n";
+
+#
+# Handle special cases through customized perl scripts
+#
+foreach my $class_name (@found_classes_order) {
+ my $code = "";
+
+ foreach my $dir (@INC) {
+ if (-e "$dir/nios2_system.h/$class_name.pm") {
+ print "/* Executing ...scripts/nios2_system.h/$class_name.pm */\n";
+ $code .= "require \"$dir/nios2_system.h/BasicModule.pm\";";
+ $code .= "require \"$dir/nios2_system.h/$class_name.pm\";";
+ $code .= $class_name . "::run(\$system, \@{\$found_classes{\$class_name}});";
+ eval $code;
+ if ($@) {
+ print "#warning Could not execute ...scripts/nios2_system.h/$class_name.pm\n";
+ print "#warning Error message is stored in nios2_system.h:\n";
+ print "/*\n";
+ print "$@";
+ print "*/\n";
+ print STDERR "Could not execute ...scripts/nios2_system.h/$class_name.pm\n";
+ print STDERR "Error message follows:\n";
+ print STDERR "$@";
+ }
+ last;
+ }
+ }
+}
+
+#
+# Write out system information
+#
+print "/*\n";
+print " * Basic System Information\n";
+print " */\n";
+
+$result = $cpu->getWSAAssignment ('cache_icache_size');
+printf ("#define %-53s %10d\n", ("nasys_icache_size", $result));
+
+$result = $cpu->getConstant ('nasys_icache_line_size');
+printf ("#define %-53s %10d\n", ("nasys_icache_line_size", $result));
+
+$result = $cpu->getWSAAssignment ('cache_dcache_size');
+printf ("#define %-53s %10d\n", ("nasys_dcache_size", $result));
+
+$result = $cpu->getConstant ('nasys_dcache_line_size');
+printf ("#define %-53s %10d\n", ("nasys_dcache_line_size", $result));
+
+print "\n";
+
+printf ("#define %-33s %30s\n",
+ ("nasys_program_mem", "na_${exec_location}"));
+printf ("#define %-33s %30s\n",
+ ("nasys_program_mem_size", "na_${exec_location}_size"));
+printf ("#define %-33s %30s\n",
+ ("nasys_program_mem_end", "na_${exec_location}_end"));
+
+print "\n";
+
+if ($upload_location eq "flash_kernel") {
+ # nothing to do
+ print ("/* Redefinition of CFI flash memory unecessary */\n");
+} else {
+ my $module = $system->getModule ("flash_kernel");
+ if ($module) {
+ # there is a conflicting module in the system, error.
+ print STDERR "Error, a SOPC module named flash_kernel already exists but is not the upload location.\n";
+ print "#error The module name \"flash_kernel\" already exists but isn't the upload location.\n";
+ print "#error This will break the kernel.\n";
+ print "#error Please rename the module to something else in SOPC Builder.\n\n";
+ exit 1;
+ } else {
+ print ("/*\n");
+ print (" * Redefining upload location ($upload_location) to flash_kernel.\n");
+ print (" */\n\n");
+ # undefine the original module names and re-define them here.
+ print ("#undef na_${upload_location}\n");
+ print ("#undef na_${upload_location}_size\n");
+ print ("#undef na_${upload_location}_end\n");
+
+ my $base_address = $upload_module->getBaseAddress ();
+ printf ("#define %-33s %30s\n",
+ ("na_flash_kernel", $base_address));
+
+ my $mem_size = $upload_module->getSize();
+ printf ("#define %-33s %30s\n",
+ ("na_flash_kernel_size", $mem_size));
+
+ my $mem_end = hex ($base_address) + hex ($mem_size);
+ printf ("#define %-53s %#010x\n",
+ ("na_flash_kernel_end", $mem_end));
+ }
+}
+
+print "\n";
+
+printf ("#define %-33s %30s\n",
+ ("nasys_clock_freq", $system->getClockFreq()));
+printf ("#define %-33s %30s\n",
+ ("nasys_clock_freq_1000", int ($system->getClockFreq()) / 1000));
+
+{
+ my ($reset_location, $reset_offset) = $cpu->getResetLocationOffset();
+ my ($reset_module_name, $reset_port_name) = ($reset_location =~ /(.*)\/(.*)/);
+ my $reset_module = $system->getModule ($reset_module_name);
+ my $reset_address = $reset_module->getBaseAddress ($reset_port_name);
+
+ $reset_address = hex ($reset_address) + hex ($reset_offset);
+ printf ("#define %-53s %#010x\n",
+ ("CPU_RESET_ADDRESS", $reset_address));
+}
+
+print "\n";
+
+#
+# print footer for nios2_system.h
+#
+print <<ENDOFFOOTER;
+#endif /* __NIOS2_SYSTEM_H__ */
+ENDOFFOOTER
diff --git a/arch/nios2nommu/scripts/hwselect.pl b/arch/nios2nommu/scripts/hwselect.pl
new file mode 100644
index 0000000..8181bee
--- /dev/null
+++ b/arch/nios2nommu/scripts/hwselect.pl
@@ -0,0 +1,166 @@
+# This script generates arch/nios2nommu/hardware.mk based on user input
+
+# usage:
+#
+# [SOPC Builder]$ perl hwselect.pl <ptf file path> <target file path>
+#
+
+use PTF::SystemPTF;
+use strict;
+use integer;
+
+my $ptf_filename;
+my $target_filename;
+my $index;
+my $system;
+
+#
+# Subroutine: Prompt user for an answer
+#
+
+sub request_answer {
+ my ($min, $max) = @_;
+ my $answer;
+
+ do {
+ print "Selection: ";
+ $answer = <STDIN>;
+ if (! ($answer >= $min && $answer <= $max)) {
+ print "Invalid response, please try again.\n";
+ }
+ } until $answer >= $min && $answer <= $max;
+
+ return $answer;
+}
+
+#
+# Check for correct number of args
+#
+
+if (scalar (@ARGV) != 2) {
+ print STDERR "ERROR: Invalid number of parameters.\n";
+ exit;
+} else {
+ $ptf_filename = $ARGV[0];
+ $target_filename = $ARGV[1];
+}
+
+#
+# Check to see if the specified file exists
+#
+
+if (! -e $ptf_filename) {
+ print STDERR "ERROR: Could not open SYSTEM ptf file.\n";
+ exit;
+}
+
+#
+# startup the parser.
+#
+$system = SystemPTF->new (filename => $ptf_filename);
+if (!$system) {
+ print STDERR "ERROR: Specified file is not a SYSTEM ptf file.\n";
+ exit;
+}
+
+#
+# Grab listing of Nios II processors and force user to select one:
+#
+
+print "\n--- Please select which CPU you wish to build the kernel against:\n\n";
+
+my @cpulist = $system->getCPUList ('altera_nios2');
+my %cpuinfo;
+
+$index = 1;
+foreach my $cpu (@cpulist) {
+ my $cpu_module = $system->getCPU ($cpu);
+ if ($cpu_module->isEnabled ()) {
+ my $class = $cpu_module->getClass();
+ my $type = $cpu_module->getWSAAssignment('cpu_selection');
+ my $version = $cpu_module->getVersion();
+
+ print "($index) $cpu - Class: $class Type: $type Version: $version\n";
+ }
+ $index += 1;
+}
+
+print "\n";
+
+my $cpu_selection = $cpulist[request_answer (1, $index - 1) - 1];
+
+#
+# Grab list of memory devices that $cpu_selection is hooked up to:
+#
+my @modulelist = $system->getSlaveModules ($cpu_selection);
+my %cfiinfo;
+my %meminfo;
+foreach my $module_name (@modulelist) {
+ my $module = $system->getModule ($module_name);
+ my $class = $module->getClass ();
+
+ if ($module->isEnabled ()) {
+ if ($class eq 'altera_avalon_cfi_flash') {
+ $cfiinfo{$module_name}{class} = $class;
+ $cfiinfo{$module_name}{size} = $module->getSize();
+ }
+
+ if ($module->isMemoryDevice()) {
+ $meminfo{$module_name}{class} = $class;
+ $meminfo{$module_name}{size} = $module->getSize();
+ }
+ }
+}
+
+#
+# Select an upload device:
+#
+print "\n--- Please select a device to upload the kernel to:\n\n";
+
+$index = 1;
+foreach my $name (keys (%cfiinfo)) {
+ my $size = hex ($cfiinfo{$name}{size});
+ print "($index) $name\n\tClass: $cfiinfo{$name}{class}\n\tSize: $size bytes\n\n";
+ $index += 1;
+}
+
+my @cfilist = keys (%cfiinfo);
+my $cfi_selected = $cfilist[request_answer (1, $index - 1) - 1];
+
+delete $meminfo{$cfi_selected};
+
+#
+# Select program memory to execute kernel from:
+#
+print "\n--- Please select a device to execute kernel from:\n\n";
+
+$index = 1;
+foreach my $name (keys (%meminfo)) {
+ my $size = hex ($meminfo{$name}{size});
+ print "($index) $name\n\tClass: $meminfo{$name}{class}\n\tSize: $size bytes\n\n";
+ $index += 1;
+}
+
+my @memlist = keys (%meminfo);
+my $mem_selected = $memlist[request_answer (1, $index - 1) - 1];
+
+print "\n--- Summary using\n\n";
+print "PTF: $ptf_filename\n";
+print "CPU: $cpu_selection\n";
+print "Device to upload to: $cfi_selected\n";
+print "Program memory to execute from: $mem_selected\n";
+
+#
+# Write settings out to Makefile fragment
+#
+open (HWMK, ">$target_filename") ||
+ die "Could not write to $target_filename";
+
+print HWMK "SYSPTF = $ptf_filename\n";
+print HWMK "CPU = $cpu_selection\n";
+print HWMK "UPLMEM = $cfi_selected\n";
+print HWMK "EXEMEM = $mem_selected\n";
+
+close (HWMK);
+
+print "\n--- Settings written to $target_filename\n\n";
\ No newline at end of file
diff --git a/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm b/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm
new file mode 100644
index 0000000..e15c26b
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm
@@ -0,0 +1,267 @@
+package BasicModule;
+
+require PTF::SystemPTF;
+require PTF::SystemPTF::Module;
+use strict;
+
+# Description: Prints an error message to stdout. This should prefix each line
+# with "#error " so that it can be properly read by the C
+# pre-processor.
+# Args: $module_name: name of module that was is required by driver
+# $class_name: name of device class that module belongs to.
+sub print_error_name_used {
+ my ($class, $module_name, $class_name) = @_;
+
+ print "#error The kernel requires that the $class->required_class_name device be named as $module_name.\n";
+ print "#error The current hardware has $module_name defined as a(n) $class_name device.\n";
+ print "#error This will cause the kernel to fail.\n";
+ print "#error Please rename the current $module_name device to something else in SOPC Builder.\n";
+}
+
+# Description: This casts the base address to a specific data type
+# By default, it does not cast the base address to
+# anything.
+sub base_address_cast {
+ my ($class, $port_name) = @_;
+ return;
+}
+
+# Description: This sub-routine prints out a prefix that is shown only once
+# before any translations take place.
+sub print_prefix {
+ my ($class, $system) = @_;
+ printf ("\n");
+}
+
+# Description: Prints a set of lines to stdout that re-defines all symbols
+# related to $module_name to the symbols required by the driver.
+# Typically starts off with "#undefine ..." statements followed
+# by one or more "#define statements".
+# Args: $required_module_name: the module name that's expected by the kernel.
+# $module_name: the name of the module that was found in the PTF file.
+sub translate {
+ my ($class, $system, $required_module_name, $module_name) = @_;
+
+ # get the necessary info about the module
+ my $module = $system->getModule ($module_name);
+ my @port_names = $module->getPorts ();
+
+ my $boolean_base_address_cast = 0;
+ if (scalar (@port_names) > 1) {
+ foreach my $port_name (@port_names) {
+ my $cast = $class->base_address_cast ($port_name);
+ if (defined ($cast)) {
+ $boolean_base_address_cast = 1;
+ last;
+ }
+ }
+ } else {
+ my $cast = $class->base_address_cast;
+ if (defined ($cast)) {
+ $boolean_base_address_cast = 1;
+ }
+ }
+
+ if ($module_name eq $required_module_name &&
+ !$boolean_base_address_cast) {
+ printf ("/* No translation necessary for $module_name */\n\n");
+ return;
+ }
+
+ # undefine the original entries
+ print "/* Redefining $module_name -> $required_module_name */\n";
+ if (scalar (@port_names) == 1) {
+ my $irq = $module->getIRQ ();
+ print "#undef na_" . $module_name . "\n";
+ if (defined ($irq)) {
+ print "#undef na_" . $module_name . "_irq\n";
+ }
+ print "\n";
+ } else {
+ foreach my $port_name (@port_names) {
+ print "#undef na_" . $module_name . "_" .
+ $port_name . "\n";
+ my $irq = $module->getIRQ ($port_name);
+ if (defined ($irq)) {
+ print "#undef na_" . $module_name . "_" .
+ $port_name . "_irq\n";
+ }
+ print "\n";
+ }
+ }
+
+ if (scalar (@port_names) == 1) {
+ # set up a string to pass to printf that will output the correct
+ # #define base address statement.
+
+ # turn on the high bit for the base address to bypass cache.
+ my $base_address = $module->getBaseAddress ();
+ $base_address = hex ($base_address) | 0x80000000;
+
+ my $cast = $class->base_address_cast;
+ $class->print_define_line ($required_module_name,
+ undef, "addr", $cast, $base_address);
+
+ # print out an IRQ define statement if necessary
+ my $irq = $module->getIRQ ();
+ if (defined ($irq)) {
+ $class->print_define_line ($required_module_name,
+ undef, "irq", undef, $irq);
+ }
+ printf ("\n");
+ } else {
+ foreach my $port_name (@port_names) {
+ my $cast = $class->base_address_cast ($port_name);
+ my $base_address = $module->getBaseAddress ($port_name);
+ $base_address = hex ($base_address) | 0x80000000;
+ $class->print_define_line ($required_module_name,
+ $port_name, "addr", $cast, $base_address);
+
+ my $irq = $module->getIRQ ($port_name);
+ if (defined ($irq)) {
+ $class->print_define_line (
+ $required_module_name, $port_name,
+ "irq", undef, $irq);
+ }
+
+ print "\n";
+ }
+ }
+}
+
+# Description: The following sub-routine prints out "undef" or "define"
+# statements based on the arguments received.
+# Args: $name: "define" or "undef"
+# $port: name of port (if applicable)
+# $type: "addr" or "irq"
+# $cast: data type to cast base address to (if applicable)
+# $value: value of symbol to be defined (if applicable)
+sub print_define_line {
+ my ($class, $name, $port, $type, $cast, $value) = @_;
+
+ # construct the symbol that is being used
+ my $symbol .= "na_";
+ $symbol .= $name;
+
+ $symbol .= defined ($port) ? "_" . $port : "";
+ $symbol .= $type eq "irq" ? "_irq" : "";
+
+ my $string_value;
+ if ($type eq "addr") {
+ $string_value = sprintf ("%#010x", $value);
+ if (defined $cast) {
+ $string_value = "(($cast*) $string_value)";
+ }
+ } else {
+ $string_value = $value;
+ }
+ printf ("%-41s %30s\n", "#define $symbol", $string_value);
+}
+
+# Description: This sub-routine prints out a prefix that is shown only once
+# after any translations take place.
+sub print_suffix {
+ my ($class, $system) = @_;
+ # intentionally left empty
+}
+
+# Description: The following function allows the class to further determine if
+# the module is valid. For instance, the timer class requires
+# that the selected module does not have a fixed period.
+# This function returns true by default which basically means
+# that all modules belonging to class are valid.
+sub is_module_valid {
+ my ($class, $system, $module_name) = @_;
+ return 1;
+}
+
+# Description: This sub-routine is required. It is executed by the
+# "../gen_nios2_system_h.pl" script whenever any devices of type
+# $class->required_class_name are found in the PTF file.
+#
+# It looks for any conflicting module names first. If any are
+# found, "print_error_name_used" is called and this perl module
+# exits.
+#
+# It then goes through the list of module names found in the PTF
+# file that are of type $class->required_class_name and maps them to the
+# list of unused names in $class->required_module_names.
+#
+# Finally, it will call the "translate" sub-routine to output the
+# symbols required by the driver.
+# Args: $system: a variable containing a reference to the system.ptf file that
+# provides full access to any information in the file.
+# @found_module_names: a list of module names that are of type
+# $class->required_class_name
+sub run2 {
+ my ($class, $system, @found_module_names) = @_;
+
+ # initialize a mapping of required module names to actual module names
+ my %module_map;
+ foreach my $module_name ($class->required_module_names) {
+ $module_map{$module_name} = "";
+ }
+
+ # if the required module name is already in use in the PTF file for a
+ # different device class, flag it as an error.
+ my $error_found = 0;
+ foreach my $module_name ($class->required_module_names) {
+ my $module = $system->getModule ($module_name);
+
+ if (!defined ($module)) {
+ next;
+ }
+
+ my $class_name = $module->getClass ();
+ if ($class_name ne $class->required_class_name) {
+ $class->print_error_name_used ($class, $module_name, $class_name);
+ $error_found = 1;
+ }
+ }
+
+ # if errors were found, then there's no point in continuing.
+ if ($error_found == 1) {
+ return;
+ }
+
+ # Run through list of modules that belong to the class and start
+ # mapping each module name to the first unused required module name
+ # as defined above
+ FOUND_MOD_LOOP: foreach my $module_name (@found_module_names) {
+
+ # If the module name has already been used, then continue
+ # to the next one.
+ foreach my $required_module_name ($class->required_module_names) {
+ if ($module_map{$required_module_name} eq $module_name) {
+ next FOUND_MOD_LOOP;
+ }
+ }
+
+ # assertion: $module_name is not mapped yet.
+ foreach my $required_module_name ($class->required_module_names) {
+ if ($module_map{$required_module_name} ne "") {
+ next;
+ }
+
+ if ($class->is_module_valid ($system, $module_name)) {
+ $module_map{$required_module_name} = $module_name;
+ }
+ last;
+ }
+ }
+
+ $class->print_prefix ($system);
+
+ # Now that everything's been mapped (or as close as we're going to get
+ # to it being mapped), start printing out the literal translation.
+ foreach my $required_module_name ($class->required_module_names) {
+ my $module_name = $module_map{$required_module_name};
+ if (length ($module_name) > 0) {
+ $class->translate ($system, $required_module_name, $module_name);
+ }
+ }
+
+ $class->print_suffix ($system);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm
new file mode 100644
index 0000000..dada452
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm
@@ -0,0 +1,18 @@
+package altera_avalon_cf;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ "ide"
+}
+
+sub required_class_name {
+ "altera_avalon_cf"
+}
+
+sub run {
+ altera_avalon_cf->run2(@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm
new file mode 100644
index 0000000..22bb9c9
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm
@@ -0,0 +1,18 @@
+package altera_avalon_jtag_uart;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ ("jtag_uart")
+}
+
+sub required_class_name {
+ "altera_avalon_jtag_uart";
+}
+
+sub run {
+ altera_avalon_jtag_uart->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm
new file mode 100644
index 0000000..5a29b7e
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm
@@ -0,0 +1,38 @@
+package altera_avalon_lan91c111;
+
+require PTF::SystemPTF;
+require PTF::SystemPTF::Module;
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ "enet"
+}
+
+sub required_class_name {
+ "altera_avalon_lan91c111"
+}
+
+sub translate {
+ my $class = shift;
+ my ($system, $required_module_name, $module_name) = @_;
+ $class->SUPER::translate (@_);
+
+ my $module = $system->getModule ($module_name);
+
+ my $offset_keyword = "LAN91C111_REGISTERS_OFFSET";
+ my $offset = $module->getWSAConstant ($offset_keyword);
+ printf ("%-41s %30s\n", "#define $offset_keyword", $offset);
+
+ my $width_keyword = "LAN91C111_DATA_BUS_WIDTH";
+ my $width = $module->getWSAConstant ($width_keyword);
+ printf ("%-41s %30s\n", "#define $width_keyword", $width);
+
+ print "\n";
+}
+
+sub run {
+ altera_avalon_lan91c111->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm
new file mode 100644
index 0000000..afdbcae
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm
@@ -0,0 +1,46 @@
+package altera_avalon_pio;
+
+require PTF::SystemPTF;
+require PTF::SystemPTF::Module;
+use strict;
+
+sub run {
+ my ($system, @pio_names) = @_;
+
+ print "#ifndef __ASSEMBLY__\n";
+ print "#include <asm/pio_struct.h>\n";
+ print "#endif\n\n";
+
+ foreach my $pio_name (@pio_names) {
+ my $module = $system->getModule ($pio_name);
+
+ # get all the relevant information
+ my $base_address = $module->getBaseAddress ();
+ $base_address = hex ($base_address) | 0x80000000;
+ my $irq = $module->getIRQ ();
+
+ print "/* Casting base addresses to the appropriate structure */\n";
+
+ # undefine all the old symbols first
+ print "#undef na_${pio_name}\n";
+ if (defined ($irq)) {
+ print "#undef na_${pio_name}_irq\n";
+ print "\n";
+ }
+
+ # define base address
+ $base_address = sprintf ("%#010x", $base_address);
+ printf ("%-41s %30s\n", "#define na_${pio_name}",
+ "((np_pio*) ${base_address})");
+
+ # define irq
+ if (defined ($irq)) {
+ printf ("%-41s %30s\n", "#define na_${pio_name}_irq",
+ $irq);
+ }
+
+ print "\n";
+ }
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm
new file mode 100644
index 0000000..719a22c
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm
@@ -0,0 +1,30 @@
+package altera_avalon_spi;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ "spi"
+}
+
+sub required_class_name {
+ "altera_avalon_spi"
+}
+
+sub base_address_cast {
+ "np_spi"
+}
+
+sub print_prefix {
+ my ($class, $system) = @_;
+
+ print "#ifndef __ASSEMBLY__\n";
+ print "#include <asm/spi_struct.h>\n";
+ print "#endif\n\n";
+}
+
+sub run {
+ altera_avalon_spi->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm
new file mode 100644
index 0000000..deb9826
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm
@@ -0,0 +1,18 @@
+package altera_avalon_sysid;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_class_name {
+ "altera_avalon_sysid"
+}
+
+sub required_module_names {
+ "sysid"
+}
+
+sub run {
+ altera_avalon_sysid->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
new file mode 100644
index 0000000..495ccdc
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
@@ -0,0 +1,46 @@
+package altera_avalon_timer;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_class_name {
+ "altera_avalon_timer";
+}
+
+sub required_module_names {
+ "timer0"
+}
+
+sub print_prefix {
+ my ($class, $system) = @_;
+
+ print "\n";
+ print "#ifndef __ASSEMBLY__\n";
+ print "#include <asm/timer_struct.h>\n";
+ print "#endif\n";
+ print "\n";
+}
+
+sub base_address_cast {
+ "np_timer"
+}
+
+# only timers with a non-fixed-period are valid
+sub is_module_valid {
+ my ($class, $system, $module_name) = @_;
+
+ my $module = $system->getModule ($module_name);
+ my $fixed_period = $module->getWSAAssignment ('fixed_period');
+
+ if ($fixed_period eq '0') {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub run {
+ altera_avalon_timer->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm
new file mode 100644
index 0000000..abf48d7
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm
@@ -0,0 +1,44 @@
+package altera_avalon_uart;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ ("uart0", "uart1", "uart2", "uart3")
+}
+
+sub required_class_name {
+ "altera_avalon_uart";
+}
+
+sub base_address_cast {
+ "np_uart"
+}
+
+sub print_prefix {
+ my ($class, $system) = @_;
+
+ print "#ifndef __ASSEMBLY__\n";
+ print "#include <asm/uart_struct.h>\n";
+ print "#endif\n\n";
+}
+
+sub translate {
+ my $class = shift;
+ my ($system, $required_module_name, $module_name) = @_;
+
+ $class->SUPER::translate (@_);
+
+ if (!defined ($altera_avalon_uart::default_uart)) {
+ print "/* The default uart is always the first one found in the PTF file */\n";
+ print "#define nasys_printf_uart na_$required_module_name\n\n";
+ $altera_avalon_uart::default_uart = $required_module_name;
+ }
+
+}
+
+sub run {
+ altera_avalon_uart->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm b/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm
new file mode 100644
index 0000000..fdd727b
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm
@@ -0,0 +1,18 @@
+package mtip_avalon_10_100_mac;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_class_name {
+ "mtip_avalon_10_100_mac";
+}
+
+sub required_module_names {
+ "mtip_mac"
+}
+
+sub run {
+ mtip_avalon_10_100_mac->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm
new file mode 100644
index 0000000..5985c2f
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm
@@ -0,0 +1,18 @@
+package mtx_avalon_dm9000;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ "dm9000"
+}
+
+sub required_class_name {
+ "mtx_avalon_dm9000"
+}
+
+sub run {
+ mtx_avalon_dm9000->run2(@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm
new file mode 100644
index 0000000..e70ffa3
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm
@@ -0,0 +1,18 @@
+package mtx_avalon_isp1161a1;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ "usb"
+}
+
+sub required_class_name {
+ "mtx_avalon_isp1161a1";
+}
+
+sub run {
+ mtx_avalon_isp1161a1->run2(@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm b/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm
new file mode 100644
index 0000000..7b580b5
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm
@@ -0,0 +1,18 @@
+package opencores_ethernet_mac;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ "igor_mac"
+}
+
+sub required_class_name {
+ "opencores_ethernet_mac"
+}
+
+sub run {
+ opencores_ethernet_mac->run2 (@_);
+}
+
+1;
diff --git a/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm b/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm
new file mode 100644
index 0000000..512d12c
--- /dev/null
+++ b/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm
@@ -0,0 +1,18 @@
+package opencores_i2c;
+
+use base qw(BasicModule);
+use strict;
+
+sub required_module_names {
+ ("i2c_0", "i2c_1")
+}
+
+sub required_class_name {
+ "opencores_i2c";
+}
+
+sub run {
+ opencores_i2c->run2 (@_);
+}
+
+1;
diff --git a/include/asm-nios2nommu/ChangeLog b/include/asm-nios2nommu/ChangeLog
new file mode 100644
index 0000000..94aaa27
--- /dev/null
+++ b/include/asm-nios2nommu/ChangeLog
@@ -0,0 +1,14 @@
+2004-06-29 Ken Hill <khill@microtronix.com>
+
+ * bitops.h (find_next_zero_bit): Fix problem with with masking for found_first
+ handling. The masking of the upper bits for size < 32 bits would set all
+ the bits to 1. Removing any zero's there may have been.
+
+2004-06-02 Ken Hill <khill@microtronix.com>
+
+ * processor.h (TASK_SIZE): Change na_sdram_end to nasys_program_mem_end to remove
+ dependancy on quartus memory component name.
+
+ * page.h (PAGE_OFFSET): Change na_sdram to nasys_program_mem to remove
+ dependancy on quartus memory component name.
+
diff --git a/include/asm-nios2nommu/Kbuild b/include/asm-nios2nommu/Kbuild
new file mode 100644
index 0000000..abf0368
--- /dev/null
+++ b/include/asm-nios2nommu/Kbuild
@@ -0,0 +1,4 @@
+include include/asm-generic/Kbuild.asm
+
+header-y += traps.h
+header-y += io.h
diff --git a/include/asm-nios2nommu/a.out.h b/include/asm-nios2nommu/a.out.h
new file mode 100644
index 0000000..8297687
--- /dev/null
+++ b/include/asm-nios2nommu/a.out.h
@@ -0,0 +1,85 @@
+/* $Id: a.out.h,v 1.1 2006/07/05 06:20:25 gerg Exp $ */
+/*
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef __NIOS2NOMMU_A_OUT_H__
+#define __NIOS2NOMMU_A_OUT_H__
+
+#define SPARC_PGSIZE 0x1000 /* Thanks to the sun4 architecture... */
+#define SEGMENT_SIZE SPARC_PGSIZE /* whee... */
+
+struct exec {
+ unsigned char a_dynamic:1; /* A __DYNAMIC is in this image */
+ unsigned char a_toolversion:7;
+ unsigned char a_machtype;
+ unsigned short a_info;
+ unsigned long a_text; /* length of text, in bytes */
+ unsigned long a_data; /* length of data, in bytes */
+ unsigned long a_bss; /* length of bss, in bytes */
+ unsigned long a_syms; /* length of symbol table, in bytes */
+ unsigned long a_entry; /* where program begins */
+ unsigned long a_trsize;
+ unsigned long a_drsize;
+};
+
+#define INIT_EXEC { \
+ .a_dynamic = 0, \
+ .a_toolversion = 0, \
+ .a_machtype = 0, \
+ .a_info = 0, \
+ .a_text = 0, \
+ .a_data = 0, \
+ .a_bss = 0, \
+ .a_syms = 0, \
+ .a_entry = 0, \
+ .a_trsize = 0, \
+ .a_drsize = 0, \
+}
+
+/* Where in the file does the text information begin? */
+#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
+
+/* Where do the Symbols start? */
+#define N_SYMOFF(x) (N_TXTOFF(x) + (x).a_text + \
+ (x).a_data + (x).a_trsize + \
+ (x).a_drsize)
+
+/* Where does text segment go in memory after being loaded? */
+#define N_TXTADDR(x) (((N_MAGIC(x) == ZMAGIC) && \
+ ((x).a_entry < SPARC_PGSIZE)) ? \
+ 0 : SPARC_PGSIZE)
+
+/* And same for the data segment.. */
+#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC ? \
+ (N_TXTADDR(x) + (x).a_text) \
+ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
+
+#define N_TRSIZE(a) ((a).a_trsize)
+#define N_DRSIZE(a) ((a).a_drsize)
+#define N_SYMSIZE(a) ((a).a_syms)
+
+#ifdef __KERNEL__
+
+#define STACK_TOP TASK_SIZE
+
+#endif
+
+#endif /* __NIOS2NOMMU_A_OUT_H__ */
diff --git a/include/asm-nios2nommu/altera_juart.h b/include/asm-nios2nommu/altera_juart.h
new file mode 100644
index 0000000..da6320d
--- /dev/null
+++ b/include/asm-nios2nommu/altera_juart.h
@@ -0,0 +1,36 @@
+/*------------------------------------------------------------------------
+ *
+ * linux/drivers/serial/altera_juart.h
+ *
+ * Driver for Altera JTAG UART core with Avalon interface
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * History:
+ * Jun/20/2005 DGT Microtronix Datacom NiosII
+ *
+ -----------------------------------------------------------------------*/
+
+#ifndef _ALTERA_JUART_H_
+ #define _ALTERA_JUART_H_
+
+ /* jtag uart details needed outside of the driver itself: */
+ /* by: arch/kernel/start.c - boot time error message(s) */
+
+ void jtaguart_console_write
+ ( struct console *co,
+ const char *s,
+ unsigned int count);
+
+#endif /* _ALTERA_JUART_H_ */
diff --git a/include/asm-nios2nommu/asm-macros.h b/include/asm-nios2nommu/asm-macros.h
new file mode 100644
index 0000000..9dda7cd
--- /dev/null
+++ b/include/asm-nios2nommu/asm-macros.h
@@ -0,0 +1,331 @@
+/*
+ * Macro used to simplify coding multi-line assembler.
+ * Some of the bit test macro can simplify down to one line
+ * depending on the mask value.
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/*
+ * ANDs reg2 with mask and places the result in reg1.
+ *
+ * You cannnot use the same register for reg1 & reg2.
+ */
+
+.macro ANDI32 reg1,reg2,mask
+ .if \mask & 0xffff
+ .if \mask & 0xffff0000
+ movhi \reg1,%hi(\mask)
+ movui \reg1,%lo(\mask)
+ and \reg1,\reg1,\reg2
+ .else
+ andi \reg1,\reg2,%lo(\mask)
+ .endif
+ .else
+ andhi \reg1,\reg2,%hi(\mask)
+ .endif
+.endm
+
+/*
+ * ORs reg2 with mask and places the result in reg1.
+ *
+ * It is safe to use the same register for reg1 & reg2.
+ */
+
+.macro ORI32 reg1,reg2,mask
+ .if \mask & 0xffff
+ .if \mask & 0xffff0000
+ orhi \reg1,\reg2,%hi(\mask)
+ ori \reg1,\reg2,%lo(\mask)
+ .else
+ ori \reg1,\reg2,%lo(\mask)
+ .endif
+ .else
+ orhi \reg1,\reg2,%hi(\mask)
+ .endif
+.endm
+
+/*
+ * XORs reg2 with mask and places the result in reg1.
+ *
+ * It is safe to use the same register for reg1 & reg2.
+ */
+
+.macro XORI32 reg1,reg2,mask
+ .if \mask & 0xffff
+ .if \mask & 0xffff0000
+ xorhi \reg1,\reg2,%hi(\mask)
+ xori \reg1,\reg1,%lo(\mask)
+ .else
+ xori \reg1,\reg2,%lo(\mask)
+ .endif
+ .else
+ xorhi \reg1,\reg2,%hi(\mask)
+ .endif
+.endm
+
+/*
+ * This is a support macro for BTBZ & BTBNZ. It checks
+ * the bit to make sure it is valid 32 value.
+ *
+ * It is safe to use the same register for reg1 & reg2.
+ */
+
+.macro BT reg1,reg2,bit
+.if \bit > 31
+ .err
+.else
+ .if \bit < 16
+ andi \reg1,\reg2,(1 << \bit)
+ .else
+ andhi \reg1,\reg2,(1 << (\bit - 16))
+ .endif
+.endif
+.endm
+
+/*
+ * Tests the bit in reg2 and branches to label if the
+ * bit is zero. The result of the bit test is stored in reg1.
+ *
+ * It is safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTBZ reg1,reg2,bit,label
+ BT \reg1,\reg2,\bit
+ beq \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bit in reg2 and branches to label if the
+ * bit is non-zero. The result of the bit test is stored in reg1.
+ *
+ * It is safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTBNZ reg1,reg2,bit,label
+ BT \reg1,\reg2,\bit
+ bne \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bit in reg2 and then compliments the bit in reg2.
+ * The result of the bit test is stored in reg1.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTC reg1,reg2,bit
+.if \bit > 31
+ .err
+.else
+ .if \bit < 16
+ andi \reg1,\reg2,(1 << \bit)
+ xori \reg2,\reg2,(1 << \bit)
+ .else
+ andhi \reg1,\reg2,(1 << (\bit - 16))
+ xorhi \reg2,\reg2,(1 << (\bit - 16))
+ .endif
+.endif
+.endm
+
+/*
+ * Tests the bit in reg2 and then sets the bit in reg2.
+ * The result of the bit test is stored in reg1.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTS reg1,reg2,bit
+.if \bit > 31
+ .err
+.else
+ .if \bit < 16
+ andi \reg1,\reg2,(1 << \bit)
+ ori \reg2,\reg2,(1 << \bit)
+ .else
+ andhi \reg1,\reg2,(1 << (\bit - 16))
+ orhi \reg2,\reg2,(1 << (\bit - 16))
+ .endif
+.endif
+.endm
+
+/*
+ * Tests the bit in reg2 and then resets the bit in reg2.
+ * The result of the bit test is stored in reg1.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTR reg1,reg2,bit
+.if \bit > 31
+ .err
+.else
+ .if \bit < 16
+ andi \reg1,\reg2,(1 << \bit)
+ andi \reg2,\reg2,%lo(~(1 << \bit))
+ .else
+ andhi \reg1,\reg2,(1 << (\bit - 16))
+ andhi \reg2,\reg2,%lo(~(1 << (\bit - 16)))
+ .endif
+.endif
+.endm
+
+/*
+ * Tests the bit in reg2 and then compliments the bit in reg2.
+ * The result of the bit test is stored in reg1. If the
+ * original bit was zero it branches to label.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTCBZ reg1,reg2,bit,label
+ BTC \reg1,\reg2,\bit
+ beq \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bit in reg2 and then compliments the bit in reg2.
+ * The result of the bit test is stored in reg1. If the
+ * original bit was non-zero it branches to label.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTCBNZ reg1,reg2,bit,label
+ BTC \reg1,\reg2,\bit
+ bne \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bit in reg2 and then sets the bit in reg2.
+ * The result of the bit test is stored in reg1. If the
+ * original bit was zero it branches to label.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTSBZ reg1,reg2,bit,label
+ BTS \reg1,\reg2,\bit
+ beq \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bit in reg2 and then sets the bit in reg2.
+ * The result of the bit test is stored in reg1. If the
+ * original bit was non-zero it branches to label.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTSBNZ reg1,reg2,bit,label
+ BTS \reg1,\reg2,\bit
+ bne \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bit in reg2 and then resets the bit in reg2.
+ * The result of the bit test is stored in reg1. If the
+ * original bit was zero it branches to label.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTRBZ reg1,reg2,bit,label
+ BTR \reg1,\reg2,\bit
+ bne \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bit in reg2 and then resets the bit in reg2.
+ * The result of the bit test is stored in reg1. If the
+ * original bit was non-zero it branches to label.
+ *
+ * It is NOT safe to use the same register for reg1 & reg2.
+ */
+
+.macro BTRBNZ reg1,reg2,bit,label
+ BTR \reg1,\reg2,\bit
+ bne \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bits in mask against reg2 stores the result in reg1.
+ * If the all the bits in the mask are zero it branches to label.
+ *
+ * It is safe to use the same register for reg1 & reg2.
+ */
+
+.macro TSTBZ reg1,reg2,mask,label
+ ANDI32 \reg1,\reg2,\mask
+ beq \reg1,r0,\label
+.endm
+
+/*
+ * Tests the bits in mask against reg2 stores the result in reg1.
+ * If the any of the bits in the mask are 1 it branches to label.
+ *
+ * It is safe to use the same register for reg1 & reg2.
+ */
+
+.macro TSTBNZ reg1,reg2,mask,label
+ ANDI32 \reg1,\reg2,\mask
+ bne \reg1,r0,\label
+.endm
+
+/*
+ * Pushes reg onto the stack.
+ */
+
+.macro PUSH reg
+ addi sp,sp,-4
+ stw \reg,0(sp)
+.endm
+
+/*
+ * Pops the top of the stack into reg.
+ */
+
+.macro POP reg
+ ldw \reg,0(sp)
+ addi sp,sp,4
+.endm
+
+/*
+ * Clears reg
+ */
+
+.macro CLR reg
+ mov \reg,r0
+.endm
+
+/*
+ * The preprocessor macro does not work for
+ * the nios2 compiler. Undefine ENTRY and define
+ * a real assembler macro.
+ */
+#undef ENTRY
+#define ENTRY(name) ASM_ENTRY name
+
+.macro ASM_ENTRY name
+.globl \name
+__ALIGN
+ \name:
+.endm
diff --git a/include/asm-nios2nommu/atomic.h b/include/asm-nios2nommu/atomic.h
new file mode 100644
index 0000000..fb627de
--- /dev/null
+++ b/include/asm-nios2nommu/atomic.h
@@ -0,0 +1,146 @@
+#ifndef __ASM_SH_ATOMIC_H
+#define __ASM_SH_ATOMIC_H
+
+/*
+ * Atomic operations that C can't guarantee us. Useful for
+ * resource counting etc..
+ *
+ */
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
+
+#define atomic_read(v) ((v)->counter)
+#define atomic_set(v,i) ((v)->counter = (i))
+
+#include <asm/system.h>
+
+/*
+ * To get proper branch prediction for the main line, we must branch
+ * forward to code at the end of this object's .text section, then
+ * branch back to restart the operation.
+ */
+
+static __inline__ void atomic_add(int i, atomic_t * v)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ *(long *)v += i;
+ local_irq_restore(flags);
+}
+
+static __inline__ void atomic_sub(int i, atomic_t *v)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ *(long *)v -= i;
+ local_irq_restore(flags);
+}
+
+static __inline__ int atomic_add_return(int i, atomic_t * v)
+{
+ unsigned long temp, flags;
+
+ local_irq_save(flags);
+ temp = *(long *)v;
+ temp += i;
+ *(long *)v = temp;
+ local_irq_restore(flags);
+
+ return temp;
+}
+
+#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
+
+static __inline__ int atomic_sub_return(int i, atomic_t * v)
+{
+ unsigned long temp, flags;
+
+ local_irq_save(flags);
+ temp = *(long *)v;
+ temp -= i;
+ *(long *)v = temp;
+ local_irq_restore(flags);
+
+ return temp;
+}
+
+#define atomic_dec_return(v) atomic_sub_return(1,(v))
+#define atomic_inc_return(v) atomic_add_return(1,(v))
+
+/*
+ * atomic_inc_and_test - increment and test
+ * @v: pointer of type atomic_t
+ *
+ * Atomically increments @v by 1
+ * and returns true if the result is zero, or false for all
+ * other cases.
+ */
+#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
+
+#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
+#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
+
+#define atomic_inc(v) atomic_add(1,(v))
+#define atomic_dec(v) atomic_sub(1,(v))
+
+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+ int ret;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ ret = v->counter;
+ if (likely(ret == old))
+ v->counter = new;
+ local_irq_restore(flags);
+
+ return ret;
+}
+
+#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+ int ret;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ ret = v->counter;
+ if (ret != u)
+ v->counter += a;
+ local_irq_restore(flags);
+
+ return ret != u;
+}
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
+static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ *(long *)v &= ~mask;
+ local_irq_restore(flags);
+}
+
+static __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ *(long *)v |= mask;
+ local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on SH */
+#define smp_mb__before_atomic_dec() barrier()
+#define smp_mb__after_atomic_dec() barrier()
+#define smp_mb__before_atomic_inc() barrier()
+#define smp_mb__after_atomic_inc() barrier()
+
+#include <asm-generic/atomic.h>
+#endif /* __ASM_SH_ATOMIC_H */
diff --git a/include/asm-nios2nommu/auxvec.h b/include/asm-nios2nommu/auxvec.h
new file mode 100644
index 0000000..fc21e4d
--- /dev/null
+++ b/include/asm-nios2nommu/auxvec.h
@@ -0,0 +1,4 @@
+#ifndef __ASM_SH_AUXVEC_H
+#define __ASM_SH_AUXVEC_H
+
+#endif /* __ASM_SH_AUXVEC_H */
diff --git a/include/asm-nios2nommu/bitops.h b/include/asm-nios2nommu/bitops.h
new file mode 100644
index 0000000..7bf1862
--- /dev/null
+++ b/include/asm-nios2nommu/bitops.h
@@ -0,0 +1,11 @@
+#ifndef __ASM_NIOS2NOMMU_BITOPS_H
+#define __ASM_NIOS2NOMMU_BITOPS_H
+
+#ifdef __KERNEL__
+#include <asm/system.h>
+#include <asm-generic/bitops.h>
+#define smp_mb__before_clear_bit() barrier()
+#define smp_mb__after_clear_bit() barrier()
+#endif /* __KERNEL__ */
+
+#endif /* __ASM_NIOS2NOMMU_BITOPS_H */
diff --git a/include/asm-nios2nommu/bootinfo.h b/include/asm-nios2nommu/bootinfo.h
new file mode 100644
index 0000000..ee8c39e
--- /dev/null
+++ b/include/asm-nios2nommu/bootinfo.h
@@ -0,0 +1,2 @@
+
+/* Nothing for nios2nommu */
diff --git a/include/asm-nios2nommu/bug.h b/include/asm-nios2nommu/bug.h
new file mode 100644
index 0000000..d99ab08
--- /dev/null
+++ b/include/asm-nios2nommu/bug.h
@@ -0,0 +1,4 @@
+#ifndef _MNIOS2NOMMU_BUG_H
+#define _MNIOS2NOMMU_BUG_H
+#include <asm-generic/bug.h>
+#endif
diff --git a/include/asm-nios2nommu/bugs.h b/include/asm-nios2nommu/bugs.h
new file mode 100644
index 0000000..a0753eb
--- /dev/null
+++ b/include/asm-nios2nommu/bugs.h
@@ -0,0 +1,40 @@
+#ifndef __ASM_NIOS_BUGS_H
+#define __ASM_NIOS_BUGS_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/bugs.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 1994 Linus Torvalds
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+/*
+ * This is included by init/main.c to check for architecture-dependent bugs.
+ *
+ * Needs:
+ * void check_bugs(void);
+ */
+
+static void check_bugs(void)
+{
+}
+
+#endif
diff --git a/include/asm-nios2nommu/byteorder.h b/include/asm-nios2nommu/byteorder.h
new file mode 100644
index 0000000..960b6d3
--- /dev/null
+++ b/include/asm-nios2nommu/byteorder.h
@@ -0,0 +1,38 @@
+#ifndef __ASM_NIOS_BYTEORDER_H
+#define __ASM_NIOS_BYTEORDER_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/byteorder.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/types.h>
+
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
+# define __BYTEORDER_HAS_U64__
+# define __SWAB_64_THRU_32__
+#endif
+
+#include <linux/byteorder/little_endian.h>
+
+#endif
+
diff --git a/include/asm-nios2nommu/cache.h b/include/asm-nios2nommu/cache.h
new file mode 100644
index 0000000..82bbd14
--- /dev/null
+++ b/include/asm-nios2nommu/cache.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef __ARCH_NIOS2NOMMU_CACHE_H
+#define __ARCH_NIOS2NOMMU_CACHE_H
+
+#include <asm/nios.h>
+
+/* bytes per L1 cache line */
+#define L1_CACHE_BYTES nasys_icache_line_size /* 32, this need to be at least 1 */
+#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
+#define L1_CACHE_SHIFT 5
+
+
+#define __cacheline_aligned
+#define ____cacheline_aligned
+
+#endif
diff --git a/include/asm-nios2nommu/cachectl.h b/include/asm-nios2nommu/cachectl.h
new file mode 100644
index 0000000..39d7d9d
--- /dev/null
+++ b/include/asm-nios2nommu/cachectl.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2NOMMU_CACHECTL_H
+#define _NIOS2NOMMU_CACHECTL_H
+
+/* Definitions for the cacheflush system call. */
+
+#define FLUSH_SCOPE_LINE 1 /* Flush a cache line */
+#define FLUSH_SCOPE_PAGE 2 /* Flush a page */
+#define FLUSH_SCOPE_ALL 3 /* Flush the whole cache -- superuser only */
+
+#define FLUSH_CACHE_DATA 1 /* Writeback and flush data cache */
+#define FLUSH_CACHE_INSN 2 /* Flush instruction cache */
+#define FLUSH_CACHE_BOTH 3 /* Flush both caches */
+
+#endif /* _NIOS2NOMMU_CACHECTL_H */
diff --git a/include/asm-nios2nommu/cacheflush.h b/include/asm-nios2nommu/cacheflush.h
new file mode 100644
index 0000000..4543201
--- /dev/null
+++ b/include/asm-nios2nommu/cacheflush.h
@@ -0,0 +1,59 @@
+#ifndef _NIOS2NOMMU_CACHEFLUSH_H
+#define _NIOS2NOMMU_CACHEFLUSH_H
+
+/*
+ * Ported from m68knommu.
+ *
+ * (C) Copyright 2003, Microtronix Datacom Ltd.
+ * (C) Copyright 2000-2002, Greg Ungerer <gerg@snapgear.com>
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#include <linux/mm.h>
+
+extern void cache_push (unsigned long vaddr, int len);
+extern void dcache_push (unsigned long vaddr, int len);
+extern void icache_push (unsigned long vaddr, int len);
+extern void cache_push_all (void);
+extern void cache_clear (unsigned long paddr, int len);
+
+#define flush_cache_all() __flush_cache_all()
+#define flush_cache_mm(mm) do { } while (0)
+#define flush_cache_range(vma, start, end) cache_push(start, end - start)
+#define flush_cache_page(vma, vmaddr) do { } while (0)
+#define flush_dcache_range(start,end) dcache_push(start, end - start)
+#define flush_dcache_page(page) do { } while (0)
+#define flush_dcache_mmap_lock(mapping) do { } while (0)
+#define flush_dcache_mmap_unlock(mapping) do { } while (0)
+#define flush_icache_range(start,end) cache_push(start, end - start)
+#define flush_icache_page(vma,pg) do { } while (0)
+#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
+
+#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
+ memcpy(dst, src, len)
+#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
+ memcpy(dst, src, len)
+
+
+extern inline void __flush_cache_all(void)
+{
+ cache_push_all();
+}
+
+#endif /* _NIOS2NOMMU_CACHEFLUSH_H */
diff --git a/include/asm-nios2nommu/checksum.h b/include/asm-nios2nommu/checksum.h
new file mode 100644
index 0000000..1f6879e
--- /dev/null
+++ b/include/asm-nios2nommu/checksum.h
@@ -0,0 +1,320 @@
+#ifndef __NIOS2_CHECKSUM_H
+#define __NIOS2_CHECKSUM_H
+
+/* checksum.h: IP/UDP/TCP checksum routines on the NIOS.
+ *
+ * Copyright(C) 1995 Linus Torvalds
+ * Copyright(C) 1995 Miguel de Icaza
+ * Copyright(C) 1996 David S. Miller
+ * Copyright(C) 2001 Ken Hill
+ * Copyright(C) 2004 Microtronix Datacom Ltd.
+ *
+ * derived from:
+ * Alpha checksum c-code
+ * ix86 inline assembly
+ * Spar nommu
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+/*
+ * computes the checksum of the TCP/UDP pseudo-header
+ * returns a 16-bit checksum, already complemented
+ */
+
+extern inline unsigned short csum_tcpudp_magic(unsigned long saddr,
+ unsigned long daddr,
+ unsigned short len,
+ unsigned short proto,
+ unsigned int sum)
+{
+ barrier();
+ __asm__ __volatile__(
+" add %0, %3, %0\n"
+" bgeu %0, %3, 1f\n"
+" addi %0, %0, 1\n"
+"1: add %0, %4, %0\n"
+" bgeu %0, %4, 1f\n"
+" addi %0, %0, 1\n"
+"1: add %0, %5, %0\n"
+" bgeu %0, %5, 1f\n"
+" addi %0, %0, 1\n"
+"1:\n"
+/*
+ We need the carry from the addition of 16-bit
+ significant addition, so we zap out the low bits
+ in one half, zap out the high bits in another,
+ shift them both up to the top 16-bits of a word
+ and do the carry producing addition, finally
+ shift the result back down to the low 16-bits.
+
+ Actually, we can further optimize away two shifts
+ because we know the low bits of the original
+ value will be added to zero-only bits so cannot
+ affect the addition result nor the final carry
+ bit.
+*/
+" slli %1,%0, 16\n" /* Need a copy to fold with */
+ /* Bring the LOW 16 bits up */
+" add %0, %1, %0\n" /* add and set carry, neat eh? */
+" cmpltu r15, %0, %1\n" /* get remaining carry bit */
+" srli %0, %0, 16\n" /* shift back down the result */
+" add %0, %0, r15\n"
+" nor %0, %0, %0\n" /* negate */
+ : "=&r" (sum), "=&r" (saddr)
+ : "0" (sum), "1" (saddr), "r" (ntohl(len+proto)), "r" (daddr)
+ : "r15");
+ return ((unsigned short) sum);
+ barrier();
+}
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+
+ extern inline unsigned short from32to16(unsigned long x)
+ {
+ barrier();
+ __asm__ __volatile__(
+ "add %0, %1, %0\n"
+ "cmpltu r15, %0, %1\n"
+ "srli %0, %0, 16\n"
+ "add %0, %0, r15\n"
+ : "=r" (x)
+ : "r" (x << 16), "0" (x)
+ : "r15");
+ return x;
+ barrier();
+ }
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+
+extern inline unsigned long do_csum(const unsigned char * buff, int len)
+{
+ int odd, count;
+ unsigned long result = 0;
+
+ barrier();
+ if (len <= 0)
+ goto out;
+ odd = 1 & (unsigned long) buff;
+ if (odd) {
+////result = *buff; // dgt: Big endian
+ result = *buff << 8; // dgt: Little endian
+
+ len--;
+ buff++;
+ }
+ count = len >> 1; /* nr of 16-bit words.. */
+ if (count) {
+ if (2 & (unsigned long) buff) {
+ result += *(unsigned short *) buff;
+ count--;
+ len -= 2;
+ buff += 2;
+ }
+ count >>= 1; /* nr of 32-bit words.. */
+ if (count) {
+ unsigned long carry = 0;
+ do {
+ unsigned long w = *(unsigned long *) buff;
+ count--;
+ buff += 4;
+ result += carry;
+ result += w;
+ carry = (w > result);
+ } while (count);
+ result += carry;
+ result = (result & 0xffff) + (result >> 16);
+ }
+ if (len & 2) {
+ result += *(unsigned short *) buff;
+ buff += 2;
+ }
+ }
+ if (len & 1)
+ result += *buff; /* This is little machine, byte is right */
+ result = from32to16(result);
+ if (odd)
+ result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
+out:
+ return result;
+ barrier();
+ }
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+
+/* ihl is always 5 or greater, almost always is 5, iph is always word
+ * aligned but can fail to be dword aligned very often.
+ */
+
+ extern inline unsigned short ip_fast_csum(const unsigned char *iph, unsigned int ihl)
+ {
+ unsigned int sum;
+
+ barrier();
+ __asm__ __volatile__(
+" andi r8, %1, 2\n" /* Remember original alignment */
+" ldw %0, (%1)\n" /* 16 or 32 bit boundary */
+" beq r8, r0, 1f\n" /* Aligned on 32 bit boundary, go */
+" srli %0, %0, 16\n" /* Get correct 16 bits */
+" addi %2, %2, -1\n" /* Take off for 4 bytes, pickup last 2 at end */
+" addi %1, %1, 2\n" /* Adjust pointer to 32 bit boundary */
+" br 2f\n"
+"1:\n"
+" addi %2, %2, -1\n"
+" addi %1, %1, 4\n" /* Bump ptr a long word */
+"2:\n"
+" ldw r9, (%1)\n"
+"1:\n"
+" add %0, r9, %0\n"
+" bgeu %0, r9, 2f\n"
+" addi %0, %0, 1\n"
+"2:\n"
+" addi %1, %1, 4\n"
+" addi %2, %2, -1\n"
+" ldw r9, (%1)\n"
+" bne %2, r0, 1b\n"
+" beq r8, r0, 1f\n" /* 32 bit boundary time to leave */
+" srli r9, r9, 16\n" /* 16 bit boundary, get correct 16 bits */
+" add %0, r9, %0\n"
+" bgeu %0, r9, 1f\n"
+" addi %0, %0, 1\n"
+"1:\n"
+" slli %2, %0, 16\n"
+" add %0, %2, %0\n"
+" cmpltu r8, %0, %2\n"
+" srli %0, %0, 16\n"
+" add %0, %0, r8\n"
+" nor %0, %0, %0\n"
+ : "=&r" (sum), "=&r" (iph), "=&r" (ihl)
+ : "1" (iph), "2" (ihl)
+ : "r8", "r9");
+ return sum;
+ barrier();
+ }
+
+/*these 2 functions are now in checksum.c */
+unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
+unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+/*
+ * the same as csum_partial_copy, but copies from user space.
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+extern inline unsigned int
+csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *csum_err)
+{
+ barrier();
+ if (csum_err) *csum_err = 0;
+ memcpy(dst, src, len);
+ return csum_partial(dst, len, sum);
+ barrier();
+}
+
+#define csum_partial_copy_nocheck(src, dst, len, sum) \
+ csum_partial_copy ((src), (dst), (len), (sum))
+
+
+/*
+ * this routine is used for miscellaneous IP-like checksums, mainly
+ * in icmp.c
+ */
+
+extern inline unsigned short ip_compute_csum(unsigned char * buff, int len)
+{
+ barrier();
+ return ~from32to16(do_csum(buff,len));
+ barrier();
+}
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+
+#define csum_partial_copy_fromuser(s, d, l, w) \
+ csum_partial_copy((char *) (s), (d), (l), (w))
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+
+/*
+ * Fold a partial checksum without adding pseudo headers
+ */
+extern __inline__ unsigned int csum_fold(unsigned int sum)
+{
+ barrier();
+ __asm__ __volatile__(
+ "add %0, %1, %0\n"
+ "cmpltu r8, %0, %1\n"
+ "srli %0, %0, 16\n"
+ "add %0, %0, r8\n"
+ "nor %0, %0, %0\n"
+ : "=r" (sum)
+ : "r" (sum << 16), "0" (sum)
+ : "r8");
+ return sum;
+ barrier();
+}
+
+
+/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+
+extern __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
+ unsigned long daddr,
+ unsigned short len,
+ unsigned short proto,
+ unsigned int sum)
+{
+ barrier();
+ __asm__ __volatile__(
+ "add %0, %1, %0\n"
+ "cmpltu r8, %0, %1\n"
+ "add %0, %0, r8\n" /* add carry */
+ "add %0, %2, %0\n"
+ "cmpltu r8, %0, %2\n"
+ "add %0, %0, r8\n" /* add carry */
+ "add %0, %3, %0\n"
+ "cmpltu r8, %0, %3\n"
+ "add %0, %0, r8\n" /* add carry */
+ : "=r" (sum), "=r" (saddr)
+ : "r" (daddr), "r" ( (ntohs(len)<<16) + (proto*256) ),
+ "0" (sum),
+ "1" (saddr)
+ : "r8");
+
+ return sum;
+ barrier();
+}
+
+
+#endif /* (__NIOS2_CHECKSUM_H) */
diff --git a/include/asm-nios2nommu/cprefix.h b/include/asm-nios2nommu/cprefix.h
new file mode 100644
index 0000000..4983211
--- /dev/null
+++ b/include/asm-nios2nommu/cprefix.h
@@ -0,0 +1,38 @@
+/* cprefix.h: This file is included by assembly source which needs
+ * to know what the c-label prefixes are. The newer versions
+ * of cpp that come with gcc predefine such things to help
+ * us out. The reason this stuff is needed is to make
+ * solaris compiles of the kernel work.
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef __NIOS2_CPREFIX_H
+#define __NIOS2_CPREFIX_H
+
+#define C_LABEL_PREFIX
+
+#define CONCAT(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a##b
+
+#define C_LABEL(name) CONCAT(C_LABEL_PREFIX, name)
+
+#endif /* !(__NIOS2_CPREFIX_H) */
diff --git a/include/asm-nios2nommu/cpumask.h b/include/asm-nios2nommu/cpumask.h
new file mode 100644
index 0000000..86fb365
--- /dev/null
+++ b/include/asm-nios2nommu/cpumask.h
@@ -0,0 +1,28 @@
+/*
+ * All rights reserved.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _ASM_NIOS2NOMMU_CPUMASK_H
+#define _ASM_NIOS2NOMMU_CPUMASK_H
+
+#include <asm-generic/cpumask.h>
+
+#endif /* _ASM_NIOS2NOMMU_CPUMASK_H */
diff --git a/include/asm-nios2nommu/cputime.h b/include/asm-nios2nommu/cputime.h
new file mode 100644
index 0000000..370e4f2
--- /dev/null
+++ b/include/asm-nios2nommu/cputime.h
@@ -0,0 +1,31 @@
+/*
+ * cputime.h
+ * (C) Copyright 2004, Microtronix Datacom Ltd.
+ *
+ * Taken from m68knommu
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2NOMMU_CPUTIME_H
+#define __NIOS2NOMMU_CPUTIME_H
+
+#include <asm-generic/cputime.h>
+
+#endif /* __NIOS@NOMMU_CPUTIME_H */
diff --git a/include/asm-nios2nommu/current.h b/include/asm-nios2nommu/current.h
new file mode 100644
index 0000000..5ac1dbc
--- /dev/null
+++ b/include/asm-nios2nommu/current.h
@@ -0,0 +1,39 @@
+#ifndef _NIOS2NOMMU_CURRENT_H
+#define _NIOS2NOMMU_CURRENT_H
+/*
+ * current.h
+ * (C) Copyright 2000, Lineo, David McCullough <davidm@uclinux.org>
+ * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
+ * (C) Copyright 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/thread_info.h>
+
+struct task_struct;
+
+static inline struct task_struct *get_current(void)
+{
+ return(current_thread_info()->task);
+}
+
+#define current get_current()
+
+#endif /* _NIOS2NOMMU_CURRENT_H */
diff --git a/include/asm-nios2nommu/delay.h b/include/asm-nios2nommu/delay.h
new file mode 100644
index 0000000..da0a184
--- /dev/null
+++ b/include/asm-nios2nommu/delay.h
@@ -0,0 +1,96 @@
+#ifndef _NIOS_DELAY_H
+#define _NIOS_DELAY_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/delay.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/param.h>
+
+extern __inline__ void __delay(unsigned long loops)
+{
+ int dummy;
+
+ __asm__ __volatile__(
+ "1: \n\t"
+ " beq %0,zero,2f\n\t"
+ " addi %0, %0, -1\n\t"
+ " br 1b\n\t"
+ "2: \n\t"
+
+ : "=r" (dummy) /* Need output for optimizer */
+
+ : "0" (loops) /* %0 Input */
+ );
+}
+
+/*
+ * Note that 19 * 226 == 4294 ==~ 2^32 / 10^6, so
+ * loops = (4294 * usecs * loops_per_jiffy * HZ) / 2^32.
+ *
+ * The mul instruction gives us loops = (a * b) / 2^32.
+ * We choose a = usecs * 19 * HZ and b = loops_per_jiffy * 226
+ * because this lets us support a wide range of HZ and
+ * loops_per_jiffy values without either a or b overflowing 2^32.
+ * Thus we need usecs * HZ <= (2^32 - 1) / 19 = 226050910 and
+ * loops_per_jiffy <= (2^32 - 1) / 226 = 19004280
+ * (which corresponds to ~3800 bogomips at HZ = 100).
+ * -- paulus
+ */
+#define __MAX_UDELAY (226050910UL/HZ) /* maximum udelay argument */
+#define __MAX_NDELAY (4294967295UL/HZ) /* maximum ndelay argument */
+
+extern unsigned long loops_per_jiffy;
+
+extern __inline__ void __udelay(unsigned int x)
+{
+ unsigned int loops;
+
+ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
+ "r" (x), "r" (loops_per_jiffy * 226));
+ __delay(loops);
+}
+
+extern __inline__ void __ndelay(unsigned int x)
+{
+ unsigned int loops;
+
+ __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
+ "r" (x), "r" (loops_per_jiffy * 5));
+ __delay(loops);
+}
+
+extern void __bad_udelay(void); /* deliberately undefined */
+extern void __bad_ndelay(void); /* deliberately undefined */
+
+#define udelay(n) (__builtin_constant_p(n)? \
+ ((n) > __MAX_UDELAY? __bad_udelay(): __udelay((n) * (19 * HZ))) : \
+ __udelay((n) * (19 * HZ)))
+
+#define ndelay(n) (__builtin_constant_p(n)? \
+ ((n) > __MAX_NDELAY? __bad_ndelay(): __ndelay((n) * HZ)) : \
+ __ndelay((n) * HZ))
+
+#define muldiv(a, b, c) (((a)*(b))/(c))
+
+#endif /* defined(_NIOS_DELAY_H) */
diff --git a/include/asm-nios2nommu/device.h b/include/asm-nios2nommu/device.h
new file mode 100644
index 0000000..d8f9872
--- /dev/null
+++ b/include/asm-nios2nommu/device.h
@@ -0,0 +1,7 @@
+/*
+ * Arch specific extensions to struct device
+ *
+ * This file is released under the GPLv2
+ */
+#include <asm-generic/device.h>
+
diff --git a/include/asm-nios2nommu/div64.h b/include/asm-nios2nommu/div64.h
new file mode 100644
index 0000000..68d72e4
--- /dev/null
+++ b/include/asm-nios2nommu/div64.h
@@ -0,0 +1,31 @@
+#ifndef __ASMNIOS_DIV64_H
+#define __ASMNIOS_DIV64_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/div64.h
+ *
+ * Derived from m68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm-generic/div64.h>
+
+#endif
+
diff --git a/include/asm-nios2nommu/dma-mapping.h b/include/asm-nios2nommu/dma-mapping.h
new file mode 100644
index 0000000..6289370
--- /dev/null
+++ b/include/asm-nios2nommu/dma-mapping.h
@@ -0,0 +1,79 @@
+#ifndef _ASM_DMA_MAPPING_H
+#define _ASM_DMA_MAPPING_H
+
+#include <asm/scatterlist.h>
+#include <asm/cache.h>
+
+void *dma_alloc_noncoherent(struct device *dev, size_t size,
+ dma_addr_t *dma_handle, gfp_t flag);
+
+void dma_free_noncoherent(struct device *dev, size_t size,
+ void *vaddr, dma_addr_t dma_handle);
+
+void *dma_alloc_coherent(struct device *dev, size_t size,
+ dma_addr_t *dma_handle, gfp_t flag);
+
+void dma_free_coherent(struct device *dev, size_t size,
+ void *vaddr, dma_addr_t dma_handle);
+
+extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
+ enum dma_data_direction direction);
+extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
+ size_t size, enum dma_data_direction direction);
+extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
+ unsigned long offset, size_t size, enum dma_data_direction direction);
+extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
+ size_t size, enum dma_data_direction direction);
+extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+ int nhwentries, enum dma_data_direction direction);
+extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+ size_t size, enum dma_data_direction direction);
+extern void dma_sync_single_for_device(struct device *dev,
+ dma_addr_t dma_handle, size_t size, enum dma_data_direction direction);
+extern void dma_sync_single_range_for_cpu(struct device *dev,
+ dma_addr_t dma_handle, unsigned long offset, size_t size,
+ enum dma_data_direction direction);
+extern void dma_sync_single_range_for_device(struct device *dev,
+ dma_addr_t dma_handle, unsigned long offset, size_t size,
+ enum dma_data_direction direction);
+extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
+ int nelems, enum dma_data_direction direction);
+extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
+ int nelems, enum dma_data_direction direction);
+extern int dma_mapping_error(dma_addr_t dma_addr);
+extern int dma_supported(struct device *dev, u64 mask);
+
+static inline int
+dma_set_mask(struct device *dev, u64 mask)
+{
+ if(!dev->dma_mask || !dma_supported(dev, mask))
+ return -EIO;
+
+ *dev->dma_mask = mask;
+
+ return 0;
+}
+
+static inline int
+dma_get_cache_alignment(void)
+{
+ /* XXX Largest on any MIPS */
+ return 128;
+}
+
+extern int dma_is_consistent(dma_addr_t dma_addr);
+
+extern void dma_cache_sync(void *vaddr, size_t size,
+ enum dma_data_direction direction);
+
+// #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
+//
+// extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+// dma_addr_t device_addr, size_t size, int flags);
+// extern void dma_release_declared_memory(struct device *dev);
+// extern void * dma_mark_declared_memory_occupied(struct device *dev,
+// dma_addr_t device_addr, size_t size);
+
+#endif /* _ASM_DMA_MAPPING_H */
diff --git a/include/asm-nios2nommu/dma.h b/include/asm-nios2nommu/dma.h
new file mode 100644
index 0000000..ea098d5
--- /dev/null
+++ b/include/asm-nios2nommu/dma.h
@@ -0,0 +1,63 @@
+/* $Id: dma.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
+ *
+ * Copyright 2004 (C) Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _ASM_NIOS2_DMA_H
+#define _ASM_NIOS2_DMA_H
+
+#include <linux/kernel.h>
+#include <asm/asm-offsets.h>
+
+#define MAX_DMA_ADDRESS (LINUX_SDRAM_END)
+
+int request_dma(unsigned int, const char *);
+void free_dma(unsigned int);
+void enable_dma(unsigned int dmanr);
+void disable_dma(unsigned int dmanr);
+void set_dma_count(unsigned int dmanr, unsigned int count);
+int get_dma_residue(unsigned int dmanr);
+void nios2_set_dma_data_width(unsigned int dmanr, unsigned int width);
+
+void nios2_set_dma_handler(unsigned int dmanr, int (*handler)(void*, int), void* user);
+int nios2_request_dma(const char *);
+
+void nios2_set_dma_mode(unsigned int dmanr, unsigned int mode);
+void nios2_set_dma_rcon(unsigned int dmanr, unsigned int set);
+void nios2_set_dma_wcon(unsigned int dmanr, unsigned int set);
+void nios2_set_dma_raddr(unsigned int dmanr, unsigned int a);
+void nios2_set_dma_waddr(unsigned int dmanr, unsigned int a);
+
+static inline unsigned long claim_dma_lock(void)
+{
+}
+
+static inline void release_dma_lock(unsigned long flags)
+{
+}
+
+#ifdef CONFIG_PCI
+extern int isa_dma_bridge_buggy;
+#else
+#define isa_dma_bridge_buggy (0)
+#endif
+
+#endif /* !(_ASM_NIOS2_DMA_H) */
diff --git a/include/asm-nios2nommu/elf.h b/include/asm-nios2nommu/elf.h
new file mode 100644
index 0000000..94b2ac0
--- /dev/null
+++ b/include/asm-nios2nommu/elf.h
@@ -0,0 +1,140 @@
+#ifndef __NIOS2_ELF_H
+#define __NIOS2_ELF_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/elf.h
+ *
+ * Nio2 ELF relocation types
+ *
+ * Derived from M68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Jan/20/2004 dgt NiosII
+ * Mar/18/2004 xwt NiosII relocation types added
+ *
+ ---------------------------------------------------------------------*/
+
+#include <asm/ptrace.h>
+#include <asm/user.h>
+
+#define R_NIOS2_NONE 0
+#define R_NIOS2_S16 1
+#define R_NIOS2_U16 2
+#define R_NIOS2_PCREL16 3
+#define R_NIOS2_CALL26 4
+#define R_NIOS2_IMM5 5
+#define R_NIOS2_CACHE_OPX 6
+#define R_NIOS2_IMM6 7
+#define R_NIOS2_IMM8 8
+#define R_NIOS2_HI16 9
+#define R_NIOS2_LO16 10
+#define R_NIOS2_HIADJ16 11
+#define R_NIOS2_BFD_RELOC_32 12
+#define R_NIOS2_BFD_RELOC_16 13
+#define R_NIOS2_BFD_RELOC_8 14
+#define R_NIOS2_GPREL 15
+#define R_NIOS2_GNU_VTINHERIT 16
+#define R_NIOS2_GNU_VTENTRY 17
+#define R_NIOS2_UJMP 18
+#define R_NIOS2_CJMP 19
+#define R_NIOS2_CALLR 20
+#define R_NIOS2_ALIGN 21
+/* Keep this the last entry. */
+#define R_NIOS2_NUM 22
+
+typedef unsigned long elf_greg_t;
+
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef unsigned long elf_fpregset_t;
+
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+#define elf_check_arch(x) \
+ ((x)->e_machine == EM_ALTERA_NIOS2)
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS ELFCLASS32
+#define ELF_DATA ELFDATA2LSB
+#define ELF_ARCH EM_ALTERA_NIOS2
+
+#define ELF_PLAT_INIT(_r, load_addr) _r->a1 = 0
+
+#define USE_ELF_CORE_DUMP
+#define ELF_EXEC_PAGESIZE 4096
+
+/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
+ use of this is to invoke "./ld.so someprog" to test out a new version of
+ the loader. We need to make sure that it is out of the way of the program
+ that it will "exec", and that there is sufficient room for the brk. */
+
+#define ELF_ET_DYN_BASE 0xD0000000UL
+
+/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
+ now struct_user_regs, they are different) */
+
+#define ELF_CORE_COPY_REGS(pr_reg, regs) \
+ /* Bleech. */ \
+ pr_reg[0] = regs->r1; \
+ pr_reg[1] = regs->r2; \
+ pr_reg[2] = regs->r3; \
+ pr_reg[3] = regs->r4; \
+ pr_reg[4] = regs->r5; \
+ pr_reg[5] = regs->r6; \
+ pr_reg[6] = regs->r7; \
+ pr_reg[7] = regs->r8; \
+ pr_reg[8] = regs->r9; \
+ pr_reg[9] = regs->r10; \
+ pr_reg[10] = regs->r11; \
+ pr_reg[11] = regs->r12; \
+ pr_reg[12] = regs->r13; \
+ pr_reg[13] = regs->r14; \
+ pr_reg[14] = regs->r15; \
+ pr_reg[23] = regs->sp; \
+ pr_reg[26] = regs->estatus; \
+ { \
+ struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \
+ pr_reg[15] = sw->r16; \
+ pr_reg[16] = sw->r17; \
+ pr_reg[17] = sw->r18; \
+ pr_reg[18] = sw->r19; \
+ pr_reg[19] = sw->r20; \
+ pr_reg[20] = sw->r21; \
+ pr_reg[21] = sw->r22; \
+ pr_reg[22] = sw->r23; \
+ pr_reg[24] = sw->fp; \
+ pr_reg[25] = sw->gp; \
+ }
+
+/* This yields a mask that user programs can use to figure out what
+ instruction set this cpu supports. */
+
+#define ELF_HWCAP (0)
+
+/* This yields a string that ld.so will use to load implementation
+ specific libraries for optimization. This is more specific in
+ intent than poking at uname or /proc/cpuinfo. */
+
+#define ELF_PLATFORM (NULL)
+
+#ifdef __KERNEL__
+#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
+#endif
+
+#endif
diff --git a/include/asm-nios2nommu/emergency-restart.h b/include/asm-nios2nommu/emergency-restart.h
new file mode 100644
index 0000000..108d8c4
--- /dev/null
+++ b/include/asm-nios2nommu/emergency-restart.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_EMERGENCY_RESTART_H
+#define _ASM_EMERGENCY_RESTART_H
+
+#include <asm-generic/emergency-restart.h>
+
+#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/include/asm-nios2nommu/entry.h b/include/asm-nios2nommu/entry.h
new file mode 100644
index 0000000..4b1773f
--- /dev/null
+++ b/include/asm-nios2nommu/entry.h
@@ -0,0 +1,187 @@
+/*
+ * Hacked from m68knommu port.
+ *
+ * Copyright(C) 2004 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2NOMMU_ENTRY_H
+#define __NIOS2NOMMU_ENTRY_H
+
+#ifdef __ASSEMBLY__
+
+#include <asm/setup.h>
+#include <asm/page.h>
+#include <asm/asm-offsets.h>
+
+/*
+ * Stack layout in 'ret_from_exception':
+ *
+ * This allows access to the syscall arguments in registers r4-r8
+ *
+ * 0(sp) - r8
+ * 4(sp) - r9
+ * 8(sp) - r10
+ * C(sp) - r11
+ * 10(sp) - r12
+ * 14(sp) - r13
+ * 18(sp) - r14
+ * 1C(sp) - r15
+ * 20(sp) - r1
+ * 24(sp) - r2
+ * 28(sp) - r3
+ * 2C(sp) - r4
+ * 30(sp) - r5
+ * 34(sp) - r6
+ * 38(sp) - r7
+ * 3C(sp) - orig_r2
+ * 40(sp) - ra
+ * 44(sp) - fp
+ * 48(sp) - sp
+ * 4C(sp) - gp
+ * 50(sp) - estatus
+ * 54(sp) - status_extension
+ * 58(sp) - ea
+ *
+ */
+
+/* process bits for task_struct.flags */
+PF_TRACESYS_OFF = 3
+PF_TRACESYS_BIT = 5
+PF_PTRACED_OFF = 3
+PF_PTRACED_BIT = 4
+PF_DTRACE_OFF = 1
+PF_DTRACE_BIT = 5
+
+LENOSYS = 38
+
+/*
+ * This defines the normal kernel pt-regs layout.
+ *
+ */
+
+/*
+ * Standard Nios2 interrupt entry and exit macros.
+ * Must be called with interrupts disabled.
+ */
+.macro SAVE_ALL
+ movia r24,status_extension // Read status extension
+ ldw r24,0(r24)
+ andi r24,r24,PS_S_ASM
+ bne r24,r0,1f // In supervisor mode, already on kernel stack
+ movia r24,_current_thread // Switch to current kernel stack
+ ldw r24,0(r24) // using the thread_info
+ addi r24,r24,THREAD_SIZE_ASM-PT_REGS_SIZE
+ stw sp,PT_SP(r24) // Save user stack before changing
+ mov sp,r24
+ br 2f
+
+1: mov r24,sp
+ addi sp,sp,-PT_REGS_SIZE // Backup the kernel stack pointer
+ stw r24,PT_SP(sp)
+2: stw r1,PT_R1(sp)
+ stw r2,PT_R2(sp)
+ stw r3,PT_R3(sp)
+ stw r4,PT_R4(sp)
+ stw r5,PT_R5(sp)
+ stw r6,PT_R6(sp)
+ stw r7,PT_R7(sp)
+ stw r8,PT_R8(sp)
+ stw r9,PT_R9(sp)
+ stw r10,PT_R10(sp)
+ stw r11,PT_R11(sp)
+ stw r12,PT_R12(sp)
+ stw r13,PT_R13(sp)
+ stw r14,PT_R14(sp)
+ stw r15,PT_R15(sp)
+ stw r2,PT_ORIG_R2(sp)
+ stw ra,PT_RA(sp)
+ stw fp,PT_FP(sp)
+ stw gp,PT_GP(sp)
+ rdctl r24,estatus
+ stw r24,PT_ESTATUS(sp)
+ movia r24,status_extension // Read status extension
+ ldw r1,0(r24)
+ stw r1,PT_STATUS_EXTENSION(sp) // Store user/supervisor status
+ ORI32 r1,r1,PS_S_ASM // Set supervisor mode
+ stw r1,0(r24)
+ stw ea,PT_EA(sp)
+.endm
+
+.macro RESTORE_ALL
+ ldw r1,PT_STATUS_EXTENSION(sp) // Restore user/supervisor status
+ movia r24,status_extension
+ stw r1,0(r24)
+ ldw r1,PT_R1(sp) // Restore registers
+ ldw r2,PT_R2(sp)
+ ldw r3,PT_R3(sp)
+ ldw r4,PT_R4(sp)
+ ldw r5,PT_R5(sp)
+ ldw r6,PT_R6(sp)
+ ldw r7,PT_R7(sp)
+ ldw r8,PT_R8(sp)
+ ldw r9,PT_R9(sp)
+ ldw r10,PT_R10(sp)
+ ldw r11,PT_R11(sp)
+ ldw r12,PT_R12(sp)
+ ldw r13,PT_R13(sp)
+ ldw r14,PT_R14(sp)
+ ldw r15,PT_R15(sp)
+ ldw ra,PT_RA(sp)
+ ldw fp,PT_FP(sp)
+ ldw gp,PT_GP(sp)
+ ldw r24,PT_ESTATUS(sp)
+ wrctl estatus,r24
+ ldw ea,PT_EA(sp)
+ ldw sp,PT_SP(sp) // Restore sp last
+.endm
+
+.macro SAVE_SWITCH_STACK
+ addi sp,sp,-SWITCH_STACK_SIZE
+ stw r16,SW_R16(sp)
+ stw r17,SW_R17(sp)
+ stw r18,SW_R18(sp)
+ stw r19,SW_R19(sp)
+ stw r20,SW_R20(sp)
+ stw r21,SW_R21(sp)
+ stw r22,SW_R22(sp)
+ stw r23,SW_R23(sp)
+ stw fp,SW_FP(sp)
+ stw gp,SW_GP(sp)
+ stw ra,SW_RA(sp)
+.endm
+
+.macro RESTORE_SWITCH_STACK
+ ldw r16,SW_R16(sp)
+ ldw r17,SW_R17(sp)
+ ldw r18,SW_R18(sp)
+ ldw r19,SW_R19(sp)
+ ldw r20,SW_R20(sp)
+ ldw r21,SW_R21(sp)
+ ldw r22,SW_R22(sp)
+ ldw r23,SW_R23(sp)
+ ldw fp,SW_FP(sp)
+ ldw gp,SW_GP(sp)
+ ldw ra,SW_RA(sp)
+ addi sp,sp,SWITCH_STACK_SIZE
+.endm
+
+#endif /* __ASSEMBLY__ */
+#endif /* __NIOS2NOMMU_ENTRY_H */
diff --git a/include/asm-nios2nommu/errno.h b/include/asm-nios2nommu/errno.h
new file mode 100644
index 0000000..c2caf21
--- /dev/null
+++ b/include/asm-nios2nommu/errno.h
@@ -0,0 +1,6 @@
+#ifndef _NIOS2NOMMU_ERRNO_H
+#define _NIOS2NOMMU_ERRNO_H
+
+#include <asm-generic/errno.h>
+
+#endif /* _NIOS2NOMMU_ERRNO_H */
diff --git a/include/asm-nios2nommu/fcntl.h b/include/asm-nios2nommu/fcntl.h
new file mode 100644
index 0000000..9d98af2
--- /dev/null
+++ b/include/asm-nios2nommu/fcntl.h
@@ -0,0 +1,11 @@
+#ifndef _NIOS2_FCNTL_H
+#define _NIOS2_FCNTL_H
+
+#define O_DIRECTORY 040000 /* must be a directory */
+#define O_NOFOLLOW 0100000 /* don't follow links */
+#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */
+#define O_LARGEFILE 0400000
+
+#include <asm-generic/fcntl.h>
+
+#endif /* _NIOS2_FCNTL_H */
diff --git a/include/asm-nios2nommu/flat.h b/include/asm-nios2nommu/flat.h
new file mode 100644
index 0000000..681329a
--- /dev/null
+++ b/include/asm-nios2nommu/flat.h
@@ -0,0 +1,129 @@
+/*
+ * include/asm-nios2nommu/flat.h -- uClinux bFLT relocations
+ *
+ * Copyright (C) 2004,05 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ */
+
+#ifndef __NIOS2_FLAT_H__
+#define __NIOS2_FLAT_H__
+
+#define flat_reloc_valid(reloc, size) ((reloc) <= (size + 0x8000))
+
+/* The stack is 64-bit aligned for Nios II, so (sp - 1) shall
+ * be 64-bit aligned, where -1 is for argc
+ */
+#define flat_stack_align(sp) (sp = (unsigned long *)(((unsigned long)sp - 1) & (-8)))
+
+/* The uClibc port for Nios II expects the argc is followed by argv and envp */
+#define flat_argvp_envp_on_stack() 1
+
+#define flat_old_ram_flag(flags) (flags)
+
+/* We store the type of relocation in the top 4 bits of the `relval.' */
+
+/* Convert a relocation entry into an address. */
+static inline unsigned long
+flat_get_relocate_addr (unsigned long relval)
+{
+ return relval & 0x0fffffff; /* Mask out top 4-bits */
+}
+
+#define FLAT_NIOS2_RELOC_TYPE(relval) ((relval) >> 28)
+
+#define FLAT_NIOS2_R_32 0 /* Normal 32-bit reloc */
+#define FLAT_NIOS2_R_HI_LO 1 /* High 16-bits + low 16-bits field */
+#define FLAT_NIOS2_R_HIADJ_LO 2 /* High 16-bits adjust + low 16-bits field */
+#define FLAT_NIOS2_R_CALL26 4 /* Call imm26 */
+
+#define flat_set_persistent(relval, p) 0
+
+/* Extract the address to be relocated from the symbol reference at rp;
+ * relval is the raw relocation-table entry from which RP is derived.
+ * rp shall always be 32-bit aligned
+ */
+static inline unsigned long flat_get_addr_from_rp (unsigned long *rp,
+ unsigned long relval,
+ unsigned long flags,
+ unsigned long *persistent)
+{
+ switch (FLAT_NIOS2_RELOC_TYPE(relval))
+ {
+ case FLAT_NIOS2_R_32:
+ /* Simple 32-bit address. The loader expect it in bigger endian */
+ return htonl(*rp);
+
+ case FLAT_NIOS2_R_HI_LO:
+ /* get the two 16-bit immediate value from instructions, then
+ * construct a 32-bit value. Again the loader expect bigger endian
+ */
+ return htonl ((((rp[0] >> 6) & 0xFFFF) << 16 ) |
+ ((rp[1] >> 6) & 0xFFFF));
+
+ case FLAT_NIOS2_R_HIADJ_LO:
+ {
+ /* get the two 16-bit immediate value from instructions, then
+ * construct a 32-bit value. Again the loader expect bigger endian
+ */
+ unsigned int low, high;
+ high = (rp[0] >> 6) & 0xFFFF;
+ low = (rp[1] >> 6) & 0xFFFF;
+
+ if ((low >> 15) & 1) high--;
+
+ return htonl ((high << 16 ) | low );
+ }
+ case FLAT_NIOS2_R_CALL26:
+ /* the 26-bit immediate value is actually 28-bit */
+ return htonl(((*rp) >> 6) << 2);
+
+ default:
+ return ~0; /* bogus value */
+ }
+}
+
+/* Insert the address addr into the symbol reference at rp;
+ * relval is the raw relocation-table entry from which rp is derived.
+ * rp shall always be 32-bit aligned
+ */
+static inline void flat_put_addr_at_rp (unsigned long *rp, unsigned long addr,
+ unsigned long relval)
+{
+ unsigned long exist_val;
+ switch (FLAT_NIOS2_RELOC_TYPE (relval)) {
+ case FLAT_NIOS2_R_32:
+ /* Simple 32-bit address. */
+ *rp = addr;
+ break;
+
+ case FLAT_NIOS2_R_HI_LO:
+ exist_val = rp[0];
+ rp[0] = ((((exist_val >> 22) << 16) | (addr >> 16)) << 6) | (exist_val & 0x3F);
+ exist_val = rp[1];
+ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
+ break;
+
+ case FLAT_NIOS2_R_HIADJ_LO:
+ {
+ unsigned int high = (addr >> 16);
+ if ((addr >> 15) & 1)
+ high = (high + 1) & 0xFFFF;
+ exist_val = rp[0];
+ rp[0] = ((((exist_val >> 22) << 16) | high) << 6) | (exist_val & 0x3F);
+ exist_val = rp[1];
+ rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
+ break;
+ }
+ case FLAT_NIOS2_R_CALL26:
+ /* the opcode of CALL is 0, so just store the value */
+ *rp = ((addr >> 2) << 6);
+ break;
+ }
+}
+
+#endif /* __NIOS2_FLAT_H__ */
diff --git a/include/asm-nios2nommu/futex.h b/include/asm-nios2nommu/futex.h
new file mode 100644
index 0000000..6a332a9
--- /dev/null
+++ b/include/asm-nios2nommu/futex.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_FUTEX_H
+#define _ASM_FUTEX_H
+
+#include <asm-generic/futex.h>
+
+#endif
diff --git a/include/asm-nios2nommu/gpio.h b/include/asm-nios2nommu/gpio.h
new file mode 100644
index 0000000..b91937b
--- /dev/null
+++ b/include/asm-nios2nommu/gpio.h
@@ -0,0 +1,11 @@
+#ifndef _ASM_GPIO_H_
+#define _ASM_GPIO_H_ 1
+
+
+struct gpio_i2c_pins {
+ unsigned sda_pin;
+ unsigned scl_pin;
+};
+
+#endif /*_ASM_GPIO_*/
+
diff --git a/include/asm-nios2nommu/hardirq.h b/include/asm-nios2nommu/hardirq.h
new file mode 100644
index 0000000..0041f51
--- /dev/null
+++ b/include/asm-nios2nommu/hardirq.h
@@ -0,0 +1,43 @@
+/*
+ * Ported from m68knommu
+ *
+ * Copyright (C) 2003, Microtronix Datacom Ltd.
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef __NIOS2_HARDIRQ_H
+#define __NIOS2_HARDIRQ_H
+
+#include <linux/cache.h>
+#include <linux/threads.h>
+
+typedef struct {
+ unsigned int __softirq_pending;
+} ____cacheline_aligned irq_cpustat_t;
+
+#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
+
+#define HARDIRQ_BITS 8
+
+#ifdef CONFIG_SMP
+# error nios2nommu SMP is not available
+#endif /* CONFIG_SMP */
+
+#endif /* __NIOS2_HARDIRQ_H */
diff --git a/include/asm-nios2nommu/hdreg.h b/include/asm-nios2nommu/hdreg.h
new file mode 100644
index 0000000..b4d910a
--- /dev/null
+++ b/include/asm-nios2nommu/hdreg.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 1994-1996 Linus Torvalds & authors
+ * Copyright (C) 2002 Wentau Xu (www.microtronix.com)
+ * copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2_HDREG_H
+#define __NIOS2_HDREG_H
+
+typedef unsigned long ide_ioreg_t;
+
+#endif /* __NIOS2_HDREG_H */
diff --git a/include/asm-nios2nommu/hw_irq.h b/include/asm-nios2nommu/hw_irq.h
new file mode 100644
index 0000000..d2fd3be
--- /dev/null
+++ b/include/asm-nios2nommu/hw_irq.h
@@ -0,0 +1,16 @@
+#ifndef _ASM_HW_IRQ_H
+#define _ASM_HW_IRQ_H
+
+/*
+ * linux/include/asm/hw_irq.h
+ *
+ * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
+ *
+ * moved some of the old arch/i386/kernel/irq.h to here. VY
+ *
+ * IRQ/IPI changes taken from work by Thomas Radke
+ * <tomsoft@informatik.tu-chemnitz.de>
+ */
+
+
+#endif /* _ASM_HW_IRQ_H */
diff --git a/include/asm-nios2nommu/ide.h b/include/asm-nios2nommu/ide.h
new file mode 100644
index 0000000..f8ef9ad
--- /dev/null
+++ b/include/asm-nios2nommu/ide.h
@@ -0,0 +1,40 @@
+/*
+ * linux/include/asm-niosnommu2/ide.h
+ *
+ * Copyright (C) 1994-1996 Linus Torvalds & authors
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __ASMNIOS2_IDE_H
+#define __ASMNIOS2_IDE_H
+
+#ifdef __KERNEL__
+#undef MAX_HWIFS /* we're going to force it */
+
+#ifndef MAX_HWIFS
+#define MAX_HWIFS 1
+#endif
+
+#include <asm-generic/ide_iops.h>
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASMNIOS2_IDE_H */
diff --git a/include/asm-nios2nommu/init.h b/include/asm-nios2nommu/init.h
new file mode 100644
index 0000000..8641f4f
--- /dev/null
+++ b/include/asm-nios2nommu/init.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#error "<asm/init.h> should never be used - use <linux/init.h> instead"
diff --git a/include/asm-nios2nommu/io.h b/include/asm-nios2nommu/io.h
new file mode 100644
index 0000000..d0e3741
--- /dev/null
+++ b/include/asm-nios2nommu/io.h
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2_IO_H
+#define __NIOS2_IO_H
+
+#ifdef __KERNEL__
+
+#include <linux/kernel.h>
+
+#include <asm/page.h> /* IO address mapping routines need this */
+#include <asm/system.h>
+#include <asm/unaligned.h>
+
+extern void insw(unsigned long port, void *dst, unsigned long count);
+extern void outsw(unsigned long port, void *src, unsigned long count);
+extern void insl(unsigned long port, void *dst, unsigned long count);
+extern void outsl(unsigned long port, void *src, unsigned long count);
+
+#define readsb(p,d,l) insb(p,d,l)
+#define readsw(p,d,l) insw(p,d,l)
+#define readsl(p,d,l) insl(p,d,l)
+#define writesb(p,d,l) outsb(p,d,l)
+#define writesw(p,d,l) outsw(p,d,l)
+#define writesl(p,d,l) outsl(p,d,l)
+#ifndef irq_canonicalize
+#define irq_canonicalize(i) (i)
+#endif
+
+#endif /* __KERNEL__ */
+/* IO macros are needed by userspace programs */
+
+/*
+ * readX/writeX() are used to access memory mapped devices. On some
+ * architectures the memory mapped IO stuff needs to be accessed
+ * differently. On the Nios architecture, we just read/write the
+ * memory location directly.
+ */
+
+#define readb(addr) \
+({ \
+ unsigned char __res;\
+ __asm__ __volatile__( \
+ "ldbuio %0, 0(%1)" \
+ : "=r"(__res) \
+ : "r" (addr)); \
+ __res; \
+})
+
+#define readw(addr) \
+({ \
+ unsigned short __res;\
+ __asm__ __volatile__( \
+ "ldhuio %0, 0(%1)" \
+ : "=r"(__res) \
+ : "r" (addr)); \
+ __res; \
+})
+
+#define readl(addr) \
+({ \
+ unsigned int __res;\
+ __asm__ __volatile__( \
+ "ldwio %0, 0(%1)" \
+ : "=r"(__res) \
+ : "r" (addr)); \
+ __res; \
+})
+
+#define writeb(b,addr) \
+({ \
+ __asm__ __volatile__( \
+ "stbio %0, 0(%1)" \
+ : : "r"(b), "r" (addr)); \
+})
+
+#define writew(b,addr) \
+({ \
+ __asm__ __volatile__( \
+ "sthio %0, 0(%1)" \
+ : : "r"(b), "r" (addr)); \
+})
+
+#define writel(b,addr) \
+({ \
+ __asm__ __volatile__( \
+ "stwio %0, 0(%1)" \
+ : : "r"(b), "r" (addr)); \
+})
+
+#define __raw_readb readb
+#define __raw_readw readw
+#define __raw_readl readl
+#define __raw_writeb writeb
+#define __raw_writew writew
+#define __raw_writel writel
+
+#define mmiowb()
+
+/*
+ * make the short names macros so specific devices
+ * can override them as required
+ */
+
+#define memset_io(addr,c,len) memset((void *)(((unsigned int)(addr)) | 0x80000000),(c),(len))
+#define memcpy_fromio(to,from,len) memcpy((to),(void *)(((unsigned int)(from)) | 0x80000000),(len))
+#define memcpy_toio(to,from,len) memcpy((void *)(((unsigned int)(to)) | 0x80000000),(from),(len))
+
+#define inb(addr) readb(addr)
+#define inw(addr) readw(addr)
+#define inl(addr) readl(addr)
+
+#define outb(x,addr) ((void) writeb(x,addr))
+#define outw(x,addr) ((void) writew(x,addr))
+#define outl(x,addr) ((void) writel(x,addr))
+
+#define inb_p(addr) inb(addr)
+#define inw_p(addr) inw(addr)
+#define inl_p(addr) inl(addr)
+
+#define outb_p(x,addr) outb(x,addr)
+#define outw_p(x,addr) outw(x,addr)
+#define outl_p(x,addr) outl(x,addr)
+
+/* IO macros are needed by userspace programs */
+#ifdef __KERNEL__
+
+extern inline void insb(unsigned long port, void *dst, unsigned long count)
+{
+ unsigned char *p=(unsigned char*)dst;
+ while (count--)
+ *p++ = inb(port);
+}
+
+/* See arch/niosnommu/io.c for optimized version */
+extern inline void _insw(unsigned long port, void *dst, unsigned long count)
+{
+ unsigned short *p=(unsigned short*)dst;
+ while (count--)
+ *p++ = inw(port);
+}
+
+/* See arch/niosnommu/kernel/io.c for unaligned destination pointer */
+extern inline void _insl(unsigned long port, void *dst, unsigned long count)
+{
+ unsigned long *p=(unsigned long*)dst;
+ while (count--)
+ *p++ = inl(port);
+}
+
+extern inline void outsb(unsigned long port, void *src, unsigned long count)
+{
+ unsigned char *p=(unsigned char*)src;
+ while (count--)
+ outb( *p++, port );
+}
+
+/* See arch/niosnommu/io.c for optimized version */
+extern inline void _outsw(unsigned long port, void *src, unsigned long count)
+{
+ unsigned short *p=(unsigned short*)src;
+ while (count--)
+ outw( *p++, port );
+}
+
+/* See arch/niosnommu/kernel/io.c for unaligned source pointer */
+extern inline void _outsl(unsigned long port, void *src, unsigned long count)
+{
+ unsigned long *p=(unsigned long*)src;
+ while (count--)
+ outl( *p++, port );
+}
+
+
+
+extern inline void mapioaddr(unsigned long physaddr, unsigned long virt_addr,
+ int bus, int rdonly)
+{
+ return;
+}
+
+//vic - copied from m68knommu
+
+/* Values for nocacheflag and cmode */
+#define IOMAP_FULL_CACHING 0
+#define IOMAP_NOCACHE_SER 1
+#define IOMAP_NOCACHE_NONSER 2
+#define IOMAP_WRITETHROUGH 3
+
+extern void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
+extern void __iounmap(void *addr, unsigned long size);
+
+extern inline void *ioremap(unsigned long physaddr, unsigned long size)
+{
+ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
+}
+extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
+{
+ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
+}
+extern inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
+{
+ return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
+}
+extern inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
+{
+ return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
+}
+
+extern void iounmap(void *addr);
+
+
+#define IO_SPACE_LIMIT 0xffffffff
+
+#define dma_cache_inv(_start,_size) dcache_push(_start,_size)
+#define dma_cache_wback(_start,_size) dcache_push(_start,_size)
+#define dma_cache_wback_inv(_start,_size) dcache_push(_start,_size)
+
+/* Pages to physical address... */
+#define page_to_phys(page) page_to_virt(page)
+#define page_to_bus(page) page_to_virt(page)
+
+#define mm_ptov(vaddr) ((void *) (vaddr))
+#define mm_vtop(vaddr) ((unsigned long) (vaddr))
+#define phys_to_virt(vaddr) ((void *) (vaddr))
+#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
+
+#define virt_to_bus virt_to_phys
+#define bus_to_virt phys_to_virt
+
+#define ioport_map(port, nr) ioremap(port, nr)
+#define ioport_unmap(port) iounmap(port)
+
+/*
+ * Convert a physical pointer to a virtual kernel pointer for /dev/mem
+ * access
+ */
+#define xlate_dev_mem_ptr(p) __va(p)
+
+/*
+ * Convert a virtual cached pointer to an uncached pointer
+ */
+#define xlate_dev_kmem_ptr(p) p
+
+#define readsb(p,d,l) insb(p,d,l)
+#define readsw(p,d,l) insw(p,d,l)
+#define readsl(p,d,l) insl(p,d,l)
+#define writesb(p,d,l) outsb(p,d,l)
+#define writesw(p,d,l) outsw(p,d,l)
+#define writesl(p,d,l) outsl(p,d,l)
+#ifndef irq_canonicalize
+#define irq_canonicalize(i) (i)
+#endif
+
+#endif /* __KERNEL__ */
+
+#endif /* !(__NIOS2_IO_H) */
+
diff --git a/include/asm-nios2nommu/ioctl.h b/include/asm-nios2nommu/ioctl.h
new file mode 100644
index 0000000..c02a36a
--- /dev/null
+++ b/include/asm-nios2nommu/ioctl.h
@@ -0,0 +1,100 @@
+/* $Id: ioctl.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
+ *
+ * linux/ioctl.h for Linux by H.H. Bergman.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2_IOCTL_H
+#define _NIOS2_IOCTL_H
+
+/* ioctl command encoding: 32 bits total, command in lower 16 bits,
+ * size of the parameter structure in the lower 14 bits of the
+ * upper 16 bits.
+ * Encoding the size of the parameter structure in the ioctl request
+ * is useful for catching programs compiled with old versions
+ * and to avoid overwriting user space outside the user buffer area.
+ * The highest 2 bits are reserved for indicating the ``access mode''.
+ * NOTE: This limits the max parameter size to 16kB -1 !
+ */
+
+/*
+ * I don't really have any idea about what this should look like, so
+ * for the time being, this is heavily based on the PC definitions.
+ */
+
+/*
+ * The following is for compatibility across the various Linux
+ * platforms. The i386 ioctl numbering scheme doesn't really enforce
+ * a type field. De facto, however, the top 8 bits of the lower 16
+ * bits are indeed used as a type field, so we might just as well make
+ * this explicit here. Please be sure to use the decoding macros
+ * below from now on.
+ */
+#define _IOC_NRBITS 8
+#define _IOC_TYPEBITS 8
+#define _IOC_SIZEBITS 14
+#define _IOC_DIRBITS 2
+
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
+
+#define _IOC_NRSHIFT 0
+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
+
+/*
+ * Direction bits.
+ */
+#define _IOC_NONE 0U
+#define _IOC_WRITE 1U
+#define _IOC_READ 2U
+
+#define _IOC(dir,type,nr,size) \
+ (((dir) << _IOC_DIRSHIFT) | \
+ ((type) << _IOC_TYPESHIFT) | \
+ ((nr) << _IOC_NRSHIFT) | \
+ ((size) << _IOC_SIZESHIFT))
+
+/* used to create numbers */
+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+
+/* used to decode ioctl numbers.. */
+#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
+#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
+#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
+#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
+
+/* ...and for the drivers/sound files... */
+
+#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
+#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
+#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
+#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
+#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
+
+#endif /* _NIOS2_IOCTL_H */
diff --git a/include/asm-nios2nommu/ioctls.h b/include/asm-nios2nommu/ioctls.h
new file mode 100644
index 0000000..288025c
--- /dev/null
+++ b/include/asm-nios2nommu/ioctls.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __ARCH_NIOS2_IOCTLS_H__
+#define __ARCH_NIOS2_IOCTLS_H__
+
+#include <asm/ioctl.h>
+
+/* 0x54 is just a magic number to make these relatively unique ('T') */
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+#define TCGETA 0x5405
+#define TCSETA 0x5406
+#define TCSETAW 0x5407
+#define TCSETAF 0x5408
+#define TCSBRK 0x5409
+#define TCXONC 0x540A
+#define TCFLSH 0x540B
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
+#define TIOCSBRK 0x5427 /* BSD compatibility */
+#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+
+#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR 0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
+#define FIOQSIZE 0x545E
+
+/* Used for packet mode */
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+
+#endif /* __ARCH_NIOS2_IOCTLS_H__ */
diff --git a/include/asm-nios2nommu/ipc.h b/include/asm-nios2nommu/ipc.h
new file mode 100644
index 0000000..cb86a31
--- /dev/null
+++ b/include/asm-nios2nommu/ipc.h
@@ -0,0 +1,51 @@
+#ifndef __NIOS2_IPC_H__
+#define __NIOS2_IPC_H__
+
+/* Copied from sparc version
+ * These are used to wrap system calls on the Nios.
+ *
+ * See arch/niosnommu/kernel/sys_nios.c for ugly details..
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+struct ipc_kludge {
+ struct msgbuf *msgp;
+ long msgtyp;
+};
+
+#define SEMOP 1
+#define SEMGET 2
+#define SEMCTL 3
+#define MSGSND 11
+#define MSGRCV 12
+#define MSGGET 13
+#define MSGCTL 14
+#define SHMAT 21
+#define SHMDT 22
+#define SHMGET 23
+#define SHMCTL 24
+
+/* Used by the DIPC package, try and avoid reusing it */
+#define DIPC 25
+
+#define IPCCALL(version,op) ((version)<<16 | (op))
+
+#endif
diff --git a/include/asm-nios2nommu/ipcbuf.h b/include/asm-nios2nommu/ipcbuf.h
new file mode 100644
index 0000000..ef59533
--- /dev/null
+++ b/include/asm-nios2nommu/ipcbuf.h
@@ -0,0 +1,49 @@
+#ifndef __NIOS2_IPCBUF_H__
+#define __NIOS2_IPCBUF_H__
+
+/* Copied from asm-m68k/ipcbuf.h
+ * The user_ipc_perm structure for Nios architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 32-bit mode_t and seq
+ * - 2 miscellaneous 32-bit values
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+struct ipc64_perm
+{
+ __kernel_key_t key;
+ __kernel_uid32_t uid;
+ __kernel_gid32_t gid;
+ __kernel_uid32_t cuid;
+ __kernel_gid32_t cgid;
+ __kernel_mode_t mode;
+ unsigned short __pad1;
+ unsigned short seq;
+ unsigned short __pad2;
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif /* __NIOS2_IPCBUF_H__ */
diff --git a/include/asm-nios2nommu/irq.h b/include/asm-nios2nommu/irq.h
new file mode 100644
index 0000000..f0e37a2
--- /dev/null
+++ b/include/asm-nios2nommu/irq.h
@@ -0,0 +1,181 @@
+/*
+ * 21Mar2001 1.1 dgt/microtronix
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+
+#ifndef _NIOS2NOMMU_IRQ_H_
+#define _NIOS2NOMMU_IRQ_H_
+
+extern void disable_irq(unsigned int);
+extern void enable_irq(unsigned int);
+
+#include <linux/interrupt.h>
+
+#define SYS_IRQS 32
+#define NR_IRQS SYS_IRQS
+
+/*
+ * Interrupt source definitions
+ * General interrupt sources are the level 1-7.
+ * Adding an interrupt service routine for one of these sources
+ * results in the addition of that routine to a chain of routines.
+ * Each one is called in succession. Each individual interrupt
+ * service routine should determine if the device associated with
+ * that routine requires service.
+ */
+
+#define IRQ01 (1) /* level 1 interrupt */
+#define IRQ02 (2) /* level 2 interrupt */
+#define IRQ03 (3) /* level 3 interrupt */
+#define IRQ04 (4) /* level 4 interrupt */
+#define IRQ05 (5) /* level 5 interrupt */
+#define IRQ06 (6) /* level 6 interrupt */
+#define IRQ07 (7) /* level 7 interrupt */
+#define IRQ08 (8) /* level 8 interrupt */
+#define IRQ09 (9) /* level 9 interrupt */
+#define IRQ0A (10) /* level 10 interrupt */
+#define IRQ0B (11) /* level 11 interrupt */
+#define IRQ0C (12) /* level 12 interrupt */
+#define IRQ0D (13) /* level 13 interrupt */
+#define IRQ0E (14) /* level 14 interrupt */
+#define IRQ0F (15) /* level 15 interrupt */
+#define IRQ10 (16) /* level 16 interrupt */
+#define IRQ12 (17) /* level 17 interrupt */
+#define IRQ13 (18) /* level 18 interrupt */
+#define IRQ14 (19) /* level 19 interrupt */
+#define IRQ15 (20) /* level 20 interrupt */
+#define IRQ16 (21) /* level 21 interrupt */
+#define IRQ17 (22) /* level 22 interrupt */
+#define IRQ18 (23) /* level 23 interrupt */
+#define IRQ19 (24) /* level 24 interrupt */
+#define IRQ1A (25) /* level 25 interrupt */
+#define IRQ1B (26) /* level 26 interrupt */
+#define IRQ1C (27) /* level 27 interrupt */
+#define IRQ1D (28) /* level 28 interrupt */
+#define IRQ1E (29) /* level 29 interrupt */
+#define IRQ1F (30) /* level 30 interrupt */
+#define IRQ20 (31) /* level 31 interrupt */
+#define IRQ21 (32) /* level 32 interrupt */
+
+#define IRQMAX IRQ21
+
+/*
+ * "Generic" interrupt sources
+ */
+
+/*
+ * Machine specific interrupt sources.
+ *
+ * Adding an interrupt service routine for a source with this bit
+ * set indicates a special machine specific interrupt source.
+ * The machine specific files define these sources.
+ *
+ * Removed, they are not used by any one.
+ */
+
+/*
+ * various flags for request_irq()
+ */
+#define IRQ_FLG_LOCK (0x0001) /* handler is not replaceable */
+#define IRQ_FLG_REPLACE (0x0002) /* replace existing handler */
+#define IRQ_FLG_FAST (0x0004)
+#define IRQ_FLG_SLOW (0x0008)
+#define IRQ_FLG_STD (0x8000) /* internally used */
+
+/*
+ * Functions to set and clear the interrupt mask.
+ */
+
+/*
+ * Use a zero to clean the bit.
+ */
+static inline void clrimr(int mask)
+{
+ int flags;
+
+ local_irq_save(flags);
+ __asm__ __volatile__(
+ "rdctl r8, ienable\n"
+ "and r8,r8,%0\n"
+ "wrctl ienable, r8\n"
+ : /* No output */
+ : "r" (mask)
+ : "r8");
+ local_irq_restore(flags);
+}
+
+/*
+ * Use a one to set the bit.
+ */
+static inline void setimr(int mask)
+{
+ int flags;
+
+ local_irq_save(flags);
+ __asm__ __volatile__(
+ "rdctl r8, ienable\n"
+ "or r8,r8,%0\n"
+ "wrctl ienable, r8\n"
+ : /* No output */
+ : "r" (mask)
+ : "r8");
+ local_irq_restore(flags);
+}
+
+/*
+ * This structure is used to chain together the ISRs for a particular
+ * interrupt source (if it supports chaining).
+ */
+typedef struct irq_node {
+ irq_handler_t handler;
+ unsigned long flags;
+ void *dev_id;
+ const char *devname;
+ struct irq_node *next;
+} irq_node_t;
+
+/*
+ * This function returns a new irq_node_t
+ */
+extern irq_node_t *new_irq_node(void);
+
+/*
+ * This structure has only 4 elements for speed reasons
+ */
+typedef struct irq_hand {
+ irq_handler_t handler;
+ unsigned long flags;
+ void *dev_id;
+ const char *devname;
+} irq_hand_t;
+
+/* count of spurious interrupts */
+extern volatile unsigned int num_spurious;
+
+#define disable_irq_nosync(i) disable_irq(i)
+
+#ifndef irq_canonicalize
+#define irq_canonicalize(i) (i)
+#endif
+
+#endif /* _NIOS2NOMMU_IRQ_H_ */
diff --git a/include/asm-nios2nommu/irq_node.h b/include/asm-nios2nommu/irq_node.h
new file mode 100644
index 0000000..24f9763
--- /dev/null
+++ b/include/asm-nios2nommu/irq_node.h
@@ -0,0 +1,36 @@
+#ifndef _NIOS2NOMMU_IRQNODE_H_
+#define _NIOS2NOMMU_IRQNODE_H_
+
+#include <linux/interrupt.h>
+
+/*
+ * This structure is used to chain together the ISRs for a particular
+ * interrupt source (if it supports chaining).
+ */
+typedef struct irq_node {
+ irqreturn_t (*handler)(int, void *, struct pt_regs *);
+ unsigned long flags;
+ void *dev_id;
+ const char *devname;
+ struct irq_node *next;
+} irq_node_t;
+
+/*
+ * This structure has only 4 elements for speed reasons
+ */
+typedef struct irq_handler {
+ irqreturn_t (*handler)(int, void *, struct pt_regs *);
+ unsigned long flags;
+ void *dev_id;
+ const char *devname;
+} irq_handler_t;
+
+/* count of spurious interrupts */
+extern volatile unsigned int num_spurious;
+
+/*
+ * This function returns a new irq_node_t
+ */
+extern irq_node_t *new_irq_node(void);
+
+#endif /* _NIOS2NOMMU_IRQNODE_H_ */
diff --git a/include/asm-nios2nommu/irq_regs.h b/include/asm-nios2nommu/irq_regs.h
new file mode 100644
index 0000000..3dd9c0b
--- /dev/null
+++ b/include/asm-nios2nommu/irq_regs.h
@@ -0,0 +1 @@
+#include <asm-generic/irq_regs.h>
diff --git a/include/asm-nios2nommu/kdebug.h b/include/asm-nios2nommu/kdebug.h
new file mode 100644
index 0000000..6ece1b0
--- /dev/null
+++ b/include/asm-nios2nommu/kdebug.h
@@ -0,0 +1 @@
+#include <asm-generic/kdebug.h>
diff --git a/include/asm-nios2nommu/kmap_types.h b/include/asm-nios2nommu/kmap_types.h
new file mode 100644
index 0000000..a26b91d
--- /dev/null
+++ b/include/asm-nios2nommu/kmap_types.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _ASM_KMAP_TYPES_H
+#define _ASM_KMAP_TYPES_H
+
+enum km_type {
+ KM_BOUNCE_READ,
+ KM_SKB_SUNRPC_DATA,
+ KM_SKB_DATA_SOFTIRQ,
+ KM_USER0,
+ KM_USER1,
+ KM_BIO_SRC_IRQ,
+ KM_BIO_DST_IRQ,
+ KM_PTE0,
+ KM_PTE1,
+ KM_IRQ0,
+ KM_IRQ1,
+ KM_SOFTIRQ0,
+ KM_SOFTIRQ1,
+ KM_TYPE_NR
+};
+
+#endif
diff --git a/include/asm-nios2nommu/linkage.h b/include/asm-nios2nommu/linkage.h
new file mode 100644
index 0000000..db79297
--- /dev/null
+++ b/include/asm-nios2nommu/linkage.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+#define __ALIGN .align 3
+#define __ALIGN_STR ".align 3"
+
+#endif
diff --git a/include/asm-nios2nommu/linux_logo.h b/include/asm-nios2nommu/linux_logo.h
new file mode 100644
index 0000000..f9d38e7
--- /dev/null
+++ b/include/asm-nios2nommu/linux_logo.h
@@ -0,0 +1,953 @@
+/* $Id: linux_logo.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
+ * include/asm-nios/linux_logo.h: This is a linux logo
+ * to be displayed on boot.
+ *
+ * Copyright (C) 1996 Larry Ewing (lewing@isc.tamu.edu)
+ * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
+ * Copyright (C) 2004 Micrtronix Datacom Ltd.
+ *
+ * You can put anything here, but:
+ * LINUX_LOGO_COLORS has to be less than 224
+ * image size has to be 80x80
+ * values have to start from 0x20
+ * (i.e. RGB(linux_logo_red[0],
+ * linux_logo_green[0],
+ * linux_logo_blue[0]) is color 0x20)
+ * BW image has to be 80x80 as well, with MS bit
+ * on the left
+ * Serial_console ascii image can be any size,
+ * but should contain %s to display the version
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/version.h>
+
+#define linux_logo_banner "Linux/NIOS2 version " UTS_RELEASE
+
+#define __HAVE_ARCH_LINUX_LOGO
+#define __HAVE_ARCH_LINUX_LOGO16
+
+#define LINUX_LOGO_COLORS 221
+
+#ifdef INCLUDE_LINUX_LOGO_DATA
+
+unsigned char linux_logo_red[] __initdata = {
+ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
+ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
+ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
+ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
+ 0xc3, 0x65, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
+ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
+ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x76, 0x79,
+ 0x62, 0x36, 0x9a, 0xe2, 0xec, 0xe1, 0xb8, 0xd7,
+ 0xaf, 0x25, 0xbc, 0xc0, 0xef, 0xea, 0xe8, 0xe8,
+ 0xf5, 0xf1, 0xda, 0xd3, 0x79, 0xdb, 0xf4, 0xf6,
+ 0xf6, 0xf6, 0xe2, 0x3d, 0xb4, 0xce, 0xe6, 0xee,
+ 0xf6, 0x68, 0xd8, 0xec, 0xf5, 0xc6, 0xc8, 0x9c,
+ 0x89, 0xd2, 0xee, 0xcb, 0xb9, 0xd2, 0x66, 0x5e,
+ 0x8b, 0xbe, 0xa8, 0xd5, 0xca, 0xb6, 0xae, 0x9c,
+ 0xc5, 0xbe, 0xbe, 0xca, 0x90, 0xb2, 0x9a, 0xa8,
+ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfe,
+ 0xf6, 0xec, 0xfe, 0xd2, 0xea, 0xf5, 0xf2, 0xf2,
+ 0xe9, 0xee, 0xf6, 0xf2, 0xee, 0xf6, 0xda, 0xd4,
+ 0xfa, 0xca, 0xf2, 0xf6, 0xfe, 0xf2, 0xda, 0xe4,
+ 0xf6, 0xdd, 0xf2, 0xee, 0xfa, 0xf0, 0x12, 0x4a,
+ 0xd6, 0xf2, 0x8e, 0xf2, 0xf6, 0xf6, 0xb5, 0xf1,
+ 0x26, 0x9a, 0xea, 0xf6, 0xe0, 0xd2, 0x16, 0x9a,
+ 0x2e, 0xd2, 0x70, 0xd6, 0x46, 0x7c, 0xb4, 0x62,
+ 0xda, 0xee, 0xd6, 0xa3, 0x74, 0xa7, 0xa2, 0xe0,
+ 0xae, 0xbe, 0xce, 0xe2, 0xa3, 0x8e, 0x6d, 0x8e,
+ 0x32, 0xaf, 0x50, 0x9e, 0x5b, 0x8a, 0x98, 0x82,
+ 0x7a, 0x82, 0x56, 0x7c, 0x8a, 0x56, 0x5e, 0x86,
+ 0x6a, 0x52, 0x59, 0x64, 0x5e,
+};
+
+unsigned char linux_logo_green[] __initdata = {
+ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
+ 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
+ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
+ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
+ 0xc3, 0x62, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
+ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
+ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x62, 0x5c,
+ 0x4e, 0x26, 0x72, 0xaa, 0xba, 0xaf, 0x90, 0xae,
+ 0x92, 0x1a, 0xa4, 0x85, 0xb6, 0xbe, 0xc3, 0xc8,
+ 0xcf, 0xd0, 0xc2, 0xce, 0x57, 0xa2, 0xd6, 0xda,
+ 0xda, 0xd7, 0xb8, 0x2a, 0x7b, 0x91, 0xae, 0xca,
+ 0xda, 0x45, 0x9e, 0xb2, 0xd7, 0x9b, 0x90, 0x76,
+ 0x5c, 0xa2, 0xbe, 0xa6, 0x85, 0x96, 0x4e, 0x46,
+ 0x66, 0x92, 0x7a, 0x9a, 0x96, 0x9d, 0x9a, 0x6b,
+ 0x8a, 0x8e, 0xb2, 0xca, 0x90, 0xa6, 0x79, 0x7c,
+ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfa,
+ 0xea, 0xd7, 0xf6, 0xbc, 0xda, 0xde, 0xda, 0xe6,
+ 0xca, 0xd8, 0xea, 0xe0, 0xcc, 0xf2, 0xce, 0xb2,
+ 0xee, 0xa2, 0xd6, 0xe6, 0xf6, 0xd7, 0xc5, 0xb8,
+ 0xc6, 0xb9, 0xce, 0xde, 0xce, 0xc6, 0x0e, 0x36,
+ 0xae, 0xbe, 0x86, 0xba, 0xbe, 0xe6, 0x8e, 0xc4,
+ 0x1e, 0x8e, 0xae, 0xba, 0xb2, 0xa6, 0x12, 0x7a,
+ 0x20, 0xc6, 0x64, 0xaa, 0x2f, 0x70, 0x85, 0x46,
+ 0xce, 0xd6, 0xa6, 0x6e, 0x51, 0x72, 0x92, 0xa6,
+ 0x87, 0x96, 0xa2, 0xd6, 0x85, 0x7a, 0x6a, 0x6e,
+ 0x22, 0x76, 0x36, 0x76, 0x3c, 0x6e, 0x63, 0x53,
+ 0x66, 0x62, 0x42, 0x50, 0x56, 0x42, 0x56, 0x56,
+ 0x56, 0x3e, 0x51, 0x52, 0x56,
+};
+
+unsigned char linux_logo_blue[] __initdata = {
+ 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
+ 0x12, 0x01, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
+ 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x06, 0x65,
+ 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
+ 0xc3, 0x59, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
+ 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
+ 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x2e, 0x08,
+ 0x0a, 0x06, 0x0a, 0x0b, 0x0b, 0x0f, 0x0c, 0x0f,
+ 0x3d, 0x09, 0x73, 0x09, 0x0d, 0x0a, 0x10, 0x1e,
+ 0x2d, 0x13, 0x86, 0xba, 0x19, 0x0a, 0x36, 0x3c,
+ 0x26, 0x14, 0x0d, 0x06, 0x07, 0x0a, 0x0b, 0x0f,
+ 0x4a, 0x06, 0x0a, 0x0c, 0x2b, 0x0a, 0x0b, 0x0a,
+ 0x06, 0x0a, 0x0a, 0x11, 0x0b, 0x0a, 0x0a, 0x1e,
+ 0x0f, 0x0d, 0x0a, 0x0b, 0x22, 0x6a, 0x72, 0x0b,
+ 0x0b, 0x22, 0x90, 0xca, 0x90, 0x92, 0x3c, 0x2c,
+ 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xea,
+ 0xb6, 0x7c, 0xda, 0x8e, 0xa6, 0x87, 0x66, 0xb6,
+ 0x81, 0x6a, 0xc6, 0x9a, 0x5b, 0xd2, 0xb6, 0x6a,
+ 0xca, 0x45, 0x92, 0xb2, 0xca, 0x52, 0x8a, 0x3e,
+ 0x2e, 0x66, 0x66, 0xae, 0x3e, 0x47, 0x06, 0x0e,
+ 0x52, 0x36, 0x6a, 0x0e, 0x0e, 0xbe, 0x2c, 0x0e,
+ 0x0a, 0x5a, 0x0d, 0x0e, 0x3e, 0x0a, 0x06, 0x2e,
+ 0x06, 0x9e, 0x4e, 0x36, 0x06, 0x58, 0x24, 0x06,
+ 0x9e, 0xae, 0x3a, 0x08, 0x08, 0x07, 0x5e, 0x0a,
+ 0x32, 0x2e, 0x2a, 0xb2, 0x43, 0x48, 0x5f, 0x2e,
+ 0x06, 0x06, 0x07, 0x24, 0x06, 0x32, 0x06, 0x06,
+ 0x46, 0x2e, 0x22, 0x06, 0x06, 0x1e, 0x4c, 0x06,
+ 0x3a, 0x22, 0x42, 0x34, 0x42,
+};
+
+unsigned char linux_logo[] __initdata = {
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22,
+ 0x22, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x26, 0x26, 0x25, 0x28, 0x23, 0x22, 0x21, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x21, 0x23, 0x25, 0x2a, 0x2b, 0x2c, 0x2d, 0x2d,
+ 0x2d, 0x2e, 0x2c, 0x2b, 0x2a, 0x25, 0x28, 0x22,
+ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
+ 0x24, 0x2a, 0x2c, 0x2f, 0x2c, 0x30, 0x30, 0x24,
+ 0x25, 0x27, 0x2b, 0x2c, 0x2f, 0x31, 0x32, 0x25,
+ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
+ 0x33, 0x34, 0x35, 0x21, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x21, 0x2b, 0x2f, 0x2c,
+ 0x30, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
+ 0x2d, 0x27, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x31,
+ 0x2d, 0x32, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x21, 0x28, 0x2a, 0x34,
+ 0x25, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x23, 0x32, 0x27, 0x21, 0x36,
+ 0x2a, 0x2d, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x22, 0x26, 0x2c, 0x35,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x25, 0x2f, 0x37, 0x32, 0x22,
+ 0x36, 0x35, 0x31, 0x27, 0x22, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x22,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x26, 0x38, 0x38, 0x35, 0x25,
+ 0x36, 0x21, 0x2d, 0x2b, 0x24, 0x21, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x21, 0x24, 0x39, 0x39, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x25, 0x2b, 0x30, 0x28, 0x22,
+ 0x36, 0x36, 0x27, 0x34, 0x30, 0x23, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x21, 0x26, 0x2d, 0x26, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x22, 0x22, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x2d, 0x33, 0x28, 0x21, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x2b, 0x2c, 0x25, 0x21, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x36, 0x36,
+ 0x36, 0x21, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x21, 0x23, 0x22, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x28, 0x34, 0x27, 0x22, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
+ 0x21, 0x21, 0x24, 0x27, 0x21, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x28, 0x27, 0x22, 0x33, 0x24, 0x36,
+ 0x36, 0x36, 0x36, 0x22, 0x2f, 0x2a, 0x23, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
+ 0x30, 0x3a, 0x38, 0x24, 0x24, 0x36, 0x36, 0x36,
+ 0x23, 0x2f, 0x3b, 0x3c, 0x3d, 0x30, 0x25, 0x21,
+ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x32, 0x23, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x23,
+ 0x3e, 0x3f, 0x40, 0x3a, 0x22, 0x36, 0x36, 0x21,
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x3e, 0x23, 0x21,
+ 0x36, 0x36, 0x36, 0x36, 0x2f, 0x33, 0x28, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x2b,
+ 0x44, 0x40, 0x46, 0x47, 0x35, 0x36, 0x36, 0x26,
+ 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x2e, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x32, 0x34, 0x36, 0x4d,
+ 0x4e, 0x25, 0x2f, 0x46, 0x4a, 0x22, 0x23, 0x32,
+ 0x4f, 0x50, 0x21, 0x31, 0x51, 0x52, 0x53, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x21, 0x3a,
+ 0x4d, 0x21, 0x31, 0x54, 0x55, 0x28, 0x30, 0x2b,
+ 0x4b, 0x4d, 0x36, 0x23, 0x32, 0x50, 0x3f, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x29, 0x20, 0x29, 0x20, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x38, 0x23, 0x37,
+ 0x55, 0x36, 0x28, 0x3a, 0x56, 0x57, 0x57, 0x58,
+ 0x3c, 0x4d, 0x36, 0x36, 0x36, 0x40, 0x40, 0x21,
+ 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x29, 0x29, 0x29, 0x20, 0x29, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x30, 0x51, 0x23, 0x35,
+ 0x43, 0x25, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
+ 0x5f, 0x60, 0x61, 0x36, 0x31, 0x47, 0x3b, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x31, 0x2c, 0x25, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x22,
+ 0x40, 0x62, 0x63, 0x5d, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x66, 0x5e, 0x6a, 0x6b, 0x2a, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x33, 0x2e, 0x26, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2f, 0x23, 0x36,
+ 0x6c, 0x63, 0x6d, 0x64, 0x5c, 0x66, 0x69, 0x6e,
+ 0x6f, 0x70, 0x71, 0x69, 0x69, 0x72, 0x6c, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x33, 0x34, 0x27, 0x22,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x27, 0x34, 0x26, 0x73,
+ 0x74, 0x75, 0x76, 0x64, 0x65, 0x77, 0x69, 0x78,
+ 0x70, 0x71, 0x71, 0x71, 0x72, 0x5f, 0x5e, 0x21,
+ 0x36, 0x36, 0x36, 0x36, 0x25, 0x38, 0x2a, 0x23,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x33, 0x79,
+ 0x63, 0x7a, 0x7b, 0x5c, 0x66, 0x69, 0x6e, 0x7c,
+ 0x71, 0x71, 0x69, 0x7d, 0x7e, 0x7a, 0x7f, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x21, 0x51, 0x2b, 0x28,
+ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x32, 0x24,
+ 0x80, 0x81, 0x64, 0x82, 0x77, 0x69, 0x71, 0x71,
+ 0x69, 0x83, 0x84, 0x85, 0x7a, 0x85, 0x86, 0x36,
+ 0x21, 0x2b, 0x23, 0x36, 0x36, 0x39, 0x2e, 0x26,
+ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x27, 0x2d, 0x33, 0x21,
+ 0x87, 0x88, 0x89, 0x72, 0x67, 0x66, 0x5f, 0x89,
+ 0x8a, 0x63, 0x85, 0x8b, 0x8c, 0x8d, 0x41, 0x36,
+ 0x36, 0x2d, 0x3a, 0x35, 0x36, 0x24, 0x51, 0x32,
+ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x33, 0x21,
+ 0x55, 0x8e, 0x8f, 0x8a, 0x7d, 0x5e, 0x90, 0x7e,
+ 0x75, 0x75, 0x90, 0x62, 0x40, 0x3f, 0x49, 0x23,
+ 0x36, 0x24, 0x3a, 0x3a, 0x24, 0x36, 0x2e, 0x31,
+ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x21, 0x28, 0x33, 0x37, 0x25, 0x22,
+ 0x3b, 0x50, 0x8e, 0x8f, 0x90, 0x7e, 0x90, 0x63,
+ 0x74, 0x91, 0x92, 0x42, 0x93, 0x4b, 0x45, 0x2c,
+ 0x36, 0x36, 0x33, 0x39, 0x21, 0x36, 0x22, 0x51,
+ 0x33, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x22, 0x27, 0x2e, 0x2e, 0x36, 0x21,
+ 0x94, 0x3f, 0x50, 0x95, 0x96, 0x8f, 0x8f, 0x97,
+ 0x8e, 0x42, 0x50, 0x43, 0x47, 0x48, 0x48, 0x98,
+ 0x21, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39,
+ 0x2e, 0x27, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x22, 0x24, 0x2b, 0x38, 0x28, 0x36, 0x32,
+ 0x4c, 0x4b, 0x50, 0x50, 0x50, 0x42, 0x42, 0x50,
+ 0x50, 0x40, 0x45, 0x99, 0x48, 0x48, 0x48, 0x48,
+ 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x23,
+ 0x2f, 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x21, 0x28, 0x32, 0x51, 0x32, 0x28, 0x21, 0x98,
+ 0x48, 0x47, 0x9a, 0x50, 0x50, 0x50, 0x50, 0x50,
+ 0x9a, 0x4f, 0x9b, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x93, 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x2a, 0x2f, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x23, 0x30, 0x2e, 0x2c, 0x36, 0x21, 0x51, 0x9b,
+ 0x48, 0x48, 0x52, 0x3f, 0x50, 0x50, 0x40, 0x4b,
+ 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x2d, 0x31, 0x27, 0x23, 0x21, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
+ 0x27, 0x2c, 0x2d, 0x21, 0x36, 0x28, 0x44, 0x48,
+ 0x48, 0x48, 0x48, 0x47, 0x46, 0x4f, 0x47, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x9c, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x28, 0x51, 0x39, 0x26, 0x22, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
+ 0x35, 0x51, 0x28, 0x36, 0x36, 0x9d, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x9b, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x4f, 0x28, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x28, 0x38, 0x2b, 0x25, 0x22, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
+ 0x51, 0x25, 0x36, 0x36, 0x23, 0x40, 0x9b, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x9b, 0x99, 0x2b, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x30, 0x2f, 0x33, 0x24, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x21, 0x23, 0x30, 0x34,
+ 0x27, 0x36, 0x36, 0x36, 0x2a, 0x40, 0x47, 0x48,
+ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x99, 0x9b, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x47, 0x52,
+ 0x46, 0x4f, 0x37, 0x21, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x30, 0x34, 0x2a, 0x23,
+ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x22, 0x25, 0x39, 0x2c,
+ 0x36, 0x36, 0x36, 0x21, 0x31, 0x4e, 0x9a, 0x4c,
+ 0x47, 0x9b, 0x9b, 0x52, 0x46, 0x4f, 0x52, 0x9b,
+ 0x9b, 0x9b, 0x47, 0x4f, 0x45, 0x9a, 0x93, 0x93,
+ 0x3f, 0x93, 0x98, 0x28, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c, 0x26,
+ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x28,
+ 0x36, 0x36, 0x36, 0x22, 0x38, 0x98, 0x44, 0x99,
+ 0x9b, 0x48, 0x48, 0x9b, 0x4c, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x47, 0x52, 0x46, 0x43, 0x93,
+ 0x40, 0x40, 0x43, 0x53, 0x21, 0x23, 0x33, 0x23,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x2f, 0x32,
+ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x21, 0x24, 0x2b, 0x31, 0x36,
+ 0x36, 0x22, 0x36, 0x24, 0x9e, 0x4f, 0x9b, 0x48,
+ 0x48, 0x48, 0x48, 0x9b, 0x99, 0x9f, 0x52, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x47,
+ 0x4f, 0x9a, 0x3f, 0x46, 0x38, 0x36, 0x21, 0x30,
+ 0x26, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c,
+ 0x25, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x22, 0x26, 0x2e, 0x33, 0x36,
+ 0x25, 0x25, 0x36, 0x4d, 0x52, 0x48, 0x48, 0x48,
+ 0x47, 0x9f, 0x48, 0x48, 0x48, 0xa0, 0xa1, 0xa2,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x47, 0x44, 0x93, 0x43, 0x23, 0x36, 0x36,
+ 0x26, 0x24, 0x36, 0x36, 0x36, 0x36, 0x28, 0x2f,
+ 0x2a, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x23, 0x2a, 0x51, 0x24, 0x36,
+ 0x2a, 0x36, 0x28, 0x44, 0x48, 0x48, 0x48, 0x48,
+ 0xa3, 0xa4, 0x48, 0x48, 0x9f, 0xa5, 0xa6, 0x9f,
+ 0x48, 0x48, 0x48, 0xa2, 0xa7, 0x47, 0x48, 0x48,
+ 0x48, 0x48, 0x9b, 0x4b, 0x44, 0x37, 0x36, 0x23,
+ 0x28, 0x30, 0x22, 0x36, 0x36, 0x36, 0x36, 0x2d,
+ 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x21, 0x28, 0x2b, 0x34, 0x36, 0x25,
+ 0x24, 0x36, 0x4a, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0xa8, 0xa1, 0x48, 0x48, 0x9f, 0xa9, 0xa6, 0x9f,
+ 0x48, 0x48, 0xaa, 0xa1, 0xa5, 0x9f, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x9b, 0x52, 0x3f, 0x21, 0x30,
+ 0x35, 0x25, 0x30, 0x36, 0x36, 0x36, 0x36, 0x32,
+ 0x2d, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x22, 0x26, 0x2e, 0x35, 0x36, 0x2a,
+ 0x36, 0x24, 0x4f, 0x48, 0x52, 0x52, 0x48, 0x48,
+ 0xab, 0xac, 0xa0, 0x48, 0xad, 0xa6, 0xa6, 0x9f,
+ 0x48, 0xa2, 0xa9, 0xa6, 0xa2, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x47, 0x32, 0x30,
+ 0x2a, 0x23, 0x30, 0x23, 0x36, 0x36, 0x36, 0x21,
+ 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x21, 0x23, 0x2a, 0x51, 0x28, 0x28, 0x25,
+ 0x36, 0x3a, 0x48, 0x48, 0xae, 0xaf, 0x48, 0x48,
+ 0xad, 0xac, 0xa1, 0x9f, 0xa2, 0xa9, 0xa9, 0xa2,
+ 0x48, 0xab, 0x78, 0xa7, 0x48, 0x48, 0x48, 0x48,
+ 0x9f, 0x48, 0x48, 0x48, 0x48, 0x48, 0x38, 0x21,
+ 0x36, 0x36, 0x22, 0x27, 0x36, 0x36, 0x36, 0x36,
+ 0x2e, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x22, 0x25, 0x2c, 0x34, 0x36, 0x30, 0x21,
+ 0x23, 0x43, 0x48, 0x48, 0xb0, 0xb1, 0xb2, 0x9f,
+ 0x48, 0xb3, 0xa5, 0xb3, 0xab, 0xa9, 0xa9, 0xb3,
+ 0xb4, 0xa9, 0xb5, 0xb0, 0x48, 0x48, 0xa0, 0xa5,
+ 0xa1, 0xad, 0x48, 0x48, 0x48, 0x48, 0x94, 0x36,
+ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
+ 0x2a, 0x2e, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x21, 0x23, 0x2a, 0x51, 0x25, 0x21, 0x2a, 0x36,
+ 0x2e, 0x9b, 0x48, 0x48, 0x48, 0xb6, 0xb7, 0xa4,
+ 0xa2, 0xa7, 0xb5, 0x78, 0x6f, 0x6f, 0x6e, 0x6f,
+ 0xa9, 0xb5, 0xab, 0x48, 0x9f, 0xab, 0xa9, 0xa1,
+ 0xaa, 0x48, 0x48, 0x48, 0x48, 0x48, 0x98, 0x36,
+ 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
+ 0x22, 0x2f, 0x30, 0x22, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x22, 0x25, 0x2c, 0x34, 0x36, 0x24, 0x28, 0x36,
+ 0x54, 0x48, 0x48, 0x48, 0x48, 0xa2, 0xa8, 0xa1,
+ 0xa5, 0xa6, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f,
+ 0x6f, 0x78, 0xa5, 0xa0, 0xa0, 0x78, 0xa6, 0xa2,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
+ 0x36, 0x36, 0x36, 0x30, 0x36, 0x36, 0x36, 0x36,
+ 0x21, 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x28, 0x32, 0x2f, 0x28, 0x36, 0x27, 0x22, 0x21,
+ 0x43, 0x48, 0x4b, 0xa2, 0x9f, 0x48, 0xa2, 0xa1,
+ 0xb8, 0x6e, 0x6e, 0xb5, 0x78, 0x6f, 0x78, 0x78,
+ 0x6e, 0x6f, 0x78, 0xb5, 0xa6, 0xa1, 0xa0, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4b, 0x21,
+ 0x36, 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
+ 0x25, 0x2c, 0x39, 0x36, 0x36, 0x30, 0x22, 0x25,
+ 0x52, 0x48, 0xa3, 0xb1, 0xb6, 0xb3, 0xaa, 0xac,
+ 0x68, 0x68, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f,
+ 0x78, 0x6f, 0x6f, 0xb5, 0xa6, 0xb4, 0x48, 0x9f,
+ 0xb4, 0xb4, 0xa2, 0x9f, 0x48, 0x48, 0x4f, 0x21,
+ 0x36, 0x36, 0x22, 0x26, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
+ 0x30, 0x2d, 0x21, 0x36, 0x36, 0x32, 0x23, 0x2a,
+ 0x47, 0x48, 0xa2, 0xb6, 0xaf, 0xb9, 0xba, 0x68,
+ 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x78,
+ 0x6f, 0x6f, 0xa6, 0x6f, 0xb5, 0xa0, 0xaa, 0xa6,
+ 0xa6, 0xa9, 0xb2, 0xb3, 0x48, 0x48, 0x4c, 0x22,
+ 0x36, 0x36, 0x24, 0x23, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
+ 0x33, 0x2e, 0x36, 0x36, 0x23, 0x31, 0x27, 0x39,
+ 0x9b, 0x48, 0x48, 0x48, 0xb0, 0xb0, 0xba, 0xb8,
+ 0x68, 0x68, 0x69, 0x78, 0x6f, 0xb5, 0x6f, 0xb5,
+ 0x78, 0x78, 0x78, 0x78, 0x78, 0xa5, 0xbb, 0xa9,
+ 0xa5, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4c, 0x23,
+ 0x36, 0x36, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
+ 0x2b, 0x39, 0x36, 0x36, 0x36, 0x26, 0x32, 0x31,
+ 0x9b, 0x48, 0x48, 0x48, 0x48, 0x9f, 0xac, 0x68,
+ 0xbc, 0x6e, 0x6e, 0x6e, 0xb5, 0x6f, 0x6e, 0x6f,
+ 0x6f, 0x78, 0x78, 0xb5, 0xb5, 0xa5, 0x9f, 0x9f,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x46, 0x22,
+ 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
+ 0x35, 0x39, 0x36, 0x36, 0x36, 0x36, 0x26, 0x2d,
+ 0x9b, 0x48, 0x48, 0xb0, 0xaa, 0xb3, 0xbd, 0xb8,
+ 0xb8, 0x68, 0x6e, 0x6e, 0xb5, 0x6f, 0x78, 0x6e,
+ 0x78, 0x6f, 0x78, 0x78, 0xb5, 0xa9, 0xa2, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
+ 0x24, 0x27, 0xbe, 0x24, 0x25, 0x28, 0x21, 0x36,
+ 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x25,
+ 0x39, 0x4d, 0xbf, 0x84, 0x81, 0x57, 0x21, 0x39,
+ 0x52, 0x48, 0x48, 0x62, 0xb1, 0xc0, 0xc1, 0xc1,
+ 0xb8, 0xb8, 0x68, 0xbc, 0x6e, 0x6e, 0x6e, 0x78,
+ 0x78, 0x78, 0x78, 0x6e, 0x78, 0xa9, 0xa0, 0xab,
+ 0xb3, 0xa2, 0x48, 0x48, 0x48, 0x48, 0x53, 0x28,
+ 0x23, 0x36, 0x36, 0x36, 0x21, 0x28, 0x2c, 0x30,
+ 0x21, 0x38, 0x33, 0x28, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x21, 0x22, 0x22, 0x28, 0x30,
+ 0x2d, 0xc2, 0x7a, 0xc3, 0xc4, 0xc4, 0x7f, 0x22,
+ 0x51, 0x52, 0x48, 0x48, 0xb0, 0xaa, 0xa8, 0xbd,
+ 0x68, 0xb8, 0xb8, 0x68, 0x68, 0x6e, 0x6e, 0x6f,
+ 0x6e, 0x6e, 0xb5, 0x6e, 0x78, 0xab, 0xab, 0xb5,
+ 0x78, 0xa6, 0xb3, 0xc5, 0xac, 0xac, 0xc6, 0x61,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x30, 0x32,
+ 0x25, 0x4d, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x21, 0x23, 0x24, 0x26, 0x30, 0x33, 0x31,
+ 0x4d, 0x91, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0x5a,
+ 0x21, 0x2e, 0x46, 0x48, 0x48, 0x48, 0xb0, 0x64,
+ 0xc1, 0xb8, 0xb8, 0xb8, 0x68, 0x71, 0x6e, 0x6e,
+ 0x6f, 0x71, 0x6f, 0x6f, 0xa6, 0xa0, 0x9f, 0xb4,
+ 0xb4, 0xa0, 0xa1, 0xb7, 0xc7, 0x69, 0x66, 0xc8,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x26, 0x25,
+ 0x83, 0xc9, 0x2c, 0x25, 0x21, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x21, 0x28, 0x30, 0x35, 0x2d, 0x2f, 0x37, 0x4a,
+ 0x60, 0x85, 0xca, 0xcb, 0xc4, 0xc4, 0xc4, 0x82,
+ 0x86, 0x36, 0x32, 0x3f, 0xa2, 0xa4, 0xa8, 0xa9,
+ 0xb8, 0xb8, 0xb8, 0xb8, 0x68, 0x6e, 0x6e, 0x6e,
+ 0x6e, 0x71, 0x6f, 0x71, 0xa6, 0xb4, 0x9f, 0x9f,
+ 0x48, 0x48, 0x48, 0xcc, 0xc3, 0xc7, 0xcd, 0xce,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x57,
+ 0x77, 0x66, 0x34, 0x27, 0x22, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x23, 0x30, 0x31, 0xcf, 0x91, 0x7e, 0x90, 0x90,
+ 0x8b, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0x5d, 0xd0, 0x36, 0x24, 0xd1, 0xb1, 0xaf, 0xaa,
+ 0xba, 0xb8, 0x68, 0x68, 0x68, 0x71, 0x6e, 0x6e,
+ 0x6e, 0x6f, 0x6e, 0x78, 0xa1, 0xa9, 0xa1, 0xb0,
+ 0x9f, 0x9b, 0x99, 0xcc, 0x64, 0x5c, 0x8b, 0xd0,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x73, 0x5d,
+ 0x82, 0x5c, 0xd2, 0x2a, 0x23, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x24, 0x2b, 0xcf, 0x8b, 0x5b, 0x76, 0x5b, 0x5b,
+ 0x7b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc7, 0x5e, 0x22, 0x36, 0x21, 0x3a, 0x99, 0x48,
+ 0xa2, 0xa8, 0xb7, 0xc1, 0xb8, 0x68, 0x68, 0xbc,
+ 0x68, 0x6e, 0xb5, 0xb4, 0xb4, 0xab, 0xb5, 0xa1,
+ 0xb0, 0x4f, 0x3f, 0xd3, 0x7b, 0x7b, 0x85, 0x80,
+ 0xbe, 0x36, 0x36, 0x36, 0x21, 0xd4, 0x7e, 0x7b,
+ 0x64, 0x64, 0xd5, 0x35, 0x24, 0x21, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
+ 0x26, 0x31, 0xd6, 0x5b, 0x64, 0xc3, 0xc3, 0xcb,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0x66, 0xd7, 0x36, 0x36, 0x36, 0x2c, 0x4b,
+ 0xd8, 0xd9, 0xb3, 0xa8, 0xbd, 0xbd, 0xbd, 0xbd,
+ 0xa9, 0xab, 0xb3, 0xa5, 0xa2, 0x9f, 0xa2, 0xa1,
+ 0x6a, 0x9a, 0x3f, 0xda, 0x76, 0x76, 0x7a, 0x63,
+ 0xdb, 0xdc, 0x86, 0xdc, 0xdd, 0x90, 0x5b, 0x64,
+ 0xc3, 0xc3, 0xde, 0x2d, 0x27, 0x23, 0x21, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x26, 0x2d, 0x91, 0x5b, 0x64, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc7, 0x83, 0xce, 0x36, 0x36, 0x36, 0x30,
+ 0xb1, 0xd9, 0x48, 0xa1, 0xb2, 0xb0, 0xb0, 0xb3,
+ 0xa2, 0x48, 0xa7, 0xbd, 0xa9, 0xa2, 0x48, 0x9f,
+ 0xaa, 0x9a, 0x3f, 0xb1, 0x5b, 0x7b, 0xdf, 0x85,
+ 0x7e, 0x90, 0x63, 0x90, 0x85, 0x5b, 0xc3, 0xc4,
+ 0xc4, 0xcb, 0x5d, 0xd5, 0x39, 0x26, 0x23, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
+ 0x26, 0x2d, 0xe0, 0xdf, 0x64, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc7, 0x88, 0x36, 0x36, 0x36, 0x36,
+ 0x2d, 0x9b, 0x48, 0xb9, 0xaf, 0xa2, 0xa2, 0xb9,
+ 0xa8, 0x9f, 0x48, 0xa7, 0xb7, 0xd9, 0x48, 0x48,
+ 0x9b, 0x45, 0x3f, 0xe1, 0x6d, 0x7b, 0xca, 0xdf,
+ 0x7a, 0x8b, 0x8b, 0x7a, 0x5b, 0x64, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc3, 0xe2, 0x37, 0x35, 0x26, 0x23,
+ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
+ 0x26, 0x2e, 0xe0, 0x7a, 0x7b, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc7, 0x72, 0x73, 0x36, 0x36, 0x36,
+ 0x24, 0x52, 0x48, 0xa3, 0xaf, 0x9f, 0x48, 0xb6,
+ 0xaf, 0xa2, 0x48, 0x9f, 0xe3, 0xd8, 0x48, 0x48,
+ 0x48, 0x46, 0x42, 0xd6, 0x7a, 0x7b, 0x64, 0x7b,
+ 0x76, 0x5b, 0x5b, 0x76, 0x7b, 0xc3, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xcb, 0x64, 0xe2, 0x4d, 0x2c, 0x27,
+ 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x25, 0x31, 0xe4, 0x8b, 0x7b, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc7, 0x89, 0xbe, 0x36, 0x36,
+ 0x32, 0x47, 0x48, 0x4f, 0xa0, 0x48, 0x48, 0xe3,
+ 0x92, 0x9f, 0x48, 0x9f, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x4b, 0x2f, 0x8f, 0x7a, 0x7b, 0xc3, 0xcb,
+ 0xc3, 0x64, 0x64, 0xc3, 0xc3, 0xcb, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x5d, 0xe5, 0x2c,
+ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x25, 0x31, 0xe4, 0x85, 0x7b, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x57, 0x27, 0x4d,
+ 0x4b, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x99, 0x34, 0xbe, 0xdb, 0x7a, 0x7b, 0xc3, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0xe4,
+ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
+ 0x26, 0x2d, 0xe4, 0x85, 0x7b, 0xcb, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc7, 0x5f, 0x92, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x44,
+ 0x35, 0x36, 0xce, 0xdd, 0x7a, 0x7b, 0xcb, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0xc3, 0xe1,
+ 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
+ 0x30, 0x2f, 0xd6, 0x8b, 0x7b, 0xcb, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x89, 0x45,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x4e, 0x25,
+ 0x36, 0x36, 0x61, 0xdb, 0x6d, 0x64, 0xcb, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0xdf, 0xe5,
+ 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
+ 0x33, 0xe6, 0x63, 0xdf, 0xc3, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x72, 0x81, 0xe7,
+ 0x46, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
+ 0x48, 0x48, 0x48, 0x48, 0x3f, 0x2c, 0x36, 0x36,
+ 0x36, 0x36, 0xe8, 0x8f, 0x6d, 0x64, 0xcb, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc3, 0xca, 0x8b, 0xcf, 0x2c,
+ 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
+ 0x35, 0x96, 0x75, 0xca, 0xc3, 0xcb, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0x81, 0xdb,
+ 0x73, 0x3b, 0x44, 0x9b, 0x48, 0x48, 0x48, 0x9b,
+ 0x99, 0x43, 0x94, 0x2c, 0x21, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x73, 0xdb, 0x7a, 0x7b, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0x64, 0x76, 0x7a, 0x91, 0xd5, 0x31, 0x30,
+ 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
+ 0x39, 0x97, 0x75, 0xdf, 0x7b, 0x64, 0xc3, 0xc3,
+ 0xcb, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x7b, 0x7a, 0xe9,
+ 0xea, 0x36, 0x21, 0x26, 0x2b, 0x39, 0x33, 0x30,
+ 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x21, 0xea, 0xdd, 0x8b, 0x7b, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x64, 0x64,
+ 0x76, 0x85, 0xe0, 0xd5, 0x34, 0x2b, 0x27, 0x28,
+ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
+ 0x33, 0xeb, 0x63, 0x7e, 0x7a, 0x6d, 0xdf, 0x5b,
+ 0x76, 0x7b, 0x64, 0x64, 0xc3, 0xcb, 0xc4, 0xc4,
+ 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x76, 0x85, 0xdb,
+ 0x79, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x21, 0xec, 0xdd, 0x75, 0x76, 0xc3, 0xc4,
+ 0xc4, 0xc4, 0xcb, 0xc3, 0x64, 0x76, 0xdf, 0x8b,
+ 0xd6, 0xd5, 0x2f, 0x35, 0x30, 0x24, 0x22, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
+ 0x27, 0x31, 0xed, 0xeb, 0xdd, 0x74, 0x63, 0x90,
+ 0x7e, 0x75, 0x8b, 0x6d, 0xdf, 0x76, 0x64, 0xc3,
+ 0xcb, 0xcb, 0xcb, 0xcb, 0x64, 0x7a, 0x84, 0xee,
+ 0x79, 0xbe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x21, 0xea, 0xee, 0x63, 0x6d, 0x7b, 0x64,
+ 0xcb, 0xc3, 0x64, 0x7b, 0xdf, 0x75, 0x63, 0x96,
+ 0x38, 0x39, 0x2a, 0x24, 0x23, 0x21, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x28, 0x27, 0x35, 0x2d, 0x41, 0xd5, 0xe7, 0x8f,
+ 0xdb, 0xdd, 0xe9, 0x74, 0x84, 0x90, 0x85, 0x6d,
+ 0x5b, 0x7b, 0x7b, 0xca, 0x6d, 0x90, 0xdb, 0xef,
+ 0xec, 0x22, 0x36, 0x36, 0x28, 0x30, 0x30, 0x30,
+ 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x25, 0x36,
+ 0x36, 0x21, 0xd4, 0x80, 0xe9, 0x7e, 0x6d, 0x76,
+ 0xca, 0x76, 0x6d, 0x85, 0x63, 0xdb, 0xd5, 0x34,
+ 0x33, 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x21, 0x23, 0x24, 0x27, 0x2a, 0x35, 0x2e, 0x2f,
+ 0x41, 0xf0, 0xf1, 0x6c, 0x80, 0xee, 0xdb, 0x74,
+ 0x84, 0x90, 0x75, 0x7e, 0x74, 0x8f, 0xef, 0x79,
+ 0xe8, 0x2b, 0x9d, 0x41, 0x2f, 0x34, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x34, 0x2f, 0x38,
+ 0x4d, 0x37, 0xf2, 0xf3, 0x8f, 0x74, 0x63, 0x7e,
+ 0x75, 0x7e, 0x63, 0xe9, 0x88, 0xe6, 0x31, 0x2a,
+ 0x24, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x21, 0x22, 0x23, 0x24, 0x26, 0x30,
+ 0x33, 0x39, 0x2e, 0x51, 0x41, 0xd2, 0x6c, 0xf3,
+ 0x80, 0xee, 0xee, 0xee, 0xf4, 0xf3, 0xd7, 0xf5,
+ 0x41, 0x34, 0x35, 0x32, 0x30, 0x27, 0x27, 0x27,
+ 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x30, 0x2a,
+ 0x2b, 0x34, 0xf6, 0xec, 0xf7, 0x8f, 0xdd, 0xe9,
+ 0xe9, 0xdd, 0xee, 0x6c, 0x41, 0x39, 0x27, 0x28,
+ 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22,
+ 0x28, 0x24, 0x26, 0x2a, 0x33, 0x2c, 0x2f, 0x41,
+ 0xf8, 0xd7, 0x79, 0x79, 0x79, 0xec, 0xf9, 0x51,
+ 0x39, 0x30, 0x24, 0x23, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x23,
+ 0x24, 0x2a, 0x31, 0xfa, 0xea, 0x79, 0xf3, 0x80,
+ 0xf7, 0xdc, 0xfb, 0x2f, 0x35, 0x26, 0x23, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x21, 0x22, 0x23, 0x28, 0x25, 0x30, 0x2b,
+ 0x31, 0x2f, 0xf6, 0xfa, 0xfa, 0x2f, 0x2e, 0x33,
+ 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x21, 0x28, 0x27, 0x35, 0x34, 0xfa, 0xfa, 0xfa,
+ 0xfc, 0xf6, 0x2e, 0x33, 0x25, 0x23, 0x21, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x23, 0x28,
+ 0x26, 0x30, 0x32, 0x2b, 0x33, 0x2a, 0x26, 0x28,
+ 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x21, 0x23, 0x25, 0x30, 0x33, 0x35, 0x35,
+ 0x2b, 0x2a, 0x26, 0x28, 0x22, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
+ 0x21, 0x22, 0x23, 0x28, 0x28, 0x23, 0x22, 0x21,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x21, 0x23, 0x28, 0x24, 0x24,
+ 0x28, 0x23, 0x22, 0x21, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+};
+
+unsigned char linux_logo16[1];
+
+#endif /* INCLUDE_LINUX_LOGO_DATA */
+
+#include <linux/linux_logo.h>
+
diff --git a/include/asm-nios2nommu/local.h b/include/asm-nios2nommu/local.h
new file mode 100644
index 0000000..5ed7d1c
--- /dev/null
+++ b/include/asm-nios2nommu/local.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2NOMMU_LOCAL_H
+#define __NIOS2NOMMU_LOCAL_H
+
+#include <asm-generic/local.h>
+
+#endif /* __NIOS2NOMMU_LOCAL_H */
diff --git a/include/asm-nios2nommu/mc146818rtc.h b/include/asm-nios2nommu/mc146818rtc.h
new file mode 100644
index 0000000..3492fc0
--- /dev/null
+++ b/include/asm-nios2nommu/mc146818rtc.h
@@ -0,0 +1,29 @@
+/*
+ * Machine dependent access functions for RTC registers.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef _NIOS2_MC146818RTC_H
+#define _NIOS2_MC146818RTC_H
+
+/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
+
+#endif /* _NIOS2_MC146818RTC_H */
diff --git a/include/asm-nios2nommu/mman.h b/include/asm-nios2nommu/mman.h
new file mode 100644
index 0000000..516ab26
--- /dev/null
+++ b/include/asm-nios2nommu/mman.h
@@ -0,0 +1,68 @@
+/*
+ * Copied from the m68k port.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2_MMAN_H__
+#define __NIOS2_MMAN_H__
+
+#define PROT_READ 0x1 /* page can be read */
+#define PROT_WRITE 0x2 /* page can be written */
+#define PROT_EXEC 0x4 /* page can be executed */
+#define PROT_SEM 0x8 /* page may be used for atomic ops */
+#define PROT_NONE 0x0 /* page can not be accessed */
+#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
+#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
+
+#define MAP_SHARED 0x01 /* Share changes */
+#define MAP_PRIVATE 0x02 /* Changes are private */
+#define MAP_TYPE 0x0f /* Mask for type of mapping */
+#define MAP_FIXED 0x10 /* Interpret addr exactly */
+#define MAP_ANONYMOUS 0x20 /* don't use a file */
+
+#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
+#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
+#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
+#define MAP_LOCKED 0x2000 /* pages are locked */
+#define MAP_NORESERVE 0x4000 /* don't check for reservations */
+#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
+#define MAP_NONBLOCK 0x10000 /* do not block on IO */
+
+#define MS_ASYNC 1 /* sync memory asynchronously */
+#define MS_INVALIDATE 2 /* invalidate the caches */
+#define MS_SYNC 4 /* synchronous memory sync */
+
+#define MCL_CURRENT 1 /* lock all current mappings */
+#define MCL_FUTURE 2 /* lock all future mappings */
+
+#define MADV_NORMAL 0x0 /* default page-in behavior */
+#define MADV_RANDOM 0x1 /* page-in minimum required */
+#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
+#define MADV_WILLNEED 0x3 /* pre-fault pages */
+#define MADV_DONTNEED 0x4 /* discard these pages */
+
+/* compatibility flags */
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FILE 0
+
+#endif /* __NIOS2_MMAN_H__ */
+
diff --git a/include/asm-nios2nommu/mmu.h b/include/asm-nios2nommu/mmu.h
new file mode 100644
index 0000000..b6e579d
--- /dev/null
+++ b/include/asm-nios2nommu/mmu.h
@@ -0,0 +1,36 @@
+/*
+ *
+ * Taken from the m68knommu.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2NOMMU_MMU_H
+#define __NIOS2NOMMU_MMU_H
+
+/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
+
+typedef struct {
+ struct vm_list_struct *vmlist;
+ unsigned long end_brk;
+} mm_context_t;
+
+#endif /* __NIOS2NOMMU_MMU_H */
diff --git a/include/asm-nios2nommu/mmu_context.h b/include/asm-nios2nommu/mmu_context.h
new file mode 100644
index 0000000..795cd09
--- /dev/null
+++ b/include/asm-nios2nommu/mmu_context.h
@@ -0,0 +1,57 @@
+/*
+ *
+ * Taken from the m68knommu.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2NOMMU_MMU_CONTEXT_H
+#define __NIOS2NOMMU_MMU_CONTEXT_H
+
+#include <asm/setup.h>
+#include <asm/page.h>
+#include <asm/pgalloc.h>
+
+static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
+{
+}
+
+extern inline int
+init_new_context(struct task_struct *tsk, struct mm_struct *mm)
+{
+ // mm->context = virt_to_phys(mm->pgd);
+ return(0);
+}
+
+#define destroy_context(mm) do { } while(0)
+
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
+{
+}
+
+#define deactivate_mm(tsk,mm) do { } while (0)
+
+extern inline void activate_mm(struct mm_struct *prev_mm,
+ struct mm_struct *next_mm)
+{
+}
+
+#endif
diff --git a/include/asm-nios2nommu/module.h b/include/asm-nios2nommu/module.h
new file mode 100644
index 0000000..864f335
--- /dev/null
+++ b/include/asm-nios2nommu/module.h
@@ -0,0 +1,36 @@
+#ifndef _NIOS2_MODULE_H
+#define _NIOS2_MODULE_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/module.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+struct mod_arch_specific
+{
+};
+
+#define Elf_Shdr Elf32_Shdr
+#define Elf_Sym Elf32_Sym
+#define Elf_Ehdr Elf32_Ehdr
+
+#endif /* _NIOS_MODULE_H */
diff --git a/include/asm-nios2nommu/msgbuf.h b/include/asm-nios2nommu/msgbuf.h
new file mode 100644
index 0000000..4d090f7
--- /dev/null
+++ b/include/asm-nios2nommu/msgbuf.h
@@ -0,0 +1,56 @@
+/*
+ * Taken from the m68k.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2_MSGBUF_H
+#define _NIOS2_MSGBUF_H
+
+/*
+ * The msqid64_ds structure for nios2 architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct msqid64_ds {
+ struct ipc64_perm msg_perm;
+ __kernel_time_t msg_stime; /* last msgsnd time */
+ unsigned long __unused1;
+ __kernel_time_t msg_rtime; /* last msgrcv time */
+ unsigned long __unused2;
+ __kernel_time_t msg_ctime; /* last change time */
+ unsigned long __unused3;
+ unsigned long msg_cbytes; /* current number of bytes on queue */
+ unsigned long msg_qnum; /* number of messages in queue */
+ unsigned long msg_qbytes; /* max number of bytes on queue */
+ __kernel_pid_t msg_lspid; /* pid of last msgsnd */
+ __kernel_pid_t msg_lrpid; /* last receive pid */
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+#endif /* _NIOS2_MSGBUF_H */
+
diff --git a/include/asm-nios2nommu/mutex.h b/include/asm-nios2nommu/mutex.h
new file mode 100644
index 0000000..458c1f7
--- /dev/null
+++ b/include/asm-nios2nommu/mutex.h
@@ -0,0 +1,9 @@
+/*
+ * Pull in the generic implementation for the mutex fastpath.
+ *
+ * TODO: implement optimized primitives instead, or leave the generic
+ * implementation in place, or pick the atomic_xchg() based generic
+ * implementation. (see asm-generic/mutex-xchg.h for details)
+ */
+
+#include <asm-generic/mutex-dec.h>
diff --git a/include/asm-nios2nommu/namei.h b/include/asm-nios2nommu/namei.h
new file mode 100644
index 0000000..d925c4e
--- /dev/null
+++ b/include/asm-nios2nommu/namei.h
@@ -0,0 +1,36 @@
+/*
+ * linux/include/asm-nios/namei.h
+ * Moved from m68k version
+ * Included from linux/fs/namei.c
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __NIOS2_NAMEI_H
+#define __NIOS2_NAMEI_H
+
+/* This dummy routine maybe changed to something useful
+ * for /usr/gnemul/ emulation stuff.
+ * Look at asm-sparc/namei.h for details.
+ */
+
+#define __emul_prefix() NULL
+
+#endif
diff --git a/include/asm-nios2nommu/ndma.h b/include/asm-nios2nommu/ndma.h
new file mode 100644
index 0000000..6b4604d
--- /dev/null
+++ b/include/asm-nios2nommu/ndma.h
@@ -0,0 +1,64 @@
+#ifndef __NDMA_H__
+ #define __NDMA_H__
+
+ #ifndef __ASSEMBLY__
+
+// DMA Registers
+typedef volatile struct
+{
+ int np_dmastatus; // status register
+ int np_dmareadaddress; // read address
+ int np_dmawriteaddress; // write address
+ int np_dmalength; // length in bytes
+ int np_dmareserved1; // reserved
+ int np_dmareserved2; // reserved
+ int np_dmacontrol; // control register
+ int np_dmareserved3; // control register alternate
+} np_dma;
+
+// DMA Register Bits
+enum
+{
+ np_dmacontrol_byte_bit = 0, // Byte transaction
+ np_dmacontrol_hw_bit = 1, // Half-word transaction
+ np_dmacontrol_word_bit = 2, // Word transaction
+ np_dmacontrol_go_bit = 3, // enable execution
+ np_dmacontrol_i_en_bit = 4, // enable interrupt
+ np_dmacontrol_reen_bit = 5, // Enable read end-of-packet
+ np_dmacontrol_ween_bit = 6, // Enable write end-of-packet
+ np_dmacontrol_leen_bit = 7, // Enable length=0 transaction end
+ np_dmacontrol_rcon_bit = 8, // Read from a fixed address
+ np_dmacontrol_wcon_bit = 9, // Write to a fixed address
+ np_dmacontrol_doubleword_bit = 10, // Double-word transaction
+ np_dmacontrol_quadword_bit = 11, // Quad-word transaction
+
+ np_dmastatus_done_bit = 0, // 1 when done. Status write clears.
+ np_dmastatus_busy_bit = 1, // 1 when busy.
+ np_dmastatus_reop_bit = 2, // read-eop received
+ np_dmastatus_weop_bit = 3, // write-eop received
+ np_dmastatus_len_bit = 4, // requested length transacted
+
+ np_dmacontrol_byte_mask = (1 << 0), // Byte transaction
+ np_dmacontrol_hw_mask = (1 << 1), // Half-word transaction
+ np_dmacontrol_word_mask = (1 << 2), // Word transaction
+ np_dmacontrol_go_mask = (1 << 3), // enable execution
+ np_dmacontrol_i_en_mask = (1 << 4), // enable interrupt
+ np_dmacontrol_reen_mask = (1 << 5), // Enable read end-of-packet
+ np_dmacontrol_ween_mask = (1 << 6), // Enable write end-of-packet
+ np_dmacontrol_leen_mask = (1 << 7), // Enable length=0 transaction end
+ np_dmacontrol_rcon_mask = (1 << 8), // Read from a fixed address
+ np_dmacontrol_wcon_mask = (1 << 9), // Write to a fixed address
+ np_dmacontrol_doubleword_mask = (1 << 10), // Double-word transaction
+ np_dmacontrol_quadword_mask = (1 << 11), // Quad-word transaction
+
+ np_dmastatus_done_mask = (1 << 0), // 1 when done. Status write clears.
+ np_dmastatus_busy_mask = (1 << 1), // 1 when busy.
+ np_dmastatus_reop_mask = (1 << 2), // read-eop received
+ np_dmastatus_weop_mask = (1 << 3), // write-eop received
+ np_dmastatus_len_mask = (1 << 4), // requested length transacted
+};
+
+ #endif /* __ASSEMBLY__ */
+
+#endif
+/* End of File */
diff --git a/include/asm-nios2nommu/nios.h b/include/asm-nios2nommu/nios.h
new file mode 100644
index 0000000..df17672
--- /dev/null
+++ b/include/asm-nios2nommu/nios.h
@@ -0,0 +1,7 @@
+#ifndef __NIOS_H__
+#define __NIOS_H__
+
+#include <nios2_system.h>
+
+#endif
+
diff --git a/include/asm-nios2nommu/page.h b/include/asm-nios2nommu/page.h
new file mode 100644
index 0000000..764e73c
--- /dev/null
+++ b/include/asm-nios2nommu/page.h
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2_PAGE_H
+#define _NIOS2_PAGE_H
+
+/* copied from m68knommu arch */
+
+/* PAGE_SHIFT determines the page size */
+
+#define PAGE_SHIFT (12)
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+#ifdef __KERNEL__
+
+#include <asm/setup.h>
+
+#if PAGE_SHIFT < 13
+#define THREAD_SIZE (8192)
+#else
+#define THREAD_SIZE PAGE_SIZE
+#endif
+
+#ifndef __ASSEMBLY__
+
+#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
+#define free_user_page(page, addr) free_page(addr)
+
+#define clear_page(page) memset((page), 0, PAGE_SIZE)
+#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
+
+#define clear_user_page(page, vaddr, pg) clear_page(page)
+#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
+
+/*
+ * These are used to make use of C type-checking..
+ */
+typedef struct { unsigned long pte; } pte_t;
+typedef struct { unsigned long pmd[16]; } pmd_t;
+typedef struct { unsigned long pgd; } pgd_t;
+typedef struct { unsigned long pgprot; } pgprot_t;
+
+#define pte_val(x) ((x).pte)
+#define pmd_val(x) ((&x)->pmd[0])
+#define pgd_val(x) ((x).pgd)
+#define pgprot_val(x) ((x).pgprot)
+
+#define __pte(x) ((pte_t) { (x) } )
+#define __pmd(x) ((pmd_t) { (x) } )
+#define __pgd(x) ((pgd_t) { (x) } )
+#define __pgprot(x) ((pgprot_t) { (x) } )
+
+/* to align the pointer to the (next) page boundary */
+#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
+
+extern unsigned long memory_start;
+extern unsigned long memory_end;
+
+#endif /* !__ASSEMBLY__ */
+#include <asm/nios.h>
+#define PAGE_OFFSET ((int)(nasys_program_mem))
+
+#ifndef __ASSEMBLY__
+
+#define __pa(vaddr) virt_to_phys((void *)(vaddr))
+#define __va(paddr) phys_to_virt((unsigned long)(paddr))
+
+#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
+
+#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
+#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
+
+#define virt_to_page(addr) ((void*) addr < (void*) memory_end ? mem_map + \
+ (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) : 0UL)
+#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
+#define VALID_PAGE(page) (((page) - mem_map) < max_mapnr)
+
+#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
+#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
+#define pfn_valid(pfn) ((pfn) < max_mapnr)
+
+#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
+ ((void *)(kaddr) < (void *)memory_end))
+
+#ifdef CONFIG_NO_KERNEL_MSG
+#define BUG_PRINT()
+#else
+#define BUG_PRINT() printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__)
+#endif
+
+#ifdef na_cpu_oci_core
+#define BUG_PANIC() asm volatile ("break") /* drop to debugger */
+#else
+// #define BUG_PANIC() while(1)
+#define BUG_PANIC() panic("BUG!")
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+#include <asm-generic/page.h>
+
+#endif /* __KERNEL__ */
+
+#endif /* _NIOS2_PAGE_H */
diff --git a/include/asm-nios2nommu/param.h b/include/asm-nios2nommu/param.h
new file mode 100644
index 0000000..e75a355
--- /dev/null
+++ b/include/asm-nios2nommu/param.h
@@ -0,0 +1,49 @@
+#ifndef _NIOS_PARAM_H
+#define _NIOS_PARAM_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/param.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#ifndef HZ
+#define HZ 100
+#endif
+
+#ifdef __KERNEL__
+#define USER_HZ HZ
+#define CLOCKS_PER_SEC (USER_HZ)
+#endif
+
+#define EXEC_PAGESIZE 4096
+
+#ifndef NGROUPS
+#define NGROUPS 32
+#endif
+
+#ifndef NOGROUP
+#define NOGROUP (-1)
+#endif
+
+#define MAXHOSTNAMELEN 64 /* max length of hostname */
+
+#endif
diff --git a/include/asm-nios2nommu/pci.h b/include/asm-nios2nommu/pci.h
new file mode 100644
index 0000000..be3b3b2
--- /dev/null
+++ b/include/asm-nios2nommu/pci.h
@@ -0,0 +1,126 @@
+#ifndef __ASM_SH_PCI_H
+#define __ASM_SH_PCI_H
+
+#ifdef __KERNEL__
+
+#include <linux/dma-mapping.h>
+
+/* Can be used to override the logic in pci_scan_bus for skipping
+ already-configured bus numbers - to be used for buggy BIOSes
+ or architectures with incomplete PCI setup by the loader */
+
+#define pcibios_assign_all_busses() 1
+#define pcibios_scan_all_fns(a, b) 0
+
+/*
+ * A board can define one or more PCI channels that represent built-in (or
+ * external) PCI controllers.
+ */
+struct pci_channel {
+ struct pci_ops *pci_ops;
+ struct resource *io_resource;
+ struct resource *mem_resource;
+ int first_devfn;
+ int last_devfn;
+};
+
+/*
+ * Each board initializes this array and terminates it with a NULL entry.
+ */
+extern struct pci_channel board_pci_channels[];
+
+#define PCIBIOS_MIN_IO board_pci_channels->io_resource->start
+#define PCIBIOS_MIN_MEM board_pci_channels->mem_resource->start
+
+struct pci_dev;
+
+extern void pcibios_set_master(struct pci_dev *dev);
+
+static inline void pcibios_penalize_isa_irq(int irq, int active)
+{
+ /* We don't do dynamic PCI IRQ allocation */
+}
+
+/* Dynamic DMA mapping stuff.
+ * SuperH has everything mapped statically like x86.
+ */
+
+/* The PCI address space does equal the physical memory
+ * address space. The networking and block device layers use
+ * this boolean for bounce buffer decisions.
+ */
+#define PCI_DMA_BUS_IS_PHYS (1)
+
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <asm/scatterlist.h>
+#include <linux/string.h>
+#include <asm/io.h>
+
+/* pci_unmap_{single,page} being a nop depends upon the
+ * configuration.
+ */
+#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
+ dma_addr_t ADDR_NAME;
+#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
+ __u32 LEN_NAME;
+#define pci_unmap_addr(PTR, ADDR_NAME) \
+ ((PTR)->ADDR_NAME)
+#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
+ (((PTR)->ADDR_NAME) = (VAL))
+#define pci_unmap_len(PTR, LEN_NAME) \
+ ((PTR)->LEN_NAME)
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
+ (((PTR)->LEN_NAME) = (VAL))
+#else
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
+#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
+#define pci_unmap_addr(PTR, ADDR_NAME) (0)
+#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
+#define pci_unmap_len(PTR, LEN_NAME) (0)
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
+#endif
+
+/* Not supporting more than 32-bit PCI bus addresses now, but
+ * must satisfy references to this function. Change if needed.
+ */
+#define pci_dac_dma_supported(pci_dev, mask) (0)
+
+/* These macros should be used after a pci_map_sg call has been done
+ * to get bus addresses of each of the SG entries and their lengths.
+ * You should only work with the number of sg entries pci_map_sg
+ * returns, or alternatively stop on the first sg_dma_len(sg) which
+ * is 0.
+ */
+#define sg_dma_address(sg) (virt_to_bus((sg)->dma_address))
+#define sg_dma_len(sg) ((sg)->length)
+
+#ifdef CONFIG_PCI
+static inline void pci_dma_burst_advice(struct pci_dev *pdev,
+ enum pci_dma_burst_strategy *strat,
+ unsigned long *strategy_parameter)
+{
+ *strat = PCI_DMA_BURST_INFINITY;
+ *strategy_parameter = ~0UL;
+}
+#endif
+
+/* Board-specific fixup routines. */
+extern void pcibios_fixup(void);
+extern void pcibios_fixup_irqs(void);
+
+#ifdef CONFIG_PCI_AUTO
+extern int pciauto_assign_resources(int busno, struct pci_channel *hose);
+#endif
+
+#endif /* __KERNEL__ */
+
+/* generic pci stuff */
+#include <asm-generic/pci.h>
+
+/* generic DMA-mapping stuff */
+#include <asm-generic/pci-dma-compat.h>
+
+#endif /* __ASM_SH_PCI_H */
+
diff --git a/include/asm-nios2nommu/percpu.h b/include/asm-nios2nommu/percpu.h
new file mode 100644
index 0000000..cd6d4a3
--- /dev/null
+++ b/include/asm-nios2nommu/percpu.h
@@ -0,0 +1,30 @@
+#ifndef __ARCH_NIOS2NOMMU_PERCPU__
+#define __ARCH_NIOS2NOMMU_PERCPU__
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/percpu.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm-generic/percpu.h>
+
+#endif /* __ARCH_NIOS2NOMMU_PERCPU__ */
diff --git a/include/asm-nios2nommu/pgalloc.h b/include/asm-nios2nommu/pgalloc.h
new file mode 100644
index 0000000..a997ada
--- /dev/null
+++ b/include/asm-nios2nommu/pgalloc.h
@@ -0,0 +1,32 @@
+#ifndef _NIOS2NOMMU_PGALLOC_H
+#define _NIOS2NOMMU_PGALLOC_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/pgalloc.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/setup.h>
+
+#define check_pgt_cache() do { } while (0)
+
+#endif /* _NIOS2NOMMU_PGALLOC_H */
diff --git a/include/asm-nios2nommu/pgtable.h b/include/asm-nios2nommu/pgtable.h
new file mode 100644
index 0000000..4124a33
--- /dev/null
+++ b/include/asm-nios2nommu/pgtable.h
@@ -0,0 +1,112 @@
+#ifndef _NIOS_PGTABLE_H
+#define _NIOS_PGTABLE_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/pgtable.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+#include <asm-generic/4level-fixup.h>
+
+//vic - this bit copied from m68knommu version
+#include <asm/setup.h>
+#include <asm/io.h>
+#include <linux/sched.h>
+
+typedef pte_t *pte_addr_t;
+
+#define pgd_present(pgd) (1) /* pages are always present on NO_MM */
+#define pgd_none(pgd) (0)
+#define pgd_bad(pgd) (0)
+#define pgd_clear(pgdp)
+#define kern_addr_valid(addr) (1)
+#define pmd_offset(a, b) ((void *)0)
+
+#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
+#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
+#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
+#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
+#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
+//vic - this bit copied from m68knommu version
+
+extern void paging_init(void);
+#define swapper_pg_dir ((pgd_t *) 0)
+
+#define __swp_type(x) (0)
+#define __swp_offset(x) (0)
+#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
+#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
+#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
+
+static inline int pte_file(pte_t pte) { return 0; }
+
+/*
+ * ZERO_PAGE is a global shared page that is always zero: used
+ * for zero-mapped memory areas etc..
+ */
+#define ZERO_PAGE(vaddr) (virt_to_page(0))
+
+extern unsigned int kobjsize(const void *objp);
+extern int is_in_rom(unsigned long);
+
+/*
+ * No page table caches to initialise
+ */
+#define pgtable_cache_init() do { } while (0)
+
+#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
+ remap_pfn_range(vma, vaddr, pfn, size, prot)
+
+extern inline void flush_cache_mm(struct mm_struct *mm)
+{
+}
+
+extern inline void flush_cache_range(struct mm_struct *mm,
+ unsigned long start,
+ unsigned long end)
+{
+}
+
+/* Push the page at kernel virtual address and clear the icache */
+extern inline void flush_page_to_ram (unsigned long address)
+{
+}
+
+/* Push n pages at kernel virtual address and clear the icache */
+extern inline void flush_pages_to_ram (unsigned long address, int n)
+{
+}
+
+/*
+ * All 32bit addresses are effectively valid for vmalloc...
+ * Sort of meaningless for non-VM targets.
+ */
+#define VMALLOC_START 0
+#define VMALLOC_END 0xffffffff
+
+#define arch_enter_lazy_mmu_mode() do {} while (0)
+#define arch_leave_lazy_mmu_mode() do {} while (0)
+#define arch_flush_lazy_mmu_mode() do {} while (0)
+#define arch_enter_lazy_cpu_mode() do {} while (0)
+#define arch_leave_lazy_cpu_mode() do {} while (0)
+#define arch_flush_lazy_cpu_mode() do {} while (0)
+
+#endif /* _NIOS_PGTABLE_H */
diff --git a/include/asm-nios2nommu/pio_struct.h b/include/asm-nios2nommu/pio_struct.h
new file mode 100644
index 0000000..8ce5176
--- /dev/null
+++ b/include/asm-nios2nommu/pio_struct.h
@@ -0,0 +1,14 @@
+// PIO Peripheral
+
+// PIO Registers
+typedef volatile struct
+ {
+ int np_piodata; // read/write, up to 32 bits
+ int np_piodirection; // write/readable, up to 32 bits, 1->output bit
+ int np_piointerruptmask; // write/readable, up to 32 bits, 1->enable interrupt
+ int np_pioedgecapture; // read, up to 32 bits, cleared by any write
+ } np_pio;
+
+// PIO Routines
+void nr_pio_showhex(int value); // shows low byte on pio named na_seven_seg_pio
+
diff --git a/include/asm-nios2nommu/poll.h b/include/asm-nios2nommu/poll.h
new file mode 100644
index 0000000..f6b9ab8
--- /dev/null
+++ b/include/asm-nios2nommu/poll.h
@@ -0,0 +1,48 @@
+#ifndef __NIOS2_POLL_H
+#define __NIOS2_POLL_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/poll.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#define POLLIN 1
+#define POLLPRI 2
+#define POLLOUT 4
+#define POLLERR 8
+#define POLLHUP 16
+#define POLLNVAL 32
+#define POLLRDNORM 64
+#define POLLWRNORM POLLOUT
+#define POLLRDBAND 128
+#define POLLWRBAND 256
+#define POLLMSG 0x0400
+#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
+
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+#endif
diff --git a/include/asm-nios2nommu/posix_types.h b/include/asm-nios2nommu/posix_types.h
new file mode 100644
index 0000000..0b019b5
--- /dev/null
+++ b/include/asm-nios2nommu/posix_types.h
@@ -0,0 +1,89 @@
+#ifndef __ARCH_NIOS2_POSIX_TYPES_H
+#define __ARCH_NIOS2_POSIX_TYPES_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/posix_types.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+/*
+ * This file is generally used by user-level software, so you need to
+ * be a little careful about namespace pollution etc. Also, we cannot
+ * assume GCC is being used.
+ */
+
+typedef unsigned long __kernel_ino_t;
+typedef unsigned short __kernel_mode_t;
+typedef unsigned short __kernel_nlink_t;
+typedef long __kernel_off_t;
+typedef int __kernel_pid_t;
+typedef unsigned short __kernel_ipc_pid_t;
+typedef unsigned short __kernel_uid_t;
+typedef unsigned short __kernel_gid_t;
+typedef unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef int __kernel_ptrdiff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_suseconds_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_timer_t;
+typedef int __kernel_clockid_t;
+typedef int __kernel_daddr_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+typedef unsigned int __kernel_uid32_t;
+typedef unsigned int __kernel_gid32_t;
+
+typedef unsigned short __kernel_old_uid_t;
+typedef unsigned short __kernel_old_gid_t;
+typedef unsigned short __kernel_old_dev_t;
+
+#ifdef __GNUC__
+typedef long long __kernel_loff_t;
+#endif
+
+typedef struct {
+#if defined(__KERNEL__) || defined(__USE_ALL)
+ int val[2];
+#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
+ int __val[2];
+#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
+} __kernel_fsid_t;
+
+#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+
+#undef __FD_SET
+#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
+
+#undef __FD_CLR
+#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
+
+#undef __FD_ISSET
+#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
+
+#undef __FD_ZERO
+#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
+
+#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
+
+#endif
diff --git a/include/asm-nios2nommu/preem_latency.h b/include/asm-nios2nommu/preem_latency.h
new file mode 100644
index 0000000..6defb5c
--- /dev/null
+++ b/include/asm-nios2nommu/preem_latency.h
@@ -0,0 +1,39 @@
+#ifndef _ASM_PREEM_LATENCY_H
+#define _ASM_PREEM_LATENCY_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/preem_latency.h
+ *
+ * timing support for preempt-stats patch
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/nios.h>
+
+#define readclock(low) \
+do {\
+ *(volatile unsigned long *)na_Counter_64_bit=1; \
+ low=*(volatile unsigned long *)na_Counter_64_bit; \
+} while (0)
+#define readclock_init()
+
+#endif /* _ASM_PREEM_LATENCY_H */
diff --git a/include/asm-nios2nommu/processor.h b/include/asm-nios2nommu/processor.h
new file mode 100644
index 0000000..5332f94
--- /dev/null
+++ b/include/asm-nios2nommu/processor.h
@@ -0,0 +1,148 @@
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/processor.h
+ *
+ * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
+ * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
+ * Vic Phillips (vic@microtronix.com)
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * hacked from:
+ * include/asm-sparc/processor.h
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ * Nov/02/2003 dgt Fix task_size
+ *
+ ---------------------------------------------------------------------*/
+
+#ifndef __ASM_NIOS_PROCESSOR_H
+#define __ASM_NIOS_PROCESSOR_H
+
+#define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */
+#define NIOS2_FLAG_COPROC 0x00000002 /* Thread used coprocess */
+#define NIOS2_FLAG_DEBUG 0x00000004 /* task is being debugged */
+
+#define NIOS2_OP_NOP 0x1883a
+#define NIOS2_OP_BREAK 0x3da03a
+
+#ifndef __ASSEMBLY__
+
+/*
+ * Default implementation of macro that returns current
+ * instruction pointer ("program counter").
+ */
+#define current_text_addr() ({ __label__ _l; _l: &&_l;})
+
+#include <linux/a.out.h>
+#include <linux/string.h>
+
+#include <asm/ptrace.h>
+#include <asm/signal.h>
+#include <asm/segment.h>
+#include <asm/current.h>
+#include <asm/system.h> /* for get_hi_limit */
+
+/*
+ * Bus types
+ */
+#define EISA_bus 0
+#define EISA_bus__is_a_macro /* for versions in ksyms.c */
+#define MCA_bus 0
+#define MCA_bus__is_a_macro /* for versions in ksyms.c */
+
+/*
+ * The nios has no problems with write protection
+ */
+#define wp_works_ok 1
+#define wp_works_ok__is_a_macro /* for versions in ksyms.c */
+
+/* Whee, this is STACK_TOP and the lowest kernel address too... */
+#if 0
+#define KERNBASE 0x00000000 /* First address the kernel will eventually be */
+#define TASK_SIZE (KERNBASE)
+#define MAX_USER_ADDR TASK_SIZE
+#define MMAP_SEARCH_START (TASK_SIZE/3)
+#endif
+
+#define TASK_SIZE ((unsigned int) nasys_program_mem_end) //...this is better...
+
+/*
+ * This decides where the kernel will search for a free chunk of vm
+ * space during mmap's. We won't be using it
+ */
+#define TASK_UNMAPPED_BASE 0
+
+/* The Nios processor specific thread struct. */
+struct thread_struct {
+ struct pt_regs *kregs;
+
+ /* For signal handling */
+ unsigned long sig_address;
+ unsigned long sig_desc;
+
+ /* Context switch saved kernel state. */
+ unsigned long ksp;
+ unsigned long kpsr;
+ unsigned long kesr;
+
+ /* Flags are defined below */
+
+ unsigned long flags;
+ int current_ds;
+ struct exec core_exec; /* just what it says. */
+};
+
+#define INIT_MMAP { &init_mm, (0), (0), \
+ __pgprot(0x0) , VM_READ | VM_WRITE | VM_EXEC }
+
+#define INIT_THREAD { \
+ .kregs = 0, \
+ .sig_address = 0, \
+ .sig_desc = 0, \
+ .ksp = 0, \
+ .kpsr = 0, \
+ .kesr = PS_S, \
+ .flags = NIOS2_FLAG_KTHREAD, \
+ .current_ds = __KERNEL_DS, \
+ .core_exec = INIT_EXEC \
+}
+
+/* Free all resources held by a thread. */
+extern void release_thread(struct task_struct *);
+
+extern unsigned long thread_saved_pc(struct task_struct *t);
+
+extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
+
+/* Prepare to copy thread state - unlazy all lazy status */
+#define prepare_to_copy(tsk) do { } while (0)
+
+extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+
+unsigned long get_wchan(struct task_struct *p);
+
+#define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
+#define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
+
+#ifdef __KERNEL__
+/* Allocation and freeing of basic task resources. */
+
+//;dgt2;#define alloc_task_struct() ((struct task_struct *) xx..see..linux..fork..xx __get_free_pages(GFP_KERNEL,1))
+//;dgt2;#define get_task_struct(tsk) xx..see..linux..sched.h...atomic_inc(&mem_map[MAP_NR(tsk)].count)
+
+#endif
+
+#define cpu_relax() do { } while (0)
+#endif /* __ASSEMBLY__ */
+#endif /* __ASM_NIOS_PROCESSOR_H */
diff --git a/include/asm-nios2nommu/ptrace.h b/include/asm-nios2nommu/ptrace.h
new file mode 100644
index 0000000..d669e08
--- /dev/null
+++ b/include/asm-nios2nommu/ptrace.h
@@ -0,0 +1,140 @@
+/*
+ * Taken from the m68k port.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef _NIOS2NOMMU_PTRACE_H
+#define _NIOS2NOMMU_PTRACE_H
+
+#ifndef __ASSEMBLY__
+
+#define PTR_R0 0
+#define PTR_R1 1
+#define PTR_R2 2
+#define PTR_R3 3
+#define PTR_R4 4
+#define PTR_R5 5
+#define PTR_R6 6
+#define PTR_R7 7
+#define PTR_R8 8
+#define PTR_R9 9
+#define PTR_R10 10
+#define PTR_R11 11
+#define PTR_R12 12
+#define PTR_R13 13
+#define PTR_R14 14
+#define PTR_R15 15
+#define PTR_R16 16
+#define PTR_R17 17
+#define PTR_R18 18
+#define PTR_R19 19
+#define PTR_R20 20
+#define PTR_R21 21
+#define PTR_R22 22
+#define PTR_R23 23
+#define PTR_R24 24
+#define PTR_R25 25
+#define PTR_GP 26
+#define PTR_SP 27
+#define PTR_FP 28
+#define PTR_EA 29
+#define PTR_BA 30
+#define PTR_RA 31
+#define PTR_STATUS 32
+#define PTR_ESTATUS 33
+#define PTR_BSTATUS 34
+#define PTR_IENABLE 35
+#define PTR_IPENDING 36
+
+/* this struct defines the way the registers are stored on the
+ stack during a system call.
+
+ There is a fake_regs in setup.c that has to match pt_regs.*/
+
+struct pt_regs {
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long r11;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long r14;
+ unsigned long r15;
+ unsigned long r1;
+ unsigned long r2;
+ unsigned long r3;
+ unsigned long r4;
+ unsigned long r5;
+ unsigned long r6;
+ unsigned long r7;
+ unsigned long orig_r2;
+ unsigned long ra;
+ unsigned long fp;
+ unsigned long sp;
+ unsigned long gp;
+ unsigned long estatus;
+ unsigned long status_extension;
+ unsigned long ea;
+};
+
+
+/*
+ * This is the extended stack used by signal handlers and the context
+ * switcher: it's pushed after the normal "struct pt_regs".
+ */
+struct switch_stack {
+ unsigned long r16;
+ unsigned long r17;
+ unsigned long r18;
+ unsigned long r19;
+ unsigned long r20;
+ unsigned long r21;
+ unsigned long r22;
+ unsigned long r23;
+ unsigned long fp;
+ unsigned long gp;
+ unsigned long ra;
+};
+
+#ifdef __KERNEL__
+/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
+#define PTRACE_GETREGS 12
+#define PTRACE_SETREGS 13
+#ifdef CONFIG_FPU
+#define PTRACE_GETFPREGS 14
+#define PTRACE_SETFPREGS 15
+#endif
+
+#ifndef PS_S
+#define PS_S (0x00000001)
+#endif
+#ifndef PS_T
+#define PS_T (0x00000002)
+#endif
+
+#define user_mode(regs) (!((regs)->status_extension & PS_S))
+#define instruction_pointer(regs) ((regs)->ra)
+#define profile_pc(regs) instruction_pointer(regs)
+extern void show_regs(struct pt_regs *);
+
+#endif /* __KERNEL__ */
+#endif /* __ASSEMBLY__ */
+#endif /* _NIOS2NOMMU_PTRACE_H */
diff --git a/include/asm-nios2nommu/resource.h b/include/asm-nios2nommu/resource.h
new file mode 100644
index 0000000..9c2499a
--- /dev/null
+++ b/include/asm-nios2nommu/resource.h
@@ -0,0 +1,6 @@
+#ifndef __ASM_SH_RESOURCE_H
+#define __ASM_SH_RESOURCE_H
+
+#include <asm-generic/resource.h>
+
+#endif /* __ASM_SH_RESOURCE_H */
diff --git a/include/asm-nios2nommu/rmap.h b/include/asm-nios2nommu/rmap.h
new file mode 100644
index 0000000..b3664cc
--- /dev/null
+++ b/include/asm-nios2nommu/rmap.h
@@ -0,0 +1,2 @@
+/* Do not need anything here */
+
diff --git a/include/asm-nios2nommu/scatterlist.h b/include/asm-nios2nommu/scatterlist.h
new file mode 100644
index 0000000..20898e2
--- /dev/null
+++ b/include/asm-nios2nommu/scatterlist.h
@@ -0,0 +1,13 @@
+#ifndef __ASM_SH_SCATTERLIST_H
+#define __ASM_SH_SCATTERLIST_H
+
+struct scatterlist {
+ struct page * page; /* Location for highmem page, if any */
+ unsigned int offset;/* for highmem, page offset */
+ dma_addr_t dma_address;
+ unsigned int length;
+};
+
+#define ISA_DMA_THRESHOLD (0xffffffff)
+
+#endif /* !(__ASM_SH_SCATTERLIST_H) */
diff --git a/include/asm-nios2nommu/sections.h b/include/asm-nios2nommu/sections.h
new file mode 100644
index 0000000..61b3f71
--- /dev/null
+++ b/include/asm-nios2nommu/sections.h
@@ -0,0 +1,30 @@
+#ifndef _NIOS2NOMMU_SECTIONS_H
+#define _NIOS2NOMMU_SECTIONS_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/sections.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm-generic/sections.h>
+
+#endif /* _NIOS2NOMMU_SECTIONS_H */
diff --git a/include/asm-nios2nommu/segment.h b/include/asm-nios2nommu/segment.h
new file mode 100644
index 0000000..25871b3
--- /dev/null
+++ b/include/asm-nios2nommu/segment.h
@@ -0,0 +1,75 @@
+#ifndef _NIOS2NOMMU_SEGMENT_H
+#define _NIOS2NOMMU_SEGMENT_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/segment.h
+ *
+ * Derived from M68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+/* define constants */
+/* Address spaces (FC0-FC2) */
+#define USER_DATA (1)
+#ifndef __USER_DS
+#define __USER_DS (USER_DATA)
+#endif
+#define USER_PROGRAM (2)
+#define SUPER_DATA (5)
+#ifndef __KERNEL_DS
+#define __KERNEL_DS (SUPER_DATA)
+#endif
+#define SUPER_PROGRAM (6)
+#define CPU_SPACE (7)
+
+#ifndef __ASSEMBLY__
+
+typedef struct {
+ unsigned long seg;
+} mm_segment_t;
+
+#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
+#define USER_DS MAKE_MM_SEG(__USER_DS)
+#define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
+
+/*
+ * Get/set the SFC/DFC registers for MOVES instructions
+ */
+
+static inline mm_segment_t get_fs(void)
+{
+ return USER_DS;
+}
+
+static inline mm_segment_t get_ds(void)
+{
+ /* return the supervisor data space code */
+ return KERNEL_DS;
+}
+
+static inline void set_fs(mm_segment_t val)
+{
+}
+
+#define segment_eq(a,b) ((a).seg == (b).seg)
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _NIOS2NOMMU_SEGMENT_H */
diff --git a/include/asm-nios2nommu/semaphore-helper.h b/include/asm-nios2nommu/semaphore-helper.h
new file mode 100644
index 0000000..a8905d1
--- /dev/null
+++ b/include/asm-nios2nommu/semaphore-helper.h
@@ -0,0 +1,99 @@
+#ifndef _NIOS2NOMMU_SEMAPHORE_HELPER_H
+#define _NIOS2NOMMU_SEMAPHORE_HELPER_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/semaphore.h
+ *
+ * SMP- and interrupt-safe semaphores helper functions.
+ *
+ * Derived from M68knommu
+ *
+ * (C) Copyright 1996 Linus Torvalds
+ * m68k version by Andreas Schwab
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+/*
+ * These two _must_ execute atomically wrt each other.
+ */
+static inline void wake_one_more(struct semaphore * sem)
+{
+ atomic_inc(&sem->waking);
+}
+
+static inline int waking_non_zero(struct semaphore *sem)
+{
+ int ret;
+ unsigned long flags;
+
+ spin_lock_irqsave(&semaphore_wake_lock, flags);
+ ret = 0;
+ if (atomic_read(&sem->waking) > 0) {
+ atomic_dec(&sem->waking);
+ ret = 1;
+ }
+ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
+ return ret;
+}
+
+/*
+ * waking_non_zero_interruptible:
+ * 1 got the lock
+ * 0 go to sleep
+ * -EINTR interrupted
+ */
+static inline int waking_non_zero_interruptible(struct semaphore *sem,
+ struct task_struct *tsk)
+{
+ int ret;
+ unsigned long flags;
+
+ spin_lock_irqsave(&semaphore_wake_lock, flags);
+ ret = 0;
+ if (atomic_read(&sem->waking) > 0) {
+ atomic_dec(&sem->waking);
+ ret = 1;
+ } else if (signal_pending(tsk)) {
+ atomic_inc(&sem->count);
+ ret = -EINTR;
+ }
+ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
+ return ret;
+}
+
+/*
+ * waking_non_zero_trylock:
+ * 1 failed to lock
+ * 0 got the lock
+ */
+static inline int waking_non_zero_trylock(struct semaphore *sem)
+{
+ int ret;
+ unsigned long flags;
+
+ spin_lock_irqsave(&semaphore_wake_lock, flags);
+ ret = 1;
+ if (atomic_read(&sem->waking) > 0) {
+ atomic_dec(&sem->waking);
+ ret = 0;
+ } else
+ atomic_inc(&sem->count);
+ spin_unlock_irqrestore(&semaphore_wake_lock, flags);
+ return ret;
+}
+
+#endif
diff --git a/include/asm-nios2nommu/semaphore.h b/include/asm-nios2nommu/semaphore.h
new file mode 100644
index 0000000..8d66c77
--- /dev/null
+++ b/include/asm-nios2nommu/semaphore.h
@@ -0,0 +1,152 @@
+#ifndef _NIOS2NOMMU_SEMAPHORE_H
+#define _NIOS2NOMMU_SEMAPHORE_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/semaphore.h
+ *
+ * Interrupt-safe semaphores..
+ *
+ * Derived from M68knommu
+ *
+ * (C) Copyright 1996 Linus Torvalds
+ * m68k version by Andreas Schwab
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+#define RW_LOCK_BIAS 0x01000000
+
+#ifndef __ASSEMBLY__
+
+#include <linux/linkage.h>
+#include <linux/wait.h>
+#include <linux/spinlock.h>
+#include <linux/rwsem.h>
+
+#include <asm/system.h>
+#include <asm/atomic.h>
+
+struct semaphore {
+ atomic_t count;
+ atomic_t waking;
+ wait_queue_head_t wait;
+};
+
+#define __SEMAPHORE_INITIALIZER(name, n) \
+{ \
+ .count = ATOMIC_INIT(n), \
+ .waking = ATOMIC_INIT(0), \
+ .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
+}
+
+#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
+
+#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+
+static inline void sema_init (struct semaphore *sem, int val)
+{
+ *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
+}
+
+static inline void init_MUTEX (struct semaphore *sem)
+{
+ sema_init(sem, 1);
+}
+
+static inline void init_MUTEX_LOCKED (struct semaphore *sem)
+{
+ sema_init(sem, 0);
+}
+
+asmlinkage void __down_failed(void /* special register calling convention */);
+asmlinkage int __down_failed_interruptible(void /* params in registers */);
+asmlinkage int __down_failed_trylock(void /* params in registers */);
+asmlinkage void __up_wakeup(void /* special register calling convention */);
+
+asmlinkage void __down(struct semaphore * sem);
+asmlinkage int __down_interruptible(struct semaphore * sem);
+asmlinkage int __down_trylock(struct semaphore * sem);
+asmlinkage void __up(struct semaphore * sem);
+
+extern spinlock_t semaphore_wake_lock;
+
+/*
+ * This is ugly, but we want the default case to fall through.
+ * "down_failed" is a special asm handler that calls the C
+ * routine that actually waits.
+ */
+static inline void down(struct semaphore * sem)
+{
+ might_sleep();
+
+ #if 0
+ ...Nios2 has no atomic "decrement memory"....
+ #else
+ if (atomic_dec_return(&sem->count) < 0)
+ __down(sem);
+ #endif
+}
+
+static inline int down_interruptible(struct semaphore * sem)
+{
+ int ret = 0;
+
+
+ might_sleep();
+
+ #if 0
+ ...Nios2 has no atomic "decrement memory"....
+ #else
+ if(atomic_dec_return(&sem->count) < 0)
+ ret = __down_interruptible(sem);
+ return ret;
+ #endif
+}
+
+static inline int down_trylock(struct semaphore * sem)
+{
+ #if 0
+ ...Nios2 has no atomic "decrement memory"....
+ #else
+ int ret = 0;
+
+ if (atomic_dec_return (&sem->count) < 0)
+ ret = __down_trylock(sem);
+ return ret;
+ #endif
+}
+
+/*
+ * Note! This is subtle. We jump to wake people up only if
+ * the semaphore was negative (== somebody was waiting on it).
+ * The default case (no contention) will result in NO
+ * jumps for both down() and up().
+ */
+static inline void up(struct semaphore * sem)
+{
+ #if 0
+ ...Nios2 has no atomic "increment memory"....
+ #else
+ if (atomic_inc_return(&sem->count) <= 0)
+ __up(sem);
+ #endif
+}
+
+#endif /* __ASSEMBLY__ */
+
+#endif
diff --git a/include/asm-nios2nommu/sembuf.h b/include/asm-nios2nommu/sembuf.h
new file mode 100644
index 0000000..e530cab
--- /dev/null
+++ b/include/asm-nios2nommu/sembuf.h
@@ -0,0 +1,48 @@
+#ifndef _NIOS_SEMBUF_H
+#define _NIOS_SEMBUF_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/sembuf.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+/*
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct semid64_ds {
+ struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
+ __kernel_time_t sem_otime; /* last semop time */
+ unsigned long __unused1;
+ __kernel_time_t sem_ctime; /* last change time */
+ unsigned long __unused2;
+ unsigned long sem_nsems; /* no. of semaphores in array */
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#endif /* _NIOS_SEMBUF_H */
diff --git a/include/asm-nios2nommu/setup.h b/include/asm-nios2nommu/setup.h
new file mode 100644
index 0000000..c5a655a
--- /dev/null
+++ b/include/asm-nios2nommu/setup.h
@@ -0,0 +1,31 @@
+/* Copied from i386 port.
+ * Just a place holder. We don't want to have to test x86 before
+ * we include stuff
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2_SETUP_H
+#define _NIOS2_SETUP_H
+
+#define COMMAND_LINE_SIZE 512
+
+#endif /* _NIOS2_SETUP_H */
diff --git a/include/asm-nios2nommu/shmbuf.h b/include/asm-nios2nommu/shmbuf.h
new file mode 100644
index 0000000..f6e6e7d
--- /dev/null
+++ b/include/asm-nios2nommu/shmbuf.h
@@ -0,0 +1,64 @@
+#ifndef _NIOS_SHMBUF_H
+#define _NIOS_SHMBUF_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/shmbuf.h
+ *
+ * Derived from m68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+/* Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 64-bit time_t to solve y2038 problem
+ * - 2 miscellaneous 32-bit values
+ */
+
+struct shmid64_ds {
+ struct ipc64_perm shm_perm; /* operation perms */
+ size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_time_t shm_atime; /* last attach time */
+ unsigned long __unused1;
+ __kernel_time_t shm_dtime; /* last detach time */
+ unsigned long __unused2;
+ __kernel_time_t shm_ctime; /* last change time */
+ unsigned long __unused3;
+ __kernel_pid_t shm_cpid; /* pid of creator */
+ __kernel_pid_t shm_lpid; /* pid of last operator */
+ unsigned long shm_nattch; /* no. of current attaches */
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+struct shminfo64 {
+ unsigned long shmmax;
+ unsigned long shmmin;
+ unsigned long shmmni;
+ unsigned long shmseg;
+ unsigned long shmall;
+ unsigned long __unused1;
+ unsigned long __unused2;
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#endif /* _NIOS_SHMBUF_H */
diff --git a/include/asm-nios2nommu/shmparam.h b/include/asm-nios2nommu/shmparam.h
new file mode 100644
index 0000000..94efe2d
--- /dev/null
+++ b/include/asm-nios2nommu/shmparam.h
@@ -0,0 +1,30 @@
+#ifndef __NIOS2NOMMU_SHMPARAM_H__
+#define __NIOS2NOMMU_SHMPARAM_H__
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/shmparam.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
+
+#endif /* __NIOS2NOMMU_SHMPARAM_H__ */
diff --git a/include/asm-nios2nommu/sigcontext.h b/include/asm-nios2nommu/sigcontext.h
new file mode 100644
index 0000000..7321e7d
--- /dev/null
+++ b/include/asm-nios2nommu/sigcontext.h
@@ -0,0 +1,35 @@
+/*
+ * Taken from the m68knommu.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _ASM_NIOS2NOMMU_SIGCONTEXT_H
+#define _ASM_NIOS2NOMMU_SIGCONTEXT_H
+
+#include <asm/ptrace.h>
+
+struct sigcontext {
+ struct pt_regs regs;
+ unsigned long sc_mask; /* old sigmask */
+};
+
+#endif
diff --git a/include/asm-nios2nommu/siginfo.h b/include/asm-nios2nommu/siginfo.h
new file mode 100644
index 0000000..c047c0b
--- /dev/null
+++ b/include/asm-nios2nommu/siginfo.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2NOMMU_SIGINFO_H
+#define _NIOS2NOMMU_SIGINFO_H
+
+#include <asm-generic/siginfo.h>
+
+#endif
diff --git a/include/asm-nios2nommu/signal.h b/include/asm-nios2nommu/signal.h
new file mode 100644
index 0000000..c86a20c
--- /dev/null
+++ b/include/asm-nios2nommu/signal.h
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2_SIGNAL_H
+#define _NIOS2_SIGNAL_H
+
+#include <linux/types.h>
+
+/* Avoid too many header ordering problems. */
+struct siginfo;
+
+#ifdef __KERNEL__
+/* Most things should be clean enough to redefine this at will, if care
+ is taken to make libc match. */
+
+#define _NSIG 64
+#define _NSIG_BPW 32
+#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
+
+typedef unsigned long old_sigset_t; /* at least 32 bits */
+
+typedef struct {
+ unsigned long sig[_NSIG_WORDS];
+} sigset_t;
+
+#else
+/* Here we must cater to libcs that poke about in kernel headers. */
+
+#define NSIG 32
+typedef unsigned long sigset_t;
+
+#endif /* __KERNEL__ */
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGIOT 6
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL SIGIO
+/*
+#define SIGLOST 29
+*/
+#define SIGPWR 30
+#define SIGSYS 31
+#define SIGUNUSED 31
+
+/* These should not be considered constants from userland. */
+#define SIGRTMIN 32
+#define SIGRTMAX _NSIG
+
+/*
+ * SA_FLAGS values:
+ *
+ * SA_ONSTACK indicates that a registered stack_t will be used.
+ * SA_RESTART flag to get restarting signals (which were the default long ago)
+ * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
+ * SA_RESETHAND clears the handler when the signal is delivered.
+ * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
+ * SA_NODEFER prevents the current signal from being masked in the handler.
+ *
+ * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
+ * Unix names RESETHAND and NODEFER respectively.
+ */
+#define SA_NOCLDSTOP 0x00000001
+#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
+#define SA_SIGINFO 0x00000004
+#define SA_ONSTACK 0x08000000
+#define SA_RESTART 0x10000000
+#define SA_NODEFER 0x40000000
+#define SA_RESETHAND 0x80000000
+
+#define SA_NOMASK SA_NODEFER
+#define SA_ONESHOT SA_RESETHAND
+
+/*
+ * sigaltstack controls
+ */
+#define SS_ONSTACK 1
+#define SS_DISABLE 2
+
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+
+#include <asm-generic/signal.h>
+
+#ifdef __KERNEL__
+struct old_sigaction {
+ __sighandler_t sa_handler;
+ old_sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+struct sigaction {
+ __sighandler_t sa_handler;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+ sigset_t sa_mask; /* mask last for extensibility */
+};
+
+struct k_sigaction {
+ struct sigaction sa;
+};
+#else
+/* Here we must cater to libcs that poke about in kernel headers. */
+
+struct sigaction {
+ union {
+ __sighandler_t _sa_handler;
+ void (*_sa_sigaction)(int, struct siginfo *, void *);
+ } _u;
+ sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+#define sa_handler _u._sa_handler
+#define sa_sigaction _u._sa_sigaction
+
+#endif /* __KERNEL__ */
+
+typedef struct sigaltstack {
+ void *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+} stack_t;
+
+#ifdef __KERNEL__
+
+#include <asm/sigcontext.h>
+#undef __HAVE_ARCH_SIG_BITOPS
+
+#define ptrace_signal_deliver(regs, cookie) do { } while (0)
+
+#endif /* __KERNEL__ */
+
+#endif /* _NIOS2_SIGNAL_H */
diff --git a/include/asm-nios2nommu/smp.h b/include/asm-nios2nommu/smp.h
new file mode 100644
index 0000000..fb23307
--- /dev/null
+++ b/include/asm-nios2nommu/smp.h
@@ -0,0 +1,32 @@
+#ifndef __ASM_SMP_H
+#define __ASM_SMP_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/smp.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+#endif
diff --git a/include/asm-nios2nommu/socket.h b/include/asm-nios2nommu/socket.h
new file mode 100644
index 0000000..5452e2b
--- /dev/null
+++ b/include/asm-nios2nommu/socket.h
@@ -0,0 +1,79 @@
+#ifndef _ASM_SOCKET_H
+#define _ASM_SOCKET_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/socket.h
+ *
+ * Derived from m68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/sockios.h>
+
+/* For setsockopt(2) */
+#define SOL_SOCKET 1
+
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_SNDBUFFORCE 32
+#define SO_RCVBUFFORCE 33
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+#define SO_BSDCOMPAT 14
+/* To add :#define SO_REUSEPORT 15 */
+#define SO_PASSCRED 16
+#define SO_PEERCRED 17
+#define SO_RCVLOWAT 18
+#define SO_SNDLOWAT 19
+#define SO_RCVTIMEO 20
+#define SO_SNDTIMEO 21
+
+/* Security levels - as per NRL IPv6 - don't actually do anything */
+#define SO_SECURITY_AUTHENTICATION 22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
+#define SO_SECURITY_ENCRYPTION_NETWORK 24
+
+#define SO_BINDTODEVICE 25
+
+/* Socket filtering */
+#define SO_ATTACH_FILTER 26
+#define SO_DETACH_FILTER 27
+
+#define SO_PEERNAME 28
+#define SO_TIMESTAMP 29
+#define SCM_TIMESTAMP SO_TIMESTAMP
+
+#define SO_ACCEPTCONN 30
+
+#define SO_PEERSEC 31 /* ;dgt2;tmp; */
+#define SO_PASSSEC 34
+#define SO_TIMESTAMPNS 35
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+
+#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-nios2nommu/sockios.h b/include/asm-nios2nommu/sockios.h
new file mode 100644
index 0000000..c604aa7
--- /dev/null
+++ b/include/asm-nios2nommu/sockios.h
@@ -0,0 +1,39 @@
+#ifndef _ASM_NIOS_SOCKIOS_H
+#define _ASM_NIOS_SOCKIOS_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/sockios.h
+ *
+ * Socket-level I/O control calls.
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906 /* Get stamp */
+#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
+
+#endif /* !(_ASM_NIOS_SOCKIOS_H) */
+
diff --git a/include/asm-nios2nommu/spi.h b/include/asm-nios2nommu/spi.h
new file mode 100644
index 0000000..6efb82c
--- /dev/null
+++ b/include/asm-nios2nommu/spi.h
@@ -0,0 +1,92 @@
+#ifndef _ASM_SPI_H_
+#define _ASM_SPI_H_ 1
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/spi.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/nios.h>
+
+int register_NIOS_SPI( void );
+void unregister_NIOS_SPI( void );
+
+#if defined(MODULE)
+void cleanup_module( void );
+int init_module( void );
+#endif
+
+#if defined(__KERNEL__)
+int spi_reset ( void );
+#endif
+
+
+#define clockCS 0x01
+#define temperatureCS 0x02
+
+#define clock_read_base 0x00
+#define clock_write_base 0x80
+#define clock_read_control 0x0F
+#define clock_read_trickle 0x11
+
+#define clock_read_sec 0x00
+#define clock_read_min 0x01
+#define clock_read_hour 0x02
+#define clock_read_day 0x03
+#define clock_read_date 0x04
+#define clock_read_month 0x05
+#define clock_read_year 0x06
+
+#define clock_write_control 0x8F
+#define clock_write_trickle 0x91
+#define clock_write_sec 0x80
+#define clock_write_min 0x81
+#define clock_write_hour 0x82
+#define clock_write_day 0x83
+#define clock_write_date 0x84
+#define clock_write_month 0x85
+#define clock_write_year 0x86
+
+#define clock_write_ram_start 0xA0
+#define clock_write_ram_end 0x100
+#define clock_read_ram_start 0x20
+#define clock_read_ram_end 0x80
+
+
+#define clock_sec_def 0x11
+#define clock_min_def 0x59
+#define clock_hour_def 0x71
+#define clock_day_def 0x00
+#define clock_date_def 0x20
+#define clock_month_def 0x12
+#define clock_year_def 0x34
+
+#define temp_read_base 0x00
+#define temp_write_base 0x80
+#define temp_read_control 0x00
+#define temp_write_control 0x80
+#define temp_read_msb 0x02
+#define temp_read_lsb 0x01
+
+#define MAX_TEMP_VAR 10
+
+#endif /*_ASM_SPI_H_*/
diff --git a/include/asm-nios2nommu/spi_struct.h b/include/asm-nios2nommu/spi_struct.h
new file mode 100644
index 0000000..c7b2faf
--- /dev/null
+++ b/include/asm-nios2nommu/spi_struct.h
@@ -0,0 +1,57 @@
+// SPI Registers
+typedef volatile struct
+ {
+ int np_spirxdata; // Read-only, 1-16 bit
+ int np_spitxdata; // Write-only, same width as rxdata
+ int np_spistatus; // Read-only, 9-bit
+ int np_spicontrol; // Read/Write, 9-bit
+ int np_spireserved; // reserved
+ int np_spislaveselect; // Read/Write, 1-16 bit, master only
+ int np_spiendofpacket; // Read/write, same width as txdata, rxdata.
+ } np_spi;
+
+// SPI Status Register Bits
+enum
+ {
+ np_spistatus_eop_bit = 9,
+ np_spistatus_e_bit = 8,
+ np_spistatus_rrdy_bit = 7,
+ np_spistatus_trdy_bit = 6,
+ np_spistatus_tmt_bit = 5,
+ np_spistatus_toe_bit = 4,
+ np_spistatus_roe_bit = 3,
+
+ np_spistatus_eop_mask = (1 << 9),
+ np_spistatus_e_mask = (1 << 8),
+ np_spistatus_rrdy_mask = (1 << 7),
+ np_spistatus_trdy_mask = (1 << 6),
+ np_spistatus_tmt_mask = (1 << 5),
+ np_spistatus_toe_mask = (1 << 4),
+ np_spistatus_roe_mask = (1 << 3),
+ };
+
+// SPI Control Register Bits
+enum
+ {
+ np_spicontrol_sso_bit = 10,
+ np_spicontrol_ieop_bit = 9,
+ np_spicontrol_ie_bit = 8,
+ np_spicontrol_irrdy_bit = 7,
+ np_spicontrol_itrdy_bit = 6,
+ np_spicontrol_itoe_bit = 4,
+ np_spicontrol_iroe_bit = 3,
+
+ np_spicontrol_sso_mask = (1 << 10),
+ np_spicontrol_ieop_mask = (1 << 9),
+ np_spicontrol_ie_mask = (1 << 8),
+ np_spicontrol_irrdy_mask = (1 << 7),
+ np_spicontrol_itrdy_mask = (1 << 6),
+ np_spicontrol_itoe_mask = (1 << 4),
+ np_spicontrol_iroe_mask = (1 << 3),
+ };
+
+// SPI Routines.
+int nr_spi_rxchar(np_spi *spiBase);
+int nr_spi_txchar(int i, np_spi *spiBase);
+
+
diff --git a/include/asm-nios2nommu/spinlock.h b/include/asm-nios2nommu/spinlock.h
new file mode 100644
index 0000000..f518755
--- /dev/null
+++ b/include/asm-nios2nommu/spinlock.h
@@ -0,0 +1,30 @@
+#ifndef __NIOS_SPINLOCK_H
+#define __NIOS_SPINLOCK_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/spinlock.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#error "Nios doesn't do SMP yet"
+
+#endif
diff --git a/include/asm-nios2nommu/stat.h b/include/asm-nios2nommu/stat.h
new file mode 100644
index 0000000..bd27a97
--- /dev/null
+++ b/include/asm-nios2nommu/stat.h
@@ -0,0 +1,102 @@
+#ifndef _ASMNIOS2NOMMU_STAT_H
+#define _ASMNIOS2NOMMU_STAT_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/stat.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+struct __old_kernel_stat {
+ unsigned short st_dev;
+ unsigned short st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+ unsigned long st_size;
+ unsigned long st_atime;
+ unsigned long st_mtime;
+ unsigned long st_ctime;
+};
+
+struct stat {
+ unsigned short st_dev;
+ unsigned short __pad1;
+ unsigned long st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+ unsigned short __pad2;
+ unsigned long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ unsigned long st_atime;
+ unsigned long __unused1;
+ unsigned long st_mtime;
+ unsigned long __unused2;
+ unsigned long st_ctime;
+ unsigned long __unused3;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat64 {
+ unsigned long long st_dev;
+ unsigned char __pad1[4];
+
+#define STAT64_HAS_BROKEN_ST_INO 1
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long __pad4; /* future possible st_blocks high bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+
+ unsigned long st_atime;
+ unsigned long st_atime_nsec;
+
+ unsigned long st_mtime;
+ unsigned long st_mtime_nsec;
+
+ unsigned long st_ctime;
+ unsigned long st_ctime_nsec;
+
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/include/asm-nios2nommu/statfs.h b/include/asm-nios2nommu/statfs.h
new file mode 100644
index 0000000..c4637f6
--- /dev/null
+++ b/include/asm-nios2nommu/statfs.h
@@ -0,0 +1,30 @@
+#ifndef _NIOS2NOMMU_STATFS_H
+#define _NIOS2NOMMU_STATFS_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/statfs.h
+ *
+ * Derived from M68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm-generic/statfs.h>
+
+#endif /* _NIOS2NOMMU_STATFS_H */
diff --git a/include/asm-nios2nommu/string.h b/include/asm-nios2nommu/string.h
new file mode 100644
index 0000000..7e39479
--- /dev/null
+++ b/include/asm-nios2nommu/string.h
@@ -0,0 +1,45 @@
+#ifndef __NIOS_STRING_H__
+#define __NIOS_STRING_H__
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/string.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#ifdef __KERNEL__ /* only set these up for kernel code */
+
+#define __HAVE_ARCH_MEMMOVE
+void * memmove(void * d, const void * s, size_t count);
+#define __HAVE_ARCH_MEMCPY
+extern void * memcpy(void *d, const void *s, size_t count);
+#define __HAVE_ARCH_MEMSET
+extern void * memset(void * s,int c,size_t count);
+
+#if 0
+#define __HAVE_ARCH_BCOPY
+#define __HAVE_ARCH_STRLEN
+#endif
+
+#endif /* KERNEL */
+
+#endif /* !(__NIOS_STRING_H__) */
diff --git a/include/asm-nios2nommu/system.h b/include/asm-nios2nommu/system.h
new file mode 100644
index 0000000..7c35af0
--- /dev/null
+++ b/include/asm-nios2nommu/system.h
@@ -0,0 +1,172 @@
+/*
+ * Taken from the m68k.
+ *
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _NIOS2NOMMU_SYSTEM_H
+#define _NIOS2NOMMU_SYSTEM_H
+
+#include <linux/linkage.h>
+#include <linux/compiler.h>
+#include <asm/segment.h>
+#include <asm/entry.h>
+#include <asm/nios.h>
+
+/*
+ * switch_to(n) should switch tasks to task ptr, first checking that
+ * ptr isn't the current task, in which case it does nothing. This
+ * also clears the TS-flag if the task we switched to has used the
+ * math co-processor latest.
+ */
+
+/*
+ */
+asmlinkage void resume(void);
+#define switch_to(prev,next,last) \
+{ \
+ void *_last; \
+ __asm__ __volatile__( \
+ "mov r4, %1\n" \
+ "mov r5, %2\n" \
+ "call resume\n" \
+ "mov %0,r4\n" \
+ : "=r" (_last) \
+ : "r" (prev), "r" (next) \
+ : "r4","r5","r7","r8","ra"); \
+ (last) = _last; \
+}
+
+#define local_irq_enable() __asm__ __volatile__ ( \
+ "rdctl r8, status\n" \
+ "ori r8, r8, 1\n" \
+ "wrctl status, r8\n" \
+ : : : "r8")
+
+#define local_irq_disable() __asm__ __volatile__ ( \
+ "rdctl r8, status\n" \
+ "andi r8, r8, 0xfffe\n" \
+ "wrctl status, r8\n" \
+ : : : "r8")
+
+#define local_save_flags(x) __asm__ __volatile__ ( \
+ "rdctl r8, status\n" \
+ "mov %0, r8\n" \
+ :"=r" (x) : : "r8", "memory")
+
+#define local_irq_restore(x) __asm__ __volatile__ ( \
+ "mov r8, %0\n" \
+ "wrctl status, r8\n" \
+ : :"r" (x) : "memory")
+
+/* For spinlocks etc */
+#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0)
+
+#define irqs_disabled() \
+({ \
+ unsigned long flags; \
+ local_save_flags(flags); \
+ ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
+})
+
+#define iret() __asm__ __volatile__ ("eret": : :"memory", "ea")
+
+/*
+ * Force strict CPU ordering.
+ * Not really required on m68k...
+ */
+#define nop() asm volatile ("nop"::)
+#define mb() asm volatile ("" : : :"memory")
+#define rmb() asm volatile ("" : : :"memory")
+#define wmb() asm volatile ("" : : :"memory")
+#define set_rmb(var, value) do { xchg(&var, value); } while (0)
+#define set_mb(var, value) set_rmb(var, value)
+#define set_wmb(var, value) do { var = value; wmb(); } while (0)
+
+#ifdef CONFIG_SMP
+#define smp_mb() mb()
+#define smp_rmb() rmb()
+#define smp_wmb() wmb()
+#define smp_read_barrier_depends() read_barrier_depends()
+#else
+#define smp_mb() barrier()
+#define smp_rmb() barrier()
+#define smp_wmb() barrier()
+#define smp_read_barrier_depends() do { } while(0)
+#endif
+
+#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
+#define tas(ptr) (xchg((ptr),1))
+
+struct __xchg_dummy { unsigned long a[100]; };
+#define __xg(x) ((volatile struct __xchg_dummy *)(x))
+
+static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
+{
+ unsigned long tmp, flags;
+
+ local_irq_save(flags);
+
+ switch (size) {
+ case 1:
+ __asm__ __volatile__( \
+ "ldb %0, %2\n" \
+ "stb %1, %2\n" \
+ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
+ break;
+ case 2:
+ __asm__ __volatile__( \
+ "ldh %0, %2\n" \
+ "sth %1, %2\n" \
+ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
+ break;
+ case 4:
+ __asm__ __volatile__( \
+ "ldw %0, %2\n" \
+ "stw %1, %2\n" \
+ : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
+ break;
+ }
+ local_irq_restore(flags);
+ return tmp;
+}
+
+/*
+ * Atomic compare and exchange. Compare OLD with MEM, if identical,
+ * store NEW in MEM. Return the initial value in MEM. Success is
+ * indicated by comparing RETURN with OLD.
+ */
+#define __HAVE_ARCH_CMPXCHG 1
+
+static __inline__ unsigned long
+cmpxchg(volatile int *p, int old, int new)
+{
+ unsigned long flags;
+ int prev;
+
+ local_irq_save(flags);
+ if ((prev = *p) == old)
+ *p = new;
+ local_irq_restore(flags);
+ return(prev);
+}
+
+#endif /* _NIOS2NOMMU_SYSTEM_H */
diff --git a/include/asm-nios2nommu/termbits.h b/include/asm-nios2nommu/termbits.h
new file mode 100644
index 0000000..74ef61d
--- /dev/null
+++ b/include/asm-nios2nommu/termbits.h
@@ -0,0 +1,210 @@
+#ifndef __ARCH_NIOS_TERMBITS_H__
+#define __ARCH_NIOS_TERMBITS_H__
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/termbits.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <linux/posix_types.h>
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 19
+struct termios {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_line; /* line discipline */
+ cc_t c_cc[NCCS]; /* control characters */
+};
+
+struct ktermios {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_line; /* line discipline */
+ cc_t c_cc[NCCS]; /* control characters */
+ speed_t c_ispeed; /* input speed */
+ speed_t c_ospeed; /* output speed */
+};
+
+/* c_cc characters */
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+
+
+/* c_iflag bits */
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
+
+/* c_oflag bits */
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#define NLDLY 0000400
+#define NL0 0000000
+#define NL1 0000400
+#define CRDLY 0003000
+#define CR0 0000000
+#define CR1 0001000
+#define CR2 0002000
+#define CR3 0003000
+#define TABDLY 0014000
+#define TAB0 0000000
+#define TAB1 0004000
+#define TAB2 0010000
+#define TAB3 0014000
+#define XTABS 0014000
+#define BSDLY 0020000
+#define BS0 0000000
+#define BS1 0020000
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+#define FFDLY 0100000
+#define FF0 0000000
+#define FF1 0100000
+
+/* c_cflag bit meaning */
+#define CBAUD 0010017
+#define B0 0000000 /* hang up */
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#define EXTA B19200
+#define EXTB B38400
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+#define CBAUDEX 0010000
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B500000 0010005
+#define B576000 0010006
+#define B921600 0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+#define CIBAUD 002003600000 /* input baud rate (not used) */
+#define CMSPAR 010000000000 /* mark or space (stick) parity */
+#define CRTSCTS 020000000000 /* flow control */
+
+/* c_lflag bits */
+#define ISIG 0000001
+#define ICANON 0000002
+#define XCASE 0000004
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#define ECHOCTL 0001000
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
+#define FLUSHO 0010000
+#define PENDIN 0040000
+#define IEXTEN 0100000
+
+
+/* tcflow() and TCXONC use these */
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+/* tcflush() and TCFLSH use these */
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+/* tcsetattr uses these */
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+#endif /* __ARCH_NIOS_TERMBITS_H__ */
diff --git a/include/asm-nios2nommu/termios.h b/include/asm-nios2nommu/termios.h
new file mode 100644
index 0000000..db0dddf
--- /dev/null
+++ b/include/asm-nios2nommu/termios.h
@@ -0,0 +1,132 @@
+#ifndef _NIOS_TERMIOS_H
+#define _NIOS_TERMIOS_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/termios.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/termbits.h>
+#include <asm/ioctls.h>
+
+struct winsize {
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
+};
+
+#define NCC 8
+struct termio {
+ unsigned short c_iflag; /* input mode flags */
+ unsigned short c_oflag; /* output mode flags */
+ unsigned short c_cflag; /* control mode flags */
+ unsigned short c_lflag; /* local mode flags */
+ unsigned char c_line; /* line discipline */
+ unsigned char c_cc[NCC]; /* control characters */
+};
+
+#ifdef __KERNEL__
+/* intr=^C quit=^| erase=del kill=^U
+ eof=^D vtime=\0 vmin=\1 sxtc=\0
+ start=^Q stop=^S susp=^Z eol=\0
+ reprint=^R discard=^U werase=^W lnext=^V
+ eol2=\0
+*/
+#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
+#endif
+
+/* modem lines */
+#define TIOCM_LE 0x001
+#define TIOCM_DTR 0x002
+#define TIOCM_RTS 0x004
+#define TIOCM_ST 0x008
+#define TIOCM_SR 0x010
+#define TIOCM_CTS 0x020
+#define TIOCM_CAR 0x040
+#define TIOCM_RNG 0x080
+#define TIOCM_DSR 0x100
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_OUT1 0x2000
+#define TIOCM_OUT2 0x4000
+#define TIOCM_LOOP 0x8000
+
+/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
+
+/* line disciplines */
+#define N_TTY 0
+#define N_SLIP 1
+#define N_MOUSE 2
+#define N_PPP 3
+#define N_STRIP 4
+#define N_AX25 5
+#define N_X25 6 /* X.25 async */
+#define N_6PACK 7
+#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
+#define N_R3964 9 /* Reserved for Simatic R3964 module */
+#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
+#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
+#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
+#define N_HDLC 13 /* synchronous HDLC */
+#define N_SYNC_PPP 14
+#define N_HCI 15 /* Bluetooth HCI UART */
+
+#ifdef __KERNEL__
+
+/*
+ * Translate a "termio" structure into a "termios". Ugh.
+ */
+#define user_termio_to_kernel_termios(termios, termio) \
+({ \
+ unsigned short tmp; \
+ get_user(tmp, &(termio)->c_iflag); \
+ (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
+ get_user(tmp, &(termio)->c_oflag); \
+ (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
+ get_user(tmp, &(termio)->c_cflag); \
+ (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
+ get_user(tmp, &(termio)->c_lflag); \
+ (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
+ get_user((termios)->c_line, &(termio)->c_line); \
+ copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
+})
+
+/*
+ * Translate a "termios" structure into a "termio". Ugh.
+ */
+#define kernel_termios_to_user_termio(termio, termios) \
+({ \
+ put_user((termios)->c_iflag, &(termio)->c_iflag); \
+ put_user((termios)->c_oflag, &(termio)->c_oflag); \
+ put_user((termios)->c_cflag, &(termio)->c_cflag); \
+ put_user((termios)->c_lflag, &(termio)->c_lflag); \
+ put_user((termios)->c_line, &(termio)->c_line); \
+ copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
+})
+
+#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
+#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
+
+#endif /* __KERNEL__ */
+
+#endif /* _NIOS_TERMIOS_H */
diff --git a/include/asm-nios2nommu/thread_info.h b/include/asm-nios2nommu/thread_info.h
new file mode 100644
index 0000000..6d51e0c
--- /dev/null
+++ b/include/asm-nios2nommu/thread_info.h
@@ -0,0 +1,127 @@
+/* thread_info.h: niosnommu low-level thread information
+ * adapted from the m68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ * Copyright (C) 2002 Microtronix Datacom
+ *
+ * - Incorporating suggestions made by Linus Torvalds and Dave Miller
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _ASM_THREAD_INFO_H
+#define _ASM_THREAD_INFO_H
+
+#include <asm/page.h>
+
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+/*
+ * low level task data.
+ */
+struct thread_info {
+ struct task_struct *task; /* main task structure */
+ struct exec_domain *exec_domain; /* execution domain */
+ unsigned long flags; /* low level flags */
+ int cpu; /* cpu we're on */
+ int preempt_count; /* 0 => preemptable, <0 => BUG*/
+ struct restart_block restart_block;
+};
+
+/*
+ * macros/functions for gaining access to the thread information structure
+ */
+#define INIT_THREAD_INFO(tsk) \
+{ \
+ .task = &tsk, \
+ .exec_domain = &default_exec_domain, \
+ .flags = 0, \
+ .cpu = 0, \
+ .preempt_count = 1, \
+ .restart_block = { \
+ .fn = do_no_restart_syscall, \
+ }, \
+}
+
+#define init_thread_info (init_thread_union.thread_info)
+#define init_stack (init_thread_union.stack)
+
+
+/* how to get the thread information struct from C
+ usable only in supervisor mode */
+static inline struct thread_info *current_thread_info(void)
+{
+ struct thread_info *ti;
+ __asm__ __volatile__(
+ "mov %0, sp\n"
+ "and %0, %0, %1\n"
+ : "=&r"(ti)
+ : "r" (~(THREAD_SIZE-1))
+ );
+ return ti;
+}
+
+/* thread information allocation */
+#define alloc_thread_info(tsk) ((struct thread_info *) \
+ __get_free_pages(GFP_KERNEL, 1))
+#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
+#define put_thread_info(ti) put_task_struct((ti)->task)
+
+#define PREEMPT_ACTIVE 0x4000000
+
+/*
+ * thread information flag bit numbers
+ */
+#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
+#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
+#define TIF_SIGPENDING 2 /* signal pending */
+#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
+#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
+ TIF_NEED_RESCHED */
+#define TIF_MEMDIE 5
+
+/* as above, but as bit values */
+#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
+#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
+#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
+#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
+#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
+
+#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
+
+#else /* __ASSEMBLY__ */
+
+/* how to get the thread information struct from ASM
+ usable only in supervisor mode */
+.macro GET_THREAD_INFO reg
+.if THREAD_SIZE & 0xffff0000
+ andhi \reg, sp, %hi(~(THREAD_SIZE-1))
+.else
+ addi \reg, r0, %lo(~(THREAD_SIZE-1))
+ and \reg, \reg, sp
+.endif
+.endm
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-nios2nommu/timer_struct.h b/include/asm-nios2nommu/timer_struct.h
new file mode 100644
index 0000000..d811a37
--- /dev/null
+++ b/include/asm-nios2nommu/timer_struct.h
@@ -0,0 +1,38 @@
+
+// ----------------------------------------------
+// Timer Peripheral
+
+// Timer Registers
+typedef volatile struct
+ {
+ int np_timerstatus; // read only, 2 bits (any write to clear TO)
+ int np_timercontrol; // write/readable, 4 bits
+ int np_timerperiodl; // write/readable, 16 bits
+ int np_timerperiodh; // write/readable, 16 bits
+ int np_timersnapl; // read only, 16 bits
+ int np_timersnaph; // read only, 16 bits
+ } np_timer;
+
+// Timer Register Bits
+enum
+ {
+ np_timerstatus_run_bit = 1, // timer is running
+ np_timerstatus_to_bit = 0, // timer has timed out
+
+ np_timercontrol_stop_bit = 3, // stop the timer
+ np_timercontrol_start_bit = 2, // start the timer
+ np_timercontrol_cont_bit = 1, // continous mode
+ np_timercontrol_ito_bit = 0, // enable time out interrupt
+
+ np_timerstatus_run_mask = (1<<1), // timer is running
+ np_timerstatus_to_mask = (1<<0), // timer has timed out
+
+ np_timercontrol_stop_mask = (1<<3), // stop the timer
+ np_timercontrol_start_mask = (1<<2), // start the timer
+ np_timercontrol_cont_mask = (1<<1), // continous mode
+ np_timercontrol_ito_mask = (1<<0) // enable time out interrupt
+ };
+
+// Timer Routines
+int nr_timer_milliseconds(void); // Starts on first call, hogs timer1.
+
diff --git a/include/asm-nios2nommu/timex.h b/include/asm-nios2nommu/timex.h
new file mode 100644
index 0000000..abd48cc
--- /dev/null
+++ b/include/asm-nios2nommu/timex.h
@@ -0,0 +1,48 @@
+#ifndef _ASMNIOS2NOMMU_TIMEX_H
+#define _ASMNIOS2NOMMU_TIMEX_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/timex.h
+ *
+ * timex specifications
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/nios.h>
+
+
+#define CLOCK_TICK_RATE nasys_clock_freq /* Underlying HZ */
+
+#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
+
+#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
+ (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
+ << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
+
+typedef unsigned long cycles_t;
+
+static inline cycles_t get_cycles(void)
+{
+ return 0;
+}
+
+#endif
diff --git a/include/asm-nios2nommu/tlb.h b/include/asm-nios2nommu/tlb.h
new file mode 100644
index 0000000..c597b25
--- /dev/null
+++ b/include/asm-nios2nommu/tlb.h
@@ -0,0 +1,35 @@
+#ifndef __NIOS_TLB_H__
+#define __NIOS_TLB_H__
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/tlb.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2003 Microtronix Datacom Ltd
+ * Copyright (C) 2002 NEC Corporation
+ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+#define tlb_flush(tlb) ((void)0)
+
+#include <asm-generic/tlb.h>
+
+#endif /* __NIOS_TLB_H__ */
+
diff --git a/include/asm-nios2nommu/tlbflush.h b/include/asm-nios2nommu/tlbflush.h
new file mode 100644
index 0000000..63cbe52
--- /dev/null
+++ b/include/asm-nios2nommu/tlbflush.h
@@ -0,0 +1,86 @@
+#ifndef _NIOS2NOMMU_TLBFLUSH_H
+#define _NIOS2NOMMU_TLBFLUSH_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/tlbflush.h
+ *
+ * Ported from m68knommu.
+ *
+ * Copyright (C) 2003 Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+#include <asm/setup.h>
+
+/*
+ * flush all user-space atc entries.
+ */
+static inline void __flush_tlb(void)
+{
+ BUG();
+}
+
+static inline void __flush_tlb_one(unsigned long addr)
+{
+ BUG();
+}
+
+#define flush_tlb() __flush_tlb()
+
+/*
+ * flush all atc entries (both kernel and user-space entries).
+ */
+static inline void flush_tlb_all(void)
+{
+ BUG();
+}
+
+static inline void flush_tlb_mm(struct mm_struct *mm)
+{
+ BUG();
+}
+
+static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
+{
+ BUG();
+}
+
+static inline void flush_tlb_range(struct mm_struct *mm,
+ unsigned long start, unsigned long end)
+{
+ BUG();
+}
+
+extern inline void flush_tlb_kernel_page(unsigned long addr)
+{
+ BUG();
+}
+
+extern inline void flush_tlb_pgtables(struct mm_struct *mm,
+ unsigned long start, unsigned long end)
+{
+ BUG();
+}
+
+#endif /* _NIOS2NOMMU_TLBFLUSH_H */
diff --git a/include/asm-nios2nommu/topology.h b/include/asm-nios2nommu/topology.h
new file mode 100644
index 0000000..cfe1054
--- /dev/null
+++ b/include/asm-nios2nommu/topology.h
@@ -0,0 +1,30 @@
+#ifndef _ASM_NIOS2NOMMU_TOPOLOGY_H
+#define _ASM_NIOS2NOMMU_TOPOLOGY_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/topology.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm-generic/topology.h>
+
+#endif /* _ASM_NIOS2NOMMU_TOPOLOGY_H */
diff --git a/include/asm-nios2nommu/traps.h b/include/asm-nios2nommu/traps.h
new file mode 100644
index 0000000..e03ef7f
--- /dev/null
+++ b/include/asm-nios2nommu/traps.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2004, Microtronix Datacom Ltd.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#ifndef _NIOS2_TRAPS_H
+#define _NIOS2_TRAPS_H
+
+#define TRAP_ID_SYSCALL 0
+#define TRAP_ID_APPDEBUG 1
+#endif /* !(_NIOS2_TRAPS_H) */
diff --git a/include/asm-nios2nommu/types.h b/include/asm-nios2nommu/types.h
new file mode 100644
index 0000000..dd7a48e
--- /dev/null
+++ b/include/asm-nios2nommu/types.h
@@ -0,0 +1,91 @@
+#ifndef _NIOS_TYPES_H
+#define _NIOS_TYPES_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/types.h
+ *
+ * Derived from m68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+/*
+ * This file is never included by application software unless
+ * explicitly requested (e.g., via linux/types.h) in which case the
+ * application is Linux specific so (user-) name space pollution is
+ * not a major issue. However, for interoperability, libraries still
+ * need to be careful to avoid a name clashes.
+ */
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned short umode_t;
+
+/*
+ * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
+ * header files exported to user space
+ */
+
+typedef __signed__ char __s8;
+typedef unsigned char __u8;
+
+typedef __signed__ short __s16;
+typedef unsigned short __u16;
+
+typedef __signed__ int __s32;
+typedef unsigned int __u32;
+
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+/*
+ * These aren't exported outside the kernel to avoid name space clashes
+ */
+#ifdef __KERNEL__
+
+#define BITS_PER_LONG 32
+
+#ifndef __ASSEMBLY__
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+/* DMA addresses are always 32-bits wide */
+
+typedef u32 dma_addr_t;
+typedef u32 dma64_addr_t;
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __KERNEL__ */
+
+#endif /* _NIOS_TYPES_H */
diff --git a/include/asm-nios2nommu/uaccess.h b/include/asm-nios2nommu/uaccess.h
new file mode 100644
index 0000000..e7ea20a
--- /dev/null
+++ b/include/asm-nios2nommu/uaccess.h
@@ -0,0 +1,184 @@
+#ifndef __NIOS2NOMMU_UACCESS_H
+#define __NIOS2NOMMU_UACCESS_H
+
+/*--------------------------------------------------------------------
+ *
+ * asm-nios2nommu/uaccess.h
+ *
+ * User space memory access functions
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Ported from asm-m68knommu/uaccess.h --wentao
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <asm/segment.h>
+#include <asm/nios.h>
+
+#define VERIFY_READ 0
+#define VERIFY_WRITE 1
+
+#define access_ok(type,addr,size) _access_ok((unsigned long)(addr),(size))
+
+static inline int _access_ok(unsigned long addr, unsigned long size)
+{
+ return (((unsigned long)addr < (unsigned long)nasys_program_mem_end) &&
+ (((unsigned long)addr >= (unsigned long)nasys_program_mem)));
+}
+
+extern inline int verify_area(int type, const void * addr, unsigned long size)
+{
+ return access_ok(type,addr,size)?0:-EFAULT;
+}
+
+/*
+ * The exception table consists of pairs of addresses: the first is the
+ * address of an instruction that is allowed to fault, and the second is
+ * the address at which the program should continue. No registers are
+ * modified, so it is entirely up to the continuation code to figure out
+ * what to do.
+ *
+ * All the routines below use bits of fixup code that are out of line
+ * with the main instruction path. This means when everything is well,
+ * we don't even have to jump over them. Further, they do not intrude
+ * on our cache or tlb entries.
+ */
+
+#define ARCH_HAS_SEARCH_EXTABLE
+//;dgt2;tmp;
+
+struct exception_table_entry
+{
+ unsigned long insn, fixup;
+};
+
+/* Returns 0 if exception not found and fixup otherwise. */
+extern unsigned long search_exception_table(unsigned long);
+
+
+/*
+ * These are the main single-value transfer routines. They automatically
+ * use the right size if we just have the right pointer type.
+ */
+
+#define put_user(x, ptr) \
+({ \
+ int __pu_err = 0; \
+ typeof(*(ptr)) __pu_val = (x); \
+ switch (sizeof (*(ptr))) { \
+ case 1: \
+ case 2: \
+ case 4: \
+ case 8: \
+ memcpy(ptr, &__pu_val, sizeof (*(ptr))); \
+ break; \
+ default: \
+ __pu_err = __put_user_bad(); \
+ break; \
+ } \
+ __pu_err; \
+})
+#define __put_user(x, ptr) put_user(x, ptr)
+
+extern int __put_user_bad(void);
+
+/*
+ * Tell gcc we read from memory instead of writing: this is because
+ * we do not write to any memory gcc knows about, so there are no
+ * aliasing issues.
+ */
+
+#define __ptr(x) ((unsigned long *)(x))
+
+#define get_user(x, ptr) \
+({ \
+ int __gu_err = 0; \
+ typeof(*(ptr)) __gu_val = 0; \
+ switch (sizeof(*(ptr))) { \
+ case 1: \
+ case 2: \
+ case 4: \
+ case 8: \
+ memcpy(&__gu_val, ptr, sizeof (*(ptr))); \
+ break; \
+ default: \
+ __gu_val = 0; \
+ __gu_err = __get_user_bad(); \
+ break; \
+ } \
+ (x) = __gu_val; \
+ __gu_err; \
+})
+#define __get_user(x, ptr) get_user(x, ptr)
+
+extern int __get_user_bad(void);
+
+#define copy_from_user(to, from, n) (memcpy(to, from, n), 0)
+#define copy_to_user(to, from, n) (memcpy(to, from, n), 0)
+
+#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
+#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
+#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
+
+#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
+
+/*
+ * Copy a null terminated string from userspace.
+ */
+
+static inline long
+strncpy_from_user(char *dst, const char *src, long count)
+{
+ char *tmp;
+ strncpy(dst, src, count);
+ for (tmp = dst; *tmp && count > 0; tmp++, count--)
+ ;
+ return(tmp - dst); /* DAVIDM should we count a NUL ? check getname */
+}
+
+/*
+ * Return the size of a string (including the ending 0)
+ *
+ * Return 0 on exception, a value greater than N if too long
+ */
+static inline long strnlen_user(const char *src, long n)
+{
+ return(strlen(src) + 1); /* DAVIDM make safer */
+}
+
+#define strlen_user(str) strnlen_user(str, 32767)
+
+/*
+ * Zero Userspace
+ */
+
+static inline unsigned long __clear_user(void *to, unsigned long n)
+{
+ memset(to, 0, n);
+ return(0);
+}
+
+#define clear_user(to, n) __clear_user(to, n)
+
+#endif /* _NIOS2NOMMU_UACCESS_H */
diff --git a/include/asm-nios2nommu/uart_struct.h b/include/asm-nios2nommu/uart_struct.h
new file mode 100644
index 0000000..d955192
--- /dev/null
+++ b/include/asm-nios2nommu/uart_struct.h
@@ -0,0 +1,83 @@
+
+// UART Registers
+typedef volatile struct
+ {
+ int np_uartrxdata; // Read-only, 8-bit
+ int np_uarttxdata; // Write-only, 8-bit
+ int np_uartstatus; // Read-only, 8-bit
+ int np_uartcontrol; // Read/Write, 9-bit
+ int np_uartdivisor; // Read/Write, 16-bit, optional
+ int np_uartendofpacket; // Read/Write, end-of-packet character
+ } np_uart;
+
+// UART Status Register Bits
+enum
+ {
+ np_uartstatus_eop_bit = 12,
+ np_uartstatus_cts_bit = 11,
+ np_uartstatus_dcts_bit = 10,
+ np_uartstatus_e_bit = 8,
+ np_uartstatus_rrdy_bit = 7,
+ np_uartstatus_trdy_bit = 6,
+ np_uartstatus_tmt_bit = 5,
+ np_uartstatus_toe_bit = 4,
+ np_uartstatus_roe_bit = 3,
+ np_uartstatus_brk_bit = 2,
+ np_uartstatus_fe_bit = 1,
+ np_uartstatus_pe_bit = 0,
+
+ np_uartstatus_eop_mask = (1<<12),
+ np_uartstatus_cts_mask = (1<<11),
+ np_uartstatus_dcts_mask = (1<<10),
+ np_uartstatus_e_mask = (1<<8),
+ np_uartstatus_rrdy_mask = (1<<7),
+ np_uartstatus_trdy_mask = (1<<6),
+ np_uartstatus_tmt_mask = (1<<5),
+ np_uartstatus_toe_mask = (1<<4),
+ np_uartstatus_roe_mask = (1<<3),
+ np_uartstatus_brk_mask = (1<<2),
+ np_uartstatus_fe_mask = (1<<1),
+ np_uartstatus_pe_mask = (1<<0)
+ };
+
+// UART Control Register Bits
+enum
+ {
+ np_uartcontrol_ieop_bit = 12,
+ np_uartcontrol_rts_bit = 11,
+ np_uartcontrol_idcts_bit = 10,
+ np_uartcontrol_tbrk_bit = 9,
+ np_uartcontrol_ie_bit = 8,
+ np_uartcontrol_irrdy_bit = 7,
+ np_uartcontrol_itrdy_bit = 6,
+ np_uartcontrol_itmt_bit = 5,
+ np_uartcontrol_itoe_bit = 4,
+ np_uartcontrol_iroe_bit = 3,
+ np_uartcontrol_ibrk_bit = 2,
+ np_uartcontrol_ife_bit = 1,
+ np_uartcontrol_ipe_bit = 0,
+
+ np_uartcontrol_ieop_mask = (1<<12),
+ np_uartcontrol_rts_mask = (1<<11),
+ np_uartcontrol_idcts_mask = (1<<10),
+ np_uartcontrol_tbrk_mask = (1<<9),
+ np_uartcontrol_ie_mask = (1<<8),
+ np_uartcontrol_irrdy_mask = (1<<7),
+ np_uartcontrol_itrdy_mask = (1<<6),
+ np_uartcontrol_itmt_mask = (1<<5),
+ np_uartcontrol_itoe_mask = (1<<4),
+ np_uartcontrol_iroe_mask = (1<<3),
+ np_uartcontrol_ibrk_mask = (1<<2),
+ np_uartcontrol_ife_mask = (1<<1),
+ np_uartcontrol_ipe_mask = (1<<0)
+ };
+
+// UART Routines
+int nr_uart_rxchar(np_uart *uartBase); // 0 for default UART
+void nr_uart_txcr(void);
+void nr_uart_txchar(int c,np_uart *uartBase); // 0 for default UART
+void nr_uart_txhex(int x); // 16 or 32 bits
+void nr_uart_txhex16(short x);
+void nr_uart_txhex32(long x);
+void nr_uart_txstring(char *s);
+
diff --git a/include/asm-nios2nommu/ucontext.h b/include/asm-nios2nommu/ucontext.h
new file mode 100644
index 0000000..f2e7ce2
--- /dev/null
+++ b/include/asm-nios2nommu/ucontext.h
@@ -0,0 +1,63 @@
+#ifndef _NIOSKNOMMU_UCONTEXT_H
+#define _NIOSKNOMMU_UCONTEXT_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/ucontext.h
+ *
+ * Derived from M68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+typedef int greg_t;
+#define NGREG 32
+typedef greg_t gregset_t[NGREG];
+
+#ifdef CONFIG_FPU
+typedef struct fpregset {
+ int f_pcr;
+ int f_psr;
+ int f_fpiaddr;
+ int f_fpregs[8][3];
+} fpregset_t;
+#endif
+
+struct mcontext {
+ int version;
+ int status_extension;
+ gregset_t gregs;
+#ifdef CONFIG_FPU
+ fpregset_t fpregs;
+#endif
+};
+
+#define MCONTEXT_VERSION 2
+
+struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ struct mcontext uc_mcontext;
+#ifdef CONFIG_FPU
+ unsigned long uc_filler[80];
+#endif
+ sigset_t uc_sigmask; /* mask last for extensibility */
+};
+
+#endif
diff --git a/include/asm-nios2nommu/unaligned.h b/include/asm-nios2nommu/unaligned.h
new file mode 100644
index 0000000..4876185
--- /dev/null
+++ b/include/asm-nios2nommu/unaligned.h
@@ -0,0 +1,6 @@
+#ifndef __NIOS2_UNALIGNED_H
+#define __NIOS2_UNALIGNED_H
+
+#include <asm-generic/unaligned.h>
+
+#endif /* __NIOS2_UNALIGNED_H */
diff --git a/include/asm-nios2nommu/unistd.h b/include/asm-nios2nommu/unistd.h
new file mode 100644
index 0000000..43cd165
--- /dev/null
+++ b/include/asm-nios2nommu/unistd.h
@@ -0,0 +1,395 @@
+#ifndef _ASM_NIOS_UNISTD_H_
+#define _ASM_NIOS_UNISTD_H_
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/unistd.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * //vic - kernel_thread moved to process.c
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/traps.h>
+
+/* TRAP isr expects the trap# (syscall=#TRAP_ID_SYSCALL) in r2,
+ * the syscall # in r3, and arguments in r4, r5, ...
+ * Return argument expected in r2.
+ */
+
+#define __NR_restart_syscall 0
+#define __NR_exit 1
+#define __NR_fork 2
+#define __NR_read 3
+#define __NR_write 4
+#define __NR_open 5
+#define __NR_close 6
+#define __NR_waitpid 7
+#define __NR_creat 8
+#define __NR_link 9
+#define __NR_unlink 10
+#define __NR_execve 11
+#define __NR_chdir 12
+#define __NR_time 13
+#define __NR_mknod 14
+#define __NR_chmod 15
+#define __NR_chown 16
+#define __NR_break 17
+#define __NR_oldstat 18
+#define __NR_lseek 19
+#define __NR_getpid 20
+#define __NR_mount 21
+#define __NR_umount 22
+#define __NR_setuid 23
+#define __NR_getuid 24
+#define __NR_stime 25
+#define __NR_ptrace 26
+#define __NR_alarm 27
+#define __NR_oldfstat 28
+#define __NR_pause 29
+#define __NR_utime 30
+#define __NR_stty 31
+#define __NR_gtty 32
+#define __NR_access 33
+#define __NR_nice 34
+#define __NR_ftime 35
+#define __NR_sync 36
+#define __NR_kill 37
+#define __NR_rename 38
+#define __NR_mkdir 39
+#define __NR_rmdir 40
+#define __NR_dup 41
+#define __NR_pipe 42
+#define __NR_times 43
+#define __NR_prof 44
+#define __NR_brk 45
+#define __NR_setgid 46
+#define __NR_getgid 47
+#define __NR_signal 48
+#define __NR_geteuid 49
+#define __NR_getegid 50
+#define __NR_acct 51
+#define __NR_umount2 52 //vic #define __NR_phys 52
+#define __NR_lock 53
+#define __NR_ioctl 54
+#define __NR_fcntl 55
+#define __NR_mpx 56
+#define __NR_setpgid 57
+#define __NR_ulimit 58
+#define __NR_oldolduname 59
+#define __NR_umask 60
+#define __NR_chroot 61
+#define __NR_ustat 62
+#define __NR_dup2 63
+#define __NR_getppid 64
+#define __NR_getpgrp 65
+#define __NR_setsid 66
+#define __NR_sigaction 67
+#define __NR_sgetmask 68
+#define __NR_ssetmask 69
+#define __NR_setreuid 70
+#define __NR_setregid 71
+#define __NR_sigsuspend 72
+#define __NR_sigpending 73
+#define __NR_sethostname 74
+#define __NR_setrlimit 75
+#define __NR_getrlimit 76
+#define __NR_getrusage 77
+#define __NR_gettimeofday 78
+#define __NR_settimeofday 79
+#define __NR_getgroups 80
+#define __NR_setgroups 81
+#define __NR_select 82
+#define __NR_symlink 83
+#define __NR_oldlstat 84
+#define __NR_readlink 85
+#define __NR_uselib 86
+#define __NR_swapon 87
+#define __NR_reboot 88
+#define __NR_readdir 89
+#define __NR_mmap 90
+#define __NR_munmap 91
+#define __NR_truncate 92
+#define __NR_ftruncate 93
+#define __NR_fchmod 94
+#define __NR_fchown 95
+#define __NR_getpriority 96
+#define __NR_setpriority 97
+#define __NR_profil 98
+#define __NR_statfs 99
+#define __NR_fstatfs 100
+#define __NR_ioperm 101
+#define __NR_socketcall 102
+#define __NR_syslog 103
+#define __NR_setitimer 104
+#define __NR_getitimer 105
+#define __NR_stat 106
+#define __NR_lstat 107
+#define __NR_fstat 108
+#define __NR_olduname 109
+#define __NR_iopl /* 110 */ not supported
+#define __NR_vhangup 111
+#define __NR_idle /* 112 */ Obsolete
+#define __NR_vm86 /* 113 */ not supported
+#define __NR_wait4 114
+#define __NR_swapoff 115
+#define __NR_sysinfo 116
+#define __NR_ipc 117
+#define __NR_fsync 118
+#define __NR_sigreturn 119
+#define __NR_clone 120
+#define __NR_setdomainname 121
+#define __NR_uname 122
+#define __NR_cacheflush 123
+#define __NR_adjtimex 124
+#define __NR_mprotect 125
+#define __NR_sigprocmask 126
+#define __NR_create_module 127
+#define __NR_init_module 128
+#define __NR_delete_module 129
+#define __NR_get_kernel_syms 130
+#define __NR_quotactl 131
+#define __NR_getpgid 132
+#define __NR_fchdir 133
+#define __NR_bdflush 134
+#define __NR_sysfs 135
+#define __NR_personality 136
+#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
+#define __NR_setfsuid 138
+#define __NR_setfsgid 139
+#define __NR__llseek 140
+#define __NR_getdents 141
+#define __NR__newselect 142
+#define __NR_flock 143
+ /* 144 __NR_msync obsolete */
+#define __NR_readv 145
+#define __NR_writev 146
+#define __NR_getsid 147
+#define __NR_fdatasync 148
+#define __NR__sysctl 149
+#define __NR_mlock 150
+#define __NR_munlock 151
+#define __NR_mlockall 152
+#define __NR_munlockall 153
+#define __NR_sched_setparam 154
+#define __NR_sched_getparam 155
+#define __NR_sched_setscheduler 156
+#define __NR_sched_getscheduler 157
+#define __NR_sched_yield 158
+#define __NR_sched_get_priority_max 159
+#define __NR_sched_get_priority_min 160
+#define __NR_sched_rr_get_interval 161
+#define __NR_nanosleep 162
+#define __NR_mremap 163
+#define __NR_setresuid 164
+#define __NR_getresuid 165
+#define __NR_getpagesize 166
+#define __NR_query_module 167
+#define __NR_poll 168
+#define __NR_nfsservctl 169
+#define __NR_setresgid 170
+#define __NR_getresgid 171
+#define __NR_prctl 172
+#define __NR_rt_sigreturn 173
+#define __NR_rt_sigaction 174
+#define __NR_rt_sigprocmask 175
+#define __NR_rt_sigpending 176
+#define __NR_rt_sigtimedwait 177
+#define __NR_rt_sigqueueinfo 178
+#define __NR_rt_sigsuspend 179
+#define __NR_pread 180
+#define __NR_pwrite 181
+#define __NR_lchown 182
+#define __NR_getcwd 183
+#define __NR_capget 184
+#define __NR_capset 185
+#define __NR_sigaltstack 186
+#define __NR_sendfile 187
+#define __NR_getpmsg 188 /* some people actually want streams */
+#define __NR_putpmsg 189 /* some people actually want streams */
+#define __NR_vfork 190
+#define __NR_ugetrlimit 191
+#define __NR_mmap2 192
+#define __NR_truncate64 193
+#define __NR_ftruncate64 194
+#define __NR_stat64 195
+#define __NR_lstat64 196
+#define __NR_fstat64 197
+#define __NR_chown32 198
+#define __NR_getuid32 199
+#define __NR_getgid32 200
+#define __NR_geteuid32 201
+#define __NR_getegid32 202
+#define __NR_setreuid32 203
+#define __NR_setregid32 204
+#define __NR_getgroups32 205
+#define __NR_setgroups32 206
+#define __NR_fchown32 207
+#define __NR_setresuid32 208
+#define __NR_getresuid32 209
+#define __NR_setresgid32 210
+#define __NR_getresgid32 211
+#define __NR_lchown32 212
+#define __NR_setuid32 213
+#define __NR_setgid32 214
+#define __NR_setfsuid32 215
+#define __NR_setfsgid32 216
+#define __NR_pivot_root 217
+/* 218 unused */
+/* 219 unused */
+#define __NR_getdents64 220
+#define __NR_gettid 221
+#define __NR_tkill 222
+#define __NR_setxattr 223
+#define __NR_lsetxattr 224
+#define __NR_fsetxattr 225
+#define __NR_getxattr 226
+#define __NR_lgetxattr 227
+#define __NR_fgetxattr 228
+#define __NR_listxattr 229
+#define __NR_llistxattr 230
+#define __NR_flistxattr 231
+#define __NR_removexattr 232
+#define __NR_lremovexattr 233
+#define __NR_fremovexattr 234
+#define __NR_futex 235
+#define __NR_sendfile64 236
+#define __NR_mincore 237
+#define __NR_madvise 238
+#define __NR_fcntl64 239
+#define __NR_readahead 240
+#define __NR_io_setup 241
+#define __NR_io_destroy 242
+#define __NR_io_getevents 243
+#define __NR_io_submit 244
+#define __NR_io_cancel 245
+#define __NR_fadvise64 246
+#define __NR_exit_group 247
+#define __NR_lookup_dcookie 248
+#define __NR_epoll_create 249
+#define __NR_epoll_ctl 250
+#define __NR_epoll_wait 251
+#define __NR_remap_file_pages 252
+#define __NR_set_tid_address 253
+#define __NR_timer_create 254
+#define __NR_timer_settime 255
+#define __NR_timer_gettime 256
+#define __NR_timer_getoverrun 257
+#define __NR_timer_delete 258
+#define __NR_clock_settime 259
+#define __NR_clock_gettime 260
+#define __NR_clock_getres 261
+#define __NR_clock_nanosleep 262
+#define __NR_statfs64 263
+#define __NR_fstatfs64 264
+#define __NR_tgkill 265
+#define __NR_utimes 266
+#define __NR_fadvise64_64 267
+#define __NR_mbind 268
+#define __NR_get_mempolicy 269
+#define __NR_set_mempolicy 270
+#define __NR_mq_open 271
+#define __NR_mq_unlink 272
+#define __NR_mq_timedsend 273
+#define __NR_mq_timedreceive 274
+#define __NR_mq_notify 275
+#define __NR_mq_getsetattr 276
+#define __NR_waitid 277
+#define __NR_sys_setaltroot 278
+#define __NR_add_key 279
+#define __NR_request_key 280
+#define __NR_keyctl 281
+#define __NR_ioprio_set 282
+#define __NR_ioprio_get 283
+#define __NR_inotify_init 284
+#define __NR_inotify_add_watch 285
+#define __NR_inotify_rm_watch 286
+#define __NR_migrate_pages 287
+#define __NR_openat 288
+#define __NR_mkdirat 289
+#define __NR_mknodat 290
+#define __NR_fchownat 291
+#define __NR_futimesat 292
+#define __NR_fstatat64 293
+#define __NR_unlinkat 294
+#define __NR_renameat 295
+#define __NR_linkat 296
+#define __NR_symlinkat 297
+#define __NR_readlinkat 298
+#define __NR_fchmodat 299
+#define __NR_faccessat 300
+#define __NR_pselect6 301
+#define __NR_ppoll 302
+#define __NR_unshare 303
+#define __NR_set_robust_list 304
+#define __NR_get_robust_list 305
+#define __NR_splice 306
+#define __NR_sync_file_range 307
+#define __NR_tee 308
+#define __NR_vmsplice 309
+#define __NR_move_pages 310
+#define __NR_sched_setaffinity 311
+#define __NR_sched_getaffinity 312
+#define __NR_kexec_load 313
+#define __NR_getcpu 314
+#define __NR_epoll_pwait 315
+#define __NR_utimensat 316
+#define __NR_signalfd 317
+#define __NR_timerfd 318
+#define __NR_eventfd 319
+#define __NR_pread64 320
+#define __NR_pwrite64 321
+
+#ifdef __KERNEL__
+#define NR_syscalls 322
+
+#define __ARCH_WANT_IPC_PARSE_VERSION
+#define __ARCH_WANT_OLD_READDIR
+#define __ARCH_WANT_OLD_STAT
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SYS_ALARM
+#define __ARCH_WANT_SYS_GETHOSTNAME
+#define __ARCH_WANT_SYS_PAUSE
+#define __ARCH_WANT_SYS_SGETMASK
+#define __ARCH_WANT_SYS_SIGNAL
+#define __ARCH_WANT_SYS_TIME
+#define __ARCH_WANT_SYS_UTIME
+#define __ARCH_WANT_SYS_WAITPID
+#define __ARCH_WANT_SYS_SOCKETCALL
+#define __ARCH_WANT_SYS_FADVISE64
+#define __ARCH_WANT_SYS_GETPGRP
+#define __ARCH_WANT_SYS_LLSEEK
+#define __ARCH_WANT_SYS_NICE
+#define __ARCH_WANT_SYS_OLD_GETRLIMIT
+#define __ARCH_WANT_SYS_OLDUMOUNT
+#define __ARCH_WANT_SYS_SIGPENDING
+#define __ARCH_WANT_SYS_SIGPROCMASK
+#define __ARCH_WANT_SYS_RT_SIGACTION
+
+/*
+ * "Conditional" syscalls
+ *
+ * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
+ * but it doesn't work on all toolchains, so we just do it by hand
+ */
+#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_NIOS_UNISTD_H_ */
diff --git a/include/asm-nios2nommu/user.h b/include/asm-nios2nommu/user.h
new file mode 100644
index 0000000..3cdc2ba
--- /dev/null
+++ b/include/asm-nios2nommu/user.h
@@ -0,0 +1,112 @@
+#ifndef _NIOS2NOMMU_USER_H
+#define _NIOS2NOMMU_USER_H
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/user.h
+ *
+ * Derived from M68knommu
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+#include <asm/page.h>
+
+/* Core file format: The core file is written in such a way that gdb
+ can understand it and provide useful information to the user (under
+ linux we use the 'trad-core' bfd). There are quite a number of
+ obstacles to being able to view the contents of the floating point
+ registers, and until these are solved you will not be able to view the
+ contents of them. Actually, you can read in the core file and look at
+ the contents of the user struct to find out what the floating point
+ registers contain.
+ The actual file contents are as follows:
+ UPAGE: 1 page consisting of a user struct that tells gdb what is present
+ in the file. Directly after this is a copy of the task_struct, which
+ is currently not used by gdb, but it may come in useful at some point.
+ All of the registers are stored as part of the upage. The upage should
+ always be only one page.
+ DATA: The data area is stored. We use current->end_text to
+ current->brk to pick up all of the user variables, plus any memory
+ that may have been malloced. No attempt is made to determine if a page
+ is demand-zero or if a page is totally unused, we just cover the entire
+ range. All of the addresses are rounded in such a way that an integral
+ number of pages is written.
+ STACK: We need the stack information in order to get a meaningful
+ backtrace. We need to write the data from (esp) to
+ current->start_stack, so we round each of these off in order to be able
+ to write an integer number of pages.
+ The minimum core file size is 3 pages, or 12288 bytes.
+*/
+
+struct user_m68kfp_struct {
+ unsigned long fpregs[8*3]; /* fp0-fp7 registers */
+ unsigned long fpcntl[3]; /* fp control regs */
+};
+
+/* This is needs more work, probably should look like gdb useage */
+struct user_regs_struct {
+ long r1,r2,r3,r4,r5,r6,r7,r8;
+ long r9,r10,r11,r12,r13,r14,r15;
+ long r16,r17,r18,r19,r20,r21,r22,r23;
+ long gp;
+ long sp;
+ long ra;
+ long fp;
+ long orig_r2;
+ long estatus;
+ long status_extension;
+ long ea;
+};
+
+
+/* When the kernel dumps core, it starts by dumping the user struct -
+ this will be used by gdb to figure out where the data and stack segments
+ are within the file, and what virtual addresses to use. */
+struct user{
+/* We start with the registers, to mimic the way that "memory" is returned
+ from the ptrace(3,...) function. */
+ struct user_regs_struct regs; /* Where the registers are actually stored */
+/* ptrace does not yet supply these. Someday.... */
+ int u_fpvalid; /* True if math co-processor being used. */
+ /* for this mess. Not yet used. */
+ struct user_m68kfp_struct m68kfp; /* Math Co-processor registers. */
+/* The rest of this junk is to help gdb figure out what goes where */
+ unsigned long int u_tsize; /* Text segment size (pages). */
+ unsigned long int u_dsize; /* Data segment size (pages). */
+ unsigned long int u_ssize; /* Stack segment size (pages). */
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack area.
+ This is actually the bottom of the stack,
+ the top of the stack is always found in the
+ esp register. */
+ long int signal; /* Signal that caused the core dump. */
+ int reserved; /* No longer used */
+ struct user_regs_struct *u_ar0;
+ /* Used by gdb to help find the values for */
+ /* the registers. */
+ struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
+ unsigned long magic; /* To uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+};
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif
diff --git a/include/asm-nios2nommu/virtconvert.h b/include/asm-nios2nommu/virtconvert.h
new file mode 100644
index 0000000..89bf899
--- /dev/null
+++ b/include/asm-nios2nommu/virtconvert.h
@@ -0,0 +1,46 @@
+#ifndef __NIOS_VIRT_CONVERT__
+#define __NIOS_VIRT_CONVERT__
+
+/*--------------------------------------------------------------------
+ *
+ * include/asm-nios2nommu/virtconvert.h
+ *
+ * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *
+ * Jan/20/2004 dgt NiosII
+ *
+ ---------------------------------------------------------------------*/
+
+
+/*
+ * Macros used for converting between virtual and physical mappings.
+ */
+
+#ifdef __KERNEL__
+
+#include <asm/setup.h>
+#include <asm/page.h>
+
+#define mm_ptov(vaddr) ((void *) (vaddr))
+#define mm_vtop(vaddr) ((unsigned long) (vaddr))
+#define phys_to_virt(vaddr) ((void *) (vaddr))
+#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
+
+#define virt_to_bus virt_to_phys
+#define bus_to_virt phys_to_virt
+
+#endif /*__KERNEL__ */
+#endif /*__NIOS_VIRT_CONVERT__*/
|