bump Linux 3.18 trunk revision to 47027; bump Linux 3.18 kernel version to 3.18.21
[ps3openwrt_patches.git] / v2-0001-linux-Add-3.16-support.patch
blob93c4ab139abcee7db0f130e2d47bd19ba153eee1
1 From 768a4a37612b4ea75a7dbc03d0e142466085b1ea Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime.ripard@free-electrons.com>
3 Date: Wed, 17 Sep 2014 14:40:24 +0200
4 Subject: [PATCH v2 1/3] linux: Add 3.16 support
6 Provide a generic configuration and the forward-ported patches in order to
7 support Linux 3.16.
9 Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
10 ---
11 target/linux/generic/config-3.16 | 4537 +++++++++++++++++
12 .../000-keep_initrafs_the_default.patch | 25 +
13 .../generic/patches-3.16/020-ssb_update.patch | 201 +
14 .../generic/patches-3.16/025-bcma_backport.patch | 1368 ++++++
15 ...part-find-NVRAM-partitions-in-middle-bloc.patch | 19 +
16 .../generic/patches-3.16/060-hso_devices.patch | 36 +
17 .../061-arm_xz_decompressor_build_fix.patch | 10 +
18 .../062-mips_decompressor_build_fix.patch | 66 +
19 .../linux/generic/patches-3.16/100-overlayfs.patch | 4120 ++++++++++++++++
20 .../patches-3.16/102-ehci_hcd_ignore_oc.patch | 82 +
21 ...-bridge_allow_receiption_on_disabled_port.patch | 54 +
22 .../patches-3.16/132-mips_inline_dma_ops.patch | 660 +++
23 .../patches-3.16/200-fix_localversion.patch | 11 +
24 .../patches-3.16/201-extra_optimization.patch | 14 +
25 .../patches-3.16/202-reduce_module_size.patch | 11 +
26 .../patches-3.16/203-kallsyms_uncompressed.patch | 108 +
27 .../generic/patches-3.16/204-module_strip.patch | 194 +
28 .../patches-3.16/210-darwin_scripts_include.patch | 3088 ++++++++++++
29 .../patches-3.16/212-byteshift_portability.patch | 51 +
30 .../generic/patches-3.16/220-gc_sections.patch | 509 ++
31 .../generic/patches-3.16/221-module_exports.patch | 88 +
32 .../patches-3.16/230-openwrt_lzma_options.patch | 58 +
33 .../patches-3.16/250-netfilter_depends.patch | 18 +
34 .../generic/patches-3.16/251-sound_kconfig.patch | 18 +
35 .../generic/patches-3.16/252-mv_cesa_depends.patch | 10 +
36 .../patches-3.16/253-ssb_b43_default_on.patch | 29 +
37 .../254-textsearch_kconfig_hacks.patch | 23 +
38 .../patches-3.16/255-lib80211_kconfig_hacks.patch | 19 +
39 .../256-crypto_add_kconfig_prompts.patch | 47 +
40 .../257-wireless_ext_kconfig_hack.patch | 22 +
41 .../258-netfilter_netlink_kconfig_hack.patch | 11 +
42 .../generic/patches-3.16/259-regmap_dynamic.patch | 76 +
43 .../260-crypto_test_dependencies.patch | 37 +
44 .../patches-3.16/261-move_bcm963xx_tag.patch | 219 +
45 .../patches-3.16/262-compressor_kconfig_hack.patch | 23 +
46 .../patches-3.16/300-mips_expose_boot_raw.patch | 39 +
47 .../patches-3.16/301-mips_image_cmdline_hack.patch | 28 +
48 .../patches-3.16/302-mips_no_branch_likely.patch | 11 +
49 .../patches-3.16/304-mips_disable_fpu.patch | 129 +
50 .../patches-3.16/305-mips_module_reloc.patch | 352 ++
51 .../306-mips_mem_functions_performance.patch | 83 +
52 .../patches-3.16/309-mips_fuse_workaround.patch | 33 +
53 .../310-arm_module_unresolved_weak_sym.patch | 13 +
54 .../patches-3.16/320-ppc4xx_optimization.patch | 31 +
55 .../321-powerpc_crtsavres_prereq.patch | 10 +
56 .../400-mtd-add-rootfs-split-support.patch | 263 +
57 ...port-for-different-partition-parser-types.patch | 113 +
58 ...mtd-parsers-for-rootfs-and-firmware-split.patch | 75 +
59 .../403-mtd-hook-mtdsplit-to-Kbuild.patch | 25 +
60 .../405-mtd-add-more-helper-functions.patch | 83 +
61 .../406-mtd-hook-mtdsplit-into-Kbuild.patch | 24 +
62 ...ve-forward-declaration-of-struct-mtd_info.patch | 18 +
63 .../411-mtd-partial_eraseblock_write.patch | 146 +
64 .../412-mtd-partial_eraseblock_unlock.patch | 18 +
65 .../patches-3.16/420-mtd-redboot_space.patch | 30 +
66 .../430-mtd-add-myloader-partition-parser.patch | 35 +
67 ...part-support-TRX-data-partition-being-UBI.patch | 66 +
68 .../generic/patches-3.16/440-block2mtd_init.patch | 107 +
69 .../generic/patches-3.16/441-block2mtd_probe.patch | 108 +
70 ...allow-to-use-platform-specific-chip-fixup.patch | 37 +
71 ...return-code-of-nand_correct_data-function.patch | 11 +
72 .../460-mtd-cfi_cmdset_0002-no-erase_suspend.patch | 11 +
73 ..._cmdset_0002-add-buffer-write-cmd-timeout.patch | 18 +
74 ...i-nor-allow-to-disable-small-sector-erase.patch | 27 +
75 ...-nor-add-support-for-Winbond-W25X05-flash.patch | 20 +
76 ...i-nor-add-support-for-EON-EN25QH128-flash.patch | 20 +
77 .../480-mtd-set-rootfs-to-be-root-dev.patch | 26 +
78 ...tach-mtd-device-named-ubi-or-data-on-boot.patch | 63 +
79 ...bi-auto-create-ubiblock-device-for-rootfs.patch | 69 +
80 ...-mounting-ubi0-rootfs-in-init-do_mounts.c.patch | 53 +
81 ...-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch | 37 +
82 .../500-yaffs-Kbuild-integration.patch | 18 +
83 ...01-yaffs-3.5-convert-to-use-kuid_t-kgid_t.patch | 155 +
84 .../502-yaffs-3.10-disable-proc-entry.patch | 44 +
85 ...503-yaffs-3.12-convert-readdir-to-iterate.patch | 129 +
86 .../503-yaffs-add-tags-9bytes-mount-option.patch | 115 +
87 .../504-yaffs-fix-compat-tags-handling.patch | 239 +
88 .../520-squashfs_update_xz_comp_opts.patch | 25 +
89 .../530-jffs2_make_lzma_available.patch | 5142 ++++++++++++++++++++
90 .../generic/patches-3.16/531-debloat_lzma.patch | 1024 ++++
91 .../generic/patches-3.16/532-jffs2_eofdetect.patch | 56 +
92 .../540-crypto-xz-decompression-support.patch | 146 +
93 .../541-ubifs-xz-decompression-support.patch | 92 +
94 .../550-ubifs-symlink-xattr-support.patch | 65 +
95 ...1-ubifs-fix-default-compression-selection.patch | 29 +
96 .../patches-3.16/600-netfilter_layer7_2.22.patch | 2141 ++++++++
97 .../601-netfilter_layer7_pktmatch.patch | 108 +
98 .../patches-3.16/602-netfilter_layer7_match.patch | 51 +
99 .../603-netfilter_layer7_2.6.36_fix.patch | 61 +
100 .../604-netfilter_conntrack_flush.patch | 86 +
101 ...610-netfilter_match_bypass_default_checks.patch | 93 +
102 .../611-netfilter_match_bypass_default_table.patch | 94 +
103 .../612-netfilter_match_reduce_memory_access.patch | 16 +
104 .../613-netfilter_optional_tcp_window_check.patch | 36 +
105 .../615-netfilter_add_xt_id_match.patch | 95 +
106 .../patches-3.16/616-net_optimize_xfrm_calls.patch | 12 +
107 .../617-netfilter_skip_filter_sysctl.patch | 87 +
108 .../generic/patches-3.16/620-sched_esfq.patch | 791 +++
109 .../patches-3.16/630-packet_socket_type.patch | 134 +
110 .../patches-3.16/640-bridge_no_eap_forward.patch | 15 +
111 .../641-bridge_always_accept_eap.patch | 11 +
112 .../patches-3.16/642-bridge_port_isolate.patch | 102 +
113 .../643-bridge_remove_ipv6_dependency.patch | 107 +
114 .../644-bridge_optimize_netfilter_hooks.patch | 155 +
115 .../645-bridge_multicast_to_unicast.patch | 373 ++
116 .../patches-3.16/650-pppoe_header_pad.patch | 20 +
117 .../patches-3.16/651-wireless_mesh_header.patch | 11 +
118 .../patches-3.16/652-atm_header_changes.patch | 12 +
119 .../patches-3.16/653-disable_netlink_trim.patch | 30 +
120 .../patches-3.16/655-increase_skb_pad.patch | 11 +
121 .../656-skb_reduce_truesize-helper.patch | 41 +
122 .../patches-3.16/657-qdisc_reduce_truesize.patch | 63 +
123 .../patches-3.16/660-fq_codel_defaults.patch | 14 +
124 .../661-fq_codel_keep_dropped_stats.patch | 10 +
125 .../patches-3.16/662-use_fq_codel_by_default.patch | 75 +
126 .../patches-3.16/663-remove_pfifo_fast.patch | 143 +
127 .../generic/patches-3.16/664-codel_fix_3_12.patch | 22 +
128 .../666-Add-support-for-MAP-E-FMRs-mesh-mode.patch | 481 ++
129 ...jecting-with-source-address-failed-policy.patch | 239 +
130 ...-defines-for-_POLICY_FAILED-until-all-cod.patch | 53 +
131 .../linux/generic/patches-3.16/700-swconfig.patch | 39 +
132 .../generic/patches-3.16/701-phy_extension.patch | 63 +
133 .../702-phy_add_aneg_done_function.patch | 28 +
134 ...-add-detach-callback-to-struct-phy_driver.patch | 27 +
135 .../710-phy-add-mdio_register_board_info.patch | 192 +
136 .../generic/patches-3.16/720-phy_adm6996.patch | 26 +
137 .../generic/patches-3.16/721-phy_packets.patch | 172 +
138 .../generic/patches-3.16/722-phy_mvswitch.patch | 23 +
139 .../generic/patches-3.16/723-phy_ip175c.patch | 23 +
140 .../generic/patches-3.16/724-phy_ar8216.patch | 24 +
141 .../generic/patches-3.16/725-phy_rtl8306.patch | 23 +
142 .../generic/patches-3.16/726-phy_rtl8366.patch | 45 +
143 .../generic/patches-3.16/727-phy-rtl8367.patch | 23 +
144 .../generic/patches-3.16/728-phy-micrel.patch | 24 +
145 .../generic/patches-3.16/729-phy-rtl8367b.patch | 23 +
146 .../generic/patches-3.16/729-phy-tantos.patch | 21 +
147 .../linux/generic/patches-3.16/730-phy_b53.patch | 18 +
148 .../731-phy_mvswitch_3.10_compilation.patch | 35 +
149 .../generic/patches-3.16/750-hostap_txpower.patch | 154 +
150 .../patches-3.16/773-bgmac-add-srab-switch.patch | 72 +
151 .../775-bgmac-check-length-of-received-frame.patch | 39 +
152 ...l-pointer-dereference-in-igb_reset_q_vect.patch | 40 +
153 .../810-pci_disable_common_quirks.patch | 51 +
154 .../811-pci_disable_usb_common_quirks.patch | 101 +
155 .../820-usb_add_usb_find_device_by_name.patch | 84 +
156 .../generic/patches-3.16/830-ledtrig_morse.patch | 28 +
157 .../generic/patches-3.16/831-ledtrig_netdev.patch | 60 +
158 .../generic/patches-3.16/832-ledtrig_usbdev.patch | 31 +
159 .../linux/generic/patches-3.16/840-rtc7301.patch | 250 +
160 .../generic/patches-3.16/841-rtc_pt7c4338.patch | 247 +
161 .../861-04_spi_gpio_implement_spi_delay.patch | 58 +
162 .../generic/patches-3.16/862-gpio_spi_driver.patch | 373 ++
163 .../linux/generic/patches-3.16/863-gpiommc.patch | 844 ++++
164 .../864-gpiommc_configfs_locking.patch | 58 +
165 .../patches-3.16/870-hifn795x_byteswap.patch | 17 +
166 .../880-gateworks_system_controller.patch | 339 ++
167 .../patches-3.16/890-8250_optional_sysrq.patch | 24 +
168 .../generic/patches-3.16/900-slab_maxsize.patch | 13 +
169 .../patches-3.16/901-debloat_sock_diag.patch | 45 +
170 .../generic/patches-3.16/902-debloat_proc.patch | 341 ++
171 .../patches-3.16/903-debloat_direct_io.patch | 84 +
172 .../generic/patches-3.16/910-kobject_uevent.patch | 21 +
173 .../911-kobject_add_broadcast_uevent.patch | 65 +
174 .../patches-3.16/921-use_preinit_as_init.patch | 12 +
175 ...2-always-create-console-node-in-initramfs.patch | 30 +
176 .../linux/generic/patches-3.16/930-crashlog.patch | 276 ++
177 .../patches-3.16/940-ocf_kbuild_integration.patch | 20 +
178 .../generic/patches-3.16/941-ocf_20120127.patch | 166 +
179 .../generic/patches-3.16/950-vm_exports.patch | 93 +
180 .../patches-3.16/960-decompress_unlzo_fix.patch | 23 +
181 ...unsane-filenames-from-deps_initramfs-list.patch | 29 +
182 .../patches-3.16/980-arm_openwrt_machtypes.patch | 32 +
183 .../linux/generic/patches-3.16/990-gpio_wdt.patch | 360 ++
184 .../patches-3.16/997-device_tree_cmdline.patch | 12 +
185 ...98-enable_wilink_platform_without_drivers.patch | 15 +
186 175 files changed, 36502 insertions(+)
187 create mode 100644 target/linux/generic/config-3.16
188 create mode 100644 target/linux/generic/patches-3.16/000-keep_initrafs_the_default.patch
189 create mode 100644 target/linux/generic/patches-3.16/020-ssb_update.patch
190 create mode 100644 target/linux/generic/patches-3.16/025-bcma_backport.patch
191 create mode 100644 target/linux/generic/patches-3.16/049-mtd-bcm47xxpart-find-NVRAM-partitions-in-middle-bloc.patch
192 create mode 100644 target/linux/generic/patches-3.16/060-hso_devices.patch
193 create mode 100644 target/linux/generic/patches-3.16/061-arm_xz_decompressor_build_fix.patch
194 create mode 100644 target/linux/generic/patches-3.16/062-mips_decompressor_build_fix.patch
195 create mode 100644 target/linux/generic/patches-3.16/100-overlayfs.patch
196 create mode 100644 target/linux/generic/patches-3.16/102-ehci_hcd_ignore_oc.patch
197 create mode 100644 target/linux/generic/patches-3.16/120-bridge_allow_receiption_on_disabled_port.patch
198 create mode 100644 target/linux/generic/patches-3.16/132-mips_inline_dma_ops.patch
199 create mode 100644 target/linux/generic/patches-3.16/200-fix_localversion.patch
200 create mode 100644 target/linux/generic/patches-3.16/201-extra_optimization.patch
201 create mode 100644 target/linux/generic/patches-3.16/202-reduce_module_size.patch
202 create mode 100644 target/linux/generic/patches-3.16/203-kallsyms_uncompressed.patch
203 create mode 100644 target/linux/generic/patches-3.16/204-module_strip.patch
204 create mode 100644 target/linux/generic/patches-3.16/210-darwin_scripts_include.patch
205 create mode 100644 target/linux/generic/patches-3.16/212-byteshift_portability.patch
206 create mode 100644 target/linux/generic/patches-3.16/220-gc_sections.patch
207 create mode 100644 target/linux/generic/patches-3.16/221-module_exports.patch
208 create mode 100644 target/linux/generic/patches-3.16/230-openwrt_lzma_options.patch
209 create mode 100644 target/linux/generic/patches-3.16/250-netfilter_depends.patch
210 create mode 100644 target/linux/generic/patches-3.16/251-sound_kconfig.patch
211 create mode 100644 target/linux/generic/patches-3.16/252-mv_cesa_depends.patch
212 create mode 100644 target/linux/generic/patches-3.16/253-ssb_b43_default_on.patch
213 create mode 100644 target/linux/generic/patches-3.16/254-textsearch_kconfig_hacks.patch
214 create mode 100644 target/linux/generic/patches-3.16/255-lib80211_kconfig_hacks.patch
215 create mode 100644 target/linux/generic/patches-3.16/256-crypto_add_kconfig_prompts.patch
216 create mode 100644 target/linux/generic/patches-3.16/257-wireless_ext_kconfig_hack.patch
217 create mode 100644 target/linux/generic/patches-3.16/258-netfilter_netlink_kconfig_hack.patch
218 create mode 100644 target/linux/generic/patches-3.16/259-regmap_dynamic.patch
219 create mode 100644 target/linux/generic/patches-3.16/260-crypto_test_dependencies.patch
220 create mode 100644 target/linux/generic/patches-3.16/261-move_bcm963xx_tag.patch
221 create mode 100644 target/linux/generic/patches-3.16/262-compressor_kconfig_hack.patch
222 create mode 100644 target/linux/generic/patches-3.16/300-mips_expose_boot_raw.patch
223 create mode 100644 target/linux/generic/patches-3.16/301-mips_image_cmdline_hack.patch
224 create mode 100644 target/linux/generic/patches-3.16/302-mips_no_branch_likely.patch
225 create mode 100644 target/linux/generic/patches-3.16/304-mips_disable_fpu.patch
226 create mode 100644 target/linux/generic/patches-3.16/305-mips_module_reloc.patch
227 create mode 100644 target/linux/generic/patches-3.16/306-mips_mem_functions_performance.patch
228 create mode 100644 target/linux/generic/patches-3.16/309-mips_fuse_workaround.patch
229 create mode 100644 target/linux/generic/patches-3.16/310-arm_module_unresolved_weak_sym.patch
230 create mode 100644 target/linux/generic/patches-3.16/320-ppc4xx_optimization.patch
231 create mode 100644 target/linux/generic/patches-3.16/321-powerpc_crtsavres_prereq.patch
232 create mode 100644 target/linux/generic/patches-3.16/400-mtd-add-rootfs-split-support.patch
233 create mode 100644 target/linux/generic/patches-3.16/401-mtd-add-support-for-different-partition-parser-types.patch
234 create mode 100644 target/linux/generic/patches-3.16/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch
235 create mode 100644 target/linux/generic/patches-3.16/403-mtd-hook-mtdsplit-to-Kbuild.patch
236 create mode 100644 target/linux/generic/patches-3.16/405-mtd-add-more-helper-functions.patch
237 create mode 100644 target/linux/generic/patches-3.16/406-mtd-hook-mtdsplit-into-Kbuild.patch
238 create mode 100644 target/linux/generic/patches-3.16/410-mtd-move-forward-declaration-of-struct-mtd_info.patch
239 create mode 100644 target/linux/generic/patches-3.16/411-mtd-partial_eraseblock_write.patch
240 create mode 100644 target/linux/generic/patches-3.16/412-mtd-partial_eraseblock_unlock.patch
241 create mode 100644 target/linux/generic/patches-3.16/420-mtd-redboot_space.patch
242 create mode 100644 target/linux/generic/patches-3.16/430-mtd-add-myloader-partition-parser.patch
243 create mode 100644 target/linux/generic/patches-3.16/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch
244 create mode 100644 target/linux/generic/patches-3.16/440-block2mtd_init.patch
245 create mode 100644 target/linux/generic/patches-3.16/441-block2mtd_probe.patch
246 create mode 100644 target/linux/generic/patches-3.16/450-mtd-nand-allow-to-use-platform-specific-chip-fixup.patch
247 create mode 100644 target/linux/generic/patches-3.16/451-mtd-nand-fix-return-code-of-nand_correct_data-function.patch
248 create mode 100644 target/linux/generic/patches-3.16/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch
249 create mode 100644 target/linux/generic/patches-3.16/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch
250 create mode 100644 target/linux/generic/patches-3.16/471-mtd-spi-nor-allow-to-disable-small-sector-erase.patch
251 create mode 100644 target/linux/generic/patches-3.16/472-mtd-spi-nor-add-support-for-Winbond-W25X05-flash.patch
252 create mode 100644 target/linux/generic/patches-3.16/473-mtd-spi-nor-add-support-for-EON-EN25QH128-flash.patch
253 create mode 100644 target/linux/generic/patches-3.16/480-mtd-set-rootfs-to-be-root-dev.patch
254 create mode 100644 target/linux/generic/patches-3.16/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
255 create mode 100644 target/linux/generic/patches-3.16/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
256 create mode 100644 target/linux/generic/patches-3.16/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch
257 create mode 100644 target/linux/generic/patches-3.16/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch
258 create mode 100644 target/linux/generic/patches-3.16/500-yaffs-Kbuild-integration.patch
259 create mode 100644 target/linux/generic/patches-3.16/501-yaffs-3.5-convert-to-use-kuid_t-kgid_t.patch
260 create mode 100644 target/linux/generic/patches-3.16/502-yaffs-3.10-disable-proc-entry.patch
261 create mode 100644 target/linux/generic/patches-3.16/503-yaffs-3.12-convert-readdir-to-iterate.patch
262 create mode 100644 target/linux/generic/patches-3.16/503-yaffs-add-tags-9bytes-mount-option.patch
263 create mode 100644 target/linux/generic/patches-3.16/504-yaffs-fix-compat-tags-handling.patch
264 create mode 100644 target/linux/generic/patches-3.16/520-squashfs_update_xz_comp_opts.patch
265 create mode 100644 target/linux/generic/patches-3.16/530-jffs2_make_lzma_available.patch
266 create mode 100644 target/linux/generic/patches-3.16/531-debloat_lzma.patch
267 create mode 100644 target/linux/generic/patches-3.16/532-jffs2_eofdetect.patch
268 create mode 100644 target/linux/generic/patches-3.16/540-crypto-xz-decompression-support.patch
269 create mode 100644 target/linux/generic/patches-3.16/541-ubifs-xz-decompression-support.patch
270 create mode 100644 target/linux/generic/patches-3.16/550-ubifs-symlink-xattr-support.patch
271 create mode 100644 target/linux/generic/patches-3.16/551-ubifs-fix-default-compression-selection.patch
272 create mode 100644 target/linux/generic/patches-3.16/600-netfilter_layer7_2.22.patch
273 create mode 100644 target/linux/generic/patches-3.16/601-netfilter_layer7_pktmatch.patch
274 create mode 100644 target/linux/generic/patches-3.16/602-netfilter_layer7_match.patch
275 create mode 100644 target/linux/generic/patches-3.16/603-netfilter_layer7_2.6.36_fix.patch
276 create mode 100644 target/linux/generic/patches-3.16/604-netfilter_conntrack_flush.patch
277 create mode 100644 target/linux/generic/patches-3.16/610-netfilter_match_bypass_default_checks.patch
278 create mode 100644 target/linux/generic/patches-3.16/611-netfilter_match_bypass_default_table.patch
279 create mode 100644 target/linux/generic/patches-3.16/612-netfilter_match_reduce_memory_access.patch
280 create mode 100644 target/linux/generic/patches-3.16/613-netfilter_optional_tcp_window_check.patch
281 create mode 100644 target/linux/generic/patches-3.16/615-netfilter_add_xt_id_match.patch
282 create mode 100644 target/linux/generic/patches-3.16/616-net_optimize_xfrm_calls.patch
283 create mode 100644 target/linux/generic/patches-3.16/617-netfilter_skip_filter_sysctl.patch
284 create mode 100644 target/linux/generic/patches-3.16/620-sched_esfq.patch
285 create mode 100644 target/linux/generic/patches-3.16/630-packet_socket_type.patch
286 create mode 100644 target/linux/generic/patches-3.16/640-bridge_no_eap_forward.patch
287 create mode 100644 target/linux/generic/patches-3.16/641-bridge_always_accept_eap.patch
288 create mode 100644 target/linux/generic/patches-3.16/642-bridge_port_isolate.patch
289 create mode 100644 target/linux/generic/patches-3.16/643-bridge_remove_ipv6_dependency.patch
290 create mode 100644 target/linux/generic/patches-3.16/644-bridge_optimize_netfilter_hooks.patch
291 create mode 100644 target/linux/generic/patches-3.16/645-bridge_multicast_to_unicast.patch
292 create mode 100644 target/linux/generic/patches-3.16/650-pppoe_header_pad.patch
293 create mode 100644 target/linux/generic/patches-3.16/651-wireless_mesh_header.patch
294 create mode 100644 target/linux/generic/patches-3.16/652-atm_header_changes.patch
295 create mode 100644 target/linux/generic/patches-3.16/653-disable_netlink_trim.patch
296 create mode 100644 target/linux/generic/patches-3.16/655-increase_skb_pad.patch
297 create mode 100644 target/linux/generic/patches-3.16/656-skb_reduce_truesize-helper.patch
298 create mode 100644 target/linux/generic/patches-3.16/657-qdisc_reduce_truesize.patch
299 create mode 100644 target/linux/generic/patches-3.16/660-fq_codel_defaults.patch
300 create mode 100644 target/linux/generic/patches-3.16/661-fq_codel_keep_dropped_stats.patch
301 create mode 100644 target/linux/generic/patches-3.16/662-use_fq_codel_by_default.patch
302 create mode 100644 target/linux/generic/patches-3.16/663-remove_pfifo_fast.patch
303 create mode 100644 target/linux/generic/patches-3.16/664-codel_fix_3_12.patch
304 create mode 100644 target/linux/generic/patches-3.16/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch
305 create mode 100644 target/linux/generic/patches-3.16/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch
306 create mode 100644 target/linux/generic/patches-3.16/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch
307 create mode 100644 target/linux/generic/patches-3.16/700-swconfig.patch
308 create mode 100644 target/linux/generic/patches-3.16/701-phy_extension.patch
309 create mode 100644 target/linux/generic/patches-3.16/702-phy_add_aneg_done_function.patch
310 create mode 100644 target/linux/generic/patches-3.16/703-phy-add-detach-callback-to-struct-phy_driver.patch
311 create mode 100644 target/linux/generic/patches-3.16/710-phy-add-mdio_register_board_info.patch
312 create mode 100644 target/linux/generic/patches-3.16/720-phy_adm6996.patch
313 create mode 100644 target/linux/generic/patches-3.16/721-phy_packets.patch
314 create mode 100644 target/linux/generic/patches-3.16/722-phy_mvswitch.patch
315 create mode 100644 target/linux/generic/patches-3.16/723-phy_ip175c.patch
316 create mode 100644 target/linux/generic/patches-3.16/724-phy_ar8216.patch
317 create mode 100644 target/linux/generic/patches-3.16/725-phy_rtl8306.patch
318 create mode 100644 target/linux/generic/patches-3.16/726-phy_rtl8366.patch
319 create mode 100644 target/linux/generic/patches-3.16/727-phy-rtl8367.patch
320 create mode 100644 target/linux/generic/patches-3.16/728-phy-micrel.patch
321 create mode 100644 target/linux/generic/patches-3.16/729-phy-rtl8367b.patch
322 create mode 100644 target/linux/generic/patches-3.16/729-phy-tantos.patch
323 create mode 100644 target/linux/generic/patches-3.16/730-phy_b53.patch
324 create mode 100644 target/linux/generic/patches-3.16/731-phy_mvswitch_3.10_compilation.patch
325 create mode 100644 target/linux/generic/patches-3.16/750-hostap_txpower.patch
326 create mode 100644 target/linux/generic/patches-3.16/773-bgmac-add-srab-switch.patch
327 create mode 100644 target/linux/generic/patches-3.16/775-bgmac-check-length-of-received-frame.patch
328 create mode 100644 target/linux/generic/patches-3.16/780-igb-Fix-Null-pointer-dereference-in-igb_reset_q_vect.patch
329 create mode 100644 target/linux/generic/patches-3.16/810-pci_disable_common_quirks.patch
330 create mode 100644 target/linux/generic/patches-3.16/811-pci_disable_usb_common_quirks.patch
331 create mode 100644 target/linux/generic/patches-3.16/820-usb_add_usb_find_device_by_name.patch
332 create mode 100644 target/linux/generic/patches-3.16/830-ledtrig_morse.patch
333 create mode 100644 target/linux/generic/patches-3.16/831-ledtrig_netdev.patch
334 create mode 100644 target/linux/generic/patches-3.16/832-ledtrig_usbdev.patch
335 create mode 100644 target/linux/generic/patches-3.16/840-rtc7301.patch
336 create mode 100644 target/linux/generic/patches-3.16/841-rtc_pt7c4338.patch
337 create mode 100644 target/linux/generic/patches-3.16/861-04_spi_gpio_implement_spi_delay.patch
338 create mode 100644 target/linux/generic/patches-3.16/862-gpio_spi_driver.patch
339 create mode 100644 target/linux/generic/patches-3.16/863-gpiommc.patch
340 create mode 100644 target/linux/generic/patches-3.16/864-gpiommc_configfs_locking.patch
341 create mode 100644 target/linux/generic/patches-3.16/870-hifn795x_byteswap.patch
342 create mode 100644 target/linux/generic/patches-3.16/880-gateworks_system_controller.patch
343 create mode 100644 target/linux/generic/patches-3.16/890-8250_optional_sysrq.patch
344 create mode 100644 target/linux/generic/patches-3.16/900-slab_maxsize.patch
345 create mode 100644 target/linux/generic/patches-3.16/901-debloat_sock_diag.patch
346 create mode 100644 target/linux/generic/patches-3.16/902-debloat_proc.patch
347 create mode 100644 target/linux/generic/patches-3.16/903-debloat_direct_io.patch
348 create mode 100644 target/linux/generic/patches-3.16/910-kobject_uevent.patch
349 create mode 100644 target/linux/generic/patches-3.16/911-kobject_add_broadcast_uevent.patch
350 create mode 100644 target/linux/generic/patches-3.16/921-use_preinit_as_init.patch
351 create mode 100644 target/linux/generic/patches-3.16/922-always-create-console-node-in-initramfs.patch
352 create mode 100644 target/linux/generic/patches-3.16/930-crashlog.patch
353 create mode 100644 target/linux/generic/patches-3.16/940-ocf_kbuild_integration.patch
354 create mode 100644 target/linux/generic/patches-3.16/941-ocf_20120127.patch
355 create mode 100644 target/linux/generic/patches-3.16/950-vm_exports.patch
356 create mode 100644 target/linux/generic/patches-3.16/960-decompress_unlzo_fix.patch
357 create mode 100644 target/linux/generic/patches-3.16/970-remove-unsane-filenames-from-deps_initramfs-list.patch
358 create mode 100644 target/linux/generic/patches-3.16/980-arm_openwrt_machtypes.patch
359 create mode 100644 target/linux/generic/patches-3.16/990-gpio_wdt.patch
360 create mode 100644 target/linux/generic/patches-3.16/997-device_tree_cmdline.patch
361 create mode 100644 target/linux/generic/patches-3.16/998-enable_wilink_platform_without_drivers.patch
363 diff --git a/target/linux/generic/config-3.16 b/target/linux/generic/config-3.16
364 new file mode 100644
365 index 000000000000..9297af2cade9
366 --- /dev/null
367 +++ b/target/linux/generic/config-3.16
368 @@ -0,0 +1,4537 @@
369 +# CONFIG_SERIAL_8250_SYSRQ is not set
370 +CONFIG_SWP_EMULATE=y
371 +# CONFIG_THUMB2_KERNEL is not set
372 +# CONFIG_IP_PNP_BOOTP is not set
373 +# CONFIG_IP_PNP_DHCP is not set
374 +# CONFIG_IP_PNP_RARP is not set
375 +# CONFIG_XEN is not set
376 +# CONFIG_NEON is not set
377 +# CONFIG_CPU_BPREDICT_DISABLE is not set
378 +# CONFIG_PL310_ERRATA_588369 is not set
379 +# CONFIG_PL310_ERRATA_727915 is not set
380 +# CONFIG_PL310_ERRATA_753970 is not set
381 +# CONFIG_PL310_ERRATA_769419 is not set
382 +# CONFIG_IWMMXT is not set
383 +# CONFIG_PJ4B_ERRATA_4742 is not set
384 +# CONFIG_SMP_ON_UP is not set
385 +CONFIG_32BIT=y
386 +# CONFIG_6PACK is not set
387 +# CONFIG_8139CP is not set
388 +# CONFIG_8139TOO is not set
389 +# CONFIG_9P_FS is not set
390 +# CONFIG_AB3100_CORE is not set
391 +# CONFIG_AB8500_CORE is not set
392 +# CONFIG_ABX500_CORE is not set
393 +# CONFIG_ACCESSIBILITY is not set
394 +# CONFIG_ACENIC is not set
395 +# CONFIG_ACERHDF is not set
396 +# CONFIG_ACORN_PARTITION is not set
397 +# CONFIG_ACPI_APEI is not set
398 +# CONFIG_ACPI_CUSTOM_METHOD is not set
399 +# CONFIG_ACPI_EXTLOG is not set
400 +# CONFIG_ACPI_HED is not set
401 +# CONFIG_ACPI_INT3403_THERMAL is not set
402 +# CONFIG_ACPI_POWER_METER is not set
403 +# CONFIG_ACPI_QUICKSTART is not set
404 +# CONFIG_AD2S1200 is not set
405 +# CONFIG_AD2S1210 is not set
406 +# CONFIG_AD2S90 is not set
407 +# CONFIG_AD5064 is not set
408 +# CONFIG_AD525X_DPOT is not set
409 +# CONFIG_AD5360 is not set
410 +# CONFIG_AD5380 is not set
411 +# CONFIG_AD5421 is not set
412 +# CONFIG_AD5446 is not set
413 +# CONFIG_AD5449 is not set
414 +# CONFIG_AD5504 is not set
415 +# CONFIG_AD5624R_SPI is not set
416 +# CONFIG_AD5686 is not set
417 +# CONFIG_AD5755 is not set
418 +# CONFIG_AD5764 is not set
419 +# CONFIG_AD5791 is not set
420 +# CONFIG_AD5930 is not set
421 +# CONFIG_AD5933 is not set
422 +# CONFIG_AD7150 is not set
423 +# CONFIG_AD7152 is not set
424 +# CONFIG_AD7192 is not set
425 +# CONFIG_AD7266 is not set
426 +# CONFIG_AD7280 is not set
427 +# CONFIG_AD7291 is not set
428 +# CONFIG_AD7298 is not set
429 +# CONFIG_AD7303 is not set
430 +# CONFIG_AD7476 is not set
431 +# CONFIG_AD7606 is not set
432 +# CONFIG_AD7746 is not set
433 +# CONFIG_AD7780 is not set
434 +# CONFIG_AD7791 is not set
435 +# CONFIG_AD7793 is not set
436 +# CONFIG_AD7816 is not set
437 +# CONFIG_AD7887 is not set
438 +# CONFIG_AD7923 is not set
439 +# CONFIG_AD799X is not set
440 +# CONFIG_AD8366 is not set
441 +# CONFIG_AD9523 is not set
442 +# CONFIG_AD9832 is not set
443 +# CONFIG_AD9834 is not set
444 +# CONFIG_AD9850 is not set
445 +# CONFIG_AD9852 is not set
446 +# CONFIG_AD9910 is not set
447 +# CONFIG_AD9951 is not set
448 +# CONFIG_ADAPTEC_STARFIRE is not set
449 +# CONFIG_ADE7753 is not set
450 +# CONFIG_ADE7754 is not set
451 +# CONFIG_ADE7758 is not set
452 +# CONFIG_ADE7759 is not set
453 +# CONFIG_ADE7854 is not set
454 +# CONFIG_ADF4350 is not set
455 +# CONFIG_ADFS_FS is not set
456 +# CONFIG_ADIS16060 is not set
457 +# CONFIG_ADIS16080 is not set
458 +# CONFIG_ADIS16130 is not set
459 +# CONFIG_ADIS16136 is not set
460 +# CONFIG_ADIS16201 is not set
461 +# CONFIG_ADIS16203 is not set
462 +# CONFIG_ADIS16204 is not set
463 +# CONFIG_ADIS16209 is not set
464 +# CONFIG_ADIS16220 is not set
465 +# CONFIG_ADIS16240 is not set
466 +# CONFIG_ADIS16255 is not set
467 +# CONFIG_ADIS16260 is not set
468 +# CONFIG_ADIS16400 is not set
469 +# CONFIG_ADIS16480 is not set
470 +# CONFIG_ADJD_S311 is not set
471 +# CONFIG_ADM6996_PHY is not set
472 +# CONFIG_ADM8211 is not set
473 +# CONFIG_ADT7316 is not set
474 +# CONFIG_ADXRS450 is not set
475 +CONFIG_AEABI=y
476 +# CONFIG_AFFS_FS is not set
477 +# CONFIG_AF_RXRPC is not set
478 +# CONFIG_AFS_FS is not set
479 +# CONFIG_AGP is not set
480 +CONFIG_AIO=y
481 +# CONFIG_AIRO_CS is not set
482 +# CONFIG_AIRO is not set
483 +# CONFIG_AIX_PARTITION is not set
484 +# CONFIG_AK8975 is not set
485 +# CONFIG_ALCHEMY_GPIO_INDIRECT is not set
486 +CONFIG_ALIGNMENT_TRAP=y
487 +# CONFIG_ALIM7101_WDT is not set
488 +# CONFIG_ALTERA_STAPL is not set
489 +# CONFIG_ALTERA_TSE is not set
490 +# CONFIG_ALX is not set
491 +# CONFIG_AM335X_PHY_USB is not set
492 +# CONFIG_AMD8111_ETH is not set
493 +# CONFIG_AMD_PHY is not set
494 +# CONFIG_AMD_XGBE is not set
495 +# CONFIG_AMD_XGBE_PHY is not set
496 +# CONFIG_AMIGA_PARTITION is not set
497 +# CONFIG_AMILO_RFKILL is not set
498 +# CONFIG_ANDROID is not set
499 +CONFIG_ANON_INODES=y
500 +# CONFIG_APDS9300 is not set
501 +# CONFIG_APDS9802ALS is not set
502 +# CONFIG_APM8018X is not set
503 +# CONFIG_APPLICOM is not set
504 +# CONFIG_AR5523 is not set
505 +# CONFIG_AR7 is not set
506 +# CONFIG_AR8216_PHY is not set
507 +# CONFIG_ARC_EMAC is not set
508 +# CONFIG_ARCH_AT91 is not set
509 +# CONFIG_ARCH_BCM2835 is not set
510 +# CONFIG_ARCH_BCM is not set
511 +# CONFIG_ARCH_BCMRING is not set
512 +# CONFIG_ARCH_BERLIN is not set
513 +CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y
514 +# CONFIG_ARCH_CLPS711X is not set
515 +# CONFIG_ARCH_CNS3XXX is not set
516 +# CONFIG_ARCH_DAVINCI is not set
517 +# CONFIG_ARCH_DMA_ADDR_T_64BIT is not set
518 +# CONFIG_ARCH_DOVE is not set
519 +# CONFIG_ARCH_EBSA110 is not set
520 +# CONFIG_ARCH_EP93XX is not set
521 +# CONFIG_ARCH_EXYNOS is not set
522 +CONFIG_ARCH_FLATMEM_ENABLE=y
523 +# CONFIG_ARCH_FOOTBRIDGE is not set
524 +# CONFIG_ARCH_GEMINI is not set
525 +# CONFIG_ARCH_H720X is not set
526 +CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
527 +# CONFIG_ARCH_HAS_ILOG2_U32 is not set
528 +# CONFIG_ARCH_HAS_ILOG2_U64 is not set
529 +CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
530 +# CONFIG_ARCH_HI3xxx is not set
531 +CONFIG_ARCH_HIBERNATION_POSSIBLE=y
532 +# CONFIG_ARCH_HIGHBANK is not set
533 +# CONFIG_ARCH_INTEGRATOR is not set
534 +# CONFIG_ARCH_IOP13XX is not set
535 +# CONFIG_ARCH_IOP32X is not set
536 +# CONFIG_ARCH_IOP33X is not set
537 +# CONFIG_ARCH_IXP2000 is not set
538 +# CONFIG_ARCH_IXP23XX is not set
539 +# CONFIG_ARCH_IXP4XX is not set
540 +# CONFIG_ARCH_KEYSTONE is not set
541 +# CONFIG_ARCH_KIRKWOOD is not set
542 +# CONFIG_ARCH_KS8695 is not set
543 +# CONFIG_ARCH_LPC32XX is not set
544 +CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
545 +# CONFIG_ARCH_MMP is not set
546 +# CONFIG_ARCH_MSM is not set
547 +CONFIG_ARCH_MULTI_CPU_AUTO=y
548 +# CONFIG_ARCH_MULTIPLATFORM is not set
549 +# CONFIG_ARCH_MULTI_V4 is not set
550 +# CONFIG_ARCH_MULTI_V4T is not set
551 +# CONFIG_ARCH_MULTI_V4_V5 is not set
552 +# CONFIG_ARCH_MULTI_V5 is not set
553 +# CONFIG_ARCH_MULTI_V6 is not set
554 +# CONFIG_ARCH_MULTI_V7 is not set
555 +# CONFIG_ARCH_MV78XX0 is not set
556 +# CONFIG_ARCH_MVEBU is not set
557 +# CONFIG_ARCH_MXC is not set
558 +# CONFIG_ARCH_MXS is not set
559 +# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set
560 +# CONFIG_ARCH_NETX is not set
561 +# CONFIG_ARCH_NOMADIK is not set
562 +CONFIG_ARCH_NR_GPIO=0
563 +# CONFIG_ARCH_NSPIRE is not set
564 +# CONFIG_ARCH_NUC93X is not set
565 +# CONFIG_ARCH_OMAP1 is not set
566 +# CONFIG_ARCH_OMAP2PLUS is not set
567 +# CONFIG_ARCH_OMAP3 is not set
568 +# CONFIG_ARCH_OMAP4 is not set
569 +# CONFIG_ARCH_OMAP is not set
570 +# CONFIG_ARCH_ORION5X is not set
571 +# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
572 +# CONFIG_ARCH_PICOXCELL is not set
573 +# CONFIG_ARCH_PNX4008 is not set
574 +# CONFIG_ARCH_PRIMA2 is not set
575 +# CONFIG_ARCH_PXA is not set
576 +# CONFIG_ARCH_QCOM is not set
577 +# CONFIG_ARCH_REALVIEW is not set
578 +# CONFIG_ARCH_ROCKCHIP is not set
579 +# CONFIG_ARCH_RPC is not set
580 +# CONFIG_ARCH_S3C24XX is not set
581 +# CONFIG_ARCH_S3C64XX is not set
582 +# CONFIG_ARCH_S5P64X0 is not set
583 +# CONFIG_ARCH_S5PC100 is not set
584 +# CONFIG_ARCH_S5PV210 is not set
585 +# CONFIG_ARCH_SA1100 is not set
586 +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
587 +# CONFIG_ARCH_SHARK is not set
588 +# CONFIG_ARCH_SHMOBILE is not set
589 +# CONFIG_ARCH_SHMOBILE_LEGACY is not set
590 +# CONFIG_ARCH_SHMOBILE_MULTI is not set
591 +# CONFIG_ARCH_SIRF is not set
592 +# CONFIG_ARCH_SOCFPGA is not set
593 +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
594 +# CONFIG_ARCH_STI is not set
595 +# CONFIG_ARCH_SUNXI is not set
596 +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
597 +CONFIG_ARCH_SUPPORTS_UPROBES=y
598 +CONFIG_ARCH_SUSPEND_POSSIBLE=y
599 +# CONFIG_ARCH_TCC_926 is not set
600 +# CONFIG_ARCH_TEGRA is not set
601 +# CONFIG_ARCH_U300 is not set
602 +# CONFIG_ARCH_U8500 is not set
603 +CONFIG_ARCH_USE_BUILTIN_BSWAP=y
604 +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
605 +# CONFIG_ARCH_VERSATILE is not set
606 +# CONFIG_ARCH_VEXPRESS is not set
607 +# CONFIG_ARCH_VIRT is not set
608 +# CONFIG_ARCH_VT8500 is not set
609 +# CONFIG_ARCH_W90X900 is not set
610 +CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
611 +CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
612 +CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
613 +# CONFIG_ARCH_WM8505 is not set
614 +# CONFIG_ARCH_WM8850 is not set
615 +# CONFIG_ARCH_ZYNQ is not set
616 +# CONFIG_ARCNET is not set
617 +# CONFIG_ARM_APPENDED_DTB is not set
618 +# CONFIG_ARM_ARCH_TIMER is not set
619 +# CONFIG_ARM_AT91_ETHER is not set
620 +# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND is not set
621 +# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER is not set
622 +# CONFIG_ARM_CCI is not set
623 +# CONFIG_ARM_CPU_SUSPEND is not set
624 +CONFIG_ARM_CPU_TOPOLOGY=y
625 +CONFIG_ARM_DMA_MEM_BUFFERABLE=y
626 +# CONFIG_ARM_ERRATA_326103 is not set
627 +# CONFIG_ARM_ERRATA_364296 is not set
628 +# CONFIG_ARM_ERRATA_411920 is not set
629 +# CONFIG_ARM_ERRATA_430973 is not set
630 +# CONFIG_ARM_ERRATA_458693 is not set
631 +# CONFIG_ARM_ERRATA_460075 is not set
632 +# CONFIG_ARM_ERRATA_643719 is not set
633 +# CONFIG_ARM_ERRATA_720789 is not set
634 +# CONFIG_ARM_ERRATA_742230 is not set
635 +# CONFIG_ARM_ERRATA_742231 is not set
636 +# CONFIG_ARM_ERRATA_743622 is not set
637 +# CONFIG_ARM_ERRATA_751472 is not set
638 +# CONFIG_ARM_ERRATA_754322 is not set
639 +# CONFIG_ARM_ERRATA_754327 is not set
640 +# CONFIG_ARM_ERRATA_764369 is not set
641 +# CONFIG_ARM_ERRATA_773022 is not set
642 +# CONFIG_ARM_ERRATA_775420 is not set
643 +# CONFIG_ARM_ERRATA_798181 is not set
644 +CONFIG_ARM_HAS_SG_CHAIN=y
645 +CONFIG_ARM_L1_CACHE_SHIFT=5
646 +# CONFIG_ARM_LPAE is not set
647 +# CONFIG_ARM_PATCH_PHYS_VIRT is not set
648 +# CONFIG_ARM_PSCI is not set
649 +# CONFIG_ARM_PTDUMP is not set
650 +CONFIG_ARM_THUMB=y
651 +CONFIG_ARM_THUMBEE=y
652 +# CONFIG_ARM_UNWIND is not set
653 +# CONFIG_ARM_VIRT_EXT is not set
654 +CONFIG_ARPD=y
655 +# CONFIG_ARTHUR is not set
656 +# CONFIG_ASUS_OLED is not set
657 +# CONFIG_ASYMMETRIC_KEY_TYPE is not set
658 +# CONFIG_ASYNC_RAID6_TEST is not set
659 +# CONFIG_ASYNC_TX_DMA is not set
660 +# CONFIG_AT76C50X_USB is not set
661 +# CONFIG_AT803X_PHY is not set
662 +# CONFIG_ATA_ACPI is not set
663 +CONFIG_ATA_BMDMA=y
664 +# CONFIG_ATA_GENERIC is not set
665 +# CONFIG_ATAGS is not set
666 +CONFIG_ATAGS_PROC=y
667 +# CONFIG_ATA is not set
668 +# CONFIG_ATALK is not set
669 +# CONFIG_ATA_NONSTANDARD is not set
670 +# CONFIG_ATA_OVER_ETH is not set
671 +# CONFIG_ATA_PIIX is not set
672 +# CONFIG_ATARI_PARTITION is not set
673 +CONFIG_ATA_SFF=y
674 +# CONFIG_ATA_VERBOSE_ERROR is not set
675 +# CONFIG_ATH10K is not set
676 +# CONFIG_ATH5K is not set
677 +# CONFIG_ATH6K_LEGACY is not set
678 +# CONFIG_ATH6KL is not set
679 +# CONFIG_ATH79 is not set
680 +# CONFIG_ATH9K_HTC is not set
681 +# CONFIG_ATH9K is not set
682 +CONFIG_ATH_CARDS=m
683 +# CONFIG_ATH_DEBUG is not set
684 +# CONFIG_ATL1C is not set
685 +# CONFIG_ATL1E is not set
686 +# CONFIG_ATL1 is not set
687 +# CONFIG_ATL2 is not set
688 +# CONFIG_ATM_AMBASSADOR is not set
689 +CONFIG_ATM_BR2684_IPFILTER=y
690 +# CONFIG_ATM_BR2684 is not set
691 +# CONFIG_ATM_CLIP is not set
692 +CONFIG_ATM_CLIP_NO_ICMP=y
693 +# CONFIG_ATM_DRIVERS is not set
694 +# CONFIG_ATM_DUMMY is not set
695 +# CONFIG_ATMEL is not set
696 +# CONFIG_ATMEL_PWM is not set
697 +# CONFIG_ATMEL_SSC is not set
698 +# CONFIG_ATM_ENI is not set
699 +# CONFIG_ATM_FIRESTREAM is not set
700 +# CONFIG_ATM_FORE200E is not set
701 +# CONFIG_ATM_HE is not set
702 +# CONFIG_ATM_HORIZON is not set
703 +# CONFIG_ATM_IA is not set
704 +# CONFIG_ATM_IDT77252 is not set
705 +# CONFIG_ATM is not set
706 +# CONFIG_ATM_LANAI is not set
707 +# CONFIG_ATM_LANE is not set
708 +# CONFIG_ATM_MPOA is not set
709 +# CONFIG_ATM_NICSTAR is not set
710 +# CONFIG_ATM_SOLOS is not set
711 +# CONFIG_ATM_TCP is not set
712 +# CONFIG_ATM_ZATM is not set
713 +# CONFIG_ATOMIC64_SELFTEST is not set
714 +# CONFIG_ATP is not set
715 +# CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set
716 +# CONFIG_AUDIT is not set
717 +# CONFIG_AUDIT_LOGINUID_IMMUTABLE is not set
718 +# CONFIG_AUTOFS4_FS is not set
719 +# CONFIG_AUTO_ZRELADDR is not set
720 +# CONFIG_AUXDISPLAY is not set
721 +# CONFIG_AVERAGE is not set
722 +# CONFIG_AX25_DAMA_SLAVE is not set
723 +# CONFIG_AX25 is not set
724 +# CONFIG_AX88796 is not set
725 +# CONFIG_B43 is not set
726 +# CONFIG_B43LEGACY is not set
727 +# CONFIG_B44 is not set
728 +# CONFIG_B53 is not set
729 +# CONFIG_B53_SPI_DRIVER is not set
730 +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
731 +# CONFIG_BACKLIGHT_LM3630A is not set
732 +# CONFIG_BACKLIGHT_LM3630 is not set
733 +# CONFIG_BACKLIGHT_LM3639 is not set
734 +# CONFIG_BACKLIGHT_LP855X is not set
735 +# CONFIG_BACKTRACE_SELF_TEST is not set
736 +CONFIG_BASE_FULL=y
737 +CONFIG_BASE_SMALL=0
738 +# CONFIG_BATMAN_ADV is not set
739 +# CONFIG_BATTERY_BQ27x00 is not set
740 +# CONFIG_BATTERY_DS2760 is not set
741 +# CONFIG_BATTERY_DS2780 is not set
742 +# CONFIG_BATTERY_DS2781 is not set
743 +# CONFIG_BATTERY_DS2782 is not set
744 +# CONFIG_BATTERY_GOLDFISH is not set
745 +# CONFIG_BATTERY_MAX17040 is not set
746 +# CONFIG_BATTERY_MAX17042 is not set
747 +# CONFIG_BATTERY_SBS is not set
748 +# CONFIG_BAYCOM_EPP is not set
749 +# CONFIG_BAYCOM_PAR is not set
750 +# CONFIG_BAYCOM_SER_FDX is not set
751 +# CONFIG_BAYCOM_SER_HDX is not set
752 +# CONFIG_BCACHE is not set
753 +# CONFIG_BCM47XX is not set
754 +# CONFIG_BCM63XX is not set
755 +# CONFIG_BCM63XX_PHY is not set
756 +# CONFIG_BCM7XXX_PHY is not set
757 +# CONFIG_BCM87XX_PHY is not set
758 +# CONFIG_BCMA_DRIVER_GPIO is not set
759 +# CONFIG_BCMA is not set
760 +CONFIG_BCMA_POSSIBLE=y
761 +# CONFIG_BCMGENET is not set
762 +# CONFIG_BCM_KONA_USB2_PHY is not set
763 +# CONFIG_BCM_WIMAX is not set
764 +# CONFIG_BDI_SWITCH is not set
765 +# CONFIG_BE2ISCSI is not set
766 +# CONFIG_BE2NET is not set
767 +# CONFIG_BEFS_FS is not set
768 +# CONFIG_BFS_FS is not set
769 +# CONFIG_BGMAC is not set
770 +# CONFIG_BIG_KEYS is not set
771 +# CONFIG_BIG_LITTLE is not set
772 +# CONFIG_BINARY_PRINTF is not set
773 +# CONFIG_BINFMT_AOUT is not set
774 +CONFIG_BINFMT_ELF=y
775 +# CONFIG_BINFMT_MISC is not set
776 +CONFIG_BINFMT_SCRIPT=y
777 +CONFIG_BITREVERSE=y
778 +# CONFIG_BLK_CMDLINE_PARSER is not set
779 +# CONFIG_BLK_CPQ_CISS_DA is not set
780 +# CONFIG_BLK_CPQ_DA is not set
781 +# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
782 +# CONFIG_BLK_DEV_4DRIVES is not set
783 +# CONFIG_BLK_DEV_AEC62XX is not set
784 +# CONFIG_BLK_DEV_ALI14XX is not set
785 +# CONFIG_BLK_DEV_ALI15X3 is not set
786 +# CONFIG_BLK_DEV_AMD74XX is not set
787 +# CONFIG_BLK_DEV_ATIIXP is not set
788 +# CONFIG_BLK_DEV_BSG is not set
789 +# CONFIG_BLK_DEV_BSGLIB is not set
790 +# CONFIG_BLK_DEV_CMD640 is not set
791 +# CONFIG_BLK_DEV_CMD64X is not set
792 +# CONFIG_BLK_DEV_COW_COMMON is not set
793 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
794 +# CONFIG_BLK_DEV_CS5520 is not set
795 +# CONFIG_BLK_DEV_CS5530 is not set
796 +# CONFIG_BLK_DEV_CS5535 is not set
797 +# CONFIG_BLK_DEV_CS5536 is not set
798 +# CONFIG_BLK_DEV_CY82C693 is not set
799 +# CONFIG_BLK_DEV_DAC960 is not set
800 +# CONFIG_BLK_DEV_DELKIN is not set
801 +# CONFIG_BLK_DEV_DRBD is not set
802 +# CONFIG_BLK_DEV_DTC2278 is not set
803 +# CONFIG_BLK_DEV_FD is not set
804 +# CONFIG_BLK_DEV_GENERIC is not set
805 +# CONFIG_BLK_DEV_HD is not set
806 +# CONFIG_BLK_DEV_HPT366 is not set
807 +# CONFIG_BLK_DEV_HT6560B is not set
808 +# CONFIG_BLK_DEV_IDEACPI is not set
809 +# CONFIG_BLK_DEV_IDE_AU1XXX is not set
810 +# CONFIG_BLK_DEV_IDECD is not set
811 +# CONFIG_BLK_DEV_IDECS is not set
812 +# CONFIG_BLK_DEV_IDEPCI is not set
813 +# CONFIG_BLK_DEV_IDEPNP is not set
814 +# CONFIG_BLK_DEV_IDE_SATA is not set
815 +# CONFIG_BLK_DEV_IDETAPE is not set
816 +CONFIG_BLK_DEV_INITRD=y
817 +# CONFIG_BLK_DEV_INTEGRITY is not set
818 +# CONFIG_BLK_DEV_IO_TRACE is not set
819 +# CONFIG_BLK_DEV_IT8172 is not set
820 +# CONFIG_BLK_DEV_IT8213 is not set
821 +# CONFIG_BLK_DEV_IT821X is not set
822 +# CONFIG_BLK_DEV_JMICRON is not set
823 +# CONFIG_BLK_DEV_LOOP is not set
824 +CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
825 +# CONFIG_BLK_DEV_NBD is not set
826 +# CONFIG_BLK_DEV_NS87415 is not set
827 +# CONFIG_BLK_DEV_NULL_BLK is not set
828 +# CONFIG_BLK_DEV_NVME is not set
829 +# CONFIG_BLK_DEV_OFFBOARD is not set
830 +# CONFIG_BLK_DEV_OPTI621 is not set
831 +# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set
832 +# CONFIG_BLK_DEV_PDC202XX_NEW is not set
833 +# CONFIG_BLK_DEV_PDC202XX_OLD is not set
834 +# CONFIG_BLK_DEV_PIIX is not set
835 +# CONFIG_BLK_DEV_PLATFORM is not set
836 +# CONFIG_BLK_DEV_QD65XX is not set
837 +# CONFIG_BLK_DEV_RAM is not set
838 +# CONFIG_BLK_DEV_RBD is not set
839 +# CONFIG_BLK_DEV_RSXX is not set
840 +# CONFIG_BLK_DEV_RZ1000 is not set
841 +# CONFIG_BLK_DEV_SC1200 is not set
842 +# CONFIG_BLK_DEV_SD is not set
843 +# CONFIG_BLK_DEV_SIIMAGE is not set
844 +# CONFIG_BLK_DEV_SIS5513 is not set
845 +# CONFIG_BLK_DEV_SKD is not set
846 +# CONFIG_BLK_DEV_SL82C105 is not set
847 +# CONFIG_BLK_DEV_SLC90E66 is not set
848 +# CONFIG_BLK_DEV_SR is not set
849 +# CONFIG_BLK_DEV_SVWKS is not set
850 +# CONFIG_BLK_DEV_SX8 is not set
851 +# CONFIG_BLK_DEV_TC86C001 is not set
852 +# CONFIG_BLK_DEV_THROTTLING is not set
853 +# CONFIG_BLK_DEV_TRIFLEX is not set
854 +# CONFIG_BLK_DEV_TRM290 is not set
855 +# CONFIG_BLK_DEV_UB is not set
856 +# CONFIG_BLK_DEV_UMC8672 is not set
857 +# CONFIG_BLK_DEV_UMEM is not set
858 +# CONFIG_BLK_DEV_VIA82CXXX is not set
859 +# CONFIG_BLK_DEV_XIP is not set
860 +CONFIG_BLK_DEV=y
861 +CONFIG_BLOCK=y
862 +# CONFIG_BMA180 is not set
863 +# CONFIG_BMP085_I2C is not set
864 +# CONFIG_BMP085 is not set
865 +# CONFIG_BMP085_SPI is not set
866 +# CONFIG_BNA is not set
867 +# CONFIG_BNX2 is not set
868 +# CONFIG_BNX2X is not set
869 +# CONFIG_BONDING is not set
870 +CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT=3
871 +# CONFIG_BOOKE_WDT is not set
872 +# CONFIG_BOOT_PRINTK_DELAY is not set
873 +CONFIG_BOOT_RAW=y
874 +CONFIG_BOUNCE=y
875 +# CONFIG_BPCTL is not set
876 +# CONFIG_BPF_JIT is not set
877 +# CONFIG_BPQETHER is not set
878 +CONFIG_BQL=y
879 +CONFIG_BRANCH_PROFILE_NONE=y
880 +# CONFIG_BRCMFMAC is not set
881 +# CONFIG_BRCMSMAC is not set
882 +# CONFIG_BRCMSTB_GISB_ARB is not set
883 +# CONFIG_BRIDGE_EBT_802_3 is not set
884 +# CONFIG_BRIDGE_EBT_AMONG is not set
885 +# CONFIG_BRIDGE_EBT_ARP is not set
886 +# CONFIG_BRIDGE_EBT_ARPREPLY is not set
887 +# CONFIG_BRIDGE_EBT_BROUTE is not set
888 +# CONFIG_BRIDGE_EBT_DNAT is not set
889 +# CONFIG_BRIDGE_EBT_IP6 is not set
890 +# CONFIG_BRIDGE_EBT_IP is not set
891 +# CONFIG_BRIDGE_EBT_LIMIT is not set
892 +# CONFIG_BRIDGE_EBT_LOG is not set
893 +# CONFIG_BRIDGE_EBT_MARK is not set
894 +# CONFIG_BRIDGE_EBT_MARK_T is not set
895 +# CONFIG_BRIDGE_EBT_NFLOG is not set
896 +# CONFIG_BRIDGE_EBT_PKTTYPE is not set
897 +# CONFIG_BRIDGE_EBT_REDIRECT is not set
898 +# CONFIG_BRIDGE_EBT_SNAT is not set
899 +# CONFIG_BRIDGE_EBT_STP is not set
900 +# CONFIG_BRIDGE_EBT_T_FILTER is not set
901 +# CONFIG_BRIDGE_EBT_T_NAT is not set
902 +# CONFIG_BRIDGE_EBT_ULOG is not set
903 +# CONFIG_BRIDGE_EBT_VLAN is not set
904 +CONFIG_BRIDGE_IGMP_SNOOPING=y
905 +# CONFIG_BRIDGE_NETFILTER is not set
906 +# CONFIG_BRIDGE_NF_EBTABLES is not set
907 +# CONFIG_BRIDGE_VLAN_FILTERING is not set
908 +CONFIG_BRIDGE=y
909 +# CONFIG_BROADCOM_PHY is not set
910 +CONFIG_BROKEN_ON_SMP=y
911 +# CONFIG_BSD_DISKLABEL is not set
912 +# CONFIG_BSD_PROCESS_ACCT is not set
913 +# CONFIG_BSD_PROCESS_ACCT_V3 is not set
914 +# CONFIG_BT_ATH3K is not set
915 +# CONFIG_BT_BNEP is not set
916 +CONFIG_BT_BNEP_MC_FILTER=y
917 +CONFIG_BT_BNEP_PROTO_FILTER=y
918 +# CONFIG_BT_CMTP is not set
919 +# CONFIG_BT_HCIBCM203X is not set
920 +# CONFIG_BT_HCIBFUSB is not set
921 +# CONFIG_BT_HCIBLUECARD is not set
922 +# CONFIG_BT_HCIBPA10X is not set
923 +# CONFIG_BT_HCIBT3C is not set
924 +# CONFIG_BT_HCIBTSDIO is not set
925 +# CONFIG_BT_HCIBTUART is not set
926 +# CONFIG_BT_HCIBTUSB is not set
927 +# CONFIG_BT_HCIDTL1 is not set
928 +# CONFIG_BT_HCIUART_3WIRE is not set
929 +# CONFIG_BT_HCIUART_ATH3K is not set
930 +CONFIG_BT_HCIUART_BCSP=y
931 +CONFIG_BT_HCIUART_H4=y
932 +# CONFIG_BT_HCIUART is not set
933 +# CONFIG_BT_HCIUART_LL is not set
934 +# CONFIG_BT_HCIVHCI is not set
935 +# CONFIG_BT_HIDP is not set
936 +# CONFIG_BT is not set
937 +CONFIG_BT_L2CAP=y
938 +# CONFIG_BT_MRVL is not set
939 +# CONFIG_BT_RFCOMM is not set
940 +CONFIG_BT_RFCOMM_TTY=y
941 +# CONFIG_BTRFS_ASSERT is not set
942 +# CONFIG_BTRFS_DEBUG is not set
943 +# CONFIG_BTRFS_FS is not set
944 +# CONFIG_BTRFS_FS_RUN_SANITY_TESTS is not set
945 +CONFIG_BT_SCO=y
946 +CONFIG_BUG=y
947 +CONFIG_BUILDTIME_EXTABLE_SORT=y
948 +# CONFIG_C2PORT is not set
949 +# CONFIG_CACHE_L2X0 is not set
950 +# CONFIG_CAIF is not set
951 +# CONFIG_CAN is not set
952 +# CONFIG_CAPI_AVM is not set
953 +# CONFIG_CAPI_EICON is not set
954 +# CONFIG_CAPI_TRACE is not set
955 +CONFIG_CARDBUS=y
956 +# CONFIG_CARDMAN_4000 is not set
957 +# CONFIG_CARDMAN_4040 is not set
958 +# CONFIG_CARL9170 is not set
959 +# CONFIG_CARMA_FPGA is not set
960 +# CONFIG_CARMA_FPGA_PROGRAM is not set
961 +# CONFIG_CASSINI is not set
962 +CONFIG_CAVIUM_OCTEON_HELPER=y
963 +# CONFIG_CAVIUM_OCTEON_REFERENCE_BOARD is not set
964 +# CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
965 +# CONFIG_CAVIUM_OCTEON_SOC is not set
966 +# CONFIG_CB710_CORE is not set
967 +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
968 +# CONFIG_CC_STACKPROTECTOR is not set
969 +CONFIG_CC_STACKPROTECTOR_NONE=y
970 +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set
971 +# CONFIG_CC_STACKPROTECTOR_STRONG is not set
972 +# CONFIG_CDROM_PKTCDVD is not set
973 +# CONFIG_CED1401 is not set
974 +# CONFIG_CEPH_FS is not set
975 +# CONFIG_CEPH_LIB is not set
976 +# CONFIG_CFG80211_CERTIFICATION_ONUS is not set
977 +# CONFIG_CFG80211 is not set
978 +# CONFIG_CGROUP_DEBUG is not set
979 +# CONFIG_CGROUP_NET_PRIO is not set
980 +# CONFIG_CGROUPS is not set
981 +# CONFIG_CHARGER_BQ2415X is not set
982 +# CONFIG_CHARGER_BQ24190 is not set
983 +# CONFIG_CHARGER_BQ24735 is not set
984 +# CONFIG_CHARGER_GPIO is not set
985 +# CONFIG_CHARGER_ISP1704 is not set
986 +# CONFIG_CHARGER_LP8727 is not set
987 +# CONFIG_CHARGER_MANAGER is not set
988 +# CONFIG_CHARGER_MAX8903 is not set
989 +# CONFIG_CHARGER_SMB347 is not set
990 +# CONFIG_CHARGER_TWL4030 is not set
991 +# CONFIG_CHECKPOINT_RESTORE is not set
992 +# CONFIG_CHELSIO_T1 is not set
993 +# CONFIG_CHELSIO_T3 is not set
994 +# CONFIG_CHELSIO_T4 is not set
995 +# CONFIG_CHELSIO_T4VF is not set
996 +# CONFIG_CHR_DEV_OSST is not set
997 +# CONFIG_CHR_DEV_SCH is not set
998 +# CONFIG_CHR_DEV_SG is not set
999 +# CONFIG_CHR_DEV_ST is not set
1000 +# CONFIG_CHROME_PLATFORMS is not set
1001 +# CONFIG_CICADA_PHY is not set
1002 +# CONFIG_CIFS_ACL is not set
1003 +# CONFIG_CIFS_DEBUG2 is not set
1004 +# CONFIG_CIFS_DEBUG is not set
1005 +# CONFIG_CIFS_FSCACHE is not set
1006 +# CONFIG_CIFS is not set
1007 +# CONFIG_CIFS_NFSD_EXPORT is not set
1008 +CONFIG_CIFS_POSIX=y
1009 +# CONFIG_CIFS_SMB2 is not set
1010 +# CONFIG_CIFS_STATS2 is not set
1011 +CONFIG_CIFS_STATS=y
1012 +# CONFIG_CIFS_WEAK_PW_HASH is not set
1013 +# CONFIG_CIFS_XATTR is not set
1014 +# CONFIG_CLEANCACHE is not set
1015 +CONFIG_CLKDEV_LOOKUP=y
1016 +CONFIG_CLKSRC_OF=y
1017 +# CONFIG_CLKSRC_VERSATILE is not set
1018 +CONFIG_CLONE_BACKWARDS=y
1019 +CONFIG_CLS_U32_MARK=y
1020 +# CONFIG_CLS_U32_PERF is not set
1021 +# CONFIG_CM32181 is not set
1022 +# CONFIG_CM36651 is not set
1023 +# CONFIG_CMA is not set
1024 +CONFIG_CMDLINE=""
1025 +# CONFIG_CMDLINE_BOOL is not set
1026 +# CONFIG_CMDLINE_EXTEND is not set
1027 +# CONFIG_CMDLINE_FORCE is not set
1028 +# CONFIG_CMDLINE_FROM_BOOTLOADER is not set
1029 +# CONFIG_CMDLINE_PARTITION is not set
1030 +# CONFIG_CNIC is not set
1031 +# CONFIG_CODA_FS is not set
1032 +# CONFIG_CODE_PATCHING_SELFTEST is not set
1033 +# CONFIG_COMEDI is not set
1034 +# CONFIG_COMMON_CLK_DEBUG is not set
1035 +# CONFIG_COMMON_CLK_QCOM is not set
1036 +# CONFIG_COMMON_CLK_SI5351 is not set
1037 +# CONFIG_COMMON_CLK_SI570 is not set
1038 +CONFIG_COMMON_CLK=y
1039 +# CONFIG_COMPACTION is not set
1040 +# CONFIG_COMPAL_LAPTOP is not set
1041 +# CONFIG_COMPAT_BRK is not set
1042 +# CONFIG_COMPILE_TEST is not set
1043 +# CONFIG_CONFIG_ARM_ATAG_DTB_COMPAT is not set
1044 +# CONFIG_CONFIGFS_FS is not set
1045 +# CONFIG_CONNECTOR is not set
1046 +CONFIG_CONSTRUCTORS=y
1047 +# CONFIG_CONTEXT_SWITCH_TRACER is not set
1048 +# CONFIG_COPS is not set
1049 +# CONFIG_CORDIC is not set
1050 +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
1051 +# CONFIG_COREDUMP is not set
1052 +# CONFIG_CPA_DEBUG is not set
1053 +CONFIG_CPU_32v5=y
1054 +CONFIG_CPU_ABRT_EV5TJ=y
1055 +CONFIG_CPU_ARM926T=y
1056 +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set
1057 +CONFIG_CPU_CACHE_VIVT=y
1058 +CONFIG_CPU_COPY_V4WB=y
1059 +CONFIG_CPU_CP15_MMU=y
1060 +CONFIG_CPU_CP15=y
1061 +# CONFIG_CPU_DCACHE_DISABLE is not set
1062 +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
1063 +# CONFIG_CPU_FREQ is not set
1064 +# CONFIG_CPU_ICACHE_DISABLE is not set
1065 +# CONFIG_CPU_IDLE_GOV_MENU is not set
1066 +# CONFIG_CPU_IDLE is not set
1067 +# CONFIG_CPU_IDLE_MULTIPLE_DRIVERS is not set
1068 +CONFIG_CPU_PABRT_LEGACY=y
1069 +CONFIG_CPU_TLB_V4WBI=y
1070 +CONFIG_CPU_USE_DOMAINS=y
1071 +# CONFIG_CRAMFS is not set
1072 +# CONFIG_CRASH_DUMP is not set
1073 +CONFIG_CRASHLOG=y
1074 +# CONFIG_CRC16 is not set
1075 +# CONFIG_CRC32_BIT is not set
1076 +CONFIG_CRC32_SARWATE=y
1077 +# CONFIG_CRC32_SELFTEST is not set
1078 +# CONFIG_CRC32_SLICEBY4 is not set
1079 +# CONFIG_CRC32_SLICEBY8 is not set
1080 +CONFIG_CRC32=y
1081 +# CONFIG_CRC7 is not set
1082 +# CONFIG_CRC8 is not set
1083 +# CONFIG_CRC_CCITT is not set
1084 +# CONFIG_CRC_ITU_T is not set
1085 +# CONFIG_CRC_T10DIF is not set
1086 +CONFIG_CROSS_COMPILE=""
1087 +# CONFIG_CROSS_MEMORY_ATTACH is not set
1088 +# CONFIG_CRYPTO_AEAD is not set
1089 +# CONFIG_CRYPTO_AES_586 is not set
1090 +# CONFIG_CRYPTO_AES_ARM_BS is not set
1091 +# CONFIG_CRYPTO_AES_ARM is not set
1092 +# CONFIG_CRYPTO_AES_NI_INTEL is not set
1093 +CONFIG_CRYPTO_AES=y
1094 +CONFIG_CRYPTO_ALGAPI2=y
1095 +CONFIG_CRYPTO_ALGAPI=y
1096 +# CONFIG_CRYPTO_ANSI_CPRNG is not set
1097 +# CONFIG_CRYPTO_ANUBIS is not set
1098 +# CONFIG_CRYPTO_ARC4 is not set
1099 +# CONFIG_CRYPTO_AUTHENC is not set
1100 +# CONFIG_CRYPTO_BLKCIPHER is not set
1101 +# CONFIG_CRYPTO_BLOWFISH is not set
1102 +# CONFIG_CRYPTO_CAMELLIA is not set
1103 +# CONFIG_CRYPTO_CAST5 is not set
1104 +# CONFIG_CRYPTO_CAST6 is not set
1105 +# CONFIG_CRYPTO_CBC is not set
1106 +# CONFIG_CRYPTO_CCM is not set
1107 +# CONFIG_CRYPTO_CMAC is not set
1108 +# CONFIG_CRYPTO_CRC32C_INTEL is not set
1109 +# CONFIG_CRYPTO_CRC32C is not set
1110 +# CONFIG_CRYPTO_CRC32 is not set
1111 +# CONFIG_CRYPTO_CRCT10DIF is not set
1112 +# CONFIG_CRYPTO_CRYPTD is not set
1113 +# CONFIG_CRYPTO_CTR is not set
1114 +# CONFIG_CRYPTO_CTS is not set
1115 +# CONFIG_CRYPTO_DEFLATE is not set
1116 +# CONFIG_CRYPTO_DES is not set
1117 +# CONFIG_CRYPTO_DEV_ATMEL_AES is not set
1118 +# CONFIG_CRYPTO_DEV_ATMEL_SHA is not set
1119 +# CONFIG_CRYPTO_DEV_ATMEL_TDES is not set
1120 +# CONFIG_CRYPTO_DEV_CCP is not set
1121 +# CONFIG_CRYPTO_DEV_FSL_CAAM is not set
1122 +# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1123 +# CONFIG_CRYPTO_DEV_MV_CESA is not set
1124 +# CONFIG_CRYPTO_DEV_SAHARA is not set
1125 +# CONFIG_CRYPTO_DEV_TALITOS is not set
1126 +# CONFIG_CRYPTO_ECB is not set
1127 +# CONFIG_CRYPTO_FCRYPT is not set
1128 +# CONFIG_CRYPTO_FIPS is not set
1129 +# CONFIG_CRYPTO_GCM is not set
1130 +# CONFIG_CRYPTO_GF128MUL is not set
1131 +# CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL is not set
1132 +# CONFIG_CRYPTO_GHASH is not set
1133 +# CONFIG_CRYPTO_HASH is not set
1134 +# CONFIG_CRYPTO_HMAC is not set
1135 +# CONFIG_CRYPTO_HW is not set
1136 +# CONFIG_CRYPTO_KHAZAD is not set
1137 +# CONFIG_CRYPTO_LRW is not set
1138 +# CONFIG_CRYPTO_LZ4HC is not set
1139 +# CONFIG_CRYPTO_LZ4 is not set
1140 +# CONFIG_CRYPTO_LZO is not set
1141 +# CONFIG_CRYPTO_MANAGER2 is not set
1142 +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
1143 +# CONFIG_CRYPTO_MANAGER is not set
1144 +# CONFIG_CRYPTO_MD4 is not set
1145 +# CONFIG_CRYPTO_MD5 is not set
1146 +# CONFIG_CRYPTO_MICHAEL_MIC is not set
1147 +# CONFIG_CRYPTO_NULL is not set
1148 +# CONFIG_CRYPTO_PCBC is not set
1149 +# CONFIG_CRYPTO_PCOMP2 is not set
1150 +# CONFIG_CRYPTO_PCOMP is not set
1151 +# CONFIG_CRYPTO_PCRYPT is not set
1152 +# CONFIG_CRYPTO_RMD128 is not set
1153 +# CONFIG_CRYPTO_RMD160 is not set
1154 +# CONFIG_CRYPTO_RMD256 is not set
1155 +# CONFIG_CRYPTO_RMD320 is not set
1156 +# CONFIG_CRYPTO_RNG is not set
1157 +# CONFIG_CRYPTO_SALSA20_586 is not set
1158 +# CONFIG_CRYPTO_SALSA20 is not set
1159 +# CONFIG_CRYPTO_SEED is not set
1160 +# CONFIG_CRYPTO_SEQIV is not set
1161 +# CONFIG_CRYPTO_SERPENT is not set
1162 +# CONFIG_CRYPTO_SHA1_ARM is not set
1163 +# CONFIG_CRYPTO_SHA1 is not set
1164 +# CONFIG_CRYPTO_SHA256 is not set
1165 +# CONFIG_CRYPTO_SHA512 is not set
1166 +# CONFIG_CRYPTO_TEA is not set
1167 +# CONFIG_CRYPTO_TEST is not set
1168 +# CONFIG_CRYPTO_TGR192 is not set
1169 +# CONFIG_CRYPTO_TWOFISH_586 is not set
1170 +# CONFIG_CRYPTO_TWOFISH_COMMON is not set
1171 +# CONFIG_CRYPTO_TWOFISH is not set
1172 +# CONFIG_CRYPTO_USER_API_HASH is not set
1173 +# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
1174 +# CONFIG_CRYPTO_USER is not set
1175 +# CONFIG_CRYPTO_VMAC is not set
1176 +# CONFIG_CRYPTO_WP512 is not set
1177 +# CONFIG_CRYPTO_XCBC is not set
1178 +# CONFIG_CRYPTO_XTS is not set
1179 +# CONFIG_CRYPTO_XZ is not set
1180 +CONFIG_CRYPTO=y
1181 +# CONFIG_CRYPTO_ZLIB is not set
1182 +# CONFIG_CRYSTALHD is not set
1183 +# CONFIG_CS5535_MFGPT is not set
1184 +# CONFIG_CS89x0 is not set
1185 +# CONFIG_CUSE is not set
1186 +# CONFIG_CW1200 is not set
1187 +# CONFIG_CXT1E1 is not set
1188 +# CONFIG_CYPRESS_FIRMWARE is not set
1189 +# CONFIG_DAVICOM_PHY is not set
1190 +# CONFIG_DCB is not set
1191 +# CONFIG_DDR is not set
1192 +# CONFIG_DE600 is not set
1193 +# CONFIG_DE620 is not set
1194 +# CONFIG_DEBUG_ATOMIC_SLEEP is not set
1195 +# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1196 +# CONFIG_DEBUG_BUGVERBOSE is not set
1197 +# CONFIG_DEBUG_CREDENTIALS is not set
1198 +# CONFIG_DEBUG_DEVRES is not set
1199 +# CONFIG_DEBUG_DRIVER is not set
1200 +# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
1201 +CONFIG_DEBUG_FS=y
1202 +# CONFIG_DEBUG_GPIO is not set
1203 +# CONFIG_DEBUG_HIGHMEM is not set
1204 +# CONFIG_DEBUG_ICEDCC is not set
1205 +# CONFIG_DEBUG_INFO is not set
1206 +CONFIG_DEBUG_INFO_REDUCED=y
1207 +CONFIG_DEBUG_KERNEL=y
1208 +# CONFIG_DEBUG_KMEMLEAK is not set
1209 +# CONFIG_DEBUG_KOBJECT is not set
1210 +# CONFIG_DEBUG_KOBJECT_RELEASE is not set
1211 +# CONFIG_DEBUG_LIST is not set
1212 +CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
1213 +# CONFIG_DEBUG_LL is not set
1214 +# CONFIG_DEBUG_LOCK_ALLOC is not set
1215 +# CONFIG_DEBUG_LOCKDEP is not set
1216 +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1217 +# CONFIG_DEBUG_MEMORY_INIT is not set
1218 +# CONFIG_DEBUG_MUTEXES is not set
1219 +# CONFIG_DEBUG_NOTIFIERS is not set
1220 +# CONFIG_DEBUG_NX_TEST is not set
1221 +# CONFIG_DEBUG_OBJECTS is not set
1222 +# CONFIG_DEBUG_PAGEALLOC is not set
1223 +# CONFIG_DEBUG_PER_CPU_MAPS is not set
1224 +# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
1225 +# CONFIG_DEBUG_PI_LIST is not set
1226 +# CONFIG_DEBUG_PINCTRL is not set
1227 +# CONFIG_DEBUG_PREEMPT is not set
1228 +# CONFIG_DEBUG_RODATA is not set
1229 +# CONFIG_DEBUG_RT_MUTEXES is not set
1230 +# CONFIG_DEBUG_SECTION_MISMATCH is not set
1231 +# CONFIG_DEBUG_SEMIHOSTING is not set
1232 +# CONFIG_DEBUG_SET_MODULE_RONX is not set
1233 +# CONFIG_DEBUG_SG is not set
1234 +# CONFIG_DEBUG_SHIRQ is not set
1235 +# CONFIG_DEBUG_SLAB is not set
1236 +# CONFIG_DEBUG_SPINLOCK is not set
1237 +# CONFIG_DEBUG_STACKOVERFLOW is not set
1238 +# CONFIG_DEBUG_STACK_USAGE is not set
1239 +# CONFIG_DEBUG_STRICT_USER_COPY_CHECKS is not set
1240 +# CONFIG_DEBUG_UART_8250 is not set
1241 +# CONFIG_DEBUG_UART_PL01X is not set
1242 +# CONFIG_DEBUG_USER is not set
1243 +# CONFIG_DEBUG_VM is not set
1244 +# CONFIG_DEBUG_WRITECOUNT is not set
1245 +# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set
1246 +# CONFIG_DEBUG_ZBOOT is not set
1247 +# CONFIG_DECNET is not set
1248 +CONFIG_DEFAULT_CUBIC=y
1249 +CONFIG_DEFAULT_DEADLINE=y
1250 +CONFIG_DEFAULT_HOSTNAME="(none)"
1251 +CONFIG_DEFAULT_IOSCHED="deadline"
1252 +CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
1253 +CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
1254 +# CONFIG_DEFAULT_NOOP is not set
1255 +# CONFIG_DEFAULT_RENO is not set
1256 +CONFIG_DEFAULT_SECURITY=""
1257 +CONFIG_DEFAULT_SECURITY_DAC=y
1258 +CONFIG_DEFAULT_TCP_CONG="cubic"
1259 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
1260 +# CONFIG_DEPRECATED_PARAM_STRUCT is not set
1261 +# CONFIG_DETECT_HUNG_TASK is not set
1262 +# CONFIG_DEVKMEM is not set
1263 +CONFIG_DEVPORT=y
1264 +# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
1265 +# CONFIG_DEVTMPFS is not set
1266 +# CONFIG_DEVTMPFS_MOUNT is not set
1267 +# CONFIG_DGAP is not set
1268 +# CONFIG_DGNC is not set
1269 +# CONFIG_DGRP is not set
1270 +# CONFIG_DHT11 is not set
1271 +# CONFIG_DIRECT_IO is not set
1272 +# CONFIG_DISCONTIGMEM_MANUAL is not set
1273 +# CONFIG_DISPLAY_CONNECTOR_ANALOG_TV is not set
1274 +# CONFIG_DISPLAY_CONNECTOR_DVI is not set
1275 +# CONFIG_DISPLAY_CONNECTOR_HDMI is not set
1276 +# CONFIG_DISPLAY_ENCODER_TFP410 is not set
1277 +# CONFIG_DISPLAY_ENCODER_TPD12S015 is not set
1278 +# CONFIG_DISPLAY_PANEL_DPI is not set
1279 +# CONFIG_DISPLAY_PANEL_LGPHILIPS_LB035Q02 is not set
1280 +# CONFIG_DISPLAY_PANEL_TPO_TD028TTEC1 is not set
1281 +# CONFIG_DISPLAY_PANEL_TPO_TD043MTEA1 is not set
1282 +# CONFIG_DISPLAY_SUPPORT is not set
1283 +# CONFIG_DL2K is not set
1284 +# CONFIG_DLM is not set
1285 +# CONFIG_DM9000 is not set
1286 +# CONFIG_DMA_API_DEBUG is not set
1287 +# CONFIG_DMADEVICES_DEBUG is not set
1288 +# CONFIG_DMADEVICES is not set
1289 +# CONFIG_DMA_ENGINE is not set
1290 +# CONFIG_DMASCC is not set
1291 +# CONFIG_DMA_SHARED_BUFFER is not set
1292 +# CONFIG_DMATEST is not set
1293 +# CONFIG_DM_CACHE is not set
1294 +# CONFIG_DM_DEBUG is not set
1295 +# CONFIG_DM_DELAY is not set
1296 +# CONFIG_DM_FLAKEY is not set
1297 +# CONFIG_DM_LOG_USERSPACE is not set
1298 +# CONFIG_DM_MULTIPATH is not set
1299 +# CONFIG_DM_RAID is not set
1300 +# CONFIG_DM_SWITCH is not set
1301 +# CONFIG_DM_THIN_PROVISIONING is not set
1302 +# CONFIG_DM_UEVENT is not set
1303 +# CONFIG_DM_VERITY is not set
1304 +# CONFIG_DM_ZERO is not set
1305 +# CONFIG_DNET is not set
1306 +# CONFIG_DNOTIFY is not set
1307 +# CONFIG_DNS_RESOLVER is not set
1308 +CONFIG_DOUBLEFAULT=y
1309 +CONFIG_DQL=y
1310 +# CONFIG_DRAGONRISE_FF is not set
1311 +# CONFIG_DRM is not set
1312 +# CONFIG_DS1682 is not set
1313 +CONFIG_DTC=y
1314 +# CONFIG_DTLK is not set
1315 +# CONFIG_DUMMY_IRQ is not set
1316 +# CONFIG_DUMMY is not set
1317 +# CONFIG_DVB_AU8522_V4L is not set
1318 +# CONFIG_DVB_CORE is not set
1319 +# CONFIG_DVB_DUMMY_FE is not set
1320 +# CONFIG_DVB_TUNER_DIB0070 is not set
1321 +# CONFIG_DVB_TUNER_DIB0090 is not set
1322 +# CONFIG_DW_DMAC_CORE is not set
1323 +# CONFIG_DW_DMAC is not set
1324 +# CONFIG_DW_DMAC_PCI is not set
1325 +# CONFIG_DW_WATCHDOG is not set
1326 +# CONFIG_DX_SEP is not set
1327 +# CONFIG_DYNAMIC_DEBUG is not set
1328 +# CONFIG_E1000E is not set
1329 +# CONFIG_E1000 is not set
1330 +# CONFIG_E100 is not set
1331 +# CONFIG_E2100 is not set
1332 +# CONFIG_EARLY_PRINTK_8250 is not set
1333 +# CONFIG_EASYCAP is not set
1334 +# CONFIG_ECHO is not set
1335 +# CONFIG_ECONET is not set
1336 +# CONFIG_ECRYPT_FS is not set
1337 +# CONFIG_EDAC is not set
1338 +# CONFIG_EEPROM_93CX6 is not set
1339 +# CONFIG_EEPROM_93XX46 is not set
1340 +# CONFIG_EEPROM_AT24 is not set
1341 +# CONFIG_EEPROM_AT25 is not set
1342 +# CONFIG_EEPROM_DIGSY_MTC_CFG is not set
1343 +# CONFIG_EEPROM_LEGACY is not set
1344 +# CONFIG_EEPROM_MAX6875 is not set
1345 +# CONFIG_EEXPRESS is not set
1346 +# CONFIG_EEXPRESS_PRO is not set
1347 +CONFIG_EFI_PARTITION=y
1348 +# CONFIG_EFS_FS is not set
1349 +# CONFIG_ELF_CORE is not set
1350 +CONFIG_EMBEDDED=y
1351 +# CONFIG_EM_TIMER_STI is not set
1352 +# CONFIG_ENABLE_MUST_CHECK is not set
1353 +CONFIG_ENABLE_WARN_DEPRECATED=y
1354 +# CONFIG_ENC28J60 is not set
1355 +# CONFIG_ENCLOSURE_SERVICES is not set
1356 +# CONFIG_ENCRYPTED_KEYS is not set
1357 +# CONFIG_ENIC is not set
1358 +# CONFIG_EPAPR_PARAVIRT is not set
1359 +# CONFIG_EPIC100 is not set
1360 +CONFIG_EPOLL=y
1361 +# CONFIG_EQUALIZER is not set
1362 +# CONFIG_ET131X is not set
1363 +# CONFIG_ETH16I is not set
1364 +CONFIG_ETHERNET=y
1365 +# CONFIG_ETHOC is not set
1366 +CONFIG_EVENTFD=y
1367 +# CONFIG_EVENT_POWER_TRACING_DEPRECATED is not set
1368 +# CONFIG_EWRK3 is not set
1369 +CONFIG_EXPERIMENTAL=y
1370 +CONFIG_EXPERT=y
1371 +# CONFIG_EXPORTFS is not set
1372 +# CONFIG_EXT2_FS is not set
1373 +# CONFIG_EXT2_FS_XATTR is not set
1374 +# CONFIG_EXT2_FS_XIP is not set
1375 +# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
1376 +# CONFIG_EXT3_FS is not set
1377 +# CONFIG_EXT3_FS_XATTR is not set
1378 +# CONFIG_EXT4_DEBUG is not set
1379 +# CONFIG_EXT4_FS is not set
1380 +# CONFIG_EXT4_FS_POSIX_ACL is not set
1381 +# CONFIG_EXT4_FS_SECURITY is not set
1382 +CONFIG_EXT4_FS_XATTR=y
1383 +CONFIG_EXT4_USE_FOR_EXT23=y
1384 +# CONFIG_EXTCON is not set
1385 +CONFIG_EXTRA_FIRMWARE=""
1386 +CONFIG_EXTRA_TARGETS=""
1387 +# CONFIG_EXYNOS_ADC is not set
1388 +# CONFIG_EXYNOS_VIDEO is not set
1389 +# CONFIG_EZX_PCAP is not set
1390 +# CONFIG_F2FS_FS is not set
1391 +# CONFIG_FAIR_GROUP_SCHED is not set
1392 +# CONFIG_FANOTIFY is not set
1393 +CONFIG_FAT_DEFAULT_CODEPAGE=437
1394 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1395 +# CONFIG_FAT_FS is not set
1396 +# CONFIG_FAULT_INJECTION is not set
1397 +# CONFIG_FB_3DFX is not set
1398 +# CONFIG_FB_ARC is not set
1399 +# CONFIG_FB_ARK is not set
1400 +# CONFIG_FB_ARMCLCD is not set
1401 +# CONFIG_FB_ASILIANT is not set
1402 +# CONFIG_FB_ATY128 is not set
1403 +# CONFIG_FB_ATY is not set
1404 +# CONFIG_FB_AUO_K190X is not set
1405 +# CONFIG_FB_BACKLIGHT is not set
1406 +# CONFIG_FB_BOOT_VESA_SUPPORT is not set
1407 +# CONFIG_FB_BROADSHEET is not set
1408 +# CONFIG_FB_CARMINE is not set
1409 +# CONFIG_FB_CFB_COPYAREA is not set
1410 +# CONFIG_FB_CFB_FILLRECT is not set
1411 +# CONFIG_FB_CFB_IMAGEBLIT is not set
1412 +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
1413 +# CONFIG_FB_CIRRUS is not set
1414 +# CONFIG_FB_CYBER2000 is not set
1415 +# CONFIG_FB_DA8XX is not set
1416 +# CONFIG_FB_DDC is not set
1417 +# CONFIG_FB_FOREIGN_ENDIAN is not set
1418 +# CONFIG_FB_GEODE is not set
1419 +# CONFIG_FB_GOLDFISH is not set
1420 +# CONFIG_FB_HGA is not set
1421 +# CONFIG_FB_I740 is not set
1422 +# CONFIG_FB_IBM_GXT4500 is not set
1423 +# CONFIG_FB_IMSTT is not set
1424 +# CONFIG_FB is not set
1425 +# CONFIG_FB_KYRO is not set
1426 +# CONFIG_FB_LE80578 is not set
1427 +# CONFIG_FB_MACMODES is not set
1428 +# CONFIG_FB_MATROX is not set
1429 +# CONFIG_FB_MB862XX is not set
1430 +# CONFIG_FB_METRONOME is not set
1431 +# CONFIG_FB_MODE_HELPERS is not set
1432 +# CONFIG_FB_N411 is not set
1433 +# CONFIG_FB_NEOMAGIC is not set
1434 +# CONFIG_FB_NVIDIA is not set
1435 +# CONFIG_FB_OF is not set
1436 +# CONFIG_FB_OPENCORES is not set
1437 +# CONFIG_FB_PM2 is not set
1438 +# CONFIG_FB_PM3 is not set
1439 +# CONFIG_FB_PS3 is not set
1440 +# CONFIG_FB_PXA is not set
1441 +# CONFIG_FB_RADEON is not set
1442 +# CONFIG_FB_RIVA is not set
1443 +# CONFIG_FB_S1D13XXX is not set
1444 +# CONFIG_FB_S3 is not set
1445 +# CONFIG_FB_SAVAGE is not set
1446 +# CONFIG_FB_SIMPLE is not set
1447 +# CONFIG_FB_SIS is not set
1448 +# CONFIG_FB_SM7XX is not set
1449 +# CONFIG_FB_SMSCUFX is not set
1450 +# CONFIG_FB_SSD1307 is not set
1451 +# CONFIG_FB_SVGALIB is not set
1452 +# CONFIG_FB_SYS_COPYAREA is not set
1453 +# CONFIG_FB_SYS_FILLRECT is not set
1454 +# CONFIG_FB_SYS_FOPS is not set
1455 +# CONFIG_FB_SYS_IMAGEBLIT is not set
1456 +# CONFIG_FB_TILEBLITTING is not set
1457 +# CONFIG_FB_TMIO is not set
1458 +# CONFIG_FB_TRIDENT is not set
1459 +# CONFIG_FB_UDL is not set
1460 +# CONFIG_FB_UVESA is not set
1461 +# CONFIG_FB_VGA16 is not set
1462 +# CONFIG_FB_VIA is not set
1463 +# CONFIG_FB_VIRTUAL is not set
1464 +# CONFIG_FB_VOODOO1 is not set
1465 +# CONFIG_FB_VT8623 is not set
1466 +# CONFIG_FB_XGI is not set
1467 +# CONFIG_FCOE_FNIC is not set
1468 +# CONFIG_FCOE is not set
1469 +# CONFIG_FDDI is not set
1470 +# CONFIG_FEALNX is not set
1471 +# CONFIG_FHANDLE is not set
1472 +CONFIG_FIB_RULES=y
1473 +CONFIG_FILE_LOCKING=y
1474 +# CONFIG_FIREWIRE is not set
1475 +# CONFIG_FIREWIRE_NOSY is not set
1476 +# CONFIG_FIREWIRE_SERIAL is not set
1477 +# CONFIG_FIRMWARE_EDID is not set
1478 +# CONFIG_FIRMWARE_IN_KERNEL is not set
1479 +# CONFIG_FIRMWARE_MEMMAP is not set
1480 +# CONFIG_FIXED_PHY is not set
1481 +CONFIG_FLATMEM_MANUAL=y
1482 +CONFIG_FLATMEM=y
1483 +CONFIG_FLAT_NODE_MEM_MAP=y
1484 +# CONFIG_FMC is not set
1485 +# CONFIG_FORCEDETH is not set
1486 +CONFIG_FORCE_MAX_ZONEORDER=11
1487 +# CONFIG_FRAMEBUFFER_CONSOLE is not set
1488 +# CONFIG_FRAME_POINTER is not set
1489 +CONFIG_FRAME_WARN=1024
1490 +# CONFIG_FREEZER is not set
1491 +# CONFIG_FRONTSWAP is not set
1492 +# CONFIG_FSCACHE is not set
1493 +# CONFIG_FSL_EDMA is not set
1494 +# CONFIG_FSL_XGMAC_MDIO is not set
1495 +CONFIG_FSNOTIFY=y
1496 +# CONFIG_FS_POSIX_ACL is not set
1497 +# CONFIG_FT1000 is not set
1498 +# CONFIG_FTGMAC100 is not set
1499 +# CONFIG_FTL is not set
1500 +# CONFIG_FTMAC100 is not set
1501 +# CONFIG_FTRACE is not set
1502 +# CONFIG_FTRACE_STARTUP_TEST is not set
1503 +# CONFIG_FTR_FIXUP_SELFTEST is not set
1504 +# CONFIG_FUJITSU_TABLET is not set
1505 +# CONFIG_FUNCTION_TRACER is not set
1506 +# CONFIG_FUSE_FS is not set
1507 +# CONFIG_FUSION_FC is not set
1508 +# CONFIG_FUSION is not set
1509 +# CONFIG_FUSION_SAS is not set
1510 +# CONFIG_FUSION_SPI is not set
1511 +CONFIG_FUTEX=y
1512 +CONFIG_FW_LOADER_USER_HELPER=y
1513 +CONFIG_FW_LOADER=y
1514 +CONFIG_GACT_PROB=y
1515 +# CONFIG_GADGET_UAC1 is not set
1516 +# CONFIG_GAMEPORT is not set
1517 +# CONFIG_GATEWORKS_GW16083 is not set
1518 +# CONFIG_GCOV is not set
1519 +# CONFIG_GCOV_KERNEL is not set
1520 +# CONFIG_GENERIC_ADC_BATTERY is not set
1521 +CONFIG_GENERIC_ATOMIC64=y
1522 +CONFIG_GENERIC_BUG=y
1523 +CONFIG_GENERIC_CALIBRATE_DELAY=y
1524 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
1525 +CONFIG_GENERIC_CLOCKEVENTS=y
1526 +# CONFIG_GENERIC_CPU_DEVICES is not set
1527 +CONFIG_GENERIC_HARDIRQS=y
1528 +CONFIG_GENERIC_HWEIGHT=y
1529 +CONFIG_GENERIC_IDLE_POLL_SETUP=y
1530 +CONFIG_GENERIC_IO=y
1531 +CONFIG_GENERIC_IRQ_PROBE=y
1532 +CONFIG_GENERIC_IRQ_SHOW=y
1533 +CONFIG_GENERIC_NET_UTILS=y
1534 +CONFIG_GENERIC_PCI_IOMAP=y
1535 +# CONFIG_GENERIC_PHY is not set
1536 +CONFIG_GENERIC_SCHED_CLOCK=y
1537 +CONFIG_GENERIC_SMP_IDLE_THREAD=y
1538 +CONFIG_GENERIC_STRNCPY_FROM_USER=y
1539 +CONFIG_GENERIC_STRNLEN_USER=y
1540 +CONFIG_GENERIC_TIME=y
1541 +# CONFIG_GENWQE is not set
1542 +# CONFIG_GFS2_FS is not set
1543 +# CONFIG_GIGASET_CAPI is not set
1544 +# CONFIG_GIGASET_DEBUG is not set
1545 +# CONFIG_GP2AP020A00F is not set
1546 +# CONFIG_GPIO_74X164 is not set
1547 +# CONFIG_GPIO_ADNP is not set
1548 +# CONFIG_GPIO_ADP5588 is not set
1549 +# CONFIG_GPIO_AMD8111 is not set
1550 +# CONFIG_GPIO_BCM_KONA is not set
1551 +# CONFIG_GPIO_BT8XX is not set
1552 +# CONFIG_GPIO_CS5535 is not set
1553 +# CONFIG_GPIO_DWAPB is not set
1554 +# CONFIG_GPIO_EM is not set
1555 +# CONFIG_GPIO_GENERIC_PLATFORM is not set
1556 +# CONFIG_GPIO_GRGPIO is not set
1557 +# CONFIG_GPIO_ICH is not set
1558 +# CONFIG_GPIO_IT8761E is not set
1559 +# CONFIG_GPIO_LANGWELL is not set
1560 +# CONFIG_GPIOLIB is not set
1561 +# CONFIG_GPIO_MAX7300 is not set
1562 +# CONFIG_GPIO_MAX7301 is not set
1563 +# CONFIG_GPIO_MAX732X is not set
1564 +# CONFIG_GPIO_MC33880 is not set
1565 +# CONFIG_GPIO_MCP23S08 is not set
1566 +# CONFIG_GPIO_ML_IOH is not set
1567 +# CONFIG_GPIO_PCA953X is not set
1568 +# CONFIG_GPIO_PCF857X is not set
1569 +# CONFIG_GPIO_PCH is not set
1570 +# CONFIG_GPIO_PL061 is not set
1571 +# CONFIG_GPIO_RCAR is not set
1572 +# CONFIG_GPIO_RDC321X is not set
1573 +# CONFIG_GPIO_SCH311X is not set
1574 +# CONFIG_GPIO_SCH is not set
1575 +# CONFIG_GPIO_SX150X is not set
1576 +# CONFIG_GPIO_SYSFS is not set
1577 +# CONFIG_GPIO_TS5500 is not set
1578 +# CONFIG_GPIO_VX855 is not set
1579 +# CONFIG_GPIO_WATCHDOG is not set
1580 +# CONFIG_GPIO_WDT is not set
1581 +# CONFIG_GPIO_XILINX is not set
1582 +# CONFIG_GPIO_ZEVIO is not set
1583 +# CONFIG_GREENASIA_FF is not set
1584 +# CONFIG_GS_FPGABOOT is not set
1585 +# CONFIG_HAMACHI is not set
1586 +CONFIG_HAMRADIO=y
1587 +# CONFIG_HAPPYMEAL is not set
1588 +CONFIG_HARDIRQS_SW_RESEND=y
1589 +# CONFIG_HARDLOCKUP_DETECTOR is not set
1590 +CONFIG_HAS_DMA=y
1591 +CONFIG_HAS_IOMEM=y
1592 +CONFIG_HAS_IOPORT_MAP=y
1593 +# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
1594 +# CONFIG_HAVE_AOUT is not set
1595 +CONFIG_HAVE_ARCH_AUDITSYSCALL=y
1596 +CONFIG_HAVE_ARCH_JUMP_LABEL=y
1597 +CONFIG_HAVE_ARCH_KGDB=y
1598 +CONFIG_HAVE_ARCH_PFN_VALID=y
1599 +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
1600 +CONFIG_HAVE_ARCH_TRACEHOOK=y
1601 +# CONFIG_HAVE_ARM_ARCH_TIMER is not set
1602 +# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
1603 +CONFIG_HAVE_BPF_JIT=y
1604 +CONFIG_HAVE_CC_STACKPROTECTOR=y
1605 +CONFIG_HAVE_CLK_PREPARE=y
1606 +CONFIG_HAVE_CLK=y
1607 +CONFIG_HAVE_CONTEXT_TRACKING=y
1608 +CONFIG_HAVE_C_RECORDMCOUNT=y
1609 +CONFIG_HAVE_DEBUG_KMEMLEAK=y
1610 +CONFIG_HAVE_DMA_API_DEBUG=y
1611 +CONFIG_HAVE_DMA_ATTRS=y
1612 +CONFIG_HAVE_DMA_CONTIGUOUS=y
1613 +CONFIG_HAVE_DYNAMIC_FTRACE=y
1614 +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1615 +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
1616 +CONFIG_HAVE_FUNCTION_TRACER=y
1617 +CONFIG_HAVE_GENERIC_DMA_COHERENT=y
1618 +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
1619 +CONFIG_HAVE_KERNEL_GZIP=y
1620 +CONFIG_HAVE_KERNEL_LZ4=y
1621 +CONFIG_HAVE_KERNEL_LZMA=y
1622 +CONFIG_HAVE_KERNEL_LZO=y
1623 +CONFIG_HAVE_KERNEL_XZ=y
1624 +CONFIG_HAVE_KPROBES=y
1625 +CONFIG_HAVE_KRETPROBES=y
1626 +CONFIG_HAVE_LATENCYTOP_SUPPORT=y
1627 +CONFIG_HAVE_MEMBLOCK=y
1628 +CONFIG_HAVE_NET_DSA=y
1629 +CONFIG_HAVE_OPROFILE=y
1630 +CONFIG_HAVE_PERF_EVENTS=y
1631 +CONFIG_HAVE_PERF_REGS=y
1632 +CONFIG_HAVE_PERF_USER_STACK_DUMP=y
1633 +CONFIG_HAVE_PROC_CPU=y
1634 +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
1635 +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
1636 +CONFIG_HAVE_UID16=y
1637 +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
1638 +# CONFIG_HCALL_STATS is not set
1639 +# CONFIG_HDLC_CISCO is not set
1640 +# CONFIG_HDLC_FR is not set
1641 +# CONFIG_HDLC is not set
1642 +# CONFIG_HDLC_PPP is not set
1643 +# CONFIG_HDLC_RAW_ETH is not set
1644 +# CONFIG_HDLC_RAW is not set
1645 +# CONFIG_HDQ_MASTER_OMAP is not set
1646 +# CONFIG_HEADERS_CHECK is not set
1647 +# CONFIG_HERMES is not set
1648 +# CONFIG_HFS_FS is not set
1649 +# CONFIG_HFSPLUS_FS is not set
1650 +# CONFIG_HFSPLUS_FS_POSIX_ACL is not set
1651 +# CONFIG_HIBERNATION is not set
1652 +# CONFIG_HID_A4TECH is not set
1653 +# CONFIG_HID_ACRUX_FF is not set
1654 +# CONFIG_HID_ACRUX is not set
1655 +# CONFIG_HID_APPLEIR is not set
1656 +# CONFIG_HID_APPLE is not set
1657 +# CONFIG_HID_AUREAL is not set
1658 +# CONFIG_HID_BELKIN is not set
1659 +# CONFIG_HID_CHERRY is not set
1660 +# CONFIG_HID_CHICONY is not set
1661 +# CONFIG_HID_CYPRESS is not set
1662 +# CONFIG_HID_DRAGONRISE is not set
1663 +# CONFIG_HID_ELECOM is not set
1664 +# CONFIG_HID_ELO is not set
1665 +# CONFIG_HID_EMS_FF is not set
1666 +# CONFIG_HID_EZKEY is not set
1667 +# CONFIG_HID_GENERIC is not set
1668 +# CONFIG_HID_GREENASIA is not set
1669 +# CONFIG_HID_GYRATION is not set
1670 +# CONFIG_HID_HOLTEK is not set
1671 +# CONFIG_HID_HUION is not set
1672 +# CONFIG_HID_ICADE is not set
1673 +# CONFIG_HID is not set
1674 +# CONFIG_HID_KENSINGTON is not set
1675 +# CONFIG_HID_KEYTOUCH is not set
1676 +# CONFIG_HID_KYE is not set
1677 +# CONFIG_HID_LCPOWER is not set
1678 +# CONFIG_HID_LENOVO_TPKBD is not set
1679 +# CONFIG_HID_LOGITECH_DJ is not set
1680 +# CONFIG_HID_LOGITECH is not set
1681 +# CONFIG_HID_MAGICMOUSE is not set
1682 +# CONFIG_HID_MICROSOFT is not set
1683 +# CONFIG_HID_MONTEREY is not set
1684 +# CONFIG_HID_MULTITOUCH is not set
1685 +# CONFIG_HID_NTRIG is not set
1686 +# CONFIG_HID_ORTEK is not set
1687 +# CONFIG_HID_PANTHERLORD is not set
1688 +# CONFIG_HID_PETALYNX is not set
1689 +# CONFIG_HID_PICOLCD is not set
1690 +# CONFIG_HID_PID is not set
1691 +# CONFIG_HID_PRIMAX is not set
1692 +# CONFIG_HID_PRODIKEYS is not set
1693 +# CONFIG_HID_PS3REMOTE is not set
1694 +# CONFIG_HID_QUANTA is not set
1695 +# CONFIG_HIDRAW is not set
1696 +# CONFIG_HID_ROCCAT_ARVO is not set
1697 +# CONFIG_HID_ROCCAT is not set
1698 +# CONFIG_HID_ROCCAT_KONE is not set
1699 +# CONFIG_HID_ROCCAT_KONEPLUS is not set
1700 +# CONFIG_HID_ROCCAT_KOVAPLUS is not set
1701 +# CONFIG_HID_ROCCAT_PYRA is not set
1702 +# CONFIG_HID_SAITEK is not set
1703 +# CONFIG_HID_SAMSUNG is not set
1704 +# CONFIG_HID_SENSOR_HUB is not set
1705 +# CONFIG_HID_SMARTJOYPLUS is not set
1706 +# CONFIG_HID_SONY is not set
1707 +# CONFIG_HID_SPEEDLINK is not set
1708 +# CONFIG_HID_STEELSERIES is not set
1709 +# CONFIG_HID_SUNPLUS is not set
1710 +# CONFIG_HID_SUPPORT is not set
1711 +# CONFIG_HID_THINGM is not set
1712 +# CONFIG_HID_THRUSTMASTER is not set
1713 +# CONFIG_HID_TIVO is not set
1714 +# CONFIG_HID_TOPSEED is not set
1715 +# CONFIG_HID_TWINHAN is not set
1716 +# CONFIG_HID_UCLOGIC is not set
1717 +# CONFIG_HID_WACOM is not set
1718 +# CONFIG_HID_WALTOP is not set
1719 +# CONFIG_HID_WIIMOTE is not set
1720 +# CONFIG_HID_XINMO is not set
1721 +# CONFIG_HID_ZEROPLUS is not set
1722 +# CONFIG_HID_ZYDACRON is not set
1723 +# CONFIG_HIGHMEM is not set
1724 +# CONFIG_HIGHPTE is not set
1725 +CONFIG_HIGH_RES_TIMERS=y
1726 +# CONFIG_HIPPI is not set
1727 +# CONFIG_HIX5HD2_GMAC is not set
1728 +# CONFIG_HMC6352 is not set
1729 +# CONFIG_HOSTAP_CS is not set
1730 +# CONFIG_HOSTAP is not set
1731 +# CONFIG_HOSTAP_PCI is not set
1732 +# CONFIG_HOSTAP_PLX is not set
1733 +# CONFIG_HOTPLUG_CPU is not set
1734 +# CONFIG_HOTPLUG_PCI is not set
1735 +CONFIG_HOTPLUG=y
1736 +# CONFIG_HP100 is not set
1737 +CONFIG_HPET_MMAP_DEFAULT=y
1738 +# CONFIG_HPFS_FS is not set
1739 +# CONFIG_HP_ILO is not set
1740 +# CONFIG_HPLAN is not set
1741 +# CONFIG_HPLAN_PLUS is not set
1742 +# CONFIG_HP_WIRELESS is not set
1743 +# CONFIG_HSI is not set
1744 +# CONFIG_HSR is not set
1745 +# CONFIG_HTC_EGPIO is not set
1746 +# CONFIG_HTC_I2CPLD is not set
1747 +# CONFIG_HTC_PASIC3 is not set
1748 +# CONFIG_HUGETLB_PAGE is not set
1749 +# CONFIG_HVC_DCC is not set
1750 +# CONFIG_HVC_UDBG is not set
1751 +# CONFIG_HWMON_DEBUG_CHIP is not set
1752 +# CONFIG_HWMON is not set
1753 +# CONFIG_HWMON_VID is not set
1754 +CONFIG_HW_PERF_EVENTS=y
1755 +# CONFIG_HW_RANDOM_AMD is not set
1756 +# CONFIG_HW_RANDOM_ATMEL is not set
1757 +# CONFIG_HW_RANDOM_EXYNOS is not set
1758 +# CONFIG_HW_RANDOM_GEODE is not set
1759 +# CONFIG_HW_RANDOM_INTEL is not set
1760 +# CONFIG_HW_RANDOM is not set
1761 +# CONFIG_HW_RANDOM_OMAP3_ROM is not set
1762 +# CONFIG_HW_RANDOM_PPC4XX is not set
1763 +# CONFIG_HW_RANDOM_TIMERIOMEM is not set
1764 +# CONFIG_HW_RANDOM_VIA is not set
1765 +# CONFIG_HWSPINLOCK_OMAP is not set
1766 +# CONFIG_HYPERV is not set
1767 +# CONFIG_HYSDN is not set
1768 +CONFIG_HZ=100
1769 +# CONFIG_HZ_1000 is not set
1770 +CONFIG_HZ_100=y
1771 +# CONFIG_HZ_200 is not set
1772 +# CONFIG_HZ_250 is not set
1773 +# CONFIG_HZ_300 is not set
1774 +# CONFIG_HZ_500 is not set
1775 +# CONFIG_HZ_PERIODIC is not set
1776 +# CONFIG_I2C_ALGOBIT is not set
1777 +# CONFIG_I2C_ALGOPCA is not set
1778 +# CONFIG_I2C_ALGOPCF is not set
1779 +# CONFIG_I2C_ALI1535 is not set
1780 +# CONFIG_I2C_ALI1563 is not set
1781 +# CONFIG_I2C_ALI15X3 is not set
1782 +# CONFIG_I2C_AMD756 is not set
1783 +# CONFIG_I2C_AMD8111 is not set
1784 +# CONFIG_I2C_ARB_GPIO_CHALLENGE is not set
1785 +# CONFIG_I2C_AU1550 is not set
1786 +# CONFIG_I2C_CBUS_GPIO is not set
1787 +# CONFIG_I2C_CHARDEV is not set
1788 +# CONFIG_I2C_COMPAT is not set
1789 +# CONFIG_I2C_DEBUG_ALGO is not set
1790 +# CONFIG_I2C_DEBUG_BUS is not set
1791 +# CONFIG_I2C_DEBUG_CORE is not set
1792 +# CONFIG_I2C_DESIGNWARE is not set
1793 +# CONFIG_I2C_DESIGNWARE_PCI is not set
1794 +# CONFIG_I2C_DESIGNWARE_PLATFORM is not set
1795 +# CONFIG_I2C_DIOLAN_U2C is not set
1796 +# CONFIG_I2C_EG20T is not set
1797 +# CONFIG_I2C_ELEKTOR is not set
1798 +# CONFIG_I2C_GPIO is not set
1799 +# CONFIG_I2C_HELPER_AUTO is not set
1800 +# CONFIG_I2C_HID is not set
1801 +# CONFIG_I2C_I801 is not set
1802 +# CONFIG_I2C_IBM_IIC is not set
1803 +# CONFIG_I2C_INTEL_MID is not set
1804 +# CONFIG_I2C_ISCH is not set
1805 +# CONFIG_I2C_ISMT is not set
1806 +# CONFIG_I2C is not set
1807 +# CONFIG_I2C_MPC is not set
1808 +# CONFIG_I2C_MUX is not set
1809 +# CONFIG_I2C_MUX_PINCTRL is not set
1810 +# CONFIG_I2C_MV64XXX is not set
1811 +# CONFIG_I2C_NFORCE2 is not set
1812 +# CONFIG_I2C_NOMADIK is not set
1813 +# CONFIG_I2C_OCORES is not set
1814 +# CONFIG_I2C_PARPORT is not set
1815 +# CONFIG_I2C_PARPORT_LIGHT is not set
1816 +# CONFIG_I2C_PCA_ISA is not set
1817 +# CONFIG_I2C_PCA_PLATFORM is not set
1818 +# CONFIG_I2C_PIIX4 is not set
1819 +# CONFIG_I2C_PXA_PCI is not set
1820 +# CONFIG_I2C_RCAR is not set
1821 +# CONFIG_I2C_RK3X is not set
1822 +# CONFIG_I2C_ROBOTFUZZ_OSIF is not set
1823 +# CONFIG_I2C_SCMI is not set
1824 +# CONFIG_I2C_SH_MOBILE is not set
1825 +# CONFIG_I2C_SIMTEC is not set
1826 +# CONFIG_I2C_SIS5595 is not set
1827 +# CONFIG_I2C_SIS630 is not set
1828 +# CONFIG_I2C_SIS96X is not set
1829 +# CONFIG_I2C_SMBUS is not set
1830 +# CONFIG_I2C_STUB is not set
1831 +# CONFIG_I2C_TAOS_EVM is not set
1832 +# CONFIG_I2C_TINY_USB is not set
1833 +# CONFIG_I2C_VERSATILE is not set
1834 +# CONFIG_I2C_VIA is not set
1835 +# CONFIG_I2C_VIAPRO is not set
1836 +# CONFIG_I2C_XILINX is not set
1837 +# CONFIG_I2O is not set
1838 +# CONFIG_I40E is not set
1839 +# CONFIG_I40EVF is not set
1840 +# CONFIG_I6300ESB_WDT is not set
1841 +# CONFIG_I82092 is not set
1842 +# CONFIG_I82365 is not set
1843 +# CONFIG_IBM_ASM is not set
1844 +# CONFIG_IBM_EMAC_DEBUG is not set
1845 +# CONFIG_IBM_EMAC_EMAC4 is not set
1846 +# CONFIG_IBM_EMAC_MAL_CLR_ICINTSTAT is not set
1847 +# CONFIG_IBM_EMAC_MAL_COMMON_ERR is not set
1848 +# CONFIG_IBM_EMAC_NO_FLOW_CTRL is not set
1849 +# CONFIG_IBM_EMAC_RGMII is not set
1850 +# CONFIG_IBM_EMAC_TAH is not set
1851 +# CONFIG_IBM_EMAC_ZMII is not set
1852 +# CONFIG_ICPLUS_PHY is not set
1853 +# CONFIG_ICS932S401 is not set
1854 +# CONFIG_IDEAPAD_LAPTOP is not set
1855 +# CONFIG_IDE_GD is not set
1856 +# CONFIG_IDE is not set
1857 +# CONFIG_IDE_PHISON is not set
1858 +# CONFIG_IDE_PROC_FS is not set
1859 +# CONFIG_IDE_TASK_IOCTL is not set
1860 +# CONFIG_IEEE802154 is not set
1861 +# CONFIG_IFB is not set
1862 +# CONFIG_IGB is not set
1863 +# CONFIG_IGBVF is not set
1864 +# CONFIG_IIO_BUFFER_CB is not set
1865 +CONFIG_IIO_CONSUMERS_PER_TRIGGER=2
1866 +# CONFIG_IIO_GPIO_TRIGGER is not set
1867 +# CONFIG_IIO_INTERRUPT_TRIGGER is not set
1868 +# CONFIG_IIO is not set
1869 +# CONFIG_IIO_PERIODIC_RTC_TRIGGER is not set
1870 +# CONFIG_IIO_SIMPLE_DUMMY is not set
1871 +# CONFIG_IIO_ST_ACCEL_3AXIS is not set
1872 +# CONFIG_IIO_ST_GYRO_3AXIS is not set
1873 +# CONFIG_IIO_ST_MAGN_3AXIS is not set
1874 +# CONFIG_IIO_ST_PRESS is not set
1875 +# CONFIG_IIO_SYSFS_TRIGGER is not set
1876 +# CONFIG_IKCONFIG is not set
1877 +# CONFIG_IKCONFIG_PROC is not set
1878 +# CONFIG_IMAGE_CMDLINE_HACK is not set
1879 +# CONFIG_INET6_AH is not set
1880 +# CONFIG_INET6_ESP is not set
1881 +# CONFIG_INET6_IPCOMP is not set
1882 +# CONFIG_INET6_TUNNEL is not set
1883 +# CONFIG_INET6_XFRM_MODE_BEET is not set
1884 +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
1885 +# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
1886 +# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
1887 +# CONFIG_INET6_XFRM_TUNNEL is not set
1888 +# CONFIG_INET_AH is not set
1889 +# CONFIG_INET_DIAG is not set
1890 +# CONFIG_INET_ESP is not set
1891 +# CONFIG_INET_IPCOMP is not set
1892 +# CONFIG_INET_LRO is not set
1893 +# CONFIG_INET_TCP_DIAG is not set
1894 +# CONFIG_INET_TUNNEL is not set
1895 +# CONFIG_INET_UDP_DIAG is not set
1896 +# CONFIG_INET_XFRM_MODE_BEET is not set
1897 +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
1898 +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
1899 +# CONFIG_INET_XFRM_TUNNEL is not set
1900 +CONFIG_INET=y
1901 +# CONFIG_INFINIBAND is not set
1902 +# CONFIG_INFTL is not set
1903 +CONFIG_INIT_ENV_ARG_LIMIT=32
1904 +# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set
1905 +# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set
1906 +# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set
1907 +CONFIG_INITRAMFS_COMPRESSION_NONE=y
1908 +CONFIG_INITRAMFS_SOURCE=""
1909 +# CONFIG_INLINE_READ_LOCK_BH is not set
1910 +# CONFIG_INLINE_READ_LOCK_IRQ is not set
1911 +# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
1912 +# CONFIG_INLINE_READ_LOCK is not set
1913 +# CONFIG_INLINE_READ_TRYLOCK is not set
1914 +# CONFIG_INLINE_READ_UNLOCK_BH is not set
1915 +CONFIG_INLINE_READ_UNLOCK_IRQ=y
1916 +CONFIG_INLINE_READ_UNLOCK=y
1917 +# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
1918 +CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
1919 +# CONFIG_INLINE_WRITE_LOCK_BH is not set
1920 +# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
1921 +# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
1922 +# CONFIG_INLINE_WRITE_LOCK is not set
1923 +# CONFIG_INLINE_WRITE_TRYLOCK is not set
1924 +# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
1925 +# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
1926 +CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
1927 +CONFIG_INLINE_WRITE_UNLOCK=y
1928 +CONFIG_INOTIFY_USER=y
1929 +# CONFIG_INPUT_AD714X is not set
1930 +# CONFIG_INPUT_ADXL34X is not set
1931 +# CONFIG_INPUT_APANEL is not set
1932 +# CONFIG_INPUT_ATI_REMOTE2 is not set
1933 +# CONFIG_INPUT_ATI_REMOTE is not set
1934 +# CONFIG_INPUT_ATLAS_BTNS is not set
1935 +# CONFIG_INPUT_BMA150 is not set
1936 +# CONFIG_INPUT_CM109 is not set
1937 +# CONFIG_INPUT_CMA3000 is not set
1938 +# CONFIG_INPUT_EVBUG is not set
1939 +# CONFIG_INPUT_EVDEV is not set
1940 +# CONFIG_INPUT_FF_MEMLESS is not set
1941 +# CONFIG_INPUT_GP2A is not set
1942 +# CONFIG_INPUT_GPIO_BEEPER is not set
1943 +# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
1944 +# CONFIG_INPUT_GPIO_TILT_POLLED is not set
1945 +# CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set
1946 +# CONFIG_INPUT_IMS_PCU is not set
1947 +# CONFIG_INPUT is not set
1948 +# CONFIG_INPUT_JOYDEV is not set
1949 +# CONFIG_INPUT_JOYSTICK is not set
1950 +# CONFIG_INPUT_KEYBOARD is not set
1951 +# CONFIG_INPUT_KEYSPAN_REMOTE is not set
1952 +# CONFIG_INPUT_KXTJ9 is not set
1953 +# CONFIG_INPUT_MATRIXKMAP is not set
1954 +CONFIG_INPUT_MISC=y
1955 +# CONFIG_INPUT_MMA8450 is not set
1956 +# CONFIG_INPUT_MOUSEDEV is not set
1957 +# CONFIG_INPUT_MOUSE is not set
1958 +# CONFIG_INPUT_MPU3050 is not set
1959 +# CONFIG_INPUT_PCF8574 is not set
1960 +# CONFIG_INPUT_PCSPKR is not set
1961 +# CONFIG_INPUT_POLLDEV is not set
1962 +# CONFIG_INPUT_POWERMATE is not set
1963 +# CONFIG_INPUT_PWM_BEEPER is not set
1964 +# CONFIG_INPUT_SPARSEKMAP is not set
1965 +# CONFIG_INPUT_TABLET is not set
1966 +# CONFIG_INPUT_TOUCHSCREEN is not set
1967 +# CONFIG_INPUT_UINPUT is not set
1968 +# CONFIG_INPUT_WISTRON_BTNS is not set
1969 +# CONFIG_INPUT_YEALINK is not set
1970 +# CONFIG_INTEL_IDLE is not set
1971 +# CONFIG_INTEL_MEI is not set
1972 +# CONFIG_INTEL_MEI_ME is not set
1973 +# CONFIG_INTEL_MIC_CARD is not set
1974 +# CONFIG_INTEL_MIC_HOST is not set
1975 +# CONFIG_INTEL_MID_PTI is not set
1976 +# CONFIG_INTEL_OAKTRAIL is not set
1977 +# CONFIG_INTEL_RST is not set
1978 +# CONFIG_INTEL_SMARTCONNECT is not set
1979 +# CONFIG_INTERVAL_TREE_TEST is not set
1980 +# CONFIG_INV_MPU6050_IIO is not set
1981 +CONFIG_IOMMU_HELPER=y
1982 +# CONFIG_IOMMU_SUPPORT is not set
1983 +# CONFIG_IOSCHED_CFQ is not set
1984 +CONFIG_IOSCHED_DEADLINE=y
1985 +CONFIG_IOSCHED_NOOP=y
1986 +# CONFIG_IP1000 is not set
1987 +# CONFIG_IP17XX_PHY is not set
1988 +# CONFIG_IP6_NF_FILTER is not set
1989 +# CONFIG_IP6_NF_IPTABLES is not set
1990 +# CONFIG_IP6_NF_MANGLE is not set
1991 +# CONFIG_IP6_NF_MATCH_AH is not set
1992 +# CONFIG_IP6_NF_MATCH_EUI64 is not set
1993 +# CONFIG_IP6_NF_MATCH_FRAG is not set
1994 +# CONFIG_IP6_NF_MATCH_HL is not set
1995 +# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set
1996 +# CONFIG_IP6_NF_MATCH_MH is not set
1997 +# CONFIG_IP6_NF_MATCH_OPTS is not set
1998 +# CONFIG_IP6_NF_MATCH_RPFILTER is not set
1999 +# CONFIG_IP6_NF_MATCH_RT is not set
2000 +# CONFIG_IP6_NF_QUEUE is not set
2001 +# CONFIG_IP6_NF_RAW is not set
2002 +# CONFIG_IP6_NF_TARGET_HL is not set
2003 +# CONFIG_IP6_NF_TARGET_LOG is not set
2004 +# CONFIG_IP6_NF_TARGET_REJECT is not set
2005 +# CONFIG_IP6_NF_TARGET_SYNPROXY is not set
2006 +# CONFIG_IPACK_BUS is not set
2007 +CONFIG_IP_ADVANCED_ROUTER=y
2008 +# CONFIG_IPC_NS is not set
2009 +# CONFIG_IP_DCCP is not set
2010 +# CONFIG_IP_FIB_TRIE_STATS is not set
2011 +# CONFIG_IPMI_HANDLER is not set
2012 +CONFIG_IP_MROUTE_MULTIPLE_TABLES=y
2013 +CONFIG_IP_MROUTE=y
2014 +CONFIG_IP_MULTICAST=y
2015 +CONFIG_IP_MULTIPLE_TABLES=y
2016 +# CONFIG_IP_NF_ARPFILTER is not set
2017 +# CONFIG_IP_NF_ARP_MANGLE is not set
2018 +# CONFIG_IP_NF_ARPTABLES is not set
2019 +# CONFIG_IP_NF_FILTER is not set
2020 +# CONFIG_IP_NF_IPTABLES is not set
2021 +# CONFIG_IP_NF_MANGLE is not set
2022 +# CONFIG_IP_NF_MATCH_AH is not set
2023 +# CONFIG_IP_NF_MATCH_ECN is not set
2024 +# CONFIG_IP_NF_MATCH_RPFILTER is not set
2025 +# CONFIG_IP_NF_MATCH_SYNPROXY is not set
2026 +# CONFIG_IP_NF_MATCH_TTL is not set
2027 +# CONFIG_IP_NF_QUEUE is not set
2028 +# CONFIG_IP_NF_RAW is not set
2029 +# CONFIG_IP_NF_SECURITY is not set
2030 +# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
2031 +# CONFIG_IP_NF_TARGET_ECN is not set
2032 +# CONFIG_IP_NF_TARGET_LOG is not set
2033 +# CONFIG_IP_NF_TARGET_MASQUERADE is not set
2034 +# CONFIG_IP_NF_TARGET_NETMAP is not set
2035 +# CONFIG_IP_NF_TARGET_REDIRECT is not set
2036 +# CONFIG_IP_NF_TARGET_REJECT is not set
2037 +# CONFIG_IP_NF_TARGET_SYNPROXY is not set
2038 +# CONFIG_IP_NF_TARGET_TTL is not set
2039 +# CONFIG_IP_NF_TARGET_ULOG is not set
2040 +# CONFIG_IP_PIMSM_V1 is not set
2041 +# CONFIG_IP_PIMSM_V2 is not set
2042 +# CONFIG_IP_PNP is not set
2043 +CONFIG_IP_ROUTE_MULTIPATH=y
2044 +CONFIG_IP_ROUTE_VERBOSE=y
2045 +# CONFIG_IP_SCTP is not set
2046 +# CONFIG_IP_SET is not set
2047 +# CONFIG_IPV6 is not set
2048 +# CONFIG_IPV6_MIP6 is not set
2049 +# CONFIG_IPV6_MROUTE is not set
2050 +# CONFIG_IPV6_MROUTE_MULTIPLE_TABLES is not set
2051 +# CONFIG_IPV6_MULTIPLE_TABLES is not set
2052 +CONFIG_IPV6_NDISC_NODETYPE=y
2053 +# CONFIG_IPV6_OPTIMISTIC_DAD is not set
2054 +# CONFIG_IPV6_PRIVACY is not set
2055 +# CONFIG_IPV6_ROUTE_INFO is not set
2056 +# CONFIG_IPV6_ROUTER_PREF is not set
2057 +# CONFIG_IPV6_SIT_6RD is not set
2058 +# CONFIG_IPV6_SIT is not set
2059 +# CONFIG_IPV6_TUNNEL is not set
2060 +# CONFIG_IPV6_VTI is not set
2061 +# CONFIG_IP_VS is not set
2062 +# CONFIG_IPW2100_DEBUG is not set
2063 +# CONFIG_IPW2100 is not set
2064 +CONFIG_IPW2100_MONITOR=y
2065 +# CONFIG_IPW2200_DEBUG is not set
2066 +# CONFIG_IPW2200 is not set
2067 +CONFIG_IPW2200_MONITOR=y
2068 +# CONFIG_IPW2200_PROMISCUOUS is not set
2069 +# CONFIG_IPW2200_QOS is not set
2070 +# CONFIG_IPW2200_RADIOTAP is not set
2071 +# CONFIG_IPWIRELESS is not set
2072 +# CONFIG_IPX is not set
2073 +# CONFIG_IRDA is not set
2074 +# CONFIG_IR_IMON is not set
2075 +# CONFIG_IR_JVC_DECODER is not set
2076 +# CONFIG_IR_LIRC_CODEC is not set
2077 +# CONFIG_IR_MCEUSB is not set
2078 +# CONFIG_IR_NEC_DECODER is not set
2079 +# CONFIG_IRQ_ALL_CPUS is not set
2080 +CONFIG_IRQCHIP=y
2081 +# CONFIG_IRQ_DOMAIN_DEBUG is not set
2082 +CONFIG_IRQ_DOMAIN=y
2083 +CONFIG_IRQ_FORCED_THREADING=y
2084 +# CONFIG_IRQSOFF_TRACER is not set
2085 +# CONFIG_IRQ_TIME_ACCOUNTING is not set
2086 +CONFIG_IRQ_WORK=y
2087 +# CONFIG_IR_RC5_DECODER is not set
2088 +# CONFIG_IR_RC5_SZ_DECODER is not set
2089 +# CONFIG_IR_RC6_DECODER is not set
2090 +# CONFIG_IR_SONY_DECODER is not set
2091 +# CONFIG_IR_STREAMZAP is not set
2092 +# CONFIG_ISCSI_BOOT_SYSFS is not set
2093 +# CONFIG_ISCSI_TCP is not set
2094 +# CONFIG_ISDN_AUDIO is not set
2095 +# CONFIG_ISDN_CAPI_CAPIDRV is not set
2096 +# CONFIG_ISDN_CAPI is not set
2097 +# CONFIG_ISDN_DIVERSION is not set
2098 +# CONFIG_ISDN_DRV_ACT2000 is not set
2099 +# CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON is not set
2100 +# CONFIG_ISDN_DRV_GIGASET is not set
2101 +# CONFIG_ISDN_DRV_HISAX is not set
2102 +# CONFIG_ISDN_DRV_ICN is not set
2103 +# CONFIG_ISDN_DRV_LOOP is not set
2104 +# CONFIG_ISDN_DRV_PCBIT is not set
2105 +# CONFIG_ISDN_DRV_SC is not set
2106 +# CONFIG_ISDN_I4L is not set
2107 +CONFIG_ISDN=y
2108 +# CONFIG_ISL29003 is not set
2109 +# CONFIG_ISL29020 is not set
2110 +# CONFIG_ISO9660_FS is not set
2111 +# CONFIG_ISS4xx is not set
2112 +# CONFIG_ITG3200 is not set
2113 +# CONFIG_IWL3945 is not set
2114 +# CONFIG_IWLAGN is not set
2115 +# CONFIG_IWLWIFI is not set
2116 +# CONFIG_IWMC3200TOP is not set
2117 +# CONFIG_IXGBE is not set
2118 +# CONFIG_IXGBEVF is not set
2119 +# CONFIG_IXGB is not set
2120 +# CONFIG_JBD2_DEBUG is not set
2121 +# CONFIG_JBD_DEBUG is not set
2122 +# CONFIG_JBD is not set
2123 +# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
2124 +# CONFIG_JFFS2_CMODE_NONE is not set
2125 +CONFIG_JFFS2_CMODE_PRIORITY=y
2126 +# CONFIG_JFFS2_CMODE_SIZE is not set
2127 +CONFIG_JFFS2_COMPRESSION_OPTIONS=y
2128 +CONFIG_JFFS2_FS_DEBUG=0
2129 +# CONFIG_JFFS2_FS_POSIX_ACL is not set
2130 +# CONFIG_JFFS2_FS_SECURITY is not set
2131 +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
2132 +CONFIG_JFFS2_FS_WRITEBUFFER=y
2133 +CONFIG_JFFS2_FS_XATTR=y
2134 +CONFIG_JFFS2_FS=y
2135 +CONFIG_JFFS2_LZMA=y
2136 +# CONFIG_JFFS2_LZO is not set
2137 +CONFIG_JFFS2_RTIME=y
2138 +# CONFIG_JFFS2_RUBIN is not set
2139 +CONFIG_JFFS2_SUMMARY=y
2140 +# CONFIG_JFFS2_ZLIB is not set
2141 +# CONFIG_JFS_DEBUG is not set
2142 +# CONFIG_JFS_FS is not set
2143 +# CONFIG_JFS_POSIX_ACL is not set
2144 +# CONFIG_JFS_SECURITY is not set
2145 +# CONFIG_JFS_STATISTICS is not set
2146 +# CONFIG_JME is not set
2147 +CONFIG_JOLIET=y
2148 +# CONFIG_JUMP_LABEL is not set
2149 +# CONFIG_KALLSYMS_ALL is not set
2150 +# CONFIG_KALLSYMS is not set
2151 +# CONFIG_KALLSYMS_UNCOMPRESSED is not set
2152 +# CONFIG_KARMA_PARTITION is not set
2153 +# CONFIG_KERNEL_BZIP2 is not set
2154 +# CONFIG_KERNEL_GZIP is not set
2155 +# CONFIG_KERNEL_LZ4 is not set
2156 +# CONFIG_KERNEL_LZMA is not set
2157 +# CONFIG_KERNEL_LZO is not set
2158 +CONFIG_KERNEL_MODE_NEON=y
2159 +CONFIG_KERNEL_XZ=y
2160 +CONFIG_KERNFS=y
2161 +# CONFIG_KEXEC is not set
2162 +# CONFIG_KEYBOARD_ADP5588 is not set
2163 +# CONFIG_KEYBOARD_ADP5589 is not set
2164 +# CONFIG_KEYBOARD_ATKBD is not set
2165 +# CONFIG_KEYBOARD_GPIO_POLLED is not set
2166 +# CONFIG_KEYBOARD_LKKBD is not set
2167 +# CONFIG_KEYBOARD_LM8323 is not set
2168 +# CONFIG_KEYBOARD_LM8333 is not set
2169 +# CONFIG_KEYBOARD_MATRIX is not set
2170 +# CONFIG_KEYBOARD_MAX7359 is not set
2171 +# CONFIG_KEYBOARD_MCS is not set
2172 +# CONFIG_KEYBOARD_MPR121 is not set
2173 +# CONFIG_KEYBOARD_NEWTON is not set
2174 +# CONFIG_KEYBOARD_OMAP4 is not set
2175 +# CONFIG_KEYBOARD_OPENCORES is not set
2176 +# CONFIG_KEYBOARD_PXA27x is not set
2177 +# CONFIG_KEYBOARD_QT1070 is not set
2178 +# CONFIG_KEYBOARD_QT2160 is not set
2179 +# CONFIG_KEYBOARD_SAMSUNG is not set
2180 +# CONFIG_KEYBOARD_SH_KEYSC is not set
2181 +# CONFIG_KEYBOARD_STOWAWAY is not set
2182 +# CONFIG_KEYBOARD_SUNKBD is not set
2183 +# CONFIG_KEYBOARD_TCA6416 is not set
2184 +# CONFIG_KEYBOARD_TCA8418 is not set
2185 +# CONFIG_KEYBOARD_XTKBD is not set
2186 +# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
2187 +# CONFIG_KEYS is not set
2188 +# CONFIG_KGDB is not set
2189 +# CONFIG_KMEMCHECK is not set
2190 +# CONFIG_KPROBES is not set
2191 +# CONFIG_KS8842 is not set
2192 +# CONFIG_KS8851 is not set
2193 +# CONFIG_KS8851_MLL is not set
2194 +# CONFIG_KSM is not set
2195 +# CONFIG_KSZ884X_PCI is not set
2196 +CONFIG_KTIME_SCALAR=y
2197 +CONFIG_KUSER_HELPERS=y
2198 +# CONFIG_KVM_GUEST is not set
2199 +# CONFIG_KXSD9 is not set
2200 +# CONFIG_L2TP_ETH is not set
2201 +# CONFIG_L2TP_IP is not set
2202 +# CONFIG_L2TP is not set
2203 +# CONFIG_L2TP_V3 is not set
2204 +# CONFIG_LANMEDIA is not set
2205 +# CONFIG_LANTIQ is not set
2206 +# CONFIG_LAPB is not set
2207 +# CONFIG_LASAT is not set
2208 +# CONFIG_LATENCYTOP is not set
2209 +# CONFIG_LATTICE_ECP3_CONFIG is not set
2210 +CONFIG_LBDAF=y
2211 +# CONFIG_LCD_HX8357 is not set
2212 +# CONFIG_LCD_ILI922X is not set
2213 +# CONFIG_LCD_ILI9320 is not set
2214 +# CONFIG_LCD_LMS501KF03 is not set
2215 +# CONFIG_LDM_PARTITION is not set
2216 +# CONFIG_LEDS_ATMEL_PWM is not set
2217 +# CONFIG_LEDS_BD2802 is not set
2218 +# CONFIG_LEDS_BLINKM is not set
2219 +CONFIG_LEDS_CLASS=y
2220 +# CONFIG_LEDS_DAC124S085 is not set
2221 +# CONFIG_LEDS_GPIO is not set
2222 +CONFIG_LEDS_GPIO_OF=y
2223 +CONFIG_LEDS_GPIO_PLATFORM=y
2224 +# CONFIG_LEDS_INTEL_SS4200 is not set
2225 +# CONFIG_LEDS_LM3530 is not set
2226 +# CONFIG_LEDS_LM3556 is not set
2227 +# CONFIG_LEDS_LM355x is not set
2228 +# CONFIG_LEDS_LM3642 is not set
2229 +# CONFIG_LEDS_LP3944 is not set
2230 +# CONFIG_LEDS_LP5521 is not set
2231 +# CONFIG_LEDS_LP5523 is not set
2232 +# CONFIG_LEDS_LP5562 is not set
2233 +# CONFIG_LEDS_LP8501 is not set
2234 +# CONFIG_LEDS_LT3593 is not set
2235 +# CONFIG_LEDS_NET5501 is not set
2236 +# CONFIG_LEDS_OT200 is not set
2237 +# CONFIG_LEDS_PCA9532 is not set
2238 +# CONFIG_LEDS_PCA955X is not set
2239 +# CONFIG_LEDS_PCA9633 is not set
2240 +# CONFIG_LEDS_PCA963X is not set
2241 +# CONFIG_LEDS_PCA9685 is not set
2242 +# CONFIG_LEDS_PWM is not set
2243 +# CONFIG_LEDS_RENESAS_TPU is not set
2244 +# CONFIG_LEDS_TCA6507 is not set
2245 +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
2246 +# CONFIG_LEDS_TRIGGER_CAMERA is not set
2247 +# CONFIG_LEDS_TRIGGER_CPU is not set
2248 +CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
2249 +# CONFIG_LEDS_TRIGGER_GPIO is not set
2250 +# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
2251 +# CONFIG_LEDS_TRIGGER_IDE_DISK is not set
2252 +# CONFIG_LEDS_TRIGGER_MORSE is not set
2253 +CONFIG_LEDS_TRIGGER_NETDEV=y
2254 +# CONFIG_LEDS_TRIGGER_ONESHOT is not set
2255 +CONFIG_LEDS_TRIGGERS=y
2256 +CONFIG_LEDS_TRIGGER_TIMER=y
2257 +# CONFIG_LEDS_TRIGGER_TRANSIENT is not set
2258 +# CONFIG_LEDS_TRIGGER_USBDEV is not set
2259 +# CONFIG_LEGACY_PTYS is not set
2260 +# CONFIG_LIB80211_CRYPT_CCMP is not set
2261 +# CONFIG_LIB80211_CRYPT_TKIP is not set
2262 +# CONFIG_LIB80211_CRYPT_WEP is not set
2263 +# CONFIG_LIB80211_DEBUG is not set
2264 +# CONFIG_LIB80211 is not set
2265 +# CONFIG_LIBCRC32C is not set
2266 +# CONFIG_LIBERTAS is not set
2267 +# CONFIG_LIBERTAS_THINFIRM is not set
2268 +# CONFIG_LIBERTAS_USB is not set
2269 +# CONFIG_LIBFC is not set
2270 +# CONFIG_LIBFCOE is not set
2271 +CONFIG_LIBFDT=y
2272 +# CONFIG_LIBIPW_DEBUG is not set
2273 +# CONFIG_LINE6_USB is not set
2274 +# CONFIG_LIRC_STAGING is not set
2275 +# CONFIG_LIS3L02DQ is not set
2276 +# CONFIG_LKDTM is not set
2277 +# CONFIG_LLC2 is not set
2278 +CONFIG_LLC=y
2279 +CONFIG_LOCALVERSION=""
2280 +# CONFIG_LOCALVERSION_AUTO is not set
2281 +CONFIG_LOCKDEP_SUPPORT=y
2282 +# CONFIG_LOCKD is not set
2283 +CONFIG_LOCKD_V4=y
2284 +# CONFIG_LOCK_STAT is not set
2285 +# CONFIG_LOCK_TORTURE_TEST is not set
2286 +# CONFIG_LOCKUP_DETECTOR is not set
2287 +CONFIG_LOG_BUF_SHIFT=17
2288 +# CONFIG_LOGFS is not set
2289 +# CONFIG_LOGIG940_FF is not set
2290 +# CONFIG_LOGIRUMBLEPAD2_FF is not set
2291 +# CONFIG_LOGITECH_FF is not set
2292 +# CONFIG_LOGIWHEELS_FF is not set
2293 +# CONFIG_LOGO is not set
2294 +# CONFIG_LOONGSON_MC146818 is not set
2295 +# CONFIG_LP486E is not set
2296 +# CONFIG_LPC_ICH is not set
2297 +# CONFIG_LP_CONSOLE is not set
2298 +# CONFIG_LPC_SCH is not set
2299 +# CONFIG_LSI_ET1011C_PHY is not set
2300 +# CONFIG_LTE_GDM724X is not set
2301 +# CONFIG_LTPC is not set
2302 +# CONFIG_LUSTRE_FS is not set
2303 +# CONFIG_LXT_PHY is not set
2304 +CONFIG_LZMA_COMPRESS=y
2305 +CONFIG_LZMA_DECOMPRESS=y
2306 +# CONFIG_LZO_COMPRESS is not set
2307 +# CONFIG_LZO_DECOMPRESS is not set
2308 +# CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE is not set
2309 +# CONFIG_MAC80211 is not set
2310 +# CONFIG_MAC80211_MESSAGE_TRACING is not set
2311 +# CONFIG_MACB is not set
2312 +# CONFIG_MAC_EMUMOUSEBTN is not set
2313 +# CONFIG_MACH_DECSTATION is not set
2314 +# CONFIG_MACH_JAZZ is not set
2315 +# CONFIG_MACH_JZ4740 is not set
2316 +# CONFIG_MACH_LOONGSON1 is not set
2317 +# CONFIG_MACH_LOONGSON is not set
2318 +# CONFIG_MACH_NO_WESTBRIDGE is not set
2319 +# CONFIG_MACH_TX39XX is not set
2320 +# CONFIG_MACH_TX49XX is not set
2321 +# CONFIG_MACH_VR41XX is not set
2322 +# CONFIG_MACINTOSH_DRIVERS is not set
2323 +# CONFIG_MAC_PARTITION is not set
2324 +# CONFIG_MACVLAN is not set
2325 +# CONFIG_MACVTAP is not set
2326 +# CONFIG_MAG3110 is not set
2327 +CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
2328 +# CONFIG_MAGIC_SYSRQ is not set
2329 +# CONFIG_MAILBOX is not set
2330 +# CONFIG_MARVELL_PHY is not set
2331 +# CONFIG_MAX1363 is not set
2332 +# CONFIG_MAX517 is not set
2333 +# CONFIG_MAX63XX_WATCHDOG is not set
2334 +# CONFIG_MCB is not set
2335 +# CONFIG_MCP320X is not set
2336 +# CONFIG_MCP3422 is not set
2337 +# CONFIG_MCP4725 is not set
2338 +# CONFIG_MCPM is not set
2339 +# CONFIG_MD_FAULTY is not set
2340 +# CONFIG_MDIO_BITBANG is not set
2341 +# CONFIG_MDIO_BUS_MUX_GPIO is not set
2342 +# CONFIG_MDIO_BUS_MUX_MMIOREG is not set
2343 +# CONFIG_MD is not set
2344 +# CONFIG_MEDIA_ANALOG_TV_SUPPORT is not set
2345 +# CONFIG_MEDIA_ATTACH is not set
2346 +# CONFIG_MEDIA_CAMERA_SUPPORT is not set
2347 +# CONFIG_MEDIA_CONTROLLER is not set
2348 +# CONFIG_MEDIA_DIGITAL_TV_SUPPORT is not set
2349 +# CONFIG_MEDIA_PARPORT_SUPPORT is not set
2350 +# CONFIG_MEDIA_PCI_SUPPORT is not set
2351 +# CONFIG_MEDIA_RADIO_SUPPORT is not set
2352 +# CONFIG_MEDIA_RC_SUPPORT is not set
2353 +# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
2354 +# CONFIG_MEDIA_SUPPORT is not set
2355 +# CONFIG_MEDIA_TUNER_CUSTOMISE is not set
2356 +# CONFIG_MEDIA_USB_SUPPORT is not set
2357 +# CONFIG_MEGARAID_LEGACY is not set
2358 +# CONFIG_MEGARAID_NEWGEN is not set
2359 +# CONFIG_MEGARAID_SAS is not set
2360 +# CONFIG_MEMORY_FAILURE is not set
2361 +# CONFIG_MEMORY is not set
2362 +# CONFIG_MEMSTICK is not set
2363 +# CONFIG_MEN_A21_WDT is not set
2364 +# CONFIG_MFD_88PM800 is not set
2365 +# CONFIG_MFD_88PM805 is not set
2366 +# CONFIG_MFD_88PM860X is not set
2367 +# CONFIG_MFD_AAT2870_CORE is not set
2368 +# CONFIG_MFD_ARIZONA_I2C is not set
2369 +# CONFIG_MFD_ARIZONA_SPI is not set
2370 +# CONFIG_MFD_AS3711 is not set
2371 +# CONFIG_MFD_AS3722 is not set
2372 +# CONFIG_MFD_ASIC3 is not set
2373 +# CONFIG_MFD_BCM590XX is not set
2374 +# CONFIG_MFD_CORE is not set
2375 +# CONFIG_MFD_CROS_EC is not set
2376 +# CONFIG_MFD_CS5535 is not set
2377 +# CONFIG_MFD_DA9052_I2C is not set
2378 +# CONFIG_MFD_DA9052_SPI is not set
2379 +# CONFIG_MFD_DA9055 is not set
2380 +# CONFIG_MFD_DA9063 is not set
2381 +# CONFIG_MFD_JANZ_CMODIO is not set
2382 +# CONFIG_MFD_KEMPLD is not set
2383 +# CONFIG_MFD_LM3533 is not set
2384 +# CONFIG_MFD_LP3943 is not set
2385 +# CONFIG_MFD_LP8788 is not set
2386 +# CONFIG_MFD_MAX14577 is not set
2387 +# CONFIG_MFD_MAX77686 is not set
2388 +# CONFIG_MFD_MAX77693 is not set
2389 +# CONFIG_MFD_MAX8907 is not set
2390 +# CONFIG_MFD_MAX8925 is not set
2391 +# CONFIG_MFD_MAX8997 is not set
2392 +# CONFIG_MFD_MAX8998 is not set
2393 +# CONFIG_MFD_MC13783 is not set
2394 +# CONFIG_MFD_MC13XXX_I2C is not set
2395 +# CONFIG_MFD_MC13XXX is not set
2396 +# CONFIG_MFD_MC13XXX_SPI is not set
2397 +# CONFIG_MFD_OMAP_USB_HOST is not set
2398 +# CONFIG_MFD_PALMAS is not set
2399 +# CONFIG_MFD_PCF50633 is not set
2400 +# CONFIG_MFD_PM8921_CORE is not set
2401 +# CONFIG_MFD_RC5T583 is not set
2402 +# CONFIG_MFD_RDC321X is not set
2403 +# CONFIG_MFD_RETU is not set
2404 +# CONFIG_MFD_RTSX_PCI is not set
2405 +# CONFIG_MFD_S5M_CORE is not set
2406 +# CONFIG_MFD_SEC_CORE is not set
2407 +# CONFIG_MFD_SI476X_CORE is not set
2408 +# CONFIG_MFD_SM501 is not set
2409 +# CONFIG_MFD_SMSC is not set
2410 +# CONFIG_MFD_STMPE is not set
2411 +CONFIG_MFD_SUPPORT=y
2412 +# CONFIG_MFD_SYSCON is not set
2413 +# CONFIG_MFD_T7L66XB is not set
2414 +# CONFIG_MFD_TC3589X is not set
2415 +# CONFIG_MFD_TC6387XB is not set
2416 +# CONFIG_MFD_TC6393XB is not set
2417 +# CONFIG_MFD_TI_AM335X_TSCADC is not set
2418 +# CONFIG_MFD_TIMBERDALE is not set
2419 +# CONFIG_MFD_TMIO is not set
2420 +# CONFIG_MFD_TPS65090 is not set
2421 +# CONFIG_MFD_TPS65217 is not set
2422 +# CONFIG_MFD_TPS65218 is not set
2423 +# CONFIG_MFD_TPS6586X is not set
2424 +# CONFIG_MFD_TPS65910 is not set
2425 +# CONFIG_MFD_TPS65912_I2C is not set
2426 +# CONFIG_MFD_TPS65912 is not set
2427 +# CONFIG_MFD_TPS65912_SPI is not set
2428 +# CONFIG_MFD_TPS80031 is not set
2429 +# CONFIG_MFD_VIPERBOARD is not set
2430 +# CONFIG_MFD_VX855 is not set
2431 +# CONFIG_MFD_WL1273_CORE is not set
2432 +# CONFIG_MFD_WM831X_I2C is not set
2433 +# CONFIG_MFD_WM831X is not set
2434 +# CONFIG_MFD_WM831X_SPI is not set
2435 +# CONFIG_MFD_WM8350_I2C is not set
2436 +# CONFIG_MFD_WM8400 is not set
2437 +# CONFIG_MFD_WM8994 is not set
2438 +# CONFIG_MG_DISK is not set
2439 +# CONFIG_MICREL_KS8995MA is not set
2440 +# CONFIG_MICREL_PHY is not set
2441 +CONFIG_MIGHT_HAVE_PCI=y
2442 +# CONFIG_MIGRATION is not set
2443 +CONFIG_MII=y
2444 +# CONFIG_MIKROTIK_RB532 is not set
2445 +# CONFIG_MINIX_FS is not set
2446 +# CONFIG_MINIX_FS_NATIVE_ENDIAN is not set
2447 +# CONFIG_MINIX_SUBPARTITION is not set
2448 +# CONFIG_MIPS_ALCHEMY is not set
2449 +# CONFIG_MIPS_COBALT is not set
2450 +# CONFIG_MIPS_FPU_EMU is not set
2451 +# CONFIG_MIPS_MALTA is not set
2452 +# CONFIG_MIPS_SEAD3 is not set
2453 +# CONFIG_MIPS_SIM is not set
2454 +CONFIG_MISC_DEVICES=y
2455 +CONFIG_MISC_FILESYSTEMS=y
2456 +# CONFIG_MISDN_AVMFRITZ is not set
2457 +# CONFIG_MISDN_HFCPCI is not set
2458 +# CONFIG_MISDN_HFCUSB is not set
2459 +# CONFIG_MISDN_INFINEON is not set
2460 +# CONFIG_MISDN is not set
2461 +# CONFIG_MISDN_NETJET is not set
2462 +# CONFIG_MISDN_SPEEDFAX is not set
2463 +# CONFIG_MISDN_W6692 is not set
2464 +# CONFIG_MKISS is not set
2465 +# CONFIG_MLX4_CORE is not set
2466 +# CONFIG_MLX4_EN is not set
2467 +# CONFIG_MLX5_CORE is not set
2468 +# CONFIG_MMC_ARMMMCI is not set
2469 +# CONFIG_MMC_AU1X is not set
2470 +CONFIG_MMC_BLOCK_BOUNCE=y
2471 +# CONFIG_MMC_BLOCK is not set
2472 +CONFIG_MMC_BLOCK_MINORS=8
2473 +# CONFIG_MMC_CB710 is not set
2474 +# CONFIG_MMC_CLKGATE is not set
2475 +# CONFIG_MMC_DEBUG is not set
2476 +# CONFIG_MMC_DW is not set
2477 +# CONFIG_MMC is not set
2478 +# CONFIG_MMC_MVSDIO is not set
2479 +# CONFIG_MMC_S3C is not set
2480 +# CONFIG_MMC_SDHCI_ACPI is not set
2481 +# CONFIG_MMC_SDHCI_BCM_KONA is not set
2482 +# CONFIG_MMC_SDHCI is not set
2483 +# CONFIG_MMC_SDHCI_OF_ARASAN is not set
2484 +# CONFIG_MMC_SDHCI_OF_ESDHC is not set
2485 +# CONFIG_MMC_SDHCI_OF_HLWD is not set
2486 +# CONFIG_MMC_SDHCI_PXAV2 is not set
2487 +# CONFIG_MMC_SDHCI_PXAV3 is not set
2488 +# CONFIG_MMC_SDRICOH_CS is not set
2489 +# CONFIG_MMC_SPI is not set
2490 +# CONFIG_MMC_TEST is not set
2491 +# CONFIG_MMC_UNSAFE_RESUME is not set
2492 +# CONFIG_MMC_USDHI6ROL0 is not set
2493 +# CONFIG_MMC_USHC is not set
2494 +# CONFIG_MMC_VIA_SDMMC is not set
2495 +# CONFIG_MMC_VUB300 is not set
2496 +CONFIG_MMU=y
2497 +# CONFIG_MODULE_FORCE_LOAD is not set
2498 +# CONFIG_MODULE_FORCE_UNLOAD is not set
2499 +# CONFIG_MODULE_SIG is not set
2500 +# CONFIG_MODULE_SRCVERSION_ALL is not set
2501 +CONFIG_MODULE_STRIPPED=y
2502 +CONFIG_MODULES_USE_ELF_REL=y
2503 +CONFIG_MODULES=y
2504 +CONFIG_MODULE_UNLOAD=y
2505 +# CONFIG_MODVERSIONS is not set
2506 +# CONFIG_MOUSE_APPLETOUCH is not set
2507 +# CONFIG_MOUSE_GPIO is not set
2508 +# CONFIG_MOUSE_INPORT is not set
2509 +# CONFIG_MOUSE_LOGIBM is not set
2510 +# CONFIG_MOUSE_PC110PAD is not set
2511 +# CONFIG_MOUSE_PS2_SENTELIC is not set
2512 +# CONFIG_MOUSE_SYNAPTICS_I2C is not set
2513 +# CONFIG_MOUSE_SYNAPTICS_USB is not set
2514 +# CONFIG_MPL3115 is not set
2515 +# CONFIG_MSDOS_FS is not set
2516 +CONFIG_MSDOS_PARTITION=y
2517 +# CONFIG_MSI_BITMAP_SELFTEST is not set
2518 +# CONFIG_MSI_LAPTOP is not set
2519 +# CONFIG_MTD_ABSENT is not set
2520 +# CONFIG_MTD_AFS_PARTS is not set
2521 +# CONFIG_MTD_ALAUDA is not set
2522 +# CONFIG_MTD_AR7_PARTS is not set
2523 +# CONFIG_MTD_ARM_INTEGRATOR is not set
2524 +CONFIG_MTD_BLKDEVS=y
2525 +# CONFIG_MTD_BLOCK2MTD is not set
2526 +CONFIG_MTD_BLOCK=y
2527 +# CONFIG_MTD_CFI_ADV_OPTIONS is not set
2528 +CONFIG_MTD_CFI_AMDSTD=y
2529 +# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
2530 +CONFIG_MTD_CFI_I1=y
2531 +CONFIG_MTD_CFI_I2=y
2532 +# CONFIG_MTD_CFI_I4 is not set
2533 +# CONFIG_MTD_CFI_I8 is not set
2534 +CONFIG_MTD_CFI_INTELEXT=y
2535 +# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
2536 +CONFIG_MTD_CFI_NOSWAP=y
2537 +# CONFIG_MTD_CFI_STAA is not set
2538 +CONFIG_MTD_CFI_UTIL=y
2539 +CONFIG_MTD_CFI=y
2540 +CONFIG_MTD_CHAR=y
2541 +# CONFIG_MTD_CMDLINE_PARTS is not set
2542 +CONFIG_MTD_COMPLEX_MAPPINGS=y
2543 +# CONFIG_MTD_DATAFLASH is not set
2544 +# CONFIG_MTD_DEBUG is not set
2545 +# CONFIG_MTD_DOC2000 is not set
2546 +# CONFIG_MTD_DOC2001 is not set
2547 +# CONFIG_MTD_DOC2001PLUS is not set
2548 +# CONFIG_MTD_DOCG3 is not set
2549 +CONFIG_MTD_GEN_PROBE=y
2550 +# CONFIG_MTD_GPIO_ADDR is not set
2551 +# CONFIG_MTD_INTEL_VR_NOR is not set
2552 +# CONFIG_MTD_JEDECPROBE is not set
2553 +# CONFIG_MTD_LATCH_ADDR is not set
2554 +# CONFIG_MTD_LPDDR2_NVM is not set
2555 +# CONFIG_MTD_LPDDR is not set
2556 +# CONFIG_MTD_M25P80 is not set
2557 +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
2558 +CONFIG_MTD_MAP_BANK_WIDTH_1=y
2559 +CONFIG_MTD_MAP_BANK_WIDTH_2=y
2560 +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
2561 +CONFIG_MTD_MAP_BANK_WIDTH_4=y
2562 +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
2563 +# CONFIG_MTD_MTDRAM is not set
2564 +# CONFIG_MTD_MYLOADER_PARTS is not set
2565 +# CONFIG_MTD_NAND_AMS_DELTA is not set
2566 +# CONFIG_MTD_NAND_AR934X_HW_ECC is not set
2567 +# CONFIG_MTD_NAND_AR934X is not set
2568 +# CONFIG_MTD_NAND_ATMEL is not set
2569 +# CONFIG_MTD_NAND_AU1550 is not set
2570 +# CONFIG_MTD_NAND_AUTCPU12 is not set
2571 +# CONFIG_MTD_NAND_BCH is not set
2572 +# CONFIG_MTD_NAND_BCM_UMI is not set
2573 +# CONFIG_MTD_NAND_BF5XX is not set
2574 +# CONFIG_MTD_NAND_CAFE is not set
2575 +# CONFIG_MTD_NAND_CM_X270 is not set
2576 +# CONFIG_MTD_NAND_CS553X is not set
2577 +# CONFIG_MTD_NAND_DAVINCI is not set
2578 +# CONFIG_MTD_NAND_DENALI is not set
2579 +# CONFIG_MTD_NAND_DISKONCHIP is not set
2580 +# CONFIG_MTD_NAND_DOCG4 is not set
2581 +# CONFIG_MTD_NAND_ECC_BCH is not set
2582 +# CONFIG_MTD_NAND_ECC is not set
2583 +# CONFIG_MTD_NAND_ECC_SMC is not set
2584 +# CONFIG_MTD_NAND_FSL_ELBC is not set
2585 +# CONFIG_MTD_NAND_FSL_IFC is not set
2586 +# CONFIG_MTD_NAND_FSL_UPM is not set
2587 +# CONFIG_MTD_NAND_FSMC is not set
2588 +# CONFIG_MTD_NAND_GPIO is not set
2589 +# CONFIG_MTD_NAND_GPMI_NAND is not set
2590 +# CONFIG_MTD_NAND_H1900 is not set
2591 +CONFIG_MTD_NAND_IDS=y
2592 +# CONFIG_MTD_NAND is not set
2593 +# CONFIG_MTD_NAND_JZ4740 is not set
2594 +# CONFIG_MTD_NAND_MPC5121_NFC is not set
2595 +# CONFIG_MTD_NAND_MUSEUM_IDS is not set
2596 +# CONFIG_MTD_NAND_MXC is not set
2597 +# CONFIG_MTD_NAND_NANDSIM is not set
2598 +# CONFIG_MTD_NAND_NDFC is not set
2599 +# CONFIG_MTD_NAND_NOMADIK is not set
2600 +# CONFIG_MTD_NAND_NUC900 is not set
2601 +# CONFIG_MTD_NAND_OMAP2 is not set
2602 +# CONFIG_MTD_NAND_ORION is not set
2603 +# CONFIG_MTD_NAND_PASEMI is not set
2604 +# CONFIG_MTD_NAND_PLATFORM is not set
2605 +# CONFIG_MTD_NAND_PPCHAMELEONEVB is not set
2606 +# CONFIG_MTD_NAND_PXA3xx is not set
2607 +# CONFIG_MTD_NAND_RB4XX is not set
2608 +# CONFIG_MTD_NAND_RB750 is not set
2609 +# CONFIG_MTD_NAND_RICOH is not set
2610 +# CONFIG_MTD_NAND_RTC_FROM4 is not set
2611 +# CONFIG_MTD_NAND_S3C2410 is not set
2612 +# CONFIG_MTD_NAND_SHARPSL is not set
2613 +# CONFIG_MTD_NAND_SH_FLCTL is not set
2614 +# CONFIG_MTD_NAND_SOCRATES is not set
2615 +# CONFIG_MTD_NAND_SPIA is not set
2616 +# CONFIG_MTD_NAND_TMIO is not set
2617 +# CONFIG_MTD_NAND_TXX9NDFMC is not set
2618 +# CONFIG_MTD_NAND_VERIFY_WRITE is not set
2619 +CONFIG_MTD_OF_PARTS=y
2620 +# CONFIG_MTD_ONENAND is not set
2621 +# CONFIG_MTD_OOPS is not set
2622 +# CONFIG_MTD_OTP is not set
2623 +# CONFIG_MTD_PCI is not set
2624 +# CONFIG_MTD_PCMCIA is not set
2625 +# CONFIG_MTD_PHRAM is not set
2626 +# CONFIG_MTD_PHYSMAP_COMPAT is not set
2627 +# CONFIG_MTD_PHYSMAP is not set
2628 +CONFIG_MTD_PHYSMAP_OF=y
2629 +# CONFIG_MTD_PLATRAM is not set
2630 +# CONFIG_MTD_PMC551 is not set
2631 +# CONFIG_MTD_RAM is not set
2632 +CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
2633 +# CONFIG_MTD_REDBOOT_PARTS is not set
2634 +# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
2635 +# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
2636 +# CONFIG_MTD_ROM is not set
2637 +CONFIG_MTD_ROOTFS_ROOT_DEV=y
2638 +CONFIG_MTD_ROOTFS_SPLIT=y
2639 +# CONFIG_MTD_SLRAM is not set
2640 +# CONFIG_MTD_SPINAND_MT29F is not set
2641 +# CONFIG_MTD_SPI_NOR is not set
2642 +# CONFIG_MTD_SPLIT_FIRMWARE is not set
2643 +CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware"
2644 +# CONFIG_MTD_SPLIT_LZMA_FW is not set
2645 +# CONFIG_MTD_SPLIT_SEAMA_FW is not set
2646 +# CONFIG_MTD_SPLIT_SQUASHFS_ROOT is not set
2647 +# CONFIG_MTD_SPLIT_UIMAGE_FW is not set
2648 +CONFIG_MTD_SPLIT=y
2649 +# CONFIG_MTD_SST25L is not set
2650 +# CONFIG_MTD_SWAP is not set
2651 +# CONFIG_MTD_TESTS is not set
2652 +CONFIG_MTD_UBI_BEB_LIMIT=20
2653 +# CONFIG_MTD_UBI_FASTMAP is not set
2654 +# CONFIG_MTD_UBI_GLUEBI is not set
2655 +# CONFIG_MTD_UBI is not set
2656 +CONFIG_MTD_UBI_WL_THRESHOLD=4096
2657 +# CONFIG_MTD_UIMAGE_SPLIT is not set
2658 +CONFIG_MTD=y
2659 +CONFIG_MULTI_IRQ_HANDLER=y
2660 +# CONFIG_MUTEX_SPIN_ON_OWNER is not set
2661 +# CONFIG_MV643XX_ETH is not set
2662 +# CONFIG_MVMDIO is not set
2663 +# CONFIG_MVSWITCH_PHY is not set
2664 +# CONFIG_MWAVE is not set
2665 +# CONFIG_MWL8K is not set
2666 +# CONFIG_MYRI10GE is not set
2667 +# CONFIG_NAMESPACES is not set
2668 +# CONFIG_NATIONAL_PHY is not set
2669 +# CONFIG_NATSEMI is not set
2670 +# CONFIG_NAU7802 is not set
2671 +# CONFIG_NCP_FS is not set
2672 +# CONFIG_NE2000 is not set
2673 +# CONFIG_NE2K_PCI is not set
2674 +# CONFIG_NEC_MARKEINS is not set
2675 +CONFIG_NEED_DMA_MAP_STATE=y
2676 +CONFIG_NEED_KUSER_HELPERS=y
2677 +CONFIG_NEED_PER_CPU_KM=y
2678 +# CONFIG_NET_9P is not set
2679 +# CONFIG_NET_ACT_CSUM is not set
2680 +# CONFIG_NET_ACT_GACT is not set
2681 +# CONFIG_NET_ACT_IPT is not set
2682 +# CONFIG_NET_ACT_MIRRED is not set
2683 +# CONFIG_NET_ACT_NAT is not set
2684 +# CONFIG_NET_ACT_PEDIT is not set
2685 +# CONFIG_NET_ACT_POLICE is not set
2686 +# CONFIG_NET_ACT_SIMP is not set
2687 +# CONFIG_NET_ACT_SKBEDIT is not set
2688 +CONFIG_NET_CADENCE=y
2689 +# CONFIG_NET_CALXEDA_XGMAC is not set
2690 +# CONFIG_NET_CLS_ACT is not set
2691 +# CONFIG_NET_CLS_BASIC is not set
2692 +# CONFIG_NET_CLS_BPF is not set
2693 +# CONFIG_NET_CLS_FLOW is not set
2694 +# CONFIG_NET_CLS_FW is not set
2695 +CONFIG_NET_CLS_IND=y
2696 +# CONFIG_NET_CLS_ROUTE4 is not set
2697 +# CONFIG_NET_CLS_RSVP6 is not set
2698 +# CONFIG_NET_CLS_RSVP is not set
2699 +# CONFIG_NET_CLS_TCINDEX is not set
2700 +# CONFIG_NET_CLS_U32 is not set
2701 +CONFIG_NET_CLS=y
2702 +# CONFIG_NETCONSOLE is not set
2703 +CONFIG_NET_CORE=y
2704 +# CONFIG_NETDEV_10000 is not set
2705 +CONFIG_NETDEV_1000=y
2706 +CONFIG_NETDEVICES=y
2707 +# CONFIG_NET_DROP_MONITOR is not set
2708 +# CONFIG_NET_DSA is not set
2709 +# CONFIG_NET_DSA_MV88E6060 is not set
2710 +# CONFIG_NET_DSA_MV88E6123_61_65 is not set
2711 +# CONFIG_NET_DSA_MV88E6131 is not set
2712 +# CONFIG_NET_DSA_MV88E6XXX is not set
2713 +# CONFIG_NET_DSA_MV88E6XXX_NEED_PPU is not set
2714 +# CONFIG_NET_DSA_TAG_DSA is not set
2715 +# CONFIG_NET_DSA_TAG_EDSA is not set
2716 +# CONFIG_NET_EMATCH_CMP is not set
2717 +# CONFIG_NET_EMATCH is not set
2718 +# CONFIG_NET_EMATCH_META is not set
2719 +# CONFIG_NET_EMATCH_NBYTE is not set
2720 +CONFIG_NET_EMATCH_STACK=32
2721 +# CONFIG_NET_EMATCH_TEXT is not set
2722 +# CONFIG_NET_EMATCH_U32 is not set
2723 +CONFIG_NET_ETHERNET=y
2724 +# CONFIG_NET_FC is not set
2725 +# CONFIG_NETFILTER_ADVANCED is not set
2726 +# CONFIG_NETFILTER_DEBUG is not set
2727 +# CONFIG_NETFILTER is not set
2728 +# CONFIG_NETFILTER_NETLINK_ACCT is not set
2729 +# CONFIG_NETFILTER_NETLINK is not set
2730 +# CONFIG_NETFILTER_NETLINK_LOG is not set
2731 +# CONFIG_NETFILTER_NETLINK_QUEUE_CT is not set
2732 +# CONFIG_NETFILTER_NETLINK_QUEUE is not set
2733 +# CONFIG_NETFILTER_TPROXY is not set
2734 +# CONFIG_NETFILTER_XTABLES is not set
2735 +# CONFIG_NETFILTER_XT_CONNMARK is not set
2736 +# CONFIG_NETFILTER_XT_MARK is not set
2737 +# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set
2738 +# CONFIG_NETFILTER_XT_MATCH_BPF is not set
2739 +# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set
2740 +# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set
2741 +# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set
2742 +# CONFIG_NETFILTER_XT_MATCH_CONNBYTES is not set
2743 +# CONFIG_NETFILTER_XT_MATCH_CONNLABEL is not set
2744 +# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
2745 +# CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set
2746 +# CONFIG_NETFILTER_XT_MATCH_CONNTRACK is not set
2747 +# CONFIG_NETFILTER_XT_MATCH_CPU is not set
2748 +# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
2749 +# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set
2750 +# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
2751 +# CONFIG_NETFILTER_XT_MATCH_ECN is not set
2752 +# CONFIG_NETFILTER_XT_MATCH_ESP is not set
2753 +# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set
2754 +# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
2755 +# CONFIG_NETFILTER_XT_MATCH_HL is not set
2756 +# CONFIG_NETFILTER_XT_MATCH_IPCOMP is not set
2757 +# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set
2758 +# CONFIG_NETFILTER_XT_MATCH_L2TP is not set
2759 +# CONFIG_NETFILTER_XT_MATCH_LAYER7_DEBUG is not set
2760 +# CONFIG_NETFILTER_XT_MATCH_LAYER7 is not set
2761 +# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
2762 +# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set
2763 +# CONFIG_NETFILTER_XT_MATCH_MAC is not set
2764 +# CONFIG_NETFILTER_XT_MATCH_MARK is not set
2765 +# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set
2766 +# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
2767 +# CONFIG_NETFILTER_XT_MATCH_OSF is not set
2768 +# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
2769 +# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set
2770 +# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
2771 +# CONFIG_NETFILTER_XT_MATCH_POLICY is not set
2772 +# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
2773 +# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
2774 +# CONFIG_NETFILTER_XT_MATCH_REALM is not set
2775 +# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
2776 +# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
2777 +# CONFIG_NETFILTER_XT_MATCH_SOCKET is not set
2778 +# CONFIG_NETFILTER_XT_MATCH_STATE is not set
2779 +# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
2780 +# CONFIG_NETFILTER_XT_MATCH_STRING is not set
2781 +# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
2782 +# CONFIG_NETFILTER_XT_MATCH_TIME is not set
2783 +# CONFIG_NETFILTER_XT_MATCH_U32 is not set
2784 +# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set
2785 +# CONFIG_NETFILTER_XT_TARGET_CHECKSUM is not set
2786 +# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set
2787 +# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
2788 +# CONFIG_NETFILTER_XT_TARGET_CT is not set
2789 +# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
2790 +# CONFIG_NETFILTER_XT_TARGET_HL is not set
2791 +# CONFIG_NETFILTER_XT_TARGET_HMARK is not set
2792 +# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set
2793 +# CONFIG_NETFILTER_XT_TARGET_LED is not set
2794 +# CONFIG_NETFILTER_XT_TARGET_LOG is not set
2795 +# CONFIG_NETFILTER_XT_TARGET_MARK is not set
2796 +# CONFIG_NETFILTER_XT_TARGET_NETMAP is not set
2797 +# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
2798 +# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set
2799 +# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
2800 +# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
2801 +# CONFIG_NETFILTER_XT_TARGET_REDIRECT is not set
2802 +# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set
2803 +# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
2804 +# CONFIG_NETFILTER_XT_TARGET_TEE is not set
2805 +# CONFIG_NETFILTER_XT_TARGET_TPROXY is not set
2806 +# CONFIG_NETFILTER_XT_TARGET_TRACE is not set
2807 +CONFIG_NET_IPGRE_BROADCAST=y
2808 +# CONFIG_NET_IPGRE_DEMUX is not set
2809 +# CONFIG_NET_IPGRE is not set
2810 +# CONFIG_NET_IPIP is not set
2811 +# CONFIG_NET_IP_TUNNEL is not set
2812 +# CONFIG_NET_IPVTI is not set
2813 +# CONFIG_NET_ISA is not set
2814 +# CONFIG_NET_KEY is not set
2815 +# CONFIG_NET_KEY_MIGRATE is not set
2816 +# CONFIG_NETLINK_DIAG is not set
2817 +# CONFIG_NETLINK_MMAP is not set
2818 +# CONFIG_NET_MPLS_GSO is not set
2819 +# CONFIG_NET_PACKET_ENGINE is not set
2820 +CONFIG_NET_PCI=y
2821 +# CONFIG_NET_PCMCIA is not set
2822 +# CONFIG_NET_PKTGEN is not set
2823 +# CONFIG_NET_POCKET is not set
2824 +# CONFIG_NET_POLL_CONTROLLER is not set
2825 +# CONFIG_NETPOLL is not set
2826 +# CONFIG_NET_PTP_CLASSIFY is not set
2827 +# CONFIG_NETROM is not set
2828 +CONFIG_NET_RX_BUSY_POLL=y
2829 +# CONFIG_NET_SB1000 is not set
2830 +# CONFIG_NET_SCH_ATM is not set
2831 +# CONFIG_NET_SCH_CBQ is not set
2832 +# CONFIG_NET_SCH_CHOKE is not set
2833 +# CONFIG_NET_SCH_CODEL is not set
2834 +# CONFIG_NET_SCH_DRR is not set
2835 +# CONFIG_NET_SCH_DSMARK is not set
2836 +CONFIG_NET_SCHED=y
2837 +# CONFIG_NET_SCH_ESFQ is not set
2838 +CONFIG_NET_SCH_ESFQ_NFCT=y
2839 +CONFIG_NET_SCH_FIFO=y
2840 +CONFIG_NET_SCH_FQ_CODEL=y
2841 +# CONFIG_NET_SCH_FQ is not set
2842 +# CONFIG_NET_SCH_GRED is not set
2843 +# CONFIG_NET_SCH_HFSC is not set
2844 +# CONFIG_NET_SCH_HHF is not set
2845 +# CONFIG_NET_SCH_HTB is not set
2846 +# CONFIG_NET_SCH_INGRESS is not set
2847 +# CONFIG_NET_SCH_MQPRIO is not set
2848 +# CONFIG_NET_SCH_MULTIQ is not set
2849 +# CONFIG_NET_SCH_NETEM is not set
2850 +# CONFIG_NET_SCH_PIE is not set
2851 +# CONFIG_NET_SCH_PLUG is not set
2852 +# CONFIG_NET_SCH_PRIO is not set
2853 +# CONFIG_NET_SCH_QFQ is not set
2854 +# CONFIG_NET_SCH_RED is not set
2855 +# CONFIG_NET_SCH_SFB is not set
2856 +# CONFIG_NET_SCH_SFQ is not set
2857 +# CONFIG_NET_SCH_TBF is not set
2858 +# CONFIG_NET_SCH_TEQL is not set
2859 +# CONFIG_NET_TEAM is not set
2860 +# CONFIG_NET_TULIP is not set
2861 +CONFIG_NET_VENDOR_3COM=y
2862 +CONFIG_NET_VENDOR_8390=y
2863 +CONFIG_NET_VENDOR_ADAPTEC=y
2864 +CONFIG_NET_VENDOR_ALTEON=y
2865 +CONFIG_NET_VENDOR_AMD=y
2866 +CONFIG_NET_VENDOR_ARC=y
2867 +CONFIG_NET_VENDOR_ATHEROS=y
2868 +CONFIG_NET_VENDOR_BROADCOM=y
2869 +CONFIG_NET_VENDOR_BROCADE=y
2870 +CONFIG_NET_VENDOR_CHELSIO=y
2871 +CONFIG_NET_VENDOR_CIRRUS=y
2872 +CONFIG_NET_VENDOR_CISCO=y
2873 +CONFIG_NET_VENDOR_DEC=y
2874 +CONFIG_NET_VENDOR_DLINK=y
2875 +CONFIG_NET_VENDOR_EMULEX=y
2876 +CONFIG_NET_VENDOR_EXAR=y
2877 +CONFIG_NET_VENDOR_FARADAY=y
2878 +CONFIG_NET_VENDOR_FREESCALE=y
2879 +CONFIG_NET_VENDOR_FUJITSU=y
2880 +CONFIG_NET_VENDOR_HISILICON=y
2881 +CONFIG_NET_VENDOR_HP=y
2882 +CONFIG_NET_VENDOR_I825XX=y
2883 +CONFIG_NET_VENDOR_IBM=y
2884 +CONFIG_NET_VENDOR_INTEL=y
2885 +CONFIG_NET_VENDOR_MARVELL=y
2886 +CONFIG_NET_VENDOR_MELLANOX=y
2887 +CONFIG_NET_VENDOR_MICREL=y
2888 +CONFIG_NET_VENDOR_MICROCHIP=y
2889 +CONFIG_NET_VENDOR_MYRI=y
2890 +CONFIG_NET_VENDOR_NATSEMI=y
2891 +CONFIG_NET_VENDOR_NVIDIA=y
2892 +CONFIG_NET_VENDOR_OKI=y
2893 +CONFIG_NET_VENDOR_QLOGIC=y
2894 +CONFIG_NET_VENDOR_RDC=y
2895 +CONFIG_NET_VENDOR_REALTEK=y
2896 +CONFIG_NET_VENDOR_SAMSUNG=y
2897 +CONFIG_NET_VENDOR_SEEQ=y
2898 +CONFIG_NET_VENDOR_SILAN=y
2899 +CONFIG_NET_VENDOR_SILICOM=y
2900 +CONFIG_NET_VENDOR_SIS=y
2901 +CONFIG_NET_VENDOR_SMSC=y
2902 +CONFIG_NET_VENDOR_STMICRO=y
2903 +CONFIG_NET_VENDOR_SUN=y
2904 +CONFIG_NET_VENDOR_TEHUTI=y
2905 +CONFIG_NET_VENDOR_TI=y
2906 +CONFIG_NET_VENDOR_TOSHIBA=y
2907 +CONFIG_NET_VENDOR_VIA=y
2908 +# CONFIG_NET_VENDOR_WIZNET is not set
2909 +CONFIG_NET_VENDOR_XILINX=y
2910 +CONFIG_NET_VENDOR_XIRCOM=y
2911 +CONFIG_NETWORK_FILESYSTEMS=y
2912 +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
2913 +# CONFIG_NETWORK_SECMARK is not set
2914 +# CONFIG_NETXEN_NIC is not set
2915 +CONFIG_NET=y
2916 +CONFIG_NEW_LEDS=y
2917 +# CONFIG_NFC_DEVICES is not set
2918 +# CONFIG_NFC is not set
2919 +# CONFIG_NF_CONNTRACK_AMANDA is not set
2920 +# CONFIG_NF_CONNTRACK_EVENTS is not set
2921 +# CONFIG_NF_CONNTRACK_FTP is not set
2922 +# CONFIG_NF_CONNTRACK_H323 is not set
2923 +# CONFIG_NF_CONNTRACK_IPV4 is not set
2924 +# CONFIG_NF_CONNTRACK_IPV6 is not set
2925 +# CONFIG_NF_CONNTRACK_IRC is not set
2926 +# CONFIG_NF_CONNTRACK is not set
2927 +# CONFIG_NF_CONNTRACK_MARK is not set
2928 +# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
2929 +# CONFIG_NF_CONNTRACK_PPTP is not set
2930 +# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
2931 +CONFIG_NF_CONNTRACK_PROCFS=y
2932 +# CONFIG_NF_CONNTRACK_RTSP is not set
2933 +# CONFIG_NF_CONNTRACK_SANE is not set
2934 +# CONFIG_NF_CONNTRACK_SIP is not set
2935 +# CONFIG_NF_CONNTRACK_SNMP is not set
2936 +# CONFIG_NF_CONNTRACK_TFTP is not set
2937 +# CONFIG_NF_CONNTRACK_TIMEOUT is not set
2938 +# CONFIG_NF_CONNTRACK_TIMESTAMP is not set
2939 +# CONFIG_NF_CONNTRACK_ZONES is not set
2940 +# CONFIG_NF_CT_NETLINK is not set
2941 +# CONFIG_NF_CT_NETLINK_TIMEOUT is not set
2942 +# CONFIG_NF_CT_PROTO_DCCP is not set
2943 +# CONFIG_NF_CT_PROTO_GRE is not set
2944 +# CONFIG_NF_CT_PROTO_SCTP is not set
2945 +# CONFIG_NF_CT_PROTO_UDPLITE is not set
2946 +# CONFIG_NF_DEFRAG_IPV4 is not set
2947 +# CONFIG_NF_NAT_AMANDA is not set
2948 +# CONFIG_NF_NAT_FTP is not set
2949 +# CONFIG_NF_NAT_H323 is not set
2950 +CONFIG_NF_NAT_IPV4=m
2951 +# CONFIG_NF_NAT_IPV6 is not set
2952 +# CONFIG_NF_NAT_IRC is not set
2953 +# CONFIG_NF_NAT is not set
2954 +# CONFIG_NF_NAT_NEEDED is not set
2955 +# CONFIG_NF_NAT_PPTP is not set
2956 +# CONFIG_NF_NAT_PROTO_GRE is not set
2957 +# CONFIG_NF_NAT_RTSP is not set
2958 +# CONFIG_NF_NAT_SIP is not set
2959 +# CONFIG_NF_NAT_SNMP_BASIC is not set
2960 +# CONFIG_NF_NAT_TFTP is not set
2961 +# CONFIG_NFS_ACL_SUPPORT is not set
2962 +CONFIG_NFS_COMMON=y
2963 +# CONFIG_NFSD_DEPRECATED is not set
2964 +# CONFIG_NFSD is not set
2965 +# CONFIG_NFSD_V2_ACL is not set
2966 +# CONFIG_NFSD_V3_ACL is not set
2967 +CONFIG_NFSD_V3=y
2968 +# CONFIG_NFSD_V4 is not set
2969 +# CONFIG_NFS_FSCACHE is not set
2970 +# CONFIG_NFS_FS is not set
2971 +# CONFIG_NFS_SWAP is not set
2972 +# CONFIG_NFS_V2 is not set
2973 +# CONFIG_NFS_V3_ACL is not set
2974 +CONFIG_NFS_V3=y
2975 +# CONFIG_NFS_V4_1 is not set
2976 +# CONFIG_NFS_V4 is not set
2977 +# CONFIG_NF_TABLES is not set
2978 +# CONFIG_NFTL is not set
2979 +# CONFIG_N_GSM is not set
2980 +# CONFIG_NI52 is not set
2981 +# CONFIG_NI65 is not set
2982 +# CONFIG_NILFS2_FS is not set
2983 +# CONFIG_NIU is not set
2984 +CONFIG_NLATTR=y
2985 +# CONFIG_NLMON is not set
2986 +# CONFIG_NLM_XLP_BOARD is not set
2987 +# CONFIG_NLM_XLR_BOARD is not set
2988 +# CONFIG_NLS_ASCII is not set
2989 +# CONFIG_NLS_CODEPAGE_1250 is not set
2990 +# CONFIG_NLS_CODEPAGE_1251 is not set
2991 +# CONFIG_NLS_CODEPAGE_437 is not set
2992 +# CONFIG_NLS_CODEPAGE_737 is not set
2993 +# CONFIG_NLS_CODEPAGE_775 is not set
2994 +# CONFIG_NLS_CODEPAGE_850 is not set
2995 +# CONFIG_NLS_CODEPAGE_852 is not set
2996 +# CONFIG_NLS_CODEPAGE_855 is not set
2997 +# CONFIG_NLS_CODEPAGE_857 is not set
2998 +# CONFIG_NLS_CODEPAGE_860 is not set
2999 +# CONFIG_NLS_CODEPAGE_861 is not set
3000 +# CONFIG_NLS_CODEPAGE_862 is not set
3001 +# CONFIG_NLS_CODEPAGE_863 is not set
3002 +# CONFIG_NLS_CODEPAGE_864 is not set
3003 +# CONFIG_NLS_CODEPAGE_865 is not set
3004 +# CONFIG_NLS_CODEPAGE_866 is not set
3005 +# CONFIG_NLS_CODEPAGE_869 is not set
3006 +# CONFIG_NLS_CODEPAGE_874 is not set
3007 +# CONFIG_NLS_CODEPAGE_932 is not set
3008 +# CONFIG_NLS_CODEPAGE_936 is not set
3009 +# CONFIG_NLS_CODEPAGE_949 is not set
3010 +# CONFIG_NLS_CODEPAGE_950 is not set
3011 +CONFIG_NLS_DEFAULT="iso8859-1"
3012 +# CONFIG_NLS is not set
3013 +# CONFIG_NLS_ISO8859_13 is not set
3014 +# CONFIG_NLS_ISO8859_14 is not set
3015 +# CONFIG_NLS_ISO8859_15 is not set
3016 +# CONFIG_NLS_ISO8859_1 is not set
3017 +# CONFIG_NLS_ISO8859_2 is not set
3018 +# CONFIG_NLS_ISO8859_3 is not set
3019 +# CONFIG_NLS_ISO8859_4 is not set
3020 +# CONFIG_NLS_ISO8859_5 is not set
3021 +# CONFIG_NLS_ISO8859_6 is not set
3022 +# CONFIG_NLS_ISO8859_7 is not set
3023 +# CONFIG_NLS_ISO8859_8 is not set
3024 +# CONFIG_NLS_ISO8859_9 is not set
3025 +# CONFIG_NLS_KOI8_R is not set
3026 +# CONFIG_NLS_KOI8_U is not set
3027 +# CONFIG_NLS_MAC_CELTIC is not set
3028 +# CONFIG_NLS_MAC_CENTEURO is not set
3029 +# CONFIG_NLS_MAC_CROATIAN is not set
3030 +# CONFIG_NLS_MAC_CYRILLIC is not set
3031 +# CONFIG_NLS_MAC_GAELIC is not set
3032 +# CONFIG_NLS_MAC_GREEK is not set
3033 +# CONFIG_NLS_MAC_ICELAND is not set
3034 +# CONFIG_NLS_MAC_INUIT is not set
3035 +# CONFIG_NLS_MAC_ROMANIAN is not set
3036 +# CONFIG_NLS_MAC_ROMAN is not set
3037 +# CONFIG_NLS_MAC_TURKISH is not set
3038 +# CONFIG_NLS_UTF8 is not set
3039 +# CONFIG_NO_BOOTMEM is not set
3040 +# CONFIG_NO_HZ_FULL is not set
3041 +# CONFIG_NO_HZ_IDLE is not set
3042 +# CONFIG_NO_HZ is not set
3043 +# CONFIG_NO_IOPORT is not set
3044 +# CONFIG_NOP_USB_XCEIV is not set
3045 +# CONFIG_NORTEL_HERMES is not set
3046 +# CONFIG_NOTIFIER_ERROR_INJECTION is not set
3047 +# CONFIG_NOZOMI is not set
3048 +# CONFIG_NS83820 is not set
3049 +# CONFIG_NTFS_DEBUG is not set
3050 +# CONFIG_NTFS_FS is not set
3051 +# CONFIG_NTFS_RW is not set
3052 +# CONFIG_NTP_PPS is not set
3053 +# CONFIG_NVRAM is not set
3054 +# CONFIG_NV_TCO is not set
3055 +# CONFIG_NXP_STB220 is not set
3056 +# CONFIG_NXP_STB225 is not set
3057 +# CONFIG_OABI_COMPAT is not set
3058 +# CONFIG_OBS600 is not set
3059 +# CONFIG_OC_ETM is not set
3060 +# CONFIG_OCF_BENCH is not set
3061 +# CONFIG_OCF_C7108 is not set
3062 +# CONFIG_OCF_CRYPTOCTEON is not set
3063 +# CONFIG_OCF_EP80579 is not set
3064 +# CONFIG_OCF_HIFNHIPP is not set
3065 +# CONFIG_OCF_HIFN is not set
3066 +# CONFIG_OCF_IXP4XX is not set
3067 +# CONFIG_OCF_KIRKWOOD is not set
3068 +# CONFIG_OCF_OCF is not set
3069 +# CONFIG_OCF_OCFNULL is not set
3070 +# CONFIG_OCFS2_FS is not set
3071 +# CONFIG_OCF_SAFE is not set
3072 +# CONFIG_OCF_TALITOS is not set
3073 +# CONFIG_OCF_UBSEC_SSB is not set
3074 +CONFIG_OF_ADDRESS=y
3075 +CONFIG_OF_EARLY_FLATTREE=y
3076 +CONFIG_OF_FLATTREE=y
3077 +CONFIG_OF_IRQ=y
3078 +CONFIG_OF_MTD=y
3079 +CONFIG_OF_NET=y
3080 +CONFIG_OF_RESERVED_MEM=y
3081 +# CONFIG_OF_SELFTEST is not set
3082 +CONFIG_OF=y
3083 +CONFIG_OLD_SIGACTION=y
3084 +CONFIG_OLD_SIGSUSPEND3=y
3085 +# CONFIG_OMAP2_DSS_DEBUGFS is not set
3086 +# CONFIG_OMAP2_DSS_DEBUG is not set
3087 +# CONFIG_OMAP2_DSS_SDI is not set
3088 +# CONFIG_OMAP_CONTROL_USB is not set
3089 +# CONFIG_OMAP_OCP2SCP is not set
3090 +# CONFIG_OMAP_USB2 is not set
3091 +# CONFIG_OMAP_USB3 is not set
3092 +# CONFIG_OMFS_FS is not set
3093 +# CONFIG_OPENVSWITCH is not set
3094 +# CONFIG_ORION_WATCHDOG is not set
3095 +# CONFIG_OSF_PARTITION is not set
3096 +CONFIG_OVERLAYFS_FS=y
3097 +# CONFIG_P54_COMMON is not set
3098 +# CONFIG_PACKET_DIAG is not set
3099 +CONFIG_PACKET=y
3100 +CONFIG_PAGEFLAGS_EXTENDED=y
3101 +CONFIG_PAGE_OFFSET=0xC0000000
3102 +# CONFIG_PAGE_POISONING is not set
3103 +# CONFIG_PAGE_SIZE_16KB is not set
3104 +# CONFIG_PAGE_SIZE_32KB is not set
3105 +CONFIG_PAGE_SIZE_4KB=y
3106 +# CONFIG_PAGE_SIZE_64KB is not set
3107 +# CONFIG_PAGE_SIZE_8KB is not set
3108 +# CONFIG_PANEL is not set
3109 +# CONFIG_PANIC_ON_OOPS is not set
3110 +CONFIG_PANIC_ON_OOPS_VALUE=0
3111 +CONFIG_PANIC_TIMEOUT=0
3112 +# CONFIG_PANTHERLORD_FF is not set
3113 +# CONFIG_PARPORT_1284 is not set
3114 +# CONFIG_PARPORT_AX88796 is not set
3115 +# CONFIG_PARPORT is not set
3116 +# CONFIG_PARPORT_PC is not set
3117 +CONFIG_PARTITION_ADVANCED=y
3118 +# CONFIG_PATA_ALI is not set
3119 +# CONFIG_PATA_AMD is not set
3120 +# CONFIG_PATA_ARASAN_CF is not set
3121 +# CONFIG_PATA_ARTOP is not set
3122 +# CONFIG_PATA_ATIIXP is not set
3123 +# CONFIG_PATA_ATP867X is not set
3124 +# CONFIG_PATA_CMD640_PCI is not set
3125 +# CONFIG_PATA_CMD64X is not set
3126 +# CONFIG_PATA_CS5520 is not set
3127 +# CONFIG_PATA_CS5530 is not set
3128 +# CONFIG_PATA_CS5535 is not set
3129 +# CONFIG_PATA_CS5536 is not set
3130 +# CONFIG_PATA_CYPRESS is not set
3131 +# CONFIG_PATA_EFAR is not set
3132 +# CONFIG_PATA_HPT366 is not set
3133 +# CONFIG_PATA_HPT37X is not set
3134 +# CONFIG_PATA_HPT3X2N is not set
3135 +# CONFIG_PATA_HPT3X3 is not set
3136 +# CONFIG_PATA_ISAPNP is not set
3137 +# CONFIG_PATA_IT8213 is not set
3138 +# CONFIG_PATA_IT821X is not set
3139 +# CONFIG_PATA_JMICRON is not set
3140 +# CONFIG_PATA_LEGACY is not set
3141 +# CONFIG_PATA_MARVELL is not set
3142 +# CONFIG_PATA_MPIIX is not set
3143 +# CONFIG_PATA_NETCELL is not set
3144 +# CONFIG_PATA_NINJA32 is not set
3145 +# CONFIG_PATA_NS87410 is not set
3146 +# CONFIG_PATA_NS87415 is not set
3147 +# CONFIG_PATA_OF_PLATFORM is not set
3148 +# CONFIG_PATA_OLDPIIX is not set
3149 +# CONFIG_PATA_OPTIDMA is not set
3150 +# CONFIG_PATA_OPTI is not set
3151 +# CONFIG_PATA_PCMCIA is not set
3152 +# CONFIG_PATA_PDC2027X is not set
3153 +# CONFIG_PATA_PDC_OLD is not set
3154 +# CONFIG_PATA_PLATFORM is not set
3155 +# CONFIG_PATA_QDI is not set
3156 +# CONFIG_PATA_RADISYS is not set
3157 +# CONFIG_PATA_RDC is not set
3158 +# CONFIG_PATA_RZ1000 is not set
3159 +# CONFIG_PATA_SC1200 is not set
3160 +# CONFIG_PATA_SCH is not set
3161 +# CONFIG_PATA_SERVERWORKS is not set
3162 +# CONFIG_PATA_SIL680 is not set
3163 +# CONFIG_PATA_SIS is not set
3164 +# CONFIG_PATA_TOSHIBA is not set
3165 +# CONFIG_PATA_TRIFLEX is not set
3166 +# CONFIG_PATA_VIA is not set
3167 +# CONFIG_PATA_WINBOND is not set
3168 +# CONFIG_PATA_WINBOND_VLB is not set
3169 +# CONFIG_PC300TOO is not set
3170 +# CONFIG_PCCARD is not set
3171 +# CONFIG_PCH_GBE is not set
3172 +# CONFIG_PCH_PHUB is not set
3173 +# CONFIG_PCI200SYN is not set
3174 +# CONFIG_PCI_ATMEL is not set
3175 +# CONFIG_PCI_CNB20LE_QUIRK is not set
3176 +# CONFIG_PCI_DEBUG is not set
3177 +# CONFIG_PCI_DISABLE_COMMON_QUIRKS is not set
3178 +# CONFIG_PCIEAER_INJECT is not set
3179 +# CONFIG_PCIEASPM is not set
3180 +# CONFIG_PCIE_ECRC is not set
3181 +# CONFIG_PCIEPORTBUS is not set
3182 +# CONFIG_PCI_HERMES is not set
3183 +# CONFIG_PCI_HOST_GENERIC is not set
3184 +# CONFIG_PCI_IOV is not set
3185 +# CONFIG_PCI is not set
3186 +# CONFIG_PCI_MSI is not set
3187 +# CONFIG_PCI_PASID is not set
3188 +# CONFIG_PCIPCWATCHDOG is not set
3189 +# CONFIG_PCI_PRI is not set
3190 +CONFIG_PCI_QUIRKS=y
3191 +# CONFIG_PCI_REALLOC_ENABLE_AUTO is not set
3192 +# CONFIG_PCI_STUB is not set
3193 +CONFIG_PCI_SYSCALL=y
3194 +# CONFIG_PCMCIA_3C574 is not set
3195 +# CONFIG_PCMCIA_3C589 is not set
3196 +# CONFIG_PCMCIA_AHA152X is not set
3197 +# CONFIG_PCMCIA_ATMEL is not set
3198 +# CONFIG_PCMCIA_AXNET is not set
3199 +# CONFIG_PCMCIA_DEBUG is not set
3200 +# CONFIG_PCMCIA_FDOMAIN is not set
3201 +# CONFIG_PCMCIA_FMVJ18X is not set
3202 +# CONFIG_PCMCIA_HERMES is not set
3203 +# CONFIG_PCMCIA is not set
3204 +# CONFIG_PCMCIA_LOAD_CIS is not set
3205 +# CONFIG_PCMCIA_NINJA_SCSI is not set
3206 +# CONFIG_PCMCIA_NMCLAN is not set
3207 +# CONFIG_PCMCIA_PCNET is not set
3208 +# CONFIG_PCMCIA_QLOGIC is not set
3209 +# CONFIG_PCMCIA_RAYCS is not set
3210 +# CONFIG_PCMCIA_SMC91C92 is not set
3211 +# CONFIG_PCMCIA_SPECTRUM is not set
3212 +# CONFIG_PCMCIA_SYM53C500 is not set
3213 +# CONFIG_PCMCIA_WL3501 is not set
3214 +# CONFIG_PCMCIA_XIRC2PS is not set
3215 +# CONFIG_PCMCIA_XIRCOM is not set
3216 +# CONFIG_PCNET32 is not set
3217 +# CONFIG_PCSPKR_PLATFORM is not set
3218 +# CONFIG_PD6729 is not set
3219 +# CONFIG_PDA_POWER is not set
3220 +# CONFIG_PDC_ADMA is not set
3221 +# CONFIG_PERCPU_TEST is not set
3222 +# CONFIG_PERF_COUNTERS is not set
3223 +# CONFIG_PERF_EVENTS is not set
3224 +CONFIG_PERF_USE_VMALLOC=y
3225 +# CONFIG_PERSISTENT_KEYRINGS is not set
3226 +# CONFIG_PHANTOM is not set
3227 +# CONFIG_PHONE is not set
3228 +# CONFIG_PHONET is not set
3229 +# CONFIG_PHY_EXYNOS_DP_VIDEO is not set
3230 +# CONFIG_PHY_EXYNOS_MIPI_VIDEO is not set
3231 +# CONFIG_PHYLIB is not set
3232 +# CONFIG_PHYS_ADDR_T_64BIT is not set
3233 +# CONFIG_PHY_SAMSUNG_USB2 is not set
3234 +# CONFIG_PID_IN_CONTEXTIDR is not set
3235 +# CONFIG_PID_NS is not set
3236 +CONFIG_PINCONF=y
3237 +# CONFIG_PINCTRL_APQ8064 is not set
3238 +# CONFIG_PINCTRL_BCM281XX is not set
3239 +# CONFIG_PINCTRL_CAPRI is not set
3240 +# CONFIG_PINCTRL_EXYNOS5440 is not set
3241 +# CONFIG_PINCTRL_EXYNOS is not set
3242 +# CONFIG_PINCTRL_IPQ8064 is not set
3243 +# CONFIG_PINCTRL is not set
3244 +# CONFIG_PINCTRL_MSM8X74 is not set
3245 +CONFIG_PINCTRL_SINGLE=y
3246 +CONFIG_PINMUX=y
3247 +# CONFIG_PLAT_SPEAR is not set
3248 +# CONFIG_PLIP is not set
3249 +# CONFIG_PLX_HERMES is not set
3250 +# CONFIG_PM_AUTOSLEEP is not set
3251 +# CONFIG_PMBUS is not set
3252 +# CONFIG_PMC_MSP is not set
3253 +# CONFIG_PMC_YOSEMITE is not set
3254 +# CONFIG_PM_DEVFREQ is not set
3255 +# CONFIG_PMIC_ADP5520 is not set
3256 +# CONFIG_PMIC_DA903X is not set
3257 +# CONFIG_PM is not set
3258 +# CONFIG_PM_RUNTIME is not set
3259 +# CONFIG_PM_WAKELOCKS is not set
3260 +# CONFIG_PNX8550_JBS is not set
3261 +# CONFIG_PNX8550_STB810 is not set
3262 +# CONFIG_POHMELFS is not set
3263 +# CONFIG_POSIX_MQUEUE is not set
3264 +# CONFIG_POWER_AVS is not set
3265 +# CONFIG_POWERCAP is not set
3266 +# CONFIG_POWER_RESET is not set
3267 +# CONFIG_POWER_RESET_RESTART is not set
3268 +# CONFIG_POWER_SUPPLY_DEBUG is not set
3269 +# CONFIG_POWER_SUPPLY is not set
3270 +# CONFIG_POWERTV is not set
3271 +# CONFIG_PPC_16K_PAGES is not set
3272 +# CONFIG_PPC_256K_PAGES is not set
3273 +CONFIG_PPC_4K_PAGES=y
3274 +# CONFIG_PPC4xx_GPIO is not set
3275 +# CONFIG_PPC_64K_PAGES is not set
3276 +# CONFIG_PPC_DISABLE_WERROR is not set
3277 +# CONFIG_PPC_EMULATED_STATS is not set
3278 +# CONFIG_PPC_EPAPR_HV_BYTECHAN is not set
3279 +# CONFIG_PPP_ASYNC is not set
3280 +# CONFIG_PPP_BSDCOMP is not set
3281 +# CONFIG_PPP_DEFLATE is not set
3282 +# CONFIG_PPP_FILTER is not set
3283 +CONFIG_PPP_FILTER=y
3284 +# CONFIG_PPP is not set
3285 +# CONFIG_PPP_MPPE is not set
3286 +# CONFIG_PPP_MULTILINK is not set
3287 +CONFIG_PPP_MULTILINK=y
3288 +# CONFIG_PPPOATM is not set
3289 +# CONFIG_PPPOE is not set
3290 +# CONFIG_PPPOL2TP is not set
3291 +# CONFIG_PPP_SYNC_TTY is not set
3292 +# CONFIG_PPS_CLIENT_GPIO is not set
3293 +# CONFIG_PPS_CLIENT_KTIMER is not set
3294 +# CONFIG_PPS_CLIENT_LDISC is not set
3295 +# CONFIG_PPS_CLIENT_PARPORT is not set
3296 +# CONFIG_PPS_DEBUG is not set
3297 +# CONFIG_PPS is not set
3298 +# CONFIG_PPTP is not set
3299 +# CONFIG_PREEMPT is not set
3300 +CONFIG_PREEMPT_NONE=y
3301 +# CONFIG_PREEMPT_RCU is not set
3302 +# CONFIG_PREEMPT_VOLUNTARY is not set
3303 +CONFIG_PREVENT_FIRMWARE_BUILD=y
3304 +# CONFIG_PRINTK_TIME is not set
3305 +CONFIG_PRINTK=y
3306 +CONFIG_PRINT_STACK_DEPTH=64
3307 +# CONFIG_PRISM2_USB is not set
3308 +# CONFIG_PRISM54 is not set
3309 +# CONFIG_PROBE_INITRD_HEADER is not set
3310 +# CONFIG_PROC_DEVICETREE is not set
3311 +CONFIG_PROC_FS=y
3312 +# CONFIG_PROC_KCORE is not set
3313 +# CONFIG_PROC_PAGE_MONITOR is not set
3314 +CONFIG_PROC_STRIPPED=y
3315 +CONFIG_PROC_SYSCTL=y
3316 +# CONFIG_PROFILE_ALL_BRANCHES is not set
3317 +# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
3318 +# CONFIG_PROFILING is not set
3319 +# CONFIG_PROVE_LOCKING is not set
3320 +# CONFIG_PROVE_RCU_DELAY is not set
3321 +# CONFIG_PROVE_RCU is not set
3322 +# CONFIG_PSB6970_PHY is not set
3323 +# CONFIG_PSTORE is not set
3324 +# CONFIG_PTP_1588_CLOCK is not set
3325 +# CONFIG_PTP_1588_CLOCK_IXP46X is not set
3326 +# CONFIG_PTP_1588_CLOCK_PCH is not set
3327 +# CONFIG_PWM is not set
3328 +# CONFIG_PWM_PCA9685 is not set
3329 +# CONFIG_QLA3XXX is not set
3330 +# CONFIG_QLCNIC is not set
3331 +# CONFIG_QLGE is not set
3332 +# CONFIG_QNX4FS_FS is not set
3333 +# CONFIG_QNX6FS_FS is not set
3334 +# CONFIG_QSEMI_PHY is not set
3335 +# CONFIG_QUOTACTL is not set
3336 +# CONFIG_QUOTA_DEBUG is not set
3337 +# CONFIG_QUOTA is not set
3338 +# CONFIG_R3964 is not set
3339 +# CONFIG_R6040 is not set
3340 +# CONFIG_R8169 is not set
3341 +# CONFIG_R8187SE is not set
3342 +# CONFIG_R8188EU is not set
3343 +# CONFIG_R8712U is not set
3344 +# CONFIG_RADIO_ADAPTERS is not set
3345 +# CONFIG_RADIO_AZTECH is not set
3346 +# CONFIG_RADIO_CADET is not set
3347 +# CONFIG_RADIO_GEMTEK is not set
3348 +# CONFIG_RADIO_MAXIRADIO is not set
3349 +# CONFIG_RADIO_RTRACK2 is not set
3350 +# CONFIG_RADIO_RTRACK is not set
3351 +# CONFIG_RADIO_SF16FMI is not set
3352 +# CONFIG_RADIO_SF16FMR2 is not set
3353 +# CONFIG_RADIO_TERRATEC is not set
3354 +# CONFIG_RADIO_TRUST is not set
3355 +# CONFIG_RADIO_TYPHOON is not set
3356 +# CONFIG_RADIO_ZOLTRIX is not set
3357 +# CONFIG_RAID_ATTRS is not set
3358 +# CONFIG_RALINK is not set
3359 +# CONFIG_RAMOOPS is not set
3360 +# CONFIG_RANDOM32_SELFTEST is not set
3361 +# CONFIG_RAPIDIO is not set
3362 +# CONFIG_RAR_REGISTER is not set
3363 +# CONFIG_RAW_DRIVER is not set
3364 +# CONFIG_RBTREE_TEST is not set
3365 +# CONFIG_RC_CORE is not set
3366 +# CONFIG_RC_MAP is not set
3367 +# CONFIG_RCU_CPU_STALL_INFO is not set
3368 +CONFIG_RCU_CPU_STALL_TIMEOUT=60
3369 +CONFIG_RCU_FANOUT=32
3370 +# CONFIG_RCU_FANOUT_EXACT is not set
3371 +CONFIG_RCU_FANOUT_LEAF=16
3372 +# CONFIG_RCU_FAST_NO_HZ is not set
3373 +# CONFIG_RCU_NOCB_CPU is not set
3374 +# CONFIG_RCU_STALL_COMMON is not set
3375 +# CONFIG_RCU_TORTURE_TEST is not set
3376 +# CONFIG_RCU_TRACE is not set
3377 +# CONFIG_RCU_USER_QS is not set
3378 +# CONFIG_RD_BZIP2 is not set
3379 +# CONFIG_RD_GZIP is not set
3380 +# CONFIG_RD_LZ4 is not set
3381 +# CONFIG_RD_LZMA is not set
3382 +# CONFIG_RD_LZO is not set
3383 +# CONFIG_RDS is not set
3384 +# CONFIG_RD_XZ is not set
3385 +# CONFIG_READABLE_ASM is not set
3386 +# CONFIG_REALTEK_PHY is not set
3387 +# CONFIG_REDWOOD is not set
3388 +# CONFIG_REGMAP_I2C is not set
3389 +# CONFIG_REGMAP is not set
3390 +# CONFIG_REGMAP_SPI is not set
3391 +# CONFIG_REGULATOR_ACT8865 is not set
3392 +# CONFIG_REGULATOR_AD5398 is not set
3393 +# CONFIG_REGULATOR_BQ24022 is not set
3394 +# CONFIG_REGULATOR_DA9210 is not set
3395 +# CONFIG_REGULATOR_FAN53555 is not set
3396 +# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
3397 +# CONFIG_REGULATOR_GPIO is not set
3398 +# CONFIG_REGULATOR_ISL6271A is not set
3399 +# CONFIG_REGULATOR is not set
3400 +# CONFIG_REGULATOR_LP3971 is not set
3401 +# CONFIG_REGULATOR_LP3972 is not set
3402 +# CONFIG_REGULATOR_LP872X is not set
3403 +# CONFIG_REGULATOR_LP8755 is not set
3404 +# CONFIG_REGULATOR_MAX1586 is not set
3405 +# CONFIG_REGULATOR_MAX8649 is not set
3406 +# CONFIG_REGULATOR_MAX8660 is not set
3407 +# CONFIG_REGULATOR_MAX8952 is not set
3408 +# CONFIG_REGULATOR_MAX8973 is not set
3409 +# CONFIG_REGULATOR_PFUZE100 is not set
3410 +# CONFIG_REGULATOR_TI_ABB is not set
3411 +# CONFIG_REGULATOR_TPS51632 is not set
3412 +# CONFIG_REGULATOR_TPS62360 is not set
3413 +# CONFIG_REGULATOR_TPS65023 is not set
3414 +# CONFIG_REGULATOR_TPS6507X is not set
3415 +# CONFIG_REGULATOR_TPS6524X is not set
3416 +# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
3417 +# CONFIG_REISERFS_CHECK is not set
3418 +# CONFIG_REISERFS_FS is not set
3419 +# CONFIG_REISERFS_FS_POSIX_ACL is not set
3420 +# CONFIG_REISERFS_FS_SECURITY is not set
3421 +# CONFIG_REISERFS_FS_XATTR is not set
3422 +# CONFIG_REISERFS_PROC_INFO is not set
3423 +# CONFIG_RELAY is not set
3424 +# CONFIG_RESET_CONTROLLER is not set
3425 +# CONFIG_RFD_FTL is not set
3426 +# CONFIG_RFKILL_INPUT is not set
3427 +# CONFIG_RFKILL is not set
3428 +# CONFIG_RING_BUFFER_BENCHMARK is not set
3429 +# CONFIG_RING_BUFFER_STARTUP_TEST is not set
3430 +# CONFIG_ROMFS_FS is not set
3431 +# CONFIG_ROSE is not set
3432 +# CONFIG_RPCSEC_GSS_KRB5 is not set
3433 +# CONFIG_RT2X00 is not set
3434 +# CONFIG_RTC_CLASS is not set
3435 +# CONFIG_RTC_DEBUG is not set
3436 +# CONFIG_RTC_DRV_AU1XXX is not set
3437 +# CONFIG_RTC_DRV_BQ32K is not set
3438 +# CONFIG_RTC_DRV_BQ4802 is not set
3439 +CONFIG_RTC_DRV_CMOS=y
3440 +# CONFIG_RTC_DRV_DS1286 is not set
3441 +# CONFIG_RTC_DRV_DS1305 is not set
3442 +# CONFIG_RTC_DRV_DS1307 is not set
3443 +# CONFIG_RTC_DRV_DS1343 is not set
3444 +# CONFIG_RTC_DRV_DS1347 is not set
3445 +# CONFIG_RTC_DRV_DS1374 is not set
3446 +# CONFIG_RTC_DRV_DS1390 is not set
3447 +# CONFIG_RTC_DRV_DS1511 is not set
3448 +# CONFIG_RTC_DRV_DS1553 is not set
3449 +# CONFIG_RTC_DRV_DS1672 is not set
3450 +# CONFIG_RTC_DRV_DS1742 is not set
3451 +# CONFIG_RTC_DRV_DS2404 is not set
3452 +# CONFIG_RTC_DRV_DS3232 is not set
3453 +# CONFIG_RTC_DRV_DS3234 is not set
3454 +# CONFIG_RTC_DRV_EM3027 is not set
3455 +# CONFIG_RTC_DRV_EP93XX is not set
3456 +# CONFIG_RTC_DRV_FM3130 is not set
3457 +# CONFIG_RTC_DRV_GENERIC is not set
3458 +# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set
3459 +# CONFIG_RTC_DRV_HYM8563 is not set
3460 +# CONFIG_RTC_DRV_ISL12022 is not set
3461 +# CONFIG_RTC_DRV_ISL12057 is not set
3462 +# CONFIG_RTC_DRV_ISL1208 is not set
3463 +# CONFIG_RTC_DRV_M41T80 is not set
3464 +# CONFIG_RTC_DRV_M41T93 is not set
3465 +# CONFIG_RTC_DRV_M41T94 is not set
3466 +# CONFIG_RTC_DRV_M48T35 is not set
3467 +# CONFIG_RTC_DRV_M48T59 is not set
3468 +# CONFIG_RTC_DRV_M48T86 is not set
3469 +# CONFIG_RTC_DRV_MAX6900 is not set
3470 +# CONFIG_RTC_DRV_MAX6902 is not set
3471 +# CONFIG_RTC_DRV_MCP795 is not set
3472 +# CONFIG_RTC_DRV_MOXART is not set
3473 +# CONFIG_RTC_DRV_MPC5121 is not set
3474 +# CONFIG_RTC_DRV_MSM6242 is not set
3475 +# CONFIG_RTC_DRV_OMAP is not set
3476 +# CONFIG_RTC_DRV_PCF2123 is not set
3477 +# CONFIG_RTC_DRV_PCF2127 is not set
3478 +# CONFIG_RTC_DRV_PCF8523 is not set
3479 +# CONFIG_RTC_DRV_PCF8563 is not set
3480 +# CONFIG_RTC_DRV_PCF8583 is not set
3481 +# CONFIG_RTC_DRV_PL030 is not set
3482 +# CONFIG_RTC_DRV_PL031 is not set
3483 +# CONFIG_RTC_DRV_PS3 is not set
3484 +# CONFIG_RTC_DRV_PT7C4338 is not set
3485 +# CONFIG_RTC_DRV_R9701 is not set
3486 +# CONFIG_RTC_DRV_RP5C01 is not set
3487 +# CONFIG_RTC_DRV_RS5C348 is not set
3488 +# CONFIG_RTC_DRV_RS5C372 is not set
3489 +# CONFIG_RTC_DRV_RTC7301 is not set
3490 +# CONFIG_RTC_DRV_RV3029C2 is not set
3491 +# CONFIG_RTC_DRV_RX4581 is not set
3492 +# CONFIG_RTC_DRV_RX8025 is not set
3493 +# CONFIG_RTC_DRV_RX8581 is not set
3494 +# CONFIG_RTC_DRV_S35390A is not set
3495 +# CONFIG_RTC_DRV_SNVS is not set
3496 +# CONFIG_RTC_DRV_STK17TA8 is not set
3497 +# CONFIG_RTC_DRV_TEST is not set
3498 +# CONFIG_RTC_DRV_V3020 is not set
3499 +# CONFIG_RTC_DRV_X1205 is not set
3500 +# CONFIG_RTC_DRV_XGENE is not set
3501 +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
3502 +CONFIG_RTC_HCTOSYS=y
3503 +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
3504 +CONFIG_RTC_INTF_DEV=y
3505 +CONFIG_RTC_INTF_PROC=y
3506 +CONFIG_RTC_INTF_SYSFS=y
3507 +CONFIG_RTC_LIB=y
3508 +CONFIG_RTC_SYSTOHC=y
3509 +# CONFIG_RTL8180 is not set
3510 +# CONFIG_RTL8187 is not set
3511 +# CONFIG_RTL8192E is not set
3512 +# CONFIG_RTL8192U is not set
3513 +# CONFIG_RTL8306_PHY is not set
3514 +# CONFIG_RTL8366RB_PHY is not set
3515 +# CONFIG_RTL8366_SMI_DEBUG_FS is not set
3516 +# CONFIG_RTL8366_SMI is not set
3517 +# CONFIG_RTL8366S_PHY is not set
3518 +# CONFIG_RTL8367B_PHY is not set
3519 +# CONFIG_RTL8367_PHY is not set
3520 +# CONFIG_RTL_CARDS is not set
3521 +# CONFIG_RTLLIB is not set
3522 +CONFIG_RT_MUTEXES=y
3523 +# CONFIG_RT_MUTEX_TESTER is not set
3524 +# CONFIG_RTS5139 is not set
3525 +# CONFIG_RTS5208 is not set
3526 +# CONFIG_RTS_PSTOR is not set
3527 +# CONFIG_RUNTIME_DEBUG is not set
3528 +CONFIG_RWSEM_GENERIC_SPINLOCK=y
3529 +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
3530 +# CONFIG_S2IO is not set
3531 +# CONFIG_SAMPLES is not set
3532 +# CONFIG_SAMSUNG_LAPTOP is not set
3533 +# CONFIG_SAMSUNG_USB2PHY is not set
3534 +# CONFIG_SAMSUNG_USB3PHY is not set
3535 +# CONFIG_SATA_ACARD_AHCI is not set
3536 +# CONFIG_SATA_AHCI is not set
3537 +# CONFIG_SATA_AHCI_PLATFORM is not set
3538 +# CONFIG_SATA_DWC is not set
3539 +# CONFIG_SATA_FSL is not set
3540 +# CONFIG_SATA_HIGHBANK is not set
3541 +# CONFIG_SATA_INIC162X is not set
3542 +# CONFIG_SATA_MV is not set
3543 +# CONFIG_SATA_NV is not set
3544 +# CONFIG_SATA_PMP is not set
3545 +# CONFIG_SATA_PROMISE is not set
3546 +# CONFIG_SATA_QSTOR is not set
3547 +# CONFIG_SATA_RCAR is not set
3548 +# CONFIG_SATA_SIL24 is not set
3549 +# CONFIG_SATA_SIL is not set
3550 +# CONFIG_SATA_SIS is not set
3551 +# CONFIG_SATA_SVW is not set
3552 +# CONFIG_SATA_SX4 is not set
3553 +# CONFIG_SATA_ULI is not set
3554 +# CONFIG_SATA_VIA is not set
3555 +# CONFIG_SATA_VITESSE is not set
3556 +# CONFIG_SBC_FITPC2_WATCHDOG is not set
3557 +# CONFIG_SBE_2T3E3 is not set
3558 +# CONFIG_SBYPASS is not set
3559 +# CONFIG_SC92031 is not set
3560 +# CONFIG_SCA3000 is not set
3561 +# CONFIG_SCC is not set
3562 +# CONFIG_SCHED_AUTOGROUP is not set
3563 +# CONFIG_SCHED_DEBUG is not set
3564 +CONFIG_SCHED_HRTICK=y
3565 +# CONFIG_SCHED_MC is not set
3566 +CONFIG_SCHED_OMIT_FRAME_POINTER=y
3567 +# CONFIG_SCHED_SMT is not set
3568 +# CONFIG_SCHEDSTATS is not set
3569 +# CONFIG_SCHED_TRACER is not set
3570 +# CONFIG_SCSI_3W_9XXX is not set
3571 +# CONFIG_SCSI_3W_SAS is not set
3572 +# CONFIG_SCSI_7000FASST is not set
3573 +# CONFIG_SCSI_AACRAID is not set
3574 +# CONFIG_SCSI_ACARD is not set
3575 +# CONFIG_SCSI_ADVANSYS is not set
3576 +# CONFIG_SCSI_AHA152X is not set
3577 +# CONFIG_SCSI_AHA1542 is not set
3578 +# CONFIG_SCSI_AIC79XX is not set
3579 +# CONFIG_SCSI_AIC7XXX is not set
3580 +# CONFIG_SCSI_AIC7XXX_OLD is not set
3581 +# CONFIG_SCSI_AIC94XX is not set
3582 +# CONFIG_SCSI_ARCMSR is not set
3583 +# CONFIG_SCSI_BFA_FC is not set
3584 +# CONFIG_SCSI_BNX2_ISCSI is not set
3585 +# CONFIG_SCSI_BNX2X_FCOE is not set
3586 +# CONFIG_SCSI_BUSLOGIC is not set
3587 +# CONFIG_SCSI_CHELSIO_FCOE is not set
3588 +# CONFIG_SCSI_CONSTANTS is not set
3589 +# CONFIG_SCSI_CXGB3_ISCSI is not set
3590 +# CONFIG_SCSI_CXGB4_ISCSI is not set
3591 +# CONFIG_SCSI_DC390T is not set
3592 +# CONFIG_SCSI_DC395x is not set
3593 +# CONFIG_SCSI_DEBUG is not set
3594 +# CONFIG_SCSI_DH is not set
3595 +CONFIG_SCSI_DMA=y
3596 +# CONFIG_SCSI_DMX3191D is not set
3597 +# CONFIG_SCSI_DPT_I2O is not set
3598 +# CONFIG_SCSI_DTC3280 is not set
3599 +# CONFIG_SCSI_EATA is not set
3600 +# CONFIG_SCSI_ESAS2R is not set
3601 +# CONFIG_SCSI_FC_ATTRS is not set
3602 +# CONFIG_SCSI_FUTURE_DOMAIN is not set
3603 +# CONFIG_SCSI_GDTH is not set
3604 +# CONFIG_SCSI_GENERIC_NCR5380 is not set
3605 +# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
3606 +# CONFIG_SCSI_HPSA is not set
3607 +# CONFIG_SCSI_HPTIOP is not set
3608 +# CONFIG_SCSI_IN2000 is not set
3609 +# CONFIG_SCSI_INIA100 is not set
3610 +# CONFIG_SCSI_INITIO is not set
3611 +# CONFIG_SCSI_IPR is not set
3612 +# CONFIG_SCSI_IPS is not set
3613 +# CONFIG_SCSI_ISCI is not set
3614 +# CONFIG_SCSI_ISCSI_ATTRS is not set
3615 +# CONFIG_SCSI is not set
3616 +# CONFIG_SCSI_LOGGING is not set
3617 +# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set
3618 +CONFIG_SCSI_LOWLEVEL=y
3619 +# CONFIG_SCSI_LPFC is not set
3620 +CONFIG_SCSI_MOD=y
3621 +# CONFIG_SCSI_MPT2SAS is not set
3622 +# CONFIG_SCSI_MPT3SAS is not set
3623 +CONFIG_SCSI_MULTI_LUN=y
3624 +# CONFIG_SCSI_MVSAS_DEBUG is not set
3625 +# CONFIG_SCSI_MVSAS is not set
3626 +# CONFIG_SCSI_MVUMI is not set
3627 +# CONFIG_SCSI_NCR53C406A is not set
3628 +# CONFIG_SCSI_NETLINK is not set
3629 +# CONFIG_SCSI_NSP32 is not set
3630 +# CONFIG_SCSI_OSD_INITIATOR is not set
3631 +# CONFIG_SCSI_PAS16 is not set
3632 +# CONFIG_SCSI_PM8001 is not set
3633 +# CONFIG_SCSI_PMCRAID is not set
3634 +CONFIG_SCSI_PROC_FS=y
3635 +# CONFIG_SCSI_QLA_FC is not set
3636 +# CONFIG_SCSI_QLA_ISCSI is not set
3637 +# CONFIG_SCSI_QLOGIC_1280 is not set
3638 +# CONFIG_SCSI_QLOGIC_FAS is not set
3639 +# CONFIG_SCSI_SAS_ATTRS is not set
3640 +# CONFIG_SCSI_SAS_LIBSAS is not set
3641 +# CONFIG_SCSI_SCAN_ASYNC is not set
3642 +# CONFIG_SCSI_SCSI_LPFC is not set
3643 +# CONFIG_SCSI_SPI_ATTRS is not set
3644 +# CONFIG_SCSI_SRP_ATTRS is not set
3645 +# CONFIG_SCSI_SRP is not set
3646 +# CONFIG_SCSI_STEX is not set
3647 +# CONFIG_SCSI_SYM53C416 is not set
3648 +# CONFIG_SCSI_SYM53C8XX_2 is not set
3649 +# CONFIG_SCSI_T128 is not set
3650 +# CONFIG_SCSI_TGT is not set
3651 +# CONFIG_SCSI_U14_34F is not set
3652 +# CONFIG_SCSI_UFSHCD is not set
3653 +# CONFIG_SCSI_ULTRASTOR is not set
3654 +CONFIG_SCSI_WAIT_SCAN=m
3655 +# CONFIG_SDIO_UART is not set
3656 +# CONFIG_SECCOMP is not set
3657 +# CONFIG_SECURITY_DMESG_RESTRICT is not set
3658 +# CONFIG_SECURITYFS is not set
3659 +# CONFIG_SECURITY is not set
3660 +# CONFIG_SEEQ8005 is not set
3661 +CONFIG_SELECT_MEMORY_MODEL=y
3662 +# CONFIG_SENSORS_ABITUGURU3 is not set
3663 +# CONFIG_SENSORS_ABITUGURU is not set
3664 +# CONFIG_SENSORS_ACPI_POWER is not set
3665 +# CONFIG_SENSORS_AD7314 is not set
3666 +# CONFIG_SENSORS_AD7414 is not set
3667 +# CONFIG_SENSORS_AD7418 is not set
3668 +# CONFIG_SENSORS_ADC128D818 is not set
3669 +# CONFIG_SENSORS_ADCXX is not set
3670 +# CONFIG_SENSORS_ADM1021 is not set
3671 +# CONFIG_SENSORS_ADM1025 is not set
3672 +# CONFIG_SENSORS_ADM1026 is not set
3673 +# CONFIG_SENSORS_ADM1029 is not set
3674 +# CONFIG_SENSORS_ADM1031 is not set
3675 +# CONFIG_SENSORS_ADM9240 is not set
3676 +# CONFIG_SENSORS_ADS1015 is not set
3677 +# CONFIG_SENSORS_ADS7828 is not set
3678 +# CONFIG_SENSORS_ADS7871 is not set
3679 +# CONFIG_SENSORS_ADT7310 is not set
3680 +# CONFIG_SENSORS_ADT7410 is not set
3681 +# CONFIG_SENSORS_ADT7411 is not set
3682 +# CONFIG_SENSORS_ADT7462 is not set
3683 +# CONFIG_SENSORS_ADT7470 is not set
3684 +# CONFIG_SENSORS_ADT7475 is not set
3685 +# CONFIG_SENSORS_AMC6821 is not set
3686 +# CONFIG_SENSORS_APDS990X is not set
3687 +# CONFIG_SENSORS_APPLESMC is not set
3688 +# CONFIG_SENSORS_ASB100 is not set
3689 +# CONFIG_SENSORS_ASC7621 is not set
3690 +# CONFIG_SENSORS_ATK0110 is not set
3691 +# CONFIG_SENSORS_ATXP1 is not set
3692 +# CONFIG_SENSORS_BH1770 is not set
3693 +# CONFIG_SENSORS_BH1780 is not set
3694 +# CONFIG_SENSORS_CORETEMP is not set
3695 +# CONFIG_SENSORS_DME1737 is not set
3696 +# CONFIG_SENSORS_DS1621 is not set
3697 +# CONFIG_SENSORS_DS620 is not set
3698 +# CONFIG_SENSORS_EMC1403 is not set
3699 +# CONFIG_SENSORS_EMC2103 is not set
3700 +# CONFIG_SENSORS_EMC6W201 is not set
3701 +# CONFIG_SENSORS_F71805F is not set
3702 +# CONFIG_SENSORS_F71882FG is not set
3703 +# CONFIG_SENSORS_F75375S is not set
3704 +# CONFIG_SENSORS_FAM15H_POWER is not set
3705 +# CONFIG_SENSORS_FSCHMD is not set
3706 +# CONFIG_SENSORS_G760A is not set
3707 +# CONFIG_SENSORS_G762 is not set
3708 +# CONFIG_SENSORS_GL518SM is not set
3709 +# CONFIG_SENSORS_GL520SM is not set
3710 +# CONFIG_SENSORS_GPIO_FAN is not set
3711 +# CONFIG_SENSORS_GSC is not set
3712 +# CONFIG_SENSORS_HDAPS is not set
3713 +# CONFIG_SENSORS_HIH6130 is not set
3714 +# CONFIG_SENSORS_HMC5843 is not set
3715 +# CONFIG_SENSORS_HTU21 is not set
3716 +# CONFIG_SENSORS_I5K_AMB is not set
3717 +# CONFIG_SENSORS_IIO_HWMON is not set
3718 +# CONFIG_SENSORS_INA209 is not set
3719 +# CONFIG_SENSORS_INA2XX is not set
3720 +# CONFIG_SENSORS_ISL29018 is not set
3721 +# CONFIG_SENSORS_ISL29028 is not set
3722 +# CONFIG_SENSORS_IT87 is not set
3723 +# CONFIG_SENSORS_JC42 is not set
3724 +# CONFIG_SENSORS_K10TEMP is not set
3725 +# CONFIG_SENSORS_K8TEMP is not set
3726 +# CONFIG_SENSORS_LINEAGE is not set
3727 +# CONFIG_SENSORS_LIS3_I2C is not set
3728 +# CONFIG_SENSORS_LIS3LV02D is not set
3729 +# CONFIG_SENSORS_LIS3_SPI is not set
3730 +# CONFIG_SENSORS_LM63 is not set
3731 +# CONFIG_SENSORS_LM70 is not set
3732 +# CONFIG_SENSORS_LM73 is not set
3733 +# CONFIG_SENSORS_LM75 is not set
3734 +# CONFIG_SENSORS_LM77 is not set
3735 +# CONFIG_SENSORS_LM78 is not set
3736 +# CONFIG_SENSORS_LM80 is not set
3737 +# CONFIG_SENSORS_LM83 is not set
3738 +# CONFIG_SENSORS_LM85 is not set
3739 +# CONFIG_SENSORS_LM87 is not set
3740 +# CONFIG_SENSORS_LM90 is not set
3741 +# CONFIG_SENSORS_LM92 is not set
3742 +# CONFIG_SENSORS_LM93 is not set
3743 +# CONFIG_SENSORS_LM95234 is not set
3744 +# CONFIG_SENSORS_LM95241 is not set
3745 +# CONFIG_SENSORS_LM95245 is not set
3746 +# CONFIG_SENSORS_LTC2945 is not set
3747 +# CONFIG_SENSORS_LTC4151 is not set
3748 +# CONFIG_SENSORS_LTC4215 is not set
3749 +# CONFIG_SENSORS_LTC4222 is not set
3750 +# CONFIG_SENSORS_LTC4245 is not set
3751 +# CONFIG_SENSORS_LTC4260 is not set
3752 +# CONFIG_SENSORS_LTC4261 is not set
3753 +# CONFIG_SENSORS_MAX1111 is not set
3754 +# CONFIG_SENSORS_MAX16065 is not set
3755 +# CONFIG_SENSORS_MAX1619 is not set
3756 +# CONFIG_SENSORS_MAX1668 is not set
3757 +# CONFIG_SENSORS_MAX197 is not set
3758 +# CONFIG_SENSORS_MAX6639 is not set
3759 +# CONFIG_SENSORS_MAX6642 is not set
3760 +# CONFIG_SENSORS_MAX6650 is not set
3761 +# CONFIG_SENSORS_MAX6697 is not set
3762 +# CONFIG_SENSORS_MCP3021 is not set
3763 +# CONFIG_SENSORS_NCT6683 is not set
3764 +# CONFIG_SENSORS_NCT6775 is not set
3765 +# CONFIG_SENSORS_NTC_THERMISTOR is not set
3766 +# CONFIG_SENSORS_PC87360 is not set
3767 +# CONFIG_SENSORS_PC87427 is not set
3768 +# CONFIG_SENSORS_PCF8591 is not set
3769 +# CONFIG_SENSORS_SCH5627 is not set
3770 +# CONFIG_SENSORS_SCH5636 is not set
3771 +# CONFIG_SENSORS_SCH56XX_COMMON is not set
3772 +# CONFIG_SENSORS_SHT15 is not set
3773 +# CONFIG_SENSORS_SHT21 is not set
3774 +# CONFIG_SENSORS_SHTC1 is not set
3775 +# CONFIG_SENSORS_SIS5595 is not set
3776 +# CONFIG_SENSORS_SMM665 is not set
3777 +# CONFIG_SENSORS_SMSC47B397 is not set
3778 +# CONFIG_SENSORS_SMSC47M192 is not set
3779 +# CONFIG_SENSORS_SMSC47M1 is not set
3780 +# CONFIG_SENSORS_THMC50 is not set
3781 +# CONFIG_SENSORS_TMP102 is not set
3782 +# CONFIG_SENSORS_TMP401 is not set
3783 +# CONFIG_SENSORS_TMP421 is not set
3784 +# CONFIG_SENSORS_TSL2550 is not set
3785 +# CONFIG_SENSORS_TSL2563 is not set
3786 +# CONFIG_SENSORS_VIA686A is not set
3787 +# CONFIG_SENSORS_VIA_CPUTEMP is not set
3788 +# CONFIG_SENSORS_VT1211 is not set
3789 +# CONFIG_SENSORS_VT8231 is not set
3790 +# CONFIG_SENSORS_W83627EHF is not set
3791 +# CONFIG_SENSORS_W83627HF is not set
3792 +# CONFIG_SENSORS_W83781D is not set
3793 +# CONFIG_SENSORS_W83791D is not set
3794 +# CONFIG_SENSORS_W83792D is not set
3795 +# CONFIG_SENSORS_W83793 is not set
3796 +# CONFIG_SENSORS_W83795 is not set
3797 +# CONFIG_SENSORS_W83L785TS is not set
3798 +# CONFIG_SENSORS_W83L786NG is not set
3799 +# CONFIG_SERIAL_8250_ACCENT is not set
3800 +# CONFIG_SERIAL_8250_BOCA is not set
3801 +CONFIG_SERIAL_8250_CONSOLE=y
3802 +# CONFIG_SERIAL_8250_CS is not set
3803 +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
3804 +# CONFIG_SERIAL_8250_DMA is not set
3805 +CONFIG_SERIAL_8250_DMA=y
3806 +# CONFIG_SERIAL_8250_DW is not set
3807 +# CONFIG_SERIAL_8250_EM is not set
3808 +# CONFIG_SERIAL_8250_EXAR_ST16C554 is not set
3809 +# CONFIG_SERIAL_8250_EXTENDED is not set
3810 +# CONFIG_SERIAL_8250_FOURPORT is not set
3811 +# CONFIG_SERIAL_8250_HUB6 is not set
3812 +# CONFIG_SERIAL_8250_MANY_PORTS is not set
3813 +CONFIG_SERIAL_8250_NR_UARTS=2
3814 +# CONFIG_SERIAL_8250_PCI is not set
3815 +# CONFIG_SERIAL_8250_RSA is not set
3816 +CONFIG_SERIAL_8250_RUNTIME_UARTS=2
3817 +CONFIG_SERIAL_8250=y
3818 +# CONFIG_SERIAL_ALTERA_JTAGUART is not set
3819 +# CONFIG_SERIAL_ALTERA_UART is not set
3820 +# CONFIG_SERIAL_ARC is not set
3821 +CONFIG_SERIAL_CORE_CONSOLE=y
3822 +CONFIG_SERIAL_CORE=y
3823 +# CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST is not set
3824 +CONFIG_SERIAL_EARLYCON=y
3825 +# CONFIG_SERIAL_FSL_LPUART is not set
3826 +# CONFIG_SERIAL_GRLIB_GAISLER_APBUART is not set
3827 +# CONFIG_SERIAL_IFX6X60 is not set
3828 +# CONFIG_SERIAL_JSM is not set
3829 +# CONFIG_SERIAL_MAX3100 is not set
3830 +# CONFIG_SERIAL_MAX3107 is not set
3831 +# CONFIG_SERIAL_MAX310X is not set
3832 +# CONFIG_SERIAL_MFD_HSU is not set
3833 +# CONFIG_SERIAL_NONSTANDARD is not set
3834 +# CONFIG_SERIAL_OF_PLATFORM is not set
3835 +# CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL is not set
3836 +# CONFIG_SERIAL_PCH_UART is not set
3837 +# CONFIG_SERIAL_RP2 is not set
3838 +# CONFIG_SERIAL_SC16IS7XX is not set
3839 +# CONFIG_SERIAL_SCCNXP is not set
3840 +# CONFIG_SERIAL_SH_SCI is not set
3841 +# CONFIG_SERIAL_ST_ASC is not set
3842 +# CONFIG_SERIAL_TIMBERDALE is not set
3843 +# CONFIG_SERIAL_UARTLITE is not set
3844 +# CONFIG_SERIAL_XILINX_PS_UART is not set
3845 +# CONFIG_SERIO_ALTERA_PS2 is not set
3846 +# CONFIG_SERIO_AMBAKMI is not set
3847 +# CONFIG_SERIO_ARC_PS2 is not set
3848 +# CONFIG_SERIO_I8042 is not set
3849 +# CONFIG_SERIO is not set
3850 +# CONFIG_SERIO_LIBPS2 is not set
3851 +# CONFIG_SERIO_PARKBD is not set
3852 +# CONFIG_SERIO_PCIPS2 is not set
3853 +# CONFIG_SERIO_PS2MULT is not set
3854 +# CONFIG_SERIO_RAW is not set
3855 +# CONFIG_SERIO_SERPORT is not set
3856 +# CONFIG_SFC is not set
3857 +# CONFIG_SFI is not set
3858 +# CONFIG_SGETMASK_SYSCALL is not set
3859 +# CONFIG_SGI_IOC4 is not set
3860 +# CONFIG_SGI_IP22 is not set
3861 +# CONFIG_SGI_IP27 is not set
3862 +# CONFIG_SGI_IP28 is not set
3863 +# CONFIG_SGI_IP32 is not set
3864 +# CONFIG_SGI_PARTITION is not set
3865 +# CONFIG_SH_ETH is not set
3866 +CONFIG_SHMEM=y
3867 +# CONFIG_SH_TIMER_CMT is not set
3868 +# CONFIG_SH_TIMER_MTU2 is not set
3869 +# CONFIG_SH_TIMER_TMU is not set
3870 +# CONFIG_SIBYTE_BIGSUR is not set
3871 +# CONFIG_SIBYTE_CARMEL is not set
3872 +# CONFIG_SIBYTE_CRHINE is not set
3873 +# CONFIG_SIBYTE_CRHONE is not set
3874 +# CONFIG_SIBYTE_LITTLESUR is not set
3875 +# CONFIG_SIBYTE_RHONE is not set
3876 +# CONFIG_SIBYTE_SENTOSA is not set
3877 +# CONFIG_SIBYTE_SWARM is not set
3878 +# CONFIG_SIGMA is not set
3879 +CONFIG_SIGNALFD=y
3880 +# CONFIG_SIMPLE_GPIO is not set
3881 +# CONFIG_SIS190 is not set
3882 +# CONFIG_SIS900 is not set
3883 +# CONFIG_SKGE is not set
3884 +# CONFIG_SKY2_DEBUG is not set
3885 +# CONFIG_SKY2 is not set
3886 +CONFIG_SLABINFO=y
3887 +CONFIG_SLAB=y
3888 +# CONFIG_SLHC is not set
3889 +# CONFIG_SLICOSS is not set
3890 +# CONFIG_SLIP is not set
3891 +# CONFIG_SLOB is not set
3892 +# CONFIG_SLUB_DEBUG is not set
3893 +# CONFIG_SLUB is not set
3894 +# CONFIG_SLUB_STATS is not set
3895 +# CONFIG_SMARTJOYPLUS_FF is not set
3896 +# CONFIG_SMC911X is not set
3897 +# CONFIG_SMC9194 is not set
3898 +# CONFIG_SMC91X is not set
3899 +# CONFIG_SM_FTL is not set
3900 +# CONFIG_SMP is not set
3901 +# CONFIG_SMSC911X is not set
3902 +# CONFIG_SMSC9420 is not set
3903 +# CONFIG_SMSC_PHY is not set
3904 +# CONFIG_SND_AC97_POWER_SAVE is not set
3905 +# CONFIG_SND_AD1816A is not set
3906 +# CONFIG_SND_AD1848 is not set
3907 +# CONFIG_SND_AD1889 is not set
3908 +# CONFIG_SND_ADLIB is not set
3909 +# CONFIG_SND_ALI5451 is not set
3910 +# CONFIG_SND_ALOOP is not set
3911 +# CONFIG_SND_ALS100 is not set
3912 +# CONFIG_SND_ALS300 is not set
3913 +# CONFIG_SND_ALS4000 is not set
3914 +# CONFIG_SND_ARM is not set
3915 +# CONFIG_SND_ASIHPI is not set
3916 +# CONFIG_SND_ATIIXP is not set
3917 +# CONFIG_SND_ATIIXP_MODEM is not set
3918 +# CONFIG_SND_ATMEL_AC97C is not set
3919 +# CONFIG_SND_ATMEL_SOC is not set
3920 +# CONFIG_SND_AU8810 is not set
3921 +# CONFIG_SND_AU8820 is not set
3922 +# CONFIG_SND_AU8830 is not set
3923 +# CONFIG_SND_AW2 is not set
3924 +# CONFIG_SND_AZT2320 is not set
3925 +# CONFIG_SND_AZT3328 is not set
3926 +# CONFIG_SND_BT87X is not set
3927 +# CONFIG_SND_CA0106 is not set
3928 +# CONFIG_SND_CMI8330 is not set
3929 +# CONFIG_SND_CMIPCI is not set
3930 +# CONFIG_SND_CS4231 is not set
3931 +# CONFIG_SND_CS4236 is not set
3932 +# CONFIG_SND_CS4281 is not set
3933 +# CONFIG_SND_CS46XX is not set
3934 +# CONFIG_SND_CS5530 is not set
3935 +# CONFIG_SND_CS5535AUDIO is not set
3936 +# CONFIG_SND_CTXFI is not set
3937 +# CONFIG_SND_DARLA20 is not set
3938 +# CONFIG_SND_DARLA24 is not set
3939 +# CONFIG_SND_DEBUG is not set
3940 +# CONFIG_SND_DESIGNWARE_I2S is not set
3941 +CONFIG_SND_DRIVERS=y
3942 +# CONFIG_SND_DUMMY is not set
3943 +# CONFIG_SND_DYNAMIC_MINORS is not set
3944 +# CONFIG_SND_ECHO3G is not set
3945 +# CONFIG_SND_EMU10K1 is not set
3946 +# CONFIG_SND_EMU10K1X is not set
3947 +# CONFIG_SND_ENS1370 is not set
3948 +# CONFIG_SND_ENS1371 is not set
3949 +# CONFIG_SND_ES1688 is not set
3950 +# CONFIG_SND_ES18XX is not set
3951 +# CONFIG_SND_ES1938 is not set
3952 +# CONFIG_SND_ES1968 is not set
3953 +# CONFIG_SND_FIREWIRE is not set
3954 +# CONFIG_SND_FM801 is not set
3955 +# CONFIG_SND_GINA20 is not set
3956 +# CONFIG_SND_GINA24 is not set
3957 +# CONFIG_SND_GUSCLASSIC is not set
3958 +# CONFIG_SND_GUSEXTREME is not set
3959 +# CONFIG_SND_GUSMAX is not set
3960 +# CONFIG_SND_HDA_INTEL is not set
3961 +# CONFIG_SND_HDSP is not set
3962 +# CONFIG_SND_HDSPM is not set
3963 +# CONFIG_SND_HRTIMER is not set
3964 +# CONFIG_SND_HWDEP is not set
3965 +# CONFIG_SND_ICE1712 is not set
3966 +# CONFIG_SND_ICE1724 is not set
3967 +# CONFIG_SND_INDIGODJ is not set
3968 +# CONFIG_SND_INDIGODJX is not set
3969 +# CONFIG_SND_INDIGOIO is not set
3970 +# CONFIG_SND_INDIGOIOX is not set
3971 +# CONFIG_SND_INDIGO is not set
3972 +# CONFIG_SND_INTEL8X0 is not set
3973 +# CONFIG_SND_INTEL8X0M is not set
3974 +# CONFIG_SND_INTERWAVE is not set
3975 +# CONFIG_SND_INTERWAVE_STB is not set
3976 +# CONFIG_SND_ISA is not set
3977 +# CONFIG_SND is not set
3978 +# CONFIG_SND_KIRKWOOD_SOC is not set
3979 +# CONFIG_SND_KORG1212 is not set
3980 +# CONFIG_SND_LAYLA20 is not set
3981 +# CONFIG_SND_LAYLA24 is not set
3982 +# CONFIG_SND_LOLA is not set
3983 +# CONFIG_SND_LX6464ES is not set
3984 +# CONFIG_SND_MAESTRO3 is not set
3985 +# CONFIG_SND_MIA is not set
3986 +# CONFIG_SND_MIPS is not set
3987 +# CONFIG_SND_MIRO is not set
3988 +# CONFIG_SND_MIXART is not set
3989 +# CONFIG_SND_MIXER_OSS is not set
3990 +# CONFIG_SND_MONA is not set
3991 +# CONFIG_SND_MPC52xx_SOC_EFIKA is not set
3992 +# CONFIG_SND_MPU401 is not set
3993 +# CONFIG_SND_MTPAV is not set
3994 +# CONFIG_SND_MTS64 is not set
3995 +# CONFIG_SND_MXS_SOC is not set
3996 +# CONFIG_SND_NM256 is not set
3997 +# CONFIG_SND_OPL3SA2 is not set
3998 +# CONFIG_SND_OPTI92X_AD1848 is not set
3999 +# CONFIG_SND_OPTI92X_CS4231 is not set
4000 +# CONFIG_SND_OPTI93X is not set
4001 +CONFIG_SND_OSSEMUL=y
4002 +# CONFIG_SND_OXYGEN is not set
4003 +CONFIG_SND_PCI=y
4004 +# CONFIG_SND_PCMCIA is not set
4005 +# CONFIG_SND_PCM is not set
4006 +# CONFIG_SND_PCM_OSS is not set
4007 +CONFIG_SND_PCM_OSS_PLUGINS=y
4008 +# CONFIG_SND_PCXHR is not set
4009 +# CONFIG_SND_PDAUDIOCF is not set
4010 +# CONFIG_SND_PORTMAN2X4 is not set
4011 +# CONFIG_SND_POWERPC_SOC is not set
4012 +# CONFIG_SND_PPC is not set
4013 +# CONFIG_SND_RAWMIDI is not set
4014 +# CONFIG_SND_RIPTIDE is not set
4015 +# CONFIG_SND_RME32 is not set
4016 +# CONFIG_SND_RME9652 is not set
4017 +# CONFIG_SND_RME96 is not set
4018 +# CONFIG_SND_RTCTIMER is not set
4019 +# CONFIG_SND_SB16 is not set
4020 +# CONFIG_SND_SB8 is not set
4021 +# CONFIG_SND_SBAWE is not set
4022 +# CONFIG_SND_SEQUENCER is not set
4023 +# CONFIG_SND_SERIAL_U16550 is not set
4024 +# CONFIG_SND_SIMPLE_CARD is not set
4025 +# CONFIG_SND_SIS7019 is not set
4026 +# CONFIG_SND_SOC_AU1XAUDIO is not set
4027 +# CONFIG_SND_SOC_AU1XPSC is not set
4028 +# CONFIG_SND_SOC_CACHE_LZO is not set
4029 +# CONFIG_SND_SOC_IMX_SPDIF is not set
4030 +# CONFIG_SND_SOC_IMX_WM8962 is not set
4031 +# CONFIG_SND_SOC is not set
4032 +# CONFIG_SND_SOC_MPC5200_AC97 is not set
4033 +# CONFIG_SND_SOC_MPC5200_I2S is not set
4034 +# CONFIG_SND_SONICVIBES is not set
4035 +# CONFIG_SND_SPI is not set
4036 +# CONFIG_SND_SSCAPE is not set
4037 +# CONFIG_SND_SUPPORT_OLD_API is not set
4038 +# CONFIG_SND_TIMER is not set
4039 +# CONFIG_SND_TRIDENT is not set
4040 +# CONFIG_SND_USB_6FIRE is not set
4041 +# CONFIG_SND_USB_AUDIO is not set
4042 +# CONFIG_SND_USB_CAIAQ is not set
4043 +# CONFIG_SND_USB_HIFACE is not set
4044 +# CONFIG_SND_USB_UA101 is not set
4045 +# CONFIG_SND_USB_US122L is not set
4046 +# CONFIG_SND_USB_USX2Y is not set
4047 +CONFIG_SND_USB=y
4048 +# CONFIG_SND_VERBOSE_PRINTK is not set
4049 +CONFIG_SND_VERBOSE_PROCFS=y
4050 +# CONFIG_SND_VIA82XX is not set
4051 +# CONFIG_SND_VIA82XX_MODEM is not set
4052 +# CONFIG_SND_VIRTUOSO is not set
4053 +# CONFIG_SND_VX222 is not set
4054 +# CONFIG_SND_VXPOCKET is not set
4055 +# CONFIG_SND_WAVEFRONT is not set
4056 +# CONFIG_SND_YMFPCI is not set
4057 +# CONFIG_SNI_RM is not set
4058 +# CONFIG_SOC_AM33XX is not set
4059 +# CONFIG_SOC_AM43XX is not set
4060 +# CONFIG_SOC_CAMERA is not set
4061 +# CONFIG_SOC_DRA7XX is not set
4062 +# CONFIG_SOC_HAS_OMAP2_SDRC is not set
4063 +# CONFIG_SOC_OMAP5 is not set
4064 +# CONFIG_SOFT_WATCHDOG is not set
4065 +# CONFIG_SOLARIS_X86_PARTITION is not set
4066 +# CONFIG_SOLO6X10 is not set
4067 +# CONFIG_SONY_LAPTOP is not set
4068 +# CONFIG_SONYPI is not set
4069 +# CONFIG_SOUND is not set
4070 +# CONFIG_SOUND_PRIME is not set
4071 +# CONFIG_SP5100_TCO is not set
4072 +# CONFIG_SPARSE_IRQ is not set
4073 +# CONFIG_SPARSEMEM_MANUAL is not set
4074 +# CONFIG_SPARSEMEM_STATIC is not set
4075 +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
4076 +# CONFIG_SPARSE_RCU_POINTER is not set
4077 +# CONFIG_SPEAKUP is not set
4078 +# CONFIG_SPI_ALTERA is not set
4079 +# CONFIG_SPI_AU1550 is not set
4080 +# CONFIG_SPI_BITBANG is not set
4081 +# CONFIG_SPI_BUTTERFLY is not set
4082 +# CONFIG_SPI_CADENCE is not set
4083 +# CONFIG_SPI_DEBUG is not set
4084 +# CONFIG_SPI_DESIGNWARE is not set
4085 +# CONFIG_SPI_FSL_DSPI is not set
4086 +# CONFIG_SPI_FSL_ESPI is not set
4087 +# CONFIG_SPI_FSL_SPI is not set
4088 +# CONFIG_SPI_GPIO is not set
4089 +# CONFIG_SPI_GPIO_OLD is not set
4090 +# CONFIG_SPI is not set
4091 +# CONFIG_SPI_LM70_LLP is not set
4092 +# CONFIG_SPI_MASTER is not set
4093 +# CONFIG_SPI_MPC52xx is not set
4094 +# CONFIG_SPI_MPC52xx_PSC is not set
4095 +# CONFIG_SPINLOCK_TEST is not set
4096 +# CONFIG_SPI_OC_TINY is not set
4097 +# CONFIG_SPI_ORION is not set
4098 +# CONFIG_SPI_PL022 is not set
4099 +# CONFIG_SPI_PPC4xx is not set
4100 +# CONFIG_SPI_PXA2XX is not set
4101 +# CONFIG_SPI_PXA2XX_PCI is not set
4102 +# CONFIG_SPI_RAMIPS is not set
4103 +# CONFIG_SPI_SC18IS602 is not set
4104 +# CONFIG_SPI_SPIDEV is not set
4105 +# CONFIG_SPI_TI_QSPI is not set
4106 +# CONFIG_SPI_TLE62X0 is not set
4107 +# CONFIG_SPI_TOPCLIFF_PCH is not set
4108 +# CONFIG_SPI_XCOMM is not set
4109 +# CONFIG_SPI_XILINX is not set
4110 +# CONFIG_SPI_XWAY is not set
4111 +CONFIG_SPLIT_PTLOCK_CPUS=4
4112 +# CONFIG_SPMI is not set
4113 +# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set
4114 +# CONFIG_SQUASHFS_DECOMP_MULTI is not set
4115 +CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU=y
4116 +# CONFIG_SQUASHFS_DECOMP_SINGLE is not set
4117 +# CONFIG_SQUASHFS_EMBEDDED is not set
4118 +# CONFIG_SQUASHFS_FILE_CACHE is not set
4119 +CONFIG_SQUASHFS_FILE_DIRECT=y
4120 +CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
4121 +# CONFIG_SQUASHFS_LZO is not set
4122 +# CONFIG_SQUASHFS_XATTR is not set
4123 +CONFIG_SQUASHFS_XZ=y
4124 +CONFIG_SQUASHFS=y
4125 +# CONFIG_SQUASHFS_ZLIB is not set
4126 +# CONFIG_SRAM is not set
4127 +# CONFIG_SSB_DEBUG is not set
4128 +# CONFIG_SSB_DRIVER_GPIO is not set
4129 +# CONFIG_SSBI is not set
4130 +# CONFIG_SSB is not set
4131 +# CONFIG_SSB_PCMCIAHOST is not set
4132 +CONFIG_SSB_POSSIBLE=y
4133 +# CONFIG_SSB_SDIOHOST is not set
4134 +# CONFIG_SSB_SILENT is not set
4135 +# CONFIG_SSFDC is not set
4136 +# CONFIG_STACK_TRACER is not set
4137 +CONFIG_STACKTRACE_SUPPORT=y
4138 +# CONFIG_STAGING_MEDIA is not set
4139 +CONFIG_STAGING=y
4140 +CONFIG_STANDALONE=y
4141 +CONFIG_STDBINUTILS=y
4142 +# CONFIG_STE10XP is not set
4143 +# CONFIG_STE_MODEM_RPROC is not set
4144 +# CONFIG_STMMAC_ETH is not set
4145 +CONFIG_STP=y
4146 +# CONFIG_STRICT_DEVMEM is not set
4147 +CONFIG_STRIP_ASM_SYMS=y
4148 +# CONFIG_STUB_POULSBO is not set
4149 +# CONFIG_SUNDANCE is not set
4150 +# CONFIG_SUNGEM is not set
4151 +# CONFIG_SUN_PARTITION is not set
4152 +# CONFIG_SUNRPC_DEBUG is not set
4153 +# CONFIG_SUNRPC_GSS is not set
4154 +# CONFIG_SUNRPC is not set
4155 +# CONFIG_SUSPEND is not set
4156 +CONFIG_SWAP=y
4157 +# CONFIG_SWCONFIG is not set
4158 +# CONFIG_SWCONFIG_LEDS is not set
4159 +CONFIG_SWIOTLB=y
4160 +# CONFIG_SXGBE_ETH is not set
4161 +# CONFIG_SYNCLINK_CS is not set
4162 +CONFIG_SYN_COOKIES=y
4163 +# CONFIG_SYSCTL_SYSCALL_CHECK is not set
4164 +# CONFIG_SYSCTL_SYSCALL is not set
4165 +CONFIG_SYSCTL=y
4166 +# CONFIG_SYSFS_DEPRECATED is not set
4167 +# CONFIG_SYSFS_DEPRECATED_V2 is not set
4168 +CONFIG_SYSFS_SYSCALL=y
4169 +CONFIG_SYSFS=y
4170 +# CONFIG_SYS_HYPERVISOR is not set
4171 +CONFIG_SYS_SUPPORTS_APM_EMULATION=y
4172 +# CONFIG_SYSTEMPORT is not set
4173 +# CONFIG_SYSTEM_TRUSTED_KEYRING is not set
4174 +# CONFIG_SYSV68_PARTITION is not set
4175 +# CONFIG_SYSV_FS is not set
4176 +CONFIG_SYSVIPC_SYSCTL=y
4177 +CONFIG_SYSVIPC=y
4178 +# CONFIG_TARGET_CORE is not set
4179 +# CONFIG_TASKSTATS is not set
4180 +# CONFIG_TC35815 is not set
4181 +# CONFIG_TCG_TPM is not set
4182 +# CONFIG_TCIC is not set
4183 +CONFIG_TCP_CONG_ADVANCED=y
4184 +# CONFIG_TCP_CONG_BIC is not set
4185 +CONFIG_TCP_CONG_CUBIC=y
4186 +# CONFIG_TCP_CONG_HSTCP is not set
4187 +# CONFIG_TCP_CONG_HTCP is not set
4188 +# CONFIG_TCP_CONG_HYBLA is not set
4189 +# CONFIG_TCP_CONG_ILLINOIS is not set
4190 +# CONFIG_TCP_CONG_LP is not set
4191 +# CONFIG_TCP_CONG_SCALABLE is not set
4192 +# CONFIG_TCP_CONG_VEGAS is not set
4193 +# CONFIG_TCP_CONG_VENO is not set
4194 +# CONFIG_TCP_CONG_WESTWOOD is not set
4195 +# CONFIG_TCP_CONG_YEAH is not set
4196 +# CONFIG_TCP_MD5SIG is not set
4197 +# CONFIG_TCS3472 is not set
4198 +# CONFIG_TEGRA_HOST1X is not set
4199 +# CONFIG_TEHUTI is not set
4200 +# CONFIG_TEST_BPF is not set
4201 +# CONFIG_TEST_KSTRTOX is not set
4202 +# CONFIG_TEST_LIST_SORT is not set
4203 +# CONFIG_TEST_MODULE is not set
4204 +# CONFIG_TEST_POWER is not set
4205 +# CONFIG_TEST_STRING_HELPERS is not set
4206 +# CONFIG_TEST_USER_COPY is not set
4207 +# CONFIG_TEXTSEARCH_BM is not set
4208 +# CONFIG_TEXTSEARCH_FSM is not set
4209 +# CONFIG_TEXTSEARCH_KMP is not set
4210 +CONFIG_TEXTSEARCH=y
4211 +# CONFIG_THERMAL_HWMON is not set
4212 +# CONFIG_THERMAL is not set
4213 +# CONFIG_THRUSTMASTER_FF is not set
4214 +# CONFIG_TI_ADC081C is not set
4215 +# CONFIG_TI_AM335X_ADC is not set
4216 +# CONFIG_TICK_CPU_ACCOUNTING is not set
4217 +CONFIG_TICK_CPU_ACCOUNTING=y
4218 +CONFIG_TICK_ONESHOT=y
4219 +# CONFIG_TI_CPSW is not set
4220 +# CONFIG_TI_CPTS is not set
4221 +# CONFIG_TI_DAC7512 is not set
4222 +# CONFIG_TI_DAVINCI_CPDMA is not set
4223 +# CONFIG_TI_DAVINCI_MDIO is not set
4224 +# CONFIG_TIFM_CORE is not set
4225 +# CONFIG_TIGON3 is not set
4226 +# CONFIG_TIMB_DMA is not set
4227 +CONFIG_TIMERFD=y
4228 +# CONFIG_TIMER_STATS is not set
4229 +CONFIG_TINY_RCU=y
4230 +# CONFIG_TIPC is not set
4231 +# CONFIG_TI_ST is not set
4232 +# CONFIG_TLAN is not set
4233 +# CONFIG_TMD_HERMES is not set
4234 +# CONFIG_TMP006 is not set
4235 +# CONFIG_TMPFS_POSIX_ACL is not set
4236 +CONFIG_TMPFS_XATTR=y
4237 +CONFIG_TMPFS=y
4238 +# CONFIG_TORTURE_TEST is not set
4239 +# CONFIG_TOUCHSCREEN_AD7877 is not set
4240 +# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
4241 +# CONFIG_TOUCHSCREEN_AD7879 is not set
4242 +# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
4243 +# CONFIG_TOUCHSCREEN_ADS7846 is not set
4244 +# CONFIG_TOUCHSCREEN_CLEARPAD_TM1217 is not set
4245 +# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set
4246 +# CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set
4247 +# CONFIG_TOUCHSCREEN_EDT_FT5X06 is not set
4248 +# CONFIG_TOUCHSCREEN_EETI is not set
4249 +# CONFIG_TOUCHSCREEN_ELO is not set
4250 +# CONFIG_TOUCHSCREEN_FUJITSU is not set
4251 +# CONFIG_TOUCHSCREEN_GUNZE is not set
4252 +# CONFIG_TOUCHSCREEN_ILI210X is not set
4253 +# CONFIG_TOUCHSCREEN_INEXIO is not set
4254 +# CONFIG_TOUCHSCREEN_MCS5000 is not set
4255 +# CONFIG_TOUCHSCREEN_MK712 is not set
4256 +# CONFIG_TOUCHSCREEN_MMS114 is not set
4257 +# CONFIG_TOUCHSCREEN_MTOUCH is not set
4258 +# CONFIG_TOUCHSCREEN_PENMOUNT is not set
4259 +# CONFIG_TOUCHSCREEN_S3C2410 is not set
4260 +# CONFIG_TOUCHSCREEN_SUR40 is not set
4261 +# CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4 is not set
4262 +# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
4263 +# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
4264 +# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
4265 +# CONFIG_TOUCHSCREEN_TPS6507X is not set
4266 +# CONFIG_TOUCHSCREEN_TSC2007 is not set
4267 +# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
4268 +# CONFIG_TOUCHSCREEN_W90X900 is not set
4269 +# CONFIG_TOUCHSCREEN_WACOM_I2C is not set
4270 +# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
4271 +# CONFIG_TOUCHSCREEN_WM97XX is not set
4272 +# CONFIG_TOUCHSCREEN_ZFORCE is not set
4273 +# CONFIG_TPS6105X is not set
4274 +# CONFIG_TPS65010 is not set
4275 +# CONFIG_TPS6507X is not set
4276 +# CONFIG_TRACE_BRANCH_PROFILING is not set
4277 +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
4278 +# CONFIG_TRACER_SNAPSHOT is not set
4279 +# CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP is not set
4280 +# CONFIG_TRACE_SINK is not set
4281 +CONFIG_TRACING_SUPPORT=y
4282 +CONFIG_TRAD_SIGNALS=y
4283 +# CONFIG_TRANSPARENT_HUGEPAGE is not set
4284 +# CONFIG_TRANZPORT is not set
4285 +# CONFIG_TREE_PREEMPT_RCU is not set
4286 +# CONFIG_TREE_RCU is not set
4287 +# CONFIG_TREE_RCU_TRACE is not set
4288 +# CONFIG_TR is not set
4289 +# CONFIG_TSL2583 is not set
4290 +# CONFIG_TSL2x7x is not set
4291 +# CONFIG_TSL4531 is not set
4292 +# CONFIG_TTY_PRINTK is not set
4293 +CONFIG_TTY=y
4294 +# CONFIG_TUN is not set
4295 +# CONFIG_TWL4030_CORE is not set
4296 +# CONFIG_TWL6030_GPADC is not set
4297 +# CONFIG_TWL6040_CORE is not set
4298 +# CONFIG_TYPHOON is not set
4299 +# CONFIG_UACCESS_WITH_MEMCPY is not set
4300 +# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
4301 +# CONFIG_UCB1400_CORE is not set
4302 +# CONFIG_UDF_FS is not set
4303 +CONFIG_UDF_NLS=y
4304 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
4305 +CONFIG_UEVENT_HELPER=y
4306 +# CONFIG_UFS_FS is not set
4307 +# CONFIG_UHID is not set
4308 +CONFIG_UID16=y
4309 +CONFIG_UIDGID_STRICT_TYPE_CHECKS=y
4310 +# CONFIG_UIO is not set
4311 +# CONFIG_ULTRA is not set
4312 +# CONFIG_ULTRIX_PARTITION is not set
4313 +CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"
4314 +CONFIG_UNIX98_PTYS=y
4315 +# CONFIG_UNIX_DIAG is not set
4316 +# CONFIG_UNIXWARE_DISKLABEL is not set
4317 +CONFIG_UNIX=y
4318 +# CONFIG_UNUSED_SYMBOLS is not set
4319 +# CONFIG_UPROBES is not set
4320 +# CONFIG_USB_ACM is not set
4321 +# CONFIG_USB_ADUTUX is not set
4322 +CONFIG_USB_ALI_M5632=y
4323 +# CONFIG_USB_AMD5536UDC is not set
4324 +CONFIG_USB_AN2720=y
4325 +# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
4326 +# CONFIG_USB_APPLEDISPLAY is not set
4327 +CONFIG_USB_ARCH_HAS_EHCI=y
4328 +CONFIG_USB_ARCH_HAS_HCD=y
4329 +CONFIG_USB_ARCH_HAS_OHCI=y
4330 +CONFIG_USB_ARMLINUX=y
4331 +# CONFIG_USB_ATM is not set
4332 +CONFIG_USB_BELKIN=y
4333 +# CONFIG_USB_BTMTK is not set
4334 +# CONFIG_USB_C67X00_HCD is not set
4335 +# CONFIG_USB_CATC is not set
4336 +# CONFIG_USB_CDC_COMPOSITE is not set
4337 +# CONFIG_USB_CHIPIDEA is not set
4338 +# CONFIG_USB_CONFIGFS is not set
4339 +# CONFIG_USB_CXACRU is not set
4340 +# CONFIG_USB_CYPRESS_CY7C63 is not set
4341 +# CONFIG_USB_CYTHERM is not set
4342 +# CONFIG_USB_DEBUG is not set
4343 +CONFIG_USB_DEFAULT_PERSIST=y
4344 +# CONFIG_USB_DEVICE_CLASS is not set
4345 +CONFIG_USB_DEVICEFS=y
4346 +# CONFIG_USB_DSBR is not set
4347 +# CONFIG_USB_DUMMY_HCD is not set
4348 +# CONFIG_USB_DWC2 is not set
4349 +# CONFIG_USB_DWC3 is not set
4350 +# CONFIG_USB_DWC_OTG_LPM is not set
4351 +# CONFIG_USB_DYNAMIC_MINORS is not set
4352 +# CONFIG_USB_EG20T is not set
4353 +# CONFIG_USB_EHCI_HCD_AT91 is not set
4354 +# CONFIG_USB_EHCI_HCD_PPC_OF is not set
4355 +# CONFIG_USB_EHCI_MV is not set
4356 +CONFIG_USB_EHCI_ROOT_HUB_TT=y
4357 +CONFIG_USB_EHCI_TT_NEWSCHED=y
4358 +# CONFIG_USB_EHSET_TEST_FIXTURE is not set
4359 +# CONFIG_USB_EMI26 is not set
4360 +# CONFIG_USB_EMI62 is not set
4361 +# CONFIG_USB_ENESTORAGE is not set
4362 +# CONFIG_USB_EPSON2888 is not set
4363 +# CONFIG_USB_ET61X251 is not set
4364 +# CONFIG_USB_EZUSB_FX2 is not set
4365 +CONFIG_USB_EZUSB=y
4366 +# CONFIG_USB_FILE_STORAGE is not set
4367 +# CONFIG_USB_FOTG210_HCD is not set
4368 +# CONFIG_USB_FOTG210_UDC is not set
4369 +# CONFIG_USB_FSL_USB2 is not set
4370 +# CONFIG_USB_FTDI_ELAN is not set
4371 +# CONFIG_USB_FUNCTIONFS is not set
4372 +# CONFIG_USB_FUSB300 is not set
4373 +# CONFIG_USB_FUSBH200_HCD is not set
4374 +# CONFIG_USB_G_ACM_MS is not set
4375 +# CONFIG_USB_GADGET_DEBUG_FILES is not set
4376 +# CONFIG_USB_GADGET_DEBUG_FS is not set
4377 +# CONFIG_USB_GADGET_DEBUG is not set
4378 +# CONFIG_USB_GADGETFS is not set
4379 +# CONFIG_USB_GADGET is not set
4380 +CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
4381 +CONFIG_USB_GADGET_VBUS_DRAW=2
4382 +# CONFIG_USB_G_DBGP is not set
4383 +# CONFIG_USB_G_HID is not set
4384 +# CONFIG_USB_GL860 is not set
4385 +# CONFIG_USB_G_MULTI is not set
4386 +# CONFIG_USB_G_NCM is not set
4387 +# CONFIG_USB_G_NOKIA is not set
4388 +# CONFIG_USB_GOKU is not set
4389 +# CONFIG_USB_GPIO_VBUS is not set
4390 +# CONFIG_USB_G_PRINTER is not set
4391 +# CONFIG_USB_GR_UDC is not set
4392 +# CONFIG_USB_G_SERIAL is not set
4393 +# CONFIG_USB_GSPCA_BENQ is not set
4394 +# CONFIG_USB_GSPCA_CONEX is not set
4395 +# CONFIG_USB_GSPCA_CPIA1 is not set
4396 +# CONFIG_USB_GSPCA_ETOMS is not set
4397 +# CONFIG_USB_GSPCA_FINEPIX is not set
4398 +# CONFIG_USB_GSPCA is not set
4399 +# CONFIG_USB_GSPCA_JEILINJ is not set
4400 +# CONFIG_USB_GSPCA_JL2005BCD is not set
4401 +# CONFIG_USB_GSPCA_KINECT is not set
4402 +# CONFIG_USB_GSPCA_KONICA is not set
4403 +# CONFIG_USB_GSPCA_MARS is not set
4404 +# CONFIG_USB_GSPCA_MR97310A is not set
4405 +# CONFIG_USB_GSPCA_NW80X is not set
4406 +# CONFIG_USB_GSPCA_OV519 is not set
4407 +# CONFIG_USB_GSPCA_OV534_9 is not set
4408 +# CONFIG_USB_GSPCA_OV534 is not set
4409 +# CONFIG_USB_GSPCA_PAC207 is not set
4410 +# CONFIG_USB_GSPCA_PAC7302 is not set
4411 +# CONFIG_USB_GSPCA_PAC7311 is not set
4412 +# CONFIG_USB_GSPCA_SE401 is not set
4413 +# CONFIG_USB_GSPCA_SN9C2028 is not set
4414 +# CONFIG_USB_GSPCA_SN9C20X is not set
4415 +# CONFIG_USB_GSPCA_SONIXB is not set
4416 +# CONFIG_USB_GSPCA_SONIXJ is not set
4417 +# CONFIG_USB_GSPCA_SPCA1528 is not set
4418 +# CONFIG_USB_GSPCA_SPCA500 is not set
4419 +# CONFIG_USB_GSPCA_SPCA501 is not set
4420 +# CONFIG_USB_GSPCA_SPCA505 is not set
4421 +# CONFIG_USB_GSPCA_SPCA506 is not set
4422 +# CONFIG_USB_GSPCA_SPCA508 is not set
4423 +# CONFIG_USB_GSPCA_SPCA561 is not set
4424 +# CONFIG_USB_GSPCA_SQ905C is not set
4425 +# CONFIG_USB_GSPCA_SQ905 is not set
4426 +# CONFIG_USB_GSPCA_SQ930X is not set
4427 +# CONFIG_USB_GSPCA_STK014 is not set
4428 +# CONFIG_USB_GSPCA_STK1135 is not set
4429 +# CONFIG_USB_GSPCA_STV0680 is not set
4430 +# CONFIG_USB_GSPCA_SUNPLUS is not set
4431 +# CONFIG_USB_GSPCA_T613 is not set
4432 +# CONFIG_USB_GSPCA_TOPRO is not set
4433 +# CONFIG_USB_GSPCA_TV8532 is not set
4434 +# CONFIG_USB_GSPCA_VC032X is not set
4435 +# CONFIG_USB_GSPCA_VICAM is not set
4436 +# CONFIG_USB_GSPCA_XIRLINK_CIT is not set
4437 +# CONFIG_USB_GSPCA_ZC3XX is not set
4438 +# CONFIG_USB_G_WEBCAM is not set
4439 +# CONFIG_USB_HCD_TEST_MODE is not set
4440 +# CONFIG_USB_HIDDEV is not set
4441 +# CONFIG_USB_HID is not set
4442 +# CONFIG_USB_HSIC_USB3503 is not set
4443 +# CONFIG_USB_HSO is not set
4444 +# CONFIG_USB_HWA_HCD is not set
4445 +# CONFIG_USB_IBMCAM is not set
4446 +# CONFIG_USB_IDMOUSE is not set
4447 +# CONFIG_USB_INPUT_IMS_PCU is not set
4448 +# CONFIG_USB_IOWARRIOR is not set
4449 +# CONFIG_USB_IP_COMMON is not set
4450 +# CONFIG_USBIP_CORE is not set
4451 +# CONFIG_USB_IPHETH is not set
4452 +# CONFIG_USB_ISIGHTFW is not set
4453 +# CONFIG_USB is not set
4454 +# CONFIG_USB_ISP116X_HCD is not set
4455 +# CONFIG_USB_ISP1301 is not set
4456 +# CONFIG_USB_ISP1362_HCD is not set
4457 +# CONFIG_USB_ISP1760_HCD is not set
4458 +# CONFIG_USB_KAWETH is not set
4459 +# CONFIG_USB_KBD is not set
4460 +# CONFIG_USB_KC2190 is not set
4461 +# CONFIG_USB_KONICAWC is not set
4462 +# CONFIG_USB_LCD is not set
4463 +# CONFIG_USB_LD is not set
4464 +# CONFIG_USB_LED is not set
4465 +# CONFIG_USB_LEGOTOWER is not set
4466 +# CONFIG_USB_LIBUSUAL is not set
4467 +# CONFIG_USB_M5602 is not set
4468 +# CONFIG_USB_M66592 is not set
4469 +# CONFIG_USB_MASS_STORAGE is not set
4470 +# CONFIG_USB_MDC800 is not set
4471 +# CONFIG_USB_MICROTEK is not set
4472 +# CONFIG_USB_MIDI_GADGET is not set
4473 +# CONFIG_USB_MON is not set
4474 +# CONFIG_USB_MOUSE is not set
4475 +# CONFIG_USB_MUSB_HDRC is not set
4476 +# CONFIG_USB_MV_U3D is not set
4477 +# CONFIG_USB_MV_UDC is not set
4478 +# CONFIG_USB_NET2272 is not set
4479 +# CONFIG_USB_NET2280 is not set
4480 +# CONFIG_USB_NET_AX88179_178A is not set
4481 +# CONFIG_USB_NET_AX8817X is not set
4482 +# CONFIG_USB_NET_CDC_EEM is not set
4483 +# CONFIG_USB_NET_CDCETHER is not set
4484 +# CONFIG_USB_NET_CDC_MBIM is not set
4485 +# CONFIG_USB_NET_CDC_NCM is not set
4486 +# CONFIG_USB_NET_CDC_SUBSET is not set
4487 +# CONFIG_USB_NET_CX82310_ETH is not set
4488 +# CONFIG_USB_NET_DM9601 is not set
4489 +# CONFIG_USB_NET_GL620A is not set
4490 +# CONFIG_USB_NET_HUAWEI_CDC_NCM is not set
4491 +# CONFIG_USB_NET_INT51X1 is not set
4492 +# CONFIG_USB_NET_KALMIA is not set
4493 +# CONFIG_USB_NET_MCS7830 is not set
4494 +# CONFIG_USB_NET_NET1080 is not set
4495 +# CONFIG_USB_NET_PLUSB is not set
4496 +# CONFIG_USB_NET_QMI_WWAN is not set
4497 +# CONFIG_USB_NET_RNDIS_HOST is not set
4498 +# CONFIG_USB_NET_RNDIS_WLAN is not set
4499 +# CONFIG_USB_NET_SMSC75XX is not set
4500 +# CONFIG_USB_NET_SMSC95XX is not set
4501 +# CONFIG_USB_NET_SR9700 is not set
4502 +# CONFIG_USB_NET_SR9800 is not set
4503 +# CONFIG_USB_NET_ZAURUS is not set
4504 +# CONFIG_USB_OHCI_HCD is not set
4505 +# CONFIG_USB_OHCI_HCD_PCI is not set
4506 +# CONFIG_USB_OHCI_HCD_PPC_OF_BE is not set
4507 +# CONFIG_USB_OHCI_HCD_PPC_OF is not set
4508 +# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set
4509 +# CONFIG_USB_OHCI_HCD_PPC_SOC is not set
4510 +# CONFIG_USB_OHCI_HCD_SSB is not set
4511 +CONFIG_USB_OHCI_LITTLE_ENDIAN=y
4512 +# CONFIG_USB_OTG_BLACKLIST_HUB is not set
4513 +# CONFIG_USB_OTG_FSM is not set
4514 +# CONFIG_USB_OTG is not set
4515 +# CONFIG_USB_OTG_WHITELIST is not set
4516 +# CONFIG_USB_OXU210HP_HCD is not set
4517 +# CONFIG_USBPCWATCHDOG is not set
4518 +# CONFIG_USB_PEGASUS is not set
4519 +# CONFIG_USB_PHY is not set
4520 +# CONFIG_USB_PRINTER is not set
4521 +# CONFIG_USB_PWC_INPUT_EVDEV is not set
4522 +# CONFIG_USB_PXA27X is not set
4523 +# CONFIG_USB_R8A66597_HCD is not set
4524 +# CONFIG_USB_R8A66597 is not set
4525 +# CONFIG_USB_RCAR_PHY is not set
4526 +# CONFIG_USB_RENESAS_USBHS is not set
4527 +# CONFIG_USB_RIO500 is not set
4528 +# CONFIG_USB_RTL8150 is not set
4529 +# CONFIG_USB_RTL8152 is not set
4530 +# CONFIG_USB_S2255 is not set
4531 +# CONFIG_USB_S3C_HSOTG is not set
4532 +# CONFIG_USB_SE401 is not set
4533 +# CONFIG_USB_SERIAL_AIRCABLE is not set
4534 +# CONFIG_USB_SERIAL_ARK3116 is not set
4535 +# CONFIG_USB_SERIAL_BELKIN is not set
4536 +# CONFIG_USB_SERIAL_CH341 is not set
4537 +# CONFIG_USB_SERIAL_CP210X is not set
4538 +# CONFIG_USB_SERIAL_CYBERJACK is not set
4539 +# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
4540 +# CONFIG_USB_SERIAL_DEBUG is not set
4541 +# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
4542 +# CONFIG_USB_SERIAL_EDGEPORT is not set
4543 +# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
4544 +# CONFIG_USB_SERIAL_EMPEG is not set
4545 +# CONFIG_USB_SERIAL_F81232 is not set
4546 +# CONFIG_USB_SERIAL_FTDI_SIO is not set
4547 +# CONFIG_USB_SERIAL_FUNSOFT is not set
4548 +# CONFIG_USB_SERIAL_GARMIN is not set
4549 +CONFIG_USB_SERIAL_GENERIC=y
4550 +# CONFIG_USB_SERIAL_HP4X is not set
4551 +# CONFIG_USB_SERIAL_IPAQ is not set
4552 +# CONFIG_USB_SERIAL_IPW is not set
4553 +# CONFIG_USB_SERIAL_IR is not set
4554 +# CONFIG_USB_SERIAL is not set
4555 +# CONFIG_USB_SERIAL_IUU is not set
4556 +# CONFIG_USB_SERIAL_KEYSPAN is not set
4557 +CONFIG_USB_SERIAL_KEYSPAN_MPR=y
4558 +# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
4559 +CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
4560 +CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
4561 +CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
4562 +CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
4563 +CONFIG_USB_SERIAL_KEYSPAN_USA19=y
4564 +CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
4565 +CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
4566 +CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
4567 +CONFIG_USB_SERIAL_KEYSPAN_USA28=y
4568 +CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
4569 +CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
4570 +# CONFIG_USB_SERIAL_KLSI is not set
4571 +# CONFIG_USB_SERIAL_KOBIL_SCT is not set
4572 +# CONFIG_USB_SERIAL_MCT_U232 is not set
4573 +# CONFIG_USB_SERIAL_METRO is not set
4574 +# CONFIG_USB_SERIAL_MOS7715_PARPORT is not set
4575 +# CONFIG_USB_SERIAL_MOS7720 is not set
4576 +# CONFIG_USB_SERIAL_MOS7840 is not set
4577 +# CONFIG_USB_SERIAL_MOTOROLA is not set
4578 +# CONFIG_USB_SERIAL_MXUPORT is not set
4579 +# CONFIG_USB_SERIAL_NAVMAN is not set
4580 +# CONFIG_USB_SERIAL_OMNINET is not set
4581 +# CONFIG_USB_SERIAL_OPTICON is not set
4582 +# CONFIG_USB_SERIAL_OPTION is not set
4583 +# CONFIG_USB_SERIAL_OTI6858 is not set
4584 +# CONFIG_USB_SERIAL_PL2303 is not set
4585 +# CONFIG_USB_SERIAL_QCAUX is not set
4586 +# CONFIG_USB_SERIAL_QT2 is not set
4587 +# CONFIG_USB_SERIAL_QUALCOMM is not set
4588 +# CONFIG_USB_SERIAL_QUATECH2 is not set
4589 +# CONFIG_USB_SERIAL_QUATECH_USB2 is not set
4590 +# CONFIG_USB_SERIAL_SAFE is not set
4591 +CONFIG_USB_SERIAL_SAFE_PADDED=y
4592 +# CONFIG_USB_SERIAL_SIEMENS_MPI is not set
4593 +# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
4594 +# CONFIG_USB_SERIAL_SIMPLE is not set
4595 +# CONFIG_USB_SERIAL_SPCP8X5 is not set
4596 +# CONFIG_USB_SERIAL_SSU100 is not set
4597 +# CONFIG_USB_SERIAL_SYMBOL is not set
4598 +# CONFIG_USB_SERIAL_TI is not set
4599 +# CONFIG_USB_SERIAL_VISOR is not set
4600 +# CONFIG_USB_SERIAL_VIVOPAY_SERIAL is not set
4601 +# CONFIG_USB_SERIAL_WHITEHEAT is not set
4602 +# CONFIG_USB_SERIAL_WISHBONE is not set
4603 +# CONFIG_USB_SERIAL_XIRCOM is not set
4604 +# CONFIG_USB_SERIAL_XSENS_MT is not set
4605 +# CONFIG_USB_SERIAL_ZIO is not set
4606 +# CONFIG_USB_SERIAL_ZTE is not set
4607 +# CONFIG_USB_SEVSEG is not set
4608 +# CONFIG_USB_SIERRA_NET is not set
4609 +# CONFIG_USB_SISUSBVGA is not set
4610 +# CONFIG_USB_SL811_HCD is not set
4611 +# CONFIG_USB_SN9C102 is not set
4612 +# CONFIG_USB_SPEEDTOUCH is not set
4613 +# CONFIG_USB_STKWEBCAM is not set
4614 +# CONFIG_USB_STORAGE_ALAUDA is not set
4615 +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
4616 +# CONFIG_USB_STORAGE_DATAFAB is not set
4617 +# CONFIG_USB_STORAGE_DEBUG is not set
4618 +# CONFIG_USB_STORAGE_ENE_UB6250 is not set
4619 +# CONFIG_USB_STORAGE_FREECOM is not set
4620 +# CONFIG_USB_STORAGE_ISD200 is not set
4621 +# CONFIG_USB_STORAGE is not set
4622 +# CONFIG_USB_STORAGE_JUMPSHOT is not set
4623 +# CONFIG_USB_STORAGE_KARMA is not set
4624 +# CONFIG_USB_STORAGE_ONETOUCH is not set
4625 +# CONFIG_USB_STORAGE_REALTEK is not set
4626 +# CONFIG_USB_STORAGE_SDDR09 is not set
4627 +# CONFIG_USB_STORAGE_SDDR55 is not set
4628 +# CONFIG_USB_STORAGE_USBAT is not set
4629 +# CONFIG_USB_STV06XX is not set
4630 +# CONFIG_USB_SUPPORT is not set
4631 +# CONFIG_USB_SUSPEND is not set
4632 +# CONFIG_USB_SWITCH_FSA9480 is not set
4633 +# CONFIG_USB_TEST is not set
4634 +# CONFIG_USB_TMC is not set
4635 +# CONFIG_USB_TRANCEVIBRATOR is not set
4636 +# CONFIG_USB_UAS is not set
4637 +# CONFIG_USB_UEAGLEATM is not set
4638 +# CONFIG_USB_ULPI is not set
4639 +# CONFIG_USB_USBNET is not set
4640 +# CONFIG_USB_USS720 is not set
4641 +CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
4642 +# CONFIG_USB_VIDEO_CLASS is not set
4643 +# CONFIG_USB_VL600 is not set
4644 +# CONFIG_USB_WDM is not set
4645 +# CONFIG_USB_WHCI_HCD is not set
4646 +# CONFIG_USB_WPAN_HCD is not set
4647 +# CONFIG_USB_WUSB_CBAF is not set
4648 +# CONFIG_USB_WUSB is not set
4649 +# CONFIG_USB_XHCI_HCD is not set
4650 +# CONFIG_USB_XUSBATM is not set
4651 +# CONFIG_USB_YUREX is not set
4652 +# CONFIG_USB_ZD1201 is not set
4653 +# CONFIG_USB_ZERO is not set
4654 +# CONFIG_USB_ZR364XX is not set
4655 +# CONFIG_USE_GENERIC_SMP_HELPERS is not set
4656 +CONFIG_USELIB=y
4657 +# CONFIG_USE_OF is not set
4658 +CONFIG_USE_OF=y
4659 +# CONFIG_UTS_NS is not set
4660 +# CONFIG_UWB is not set
4661 +# CONFIG_V4L_MEM2MEM_DRIVERS is not set
4662 +# CONFIG_V4L_TEST_DRIVERS is not set
4663 +# CONFIG_VCNL4000 is not set
4664 +CONFIG_VECTORS_BASE=0xffff0000
4665 +# CONFIG_VETH is not set
4666 +# CONFIG_VEXPRESS_CONFIG is not set
4667 +# CONFIG_VFAT_FS is not set
4668 +# CONFIG_VFP is not set
4669 +# CONFIG_VGA_ARB is not set
4670 +# CONFIG_VGASTATE is not set
4671 +# CONFIG_VGA_SWITCHEROO is not set
4672 +# CONFIG_VIA_RHINE is not set
4673 +# CONFIG_VIA_VELOCITY is not set
4674 +# CONFIG_VIDEO_ADV7170 is not set
4675 +# CONFIG_VIDEO_ADV7175 is not set
4676 +# CONFIG_VIDEO_ADV7180 is not set
4677 +# CONFIG_VIDEO_ADV7183 is not set
4678 +# CONFIG_VIDEO_ADV7343 is not set
4679 +# CONFIG_VIDEO_ADV7393 is not set
4680 +# CONFIG_VIDEO_ADV_DEBUG is not set
4681 +# CONFIG_VIDEO_AK881X is not set
4682 +# CONFIG_VIDEO_BT819 is not set
4683 +# CONFIG_VIDEO_BT848 is not set
4684 +# CONFIG_VIDEO_BT856 is not set
4685 +# CONFIG_VIDEO_BT866 is not set
4686 +# CONFIG_VIDEO_BWQCAM is not set
4687 +# CONFIG_VIDEO_CAFE_CCIC is not set
4688 +# CONFIG_VIDEO_CAPTURE_DRIVERS is not set
4689 +# CONFIG_VIDEO_CPIA is not set
4690 +# CONFIG_VIDEO_CQCAM is not set
4691 +# CONFIG_VIDEO_CS5345 is not set
4692 +# CONFIG_VIDEO_CS53L32A is not set
4693 +# CONFIG_VIDEO_CX231XX is not set
4694 +# CONFIG_VIDEO_CX2341X is not set
4695 +# CONFIG_VIDEO_CX25840 is not set
4696 +# CONFIG_VIDEO_CX88 is not set
4697 +# CONFIG_VIDEO_DEV is not set
4698 +# CONFIG_VIDEO_DM6446_CCDC is not set
4699 +# CONFIG_VIDEO_DT3155 is not set
4700 +# CONFIG_VIDEO_EM28XX is not set
4701 +# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
4702 +# CONFIG_VIDEO_GO7007 is not set
4703 +# CONFIG_VIDEO_HDPVR is not set
4704 +# CONFIG_VIDEO_HELPER_CHIPS_AUTO is not set
4705 +# CONFIG_VIDEO_HEXIUM_GEMINI is not set
4706 +# CONFIG_VIDEO_HEXIUM_ORION is not set
4707 +# CONFIG_VIDEO_IR_I2C is not set
4708 +# CONFIG_VIDEO_IVTV is not set
4709 +# CONFIG_VIDEO_KS0127 is not set
4710 +# CONFIG_VIDEO_M52790 is not set
4711 +# CONFIG_VIDEO_MEDIA is not set
4712 +# CONFIG_VIDEO_MEM2MEM_TESTDEV is not set
4713 +# CONFIG_VIDEO_ML86V7667 is not set
4714 +# CONFIG_VIDEO_MSP3400 is not set
4715 +# CONFIG_VIDEO_MT9V011 is not set
4716 +# CONFIG_VIDEO_MXB is not set
4717 +# CONFIG_VIDEO_NOON010PC30 is not set
4718 +# CONFIG_VIDEO_OMAP2_VOUT is not set
4719 +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
4720 +# CONFIG_VIDEO_OV7640 is not set
4721 +# CONFIG_VIDEO_OV7670 is not set
4722 +# CONFIG_VIDEO_PMS is not set
4723 +# CONFIG_VIDEO_PVRUSB2 is not set
4724 +# CONFIG_VIDEO_SAA6588 is not set
4725 +# CONFIG_VIDEO_SAA6752HS is not set
4726 +# CONFIG_VIDEO_SAA7110 is not set
4727 +# CONFIG_VIDEO_SAA711X is not set
4728 +# CONFIG_VIDEO_SAA7127 is not set
4729 +# CONFIG_VIDEO_SAA7134 is not set
4730 +# CONFIG_VIDEO_SAA717X is not set
4731 +# CONFIG_VIDEO_SAA7185 is not set
4732 +# CONFIG_VIDEO_SAA7191 is not set
4733 +# CONFIG_VIDEO_SH_MOBILE_CEU is not set
4734 +# CONFIG_VIDEO_SONY_BTF_MPX is not set
4735 +# CONFIG_VIDEO_SR030PC30 is not set
4736 +# CONFIG_VIDEO_TCM825X is not set
4737 +# CONFIG_VIDEO_TDA7432 is not set
4738 +# CONFIG_VIDEO_TDA9840 is not set
4739 +# CONFIG_VIDEO_TEA6415C is not set
4740 +# CONFIG_VIDEO_TEA6420 is not set
4741 +# CONFIG_VIDEO_THS7303 is not set
4742 +# CONFIG_VIDEO_THS8200 is not set
4743 +# CONFIG_VIDEO_TIMBERDALE is not set
4744 +# CONFIG_VIDEO_TLV320AIC23B is not set
4745 +# CONFIG_VIDEO_TM6000 is not set
4746 +# CONFIG_VIDEO_TVAUDIO is not set
4747 +# CONFIG_VIDEO_TVP514X is not set
4748 +# CONFIG_VIDEO_TVP5150 is not set
4749 +# CONFIG_VIDEO_TVP7002 is not set
4750 +# CONFIG_VIDEO_TW2804 is not set
4751 +# CONFIG_VIDEO_TW9903 is not set
4752 +# CONFIG_VIDEO_TW9906 is not set
4753 +# CONFIG_VIDEO_UDA1342 is not set
4754 +# CONFIG_VIDEO_UPD64031A is not set
4755 +# CONFIG_VIDEO_UPD64083 is not set
4756 +# CONFIG_VIDEO_USBTV is not set
4757 +# CONFIG_VIDEO_USBVISION is not set
4758 +# CONFIG_VIDEO_V4L2_COMMON is not set
4759 +# CONFIG_VIDEO_V4L2_INT_DEVICE is not set
4760 +# CONFIG_VIDEO_V4L2 is not set
4761 +# CONFIG_VIDEO_VIVI is not set
4762 +# CONFIG_VIDEO_VP27SMPX is not set
4763 +# CONFIG_VIDEO_VPX3220 is not set
4764 +# CONFIG_VIDEO_VS6624 is not set
4765 +# CONFIG_VIDEO_WM8739 is not set
4766 +# CONFIG_VIDEO_WM8775 is not set
4767 +# CONFIG_VIDEO_ZORAN is not set
4768 +# CONFIG_VIRQ_DEBUG is not set
4769 +# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
4770 +# CONFIG_VIRT_DRIVERS is not set
4771 +# CONFIG_VIRTIO_BALLOON is not set
4772 +# CONFIG_VIRTIO_MMIO is not set
4773 +# CONFIG_VIRTIO_PCI is not set
4774 +CONFIG_VIRT_TO_BUS=y
4775 +# CONFIG_VIRTUALIZATION is not set
4776 +# CONFIG_VITESSE_PHY is not set
4777 +# CONFIG_VLAN_8021Q_GVRP is not set
4778 +# CONFIG_VLAN_8021Q_MVRP is not set
4779 +CONFIG_VLAN_8021Q=y
4780 +# CONFIG_VME_BUS is not set
4781 +# CONFIG_VM_EVENT_COUNTERS is not set
4782 +# CONFIG_VMSPLIT_1G is not set
4783 +# CONFIG_VMSPLIT_2G is not set
4784 +# CONFIG_VMSPLIT_2G_OPT is not set
4785 +# CONFIG_VMSPLIT_3G_OPT is not set
4786 +CONFIG_VMSPLIT_3G=y
4787 +# CONFIG_VMWARE_PVSCSI is not set
4788 +# CONFIG_VMXNET3 is not set
4789 +# CONFIG_VORTEX is not set
4790 +# CONFIG_VSOCKETS is not set
4791 +# CONFIG_VT6655 is not set
4792 +# CONFIG_VT6656 is not set
4793 +# CONFIG_VT is not set
4794 +# CONFIG_VXFS_FS is not set
4795 +# CONFIG_VXGE is not set
4796 +# CONFIG_VXLAN is not set
4797 +# CONFIG_W1_CON is not set
4798 +# CONFIG_W1 is not set
4799 +# CONFIG_W1_MASTER_DS1WM is not set
4800 +# CONFIG_W1_MASTER_DS2482 is not set
4801 +# CONFIG_W1_MASTER_DS2490 is not set
4802 +# CONFIG_W1_MASTER_GPIO is not set
4803 +# CONFIG_W1_MASTER_MATROX is not set
4804 +# CONFIG_W1_SLAVE_BQ27000 is not set
4805 +# CONFIG_W1_SLAVE_DS2408 is not set
4806 +# CONFIG_W1_SLAVE_DS2413 is not set
4807 +# CONFIG_W1_SLAVE_DS2423 is not set
4808 +# CONFIG_W1_SLAVE_DS2431 is not set
4809 +# CONFIG_W1_SLAVE_DS2433 is not set
4810 +# CONFIG_W1_SLAVE_DS2760 is not set
4811 +# CONFIG_W1_SLAVE_DS2780 is not set
4812 +# CONFIG_W1_SLAVE_DS2781 is not set
4813 +# CONFIG_W1_SLAVE_DS28E04 is not set
4814 +# CONFIG_W1_SLAVE_SMEM is not set
4815 +# CONFIG_W1_SLAVE_THERM is not set
4816 +# CONFIG_W35UND is not set
4817 +# CONFIG_W83627HF_WDT is not set
4818 +# CONFIG_W83697HF_WDT is not set
4819 +# CONFIG_W83877F_WDT is not set
4820 +# CONFIG_W83977F_WDT is not set
4821 +# CONFIG_WAN is not set
4822 +# CONFIG_WAN_ROUTER is not set
4823 +# CONFIG_WANXL is not set
4824 +# CONFIG_WATCHDOG_CORE is not set
4825 +# CONFIG_WATCHDOG_NOWAYOUT is not set
4826 +CONFIG_WATCHDOG=y
4827 +# CONFIG_WD80x3 is not set
4828 +# CONFIG_WDTPCI is not set
4829 +CONFIG_WEXT_CORE=y
4830 +CONFIG_WEXT_PRIV=y
4831 +CONFIG_WEXT_PROC=y
4832 +CONFIG_WEXT_SPY=y
4833 +CONFIG_WILINK_PLATFORM_DATA=y
4834 +# CONFIG_WIMAX_GDM72XX is not set
4835 +# CONFIG_WIMAX is not set
4836 +# CONFIG_WIRELESS_EXT_SYSFS is not set
4837 +CONFIG_WIRELESS_EXT=y
4838 +CONFIG_WIRELESS=y
4839 +# CONFIG_WL1251 is not set
4840 +# CONFIG_WL12XX is not set
4841 +# CONFIG_WL18XX is not set
4842 +# CONFIG_WLAGS49_H25 is not set
4843 +# CONFIG_WLAGS49_H2 is not set
4844 +CONFIG_WLAN=y
4845 +# CONFIG_WLCORE is not set
4846 +CONFIG_WL_TI=y
4847 +CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y
4848 +# CONFIG_WR_PPMC is not set
4849 +# CONFIG_X25 is not set
4850 +# CONFIG_X86_DEBUG_STATIC_CPU_HAS is not set
4851 +# CONFIG_X86_PKG_TEMP_THERMAL is not set
4852 +CONFIG_X86_SYSFB=y
4853 +# CONFIG_XFRM_IPCOMP is not set
4854 +# CONFIG_XFRM_MIGRATE is not set
4855 +# CONFIG_XFRM_STATISTICS is not set
4856 +# CONFIG_XFRM_SUB_POLICY is not set
4857 +# CONFIG_XFRM_USER is not set
4858 +CONFIG_XFRM=y
4859 +# CONFIG_XFS_DEBUG is not set
4860 +# CONFIG_XFS_FS is not set
4861 +# CONFIG_XFS_POSIX_ACL is not set
4862 +# CONFIG_XFS_QUOTA is not set
4863 +# CONFIG_XFS_RT is not set
4864 +# CONFIG_XFS_WARN is not set
4865 +# CONFIG_XILINX_AXI_EMAC is not set
4866 +# CONFIG_XILINX_EMACLITE is not set
4867 +# CONFIG_XILINX_LL_TEMAC is not set
4868 +# CONFIG_XILINX_WATCHDOG is not set
4869 +# CONFIG_XILLYBUS is not set
4870 +# CONFIG_XIP_KERNEL is not set
4871 +# CONFIG_XMON is not set
4872 +# CONFIG_XVMALLOC is not set
4873 +# CONFIG_XZ_DEC_ARM is not set
4874 +# CONFIG_XZ_DEC_ARMTHUMB is not set
4875 +# CONFIG_XZ_DEC_BCJ is not set
4876 +# CONFIG_XZ_DEC_IA64 is not set
4877 +# CONFIG_XZ_DEC_POWERPC is not set
4878 +# CONFIG_XZ_DEC_SPARC is not set
4879 +# CONFIG_XZ_DEC_TEST is not set
4880 +# CONFIG_XZ_DEC_X86 is not set
4881 +CONFIG_XZ_DEC=y
4882 +# CONFIG_YAFFS_DISABLE_BAD_BLOCK_MARKING is not set
4883 +# CONFIG_YAFFS_FS is not set
4884 +# CONFIG_YAM is not set
4885 +# CONFIG_YELLOWFIN is not set
4886 +# CONFIG_YENTA is not set
4887 +# CONFIG_YENTA_O2 is not set
4888 +# CONFIG_YENTA_RICOH is not set
4889 +# CONFIG_YENTA_TI is not set
4890 +# CONFIG_YENTA_TOSHIBA is not set
4891 +CONFIG_ZBOOT_ROM_BSS=0x0
4892 +CONFIG_ZBOOT_ROM_TEXT=0x0
4893 +# CONFIG_ZBUD is not set
4894 +# CONFIG_ZD1211RW_DEBUG is not set
4895 +# CONFIG_ZD1211RW is not set
4896 +# CONFIG_ZEROPLUS_FF is not set
4897 +# CONFIG_ZISOFS is not set
4898 +# CONFIG_ZLIB_DEFLATE is not set
4899 +# CONFIG_ZLIB_INFLATE is not set
4900 +# CONFIG_ZNET is not set
4901 +CONFIG_ZONE_DMA_FLAG=0
4902 +CONFIG_ZONE_DMA_FLAG=1
4903 +CONFIG_ZONE_DMA=y
4904 +# CONFIG_ZRAM is not set
4905 +# CONFIG_ZSMALLOC is not set
4906 diff --git a/target/linux/generic/patches-3.16/000-keep_initrafs_the_default.patch b/target/linux/generic/patches-3.16/000-keep_initrafs_the_default.patch
4907 new file mode 100644
4908 index 000000000000..b5b1955f1517
4909 --- /dev/null
4910 +++ b/target/linux/generic/patches-3.16/000-keep_initrafs_the_default.patch
4911 @@ -0,0 +1,25 @@
4912 +Upstream changed the default rootfs to tmpfs when none has been passed
4913 +to the kernel - this doesn't fit our purposes, so change it back.
4915 +Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
4917 +--- a/init/do_mounts.c
4918 ++++ b/init/do_mounts.c
4919 +@@ -622,6 +622,7 @@ int __init init_rootfs(void)
4920 + if (err)
4921 + return err;
4923 ++#if 0
4924 + if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
4925 + (!root_fs_names || strstr(root_fs_names, "tmpfs"))) {
4926 + err = shmem_init();
4927 +@@ -629,6 +630,9 @@ int __init init_rootfs(void)
4928 + } else {
4929 + err = init_ramfs_fs();
4931 ++#else
4932 ++ err = init_ramfs_fs();
4933 ++#endif
4935 + if (err)
4936 + unregister_filesystem(&rootfs_fs_type);
4937 diff --git a/target/linux/generic/patches-3.16/020-ssb_update.patch b/target/linux/generic/patches-3.16/020-ssb_update.patch
4938 new file mode 100644
4939 index 000000000000..083a892510d6
4940 --- /dev/null
4941 +++ b/target/linux/generic/patches-3.16/020-ssb_update.patch
4942 @@ -0,0 +1,201 @@
4943 +--- a/drivers/ssb/pci.c
4944 ++++ b/drivers/ssb/pci.c
4945 +@@ -326,13 +326,13 @@ err_ctlreg:
4946 + return err;
4949 +-static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in,
4950 +- u16 mask, u16 shift)
4951 ++static s8 sprom_extract_antgain(u8 sprom_revision, const u16 *in, u16 offset,
4952 ++ u16 mask, u16 shift)
4954 + u16 v;
4955 + u8 gain;
4957 +- v = in[SPOFF(SSB_SPROM1_AGAIN)];
4958 ++ v = in[SPOFF(offset)];
4959 + gain = (v & mask) >> shift;
4960 + if (gain == 0xFF)
4961 + gain = 2; /* If unset use 2dBm */
4962 +@@ -416,12 +416,14 @@ static void sprom_extract_r123(struct ss
4963 + SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);
4965 + /* Extract the antenna gain values. */
4966 +- out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
4967 +- SSB_SPROM1_AGAIN_BG,
4968 +- SSB_SPROM1_AGAIN_BG_SHIFT);
4969 +- out->antenna_gain.a1 = r123_extract_antgain(out->revision, in,
4970 +- SSB_SPROM1_AGAIN_A,
4971 +- SSB_SPROM1_AGAIN_A_SHIFT);
4972 ++ out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,
4973 ++ SSB_SPROM1_AGAIN,
4974 ++ SSB_SPROM1_AGAIN_BG,
4975 ++ SSB_SPROM1_AGAIN_BG_SHIFT);
4976 ++ out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,
4977 ++ SSB_SPROM1_AGAIN,
4978 ++ SSB_SPROM1_AGAIN_A,
4979 ++ SSB_SPROM1_AGAIN_A_SHIFT);
4980 + if (out->revision >= 2)
4981 + sprom_extract_r23(out, in);
4983 +@@ -468,7 +470,15 @@ static void sprom_extract_r458(struct ss
4985 + static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
4987 ++ static const u16 pwr_info_offset[] = {
4988 ++ SSB_SPROM4_PWR_INFO_CORE0, SSB_SPROM4_PWR_INFO_CORE1,
4989 ++ SSB_SPROM4_PWR_INFO_CORE2, SSB_SPROM4_PWR_INFO_CORE3
4990 ++ };
4991 + u16 il0mac_offset;
4992 ++ int i;
4994 ++ BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
4995 ++ ARRAY_SIZE(out->core_pwr_info));
4997 + if (out->revision == 4)
4998 + il0mac_offset = SSB_SPROM4_IL0MAC;
4999 +@@ -524,14 +534,59 @@ static void sprom_extract_r45(struct ssb
5002 + /* Extract the antenna gain values. */
5003 +- SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01,
5004 +- SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT);
5005 +- SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01,
5006 +- SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT);
5007 +- SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23,
5008 +- SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT);
5009 +- SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23,
5010 +- SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT);
5011 ++ out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,
5012 ++ SSB_SPROM4_AGAIN01,
5013 ++ SSB_SPROM4_AGAIN0,
5014 ++ SSB_SPROM4_AGAIN0_SHIFT);
5015 ++ out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,
5016 ++ SSB_SPROM4_AGAIN01,
5017 ++ SSB_SPROM4_AGAIN1,
5018 ++ SSB_SPROM4_AGAIN1_SHIFT);
5019 ++ out->antenna_gain.a2 = sprom_extract_antgain(out->revision, in,
5020 ++ SSB_SPROM4_AGAIN23,
5021 ++ SSB_SPROM4_AGAIN2,
5022 ++ SSB_SPROM4_AGAIN2_SHIFT);
5023 ++ out->antenna_gain.a3 = sprom_extract_antgain(out->revision, in,
5024 ++ SSB_SPROM4_AGAIN23,
5025 ++ SSB_SPROM4_AGAIN3,
5026 ++ SSB_SPROM4_AGAIN3_SHIFT);
5028 ++ /* Extract cores power info info */
5029 ++ for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
5030 ++ u16 o = pwr_info_offset[i];
5032 ++ SPEX(core_pwr_info[i].itssi_2g, o + SSB_SPROM4_2G_MAXP_ITSSI,
5033 ++ SSB_SPROM4_2G_ITSSI, SSB_SPROM4_2G_ITSSI_SHIFT);
5034 ++ SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SPROM4_2G_MAXP_ITSSI,
5035 ++ SSB_SPROM4_2G_MAXP, 0);
5037 ++ SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SPROM4_2G_PA_0, ~0, 0);
5038 ++ SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SPROM4_2G_PA_1, ~0, 0);
5039 ++ SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SPROM4_2G_PA_2, ~0, 0);
5040 ++ SPEX(core_pwr_info[i].pa_2g[3], o + SSB_SPROM4_2G_PA_3, ~0, 0);
5042 ++ SPEX(core_pwr_info[i].itssi_5g, o + SSB_SPROM4_5G_MAXP_ITSSI,
5043 ++ SSB_SPROM4_5G_ITSSI, SSB_SPROM4_5G_ITSSI_SHIFT);
5044 ++ SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SPROM4_5G_MAXP_ITSSI,
5045 ++ SSB_SPROM4_5G_MAXP, 0);
5046 ++ SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM4_5GHL_MAXP,
5047 ++ SSB_SPROM4_5GH_MAXP, 0);
5048 ++ SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM4_5GHL_MAXP,
5049 ++ SSB_SPROM4_5GL_MAXP, SSB_SPROM4_5GL_MAXP_SHIFT);
5051 ++ SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SPROM4_5GL_PA_0, ~0, 0);
5052 ++ SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SPROM4_5GL_PA_1, ~0, 0);
5053 ++ SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SPROM4_5GL_PA_2, ~0, 0);
5054 ++ SPEX(core_pwr_info[i].pa_5gl[3], o + SSB_SPROM4_5GL_PA_3, ~0, 0);
5055 ++ SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SPROM4_5G_PA_0, ~0, 0);
5056 ++ SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SPROM4_5G_PA_1, ~0, 0);
5057 ++ SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SPROM4_5G_PA_2, ~0, 0);
5058 ++ SPEX(core_pwr_info[i].pa_5g[3], o + SSB_SPROM4_5G_PA_3, ~0, 0);
5059 ++ SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SPROM4_5GH_PA_0, ~0, 0);
5060 ++ SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SPROM4_5GH_PA_1, ~0, 0);
5061 ++ SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SPROM4_5GH_PA_2, ~0, 0);
5062 ++ SPEX(core_pwr_info[i].pa_5gh[3], o + SSB_SPROM4_5GH_PA_3, ~0, 0);
5063 ++ }
5065 + sprom_extract_r458(out, in);
5067 +@@ -621,14 +676,22 @@ static void sprom_extract_r8(struct ssb_
5068 + SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
5070 + /* Extract the antenna gain values. */
5071 +- SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
5072 +- SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
5073 +- SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
5074 +- SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
5075 +- SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
5076 +- SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
5077 +- SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
5078 +- SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
5079 ++ out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,
5080 ++ SSB_SPROM8_AGAIN01,
5081 ++ SSB_SPROM8_AGAIN0,
5082 ++ SSB_SPROM8_AGAIN0_SHIFT);
5083 ++ out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,
5084 ++ SSB_SPROM8_AGAIN01,
5085 ++ SSB_SPROM8_AGAIN1,
5086 ++ SSB_SPROM8_AGAIN1_SHIFT);
5087 ++ out->antenna_gain.a2 = sprom_extract_antgain(out->revision, in,
5088 ++ SSB_SPROM8_AGAIN23,
5089 ++ SSB_SPROM8_AGAIN2,
5090 ++ SSB_SPROM8_AGAIN2_SHIFT);
5091 ++ out->antenna_gain.a3 = sprom_extract_antgain(out->revision, in,
5092 ++ SSB_SPROM8_AGAIN23,
5093 ++ SSB_SPROM8_AGAIN3,
5094 ++ SSB_SPROM8_AGAIN3_SHIFT);
5096 + /* Extract cores power info info */
5097 + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
5098 +--- a/include/linux/ssb/ssb_regs.h
5099 ++++ b/include/linux/ssb/ssb_regs.h
5100 +@@ -345,6 +345,43 @@
5101 + #define SSB_SPROM4_TXPID5GH2_SHIFT 0
5102 + #define SSB_SPROM4_TXPID5GH3 0xFF00
5103 + #define SSB_SPROM4_TXPID5GH3_SHIFT 8
5105 ++/* There are 4 blocks with power info sharing the same layout */
5106 ++#define SSB_SPROM4_PWR_INFO_CORE0 0x0080
5107 ++#define SSB_SPROM4_PWR_INFO_CORE1 0x00AE
5108 ++#define SSB_SPROM4_PWR_INFO_CORE2 0x00DC
5109 ++#define SSB_SPROM4_PWR_INFO_CORE3 0x010A
5111 ++#define SSB_SPROM4_2G_MAXP_ITSSI 0x00 /* 2 GHz ITSSI and 2 GHz Max Power */
5112 ++#define SSB_SPROM4_2G_MAXP 0x00FF
5113 ++#define SSB_SPROM4_2G_ITSSI 0xFF00
5114 ++#define SSB_SPROM4_2G_ITSSI_SHIFT 8
5115 ++#define SSB_SPROM4_2G_PA_0 0x02 /* 2 GHz power amp */
5116 ++#define SSB_SPROM4_2G_PA_1 0x04
5117 ++#define SSB_SPROM4_2G_PA_2 0x06
5118 ++#define SSB_SPROM4_2G_PA_3 0x08
5119 ++#define SSB_SPROM4_5G_MAXP_ITSSI 0x0A /* 5 GHz ITSSI and 5.3 GHz Max Power */
5120 ++#define SSB_SPROM4_5G_MAXP 0x00FF
5121 ++#define SSB_SPROM4_5G_ITSSI 0xFF00
5122 ++#define SSB_SPROM4_5G_ITSSI_SHIFT 8
5123 ++#define SSB_SPROM4_5GHL_MAXP 0x0C /* 5.2 GHz and 5.8 GHz Max Power */
5124 ++#define SSB_SPROM4_5GH_MAXP 0x00FF
5125 ++#define SSB_SPROM4_5GL_MAXP 0xFF00
5126 ++#define SSB_SPROM4_5GL_MAXP_SHIFT 8
5127 ++#define SSB_SPROM4_5G_PA_0 0x0E /* 5.3 GHz power amp */
5128 ++#define SSB_SPROM4_5G_PA_1 0x10
5129 ++#define SSB_SPROM4_5G_PA_2 0x12
5130 ++#define SSB_SPROM4_5G_PA_3 0x14
5131 ++#define SSB_SPROM4_5GL_PA_0 0x16 /* 5.2 GHz power amp */
5132 ++#define SSB_SPROM4_5GL_PA_1 0x18
5133 ++#define SSB_SPROM4_5GL_PA_2 0x1A
5134 ++#define SSB_SPROM4_5GL_PA_3 0x1C
5135 ++#define SSB_SPROM4_5GH_PA_0 0x1E /* 5.8 GHz power amp */
5136 ++#define SSB_SPROM4_5GH_PA_1 0x20
5137 ++#define SSB_SPROM4_5GH_PA_2 0x22
5138 ++#define SSB_SPROM4_5GH_PA_3 0x24
5140 ++/* TODO: Make it deprecated */
5141 + #define SSB_SPROM4_MAXP_BG 0x0080 /* Max Power BG in path 1 */
5142 + #define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */
5143 + #define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
5144 diff --git a/target/linux/generic/patches-3.16/025-bcma_backport.patch b/target/linux/generic/patches-3.16/025-bcma_backport.patch
5145 new file mode 100644
5146 index 000000000000..a1c3c5f57ed9
5147 --- /dev/null
5148 +++ b/target/linux/generic/patches-3.16/025-bcma_backport.patch
5149 @@ -0,0 +1,1368 @@
5150 +--- a/drivers/bcma/Makefile
5151 ++++ b/drivers/bcma/Makefile
5152 +@@ -1,8 +1,10 @@
5153 + bcma-y += main.o scan.o core.o sprom.o
5154 + bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
5155 ++bcma-y += driver_chipcommon_b.o
5156 + bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o
5157 + bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o
5158 + bcma-y += driver_pci.o
5159 ++bcma-y += driver_pcie2.o
5160 + bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
5161 + bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
5162 + bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
5163 +--- a/drivers/bcma/driver_chipcommon_pmu.c
5164 ++++ b/drivers/bcma/driver_chipcommon_pmu.c
5165 +@@ -603,6 +603,8 @@ void bcma_pmu_spuravoid_pllupdate(struct
5166 + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
5167 + break;
5169 ++ case BCMA_CHIP_ID_BCM43131:
5170 ++ case BCMA_CHIP_ID_BCM43217:
5171 + case BCMA_CHIP_ID_BCM43227:
5172 + case BCMA_CHIP_ID_BCM43228:
5173 + case BCMA_CHIP_ID_BCM43428:
5174 +--- a/drivers/bcma/driver_gpio.c
5175 ++++ b/drivers/bcma/driver_gpio.c
5176 +@@ -76,7 +76,7 @@ static void bcma_gpio_free(struct gpio_c
5177 + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
5180 +-#if IS_BUILTIN(CONFIG_BCMA_HOST_SOC)
5181 ++#if IS_BUILTIN(CONFIG_BCM47XX)
5182 + static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
5184 + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
5185 +@@ -215,11 +215,18 @@ int bcma_gpio_init(struct bcma_drv_cc *c
5186 + chip->set = bcma_gpio_set_value;
5187 + chip->direction_input = bcma_gpio_direction_input;
5188 + chip->direction_output = bcma_gpio_direction_output;
5189 +-#if IS_BUILTIN(CONFIG_BCMA_HOST_SOC)
5190 ++#if IS_BUILTIN(CONFIG_BCM47XX)
5191 + chip->to_irq = bcma_gpio_to_irq;
5192 + #endif
5194 ++#if IS_BUILTIN(CONFIG_OF)
5195 ++ if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
5196 ++ chip->of_node = cc->core->dev.of_node;
5197 ++#endif
5199 + switch (cc->core->bus->chipinfo.id) {
5200 + case BCMA_CHIP_ID_BCM5357:
5201 ++ case BCMA_CHIP_ID_BCM53572:
5202 + chip->ngpio = 32;
5203 + break;
5204 + default:
5205 +--- /dev/null
5206 ++++ b/drivers/bcma/driver_pcie2.c
5207 +@@ -0,0 +1,175 @@
5208 ++/*
5209 ++ * Broadcom specific AMBA
5210 ++ * PCIe Gen 2 Core
5211 ++ *
5212 ++ * Copyright 2014, Broadcom Corporation
5213 ++ * Copyright 2014, Rafał Miłecki <zajec5@gmail.com>
5214 ++ *
5215 ++ * Licensed under the GNU/GPL. See COPYING for details.
5216 ++ */
5218 ++#include "bcma_private.h"
5219 ++#include <linux/bcma/bcma.h>
5221 ++/**************************************************
5222 ++ * R/W ops.
5223 ++ **************************************************/
5225 ++#if 0
5226 ++static u32 bcma_core_pcie2_cfg_read(struct bcma_drv_pcie2 *pcie2, u32 addr)
5228 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, addr);
5229 ++ pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR);
5230 ++ return pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA);
5232 ++#endif
5234 ++static void bcma_core_pcie2_cfg_write(struct bcma_drv_pcie2 *pcie2, u32 addr,
5235 ++ u32 val)
5237 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, addr);
5238 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, val);
5241 ++/**************************************************
5242 ++ * Init.
5243 ++ **************************************************/
5245 ++static u32 bcma_core_pcie2_war_delay_perst_enab(struct bcma_drv_pcie2 *pcie2,
5246 ++ bool enable)
5248 ++ u32 val;
5250 ++ /* restore back to default */
5251 ++ val = pcie2_read32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL);
5252 ++ val |= PCIE2_CLKC_DLYPERST;
5253 ++ val &= ~PCIE2_CLKC_DISSPROMLD;
5254 ++ if (enable) {
5255 ++ val &= ~PCIE2_CLKC_DLYPERST;
5256 ++ val |= PCIE2_CLKC_DISSPROMLD;
5257 ++ }
5258 ++ pcie2_write32(pcie2, (BCMA_CORE_PCIE2_CLK_CONTROL), val);
5259 ++ /* flush */
5260 ++ return pcie2_read32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL);
5263 ++static void bcma_core_pcie2_set_ltr_vals(struct bcma_drv_pcie2 *pcie2)
5265 ++ /* LTR0 */
5266 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x844);
5267 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x883c883c);
5268 ++ /* LTR1 */
5269 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x848);
5270 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x88648864);
5271 ++ /* LTR2 */
5272 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, 0x84C);
5273 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x90039003);
5276 ++static void bcma_core_pcie2_hw_ltr_war(struct bcma_drv_pcie2 *pcie2)
5278 ++ u8 core_rev = pcie2->core->id.rev;
5279 ++ u32 devstsctr2;
5281 ++ if (core_rev < 2 || core_rev == 10 || core_rev > 13)
5282 ++ return;
5284 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
5285 ++ PCIE2_CAP_DEVSTSCTRL2_OFFSET);
5286 ++ devstsctr2 = pcie2_read32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA);
5287 ++ if (devstsctr2 & PCIE2_CAP_DEVSTSCTRL2_LTRENAB) {
5288 ++ /* force the right LTR values */
5289 ++ bcma_core_pcie2_set_ltr_vals(pcie2);
5291 ++ /* TODO:
5292 ++ si_core_wrapperreg(pcie2, 3, 0x60, 0x8080, 0); */
5294 ++ /* enable the LTR */
5295 ++ devstsctr2 |= PCIE2_CAP_DEVSTSCTRL2_LTRENAB;
5296 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
5297 ++ PCIE2_CAP_DEVSTSCTRL2_OFFSET);
5298 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, devstsctr2);
5300 ++ /* set the LTR state to be active */
5301 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_LTR_STATE,
5302 ++ PCIE2_LTR_ACTIVE);
5303 ++ usleep_range(1000, 2000);
5305 ++ /* set the LTR state to be sleep */
5306 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_LTR_STATE,
5307 ++ PCIE2_LTR_SLEEP);
5308 ++ usleep_range(1000, 2000);
5309 ++ }
5312 ++static void pciedev_crwlpciegen2(struct bcma_drv_pcie2 *pcie2)
5314 ++ u8 core_rev = pcie2->core->id.rev;
5315 ++ bool pciewar160, pciewar162;
5317 ++ pciewar160 = core_rev == 7 || core_rev == 9 || core_rev == 11;
5318 ++ pciewar162 = core_rev == 5 || core_rev == 7 || core_rev == 8 ||
5319 ++ core_rev == 9 || core_rev == 11;
5321 ++ if (!pciewar160 && !pciewar162)
5322 ++ return;
5324 ++/* TODO */
5325 ++#if 0
5326 ++ pcie2_set32(pcie2, BCMA_CORE_PCIE2_CLK_CONTROL,
5327 ++ PCIE_DISABLE_L1CLK_GATING);
5328 ++#if 0
5329 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
5330 ++ PCIEGEN2_COE_PVT_TL_CTRL_0);
5331 ++ pcie2_mask32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA,
5332 ++ ~(1 << COE_PVT_TL_CTRL_0_PM_DIS_L1_REENTRY_BIT));
5333 ++#endif
5334 ++#endif
5337 ++static void pciedev_crwlpciegen2_180(struct bcma_drv_pcie2 *pcie2)
5339 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, PCIE2_PMCR_REFUP);
5340 ++ pcie2_set32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 0x1f);
5343 ++static void pciedev_crwlpciegen2_182(struct bcma_drv_pcie2 *pcie2)
5345 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR, PCIE2_SBMBX);
5346 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, 1 << 0);
5349 ++static void pciedev_reg_pm_clk_period(struct bcma_drv_pcie2 *pcie2)
5351 ++ struct bcma_drv_cc *drv_cc = &pcie2->core->bus->drv_cc;
5352 ++ u8 core_rev = pcie2->core->id.rev;
5353 ++ u32 alp_khz, pm_value;
5355 ++ if (core_rev <= 13) {
5356 ++ alp_khz = bcma_pmu_get_alp_clock(drv_cc) / 1000;
5357 ++ pm_value = (1000000 * 2) / alp_khz;
5358 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDADDR,
5359 ++ PCIE2_PVT_REG_PM_CLK_PERIOD);
5360 ++ pcie2_write32(pcie2, BCMA_CORE_PCIE2_CONFIGINDDATA, pm_value);
5361 ++ }
5364 ++void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
5366 ++ struct bcma_chipinfo *ci = &pcie2->core->bus->chipinfo;
5367 ++ u32 tmp;
5369 ++ tmp = pcie2_read32(pcie2, BCMA_CORE_PCIE2_SPROM(54));
5370 ++ if ((tmp & 0xe) >> 1 == 2)
5371 ++ bcma_core_pcie2_cfg_write(pcie2, 0x4e0, 0x17);
5373 ++ /* TODO: Do we need pcie_reqsize? */
5375 ++ if (ci->id == BCMA_CHIP_ID_BCM4360 && ci->rev > 3)
5376 ++ bcma_core_pcie2_war_delay_perst_enab(pcie2, true);
5377 ++ bcma_core_pcie2_hw_ltr_war(pcie2);
5378 ++ pciedev_crwlpciegen2(pcie2);
5379 ++ pciedev_reg_pm_clk_period(pcie2);
5380 ++ pciedev_crwlpciegen2_180(pcie2);
5381 ++ pciedev_crwlpciegen2_182(pcie2);
5383 +--- a/drivers/bcma/host_pci.c
5384 ++++ b/drivers/bcma/host_pci.c
5385 +@@ -208,6 +208,9 @@ static int bcma_host_pci_probe(struct pc
5386 + bus->boardinfo.vendor = bus->host_pci->subsystem_vendor;
5387 + bus->boardinfo.type = bus->host_pci->subsystem_device;
5389 ++ /* Initialize struct, detect chip */
5390 ++ bcma_init_bus(bus);
5392 + /* Register */
5393 + err = bcma_bus_register(bus);
5394 + if (err)
5395 +@@ -279,7 +282,10 @@ static const struct pci_device_id bcma_p
5396 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
5397 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
5398 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
5399 ++ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
5400 ++ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
5401 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
5402 ++ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xA8DB */
5403 + { 0, },
5404 + };
5405 + MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl);
5406 +--- a/drivers/bcma/main.c
5407 ++++ b/drivers/bcma/main.c
5408 +@@ -10,6 +10,7 @@
5409 + #include <linux/platform_device.h>
5410 + #include <linux/bcma/bcma.h>
5411 + #include <linux/slab.h>
5412 ++#include <linux/of_address.h>
5414 + MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
5415 + MODULE_LICENSE("GPL");
5416 +@@ -120,56 +121,121 @@ static void bcma_release_core_dev(struct
5417 + kfree(core);
5420 +-static int bcma_register_cores(struct bcma_bus *bus)
5421 ++static bool bcma_is_core_needed_early(u16 core_id)
5423 ++ switch (core_id) {
5424 ++ case BCMA_CORE_NS_NAND:
5425 ++ case BCMA_CORE_NS_QSPI:
5426 ++ return true;
5427 ++ }
5429 ++ return false;
5432 ++#ifdef CONFIG_OF
5433 ++static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
5434 ++ struct bcma_device *core)
5436 ++ struct device_node *node;
5437 ++ u64 size;
5438 ++ const __be32 *reg;
5440 ++ if (!parent || !parent->dev.of_node)
5441 ++ return NULL;
5443 ++ for_each_child_of_node(parent->dev.of_node, node) {
5444 ++ reg = of_get_address(node, 0, &size, NULL);
5445 ++ if (!reg)
5446 ++ continue;
5447 ++ if (of_translate_address(node, reg) == core->addr)
5448 ++ return node;
5449 ++ }
5450 ++ return NULL;
5453 ++static void bcma_of_fill_device(struct platform_device *parent,
5454 ++ struct bcma_device *core)
5456 ++ struct device_node *node;
5458 ++ node = bcma_of_find_child_device(parent, core);
5459 ++ if (node)
5460 ++ core->dev.of_node = node;
5462 ++#else
5463 ++static void bcma_of_fill_device(struct platform_device *parent,
5464 ++ struct bcma_device *core)
5467 ++#endif /* CONFIG_OF */
5469 ++static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
5471 ++ int err;
5473 ++ core->dev.release = bcma_release_core_dev;
5474 ++ core->dev.bus = &bcma_bus_type;
5475 ++ dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
5477 ++ switch (bus->hosttype) {
5478 ++ case BCMA_HOSTTYPE_PCI:
5479 ++ core->dev.parent = &bus->host_pci->dev;
5480 ++ core->dma_dev = &bus->host_pci->dev;
5481 ++ core->irq = bus->host_pci->irq;
5482 ++ break;
5483 ++ case BCMA_HOSTTYPE_SOC:
5484 ++ core->dev.dma_mask = &core->dev.coherent_dma_mask;
5485 ++ if (bus->host_pdev) {
5486 ++ core->dma_dev = &bus->host_pdev->dev;
5487 ++ core->dev.parent = &bus->host_pdev->dev;
5488 ++ bcma_of_fill_device(bus->host_pdev, core);
5489 ++ } else {
5490 ++ core->dma_dev = &core->dev;
5491 ++ }
5492 ++ break;
5493 ++ case BCMA_HOSTTYPE_SDIO:
5494 ++ break;
5495 ++ }
5497 ++ err = device_register(&core->dev);
5498 ++ if (err) {
5499 ++ bcma_err(bus, "Could not register dev for core 0x%03X\n",
5500 ++ core->id.id);
5501 ++ put_device(&core->dev);
5502 ++ return;
5503 ++ }
5504 ++ core->dev_registered = true;
5507 ++static int bcma_register_devices(struct bcma_bus *bus)
5509 + struct bcma_device *core;
5510 +- int err, dev_id = 0;
5511 ++ int err;
5513 + list_for_each_entry(core, &bus->cores, list) {
5514 + /* We support that cores ourself */
5515 + switch (core->id.id) {
5516 + case BCMA_CORE_4706_CHIPCOMMON:
5517 + case BCMA_CORE_CHIPCOMMON:
5518 ++ case BCMA_CORE_NS_CHIPCOMMON_B:
5519 + case BCMA_CORE_PCI:
5520 + case BCMA_CORE_PCIE:
5521 ++ case BCMA_CORE_PCIE2:
5522 + case BCMA_CORE_MIPS_74K:
5523 + case BCMA_CORE_4706_MAC_GBIT_COMMON:
5524 + continue;
5527 ++ /* Early cores were already registered */
5528 ++ if (bcma_is_core_needed_early(core->id.id))
5529 ++ continue;
5531 + /* Only first GMAC core on BCM4706 is connected and working */
5532 + if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
5533 + core->core_unit > 0)
5534 + continue;
5536 +- core->dev.release = bcma_release_core_dev;
5537 +- core->dev.bus = &bcma_bus_type;
5538 +- dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
5540 +- switch (bus->hosttype) {
5541 +- case BCMA_HOSTTYPE_PCI:
5542 +- core->dev.parent = &bus->host_pci->dev;
5543 +- core->dma_dev = &bus->host_pci->dev;
5544 +- core->irq = bus->host_pci->irq;
5545 +- break;
5546 +- case BCMA_HOSTTYPE_SOC:
5547 +- core->dev.dma_mask = &core->dev.coherent_dma_mask;
5548 +- core->dma_dev = &core->dev;
5549 +- break;
5550 +- case BCMA_HOSTTYPE_SDIO:
5551 +- break;
5552 +- }
5554 +- err = device_register(&core->dev);
5555 +- if (err) {
5556 +- bcma_err(bus,
5557 +- "Could not register dev for core 0x%03X\n",
5558 +- core->id.id);
5559 +- put_device(&core->dev);
5560 +- continue;
5561 +- }
5562 +- core->dev_registered = true;
5563 +- dev_id++;
5564 ++ bcma_register_core(bus, core);
5567 + #ifdef CONFIG_BCMA_DRIVER_MIPS
5568 +@@ -246,6 +312,12 @@ int bcma_bus_register(struct bcma_bus *b
5569 + bcma_core_chipcommon_early_init(&bus->drv_cc);
5572 ++ /* Cores providing flash access go before SPROM init */
5573 ++ list_for_each_entry(core, &bus->cores, list) {
5574 ++ if (bcma_is_core_needed_early(core->id.id))
5575 ++ bcma_register_core(bus, core);
5576 ++ }
5578 + /* Try to get SPROM */
5579 + err = bcma_sprom_get(bus);
5580 + if (err == -ENOENT) {
5581 +@@ -260,6 +332,13 @@ int bcma_bus_register(struct bcma_bus *b
5582 + bcma_core_chipcommon_init(&bus->drv_cc);
5585 ++ /* Init CC core */
5586 ++ core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B);
5587 ++ if (core) {
5588 ++ bus->drv_cc_b.core = core;
5589 ++ bcma_core_chipcommon_b_init(&bus->drv_cc_b);
5590 ++ }
5592 + /* Init MIPS core */
5593 + core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
5594 + if (core) {
5595 +@@ -281,6 +360,13 @@ int bcma_bus_register(struct bcma_bus *b
5596 + bcma_core_pci_init(&bus->drv_pci[1]);
5599 ++ /* Init PCIe Gen 2 core */
5600 ++ core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0);
5601 ++ if (core) {
5602 ++ bus->drv_pcie2.core = core;
5603 ++ bcma_core_pcie2_init(&bus->drv_pcie2);
5604 ++ }
5606 + /* Init GBIT MAC COMMON core */
5607 + core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
5608 + if (core) {
5609 +@@ -289,7 +375,7 @@ int bcma_bus_register(struct bcma_bus *b
5612 + /* Register found cores */
5613 +- bcma_register_cores(bus);
5614 ++ bcma_register_devices(bus);
5616 + bcma_info(bus, "Bus registered\n");
5618 +@@ -307,6 +393,8 @@ void bcma_bus_unregister(struct bcma_bus
5619 + else if (err)
5620 + bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
5622 ++ bcma_core_chipcommon_b_free(&bus->drv_cc_b);
5624 + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
5625 + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
5626 + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
5627 +@@ -326,8 +414,6 @@ int __init bcma_bus_early_register(struc
5628 + struct bcma_device *core;
5629 + struct bcma_device_id match;
5631 +- bcma_init_bus(bus);
5633 + match.manuf = BCMA_MANUF_BCM;
5634 + match.id = bcma_cc_core_id(bus);
5635 + match.class = BCMA_CL_SIM;
5636 +@@ -486,6 +572,11 @@ static int __init bcma_modinit(void)
5637 + if (err)
5638 + return err;
5640 ++ err = bcma_host_soc_register_driver();
5641 ++ if (err) {
5642 ++ pr_err("SoC host initialization failed\n");
5643 ++ err = 0;
5644 ++ }
5645 + #ifdef CONFIG_BCMA_HOST_PCI
5646 + err = bcma_host_pci_init();
5647 + if (err) {
5648 +@@ -503,6 +594,7 @@ static void __exit bcma_modexit(void)
5649 + #ifdef CONFIG_BCMA_HOST_PCI
5650 + bcma_host_pci_exit();
5651 + #endif
5652 ++ bcma_host_soc_unregister_driver();
5653 + bus_unregister(&bcma_bus_type);
5655 + module_exit(bcma_modexit)
5656 +--- a/drivers/bcma/sprom.c
5657 ++++ b/drivers/bcma/sprom.c
5658 +@@ -201,6 +201,23 @@ static int bcma_sprom_valid(struct bcma_
5659 + SPEX(_field[7], _offset + 14, _mask, _shift); \
5660 + } while (0)
5662 ++static s8 sprom_extract_antgain(const u16 *in, u16 offset, u16 mask, u16 shift)
5664 ++ u16 v;
5665 ++ u8 gain;
5667 ++ v = in[SPOFF(offset)];
5668 ++ gain = (v & mask) >> shift;
5669 ++ if (gain == 0xFF) {
5670 ++ gain = 8; /* If unset use 2dBm */
5671 ++ } else {
5672 ++ /* Q5.2 Fractional part is stored in 0xC0 */
5673 ++ gain = ((gain & 0xC0) >> 6) | ((gain & 0x3F) << 2);
5674 ++ }
5676 ++ return (s8)gain;
5679 + static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
5681 + u16 v, o;
5682 +@@ -381,14 +398,22 @@ static void bcma_sprom_extract_r8(struct
5683 + SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, ~0, 0);
5685 + /* Extract the antenna gain values. */
5686 +- SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
5687 +- SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
5688 +- SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
5689 +- SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
5690 +- SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
5691 +- SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
5692 +- SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
5693 +- SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
5694 ++ bus->sprom.antenna_gain.a0 = sprom_extract_antgain(sprom,
5695 ++ SSB_SPROM8_AGAIN01,
5696 ++ SSB_SPROM8_AGAIN0,
5697 ++ SSB_SPROM8_AGAIN0_SHIFT);
5698 ++ bus->sprom.antenna_gain.a1 = sprom_extract_antgain(sprom,
5699 ++ SSB_SPROM8_AGAIN01,
5700 ++ SSB_SPROM8_AGAIN1,
5701 ++ SSB_SPROM8_AGAIN1_SHIFT);
5702 ++ bus->sprom.antenna_gain.a2 = sprom_extract_antgain(sprom,
5703 ++ SSB_SPROM8_AGAIN23,
5704 ++ SSB_SPROM8_AGAIN2,
5705 ++ SSB_SPROM8_AGAIN2_SHIFT);
5706 ++ bus->sprom.antenna_gain.a3 = sprom_extract_antgain(sprom,
5707 ++ SSB_SPROM8_AGAIN23,
5708 ++ SSB_SPROM8_AGAIN3,
5709 ++ SSB_SPROM8_AGAIN3_SHIFT);
5711 + SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
5712 + SSB_SPROM8_LEDDC_ON_SHIFT);
5713 +@@ -509,6 +534,8 @@ static bool bcma_sprom_onchip_available(
5714 + /* for these chips OTP is always available */
5715 + present = true;
5716 + break;
5717 ++ case BCMA_CHIP_ID_BCM43131:
5718 ++ case BCMA_CHIP_ID_BCM43217:
5719 + case BCMA_CHIP_ID_BCM43227:
5720 + case BCMA_CHIP_ID_BCM43228:
5721 + case BCMA_CHIP_ID_BCM43428:
5722 +--- a/include/linux/bcma/bcma.h
5723 ++++ b/include/linux/bcma/bcma.h
5724 +@@ -6,6 +6,7 @@
5726 + #include <linux/bcma/bcma_driver_chipcommon.h>
5727 + #include <linux/bcma/bcma_driver_pci.h>
5728 ++#include <linux/bcma/bcma_driver_pcie2.h>
5729 + #include <linux/bcma/bcma_driver_mips.h>
5730 + #include <linux/bcma/bcma_driver_gmac_cmn.h>
5731 + #include <linux/ssb/ssb.h> /* SPROM sharing */
5732 +@@ -72,17 +73,17 @@ struct bcma_host_ops {
5733 + /* Core-ID values. */
5734 + #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
5735 + #define BCMA_CORE_4706_CHIPCOMMON 0x500
5736 +-#define BCMA_CORE_PCIEG2 0x501
5737 +-#define BCMA_CORE_DMA 0x502
5738 +-#define BCMA_CORE_SDIO3 0x503
5739 +-#define BCMA_CORE_USB20 0x504
5740 +-#define BCMA_CORE_USB30 0x505
5741 +-#define BCMA_CORE_A9JTAG 0x506
5742 +-#define BCMA_CORE_DDR23 0x507
5743 +-#define BCMA_CORE_ROM 0x508
5744 +-#define BCMA_CORE_NAND 0x509
5745 +-#define BCMA_CORE_QSPI 0x50A
5746 +-#define BCMA_CORE_CHIPCOMMON_B 0x50B
5747 ++#define BCMA_CORE_NS_PCIEG2 0x501
5748 ++#define BCMA_CORE_NS_DMA 0x502
5749 ++#define BCMA_CORE_NS_SDIO3 0x503
5750 ++#define BCMA_CORE_NS_USB20 0x504
5751 ++#define BCMA_CORE_NS_USB30 0x505
5752 ++#define BCMA_CORE_NS_A9JTAG 0x506
5753 ++#define BCMA_CORE_NS_DDR23 0x507
5754 ++#define BCMA_CORE_NS_ROM 0x508
5755 ++#define BCMA_CORE_NS_NAND 0x509
5756 ++#define BCMA_CORE_NS_QSPI 0x50A
5757 ++#define BCMA_CORE_NS_CHIPCOMMON_B 0x50B
5758 + #define BCMA_CORE_4706_SOC_RAM 0x50E
5759 + #define BCMA_CORE_ARMCA9 0x510
5760 + #define BCMA_CORE_4706_MAC_GBIT 0x52D
5761 +@@ -157,6 +158,9 @@ struct bcma_host_ops {
5762 + /* Chip IDs of PCIe devices */
5763 + #define BCMA_CHIP_ID_BCM4313 0x4313
5764 + #define BCMA_CHIP_ID_BCM43142 43142
5765 ++#define BCMA_CHIP_ID_BCM43131 43131
5766 ++#define BCMA_CHIP_ID_BCM43217 43217
5767 ++#define BCMA_CHIP_ID_BCM43222 43222
5768 + #define BCMA_CHIP_ID_BCM43224 43224
5769 + #define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
5770 + #define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
5771 +@@ -263,7 +267,7 @@ struct bcma_device {
5772 + u8 core_unit;
5774 + u32 addr;
5775 +- u32 addr1;
5776 ++ u32 addr_s[8];
5777 + u32 wrap;
5779 + void __iomem *io_addr;
5780 +@@ -319,6 +323,8 @@ struct bcma_bus {
5781 + struct pci_dev *host_pci;
5782 + /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
5783 + struct sdio_func *host_sdio;
5784 ++ /* Pointer to platform device (only for BCMA_HOSTTYPE_SOC) */
5785 ++ struct platform_device *host_pdev;
5786 + };
5788 + struct bcma_chipinfo chipinfo;
5789 +@@ -328,11 +334,12 @@ struct bcma_bus {
5790 + struct bcma_device *mapped_core;
5791 + struct list_head cores;
5792 + u8 nr_cores;
5793 +- u8 init_done:1;
5794 + u8 num;
5796 + struct bcma_drv_cc drv_cc;
5797 ++ struct bcma_drv_cc_b drv_cc_b;
5798 + struct bcma_drv_pci drv_pci[2];
5799 ++ struct bcma_drv_pcie2 drv_pcie2;
5800 + struct bcma_drv_mips drv_mips;
5801 + struct bcma_drv_gmac_cmn drv_gmac_cmn;
5803 +--- /dev/null
5804 ++++ b/include/linux/bcma/bcma_driver_pcie2.h
5805 +@@ -0,0 +1,158 @@
5806 ++#ifndef LINUX_BCMA_DRIVER_PCIE2_H_
5807 ++#define LINUX_BCMA_DRIVER_PCIE2_H_
5809 ++#define BCMA_CORE_PCIE2_CLK_CONTROL 0x0000
5810 ++#define PCIE2_CLKC_RST_OE 0x0001 /* When set, drives PCI_RESET out to pin */
5811 ++#define PCIE2_CLKC_RST 0x0002 /* Value driven out to pin */
5812 ++#define PCIE2_CLKC_SPERST 0x0004 /* SurvivePeRst */
5813 ++#define PCIE2_CLKC_DISABLE_L1CLK_GATING 0x0010
5814 ++#define PCIE2_CLKC_DLYPERST 0x0100 /* Delay PeRst to CoE Core */
5815 ++#define PCIE2_CLKC_DISSPROMLD 0x0200 /* DisableSpromLoadOnPerst */
5816 ++#define PCIE2_CLKC_WAKE_MODE_L2 0x1000 /* Wake on L2 */
5817 ++#define BCMA_CORE_PCIE2_RC_PM_CONTROL 0x0004
5818 ++#define BCMA_CORE_PCIE2_RC_PM_STATUS 0x0008
5819 ++#define BCMA_CORE_PCIE2_EP_PM_CONTROL 0x000C
5820 ++#define BCMA_CORE_PCIE2_EP_PM_STATUS 0x0010
5821 ++#define BCMA_CORE_PCIE2_EP_LTR_CONTROL 0x0014
5822 ++#define BCMA_CORE_PCIE2_EP_LTR_STATUS 0x0018
5823 ++#define BCMA_CORE_PCIE2_EP_OBFF_STATUS 0x001C
5824 ++#define BCMA_CORE_PCIE2_PCIE_ERR_STATUS 0x0020
5825 ++#define BCMA_CORE_PCIE2_RC_AXI_CONFIG 0x0100
5826 ++#define BCMA_CORE_PCIE2_EP_AXI_CONFIG 0x0104
5827 ++#define BCMA_CORE_PCIE2_RXDEBUG_STATUS0 0x0108
5828 ++#define BCMA_CORE_PCIE2_RXDEBUG_CONTROL0 0x010C
5829 ++#define BCMA_CORE_PCIE2_CONFIGINDADDR 0x0120
5830 ++#define BCMA_CORE_PCIE2_CONFIGINDDATA 0x0124
5831 ++#define BCMA_CORE_PCIE2_MDIOCONTROL 0x0128
5832 ++#define BCMA_CORE_PCIE2_MDIOWRDATA 0x012C
5833 ++#define BCMA_CORE_PCIE2_MDIORDDATA 0x0130
5834 ++#define BCMA_CORE_PCIE2_DATAINTF 0x0180
5835 ++#define BCMA_CORE_PCIE2_D2H_INTRLAZY_0 0x0188
5836 ++#define BCMA_CORE_PCIE2_H2D_INTRLAZY_0 0x018c
5837 ++#define BCMA_CORE_PCIE2_H2D_INTSTAT_0 0x0190
5838 ++#define BCMA_CORE_PCIE2_H2D_INTMASK_0 0x0194
5839 ++#define BCMA_CORE_PCIE2_D2H_INTSTAT_0 0x0198
5840 ++#define BCMA_CORE_PCIE2_D2H_INTMASK_0 0x019c
5841 ++#define BCMA_CORE_PCIE2_LTR_STATE 0x01A0 /* Latency Tolerance Reporting */
5842 ++#define PCIE2_LTR_ACTIVE 2
5843 ++#define PCIE2_LTR_ACTIVE_IDLE 1
5844 ++#define PCIE2_LTR_SLEEP 0
5845 ++#define PCIE2_LTR_FINAL_MASK 0x300
5846 ++#define PCIE2_LTR_FINAL_SHIFT 8
5847 ++#define BCMA_CORE_PCIE2_PWR_INT_STATUS 0x01A4
5848 ++#define BCMA_CORE_PCIE2_PWR_INT_MASK 0x01A8
5849 ++#define BCMA_CORE_PCIE2_CFG_ADDR 0x01F8
5850 ++#define BCMA_CORE_PCIE2_CFG_DATA 0x01FC
5851 ++#define BCMA_CORE_PCIE2_SYS_EQ_PAGE 0x0200
5852 ++#define BCMA_CORE_PCIE2_SYS_MSI_PAGE 0x0204
5853 ++#define BCMA_CORE_PCIE2_SYS_MSI_INTREN 0x0208
5854 ++#define BCMA_CORE_PCIE2_SYS_MSI_CTRL0 0x0210
5855 ++#define BCMA_CORE_PCIE2_SYS_MSI_CTRL1 0x0214
5856 ++#define BCMA_CORE_PCIE2_SYS_MSI_CTRL2 0x0218
5857 ++#define BCMA_CORE_PCIE2_SYS_MSI_CTRL3 0x021C
5858 ++#define BCMA_CORE_PCIE2_SYS_MSI_CTRL4 0x0220
5859 ++#define BCMA_CORE_PCIE2_SYS_MSI_CTRL5 0x0224
5860 ++#define BCMA_CORE_PCIE2_SYS_EQ_HEAD0 0x0250
5861 ++#define BCMA_CORE_PCIE2_SYS_EQ_TAIL0 0x0254
5862 ++#define BCMA_CORE_PCIE2_SYS_EQ_HEAD1 0x0258
5863 ++#define BCMA_CORE_PCIE2_SYS_EQ_TAIL1 0x025C
5864 ++#define BCMA_CORE_PCIE2_SYS_EQ_HEAD2 0x0260
5865 ++#define BCMA_CORE_PCIE2_SYS_EQ_TAIL2 0x0264
5866 ++#define BCMA_CORE_PCIE2_SYS_EQ_HEAD3 0x0268
5867 ++#define BCMA_CORE_PCIE2_SYS_EQ_TAIL3 0x026C
5868 ++#define BCMA_CORE_PCIE2_SYS_EQ_HEAD4 0x0270
5869 ++#define BCMA_CORE_PCIE2_SYS_EQ_TAIL4 0x0274
5870 ++#define BCMA_CORE_PCIE2_SYS_EQ_HEAD5 0x0278
5871 ++#define BCMA_CORE_PCIE2_SYS_EQ_TAIL5 0x027C
5872 ++#define BCMA_CORE_PCIE2_SYS_RC_INTX_EN 0x0330
5873 ++#define BCMA_CORE_PCIE2_SYS_RC_INTX_CSR 0x0334
5874 ++#define BCMA_CORE_PCIE2_SYS_MSI_REQ 0x0340
5875 ++#define BCMA_CORE_PCIE2_SYS_HOST_INTR_EN 0x0344
5876 ++#define BCMA_CORE_PCIE2_SYS_HOST_INTR_CSR 0x0348
5877 ++#define BCMA_CORE_PCIE2_SYS_HOST_INTR0 0x0350
5878 ++#define BCMA_CORE_PCIE2_SYS_HOST_INTR1 0x0354
5879 ++#define BCMA_CORE_PCIE2_SYS_HOST_INTR2 0x0358
5880 ++#define BCMA_CORE_PCIE2_SYS_HOST_INTR3 0x035C
5881 ++#define BCMA_CORE_PCIE2_SYS_EP_INT_EN0 0x0360
5882 ++#define BCMA_CORE_PCIE2_SYS_EP_INT_EN1 0x0364
5883 ++#define BCMA_CORE_PCIE2_SYS_EP_INT_CSR0 0x0370
5884 ++#define BCMA_CORE_PCIE2_SYS_EP_INT_CSR1 0x0374
5885 ++#define BCMA_CORE_PCIE2_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2))
5886 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_0 0x0C00
5887 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_1 0x0C04
5888 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_2 0x0C08
5889 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_3 0x0C0C
5890 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_4 0x0C10
5891 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_5 0x0C14
5892 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_6 0x0C18
5893 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP0_7 0x0C1C
5894 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_0 0x0C20
5895 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_1 0x0C24
5896 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_2 0x0C28
5897 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_3 0x0C2C
5898 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_4 0x0C30
5899 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_5 0x0C34
5900 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_6 0x0C38
5901 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP0_7 0x0C3C
5902 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP1 0x0C80
5903 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP1 0x0C88
5904 ++#define BCMA_CORE_PCIE2_FUNC0_IMAP2 0x0CC0
5905 ++#define BCMA_CORE_PCIE2_FUNC1_IMAP2 0x0CC8
5906 ++#define BCMA_CORE_PCIE2_IARR0_LOWER 0x0D00
5907 ++#define BCMA_CORE_PCIE2_IARR0_UPPER 0x0D04
5908 ++#define BCMA_CORE_PCIE2_IARR1_LOWER 0x0D08
5909 ++#define BCMA_CORE_PCIE2_IARR1_UPPER 0x0D0C
5910 ++#define BCMA_CORE_PCIE2_IARR2_LOWER 0x0D10
5911 ++#define BCMA_CORE_PCIE2_IARR2_UPPER 0x0D14
5912 ++#define BCMA_CORE_PCIE2_OARR0 0x0D20
5913 ++#define BCMA_CORE_PCIE2_OARR1 0x0D28
5914 ++#define BCMA_CORE_PCIE2_OARR2 0x0D30
5915 ++#define BCMA_CORE_PCIE2_OMAP0_LOWER 0x0D40
5916 ++#define BCMA_CORE_PCIE2_OMAP0_UPPER 0x0D44
5917 ++#define BCMA_CORE_PCIE2_OMAP1_LOWER 0x0D48
5918 ++#define BCMA_CORE_PCIE2_OMAP1_UPPER 0x0D4C
5919 ++#define BCMA_CORE_PCIE2_OMAP2_LOWER 0x0D50
5920 ++#define BCMA_CORE_PCIE2_OMAP2_UPPER 0x0D54
5921 ++#define BCMA_CORE_PCIE2_FUNC1_IARR1_SIZE 0x0D58
5922 ++#define BCMA_CORE_PCIE2_FUNC1_IARR2_SIZE 0x0D5C
5923 ++#define BCMA_CORE_PCIE2_MEM_CONTROL 0x0F00
5924 ++#define BCMA_CORE_PCIE2_MEM_ECC_ERRLOG0 0x0F04
5925 ++#define BCMA_CORE_PCIE2_MEM_ECC_ERRLOG1 0x0F08
5926 ++#define BCMA_CORE_PCIE2_LINK_STATUS 0x0F0C
5927 ++#define BCMA_CORE_PCIE2_STRAP_STATUS 0x0F10
5928 ++#define BCMA_CORE_PCIE2_RESET_STATUS 0x0F14
5929 ++#define BCMA_CORE_PCIE2_RESETEN_IN_LINKDOWN 0x0F18
5930 ++#define BCMA_CORE_PCIE2_MISC_INTR_EN 0x0F1C
5931 ++#define BCMA_CORE_PCIE2_TX_DEBUG_CFG 0x0F20
5932 ++#define BCMA_CORE_PCIE2_MISC_CONFIG 0x0F24
5933 ++#define BCMA_CORE_PCIE2_MISC_STATUS 0x0F28
5934 ++#define BCMA_CORE_PCIE2_INTR_EN 0x0F30
5935 ++#define BCMA_CORE_PCIE2_INTR_CLEAR 0x0F34
5936 ++#define BCMA_CORE_PCIE2_INTR_STATUS 0x0F38
5938 ++/* PCIE gen2 config regs */
5939 ++#define PCIE2_INTSTATUS 0x090
5940 ++#define PCIE2_INTMASK 0x094
5941 ++#define PCIE2_SBMBX 0x098
5943 ++#define PCIE2_PMCR_REFUP 0x1814 /* Trefup time */
5945 ++#define PCIE2_CAP_DEVSTSCTRL2_OFFSET 0xD4
5946 ++#define PCIE2_CAP_DEVSTSCTRL2_LTRENAB 0x400
5947 ++#define PCIE2_PVT_REG_PM_CLK_PERIOD 0x184c
5949 ++struct bcma_drv_pcie2 {
5950 ++ struct bcma_device *core;
5951 ++};
5953 ++#define pcie2_read16(pcie2, offset) bcma_read16((pcie2)->core, offset)
5954 ++#define pcie2_read32(pcie2, offset) bcma_read32((pcie2)->core, offset)
5955 ++#define pcie2_write16(pcie2, offset, val) bcma_write16((pcie2)->core, offset, val)
5956 ++#define pcie2_write32(pcie2, offset, val) bcma_write32((pcie2)->core, offset, val)
5958 ++#define pcie2_set32(pcie2, offset, set) bcma_set32((pcie2)->core, offset, set)
5959 ++#define pcie2_mask32(pcie2, offset, mask) bcma_mask32((pcie2)->core, offset, mask)
5961 ++void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
5963 ++#endif /* LINUX_BCMA_DRIVER_PCIE2_H_ */
5964 +--- a/drivers/bcma/scan.c
5965 ++++ b/drivers/bcma/scan.c
5966 +@@ -32,17 +32,17 @@ static const struct bcma_device_id_name
5967 + { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
5968 + { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
5969 + { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
5970 +- { BCMA_CORE_PCIEG2, "PCIe Gen 2" },
5971 +- { BCMA_CORE_DMA, "DMA" },
5972 +- { BCMA_CORE_SDIO3, "SDIO3" },
5973 +- { BCMA_CORE_USB20, "USB 2.0" },
5974 +- { BCMA_CORE_USB30, "USB 3.0" },
5975 +- { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" },
5976 +- { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" },
5977 +- { BCMA_CORE_ROM, "ROM" },
5978 +- { BCMA_CORE_NAND, "NAND flash controller" },
5979 +- { BCMA_CORE_QSPI, "SPI flash controller" },
5980 +- { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" },
5981 ++ { BCMA_CORE_NS_PCIEG2, "PCIe Gen 2" },
5982 ++ { BCMA_CORE_NS_DMA, "DMA" },
5983 ++ { BCMA_CORE_NS_SDIO3, "SDIO3" },
5984 ++ { BCMA_CORE_NS_USB20, "USB 2.0" },
5985 ++ { BCMA_CORE_NS_USB30, "USB 3.0" },
5986 ++ { BCMA_CORE_NS_A9JTAG, "ARM Cortex A9 JTAG" },
5987 ++ { BCMA_CORE_NS_DDR23, "Denali DDR2/DDR3 memory controller" },
5988 ++ { BCMA_CORE_NS_ROM, "ROM" },
5989 ++ { BCMA_CORE_NS_NAND, "NAND flash controller" },
5990 ++ { BCMA_CORE_NS_QSPI, "SPI flash controller" },
5991 ++ { BCMA_CORE_NS_CHIPCOMMON_B, "Chipcommon B" },
5992 + { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" },
5993 + { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
5994 + { BCMA_CORE_ALTA, "ALTA (I2S)" },
5995 +@@ -276,7 +276,7 @@ static int bcma_get_next_core(struct bcm
5996 + struct bcma_device *core)
5998 + u32 tmp;
5999 +- u8 i, j;
6000 ++ u8 i, j, k;
6001 + s32 cia, cib;
6002 + u8 ports[2], wrappers[2];
6004 +@@ -314,6 +314,7 @@ static int bcma_get_next_core(struct bcm
6005 + /* Some specific cores don't need wrappers */
6006 + switch (core->id.id) {
6007 + case BCMA_CORE_4706_MAC_GBIT_COMMON:
6008 ++ case BCMA_CORE_NS_CHIPCOMMON_B:
6009 + /* Not used yet: case BCMA_CORE_OOB_ROUTER: */
6010 + break;
6011 + default:
6012 +@@ -367,6 +368,7 @@ static int bcma_get_next_core(struct bcm
6013 + core->addr = tmp;
6015 + /* get & parse slave ports */
6016 ++ k = 0;
6017 + for (i = 0; i < ports[1]; i++) {
6018 + for (j = 0; ; j++) {
6019 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
6020 +@@ -376,9 +378,9 @@ static int bcma_get_next_core(struct bcm
6021 + /* pr_debug("erom: slave port %d "
6022 + * "has %d descriptors\n", i, j); */
6023 + break;
6024 +- } else {
6025 +- if (i == 0 && j == 0)
6026 +- core->addr1 = tmp;
6027 ++ } else if (k < ARRAY_SIZE(core->addr_s)) {
6028 ++ core->addr_s[k] = tmp;
6029 ++ k++;
6033 +@@ -421,10 +423,13 @@ static int bcma_get_next_core(struct bcm
6034 + core->io_addr = ioremap_nocache(core->addr, BCMA_CORE_SIZE);
6035 + if (!core->io_addr)
6036 + return -ENOMEM;
6037 +- core->io_wrap = ioremap_nocache(core->wrap, BCMA_CORE_SIZE);
6038 +- if (!core->io_wrap) {
6039 +- iounmap(core->io_addr);
6040 +- return -ENOMEM;
6041 ++ if (core->wrap) {
6042 ++ core->io_wrap = ioremap_nocache(core->wrap,
6043 ++ BCMA_CORE_SIZE);
6044 ++ if (!core->io_wrap) {
6045 ++ iounmap(core->io_addr);
6046 ++ return -ENOMEM;
6047 ++ }
6050 + return 0;
6051 +@@ -434,9 +439,7 @@ void bcma_init_bus(struct bcma_bus *bus)
6053 + s32 tmp;
6054 + struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
6056 +- if (bus->init_done)
6057 +- return;
6058 ++ char chip_id[8];
6060 + INIT_LIST_HEAD(&bus->cores);
6061 + bus->nr_cores = 0;
6062 +@@ -447,10 +450,11 @@ void bcma_init_bus(struct bcma_bus *bus)
6063 + chipinfo->id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
6064 + chipinfo->rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
6065 + chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
6066 +- bcma_info(bus, "Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
6067 +- chipinfo->id, chipinfo->rev, chipinfo->pkg);
6069 +- bus->init_done = true;
6070 ++ snprintf(chip_id, ARRAY_SIZE(chip_id),
6071 ++ (chipinfo->id > 0x9999) ? "%d" : "0x%04X", chipinfo->id);
6072 ++ bcma_info(bus, "Found chip with id %s, rev 0x%02X and package 0x%02X\n",
6073 ++ chip_id, chipinfo->rev, chipinfo->pkg);
6076 + int bcma_bus_scan(struct bcma_bus *bus)
6077 +@@ -460,8 +464,6 @@ int bcma_bus_scan(struct bcma_bus *bus)
6079 + int err, core_num = 0;
6081 +- bcma_init_bus(bus);
6083 + erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
6084 + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
6085 + eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
6086 +--- a/drivers/bcma/host_soc.c
6087 ++++ b/drivers/bcma/host_soc.c
6088 +@@ -7,6 +7,9 @@
6090 + #include "bcma_private.h"
6091 + #include "scan.h"
6092 ++#include <linux/slab.h>
6093 ++#include <linux/module.h>
6094 ++#include <linux/of_address.h>
6095 + #include <linux/bcma/bcma.h>
6096 + #include <linux/bcma/bcma_soc.h>
6098 +@@ -134,12 +137,16 @@ static void bcma_host_soc_block_write(st
6100 + static u32 bcma_host_soc_aread32(struct bcma_device *core, u16 offset)
6102 ++ if (WARN_ONCE(!core->io_wrap, "Accessed core has no wrapper/agent\n"))
6103 ++ return ~0;
6104 + return readl(core->io_wrap + offset);
6107 + static void bcma_host_soc_awrite32(struct bcma_device *core, u16 offset,
6108 + u32 value)
6110 ++ if (WARN_ONCE(!core->io_wrap, "Accessed core has no wrapper/agent\n"))
6111 ++ return;
6112 + writel(value, core->io_wrap + offset);
6115 +@@ -161,7 +168,6 @@ static const struct bcma_host_ops bcma_h
6116 + int __init bcma_host_soc_register(struct bcma_soc *soc)
6118 + struct bcma_bus *bus = &soc->bus;
6119 +- int err;
6121 + /* iomap only first core. We have to read some register on this core
6122 + * to scan the bus.
6123 +@@ -173,11 +179,100 @@ int __init bcma_host_soc_register(struct
6124 + /* Host specific */
6125 + bus->hosttype = BCMA_HOSTTYPE_SOC;
6126 + bus->ops = &bcma_host_soc_ops;
6127 ++ bus->host_pdev = NULL;
6129 +- /* Register */
6130 ++ /* Initialize struct, detect chip */
6131 ++ bcma_init_bus(bus);
6133 ++ return 0;
6136 ++int __init bcma_host_soc_init(struct bcma_soc *soc)
6138 ++ struct bcma_bus *bus = &soc->bus;
6139 ++ int err;
6141 ++ /* Scan bus and initialize it */
6142 + err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
6143 + if (err)
6144 + iounmap(bus->mmio);
6146 + return err;
6149 ++#ifdef CONFIG_OF
6150 ++static int bcma_host_soc_probe(struct platform_device *pdev)
6152 ++ struct device *dev = &pdev->dev;
6153 ++ struct device_node *np = dev->of_node;
6154 ++ struct bcma_bus *bus;
6155 ++ int err;
6157 ++ /* Alloc */
6158 ++ bus = devm_kzalloc(dev, sizeof(*bus), GFP_KERNEL);
6159 ++ if (!bus)
6160 ++ return -ENOMEM;
6162 ++ /* Map MMIO */
6163 ++ bus->mmio = of_iomap(np, 0);
6164 ++ if (!bus->mmio)
6165 ++ return -ENOMEM;
6167 ++ /* Host specific */
6168 ++ bus->hosttype = BCMA_HOSTTYPE_SOC;
6169 ++ bus->ops = &bcma_host_soc_ops;
6170 ++ bus->host_pdev = pdev;
6172 ++ /* Initialize struct, detect chip */
6173 ++ bcma_init_bus(bus);
6175 ++ /* Register */
6176 ++ err = bcma_bus_register(bus);
6177 ++ if (err)
6178 ++ goto err_unmap_mmio;
6180 ++ platform_set_drvdata(pdev, bus);
6182 ++ return err;
6184 ++err_unmap_mmio:
6185 ++ iounmap(bus->mmio);
6186 ++ return err;
6189 ++static int bcma_host_soc_remove(struct platform_device *pdev)
6191 ++ struct bcma_bus *bus = platform_get_drvdata(pdev);
6193 ++ bcma_bus_unregister(bus);
6194 ++ iounmap(bus->mmio);
6195 ++ platform_set_drvdata(pdev, NULL);
6197 ++ return 0;
6200 ++static const struct of_device_id bcma_host_soc_of_match[] = {
6201 ++ { .compatible = "brcm,bus-axi", },
6202 ++ {},
6203 ++};
6204 ++MODULE_DEVICE_TABLE(of, bcma_host_soc_of_match);
6206 ++static struct platform_driver bcma_host_soc_driver = {
6207 ++ .driver = {
6208 ++ .name = "bcma-host-soc",
6209 ++ .of_match_table = bcma_host_soc_of_match,
6210 ++ },
6211 ++ .probe = bcma_host_soc_probe,
6212 ++ .remove = bcma_host_soc_remove,
6213 ++};
6215 ++int __init bcma_host_soc_register_driver(void)
6217 ++ return platform_driver_register(&bcma_host_soc_driver);
6220 ++void __exit bcma_host_soc_unregister_driver(void)
6222 ++ platform_driver_unregister(&bcma_host_soc_driver);
6224 ++#endif /* CONFIG_OF */
6225 +--- a/drivers/bcma/driver_mips.c
6226 ++++ b/drivers/bcma/driver_mips.c
6227 +@@ -21,6 +21,14 @@
6228 + #include <linux/serial_reg.h>
6229 + #include <linux/time.h>
6231 ++enum bcma_boot_dev {
6232 ++ BCMA_BOOT_DEV_UNK = 0,
6233 ++ BCMA_BOOT_DEV_ROM,
6234 ++ BCMA_BOOT_DEV_PARALLEL,
6235 ++ BCMA_BOOT_DEV_SERIAL,
6236 ++ BCMA_BOOT_DEV_NAND,
6237 ++};
6239 + static const char * const part_probes[] = { "bcm47xxpart", NULL };
6241 + static struct physmap_flash_data bcma_pflash_data = {
6242 +@@ -229,11 +237,51 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
6244 + EXPORT_SYMBOL(bcma_cpu_clock);
6246 ++static enum bcma_boot_dev bcma_boot_dev(struct bcma_bus *bus)
6248 ++ struct bcma_drv_cc *cc = &bus->drv_cc;
6249 ++ u8 cc_rev = cc->core->id.rev;
6251 ++ if (cc_rev == 42) {
6252 ++ struct bcma_device *core;
6254 ++ core = bcma_find_core(bus, BCMA_CORE_NS_ROM);
6255 ++ if (core) {
6256 ++ switch (bcma_aread32(core, BCMA_IOST) &
6257 ++ BCMA_NS_ROM_IOST_BOOT_DEV_MASK) {
6258 ++ case BCMA_NS_ROM_IOST_BOOT_DEV_NOR:
6259 ++ return BCMA_BOOT_DEV_SERIAL;
6260 ++ case BCMA_NS_ROM_IOST_BOOT_DEV_NAND:
6261 ++ return BCMA_BOOT_DEV_NAND;
6262 ++ case BCMA_NS_ROM_IOST_BOOT_DEV_ROM:
6263 ++ default:
6264 ++ return BCMA_BOOT_DEV_ROM;
6265 ++ }
6266 ++ }
6267 ++ } else {
6268 ++ if (cc_rev == 38) {
6269 ++ if (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)
6270 ++ return BCMA_BOOT_DEV_NAND;
6271 ++ else if (cc->status & BIT(5))
6272 ++ return BCMA_BOOT_DEV_ROM;
6273 ++ }
6275 ++ if ((cc->capabilities & BCMA_CC_CAP_FLASHT) ==
6276 ++ BCMA_CC_FLASHT_PARA)
6277 ++ return BCMA_BOOT_DEV_PARALLEL;
6278 ++ else
6279 ++ return BCMA_BOOT_DEV_SERIAL;
6280 ++ }
6282 ++ return BCMA_BOOT_DEV_SERIAL;
6285 + static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
6287 + struct bcma_bus *bus = mcore->core->bus;
6288 + struct bcma_drv_cc *cc = &bus->drv_cc;
6289 + struct bcma_pflash *pflash = &cc->pflash;
6290 ++ enum bcma_boot_dev boot_dev;
6292 + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
6293 + case BCMA_CC_FLASHT_STSER:
6294 +@@ -269,6 +317,20 @@ static void bcma_core_mips_flash_detect(
6295 + bcma_nflash_init(cc);
6299 ++ /* Determine flash type this SoC boots from */
6300 ++ boot_dev = bcma_boot_dev(bus);
6301 ++ switch (boot_dev) {
6302 ++ case BCMA_BOOT_DEV_PARALLEL:
6303 ++ case BCMA_BOOT_DEV_SERIAL:
6304 ++ /* TODO: Init NVRAM using BCMA_SOC_FLASH2 window */
6305 ++ break;
6306 ++ case BCMA_BOOT_DEV_NAND:
6307 ++ /* TODO: Init NVRAM using BCMA_SOC_FLASH1 window */
6308 ++ break;
6309 ++ default:
6310 ++ break;
6311 ++ }
6314 + void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
6315 +--- a/include/linux/bcma/bcma_regs.h
6316 ++++ b/include/linux/bcma/bcma_regs.h
6317 +@@ -39,6 +39,11 @@
6318 + #define BCMA_RESET_CTL_RESET 0x0001
6319 + #define BCMA_RESET_ST 0x0804
6321 ++#define BCMA_NS_ROM_IOST_BOOT_DEV_MASK 0x0003
6322 ++#define BCMA_NS_ROM_IOST_BOOT_DEV_NOR 0x0000
6323 ++#define BCMA_NS_ROM_IOST_BOOT_DEV_NAND 0x0001
6324 ++#define BCMA_NS_ROM_IOST_BOOT_DEV_ROM 0x0002
6326 + /* BCMA PCI config space registers. */
6327 + #define BCMA_PCI_PMCSR 0x44
6328 + #define BCMA_PCI_PE 0x100
6329 +--- a/drivers/usb/host/bcma-hcd.c
6330 ++++ b/drivers/usb/host/bcma-hcd.c
6331 +@@ -237,7 +237,7 @@ static int bcma_hcd_probe(struct bcma_de
6332 + bcma_hcd_init_chip(dev);
6334 + /* In AI chips EHCI is addrspace 0, OHCI is 1 */
6335 +- ohci_addr = dev->addr1;
6336 ++ ohci_addr = dev->addr_s[0];
6337 + if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749)
6338 + && chipinfo->rev == 0)
6339 + ohci_addr = 0x18009000;
6340 +--- a/drivers/bcma/bcma_private.h
6341 ++++ b/drivers/bcma/bcma_private.h
6342 +@@ -50,6 +50,10 @@ void bcma_chipco_serial_init(struct bcma
6343 + extern struct platform_device bcma_pflash_dev;
6344 + #endif /* CONFIG_BCMA_DRIVER_MIPS */
6346 ++/* driver_chipcommon_b.c */
6347 ++int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb);
6348 ++void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb);
6350 + /* driver_chipcommon_pmu.c */
6351 + u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
6352 + u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
6353 +@@ -84,6 +88,20 @@ extern int __init bcma_host_pci_init(voi
6354 + extern void __exit bcma_host_pci_exit(void);
6355 + #endif /* CONFIG_BCMA_HOST_PCI */
6357 ++/* host_soc.c */
6358 ++#if defined(CONFIG_BCMA_HOST_SOC) && defined(CONFIG_OF)
6359 ++extern int __init bcma_host_soc_register_driver(void);
6360 ++extern void __exit bcma_host_soc_unregister_driver(void);
6361 ++#else
6362 ++static inline int __init bcma_host_soc_register_driver(void)
6364 ++ return 0;
6366 ++static inline void __exit bcma_host_soc_unregister_driver(void)
6369 ++#endif /* CONFIG_BCMA_HOST_SOC && CONFIG_OF */
6371 + /* driver_pci.c */
6372 + u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
6374 +--- /dev/null
6375 ++++ b/drivers/bcma/driver_chipcommon_b.c
6376 +@@ -0,0 +1,61 @@
6377 ++/*
6378 ++ * Broadcom specific AMBA
6379 ++ * ChipCommon B Unit driver
6380 ++ *
6381 ++ * Copyright 2014, Hauke Mehrtens <hauke@hauke-m.de>
6382 ++ *
6383 ++ * Licensed under the GNU/GPL. See COPYING for details.
6384 ++ */
6386 ++#include "bcma_private.h"
6387 ++#include <linux/export.h>
6388 ++#include <linux/bcma/bcma.h>
6390 ++static bool bcma_wait_reg(struct bcma_bus *bus, void __iomem *addr, u32 mask,
6391 ++ u32 value, int timeout)
6393 ++ unsigned long deadline = jiffies + timeout;
6394 ++ u32 val;
6396 ++ do {
6397 ++ val = readl(addr);
6398 ++ if ((val & mask) == value)
6399 ++ return true;
6400 ++ cpu_relax();
6401 ++ udelay(10);
6402 ++ } while (!time_after_eq(jiffies, deadline));
6404 ++ bcma_err(bus, "Timeout waiting for register %p\n", addr);
6406 ++ return false;
6409 ++void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value)
6411 ++ struct bcma_bus *bus = ccb->core->bus;
6413 ++ writel(offset, ccb->mii + 0x00);
6414 ++ bcma_wait_reg(bus, ccb->mii + 0x00, 0x0100, 0x0000, 100);
6415 ++ writel(value, ccb->mii + 0x04);
6416 ++ bcma_wait_reg(bus, ccb->mii + 0x00, 0x0100, 0x0000, 100);
6418 ++EXPORT_SYMBOL_GPL(bcma_chipco_b_mii_write);
6420 ++int bcma_core_chipcommon_b_init(struct bcma_drv_cc_b *ccb)
6422 ++ if (ccb->setup_done)
6423 ++ return 0;
6425 ++ ccb->setup_done = 1;
6426 ++ ccb->mii = ioremap_nocache(ccb->core->addr_s[1], BCMA_CORE_SIZE);
6427 ++ if (!ccb->mii)
6428 ++ return -ENOMEM;
6430 ++ return 0;
6433 ++void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb)
6435 ++ if (ccb->mii)
6436 ++ iounmap(ccb->mii);
6438 +--- a/include/linux/bcma/bcma_driver_chipcommon.h
6439 ++++ b/include/linux/bcma/bcma_driver_chipcommon.h
6440 +@@ -644,6 +644,12 @@ struct bcma_drv_cc {
6441 + #endif
6442 + };
6444 ++struct bcma_drv_cc_b {
6445 ++ struct bcma_device *core;
6446 ++ u8 setup_done:1;
6447 ++ void __iomem *mii;
6448 ++};
6450 + /* Register access */
6451 + #define bcma_cc_read32(cc, offset) \
6452 + bcma_read32((cc)->core, offset)
6453 +@@ -699,4 +705,6 @@ extern void bcma_pmu_spuravoid_pllupdate
6455 + extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
6457 ++void bcma_chipco_b_mii_write(struct bcma_drv_cc_b *ccb, u32 offset, u32 value);
6459 + #endif /* LINUX_BCMA_DRIVER_CC_H_ */
6460 +--- a/arch/mips/bcm47xx/setup.c
6461 ++++ b/arch/mips/bcm47xx/setup.c
6462 +@@ -202,6 +202,10 @@ static void __init bcm47xx_register_bcma
6464 + err = bcma_host_soc_register(&bcm47xx_bus.bcma);
6465 + if (err)
6466 ++ panic("Failed to register BCMA bus (err %d)", err);
6468 ++ err = bcma_host_soc_init(&bcm47xx_bus.bcma);
6469 ++ if (err)
6470 + panic("Failed to initialize BCMA bus (err %d)", err);
6472 + bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL);
6473 +--- a/include/linux/bcma/bcma_soc.h
6474 ++++ b/include/linux/bcma/bcma_soc.h
6475 +@@ -10,6 +10,7 @@ struct bcma_soc {
6476 + };
6478 + int __init bcma_host_soc_register(struct bcma_soc *soc);
6479 ++int __init bcma_host_soc_init(struct bcma_soc *soc);
6481 + int bcma_bus_register(struct bcma_bus *bus);
6483 +--- /dev/null
6484 ++++ b/Documentation/devicetree/bindings/bus/bcma.txt
6485 +@@ -0,0 +1,32 @@
6486 ++Driver for ARM AXI Bus with Broadcom Plugins (bcma)
6488 ++Required properties:
6490 ++- compatible : brcm,bus-axi
6492 ++- reg : iomem address range of chipcommon core
6494 ++The cores on the AXI bus are automatically detected by bcma with the
6495 ++memory ranges they are using and they get registered afterwards.
6497 ++The top-level axi bus may contain children representing attached cores
6498 ++(devices). This is needed since some hardware details can't be auto
6499 ++detected (e.g. IRQ numbers). Also some of the cores may be responsible
6500 ++for extra things, e.g. ChipCommon providing access to the GPIO chip.
6502 ++Example:
6504 ++ axi@18000000 {
6505 ++ compatible = "brcm,bus-axi";
6506 ++ reg = <0x18000000 0x1000>;
6507 ++ ranges = <0x00000000 0x18000000 0x00100000>;
6508 ++ #address-cells = <1>;
6509 ++ #size-cells = <1>;
6511 ++ chipcommon {
6512 ++ reg = <0x00000000 0x1000>;
6514 ++ gpio-controller;
6515 ++ #gpio-cells = <2>;
6516 ++ };
6517 ++ };
6518 diff --git a/target/linux/generic/patches-3.16/049-mtd-bcm47xxpart-find-NVRAM-partitions-in-middle-bloc.patch b/target/linux/generic/patches-3.16/049-mtd-bcm47xxpart-find-NVRAM-partitions-in-middle-bloc.patch
6519 new file mode 100644
6520 index 000000000000..48f8d36da410
6521 --- /dev/null
6522 +++ b/target/linux/generic/patches-3.16/049-mtd-bcm47xxpart-find-NVRAM-partitions-in-middle-bloc.patch
6523 @@ -0,0 +1,19 @@
6524 +--- a/drivers/mtd/bcm47xxpart.c
6525 ++++ b/drivers/mtd/bcm47xxpart.c
6526 +@@ -199,6 +199,16 @@ static int bcm47xxpart_parse(struct mtd_
6527 + continue;
6530 ++ /* New (ARM?) devices may have NVRAM in some middle block. Last
6531 ++ * block will be checked later, so skip it.
6532 ++ */
6533 ++ if (offset != master->size - blocksize &&
6534 ++ buf[0x000 / 4] == NVRAM_HEADER) {
6535 ++ bcm47xxpart_add_part(&parts[curr_part++], "nvram",
6536 ++ offset, 0);
6537 ++ continue;
6538 ++ }
6540 + /* Read middle of the block */
6541 + if (mtd_read(master, offset + 0x8000, 0x4,
6542 + &bytes_read, (uint8_t *)buf) < 0) {
6543 diff --git a/target/linux/generic/patches-3.16/060-hso_devices.patch b/target/linux/generic/patches-3.16/060-hso_devices.patch
6544 new file mode 100644
6545 index 000000000000..153daa7f306b
6546 --- /dev/null
6547 +++ b/target/linux/generic/patches-3.16/060-hso_devices.patch
6548 @@ -0,0 +1,36 @@
6549 +--- a/drivers/net/usb/hso.c
6550 ++++ b/drivers/net/usb/hso.c
6551 +@@ -467,8 +467,10 @@ static const struct usb_device_id hso_id
6552 + {USB_DEVICE(0x0af0, 0x8400)},
6553 + {USB_DEVICE(0x0af0, 0x8600)},
6554 + {USB_DEVICE(0x0af0, 0x8800)},
6555 +- {USB_DEVICE(0x0af0, 0x8900)},
6556 +- {USB_DEVICE(0x0af0, 0x9000)},
6557 ++ {USB_DEVICE(0x0af0, 0x8900)}, /* GTM 67xx */
6558 ++ {USB_DEVICE(0x0af0, 0x9000)}, /* GTM 66xx */
6559 ++ {USB_DEVICE(0x0af0, 0x9200)}, /* GTM 67xxWFS */
6560 ++ {USB_DEVICE(0x0af0, 0x9300)}, /* GTM 66xxWFS */
6561 + {USB_DEVICE(0x0af0, 0xd035)},
6562 + {USB_DEVICE(0x0af0, 0xd055)},
6563 + {USB_DEVICE(0x0af0, 0xd155)},
6564 +--- a/drivers/usb/storage/unusual_devs.h
6565 ++++ b/drivers/usb/storage/unusual_devs.h
6566 +@@ -1280,6 +1280,18 @@ UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0
6567 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
6568 + 0 ),
6570 ++UNUSUAL_DEV( 0x0af0, 0x9200, 0x0000, 0x0000,
6571 ++ "Option",
6572 ++ "Globetrotter 67xxWFS SD-Card",
6573 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
6574 ++ 0 ),
6576 ++UNUSUAL_DEV( 0x0af0, 0x9300, 0x0000, 0x0000,
6577 ++ "Option",
6578 ++ "Globetrotter 66xxWFS SD-Card",
6579 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
6580 ++ 0 ),
6582 + UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000,
6583 + "Option",
6584 + "GI 070x SD-Card",
6585 diff --git a/target/linux/generic/patches-3.16/061-arm_xz_decompressor_build_fix.patch b/target/linux/generic/patches-3.16/061-arm_xz_decompressor_build_fix.patch
6586 new file mode 100644
6587 index 000000000000..e69ca259a65e
6588 --- /dev/null
6589 +++ b/target/linux/generic/patches-3.16/061-arm_xz_decompressor_build_fix.patch
6590 @@ -0,0 +1,10 @@
6591 +--- a/arch/arm/boot/compressed/decompress.c
6592 ++++ b/arch/arm/boot/compressed/decompress.c
6593 +@@ -48,6 +48,7 @@ extern char * strstr(const char * s1, co
6594 + #ifdef CONFIG_KERNEL_XZ
6595 + #define memmove memmove
6596 + #define memcpy memcpy
6597 ++extern char * strstr(const char *, const char *);
6598 + #include "../../../../lib/decompress_unxz.c"
6599 + #endif
6601 diff --git a/target/linux/generic/patches-3.16/062-mips_decompressor_build_fix.patch b/target/linux/generic/patches-3.16/062-mips_decompressor_build_fix.patch
6602 new file mode 100644
6603 index 000000000000..52c45c38e095
6604 --- /dev/null
6605 +++ b/target/linux/generic/patches-3.16/062-mips_decompressor_build_fix.patch
6606 @@ -0,0 +1,66 @@
6607 +From 0db3db45f5bd6df4bdc03bbd5dec672e16164c4e Mon Sep 17 00:00:00 2001
6608 +From: Florian Fainelli <florian@openwrt.org>
6609 +Date: Mon, 12 Nov 2012 12:31:55 +0100
6610 +Subject: [PATCH] MIPS: decompressor: fix build failure on memcpy() in
6611 + decompress.c
6613 +The decompress.c file includes linux/kernel.h which causes the following
6614 +inclusion chain to be pulled:
6615 +linux/kernel.h ->
6616 + linux/dynamic_debug.h ->
6617 + linux/string.h ->
6618 + asm/string.h
6620 +We end up having a the GCC builtin + architecture specific memcpy() expanding
6621 +into this:
6623 +void *({ size_t __len = (size_t n); void *__ret; if
6624 +(__builtin_constant_p(size_t n) && __len >= 64) __ret = memcpy((void *dest),
6625 +(const void *src), __len); else __ret = __builtin_memcpy((void *dest), (const
6626 +void *src), __len); __ret; })
6628 + [memcpy implementation in decompress.c starts here]
6629 + int i;
6630 + const char *s = src;
6631 + char *d = dest;
6633 + for (i = 0; i < n; i++)
6634 + d[i] = s[i];
6635 + return dest;
6638 +raising the following compilation error:
6639 +arch/mips/boot/compressed/decompress.c:46:8: error: expected identifier or '('
6640 +before '{' token
6642 +There are at least three possibilities to fix this issue:
6644 +1) define _LINUX_STRING_H_ at the beginning of decompress.c to prevent
6645 + further linux/string.h definitions and declarations from being used, and add
6646 + an explicit strstr() declaration for linux/dynamic_debug.h
6648 +2) remove the inclusion of linux/kernel.h because we actually use no definition
6649 + or declaration from this header file
6651 +3) undefine memcpy or re-define memcpy to memcpy thus resulting in picking up
6652 + the local memcpy() implementation to this compilation unit
6654 +This patch uses the second option which is the less intrusive one.
6656 +Signed-off-by: Florian Fainelli <florian@openwrt.org>
6657 +---
6658 + arch/mips/boot/compressed/decompress.c | 2 --
6659 + 1 file changed, 2 deletions(-)
6661 +--- a/arch/mips/boot/compressed/decompress.c
6662 ++++ b/arch/mips/boot/compressed/decompress.c
6663 +@@ -10,9 +10,7 @@
6664 + * Free Software Foundation; either version 2 of the License, or (at your
6665 + * option) any later version.
6666 + */
6668 + #include <linux/types.h>
6669 +-#include <linux/kernel.h>
6671 + #include <asm/addrspace.h>
6673 diff --git a/target/linux/generic/patches-3.16/100-overlayfs.patch b/target/linux/generic/patches-3.16/100-overlayfs.patch
6674 new file mode 100644
6675 index 000000000000..50f714f8e4a0
6676 --- /dev/null
6677 +++ b/target/linux/generic/patches-3.16/100-overlayfs.patch
6678 @@ -0,0 +1,4120 @@
6679 +--- a/Documentation/filesystems/Locking
6680 ++++ b/Documentation/filesystems/Locking
6681 +@@ -67,6 +67,7 @@ prototypes:
6682 + struct file *, unsigned open_flag,
6683 + umode_t create_mode, int *opened);
6684 + int (*tmpfile) (struct inode *, struct dentry *, umode_t);
6685 ++ int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
6687 + locking rules:
6688 + all may block
6689 +@@ -96,6 +97,7 @@ fiemap: no
6690 + update_time: no
6691 + atomic_open: yes
6692 + tmpfile: no
6693 ++dentry_open: no
6695 + Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
6696 + victim.
6697 +--- /dev/null
6698 ++++ b/Documentation/filesystems/overlayfs.txt
6699 +@@ -0,0 +1,198 @@
6700 ++Written by: Neil Brown <neilb@suse.de>
6702 ++Overlay Filesystem
6703 ++==================
6705 ++This document describes a prototype for a new approach to providing
6706 ++overlay-filesystem functionality in Linux (sometimes referred to as
6707 ++union-filesystems). An overlay-filesystem tries to present a
6708 ++filesystem which is the result over overlaying one filesystem on top
6709 ++of the other.
6711 ++The result will inevitably fail to look exactly like a normal
6712 ++filesystem for various technical reasons. The expectation is that
6713 ++many use cases will be able to ignore these differences.
6715 ++This approach is 'hybrid' because the objects that appear in the
6716 ++filesystem do not all appear to belong to that filesystem. In many
6717 ++cases an object accessed in the union will be indistinguishable
6718 ++from accessing the corresponding object from the original filesystem.
6719 ++This is most obvious from the 'st_dev' field returned by stat(2).
6721 ++While directories will report an st_dev from the overlay-filesystem,
6722 ++all non-directory objects will report an st_dev from the lower or
6723 ++upper filesystem that is providing the object. Similarly st_ino will
6724 ++only be unique when combined with st_dev, and both of these can change
6725 ++over the lifetime of a non-directory object. Many applications and
6726 ++tools ignore these values and will not be affected.
6728 ++Upper and Lower
6729 ++---------------
6731 ++An overlay filesystem combines two filesystems - an 'upper' filesystem
6732 ++and a 'lower' filesystem. When a name exists in both filesystems, the
6733 ++object in the 'upper' filesystem is visible while the object in the
6734 ++'lower' filesystem is either hidden or, in the case of directories,
6735 ++merged with the 'upper' object.
6737 ++It would be more correct to refer to an upper and lower 'directory
6738 ++tree' rather than 'filesystem' as it is quite possible for both
6739 ++directory trees to be in the same filesystem and there is no
6740 ++requirement that the root of a filesystem be given for either upper or
6741 ++lower.
6743 ++The lower filesystem can be any filesystem supported by Linux and does
6744 ++not need to be writable. The lower filesystem can even be another
6745 ++overlayfs. The upper filesystem will normally be writable and if it
6746 ++is it must support the creation of trusted.* extended attributes, and
6747 ++must provide valid d_type in readdir responses, so NFS is not suitable.
6749 ++A read-only overlay of two read-only filesystems may use any
6750 ++filesystem type.
6752 ++Directories
6753 ++-----------
6755 ++Overlaying mainly involves directories. If a given name appears in both
6756 ++upper and lower filesystems and refers to a non-directory in either,
6757 ++then the lower object is hidden - the name refers only to the upper
6758 ++object.
6760 ++Where both upper and lower objects are directories, a merged directory
6761 ++is formed.
6763 ++At mount time, the two directories given as mount options "lowerdir" and
6764 ++"upperdir" are combined into a merged directory:
6766 ++ mount -t overlayfs overlayfs -olowerdir=/lower,upperdir=/upper,\
6767 ++workdir=/work /merged
6769 ++The "workdir" needs to be an empty directory on the same filesystem
6770 ++as upperdir.
6772 ++Then whenever a lookup is requested in such a merged directory, the
6773 ++lookup is performed in each actual directory and the combined result
6774 ++is cached in the dentry belonging to the overlay filesystem. If both
6775 ++actual lookups find directories, both are stored and a merged
6776 ++directory is created, otherwise only one is stored: the upper if it
6777 ++exists, else the lower.
6779 ++Only the lists of names from directories are merged. Other content
6780 ++such as metadata and extended attributes are reported for the upper
6781 ++directory only. These attributes of the lower directory are hidden.
6783 ++whiteouts and opaque directories
6784 ++--------------------------------
6786 ++In order to support rm and rmdir without changing the lower
6787 ++filesystem, an overlay filesystem needs to record in the upper filesystem
6788 ++that files have been removed. This is done using whiteouts and opaque
6789 ++directories (non-directories are always opaque).
6791 ++A whiteout is created as a character device with 0/0 device number.
6792 ++When a whiteout is found in the upper level of a merged directory, any
6793 ++matching name in the lower level is ignored, and the whiteout itself
6794 ++is also hidden.
6796 ++A directory is made opaque by setting the xattr "trusted.overlay.opaque"
6797 ++to "y". Where the upper filesystem contains an opaque directory, any
6798 ++directory in the lower filesystem with the same name is ignored.
6800 ++readdir
6801 ++-------
6803 ++When a 'readdir' request is made on a merged directory, the upper and
6804 ++lower directories are each read and the name lists merged in the
6805 ++obvious way (upper is read first, then lower - entries that already
6806 ++exist are not re-added). This merged name list is cached in the
6807 ++'struct file' and so remains as long as the file is kept open. If the
6808 ++directory is opened and read by two processes at the same time, they
6809 ++will each have separate caches. A seekdir to the start of the
6810 ++directory (offset 0) followed by a readdir will cause the cache to be
6811 ++discarded and rebuilt.
6813 ++This means that changes to the merged directory do not appear while a
6814 ++directory is being read. This is unlikely to be noticed by many
6815 ++programs.
6817 ++seek offsets are assigned sequentially when the directories are read.
6818 ++Thus if
6819 ++ - read part of a directory
6820 ++ - remember an offset, and close the directory
6821 ++ - re-open the directory some time later
6822 ++ - seek to the remembered offset
6824 ++there may be little correlation between the old and new locations in
6825 ++the list of filenames, particularly if anything has changed in the
6826 ++directory.
6828 ++Readdir on directories that are not merged is simply handled by the
6829 ++underlying directory (upper or lower).
6832 ++Non-directories
6833 ++---------------
6835 ++Objects that are not directories (files, symlinks, device-special
6836 ++files etc.) are presented either from the upper or lower filesystem as
6837 ++appropriate. When a file in the lower filesystem is accessed in a way
6838 ++the requires write-access, such as opening for write access, changing
6839 ++some metadata etc., the file is first copied from the lower filesystem
6840 ++to the upper filesystem (copy_up). Note that creating a hard-link
6841 ++also requires copy_up, though of course creation of a symlink does
6842 ++not.
6844 ++The copy_up may turn out to be unnecessary, for example if the file is
6845 ++opened for read-write but the data is not modified.
6847 ++The copy_up process first makes sure that the containing directory
6848 ++exists in the upper filesystem - creating it and any parents as
6849 ++necessary. It then creates the object with the same metadata (owner,
6850 ++mode, mtime, symlink-target etc.) and then if the object is a file, the
6851 ++data is copied from the lower to the upper filesystem. Finally any
6852 ++extended attributes are copied up.
6854 ++Once the copy_up is complete, the overlay filesystem simply
6855 ++provides direct access to the newly created file in the upper
6856 ++filesystem - future operations on the file are barely noticed by the
6857 ++overlay filesystem (though an operation on the name of the file such as
6858 ++rename or unlink will of course be noticed and handled).
6861 ++Non-standard behavior
6862 ++---------------------
6864 ++The copy_up operation essentially creates a new, identical file and
6865 ++moves it over to the old name. The new file may be on a different
6866 ++filesystem, so both st_dev and st_ino of the file may change.
6868 ++Any open files referring to this inode will access the old data and
6869 ++metadata. Similarly any file locks obtained before copy_up will not
6870 ++apply to the copied up file.
6872 ++On a file opened with O_RDONLY fchmod(2), fchown(2), futimesat(2) and
6873 ++fsetxattr(2) will fail with EROFS.
6875 ++If a file with multiple hard links is copied up, then this will
6876 ++"break" the link. Changes will not be propagated to other names
6877 ++referring to the same inode.
6879 ++Symlinks in /proc/PID/ and /proc/PID/fd which point to a non-directory
6880 ++object in overlayfs will not contain valid absolute paths, only
6881 ++relative paths leading up to the filesystem's root. This will be
6882 ++fixed in the future.
6884 ++Some operations are not atomic, for example a crash during copy_up or
6885 ++rename will leave the filesystem in an inconsistent state. This will
6886 ++be addressed in the future.
6888 ++Changes to underlying filesystems
6889 ++---------------------------------
6891 ++Offline changes, when the overlay is not mounted, are allowed to either
6892 ++the upper or the lower trees.
6894 ++Changes to the underlying filesystems while part of a mounted overlay
6895 ++filesystem are not allowed. If the underlying filesystem is changed,
6896 ++the behavior of the overlay is undefined, though it will not result in
6897 ++a crash or deadlock.
6898 +--- a/Documentation/filesystems/vfs.txt
6899 ++++ b/Documentation/filesystems/vfs.txt
6900 +@@ -364,6 +364,7 @@ struct inode_operations {
6901 + int (*atomic_open)(struct inode *, struct dentry *, struct file *,
6902 + unsigned open_flag, umode_t create_mode, int *opened);
6903 + int (*tmpfile) (struct inode *, struct dentry *, umode_t);
6904 ++ int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
6905 + };
6907 + Again, all methods are called without any locks being held, unless
6908 +@@ -696,6 +697,12 @@ struct address_space_operations {
6909 + but instead uses bmap to find out where the blocks in the file
6910 + are and uses those addresses directly.
6912 ++ dentry_open: this is an alternative to f_op->open(), the difference is that
6913 ++ this method may open a file not necessarily originating from the same
6914 ++ filesystem as the one i_op->open() was called on. It may be
6915 ++ useful for stacking filesystems which want to allow native I/O directly
6916 ++ on underlying files.
6919 + invalidatepage: If a page has PagePrivate set, then invalidatepage
6920 + will be called when part or all of the page is to be removed
6921 +--- a/MAINTAINERS
6922 ++++ b/MAINTAINERS
6923 +@@ -6654,6 +6654,13 @@ F: drivers/scsi/osd/
6924 + F: include/scsi/osd_*
6925 + F: fs/exofs/
6927 ++OVERLAYFS FILESYSTEM
6928 ++M: Miklos Szeredi <miklos@szeredi.hu>
6929 ++L: linux-fsdevel@vger.kernel.org
6930 ++S: Supported
6931 ++F: fs/overlayfs/*
6932 ++F: Documentation/filesystems/overlayfs.txt
6934 + P54 WIRELESS DRIVER
6935 + M: Christian Lamparter <chunkeey@googlemail.com>
6936 + L: linux-wireless@vger.kernel.org
6937 +--- a/fs/Kconfig
6938 ++++ b/fs/Kconfig
6939 +@@ -67,6 +67,7 @@ source "fs/quota/Kconfig"
6941 + source "fs/autofs4/Kconfig"
6942 + source "fs/fuse/Kconfig"
6943 ++source "fs/overlayfs/Kconfig"
6945 + menu "Caches"
6947 +--- a/fs/Makefile
6948 ++++ b/fs/Makefile
6949 +@@ -104,6 +104,7 @@ obj-$(CONFIG_QNX6FS_FS) += qnx6/
6950 + obj-$(CONFIG_AUTOFS4_FS) += autofs4/
6951 + obj-$(CONFIG_ADFS_FS) += adfs/
6952 + obj-$(CONFIG_FUSE_FS) += fuse/
6953 ++obj-$(CONFIG_OVERLAYFS_FS) += overlayfs/
6954 + obj-$(CONFIG_UDF_FS) += udf/
6955 + obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/
6956 + obj-$(CONFIG_OMFS_FS) += omfs/
6957 +--- a/fs/btrfs/ioctl.c
6958 ++++ b/fs/btrfs/ioctl.c
6959 +@@ -763,23 +763,6 @@ out:
6960 + return ret;
6963 +-/* copy of check_sticky in fs/namei.c()
6964 +-* It's inline, so penalty for filesystems that don't use sticky bit is
6965 +-* minimal.
6966 +-*/
6967 +-static inline int btrfs_check_sticky(struct inode *dir, struct inode *inode)
6969 +- kuid_t fsuid = current_fsuid();
6971 +- if (!(dir->i_mode & S_ISVTX))
6972 +- return 0;
6973 +- if (uid_eq(inode->i_uid, fsuid))
6974 +- return 0;
6975 +- if (uid_eq(dir->i_uid, fsuid))
6976 +- return 0;
6977 +- return !capable(CAP_FOWNER);
6980 + /* copy of may_delete in fs/namei.c()
6981 + * Check whether we can remove a link victim from directory dir, check
6982 + * whether the type of victim is right.
6983 +@@ -815,8 +798,7 @@ static int btrfs_may_delete(struct inode
6984 + return error;
6985 + if (IS_APPEND(dir))
6986 + return -EPERM;
6987 +- if (btrfs_check_sticky(dir, victim->d_inode)||
6988 +- IS_APPEND(victim->d_inode)||
6989 ++ if (check_sticky(dir, victim->d_inode) || IS_APPEND(victim->d_inode) ||
6990 + IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6991 + return -EPERM;
6992 + if (isdir) {
6993 +--- a/fs/dcache.c
6994 ++++ b/fs/dcache.c
6995 +@@ -2622,6 +2622,7 @@ struct dentry *d_ancestor(struct dentry
6997 + return NULL;
6999 ++EXPORT_SYMBOL(d_ancestor);
7001 + /*
7002 + * This helper attempts to cope with remotely renamed directories
7003 +--- a/fs/ecryptfs/main.c
7004 ++++ b/fs/ecryptfs/main.c
7005 +@@ -566,6 +566,13 @@ static struct dentry *ecryptfs_mount(str
7006 + s->s_maxbytes = path.dentry->d_sb->s_maxbytes;
7007 + s->s_blocksize = path.dentry->d_sb->s_blocksize;
7008 + s->s_magic = ECRYPTFS_SUPER_MAGIC;
7009 ++ s->s_stack_depth = path.dentry->d_sb->s_stack_depth + 1;
7011 ++ rc = -EINVAL;
7012 ++ if (s->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
7013 ++ pr_err("eCryptfs: maximum fs stacking depth exceeded\n");
7014 ++ goto out_free;
7015 ++ }
7017 + inode = ecryptfs_get_inode(path.dentry->d_inode, s);
7018 + rc = PTR_ERR(inode);
7019 +--- a/fs/ext4/namei.c
7020 ++++ b/fs/ext4/namei.c
7021 +@@ -3169,6 +3169,39 @@ static void ext4_update_dir_count(handle
7025 ++static struct inode *ext4_whiteout_for_rename(struct ext4_renament *ent,
7026 ++ int credits, handle_t **h)
7028 ++ struct inode *wh;
7029 ++ handle_t *handle;
7030 ++ int retries = 0;
7032 ++ /*
7033 ++ * for inode block, sb block, group summaries,
7034 ++ * and inode bitmap
7035 ++ */
7036 ++ credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(ent->dir->i_sb) +
7037 ++ EXT4_XATTR_TRANS_BLOCKS + 4);
7038 ++retry:
7039 ++ wh = ext4_new_inode_start_handle(ent->dir, S_IFCHR | WHITEOUT_MODE,
7040 ++ &ent->dentry->d_name, 0, NULL,
7041 ++ EXT4_HT_DIR, credits);
7043 ++ handle = ext4_journal_current_handle();
7044 ++ if (IS_ERR(wh)) {
7045 ++ if (handle)
7046 ++ ext4_journal_stop(handle);
7047 ++ if (PTR_ERR(wh) == -ENOSPC &&
7048 ++ ext4_should_retry_alloc(ent->dir->i_sb, &retries))
7049 ++ goto retry;
7050 ++ } else {
7051 ++ *h = handle;
7052 ++ init_special_inode(wh, wh->i_mode, WHITEOUT_DEV);
7053 ++ wh->i_op = &ext4_special_inode_operations;
7054 ++ }
7055 ++ return wh;
7058 + /*
7059 + * Anybody can rename anything with this: the permission checks are left to the
7060 + * higher-level routines.
7061 +@@ -3177,8 +3210,9 @@ static void ext4_update_dir_count(handle
7062 + * while new_{dentry,inode) refers to the destination dentry/inode
7063 + * This comes from rename(const char *oldpath, const char *newpath)
7064 + */
7065 +-static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
7066 +- struct inode *new_dir, struct dentry *new_dentry)
7067 ++static int ext4_simple_rename(struct inode *old_dir, struct dentry *old_dentry,
7068 ++ struct inode *new_dir, struct dentry *new_dentry,
7069 ++ unsigned int flags)
7071 + handle_t *handle = NULL;
7072 + struct ext4_renament old = {
7073 +@@ -3192,6 +3226,9 @@ static int ext4_rename(struct inode *old
7074 + .inode = new_dentry->d_inode,
7075 + };
7076 + int retval;
7077 ++ struct inode *whiteout = NULL;
7078 ++ int credits;
7079 ++ u8 old_file_type;
7081 + dquot_initialize(old.dir);
7082 + dquot_initialize(new.dir);
7083 +@@ -3223,11 +3260,17 @@ static int ext4_rename(struct inode *old
7084 + if (new.inode && !test_opt(new.dir->i_sb, NO_AUTO_DA_ALLOC))
7085 + ext4_alloc_da_blocks(old.inode);
7087 +- handle = ext4_journal_start(old.dir, EXT4_HT_DIR,
7088 +- (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) +
7089 +- EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2));
7090 +- if (IS_ERR(handle))
7091 +- return PTR_ERR(handle);
7092 ++ credits = (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) +
7093 ++ EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
7094 ++ if (!(flags & RENAME_WHITEOUT)) {
7095 ++ handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits);
7096 ++ if (IS_ERR(handle))
7097 ++ return PTR_ERR(handle);
7098 ++ } else {
7099 ++ whiteout = ext4_whiteout_for_rename(&old, credits, &handle);
7100 ++ if (IS_ERR(whiteout))
7101 ++ return PTR_ERR(whiteout);
7102 ++ }
7104 + if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir))
7105 + ext4_handle_sync(handle);
7106 +@@ -3246,13 +3289,21 @@ static int ext4_rename(struct inode *old
7107 + if (retval)
7108 + goto end_rename;
7110 ++ old_file_type = old.de->file_type;
7111 ++ if (whiteout) {
7112 ++ retval = ext4_setent(handle, &old, whiteout->i_ino,
7113 ++ EXT4_FT_CHRDEV);
7114 ++ if (retval)
7115 ++ goto end_rename;
7116 ++ ext4_mark_inode_dirty(handle, whiteout);
7117 ++ }
7118 + if (!new.bh) {
7119 + retval = ext4_add_entry(handle, new.dentry, old.inode);
7120 + if (retval)
7121 + goto end_rename;
7122 + } else {
7123 + retval = ext4_setent(handle, &new,
7124 +- old.inode->i_ino, old.de->file_type);
7125 ++ old.inode->i_ino, old_file_type);
7126 + if (retval)
7127 + goto end_rename;
7129 +@@ -3264,10 +3315,12 @@ static int ext4_rename(struct inode *old
7130 + old.inode->i_ctime = ext4_current_time(old.inode);
7131 + ext4_mark_inode_dirty(handle, old.inode);
7133 +- /*
7134 +- * ok, that's it
7135 +- */
7136 +- ext4_rename_delete(handle, &old);
7137 ++ if (!whiteout) {
7138 ++ /*
7139 ++ * ok, that's it
7140 ++ */
7141 ++ ext4_rename_delete(handle, &old);
7142 ++ }
7144 + if (new.inode) {
7145 + ext4_dec_count(handle, new.inode);
7146 +@@ -3303,6 +3356,12 @@ end_rename:
7147 + brelse(old.dir_bh);
7148 + brelse(old.bh);
7149 + brelse(new.bh);
7150 ++ if (whiteout) {
7151 ++ if (retval)
7152 ++ drop_nlink(whiteout);
7153 ++ unlock_new_inode(whiteout);
7154 ++ iput(whiteout);
7155 ++ }
7156 + if (handle)
7157 + ext4_journal_stop(handle);
7158 + return retval;
7159 +@@ -3424,22 +3483,26 @@ end_rename:
7160 + return retval;
7163 ++static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
7164 ++ struct inode *new_dir, struct dentry *new_dentry)
7166 ++ return ext4_simple_rename(old_dir, old_dentry, new_dir, new_dentry, 0);
7169 + static int ext4_rename2(struct inode *old_dir, struct dentry *old_dentry,
7170 + struct inode *new_dir, struct dentry *new_dentry,
7171 + unsigned int flags)
7173 +- if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
7174 ++ if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
7175 + return -EINVAL;
7177 + if (flags & RENAME_EXCHANGE) {
7178 + return ext4_cross_rename(old_dir, old_dentry,
7179 + new_dir, new_dentry);
7181 +- /*
7182 +- * Existence checking was done by the VFS, otherwise "RENAME_NOREPLACE"
7183 +- * is equivalent to regular rename.
7184 +- */
7185 +- return ext4_rename(old_dir, old_dentry, new_dir, new_dentry);
7187 ++ return ext4_simple_rename(old_dir, old_dentry,
7188 ++ new_dir, new_dentry, flags);
7191 + /*
7192 +--- a/fs/internal.h
7193 ++++ b/fs/internal.h
7194 +@@ -42,7 +42,6 @@ extern void __init chrdev_init(void);
7195 + /*
7196 + * namei.c
7197 + */
7198 +-extern int __inode_permission(struct inode *, int);
7199 + extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
7200 + extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
7201 + const char *, unsigned int, struct path *);
7202 +@@ -135,12 +134,6 @@ extern ssize_t __kernel_write(struct fil
7203 + extern int rw_verify_area(int, struct file *, const loff_t *, size_t);
7205 + /*
7206 +- * splice.c
7207 +- */
7208 +-extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
7209 +- loff_t *opos, size_t len, unsigned int flags);
7211 +-/*
7212 + * pipe.c
7213 + */
7214 + extern const struct file_operations pipefifo_fops;
7215 +--- a/fs/namei.c
7216 ++++ b/fs/namei.c
7217 +@@ -415,6 +415,7 @@ int __inode_permission(struct inode *ino
7219 + return security_inode_permission(inode, mask);
7221 ++EXPORT_SYMBOL(__inode_permission);
7223 + /**
7224 + * sb_permission - Check superblock-level permissions
7225 +@@ -2367,22 +2368,17 @@ kern_path_mountpoint(int dfd, const char
7227 + EXPORT_SYMBOL(kern_path_mountpoint);
7229 +-/*
7230 +- * It's inline, so penalty for filesystems that don't use sticky bit is
7231 +- * minimal.
7232 +- */
7233 +-static inline int check_sticky(struct inode *dir, struct inode *inode)
7234 ++int __check_sticky(struct inode *dir, struct inode *inode)
7236 + kuid_t fsuid = current_fsuid();
7238 +- if (!(dir->i_mode & S_ISVTX))
7239 +- return 0;
7240 + if (uid_eq(inode->i_uid, fsuid))
7241 + return 0;
7242 + if (uid_eq(dir->i_uid, fsuid))
7243 + return 0;
7244 + return !capable_wrt_inode_uidgid(inode, CAP_FOWNER);
7246 ++EXPORT_SYMBOL(__check_sticky);
7248 + /*
7249 + * Check whether we can remove a link victim from directory dir, check
7250 +@@ -3048,9 +3044,12 @@ finish_open_created:
7251 + error = may_open(&nd->path, acc_mode, open_flag);
7252 + if (error)
7253 + goto out;
7254 +- file->f_path.mnt = nd->path.mnt;
7255 +- error = finish_open(file, nd->path.dentry, NULL, opened);
7256 +- if (error) {
7258 ++ BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
7259 ++ error = vfs_open(&nd->path, file, current_cred());
7260 ++ if (!error) {
7261 ++ *opened |= FILE_OPENED;
7262 ++ } else {
7263 + if (error == -EOPENSTALE)
7264 + goto stale_open;
7265 + goto out;
7266 +@@ -4189,12 +4188,16 @@ SYSCALL_DEFINE5(renameat2, int, olddfd,
7267 + bool should_retry = false;
7268 + int error;
7270 +- if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
7271 ++ if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
7272 + return -EINVAL;
7274 +- if ((flags & RENAME_NOREPLACE) && (flags & RENAME_EXCHANGE))
7275 ++ if ((flags & (RENAME_NOREPLACE | RENAME_WHITEOUT)) &&
7276 ++ (flags & RENAME_EXCHANGE))
7277 + return -EINVAL;
7279 ++ if ((flags & RENAME_WHITEOUT) && !capable(CAP_MKNOD))
7280 ++ return -EPERM;
7282 + retry:
7283 + from = user_path_parent(olddfd, oldname, &oldnd, lookup_flags);
7284 + if (IS_ERR(from)) {
7285 +@@ -4326,6 +4329,20 @@ SYSCALL_DEFINE2(rename, const char __use
7286 + return sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
7289 ++int vfs_whiteout(struct inode *dir, struct dentry *dentry)
7291 ++ int error = may_create(dir, dentry);
7292 ++ if (error)
7293 ++ return error;
7295 ++ if (!dir->i_op->mknod)
7296 ++ return -EPERM;
7298 ++ return dir->i_op->mknod(dir, dentry,
7299 ++ S_IFCHR | WHITEOUT_MODE, WHITEOUT_DEV);
7301 ++EXPORT_SYMBOL(vfs_whiteout);
7303 + int readlink_copy(char __user *buffer, int buflen, const char *link)
7305 + int len = PTR_ERR(link);
7306 +--- a/fs/namespace.c
7307 ++++ b/fs/namespace.c
7308 +@@ -1550,6 +1550,33 @@ void drop_collected_mounts(struct vfsmou
7309 + namespace_unlock();
7312 ++/**
7313 ++ * clone_private_mount - create a private clone of a path
7314 ++ *
7315 ++ * This creates a new vfsmount, which will be the clone of @path. The new will
7316 ++ * not be attached anywhere in the namespace and will be private (i.e. changes
7317 ++ * to the originating mount won't be propagated into this).
7318 ++ *
7319 ++ * Release with mntput().
7320 ++ */
7321 ++struct vfsmount *clone_private_mount(struct path *path)
7323 ++ struct mount *old_mnt = real_mount(path->mnt);
7324 ++ struct mount *new_mnt;
7326 ++ if (IS_MNT_UNBINDABLE(old_mnt))
7327 ++ return ERR_PTR(-EINVAL);
7329 ++ down_read(&namespace_sem);
7330 ++ new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
7331 ++ up_read(&namespace_sem);
7332 ++ if (IS_ERR(new_mnt))
7333 ++ return ERR_CAST(new_mnt);
7335 ++ return &new_mnt->mnt;
7337 ++EXPORT_SYMBOL_GPL(clone_private_mount);
7339 + int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
7340 + struct vfsmount *root)
7342 +--- a/fs/open.c
7343 ++++ b/fs/open.c
7344 +@@ -823,8 +823,7 @@ struct file *dentry_open(const struct pa
7345 + f = get_empty_filp();
7346 + if (!IS_ERR(f)) {
7347 + f->f_flags = flags;
7348 +- f->f_path = *path;
7349 +- error = do_dentry_open(f, NULL, cred);
7350 ++ error = vfs_open(path, f, cred);
7351 + if (!error) {
7352 + /* from now on we need fput() to dispose of f */
7353 + error = open_check_o_direct(f);
7354 +@@ -841,6 +840,26 @@ struct file *dentry_open(const struct pa
7356 + EXPORT_SYMBOL(dentry_open);
7358 ++/**
7359 ++ * vfs_open - open the file at the given path
7360 ++ * @path: path to open
7361 ++ * @filp: newly allocated file with f_flag initialized
7362 ++ * @cred: credentials to use
7363 ++ */
7364 ++int vfs_open(const struct path *path, struct file *filp,
7365 ++ const struct cred *cred)
7367 ++ struct inode *inode = path->dentry->d_inode;
7369 ++ if (inode->i_op->dentry_open)
7370 ++ return inode->i_op->dentry_open(path->dentry, filp, cred);
7371 ++ else {
7372 ++ filp->f_path = *path;
7373 ++ return do_dentry_open(filp, NULL, cred);
7374 ++ }
7376 ++EXPORT_SYMBOL(vfs_open);
7378 + static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
7380 + int lookup_flags = 0;
7381 +--- /dev/null
7382 ++++ b/fs/overlayfs/Kconfig
7383 +@@ -0,0 +1,10 @@
7384 ++config OVERLAYFS_FS
7385 ++ tristate "Overlay filesystem support"
7386 ++ help
7387 ++ An overlay filesystem combines two filesystems - an 'upper' filesystem
7388 ++ and a 'lower' filesystem. When a name exists in both filesystems, the
7389 ++ object in the 'upper' filesystem is visible while the object in the
7390 ++ 'lower' filesystem is either hidden or, in the case of directories,
7391 ++ merged with the 'upper' object.
7393 ++ For more information see Documentation/filesystems/overlayfs.txt
7394 +--- /dev/null
7395 ++++ b/fs/overlayfs/Makefile
7396 +@@ -0,0 +1,7 @@
7398 ++# Makefile for the overlay filesystem.
7401 ++obj-$(CONFIG_OVERLAYFS_FS) += overlayfs.o
7403 ++overlayfs-objs := super.o inode.o dir.o readdir.o copy_up.o
7404 +--- /dev/null
7405 ++++ b/fs/overlayfs/copy_up.c
7406 +@@ -0,0 +1,431 @@
7407 ++/*
7408 ++ *
7409 ++ * Copyright (C) 2011 Novell Inc.
7410 ++ *
7411 ++ * This program is free software; you can redistribute it and/or modify it
7412 ++ * under the terms of the GNU General Public License version 2 as published by
7413 ++ * the Free Software Foundation.
7414 ++ */
7416 ++#include <linux/fs.h>
7417 ++#include <linux/slab.h>
7418 ++#include <linux/file.h>
7419 ++#include <linux/splice.h>
7420 ++#include <linux/xattr.h>
7421 ++#include <linux/security.h>
7422 ++#include <linux/uaccess.h>
7423 ++#include <linux/sched.h>
7424 ++#include <linux/namei.h>
7425 ++#include "overlayfs.h"
7427 ++#define OVL_COPY_UP_CHUNK_SIZE (1 << 20)
7429 ++int ovl_copy_xattr(struct dentry *old, struct dentry *new)
7431 ++ ssize_t list_size, size;
7432 ++ char *buf, *name, *value;
7433 ++ int error;
7435 ++ if (!old->d_inode->i_op->getxattr ||
7436 ++ !new->d_inode->i_op->getxattr)
7437 ++ return 0;
7439 ++ list_size = vfs_listxattr(old, NULL, 0);
7440 ++ if (list_size <= 0) {
7441 ++ if (list_size == -EOPNOTSUPP)
7442 ++ return 0;
7443 ++ return list_size;
7444 ++ }
7446 ++ buf = kzalloc(list_size, GFP_KERNEL);
7447 ++ if (!buf)
7448 ++ return -ENOMEM;
7450 ++ error = -ENOMEM;
7451 ++ value = kmalloc(XATTR_SIZE_MAX, GFP_KERNEL);
7452 ++ if (!value)
7453 ++ goto out;
7455 ++ list_size = vfs_listxattr(old, buf, list_size);
7456 ++ if (list_size <= 0) {
7457 ++ error = list_size;
7458 ++ goto out_free_value;
7459 ++ }
7461 ++ for (name = buf; name < (buf + list_size); name += strlen(name) + 1) {
7462 ++ size = vfs_getxattr(old, name, value, XATTR_SIZE_MAX);
7463 ++ if (size <= 0) {
7464 ++ error = size;
7465 ++ goto out_free_value;
7466 ++ }
7467 ++ error = vfs_setxattr(new, name, value, size, 0);
7468 ++ if (error)
7469 ++ goto out_free_value;
7470 ++ }
7472 ++out_free_value:
7473 ++ kfree(value);
7474 ++out:
7475 ++ kfree(buf);
7476 ++ return error;
7479 ++static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len)
7481 ++ struct file *old_file;
7482 ++ struct file *new_file;
7483 ++ loff_t old_pos = 0;
7484 ++ loff_t new_pos = 0;
7485 ++ int error = 0;
7487 ++ if (len == 0)
7488 ++ return 0;
7490 ++ old_file = ovl_path_open(old, O_RDONLY);
7491 ++ if (IS_ERR(old_file))
7492 ++ return PTR_ERR(old_file);
7494 ++ new_file = ovl_path_open(new, O_WRONLY);
7495 ++ if (IS_ERR(new_file)) {
7496 ++ error = PTR_ERR(new_file);
7497 ++ goto out_fput;
7498 ++ }
7500 ++ /* FIXME: copy up sparse files efficiently */
7501 ++ while (len) {
7502 ++ size_t this_len = OVL_COPY_UP_CHUNK_SIZE;
7503 ++ long bytes;
7505 ++ if (len < this_len)
7506 ++ this_len = len;
7508 ++ if (signal_pending_state(TASK_KILLABLE, current)) {
7509 ++ error = -EINTR;
7510 ++ break;
7511 ++ }
7513 ++ bytes = do_splice_direct(old_file, &old_pos,
7514 ++ new_file, &new_pos,
7515 ++ this_len, SPLICE_F_MOVE);
7516 ++ if (bytes <= 0) {
7517 ++ error = bytes;
7518 ++ break;
7519 ++ }
7520 ++ WARN_ON(old_pos != new_pos);
7522 ++ len -= bytes;
7523 ++ }
7525 ++ fput(new_file);
7526 ++out_fput:
7527 ++ fput(old_file);
7528 ++ return error;
7531 ++static char *ovl_read_symlink(struct dentry *realdentry)
7533 ++ int res;
7534 ++ char *buf;
7535 ++ struct inode *inode = realdentry->d_inode;
7536 ++ mm_segment_t old_fs;
7538 ++ res = -EINVAL;
7539 ++ if (!inode->i_op->readlink)
7540 ++ goto err;
7542 ++ res = -ENOMEM;
7543 ++ buf = (char *) __get_free_page(GFP_KERNEL);
7544 ++ if (!buf)
7545 ++ goto err;
7547 ++ old_fs = get_fs();
7548 ++ set_fs(get_ds());
7549 ++ /* The cast to a user pointer is valid due to the set_fs() */
7550 ++ res = inode->i_op->readlink(realdentry,
7551 ++ (char __user *)buf, PAGE_SIZE - 1);
7552 ++ set_fs(old_fs);
7553 ++ if (res < 0) {
7554 ++ free_page((unsigned long) buf);
7555 ++ goto err;
7556 ++ }
7557 ++ buf[res] = '\0';
7559 ++ return buf;
7561 ++err:
7562 ++ return ERR_PTR(res);
7565 ++static int ovl_set_timestamps(struct dentry *upperdentry, struct kstat *stat)
7567 ++ struct iattr attr = {
7568 ++ .ia_valid =
7569 ++ ATTR_ATIME | ATTR_MTIME | ATTR_ATIME_SET | ATTR_MTIME_SET,
7570 ++ .ia_atime = stat->atime,
7571 ++ .ia_mtime = stat->mtime,
7572 ++ };
7574 ++ return notify_change(upperdentry, &attr, NULL);
7577 ++int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat)
7579 ++ int err = 0;
7581 ++ mutex_lock(&upperdentry->d_inode->i_mutex);
7582 ++ if (!S_ISLNK(stat->mode)) {
7583 ++ struct iattr attr = {
7584 ++ .ia_valid = ATTR_MODE,
7585 ++ .ia_mode = stat->mode,
7586 ++ };
7587 ++ err = notify_change(upperdentry, &attr, NULL);
7588 ++ }
7589 ++ if (!err) {
7590 ++ struct iattr attr = {
7591 ++ .ia_valid = ATTR_UID | ATTR_GID,
7592 ++ .ia_uid = stat->uid,
7593 ++ .ia_gid = stat->gid,
7594 ++ };
7595 ++ err = notify_change(upperdentry, &attr, NULL);
7596 ++ }
7597 ++ if (!err)
7598 ++ ovl_set_timestamps(upperdentry, stat);
7599 ++ mutex_unlock(&upperdentry->d_inode->i_mutex);
7601 ++ return err;
7605 ++static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
7606 ++ struct dentry *dentry, struct path *lowerpath,
7607 ++ struct kstat *stat, const char *link)
7609 ++ struct inode *wdir = workdir->d_inode;
7610 ++ struct inode *udir = upperdir->d_inode;
7611 ++ struct dentry *newdentry = NULL;
7612 ++ struct dentry *upper = NULL;
7613 ++ umode_t mode = stat->mode;
7614 ++ int err;
7616 ++ newdentry = ovl_lookup_temp(workdir, dentry);
7617 ++ err = PTR_ERR(newdentry);
7618 ++ if (IS_ERR(newdentry))
7619 ++ goto out;
7621 ++ upper = lookup_one_len(dentry->d_name.name, upperdir,
7622 ++ dentry->d_name.len);
7623 ++ err = PTR_ERR(upper);
7624 ++ if (IS_ERR(upper))
7625 ++ goto out;
7627 ++ /* Can't properly set mode on creation because of the umask */
7628 ++ stat->mode &= S_IFMT;
7629 ++ err = ovl_create_real(wdir, newdentry, stat, link, NULL, true);
7630 ++ stat->mode = mode;
7631 ++ if (err)
7632 ++ goto out;
7634 ++ if (S_ISREG(stat->mode)) {
7635 ++ struct path upperpath;
7636 ++ ovl_path_upper(dentry, &upperpath);
7637 ++ BUG_ON(upperpath.dentry != NULL);
7638 ++ upperpath.dentry = newdentry;
7640 ++ err = ovl_copy_up_data(lowerpath, &upperpath, stat->size);
7641 ++ if (err)
7642 ++ goto out_cleanup;
7643 ++ }
7645 ++ err = ovl_copy_xattr(lowerpath->dentry, newdentry);
7646 ++ if (err)
7647 ++ goto out_cleanup;
7649 ++ err = ovl_set_attr(newdentry, stat);
7650 ++ if (err)
7651 ++ goto out_cleanup;
7653 ++ err = ovl_do_rename(wdir, newdentry, udir, upper, 0);
7654 ++ if (err)
7655 ++ goto out_cleanup;
7657 ++ ovl_dentry_update(dentry, newdentry);
7658 ++ newdentry = NULL;
7660 ++ /*
7661 ++ * Easiest way to get rid of the lower dentry reference is to
7662 ++ * drop this dentry. This is neither needed nor possible for
7663 ++ * directories.
7664 ++ *
7665 ++ * Non-directores become opaque when copied up.
7666 ++ */
7667 ++ if (!S_ISDIR(stat->mode)) {
7668 ++ ovl_dentry_set_opaque(dentry, true);
7669 ++ d_drop(dentry);
7670 ++ }
7671 ++out:
7672 ++ dput(upper);
7673 ++ dput(newdentry);
7674 ++ return err;
7676 ++out_cleanup:
7677 ++ ovl_cleanup(wdir, newdentry);
7678 ++ goto out;
7681 ++/*
7682 ++ * Copy up a single dentry
7683 ++ *
7684 ++ * Directory renames only allowed on "pure upper" (already created on
7685 ++ * upper filesystem, never copied up). Directories which are on lower or
7686 ++ * are merged may not be renamed. For these -EXDEV is returned and
7687 ++ * userspace has to deal with it. This means, when copying up a
7688 ++ * directory we can rely on it and ancestors being stable.
7689 ++ *
7690 ++ * Non-directory renames start with copy up of source if necessary. The
7691 ++ * actual rename will only proceed once the copy up was successful. Copy
7692 ++ * up uses upper parent i_mutex for exclusion. Since rename can change
7693 ++ * d_parent it is possible that the copy up will lock the old parent. At
7694 ++ * that point the file will have already been copied up anyway.
7695 ++ */
7696 ++static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
7697 ++ struct path *lowerpath, struct kstat *stat)
7699 ++ struct dentry *workdir = ovl_workdir(dentry);
7700 ++ int err;
7701 ++ struct kstat pstat;
7702 ++ struct path parentpath;
7703 ++ struct dentry *upperdir;
7704 ++ const struct cred *old_cred;
7705 ++ struct cred *override_cred;
7706 ++ char *link = NULL;
7708 ++ ovl_path_upper(parent, &parentpath);
7709 ++ upperdir = parentpath.dentry;
7711 ++ err = vfs_getattr(&parentpath, &pstat);
7712 ++ if (err)
7713 ++ return err;
7715 ++ if (S_ISLNK(stat->mode)) {
7716 ++ link = ovl_read_symlink(lowerpath->dentry);
7717 ++ if (IS_ERR(link))
7718 ++ return PTR_ERR(link);
7719 ++ }
7721 ++ err = -ENOMEM;
7722 ++ override_cred = prepare_creds();
7723 ++ if (!override_cred)
7724 ++ goto out_free_link;
7726 ++ override_cred->fsuid = stat->uid;
7727 ++ override_cred->fsgid = stat->gid;
7728 ++ /*
7729 ++ * CAP_SYS_ADMIN for copying up extended attributes
7730 ++ * CAP_DAC_OVERRIDE for create
7731 ++ * CAP_FOWNER for chmod, timestamp update
7732 ++ * CAP_FSETID for chmod
7733 ++ * CAP_CHOWN for chown
7734 ++ * CAP_MKNOD for mknod
7735 ++ */
7736 ++ cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN);
7737 ++ cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE);
7738 ++ cap_raise(override_cred->cap_effective, CAP_FOWNER);
7739 ++ cap_raise(override_cred->cap_effective, CAP_FSETID);
7740 ++ cap_raise(override_cred->cap_effective, CAP_CHOWN);
7741 ++ cap_raise(override_cred->cap_effective, CAP_MKNOD);
7742 ++ old_cred = override_creds(override_cred);
7744 ++ err = -EIO;
7745 ++ if (lock_rename(workdir, upperdir) != NULL) {
7746 ++ pr_err("overlayfs: failed to lock workdir+upperdir\n");
7747 ++ goto out_unlock;
7748 ++ }
7749 ++ if (ovl_path_type(dentry) != OVL_PATH_LOWER) {
7750 ++ err = 0;
7751 ++ } else {
7752 ++ err = ovl_copy_up_locked(workdir, upperdir, dentry, lowerpath,
7753 ++ stat, link);
7754 ++ if (!err) {
7755 ++ /* Restore timestamps on parent (best effort) */
7756 ++ ovl_set_timestamps(upperdir, &pstat);
7757 ++ }
7758 ++ }
7759 ++out_unlock:
7760 ++ unlock_rename(workdir, upperdir);
7762 ++ revert_creds(old_cred);
7763 ++ put_cred(override_cred);
7765 ++out_free_link:
7766 ++ if (link)
7767 ++ free_page((unsigned long) link);
7769 ++ return err;
7772 ++int ovl_copy_up(struct dentry *dentry)
7774 ++ int err;
7776 ++ err = 0;
7777 ++ while (!err) {
7778 ++ struct dentry *next;
7779 ++ struct dentry *parent;
7780 ++ struct path lowerpath;
7781 ++ struct kstat stat;
7782 ++ enum ovl_path_type type = ovl_path_type(dentry);
7784 ++ if (type != OVL_PATH_LOWER)
7785 ++ break;
7787 ++ next = dget(dentry);
7788 ++ /* find the topmost dentry not yet copied up */
7789 ++ for (;;) {
7790 ++ parent = dget_parent(next);
7792 ++ type = ovl_path_type(parent);
7793 ++ if (type != OVL_PATH_LOWER)
7794 ++ break;
7796 ++ dput(next);
7797 ++ next = parent;
7798 ++ }
7800 ++ ovl_path_lower(next, &lowerpath);
7801 ++ err = vfs_getattr(&lowerpath, &stat);
7802 ++ if (!err)
7803 ++ err = ovl_copy_up_one(parent, next, &lowerpath, &stat);
7805 ++ dput(parent);
7806 ++ dput(next);
7807 ++ }
7809 ++ return err;
7812 ++/* Optimize by not copying up the file first and truncating later */
7813 ++int ovl_copy_up_truncate(struct dentry *dentry, loff_t size)
7815 ++ int err;
7816 ++ struct kstat stat;
7817 ++ struct path lowerpath;
7818 ++ struct dentry *parent = dget_parent(dentry);
7820 ++ err = ovl_copy_up(parent);
7821 ++ if (err)
7822 ++ goto out_dput_parent;
7824 ++ ovl_path_lower(dentry, &lowerpath);
7825 ++ err = vfs_getattr(&lowerpath, &stat);
7826 ++ if (err)
7827 ++ goto out_dput_parent;
7829 ++ if (size < stat.size)
7830 ++ stat.size = size;
7832 ++ err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat);
7834 ++out_dput_parent:
7835 ++ dput(parent);
7836 ++ return err;
7838 +--- /dev/null
7839 ++++ b/fs/overlayfs/dir.c
7840 +@@ -0,0 +1,922 @@
7841 ++/*
7842 ++ *
7843 ++ * Copyright (C) 2011 Novell Inc.
7844 ++ *
7845 ++ * This program is free software; you can redistribute it and/or modify it
7846 ++ * under the terms of the GNU General Public License version 2 as published by
7847 ++ * the Free Software Foundation.
7848 ++ */
7850 ++#include <linux/fs.h>
7851 ++#include <linux/namei.h>
7852 ++#include <linux/xattr.h>
7853 ++#include <linux/security.h>
7854 ++#include <linux/cred.h>
7855 ++#include "overlayfs.h"
7857 ++void ovl_cleanup(struct inode *wdir, struct dentry *wdentry)
7859 ++ int err;
7861 ++ if (S_ISDIR(wdentry->d_inode->i_mode))
7862 ++ err = ovl_do_rmdir(wdir, wdentry);
7863 ++ else
7864 ++ err = ovl_do_unlink(wdir, wdentry);
7866 ++ if (err) {
7867 ++ pr_err("overlayfs: cleanup of '%pd2' failed (%i)\n",
7868 ++ wdentry, err);
7869 ++ }
7872 ++struct dentry *ovl_lookup_temp(struct dentry *workdir, struct dentry *dentry)
7874 ++ struct dentry *temp;
7875 ++ char name[20];
7877 ++ snprintf(name, sizeof(name), "#%lx", (unsigned long) dentry);
7879 ++ temp = lookup_one_len(name, workdir, strlen(name));
7880 ++ if (!IS_ERR(temp) && temp->d_inode) {
7881 ++ pr_err("overlayfs: workdir/%s already exists\n", name);
7882 ++ dput(temp);
7883 ++ temp = ERR_PTR(-EIO);
7884 ++ }
7886 ++ return temp;
7889 ++/* caller holds i_mutex on workdir */
7890 ++static struct dentry *ovl_whiteout(struct dentry *workdir,
7891 ++ struct dentry *dentry)
7893 ++ int err;
7894 ++ struct dentry *whiteout;
7895 ++ struct inode *wdir = workdir->d_inode;
7897 ++ whiteout = ovl_lookup_temp(workdir, dentry);
7898 ++ if (IS_ERR(whiteout))
7899 ++ return whiteout;
7901 ++ err = ovl_do_whiteout(wdir, whiteout);
7902 ++ if (err) {
7903 ++ dput(whiteout);
7904 ++ whiteout = ERR_PTR(err);
7905 ++ }
7907 ++ return whiteout;
7910 ++int ovl_create_real(struct inode *dir, struct dentry *newdentry,
7911 ++ struct kstat *stat, const char *link,
7912 ++ struct dentry *hardlink, bool debug)
7914 ++ int err;
7916 ++ if (newdentry->d_inode)
7917 ++ return -ESTALE;
7919 ++ if (hardlink) {
7920 ++ err = ovl_do_link(hardlink, dir, newdentry, debug);
7921 ++ } else {
7922 ++ switch (stat->mode & S_IFMT) {
7923 ++ case S_IFREG:
7924 ++ err = ovl_do_create(dir, newdentry, stat->mode, debug);
7925 ++ break;
7927 ++ case S_IFDIR:
7928 ++ err = ovl_do_mkdir(dir, newdentry, stat->mode, debug);
7929 ++ break;
7931 ++ case S_IFCHR:
7932 ++ case S_IFBLK:
7933 ++ case S_IFIFO:
7934 ++ case S_IFSOCK:
7935 ++ err = ovl_do_mknod(dir, newdentry,
7936 ++ stat->mode, stat->rdev, debug);
7937 ++ break;
7939 ++ case S_IFLNK:
7940 ++ err = ovl_do_symlink(dir, newdentry, link, debug);
7941 ++ break;
7943 ++ default:
7944 ++ err = -EPERM;
7945 ++ }
7946 ++ }
7947 ++ if (!err && WARN_ON(!newdentry->d_inode)) {
7948 ++ /*
7949 ++ * Not quite sure if non-instantiated dentry is legal or not.
7950 ++ * VFS doesn't seem to care so check and warn here.
7951 ++ */
7952 ++ err = -ENOENT;
7953 ++ }
7954 ++ return err;
7957 ++static int ovl_set_opaque(struct dentry *upperdentry)
7959 ++ return ovl_do_setxattr(upperdentry, ovl_opaque_xattr, "y", 1, 0);
7962 ++static void ovl_remove_opaque(struct dentry *upperdentry)
7964 ++ int err;
7966 ++ err = ovl_do_removexattr(upperdentry, ovl_opaque_xattr);
7967 ++ if (err) {
7968 ++ pr_warn("overlayfs: failed to remove opaque from '%s' (%i)\n",
7969 ++ upperdentry->d_name.name, err);
7970 ++ }
7973 ++static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry,
7974 ++ struct kstat *stat)
7976 ++ int err;
7977 ++ enum ovl_path_type type;
7978 ++ struct path realpath;
7980 ++ type = ovl_path_real(dentry, &realpath);
7981 ++ err = vfs_getattr(&realpath, stat);
7982 ++ if (err)
7983 ++ return err;
7985 ++ stat->dev = dentry->d_sb->s_dev;
7986 ++ stat->ino = dentry->d_inode->i_ino;
7988 ++ /*
7989 ++ * It's probably not worth it to count subdirs to get the
7990 ++ * correct link count. nlink=1 seems to pacify 'find' and
7991 ++ * other utilities.
7992 ++ */
7993 ++ if (type == OVL_PATH_MERGE)
7994 ++ stat->nlink = 1;
7996 ++ return 0;
7999 ++static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
8000 ++ struct kstat *stat, const char *link,
8001 ++ struct dentry *hardlink)
8003 ++ struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
8004 ++ struct inode *udir = upperdir->d_inode;
8005 ++ struct dentry *newdentry;
8006 ++ int err;
8008 ++ mutex_lock_nested(&udir->i_mutex, I_MUTEX_PARENT);
8009 ++ newdentry = lookup_one_len(dentry->d_name.name, upperdir,
8010 ++ dentry->d_name.len);
8011 ++ err = PTR_ERR(newdentry);
8012 ++ if (IS_ERR(newdentry))
8013 ++ goto out_unlock;
8014 ++ err = ovl_create_real(udir, newdentry, stat, link, hardlink, false);
8015 ++ if (err)
8016 ++ goto out_dput;
8018 ++ ovl_dentry_version_inc(dentry->d_parent);
8019 ++ ovl_dentry_update(dentry, newdentry);
8020 ++ ovl_copyattr(newdentry->d_inode, inode);
8021 ++ d_instantiate(dentry, inode);
8022 ++ newdentry = NULL;
8023 ++out_dput:
8024 ++ dput(newdentry);
8025 ++out_unlock:
8026 ++ mutex_unlock(&udir->i_mutex);
8027 ++ return err;
8030 ++static int ovl_lock_rename_workdir(struct dentry *workdir,
8031 ++ struct dentry *upperdir)
8033 ++ /* Workdir should not be subdir of upperdir and vice versa */
8034 ++ if (lock_rename(workdir, upperdir) != NULL) {
8035 ++ unlock_rename(workdir, upperdir);
8036 ++ pr_err("overlayfs: failed to lock workdir+upperdir\n");
8037 ++ return -EIO;
8038 ++ }
8039 ++ return 0;
8042 ++static struct dentry *ovl_clear_empty(struct dentry *dentry,
8043 ++ struct list_head *list)
8045 ++ struct dentry *workdir = ovl_workdir(dentry);
8046 ++ struct inode *wdir = workdir->d_inode;
8047 ++ struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
8048 ++ struct inode *udir = upperdir->d_inode;
8049 ++ struct path upperpath;
8050 ++ struct dentry *upper;
8051 ++ struct dentry *opaquedir;
8052 ++ struct kstat stat;
8053 ++ int err;
8055 ++ err = ovl_lock_rename_workdir(workdir, upperdir);
8056 ++ if (err)
8057 ++ goto out;
8059 ++ ovl_path_upper(dentry, &upperpath);
8060 ++ err = vfs_getattr(&upperpath, &stat);
8061 ++ if (err)
8062 ++ goto out;
8064 ++ err = -ESTALE;
8065 ++ if (!S_ISDIR(stat.mode))
8066 ++ goto out;
8068 ++ opaquedir = ovl_lookup_temp(workdir, dentry);
8069 ++ err = PTR_ERR(opaquedir);
8070 ++ if (IS_ERR(opaquedir))
8071 ++ goto out_unlock;
8073 ++ err = ovl_create_real(wdir, opaquedir, &stat, NULL, NULL, true);
8074 ++ if (err)
8075 ++ goto out_dput;
8077 ++ upper = upperpath.dentry;
8078 ++ err = ovl_copy_xattr(upper, opaquedir);
8079 ++ if (err)
8080 ++ goto out_cleanup;
8082 ++ err = ovl_set_opaque(opaquedir);
8083 ++ if (err)
8084 ++ goto out_cleanup;
8086 ++ err = ovl_set_attr(opaquedir, &stat);
8087 ++ if (err)
8088 ++ goto out_cleanup;
8090 ++ err = ovl_do_rename(wdir, opaquedir, udir, upper, RENAME_EXCHANGE);
8091 ++ if (err)
8092 ++ goto out_cleanup;
8094 ++ unlock_rename(workdir, upperdir);
8095 ++ ovl_cleanup_whiteouts(upper, list);
8096 ++ mutex_lock_nested(&wdir->i_mutex, I_MUTEX_PARENT);
8097 ++ ovl_cleanup(wdir, upper);
8098 ++ mutex_unlock(&wdir->i_mutex);
8100 ++ /* dentry's upper doesn't match now, get rid of it */
8101 ++ d_drop(dentry);
8103 ++ return opaquedir;
8105 ++out_cleanup:
8106 ++ ovl_cleanup(wdir, opaquedir);
8107 ++out_dput:
8108 ++ dput(opaquedir);
8109 ++out_unlock:
8110 ++ unlock_rename(workdir, upperdir);
8111 ++out:
8112 ++ return ERR_PTR(err);
8115 ++static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry,
8116 ++ enum ovl_path_type type)
8118 ++ int err;
8119 ++ struct dentry *ret = NULL;
8120 ++ LIST_HEAD(list);
8122 ++ err = ovl_check_empty_dir(dentry, &list);
8123 ++ if (err)
8124 ++ ret = ERR_PTR(err);
8125 ++ else if (type == OVL_PATH_MERGE)
8126 ++ ret = ovl_clear_empty(dentry, &list);
8128 ++ ovl_cache_free(&list);
8130 ++ return ret;
8133 ++static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
8134 ++ struct kstat *stat, const char *link,
8135 ++ struct dentry *hardlink)
8137 ++ struct dentry *workdir = ovl_workdir(dentry);
8138 ++ struct inode *wdir = workdir->d_inode;
8139 ++ struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
8140 ++ struct inode *udir = upperdir->d_inode;
8141 ++ struct dentry *upper;
8142 ++ struct dentry *newdentry;
8143 ++ int err;
8145 ++ err = ovl_lock_rename_workdir(workdir, upperdir);
8146 ++ if (err)
8147 ++ goto out;
8149 ++ newdentry = ovl_lookup_temp(workdir, dentry);
8150 ++ err = PTR_ERR(newdentry);
8151 ++ if (IS_ERR(newdentry))
8152 ++ goto out_unlock;
8154 ++ upper = lookup_one_len(dentry->d_name.name, upperdir,
8155 ++ dentry->d_name.len);
8156 ++ err = PTR_ERR(upper);
8157 ++ if (IS_ERR(upper))
8158 ++ goto out_dput;
8160 ++ err = ovl_create_real(wdir, newdentry, stat, link, hardlink, true);
8161 ++ if (err)
8162 ++ goto out_dput2;
8164 ++ if (S_ISDIR(stat->mode)) {
8165 ++ err = ovl_set_opaque(newdentry);
8166 ++ if (err)
8167 ++ goto out_cleanup;
8169 ++ err = ovl_do_rename(wdir, newdentry, udir, upper,
8170 ++ RENAME_EXCHANGE);
8171 ++ if (err)
8172 ++ goto out_cleanup;
8174 ++ ovl_cleanup(wdir, upper);
8175 ++ } else {
8176 ++ err = ovl_do_rename(wdir, newdentry, udir, upper, 0);
8177 ++ if (err)
8178 ++ goto out_cleanup;
8179 ++ }
8180 ++ ovl_dentry_version_inc(dentry->d_parent);
8181 ++ ovl_dentry_update(dentry, newdentry);
8182 ++ ovl_copyattr(newdentry->d_inode, inode);
8183 ++ d_instantiate(dentry, inode);
8184 ++ newdentry = NULL;
8185 ++out_dput2:
8186 ++ dput(upper);
8187 ++out_dput:
8188 ++ dput(newdentry);
8189 ++out_unlock:
8190 ++ unlock_rename(workdir, upperdir);
8191 ++out:
8192 ++ return err;
8194 ++out_cleanup:
8195 ++ ovl_cleanup(wdir, newdentry);
8196 ++ goto out_dput2;
8199 ++static int ovl_create_or_link(struct dentry *dentry, int mode, dev_t rdev,
8200 ++ const char *link, struct dentry *hardlink)
8202 ++ int err;
8203 ++ struct inode *inode;
8204 ++ struct kstat stat = {
8205 ++ .mode = mode,
8206 ++ .rdev = rdev,
8207 ++ };
8209 ++ err = -ENOMEM;
8210 ++ inode = ovl_new_inode(dentry->d_sb, mode, dentry->d_fsdata);
8211 ++ if (!inode)
8212 ++ goto out;
8214 ++ err = ovl_copy_up(dentry->d_parent);
8215 ++ if (err)
8216 ++ goto out_iput;
8218 ++ if (!ovl_dentry_is_opaque(dentry)) {
8219 ++ err = ovl_create_upper(dentry, inode, &stat, link, hardlink);
8220 ++ } else {
8221 ++ const struct cred *old_cred;
8222 ++ struct cred *override_cred;
8224 ++ err = -ENOMEM;
8225 ++ override_cred = prepare_creds();
8226 ++ if (!override_cred)
8227 ++ goto out_iput;
8229 ++ /*
8230 ++ * CAP_SYS_ADMIN for setting opaque xattr
8231 ++ * CAP_DAC_OVERRIDE for create in workdir, rename
8232 ++ * CAP_FOWNER for removing whiteout from sticky dir
8233 ++ */
8234 ++ cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN);
8235 ++ cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE);
8236 ++ cap_raise(override_cred->cap_effective, CAP_FOWNER);
8237 ++ old_cred = override_creds(override_cred);
8239 ++ err = ovl_create_over_whiteout(dentry, inode, &stat, link,
8240 ++ hardlink);
8242 ++ revert_creds(old_cred);
8243 ++ put_cred(override_cred);
8244 ++ }
8246 ++ if (!err)
8247 ++ inode = NULL;
8248 ++out_iput:
8249 ++ iput(inode);
8250 ++out:
8251 ++ return err;
8254 ++static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev,
8255 ++ const char *link)
8257 ++ int err;
8259 ++ err = ovl_want_write(dentry);
8260 ++ if (!err) {
8261 ++ err = ovl_create_or_link(dentry, mode, rdev, link, NULL);
8262 ++ ovl_drop_write(dentry);
8263 ++ }
8265 ++ return err;
8268 ++static int ovl_create(struct inode *dir, struct dentry *dentry, umode_t mode,
8269 ++ bool excl)
8271 ++ return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL);
8274 ++static int ovl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
8276 ++ return ovl_create_object(dentry, (mode & 07777) | S_IFDIR, 0, NULL);
8279 ++static int ovl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
8280 ++ dev_t rdev)
8282 ++ /* Don't allow creation of "whiteout" on overlay */
8283 ++ if (S_ISCHR(mode) && rdev == WHITEOUT_DEV)
8284 ++ return -EPERM;
8286 ++ return ovl_create_object(dentry, mode, rdev, NULL);
8289 ++static int ovl_symlink(struct inode *dir, struct dentry *dentry,
8290 ++ const char *link)
8292 ++ return ovl_create_object(dentry, S_IFLNK, 0, link);
8295 ++static int ovl_link(struct dentry *old, struct inode *newdir,
8296 ++ struct dentry *new)
8298 ++ int err;
8299 ++ struct dentry *upper;
8301 ++ err = ovl_want_write(old);
8302 ++ if (err)
8303 ++ goto out;
8305 ++ err = ovl_copy_up(old);
8306 ++ if (err)
8307 ++ goto out_drop_write;
8309 ++ upper = ovl_dentry_upper(old);
8310 ++ err = ovl_create_or_link(new, upper->d_inode->i_mode, 0, NULL, upper);
8312 ++out_drop_write:
8313 ++ ovl_drop_write(old);
8314 ++out:
8315 ++ return err;
8318 ++static int ovl_remove_and_whiteout(struct dentry *dentry,
8319 ++ enum ovl_path_type type, bool is_dir)
8321 ++ struct dentry *workdir = ovl_workdir(dentry);
8322 ++ struct inode *wdir = workdir->d_inode;
8323 ++ struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
8324 ++ struct inode *udir = upperdir->d_inode;
8325 ++ struct dentry *whiteout;
8326 ++ struct dentry *upper;
8327 ++ struct dentry *opaquedir = NULL;
8328 ++ int err;
8330 ++ if (is_dir) {
8331 ++ opaquedir = ovl_check_empty_and_clear(dentry, type);
8332 ++ err = PTR_ERR(opaquedir);
8333 ++ if (IS_ERR(opaquedir))
8334 ++ goto out;
8335 ++ }
8337 ++ err = ovl_lock_rename_workdir(workdir, upperdir);
8338 ++ if (err)
8339 ++ goto out_dput;
8341 ++ whiteout = ovl_whiteout(workdir, dentry);
8342 ++ err = PTR_ERR(whiteout);
8343 ++ if (IS_ERR(whiteout))
8344 ++ goto out_unlock;
8346 ++ if (type == OVL_PATH_LOWER) {
8347 ++ upper = lookup_one_len(dentry->d_name.name, upperdir,
8348 ++ dentry->d_name.len);
8349 ++ err = PTR_ERR(upper);
8350 ++ if (IS_ERR(upper))
8351 ++ goto kill_whiteout;
8353 ++ err = ovl_do_rename(wdir, whiteout, udir, upper, 0);
8354 ++ dput(upper);
8355 ++ if (err)
8356 ++ goto kill_whiteout;
8357 ++ } else {
8358 ++ int flags = 0;
8360 ++ upper = ovl_dentry_upper(dentry);
8361 ++ if (opaquedir)
8362 ++ upper = opaquedir;
8363 ++ err = -ESTALE;
8364 ++ if (upper->d_parent != upperdir)
8365 ++ goto kill_whiteout;
8367 ++ if (is_dir)
8368 ++ flags |= RENAME_EXCHANGE;
8370 ++ err = ovl_do_rename(wdir, whiteout, udir, upper, flags);
8371 ++ if (err)
8372 ++ goto kill_whiteout;
8374 ++ if (is_dir)
8375 ++ ovl_cleanup(wdir, upper);
8376 ++ }
8377 ++ ovl_dentry_version_inc(dentry->d_parent);
8378 ++out_d_drop:
8379 ++ d_drop(dentry);
8380 ++ dput(whiteout);
8381 ++out_unlock:
8382 ++ unlock_rename(workdir, upperdir);
8383 ++out_dput:
8384 ++ dput(opaquedir);
8385 ++out:
8386 ++ return err;
8388 ++kill_whiteout:
8389 ++ ovl_cleanup(wdir, whiteout);
8390 ++ goto out_d_drop;
8393 ++static int ovl_remove_upper(struct dentry *dentry, bool is_dir)
8395 ++ struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
8396 ++ struct inode *dir = upperdir->d_inode;
8397 ++ struct dentry *upper = ovl_dentry_upper(dentry);
8398 ++ int err;
8400 ++ mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
8401 ++ err = -ESTALE;
8402 ++ if (upper->d_parent == upperdir) {
8403 ++ if (is_dir)
8404 ++ err = vfs_rmdir(dir, upper);
8405 ++ else
8406 ++ err = vfs_unlink(dir, upper, NULL);
8408 ++ ovl_dentry_version_inc(dentry->d_parent);
8409 ++ }
8411 ++ /*
8412 ++ * Keeping this dentry hashed would mean having to release
8413 ++ * upperpath/lowerpath, which could only be done if we are the
8414 ++ * sole user of this dentry. Too tricky... Just unhash for
8415 ++ * now.
8416 ++ */
8417 ++ d_drop(dentry);
8418 ++ mutex_unlock(&dir->i_mutex);
8420 ++ return err;
8423 ++static inline int ovl_check_sticky(struct dentry *dentry)
8425 ++ struct inode *dir = ovl_dentry_real(dentry->d_parent)->d_inode;
8426 ++ struct inode *inode = ovl_dentry_real(dentry)->d_inode;
8428 ++ if (check_sticky(dir, inode))
8429 ++ return -EPERM;
8431 ++ return 0;
8434 ++static int ovl_do_remove(struct dentry *dentry, bool is_dir)
8436 ++ enum ovl_path_type type;
8437 ++ int err;
8439 ++ err = ovl_check_sticky(dentry);
8440 ++ if (err)
8441 ++ goto out;
8443 ++ err = ovl_want_write(dentry);
8444 ++ if (err)
8445 ++ goto out;
8447 ++ err = ovl_copy_up(dentry->d_parent);
8448 ++ if (err)
8449 ++ goto out_drop_write;
8451 ++ type = ovl_path_type(dentry);
8452 ++ if (type == OVL_PATH_UPPER && !ovl_dentry_is_opaque(dentry)) {
8453 ++ err = ovl_remove_upper(dentry, is_dir);
8454 ++ } else {
8455 ++ const struct cred *old_cred;
8456 ++ struct cred *override_cred;
8458 ++ err = -ENOMEM;
8459 ++ override_cred = prepare_creds();
8460 ++ if (!override_cred)
8461 ++ goto out_drop_write;
8463 ++ /*
8464 ++ * CAP_SYS_ADMIN for setting xattr on whiteout, opaque dir
8465 ++ * CAP_DAC_OVERRIDE for create in workdir, rename
8466 ++ * CAP_FOWNER for removing whiteout from sticky dir
8467 ++ * CAP_FSETID for chmod of opaque dir
8468 ++ * CAP_CHOWN for chown of opaque dir
8469 ++ */
8470 ++ cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN);
8471 ++ cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE);
8472 ++ cap_raise(override_cred->cap_effective, CAP_FOWNER);
8473 ++ cap_raise(override_cred->cap_effective, CAP_FSETID);
8474 ++ cap_raise(override_cred->cap_effective, CAP_CHOWN);
8475 ++ old_cred = override_creds(override_cred);
8477 ++ err = ovl_remove_and_whiteout(dentry, type, is_dir);
8479 ++ revert_creds(old_cred);
8480 ++ put_cred(override_cred);
8481 ++ }
8482 ++out_drop_write:
8483 ++ ovl_drop_write(dentry);
8484 ++out:
8485 ++ return err;
8488 ++static int ovl_unlink(struct inode *dir, struct dentry *dentry)
8490 ++ return ovl_do_remove(dentry, false);
8493 ++static int ovl_rmdir(struct inode *dir, struct dentry *dentry)
8495 ++ return ovl_do_remove(dentry, true);
8498 ++static int ovl_rename2(struct inode *olddir, struct dentry *old,
8499 ++ struct inode *newdir, struct dentry *new,
8500 ++ unsigned int flags)
8502 ++ int err;
8503 ++ enum ovl_path_type old_type;
8504 ++ enum ovl_path_type new_type;
8505 ++ struct dentry *old_upperdir;
8506 ++ struct dentry *new_upperdir;
8507 ++ struct dentry *olddentry;
8508 ++ struct dentry *newdentry;
8509 ++ struct dentry *trap;
8510 ++ bool old_opaque;
8511 ++ bool new_opaque;
8512 ++ bool new_create = false;
8513 ++ bool cleanup_whiteout = false;
8514 ++ bool overwrite = !(flags & RENAME_EXCHANGE);
8515 ++ bool is_dir = S_ISDIR(old->d_inode->i_mode);
8516 ++ bool new_is_dir = false;
8517 ++ struct dentry *opaquedir = NULL;
8518 ++ const struct cred *old_cred = NULL;
8519 ++ struct cred *override_cred = NULL;
8521 ++ err = -EINVAL;
8522 ++ if (flags & ~(RENAME_EXCHANGE | RENAME_NOREPLACE))
8523 ++ goto out;
8525 ++ flags &= ~RENAME_NOREPLACE;
8527 ++ err = ovl_check_sticky(old);
8528 ++ if (err)
8529 ++ goto out;
8531 ++ /* Don't copy up directory trees */
8532 ++ old_type = ovl_path_type(old);
8533 ++ err = -EXDEV;
8534 ++ if (old_type != OVL_PATH_UPPER && is_dir)
8535 ++ goto out;
8537 ++ if (new->d_inode) {
8538 ++ err = ovl_check_sticky(new);
8539 ++ if (err)
8540 ++ goto out;
8542 ++ if (S_ISDIR(new->d_inode->i_mode))
8543 ++ new_is_dir = true;
8545 ++ new_type = ovl_path_type(new);
8546 ++ err = -EXDEV;
8547 ++ if (!overwrite && new_type != OVL_PATH_UPPER && new_is_dir)
8548 ++ goto out;
8550 ++ err = 0;
8551 ++ if (new_type == OVL_PATH_LOWER && old_type == OVL_PATH_LOWER) {
8552 ++ if (ovl_dentry_lower(old)->d_inode ==
8553 ++ ovl_dentry_lower(new)->d_inode)
8554 ++ goto out;
8555 ++ }
8556 ++ if (new_type != OVL_PATH_LOWER && old_type != OVL_PATH_LOWER) {
8557 ++ if (ovl_dentry_upper(old)->d_inode ==
8558 ++ ovl_dentry_upper(new)->d_inode)
8559 ++ goto out;
8560 ++ }
8561 ++ } else {
8562 ++ new_type = OVL_PATH_UPPER;
8563 ++ }
8565 ++ err = ovl_want_write(old);
8566 ++ if (err)
8567 ++ goto out;
8569 ++ err = ovl_copy_up(old);
8570 ++ if (err)
8571 ++ goto out_drop_write;
8573 ++ err = ovl_copy_up(new->d_parent);
8574 ++ if (err)
8575 ++ goto out_drop_write;
8576 ++ if (!overwrite) {
8577 ++ err = ovl_copy_up(new);
8578 ++ if (err)
8579 ++ goto out_drop_write;
8580 ++ }
8582 ++ old_opaque = ovl_dentry_is_opaque(old) || old_type != OVL_PATH_UPPER;
8583 ++ new_opaque = ovl_dentry_is_opaque(new) || new_type != OVL_PATH_UPPER;
8585 ++ if (old_opaque || new_opaque) {
8586 ++ err = -ENOMEM;
8587 ++ override_cred = prepare_creds();
8588 ++ if (!override_cred)
8589 ++ goto out_drop_write;
8591 ++ /*
8592 ++ * CAP_SYS_ADMIN for setting xattr on whiteout, opaque dir
8593 ++ * CAP_DAC_OVERRIDE for create in workdir
8594 ++ * CAP_FOWNER for removing whiteout from sticky dir
8595 ++ * CAP_FSETID for chmod of opaque dir
8596 ++ * CAP_CHOWN for chown of opaque dir
8597 ++ */
8598 ++ cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN);
8599 ++ cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE);
8600 ++ cap_raise(override_cred->cap_effective, CAP_FOWNER);
8601 ++ cap_raise(override_cred->cap_effective, CAP_FSETID);
8602 ++ cap_raise(override_cred->cap_effective, CAP_CHOWN);
8603 ++ old_cred = override_creds(override_cred);
8604 ++ }
8606 ++ if (overwrite && new_type != OVL_PATH_UPPER && new_is_dir) {
8607 ++ opaquedir = ovl_check_empty_and_clear(new, new_type);
8608 ++ err = PTR_ERR(opaquedir);
8609 ++ if (IS_ERR(opaquedir)) {
8610 ++ opaquedir = NULL;
8611 ++ goto out_revert_creds;
8612 ++ }
8613 ++ }
8615 ++ if (overwrite) {
8616 ++ if (old_opaque) {
8617 ++ if (new->d_inode || !new_opaque) {
8618 ++ /* Whiteout source */
8619 ++ flags |= RENAME_WHITEOUT;
8620 ++ } else {
8621 ++ /* Switch whiteouts */
8622 ++ flags |= RENAME_EXCHANGE;
8623 ++ }
8624 ++ } else if (is_dir && !new->d_inode && new_opaque) {
8625 ++ flags |= RENAME_EXCHANGE;
8626 ++ cleanup_whiteout = true;
8627 ++ }
8628 ++ }
8630 ++ old_upperdir = ovl_dentry_upper(old->d_parent);
8631 ++ new_upperdir = ovl_dentry_upper(new->d_parent);
8633 ++ trap = lock_rename(new_upperdir, old_upperdir);
8635 ++ olddentry = ovl_dentry_upper(old);
8636 ++ newdentry = ovl_dentry_upper(new);
8637 ++ if (newdentry) {
8638 ++ if (opaquedir) {
8639 ++ newdentry = opaquedir;
8640 ++ opaquedir = NULL;
8641 ++ } else {
8642 ++ dget(newdentry);
8643 ++ }
8644 ++ } else {
8645 ++ new_create = true;
8646 ++ newdentry = lookup_one_len(new->d_name.name, new_upperdir,
8647 ++ new->d_name.len);
8648 ++ err = PTR_ERR(newdentry);
8649 ++ if (IS_ERR(newdentry))
8650 ++ goto out_unlock;
8651 ++ }
8653 ++ err = -ESTALE;
8654 ++ if (olddentry->d_parent != old_upperdir)
8655 ++ goto out_dput;
8656 ++ if (newdentry->d_parent != new_upperdir)
8657 ++ goto out_dput;
8658 ++ if (olddentry == trap)
8659 ++ goto out_dput;
8660 ++ if (newdentry == trap)
8661 ++ goto out_dput;
8663 ++ if (is_dir && !old_opaque && new_opaque) {
8664 ++ err = ovl_set_opaque(olddentry);
8665 ++ if (err)
8666 ++ goto out_dput;
8667 ++ }
8668 ++ if (!overwrite && new_is_dir && old_opaque && !new_opaque) {
8669 ++ err = ovl_set_opaque(newdentry);
8670 ++ if (err)
8671 ++ goto out_dput;
8672 ++ }
8674 ++ if (old_opaque || new_opaque) {
8675 ++ err = ovl_do_rename(old_upperdir->d_inode, olddentry,
8676 ++ new_upperdir->d_inode, newdentry,
8677 ++ flags);
8678 ++ } else {
8679 ++ /* No debug for the plain case */
8680 ++ BUG_ON(flags & ~RENAME_EXCHANGE);
8681 ++ err = vfs_rename(old_upperdir->d_inode, olddentry,
8682 ++ new_upperdir->d_inode, newdentry,
8683 ++ NULL, flags);
8684 ++ }
8686 ++ if (err) {
8687 ++ if (is_dir && !old_opaque && new_opaque)
8688 ++ ovl_remove_opaque(olddentry);
8689 ++ if (!overwrite && new_is_dir && old_opaque && !new_opaque)
8690 ++ ovl_remove_opaque(newdentry);
8691 ++ goto out_dput;
8692 ++ }
8694 ++ if (is_dir && old_opaque && !new_opaque)
8695 ++ ovl_remove_opaque(olddentry);
8696 ++ if (!overwrite && new_is_dir && !old_opaque && new_opaque)
8697 ++ ovl_remove_opaque(newdentry);
8699 ++ if (old_opaque != new_opaque) {
8700 ++ ovl_dentry_set_opaque(old, new_opaque);
8701 ++ if (!overwrite)
8702 ++ ovl_dentry_set_opaque(new, old_opaque);
8703 ++ }
8705 ++ if (cleanup_whiteout)
8706 ++ ovl_cleanup(old_upperdir->d_inode, newdentry);
8708 ++ /*
8709 ++ * Copy-up already unhashed it, but then vfs_rename() rehashed it.
8710 ++ * See comment in ovl_copy_up_locked() as to why we drop the dentry().
8711 ++ */
8712 ++ if (!is_dir && old_type == OVL_PATH_LOWER)
8713 ++ d_drop(old);
8715 ++ if (!overwrite && !new_is_dir && new_type == OVL_PATH_LOWER)
8716 ++ d_drop(new);
8718 ++ ovl_dentry_version_inc(old->d_parent);
8719 ++ ovl_dentry_version_inc(new->d_parent);
8721 ++out_dput:
8722 ++ dput(newdentry);
8723 ++out_unlock:
8724 ++ unlock_rename(new_upperdir, old_upperdir);
8725 ++out_revert_creds:
8726 ++ if (old_opaque || new_opaque) {
8727 ++ revert_creds(old_cred);
8728 ++ put_cred(override_cred);
8729 ++ }
8730 ++out_drop_write:
8731 ++ ovl_drop_write(old);
8732 ++out:
8733 ++ dput(opaquedir);
8734 ++ return err;
8737 ++static int ovl_rename(struct inode *olddir, struct dentry *old,
8738 ++ struct inode *newdir, struct dentry *new)
8740 ++ return ovl_rename2(olddir, old, newdir, new, 0);
8744 ++const struct inode_operations ovl_dir_inode_operations = {
8745 ++ .lookup = ovl_lookup,
8746 ++ .mkdir = ovl_mkdir,
8747 ++ .symlink = ovl_symlink,
8748 ++ .unlink = ovl_unlink,
8749 ++ .rmdir = ovl_rmdir,
8750 ++ .rename = ovl_rename,
8751 ++ .rename2 = ovl_rename2,
8752 ++ .link = ovl_link,
8753 ++ .setattr = ovl_setattr,
8754 ++ .create = ovl_create,
8755 ++ .mknod = ovl_mknod,
8756 ++ .permission = ovl_permission,
8757 ++ .getattr = ovl_dir_getattr,
8758 ++ .setxattr = ovl_setxattr,
8759 ++ .getxattr = ovl_getxattr,
8760 ++ .listxattr = ovl_listxattr,
8761 ++ .removexattr = ovl_removexattr,
8762 ++};
8763 +--- /dev/null
8764 ++++ b/fs/overlayfs/inode.c
8765 +@@ -0,0 +1,408 @@
8766 ++/*
8767 ++ *
8768 ++ * Copyright (C) 2011 Novell Inc.
8769 ++ *
8770 ++ * This program is free software; you can redistribute it and/or modify it
8771 ++ * under the terms of the GNU General Public License version 2 as published by
8772 ++ * the Free Software Foundation.
8773 ++ */
8775 ++#include <linux/fs.h>
8776 ++#include <linux/slab.h>
8777 ++#include <linux/xattr.h>
8778 ++#include "overlayfs.h"
8780 ++int ovl_setattr(struct dentry *dentry, struct iattr *attr)
8782 ++ struct dentry *upperdentry;
8783 ++ int err;
8785 ++ err = ovl_want_write(dentry);
8786 ++ if (err)
8787 ++ goto out;
8789 ++ if ((attr->ia_valid & ATTR_SIZE) && !ovl_dentry_upper(dentry))
8790 ++ err = ovl_copy_up_truncate(dentry, attr->ia_size);
8791 ++ else
8792 ++ err = ovl_copy_up(dentry);
8793 ++ if (err)
8794 ++ goto out_drop_write;
8796 ++ upperdentry = ovl_dentry_upper(dentry);
8798 ++ if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
8799 ++ attr->ia_valid &= ~ATTR_MODE;
8801 ++ mutex_lock(&upperdentry->d_inode->i_mutex);
8802 ++ err = notify_change(upperdentry, attr, NULL);
8803 ++ if (!err)
8804 ++ ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
8805 ++ mutex_unlock(&upperdentry->d_inode->i_mutex);
8807 ++out_drop_write:
8808 ++ ovl_drop_write(dentry);
8809 ++out:
8810 ++ return err;
8813 ++static int ovl_getattr(struct vfsmount *mnt, struct dentry *dentry,
8814 ++ struct kstat *stat)
8816 ++ struct path realpath;
8818 ++ ovl_path_real(dentry, &realpath);
8819 ++ return vfs_getattr(&realpath, stat);
8822 ++int ovl_permission(struct inode *inode, int mask)
8824 ++ struct ovl_entry *oe;
8825 ++ struct dentry *alias = NULL;
8826 ++ struct inode *realinode;
8827 ++ struct dentry *realdentry;
8828 ++ bool is_upper;
8829 ++ int err;
8831 ++ if (S_ISDIR(inode->i_mode)) {
8832 ++ oe = inode->i_private;
8833 ++ } else if (mask & MAY_NOT_BLOCK) {
8834 ++ return -ECHILD;
8835 ++ } else {
8836 ++ /*
8837 ++ * For non-directories find an alias and get the info
8838 ++ * from there.
8839 ++ */
8840 ++ alias = d_find_any_alias(inode);
8841 ++ if (WARN_ON(!alias))
8842 ++ return -ENOENT;
8844 ++ oe = alias->d_fsdata;
8845 ++ }
8847 ++ realdentry = ovl_entry_real(oe, &is_upper);
8849 ++ /* Careful in RCU walk mode */
8850 ++ realinode = ACCESS_ONCE(realdentry->d_inode);
8851 ++ if (!realinode) {
8852 ++ WARN_ON(!(mask & MAY_NOT_BLOCK));
8853 ++ err = -ENOENT;
8854 ++ goto out_dput;
8855 ++ }
8857 ++ if (mask & MAY_WRITE) {
8858 ++ umode_t mode = realinode->i_mode;
8860 ++ /*
8861 ++ * Writes will always be redirected to upper layer, so
8862 ++ * ignore lower layer being read-only.
8863 ++ *
8864 ++ * If the overlay itself is read-only then proceed
8865 ++ * with the permission check, don't return EROFS.
8866 ++ * This will only happen if this is the lower layer of
8867 ++ * another overlayfs.
8868 ++ *
8869 ++ * If upper fs becomes read-only after the overlay was
8870 ++ * constructed return EROFS to prevent modification of
8871 ++ * upper layer.
8872 ++ */
8873 ++ err = -EROFS;
8874 ++ if (is_upper && !IS_RDONLY(inode) && IS_RDONLY(realinode) &&
8875 ++ (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
8876 ++ goto out_dput;
8877 ++ }
8879 ++ err = __inode_permission(realinode, mask);
8880 ++out_dput:
8881 ++ dput(alias);
8882 ++ return err;
8886 ++struct ovl_link_data {
8887 ++ struct dentry *realdentry;
8888 ++ void *cookie;
8889 ++};
8891 ++static void *ovl_follow_link(struct dentry *dentry, struct nameidata *nd)
8893 ++ void *ret;
8894 ++ struct dentry *realdentry;
8895 ++ struct inode *realinode;
8897 ++ realdentry = ovl_dentry_real(dentry);
8898 ++ realinode = realdentry->d_inode;
8900 ++ if (WARN_ON(!realinode->i_op->follow_link))
8901 ++ return ERR_PTR(-EPERM);
8903 ++ ret = realinode->i_op->follow_link(realdentry, nd);
8904 ++ if (IS_ERR(ret))
8905 ++ return ret;
8907 ++ if (realinode->i_op->put_link) {
8908 ++ struct ovl_link_data *data;
8910 ++ data = kmalloc(sizeof(struct ovl_link_data), GFP_KERNEL);
8911 ++ if (!data) {
8912 ++ realinode->i_op->put_link(realdentry, nd, ret);
8913 ++ return ERR_PTR(-ENOMEM);
8914 ++ }
8915 ++ data->realdentry = realdentry;
8916 ++ data->cookie = ret;
8918 ++ return data;
8919 ++ } else {
8920 ++ return NULL;
8921 ++ }
8924 ++static void ovl_put_link(struct dentry *dentry, struct nameidata *nd, void *c)
8926 ++ struct inode *realinode;
8927 ++ struct ovl_link_data *data = c;
8929 ++ if (!data)
8930 ++ return;
8932 ++ realinode = data->realdentry->d_inode;
8933 ++ realinode->i_op->put_link(data->realdentry, nd, data->cookie);
8934 ++ kfree(data);
8937 ++static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz)
8939 ++ struct path realpath;
8940 ++ struct inode *realinode;
8942 ++ ovl_path_real(dentry, &realpath);
8943 ++ realinode = realpath.dentry->d_inode;
8945 ++ if (!realinode->i_op->readlink)
8946 ++ return -EINVAL;
8948 ++ touch_atime(&realpath);
8950 ++ return realinode->i_op->readlink(realpath.dentry, buf, bufsiz);
8954 ++static bool ovl_is_private_xattr(const char *name)
8956 ++ return strncmp(name, "trusted.overlay.", 14) == 0;
8959 ++int ovl_setxattr(struct dentry *dentry, const char *name,
8960 ++ const void *value, size_t size, int flags)
8962 ++ int err;
8963 ++ struct dentry *upperdentry;
8965 ++ err = ovl_want_write(dentry);
8966 ++ if (err)
8967 ++ goto out;
8969 ++ err = -EPERM;
8970 ++ if (ovl_is_private_xattr(name))
8971 ++ goto out_drop_write;
8973 ++ err = ovl_copy_up(dentry);
8974 ++ if (err)
8975 ++ goto out_drop_write;
8977 ++ upperdentry = ovl_dentry_upper(dentry);
8978 ++ err = vfs_setxattr(upperdentry, name, value, size, flags);
8980 ++out_drop_write:
8981 ++ ovl_drop_write(dentry);
8982 ++out:
8983 ++ return err;
8986 ++ssize_t ovl_getxattr(struct dentry *dentry, const char *name,
8987 ++ void *value, size_t size)
8989 ++ if (ovl_path_type(dentry->d_parent) == OVL_PATH_MERGE &&
8990 ++ ovl_is_private_xattr(name))
8991 ++ return -ENODATA;
8993 ++ return vfs_getxattr(ovl_dentry_real(dentry), name, value, size);
8996 ++ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
8998 ++ ssize_t res;
8999 ++ int off;
9001 ++ res = vfs_listxattr(ovl_dentry_real(dentry), list, size);
9002 ++ if (res <= 0 || size == 0)
9003 ++ return res;
9005 ++ if (ovl_path_type(dentry->d_parent) != OVL_PATH_MERGE)
9006 ++ return res;
9008 ++ /* filter out private xattrs */
9009 ++ for (off = 0; off < res;) {
9010 ++ char *s = list + off;
9011 ++ size_t slen = strlen(s) + 1;
9013 ++ BUG_ON(off + slen > res);
9015 ++ if (ovl_is_private_xattr(s)) {
9016 ++ res -= slen;
9017 ++ memmove(s, s + slen, res - off);
9018 ++ } else {
9019 ++ off += slen;
9020 ++ }
9021 ++ }
9023 ++ return res;
9026 ++int ovl_removexattr(struct dentry *dentry, const char *name)
9028 ++ int err;
9029 ++ struct path realpath;
9030 ++ enum ovl_path_type type;
9032 ++ err = ovl_want_write(dentry);
9033 ++ if (err)
9034 ++ goto out;
9036 ++ if (ovl_path_type(dentry->d_parent) == OVL_PATH_MERGE &&
9037 ++ ovl_is_private_xattr(name))
9038 ++ goto out_drop_write;
9040 ++ type = ovl_path_real(dentry, &realpath);
9041 ++ if (type == OVL_PATH_LOWER) {
9042 ++ err = vfs_getxattr(realpath.dentry, name, NULL, 0);
9043 ++ if (err < 0)
9044 ++ goto out_drop_write;
9046 ++ err = ovl_copy_up(dentry);
9047 ++ if (err)
9048 ++ goto out_drop_write;
9050 ++ ovl_path_upper(dentry, &realpath);
9051 ++ }
9053 ++ err = vfs_removexattr(realpath.dentry, name);
9054 ++out_drop_write:
9055 ++ ovl_drop_write(dentry);
9056 ++out:
9057 ++ return err;
9060 ++static bool ovl_open_need_copy_up(int flags, enum ovl_path_type type,
9061 ++ struct dentry *realdentry)
9063 ++ if (type != OVL_PATH_LOWER)
9064 ++ return false;
9066 ++ if (special_file(realdentry->d_inode->i_mode))
9067 ++ return false;
9069 ++ if (!(OPEN_FMODE(flags) & FMODE_WRITE) && !(flags & O_TRUNC))
9070 ++ return false;
9072 ++ return true;
9075 ++static int ovl_dentry_open(struct dentry *dentry, struct file *file,
9076 ++ const struct cred *cred)
9078 ++ int err;
9079 ++ struct path realpath;
9080 ++ enum ovl_path_type type;
9081 ++ bool want_write = false;
9083 ++ type = ovl_path_real(dentry, &realpath);
9084 ++ if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) {
9085 ++ want_write = true;
9086 ++ err = ovl_want_write(dentry);
9087 ++ if (err)
9088 ++ goto out;
9090 ++ if (file->f_flags & O_TRUNC)
9091 ++ err = ovl_copy_up_truncate(dentry, 0);
9092 ++ else
9093 ++ err = ovl_copy_up(dentry);
9094 ++ if (err)
9095 ++ goto out_drop_write;
9097 ++ ovl_path_upper(dentry, &realpath);
9098 ++ }
9100 ++ err = vfs_open(&realpath, file, cred);
9101 ++out_drop_write:
9102 ++ if (want_write)
9103 ++ ovl_drop_write(dentry);
9104 ++out:
9105 ++ return err;
9108 ++static const struct inode_operations ovl_file_inode_operations = {
9109 ++ .setattr = ovl_setattr,
9110 ++ .permission = ovl_permission,
9111 ++ .getattr = ovl_getattr,
9112 ++ .setxattr = ovl_setxattr,
9113 ++ .getxattr = ovl_getxattr,
9114 ++ .listxattr = ovl_listxattr,
9115 ++ .removexattr = ovl_removexattr,
9116 ++ .dentry_open = ovl_dentry_open,
9117 ++};
9119 ++static const struct inode_operations ovl_symlink_inode_operations = {
9120 ++ .setattr = ovl_setattr,
9121 ++ .follow_link = ovl_follow_link,
9122 ++ .put_link = ovl_put_link,
9123 ++ .readlink = ovl_readlink,
9124 ++ .getattr = ovl_getattr,
9125 ++ .setxattr = ovl_setxattr,
9126 ++ .getxattr = ovl_getxattr,
9127 ++ .listxattr = ovl_listxattr,
9128 ++ .removexattr = ovl_removexattr,
9129 ++};
9131 ++struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
9132 ++ struct ovl_entry *oe)
9134 ++ struct inode *inode;
9136 ++ inode = new_inode(sb);
9137 ++ if (!inode)
9138 ++ return NULL;
9140 ++ mode &= S_IFMT;
9142 ++ inode->i_ino = get_next_ino();
9143 ++ inode->i_mode = mode;
9144 ++ inode->i_flags |= S_NOATIME | S_NOCMTIME;
9146 ++ switch (mode) {
9147 ++ case S_IFDIR:
9148 ++ inode->i_private = oe;
9149 ++ inode->i_op = &ovl_dir_inode_operations;
9150 ++ inode->i_fop = &ovl_dir_operations;
9151 ++ break;
9153 ++ case S_IFLNK:
9154 ++ inode->i_op = &ovl_symlink_inode_operations;
9155 ++ break;
9157 ++ case S_IFREG:
9158 ++ case S_IFSOCK:
9159 ++ case S_IFBLK:
9160 ++ case S_IFCHR:
9161 ++ case S_IFIFO:
9162 ++ inode->i_op = &ovl_file_inode_operations;
9163 ++ break;
9165 ++ default:
9166 ++ WARN(1, "illegal file type: %i\n", mode);
9167 ++ iput(inode);
9168 ++ inode = NULL;
9169 ++ }
9171 ++ return inode;
9174 +--- /dev/null
9175 ++++ b/fs/overlayfs/overlayfs.h
9176 +@@ -0,0 +1,187 @@
9177 ++/*
9178 ++ *
9179 ++ * Copyright (C) 2011 Novell Inc.
9180 ++ *
9181 ++ * This program is free software; you can redistribute it and/or modify it
9182 ++ * under the terms of the GNU General Public License version 2 as published by
9183 ++ * the Free Software Foundation.
9184 ++ */
9186 ++#include <linux/kernel.h>
9188 ++struct ovl_entry;
9190 ++enum ovl_path_type {
9191 ++ OVL_PATH_UPPER,
9192 ++ OVL_PATH_MERGE,
9193 ++ OVL_PATH_LOWER,
9194 ++};
9196 ++extern const char *ovl_opaque_xattr;
9197 ++extern const struct dentry_operations ovl_dentry_operations;
9199 ++static inline int ovl_do_rmdir(struct inode *dir, struct dentry *dentry)
9201 ++ int err = vfs_rmdir(dir, dentry);
9202 ++ pr_debug("rmdir(%pd2) = %i\n", dentry, err);
9203 ++ return err;
9206 ++static inline int ovl_do_unlink(struct inode *dir, struct dentry *dentry)
9208 ++ int err = vfs_unlink(dir, dentry, NULL);
9209 ++ pr_debug("unlink(%pd2) = %i\n", dentry, err);
9210 ++ return err;
9213 ++static inline int ovl_do_link(struct dentry *old_dentry, struct inode *dir,
9214 ++ struct dentry *new_dentry, bool debug)
9216 ++ int err = vfs_link(old_dentry, dir, new_dentry, NULL);
9217 ++ if (debug) {
9218 ++ pr_debug("link(%pd2, %pd2) = %i\n",
9219 ++ old_dentry, new_dentry, err);
9220 ++ }
9221 ++ return err;
9224 ++static inline int ovl_do_create(struct inode *dir, struct dentry *dentry,
9225 ++ umode_t mode, bool debug)
9227 ++ int err = vfs_create(dir, dentry, mode, true);
9228 ++ if (debug)
9229 ++ pr_debug("create(%pd2, 0%o) = %i\n", dentry, mode, err);
9230 ++ return err;
9233 ++static inline int ovl_do_mkdir(struct inode *dir, struct dentry *dentry,
9234 ++ umode_t mode, bool debug)
9236 ++ int err = vfs_mkdir(dir, dentry, mode);
9237 ++ if (debug)
9238 ++ pr_debug("mkdir(%pd2, 0%o) = %i\n", dentry, mode, err);
9239 ++ return err;
9242 ++static inline int ovl_do_mknod(struct inode *dir, struct dentry *dentry,
9243 ++ umode_t mode, dev_t dev, bool debug)
9245 ++ int err = vfs_mknod(dir, dentry, mode, dev);
9246 ++ if (debug) {
9247 ++ pr_debug("mknod(%pd2, 0%o, 0%o) = %i\n",
9248 ++ dentry, mode, dev, err);
9249 ++ }
9250 ++ return err;
9253 ++static inline int ovl_do_symlink(struct inode *dir, struct dentry *dentry,
9254 ++ const char *oldname, bool debug)
9256 ++ int err = vfs_symlink(dir, dentry, oldname);
9257 ++ if (debug)
9258 ++ pr_debug("symlink(\"%s\", %pd2) = %i\n", oldname, dentry, err);
9259 ++ return err;
9262 ++static inline int ovl_do_setxattr(struct dentry *dentry, const char *name,
9263 ++ const void *value, size_t size, int flags)
9265 ++ int err = vfs_setxattr(dentry, name, value, size, flags);
9266 ++ pr_debug("setxattr(%pd2, \"%s\", \"%*s\", 0x%x) = %i\n",
9267 ++ dentry, name, (int) size, (char *) value, flags, err);
9268 ++ return err;
9271 ++static inline int ovl_do_removexattr(struct dentry *dentry, const char *name)
9273 ++ int err = vfs_removexattr(dentry, name);
9274 ++ pr_debug("removexattr(%pd2, \"%s\") = %i\n", dentry, name, err);
9275 ++ return err;
9278 ++static inline int ovl_do_rename(struct inode *olddir, struct dentry *olddentry,
9279 ++ struct inode *newdir, struct dentry *newdentry,
9280 ++ unsigned int flags)
9282 ++ int err;
9284 ++ pr_debug("rename2(%pd2, %pd2, 0x%x)\n",
9285 ++ olddentry, newdentry, flags);
9287 ++ err = vfs_rename(olddir, olddentry, newdir, newdentry, NULL, flags);
9289 ++ if (err) {
9290 ++ pr_debug("...rename2(%pd2, %pd2, ...) = %i\n",
9291 ++ olddentry, newdentry, err);
9292 ++ }
9293 ++ return err;
9296 ++static inline int ovl_do_whiteout(struct inode *dir, struct dentry *dentry)
9298 ++ int err = vfs_whiteout(dir, dentry);
9299 ++ pr_debug("whiteout(%pd2) = %i\n", dentry, err);
9300 ++ return err;
9303 ++enum ovl_path_type ovl_path_type(struct dentry *dentry);
9304 ++u64 ovl_dentry_version_get(struct dentry *dentry);
9305 ++void ovl_dentry_version_inc(struct dentry *dentry);
9306 ++void ovl_path_upper(struct dentry *dentry, struct path *path);
9307 ++void ovl_path_lower(struct dentry *dentry, struct path *path);
9308 ++enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path);
9309 ++struct dentry *ovl_dentry_upper(struct dentry *dentry);
9310 ++struct dentry *ovl_dentry_lower(struct dentry *dentry);
9311 ++struct dentry *ovl_dentry_real(struct dentry *dentry);
9312 ++struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper);
9313 ++struct dentry *ovl_workdir(struct dentry *dentry);
9314 ++int ovl_want_write(struct dentry *dentry);
9315 ++void ovl_drop_write(struct dentry *dentry);
9316 ++bool ovl_dentry_is_opaque(struct dentry *dentry);
9317 ++void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque);
9318 ++bool ovl_is_whiteout(struct dentry *dentry);
9319 ++void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry);
9320 ++struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
9321 ++ unsigned int flags);
9322 ++struct file *ovl_path_open(struct path *path, int flags);
9324 ++struct dentry *ovl_upper_create(struct dentry *upperdir, struct dentry *dentry,
9325 ++ struct kstat *stat, const char *link);
9327 ++/* readdir.c */
9328 ++extern const struct file_operations ovl_dir_operations;
9329 ++int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list);
9330 ++void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list);
9331 ++void ovl_cache_free(struct list_head *list);
9333 ++/* inode.c */
9334 ++int ovl_setattr(struct dentry *dentry, struct iattr *attr);
9335 ++int ovl_permission(struct inode *inode, int mask);
9336 ++int ovl_setxattr(struct dentry *dentry, const char *name,
9337 ++ const void *value, size_t size, int flags);
9338 ++ssize_t ovl_getxattr(struct dentry *dentry, const char *name,
9339 ++ void *value, size_t size);
9340 ++ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
9341 ++int ovl_removexattr(struct dentry *dentry, const char *name);
9343 ++struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
9344 ++ struct ovl_entry *oe);
9345 ++static inline void ovl_copyattr(struct inode *from, struct inode *to)
9347 ++ to->i_uid = from->i_uid;
9348 ++ to->i_gid = from->i_gid;
9351 ++/* dir.c */
9352 ++extern const struct inode_operations ovl_dir_inode_operations;
9353 ++struct dentry *ovl_lookup_temp(struct dentry *workdir, struct dentry *dentry);
9354 ++int ovl_create_real(struct inode *dir, struct dentry *newdentry,
9355 ++ struct kstat *stat, const char *link,
9356 ++ struct dentry *hardlink, bool debug);
9357 ++void ovl_cleanup(struct inode *dir, struct dentry *dentry);
9359 ++/* copy_up.c */
9360 ++int ovl_copy_up(struct dentry *dentry);
9361 ++int ovl_copy_up_truncate(struct dentry *dentry, loff_t size);
9362 ++int ovl_copy_xattr(struct dentry *old, struct dentry *new);
9363 ++int ovl_set_attr(struct dentry *upper, struct kstat *stat);
9364 +--- /dev/null
9365 ++++ b/fs/overlayfs/readdir.c
9366 +@@ -0,0 +1,518 @@
9367 ++/*
9368 ++ *
9369 ++ * Copyright (C) 2011 Novell Inc.
9370 ++ *
9371 ++ * This program is free software; you can redistribute it and/or modify it
9372 ++ * under the terms of the GNU General Public License version 2 as published by
9373 ++ * the Free Software Foundation.
9374 ++ */
9376 ++#include <linux/fs.h>
9377 ++#include <linux/slab.h>
9378 ++#include <linux/namei.h>
9379 ++#include <linux/file.h>
9380 ++#include <linux/xattr.h>
9381 ++#include <linux/rbtree.h>
9382 ++#include <linux/security.h>
9383 ++#include <linux/cred.h>
9384 ++#include "overlayfs.h"
9386 ++struct ovl_cache_entry {
9387 ++ const char *name;
9388 ++ unsigned int len;
9389 ++ unsigned int type;
9390 ++ u64 ino;
9391 ++ bool is_whiteout;
9392 ++ struct list_head l_node;
9393 ++ struct rb_node node;
9394 ++};
9396 ++struct ovl_readdir_data {
9397 ++ struct dir_context ctx;
9398 ++ bool is_merge;
9399 ++ struct rb_root *root;
9400 ++ struct list_head *list;
9401 ++ struct list_head *middle;
9402 ++ int count;
9403 ++ int err;
9404 ++};
9406 ++struct ovl_dir_file {
9407 ++ bool is_real;
9408 ++ bool is_cached;
9409 ++ struct list_head cursor;
9410 ++ u64 cache_version;
9411 ++ struct list_head cache;
9412 ++ struct file *realfile;
9413 ++};
9415 ++static struct ovl_cache_entry *ovl_cache_entry_from_node(struct rb_node *n)
9417 ++ return container_of(n, struct ovl_cache_entry, node);
9420 ++static struct ovl_cache_entry *ovl_cache_entry_find(struct rb_root *root,
9421 ++ const char *name, int len)
9423 ++ struct rb_node *node = root->rb_node;
9424 ++ int cmp;
9426 ++ while (node) {
9427 ++ struct ovl_cache_entry *p = ovl_cache_entry_from_node(node);
9429 ++ cmp = strncmp(name, p->name, len);
9430 ++ if (cmp > 0)
9431 ++ node = p->node.rb_right;
9432 ++ else if (cmp < 0 || len < p->len)
9433 ++ node = p->node.rb_left;
9434 ++ else
9435 ++ return p;
9436 ++ }
9438 ++ return NULL;
9441 ++static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len,
9442 ++ u64 ino, unsigned int d_type)
9444 ++ struct ovl_cache_entry *p;
9446 ++ p = kmalloc(sizeof(*p) + len + 1, GFP_KERNEL);
9447 ++ if (p) {
9448 ++ char *name_copy = (char *) (p + 1);
9449 ++ memcpy(name_copy, name, len);
9450 ++ name_copy[len] = '\0';
9451 ++ p->name = name_copy;
9452 ++ p->len = len;
9453 ++ p->type = d_type;
9454 ++ p->ino = ino;
9455 ++ p->is_whiteout = false;
9456 ++ }
9458 ++ return p;
9461 ++static int ovl_cache_entry_add_rb(struct ovl_readdir_data *rdd,
9462 ++ const char *name, int len, u64 ino,
9463 ++ unsigned int d_type)
9465 ++ struct rb_node **newp = &rdd->root->rb_node;
9466 ++ struct rb_node *parent = NULL;
9467 ++ struct ovl_cache_entry *p;
9469 ++ while (*newp) {
9470 ++ int cmp;
9471 ++ struct ovl_cache_entry *tmp;
9473 ++ parent = *newp;
9474 ++ tmp = ovl_cache_entry_from_node(*newp);
9475 ++ cmp = strncmp(name, tmp->name, len);
9476 ++ if (cmp > 0)
9477 ++ newp = &tmp->node.rb_right;
9478 ++ else if (cmp < 0 || len < tmp->len)
9479 ++ newp = &tmp->node.rb_left;
9480 ++ else
9481 ++ return 0;
9482 ++ }
9484 ++ p = ovl_cache_entry_new(name, len, ino, d_type);
9485 ++ if (p == NULL)
9486 ++ return -ENOMEM;
9488 ++ list_add_tail(&p->l_node, rdd->list);
9489 ++ rb_link_node(&p->node, parent, newp);
9490 ++ rb_insert_color(&p->node, rdd->root);
9492 ++ return 0;
9495 ++static int ovl_fill_lower(struct ovl_readdir_data *rdd,
9496 ++ const char *name, int namelen,
9497 ++ loff_t offset, u64 ino, unsigned int d_type)
9499 ++ struct ovl_cache_entry *p;
9501 ++ p = ovl_cache_entry_find(rdd->root, name, namelen);
9502 ++ if (p) {
9503 ++ list_move_tail(&p->l_node, rdd->middle);
9504 ++ } else {
9505 ++ p = ovl_cache_entry_new(name, namelen, ino, d_type);
9506 ++ if (p == NULL)
9507 ++ rdd->err = -ENOMEM;
9508 ++ else
9509 ++ list_add_tail(&p->l_node, rdd->middle);
9510 ++ }
9512 ++ return rdd->err;
9515 ++void ovl_cache_free(struct list_head *list)
9517 ++ struct ovl_cache_entry *p;
9518 ++ struct ovl_cache_entry *n;
9520 ++ list_for_each_entry_safe(p, n, list, l_node)
9521 ++ kfree(p);
9523 ++ INIT_LIST_HEAD(list);
9526 ++static int ovl_fill_merge(void *buf, const char *name, int namelen,
9527 ++ loff_t offset, u64 ino, unsigned int d_type)
9529 ++ struct ovl_readdir_data *rdd = buf;
9531 ++ rdd->count++;
9532 ++ if (!rdd->is_merge)
9533 ++ return ovl_cache_entry_add_rb(rdd, name, namelen, ino, d_type);
9534 ++ else
9535 ++ return ovl_fill_lower(rdd, name, namelen, offset, ino, d_type);
9538 ++static inline int ovl_dir_read(struct path *realpath,
9539 ++ struct ovl_readdir_data *rdd)
9541 ++ struct file *realfile;
9542 ++ int err;
9544 ++ realfile = ovl_path_open(realpath, O_RDONLY | O_DIRECTORY);
9545 ++ if (IS_ERR(realfile))
9546 ++ return PTR_ERR(realfile);
9548 ++ rdd->ctx.pos = 0;
9549 ++ do {
9550 ++ rdd->count = 0;
9551 ++ rdd->err = 0;
9552 ++ err = iterate_dir(realfile, &rdd->ctx);
9553 ++ if (err >= 0)
9554 ++ err = rdd->err;
9555 ++ } while (!err && rdd->count);
9556 ++ fput(realfile);
9558 ++ return err;
9561 ++static void ovl_dir_reset(struct file *file)
9563 ++ struct ovl_dir_file *od = file->private_data;
9564 ++ enum ovl_path_type type = ovl_path_type(file->f_path.dentry);
9566 ++ if (ovl_dentry_version_get(file->f_path.dentry) != od->cache_version) {
9567 ++ list_del_init(&od->cursor);
9568 ++ ovl_cache_free(&od->cache);
9569 ++ od->is_cached = false;
9570 ++ }
9571 ++ WARN_ON(!od->is_real && type != OVL_PATH_MERGE);
9572 ++ if (od->is_real && type == OVL_PATH_MERGE) {
9573 ++ fput(od->realfile);
9574 ++ od->realfile = NULL;
9575 ++ od->is_real = false;
9576 ++ }
9579 ++static int ovl_dir_mark_whiteouts(struct dentry *dir,
9580 ++ struct ovl_readdir_data *rdd)
9582 ++ struct ovl_cache_entry *p;
9583 ++ struct dentry *dentry;
9584 ++ const struct cred *old_cred;
9585 ++ struct cred *override_cred;
9587 ++ override_cred = prepare_creds();
9588 ++ if (!override_cred) {
9589 ++ ovl_cache_free(rdd->list);
9590 ++ return -ENOMEM;
9591 ++ }
9593 ++ /*
9594 ++ * CAP_DAC_OVERRIDE for lookup
9595 ++ */
9596 ++ cap_raise(override_cred->cap_effective, CAP_DAC_OVERRIDE);
9597 ++ old_cred = override_creds(override_cred);
9599 ++ mutex_lock(&dir->d_inode->i_mutex);
9600 ++ list_for_each_entry(p, rdd->list, l_node) {
9601 ++ if (p->type != DT_CHR)
9602 ++ continue;
9604 ++ dentry = lookup_one_len(p->name, dir, p->len);
9605 ++ if (IS_ERR(dentry))
9606 ++ continue;
9608 ++ p->is_whiteout = ovl_is_whiteout(dentry);
9609 ++ dput(dentry);
9610 ++ }
9611 ++ mutex_unlock(&dir->d_inode->i_mutex);
9613 ++ revert_creds(old_cred);
9614 ++ put_cred(override_cred);
9616 ++ return 0;
9619 ++static inline int ovl_dir_read_merged(struct path *upperpath,
9620 ++ struct path *lowerpath,
9621 ++ struct list_head *list)
9623 ++ int err;
9624 ++ struct rb_root root = RB_ROOT;
9625 ++ struct list_head middle;
9626 ++ struct ovl_readdir_data rdd = {
9627 ++ .ctx.actor = ovl_fill_merge,
9628 ++ .list = list,
9629 ++ .root = &root,
9630 ++ .is_merge = false,
9631 ++ };
9633 ++ if (upperpath->dentry) {
9634 ++ err = ovl_dir_read(upperpath, &rdd);
9635 ++ if (err)
9636 ++ goto out;
9638 ++ if (lowerpath->dentry) {
9639 ++ err = ovl_dir_mark_whiteouts(upperpath->dentry, &rdd);
9640 ++ if (err)
9641 ++ goto out;
9642 ++ }
9643 ++ }
9644 ++ if (lowerpath->dentry) {
9645 ++ /*
9646 ++ * Insert lowerpath entries before upperpath ones, this allows
9647 ++ * offsets to be reasonably constant
9648 ++ */
9649 ++ list_add(&middle, rdd.list);
9650 ++ rdd.middle = &middle;
9651 ++ rdd.is_merge = true;
9652 ++ err = ovl_dir_read(lowerpath, &rdd);
9653 ++ list_del(&middle);
9654 ++ }
9655 ++out:
9656 ++ return err;
9660 ++static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
9662 ++ struct list_head *l;
9663 ++ loff_t off;
9665 ++ l = od->cache.next;
9666 ++ for (off = 0; off < pos; off++) {
9667 ++ if (l == &od->cache)
9668 ++ break;
9669 ++ l = l->next;
9670 ++ }
9671 ++ list_move_tail(&od->cursor, l);
9674 ++static int ovl_iterate(struct file *file, struct dir_context *ctx)
9676 ++ struct ovl_dir_file *od = file->private_data;
9677 ++ int res;
9679 ++ if (!ctx->pos)
9680 ++ ovl_dir_reset(file);
9682 ++ if (od->is_real) {
9683 ++ res = iterate_dir(od->realfile, ctx);
9685 ++ return res;
9686 ++ }
9688 ++ if (!od->is_cached) {
9689 ++ struct path lowerpath;
9690 ++ struct path upperpath;
9692 ++ ovl_path_lower(file->f_path.dentry, &lowerpath);
9693 ++ ovl_path_upper(file->f_path.dentry, &upperpath);
9695 ++ res = ovl_dir_read_merged(&upperpath, &lowerpath, &od->cache);
9696 ++ if (res) {
9697 ++ ovl_cache_free(&od->cache);
9698 ++ return res;
9699 ++ }
9701 ++ od->cache_version = ovl_dentry_version_get(file->f_path.dentry);
9702 ++ od->is_cached = true;
9704 ++ ovl_seek_cursor(od, ctx->pos);
9705 ++ }
9707 ++ while (od->cursor.next != &od->cache) {
9708 ++ struct ovl_cache_entry *p;
9710 ++ p = list_entry(od->cursor.next, struct ovl_cache_entry, l_node);
9711 ++ if (!p->is_whiteout) {
9712 ++ if (!dir_emit(ctx, p->name, p->len, p->ino, p->type))
9713 ++ break;
9714 ++ }
9715 ++ ctx->pos++;
9716 ++ list_move(&od->cursor, &p->l_node);
9717 ++ }
9719 ++ return 0;
9722 ++static loff_t ovl_dir_llseek(struct file *file, loff_t offset, int origin)
9724 ++ loff_t res;
9725 ++ struct ovl_dir_file *od = file->private_data;
9727 ++ mutex_lock(&file_inode(file)->i_mutex);
9728 ++ if (!file->f_pos)
9729 ++ ovl_dir_reset(file);
9731 ++ if (od->is_real) {
9732 ++ res = vfs_llseek(od->realfile, offset, origin);
9733 ++ file->f_pos = od->realfile->f_pos;
9734 ++ } else {
9735 ++ res = -EINVAL;
9737 ++ switch (origin) {
9738 ++ case SEEK_CUR:
9739 ++ offset += file->f_pos;
9740 ++ break;
9741 ++ case SEEK_SET:
9742 ++ break;
9743 ++ default:
9744 ++ goto out_unlock;
9745 ++ }
9746 ++ if (offset < 0)
9747 ++ goto out_unlock;
9749 ++ if (offset != file->f_pos) {
9750 ++ file->f_pos = offset;
9751 ++ if (od->is_cached)
9752 ++ ovl_seek_cursor(od, offset);
9753 ++ }
9754 ++ res = offset;
9755 ++ }
9756 ++out_unlock:
9757 ++ mutex_unlock(&file_inode(file)->i_mutex);
9759 ++ return res;
9762 ++static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
9763 ++ int datasync)
9765 ++ struct ovl_dir_file *od = file->private_data;
9767 ++ /* May need to reopen directory if it got copied up */
9768 ++ if (!od->realfile) {
9769 ++ struct path upperpath;
9771 ++ ovl_path_upper(file->f_path.dentry, &upperpath);
9772 ++ od->realfile = ovl_path_open(&upperpath, O_RDONLY);
9773 ++ if (IS_ERR(od->realfile))
9774 ++ return PTR_ERR(od->realfile);
9775 ++ }
9777 ++ return vfs_fsync_range(od->realfile, start, end, datasync);
9780 ++static int ovl_dir_release(struct inode *inode, struct file *file)
9782 ++ struct ovl_dir_file *od = file->private_data;
9784 ++ list_del(&od->cursor);
9785 ++ ovl_cache_free(&od->cache);
9786 ++ if (od->realfile)
9787 ++ fput(od->realfile);
9788 ++ kfree(od);
9790 ++ return 0;
9793 ++static int ovl_dir_open(struct inode *inode, struct file *file)
9795 ++ struct path realpath;
9796 ++ struct file *realfile;
9797 ++ struct ovl_dir_file *od;
9798 ++ enum ovl_path_type type;
9800 ++ od = kzalloc(sizeof(struct ovl_dir_file), GFP_KERNEL);
9801 ++ if (!od)
9802 ++ return -ENOMEM;
9804 ++ type = ovl_path_real(file->f_path.dentry, &realpath);
9805 ++ realfile = ovl_path_open(&realpath, file->f_flags);
9806 ++ if (IS_ERR(realfile)) {
9807 ++ kfree(od);
9808 ++ return PTR_ERR(realfile);
9809 ++ }
9810 ++ INIT_LIST_HEAD(&od->cache);
9811 ++ INIT_LIST_HEAD(&od->cursor);
9812 ++ od->is_cached = false;
9813 ++ od->realfile = realfile;
9814 ++ od->is_real = (type != OVL_PATH_MERGE);
9815 ++ file->private_data = od;
9817 ++ return 0;
9820 ++const struct file_operations ovl_dir_operations = {
9821 ++ .read = generic_read_dir,
9822 ++ .open = ovl_dir_open,
9823 ++ .iterate = ovl_iterate,
9824 ++ .llseek = ovl_dir_llseek,
9825 ++ .fsync = ovl_dir_fsync,
9826 ++ .release = ovl_dir_release,
9827 ++};
9829 ++int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
9831 ++ int err;
9832 ++ struct path lowerpath;
9833 ++ struct path upperpath;
9834 ++ struct ovl_cache_entry *p;
9836 ++ ovl_path_upper(dentry, &upperpath);
9837 ++ ovl_path_lower(dentry, &lowerpath);
9839 ++ err = ovl_dir_read_merged(&upperpath, &lowerpath, list);
9840 ++ if (err)
9841 ++ return err;
9843 ++ err = 0;
9845 ++ list_for_each_entry(p, list, l_node) {
9846 ++ if (p->is_whiteout)
9847 ++ continue;
9849 ++ if (p->name[0] == '.') {
9850 ++ if (p->len == 1)
9851 ++ continue;
9852 ++ if (p->len == 2 && p->name[1] == '.')
9853 ++ continue;
9854 ++ }
9855 ++ err = -ENOTEMPTY;
9856 ++ break;
9857 ++ }
9859 ++ return err;
9862 ++void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list)
9864 ++ struct ovl_cache_entry *p;
9866 ++ mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_PARENT);
9867 ++ list_for_each_entry(p, list, l_node) {
9868 ++ struct dentry *dentry;
9870 ++ if (!p->is_whiteout)
9871 ++ continue;
9873 ++ dentry = lookup_one_len(p->name, upper, p->len);
9874 ++ if (IS_ERR(dentry)) {
9875 ++ pr_err("overlayfs: lookup '%s/%.*s' failed (%i)\n",
9876 ++ upper->d_name.name, p->len, p->name,
9877 ++ (int) PTR_ERR(dentry));
9878 ++ continue;
9879 ++ }
9880 ++ ovl_cleanup(upper->d_inode, dentry);
9881 ++ dput(dentry);
9882 ++ }
9883 ++ mutex_unlock(&upper->d_inode->i_mutex);
9885 +--- /dev/null
9886 ++++ b/fs/overlayfs/super.c
9887 +@@ -0,0 +1,762 @@
9888 ++/*
9889 ++ *
9890 ++ * Copyright (C) 2011 Novell Inc.
9891 ++ *
9892 ++ * This program is free software; you can redistribute it and/or modify it
9893 ++ * under the terms of the GNU General Public License version 2 as published by
9894 ++ * the Free Software Foundation.
9895 ++ */
9897 ++#include <linux/fs.h>
9898 ++#include <linux/namei.h>
9899 ++#include <linux/xattr.h>
9900 ++#include <linux/security.h>
9901 ++#include <linux/mount.h>
9902 ++#include <linux/slab.h>
9903 ++#include <linux/parser.h>
9904 ++#include <linux/module.h>
9905 ++#include <linux/sched.h>
9906 ++#include <linux/statfs.h>
9907 ++#include <linux/seq_file.h>
9908 ++#include "overlayfs.h"
9910 ++MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
9911 ++MODULE_DESCRIPTION("Overlay filesystem");
9912 ++MODULE_LICENSE("GPL");
9914 ++#define OVERLAYFS_SUPER_MAGIC 0x794c764f
9916 ++struct ovl_config {
9917 ++ char *lowerdir;
9918 ++ char *upperdir;
9919 ++ char *workdir;
9920 ++};
9922 ++/* private information held for overlayfs's superblock */
9923 ++struct ovl_fs {
9924 ++ struct vfsmount *upper_mnt;
9925 ++ struct vfsmount *lower_mnt;
9926 ++ struct dentry *workdir;
9927 ++ long lower_namelen;
9928 ++ /* pathnames of lower and upper dirs, for show_options */
9929 ++ struct ovl_config config;
9930 ++};
9932 ++/* private information held for every overlayfs dentry */
9933 ++struct ovl_entry {
9934 ++ /*
9935 ++ * Keep "double reference" on upper dentries, so that
9936 ++ * d_delete() doesn't think it's OK to reset d_inode to NULL.
9937 ++ */
9938 ++ struct dentry *__upperdentry;
9939 ++ struct dentry *lowerdentry;
9940 ++ union {
9941 ++ struct {
9942 ++ u64 version;
9943 ++ bool opaque;
9944 ++ };
9945 ++ struct rcu_head rcu;
9946 ++ };
9947 ++};
9949 ++const char *ovl_opaque_xattr = "trusted.overlay.opaque";
9952 ++enum ovl_path_type ovl_path_type(struct dentry *dentry)
9954 ++ struct ovl_entry *oe = dentry->d_fsdata;
9956 ++ if (oe->__upperdentry) {
9957 ++ if (oe->lowerdentry && S_ISDIR(dentry->d_inode->i_mode))
9958 ++ return OVL_PATH_MERGE;
9959 ++ else
9960 ++ return OVL_PATH_UPPER;
9961 ++ } else {
9962 ++ return OVL_PATH_LOWER;
9963 ++ }
9966 ++static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe)
9968 ++ struct dentry *upperdentry = ACCESS_ONCE(oe->__upperdentry);
9969 ++ /*
9970 ++ * Make sure to order reads to upperdentry wrt ovl_dentry_update()
9971 ++ */
9972 ++ smp_read_barrier_depends();
9973 ++ return upperdentry;
9976 ++void ovl_path_upper(struct dentry *dentry, struct path *path)
9978 ++ struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
9979 ++ struct ovl_entry *oe = dentry->d_fsdata;
9981 ++ path->mnt = ofs->upper_mnt;
9982 ++ path->dentry = ovl_upperdentry_dereference(oe);
9985 ++enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
9988 ++ enum ovl_path_type type = ovl_path_type(dentry);
9990 ++ if (type == OVL_PATH_LOWER)
9991 ++ ovl_path_lower(dentry, path);
9992 ++ else
9993 ++ ovl_path_upper(dentry, path);
9995 ++ return type;
9998 ++struct dentry *ovl_dentry_upper(struct dentry *dentry)
10000 ++ struct ovl_entry *oe = dentry->d_fsdata;
10002 ++ return ovl_upperdentry_dereference(oe);
10005 ++struct dentry *ovl_dentry_lower(struct dentry *dentry)
10007 ++ struct ovl_entry *oe = dentry->d_fsdata;
10009 ++ return oe->lowerdentry;
10012 ++struct dentry *ovl_dentry_real(struct dentry *dentry)
10014 ++ struct ovl_entry *oe = dentry->d_fsdata;
10015 ++ struct dentry *realdentry;
10017 ++ realdentry = ovl_upperdentry_dereference(oe);
10018 ++ if (!realdentry)
10019 ++ realdentry = oe->lowerdentry;
10021 ++ return realdentry;
10024 ++struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper)
10026 ++ struct dentry *realdentry;
10028 ++ realdentry = ovl_upperdentry_dereference(oe);
10029 ++ if (realdentry) {
10030 ++ *is_upper = true;
10031 ++ } else {
10032 ++ realdentry = oe->lowerdentry;
10033 ++ *is_upper = false;
10034 ++ }
10035 ++ return realdentry;
10038 ++void ovl_path_lower(struct dentry *dentry, struct path *path)
10040 ++ struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
10041 ++ struct ovl_entry *oe = dentry->d_fsdata;
10043 ++ path->mnt = ofs->lower_mnt;
10044 ++ path->dentry = oe->lowerdentry;
10047 ++int ovl_want_write(struct dentry *dentry)
10049 ++ struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
10050 ++ return mnt_want_write(ofs->upper_mnt);
10053 ++void ovl_drop_write(struct dentry *dentry)
10055 ++ struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
10056 ++ mnt_drop_write(ofs->upper_mnt);
10059 ++struct dentry *ovl_workdir(struct dentry *dentry)
10061 ++ struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
10062 ++ return ofs->workdir;
10065 ++bool ovl_dentry_is_opaque(struct dentry *dentry)
10067 ++ struct ovl_entry *oe = dentry->d_fsdata;
10068 ++ return oe->opaque;
10071 ++void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque)
10073 ++ struct ovl_entry *oe = dentry->d_fsdata;
10074 ++ oe->opaque = opaque;
10077 ++void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry)
10079 ++ struct ovl_entry *oe = dentry->d_fsdata;
10081 ++ WARN_ON(!mutex_is_locked(&upperdentry->d_parent->d_inode->i_mutex));
10082 ++ WARN_ON(oe->__upperdentry);
10083 ++ BUG_ON(!upperdentry->d_inode);
10084 ++ /*
10085 ++ * Make sure upperdentry is consistent before making it visible to
10086 ++ * ovl_upperdentry_dereference().
10087 ++ */
10088 ++ smp_wmb();
10089 ++ oe->__upperdentry = dget(upperdentry);
10092 ++void ovl_dentry_version_inc(struct dentry *dentry)
10094 ++ struct ovl_entry *oe = dentry->d_fsdata;
10096 ++ WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
10097 ++ oe->version++;
10100 ++u64 ovl_dentry_version_get(struct dentry *dentry)
10102 ++ struct ovl_entry *oe = dentry->d_fsdata;
10104 ++ WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
10105 ++ return oe->version;
10108 ++bool ovl_is_whiteout(struct dentry *dentry)
10110 ++ struct inode *inode = dentry->d_inode;
10112 ++ return inode && IS_WHITEOUT(inode);
10115 ++static bool ovl_is_opaquedir(struct dentry *dentry)
10117 ++ int res;
10118 ++ char val;
10119 ++ struct inode *inode = dentry->d_inode;
10121 ++ if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr)
10122 ++ return false;
10124 ++ res = inode->i_op->getxattr(dentry, ovl_opaque_xattr, &val, 1);
10125 ++ if (res == 1 && val == 'y')
10126 ++ return true;
10128 ++ return false;
10131 ++static void ovl_entry_free(struct rcu_head *head)
10133 ++ struct ovl_entry *oe = container_of(head, struct ovl_entry, rcu);
10134 ++ kfree(oe);
10137 ++static void ovl_dentry_release(struct dentry *dentry)
10139 ++ struct ovl_entry *oe = dentry->d_fsdata;
10141 ++ if (oe) {
10142 ++ dput(oe->__upperdentry);
10143 ++ dput(oe->__upperdentry);
10144 ++ dput(oe->lowerdentry);
10145 ++ call_rcu(&oe->rcu, ovl_entry_free);
10146 ++ }
10149 ++const struct dentry_operations ovl_dentry_operations = {
10150 ++ .d_release = ovl_dentry_release,
10151 ++};
10153 ++static struct ovl_entry *ovl_alloc_entry(void)
10155 ++ return kzalloc(sizeof(struct ovl_entry), GFP_KERNEL);
10158 ++static inline struct dentry *ovl_lookup_real(struct dentry *dir,
10159 ++ struct qstr *name)
10161 ++ struct dentry *dentry;
10163 ++ mutex_lock(&dir->d_inode->i_mutex);
10164 ++ dentry = lookup_one_len(name->name, dir, name->len);
10165 ++ mutex_unlock(&dir->d_inode->i_mutex);
10167 ++ if (IS_ERR(dentry)) {
10168 ++ if (PTR_ERR(dentry) == -ENOENT)
10169 ++ dentry = NULL;
10170 ++ } else if (!dentry->d_inode) {
10171 ++ dput(dentry);
10172 ++ dentry = NULL;
10173 ++ }
10174 ++ return dentry;
10177 ++static int ovl_do_lookup(struct dentry *dentry)
10179 ++ struct ovl_entry *oe;
10180 ++ struct dentry *upperdir;
10181 ++ struct dentry *lowerdir;
10182 ++ struct dentry *upperdentry = NULL;
10183 ++ struct dentry *lowerdentry = NULL;
10184 ++ struct inode *inode = NULL;
10185 ++ int err;
10187 ++ err = -ENOMEM;
10188 ++ oe = ovl_alloc_entry();
10189 ++ if (!oe)
10190 ++ goto out;
10192 ++ upperdir = ovl_dentry_upper(dentry->d_parent);
10193 ++ lowerdir = ovl_dentry_lower(dentry->d_parent);
10195 ++ if (upperdir) {
10196 ++ upperdentry = ovl_lookup_real(upperdir, &dentry->d_name);
10197 ++ err = PTR_ERR(upperdentry);
10198 ++ if (IS_ERR(upperdentry))
10199 ++ goto out_put_dir;
10201 ++ if (lowerdir && upperdentry) {
10202 ++ if (ovl_is_whiteout(upperdentry)) {
10203 ++ dput(upperdentry);
10204 ++ upperdentry = NULL;
10205 ++ oe->opaque = true;
10206 ++ } else if (ovl_is_opaquedir(upperdentry)) {
10207 ++ oe->opaque = true;
10208 ++ }
10209 ++ }
10210 ++ }
10211 ++ if (lowerdir && !oe->opaque) {
10212 ++ lowerdentry = ovl_lookup_real(lowerdir, &dentry->d_name);
10213 ++ err = PTR_ERR(lowerdentry);
10214 ++ if (IS_ERR(lowerdentry))
10215 ++ goto out_dput_upper;
10216 ++ }
10218 ++ if (lowerdentry && upperdentry &&
10219 ++ (!S_ISDIR(upperdentry->d_inode->i_mode) ||
10220 ++ !S_ISDIR(lowerdentry->d_inode->i_mode))) {
10221 ++ dput(lowerdentry);
10222 ++ lowerdentry = NULL;
10223 ++ oe->opaque = true;
10224 ++ }
10226 ++ if (lowerdentry || upperdentry) {
10227 ++ struct dentry *realdentry;
10229 ++ realdentry = upperdentry ? upperdentry : lowerdentry;
10230 ++ err = -ENOMEM;
10231 ++ inode = ovl_new_inode(dentry->d_sb, realdentry->d_inode->i_mode,
10232 ++ oe);
10233 ++ if (!inode)
10234 ++ goto out_dput;
10235 ++ ovl_copyattr(realdentry->d_inode, inode);
10236 ++ }
10238 ++ if (upperdentry)
10239 ++ oe->__upperdentry = dget(upperdentry);
10241 ++ if (lowerdentry)
10242 ++ oe->lowerdentry = lowerdentry;
10244 ++ dentry->d_fsdata = oe;
10245 ++ dentry->d_op = &ovl_dentry_operations;
10246 ++ d_add(dentry, inode);
10248 ++ return 0;
10250 ++out_dput:
10251 ++ dput(lowerdentry);
10252 ++out_dput_upper:
10253 ++ dput(upperdentry);
10254 ++out_put_dir:
10255 ++ kfree(oe);
10256 ++out:
10257 ++ return err;
10260 ++struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
10261 ++ unsigned int flags)
10263 ++ int err = ovl_do_lookup(dentry);
10265 ++ if (err)
10266 ++ return ERR_PTR(err);
10268 ++ return NULL;
10271 ++struct file *ovl_path_open(struct path *path, int flags)
10273 ++ return dentry_open(path, flags, current_cred());
10276 ++static void ovl_put_super(struct super_block *sb)
10278 ++ struct ovl_fs *ufs = sb->s_fs_info;
10280 ++ dput(ufs->workdir);
10281 ++ mntput(ufs->upper_mnt);
10282 ++ mntput(ufs->lower_mnt);
10284 ++ kfree(ufs->config.lowerdir);
10285 ++ kfree(ufs->config.upperdir);
10286 ++ kfree(ufs->config.workdir);
10287 ++ kfree(ufs);
10290 ++/**
10291 ++ * ovl_statfs
10292 ++ * @sb: The overlayfs super block
10293 ++ * @buf: The struct kstatfs to fill in with stats
10294 ++ *
10295 ++ * Get the filesystem statistics. As writes always target the upper layer
10296 ++ * filesystem pass the statfs to the same filesystem.
10297 ++ */
10298 ++static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)
10300 ++ struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
10301 ++ struct dentry *root_dentry = dentry->d_sb->s_root;
10302 ++ struct path path;
10303 ++ int err;
10305 ++ ovl_path_upper(root_dentry, &path);
10307 ++ err = vfs_statfs(&path, buf);
10308 ++ if (!err) {
10309 ++ buf->f_namelen = max(buf->f_namelen, ofs->lower_namelen);
10310 ++ buf->f_type = OVERLAYFS_SUPER_MAGIC;
10311 ++ }
10313 ++ return err;
10316 ++/**
10317 ++ * ovl_show_options
10318 ++ *
10319 ++ * Prints the mount options for a given superblock.
10320 ++ * Returns zero; does not fail.
10321 ++ */
10322 ++static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
10324 ++ struct super_block *sb = dentry->d_sb;
10325 ++ struct ovl_fs *ufs = sb->s_fs_info;
10327 ++ seq_printf(m, ",lowerdir=%s", ufs->config.lowerdir);
10328 ++ seq_printf(m, ",upperdir=%s", ufs->config.upperdir);
10329 ++ seq_printf(m, ",workdir=%s", ufs->config.workdir);
10330 ++ return 0;
10333 ++static const struct super_operations ovl_super_operations = {
10334 ++ .put_super = ovl_put_super,
10335 ++ .statfs = ovl_statfs,
10336 ++ .show_options = ovl_show_options,
10337 ++};
10339 ++enum {
10340 ++ OPT_LOWERDIR,
10341 ++ OPT_UPPERDIR,
10342 ++ OPT_WORKDIR,
10343 ++ OPT_ERR,
10344 ++};
10346 ++static const match_table_t ovl_tokens = {
10347 ++ {OPT_LOWERDIR, "lowerdir=%s"},
10348 ++ {OPT_UPPERDIR, "upperdir=%s"},
10349 ++ {OPT_WORKDIR, "workdir=%s"},
10350 ++ {OPT_ERR, NULL}
10351 ++};
10353 ++static int ovl_parse_opt(char *opt, struct ovl_config *config)
10355 ++ char *p;
10357 ++ config->upperdir = NULL;
10358 ++ config->lowerdir = NULL;
10359 ++ config->workdir = NULL;
10361 ++ while ((p = strsep(&opt, ",")) != NULL) {
10362 ++ int token;
10363 ++ substring_t args[MAX_OPT_ARGS];
10365 ++ if (!*p)
10366 ++ continue;
10368 ++ token = match_token(p, ovl_tokens, args);
10369 ++ switch (token) {
10370 ++ case OPT_UPPERDIR:
10371 ++ kfree(config->upperdir);
10372 ++ config->upperdir = match_strdup(&args[0]);
10373 ++ if (!config->upperdir)
10374 ++ return -ENOMEM;
10375 ++ break;
10377 ++ case OPT_LOWERDIR:
10378 ++ kfree(config->lowerdir);
10379 ++ config->lowerdir = match_strdup(&args[0]);
10380 ++ if (!config->lowerdir)
10381 ++ return -ENOMEM;
10382 ++ break;
10384 ++ case OPT_WORKDIR:
10385 ++ kfree(config->workdir);
10386 ++ config->workdir = match_strdup(&args[0]);
10387 ++ if (!config->workdir)
10388 ++ return -ENOMEM;
10389 ++ break;
10391 ++ default:
10392 ++ return -EINVAL;
10393 ++ }
10394 ++ }
10395 ++ return 0;
10398 ++#define OVL_WORKDIR_NAME "work"
10400 ++static struct dentry *ovl_workdir_create(struct vfsmount *mnt,
10401 ++ struct dentry *dentry)
10403 ++ struct inode *dir = dentry->d_inode;
10404 ++ struct dentry *work;
10405 ++ int err;
10406 ++ bool retried = false;
10408 ++ err = mnt_want_write(mnt);
10409 ++ if (err)
10410 ++ return ERR_PTR(err);
10412 ++ mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
10413 ++retry:
10414 ++ work = lookup_one_len(OVL_WORKDIR_NAME, dentry,
10415 ++ strlen(OVL_WORKDIR_NAME));
10417 ++ if (!IS_ERR(work)) {
10418 ++ struct kstat stat = {
10419 ++ .mode = S_IFDIR | 0,
10420 ++ };
10422 ++ if (work->d_inode) {
10423 ++ err = -EEXIST;
10424 ++ if (retried)
10425 ++ goto out_dput;
10427 ++ retried = true;
10428 ++ ovl_cleanup(dir, work);
10429 ++ dput(work);
10430 ++ goto retry;
10431 ++ }
10433 ++ err = ovl_create_real(dir, work, &stat, NULL, NULL, true);
10434 ++ if (err)
10435 ++ goto out_dput;
10436 ++ }
10437 ++out_unlock:
10438 ++ mutex_unlock(&dir->i_mutex);
10439 ++ mnt_drop_write(mnt);
10441 ++ return work;
10443 ++out_dput:
10444 ++ dput(work);
10445 ++ work = ERR_PTR(err);
10446 ++ goto out_unlock;
10449 ++static int ovl_mount_dir(const char *name, struct path *path)
10451 ++ int err;
10453 ++ err = kern_path(name, LOOKUP_FOLLOW, path);
10454 ++ if (err) {
10455 ++ pr_err("overlayfs: failed to resolve '%s': %i\n", name, err);
10456 ++ err = -EINVAL;
10457 ++ }
10458 ++ return err;
10461 ++static int ovl_fill_super(struct super_block *sb, void *data, int silent)
10463 ++ struct path lowerpath;
10464 ++ struct path upperpath;
10465 ++ struct path workpath;
10466 ++ struct inode *root_inode;
10467 ++ struct dentry *root_dentry;
10468 ++ struct ovl_entry *oe;
10469 ++ struct ovl_fs *ufs;
10470 ++ struct kstatfs statfs;
10471 ++ int err;
10473 ++ err = -ENOMEM;
10474 ++ ufs = kmalloc(sizeof(struct ovl_fs), GFP_KERNEL);
10475 ++ if (!ufs)
10476 ++ goto out;
10478 ++ err = ovl_parse_opt((char *) data, &ufs->config);
10479 ++ if (err)
10480 ++ goto out_free_ufs;
10482 ++ /* FIXME: workdir is not needed for a R/O mount */
10483 ++ err = -EINVAL;
10484 ++ if (!ufs->config.upperdir || !ufs->config.lowerdir ||
10485 ++ !ufs->config.workdir) {
10486 ++ pr_err("overlayfs: missing upperdir or lowerdir or workdir\n");
10487 ++ goto out_free_config;
10488 ++ }
10490 ++ oe = ovl_alloc_entry();
10491 ++ if (oe == NULL)
10492 ++ goto out_free_config;
10494 ++ err = ovl_mount_dir(ufs->config.upperdir, &upperpath);
10495 ++ if (err)
10496 ++ goto out_free_oe;
10498 ++ err = ovl_mount_dir(ufs->config.lowerdir, &lowerpath);
10499 ++ if (err)
10500 ++ goto out_put_upperpath;
10502 ++ err = ovl_mount_dir(ufs->config.workdir, &workpath);
10503 ++ if (err)
10504 ++ goto out_put_lowerpath;
10506 ++ err = -EINVAL;
10507 ++ if (!S_ISDIR(upperpath.dentry->d_inode->i_mode) ||
10508 ++ !S_ISDIR(lowerpath.dentry->d_inode->i_mode) ||
10509 ++ !S_ISDIR(workpath.dentry->d_inode->i_mode)) {
10510 ++ pr_err("overlayfs: upperdir or lowerdir or workdir not a directory\n");
10511 ++ goto out_put_workpath;
10512 ++ }
10514 ++ if (upperpath.mnt != workpath.mnt) {
10515 ++ pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
10516 ++ goto out_put_workpath;
10517 ++ }
10518 ++ if (upperpath.dentry == workpath.dentry ||
10519 ++ d_ancestor(upperpath.dentry, workpath.dentry) ||
10520 ++ d_ancestor(workpath.dentry, upperpath.dentry)) {
10521 ++ pr_err("overlayfs: workdir and upperdir must be separate subtrees\n");
10522 ++ goto out_put_workpath;
10523 ++ }
10525 ++ err = vfs_statfs(&lowerpath, &statfs);
10526 ++ if (err) {
10527 ++ pr_err("overlayfs: statfs failed on lowerpath\n");
10528 ++ goto out_put_workpath;
10529 ++ }
10530 ++ ufs->lower_namelen = statfs.f_namelen;
10532 ++ sb->s_stack_depth = max(upperpath.mnt->mnt_sb->s_stack_depth,
10533 ++ lowerpath.mnt->mnt_sb->s_stack_depth) + 1;
10535 ++ err = -EINVAL;
10536 ++ if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
10537 ++ pr_err("overlayfs: maximum fs stacking depth exceeded\n");
10538 ++ goto out_put_lowerpath;
10539 ++ }
10542 ++ ufs->upper_mnt = clone_private_mount(&upperpath);
10543 ++ err = PTR_ERR(ufs->upper_mnt);
10544 ++ if (IS_ERR(ufs->upper_mnt)) {
10545 ++ pr_err("overlayfs: failed to clone upperpath\n");
10546 ++ goto out_put_workpath;
10547 ++ }
10549 ++ ufs->lower_mnt = clone_private_mount(&lowerpath);
10550 ++ err = PTR_ERR(ufs->lower_mnt);
10551 ++ if (IS_ERR(ufs->lower_mnt)) {
10552 ++ pr_err("overlayfs: failed to clone lowerpath\n");
10553 ++ goto out_put_upper_mnt;
10554 ++ }
10556 ++ ufs->workdir = ovl_workdir_create(ufs->upper_mnt, workpath.dentry);
10557 ++ err = PTR_ERR(ufs->workdir);
10558 ++ if (IS_ERR(ufs->workdir)) {
10559 ++ pr_err("overlayfs: failed to create directory %s/%s\n",
10560 ++ ufs->config.workdir, OVL_WORKDIR_NAME);
10561 ++ goto out_put_lower_mnt;
10562 ++ }
10564 ++ /*
10565 ++ * Make lower_mnt R/O. That way fchmod/fchown on lower file
10566 ++ * will fail instead of modifying lower fs.
10567 ++ */
10568 ++ ufs->lower_mnt->mnt_flags |= MNT_READONLY;
10570 ++ /* If the upper fs is r/o, we mark overlayfs r/o too */
10571 ++ if (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY)
10572 ++ sb->s_flags |= MS_RDONLY;
10574 ++ err = -ENOMEM;
10575 ++ root_inode = ovl_new_inode(sb, S_IFDIR, oe);
10576 ++ if (!root_inode)
10577 ++ goto out_put_workdir;
10579 ++ root_dentry = d_make_root(root_inode);
10580 ++ if (!root_dentry)
10581 ++ goto out_put_workdir;
10583 ++ mntput(upperpath.mnt);
10584 ++ mntput(lowerpath.mnt);
10585 ++ path_put(&workpath);
10587 ++ oe->__upperdentry = dget(upperpath.dentry);
10588 ++ oe->lowerdentry = lowerpath.dentry;
10590 ++ root_dentry->d_fsdata = oe;
10591 ++ root_dentry->d_op = &ovl_dentry_operations;
10593 ++ sb->s_magic = OVERLAYFS_SUPER_MAGIC;
10594 ++ sb->s_op = &ovl_super_operations;
10595 ++ sb->s_root = root_dentry;
10596 ++ sb->s_fs_info = ufs;
10598 ++ return 0;
10600 ++out_put_workdir:
10601 ++ dput(ufs->workdir);
10602 ++out_put_lower_mnt:
10603 ++ mntput(ufs->lower_mnt);
10604 ++out_put_upper_mnt:
10605 ++ mntput(ufs->upper_mnt);
10606 ++out_put_workpath:
10607 ++ path_put(&workpath);
10608 ++out_put_lowerpath:
10609 ++ path_put(&lowerpath);
10610 ++out_put_upperpath:
10611 ++ path_put(&upperpath);
10612 ++out_free_oe:
10613 ++ kfree(oe);
10614 ++out_free_config:
10615 ++ kfree(ufs->config.lowerdir);
10616 ++ kfree(ufs->config.upperdir);
10617 ++ kfree(ufs->config.workdir);
10618 ++out_free_ufs:
10619 ++ kfree(ufs);
10620 ++out:
10621 ++ return err;
10624 ++static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
10625 ++ const char *dev_name, void *raw_data)
10627 ++ return mount_nodev(fs_type, flags, raw_data, ovl_fill_super);
10630 ++static struct file_system_type ovl_fs_type = {
10631 ++ .owner = THIS_MODULE,
10632 ++ .name = "overlayfs",
10633 ++ .mount = ovl_mount,
10634 ++ .kill_sb = kill_anon_super,
10635 ++};
10636 ++MODULE_ALIAS_FS("overlayfs");
10638 ++static int __init ovl_init(void)
10640 ++ return register_filesystem(&ovl_fs_type);
10643 ++static void __exit ovl_exit(void)
10645 ++ unregister_filesystem(&ovl_fs_type);
10648 ++module_init(ovl_init);
10649 ++module_exit(ovl_exit);
10650 +--- a/fs/splice.c
10651 ++++ b/fs/splice.c
10652 +@@ -1330,6 +1330,7 @@ long do_splice_direct(struct file *in, l
10654 + return ret;
10656 ++EXPORT_SYMBOL(do_splice_direct);
10658 + static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
10659 + struct pipe_inode_info *opipe,
10660 +--- a/include/linux/fs.h
10661 ++++ b/include/linux/fs.h
10662 +@@ -225,6 +225,20 @@ typedef void (dio_iodone_t)(struct kiocb
10663 + #define ATTR_TIMES_SET (1 << 16)
10665 + /*
10666 ++ * Whiteout is represented by a char device. The following constants define the
10667 ++ * mode and device number to use.
10668 ++ */
10669 ++#define WHITEOUT_MODE 0
10670 ++#define WHITEOUT_DEV 0
10672 ++/*
10673 ++ * Whiteout is represented by a char device. The following constants define the
10674 ++ * mode and device number to use.
10675 ++ */
10676 ++#define WHITEOUT_MODE 0
10677 ++#define WHITEOUT_DEV 0
10679 ++/*
10680 + * This is the Inode Attributes structure, used for notify_change(). It
10681 + * uses the above definitions as flags, to know which values have changed.
10682 + * Also, in this manner, a Filesystem can look at only the values it cares
10683 +@@ -256,6 +270,12 @@ struct iattr {
10684 + */
10685 + #include <linux/quota.h>
10687 ++/*
10688 ++ * Maximum number of layers of fs stack. Needs to be limited to
10689 ++ * prevent kernel stack overflow
10690 ++ */
10691 ++#define FILESYSTEM_MAX_STACK_DEPTH 2
10693 + /**
10694 + * enum positive_aop_returns - aop return codes with specific semantics
10696 +@@ -1258,6 +1278,11 @@ struct super_block {
10697 + struct list_lru s_dentry_lru ____cacheline_aligned_in_smp;
10698 + struct list_lru s_inode_lru ____cacheline_aligned_in_smp;
10699 + struct rcu_head rcu;
10701 ++ /*
10702 ++ * Indicates how deep in a filesystem stack this SB is
10703 ++ */
10704 ++ int s_stack_depth;
10705 + };
10707 + extern struct timespec current_fs_time(struct super_block *sb);
10708 +@@ -1390,6 +1415,7 @@ extern int vfs_link(struct dentry *, str
10709 + extern int vfs_rmdir(struct inode *, struct dentry *);
10710 + extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
10711 + extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int);
10712 ++extern int vfs_whiteout(struct inode *, struct dentry *);
10714 + /*
10715 + * VFS dentry helper functions.
10716 +@@ -1520,6 +1546,7 @@ struct inode_operations {
10717 + umode_t create_mode, int *opened);
10718 + int (*tmpfile) (struct inode *, struct dentry *, umode_t);
10719 + int (*set_acl)(struct inode *, struct posix_acl *, int);
10720 ++ int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
10721 + } ____cacheline_aligned;
10723 + ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
10724 +@@ -1617,6 +1644,9 @@ struct super_operations {
10725 + #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
10726 + #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
10728 ++#define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \
10729 ++ (inode)->i_rdev == WHITEOUT_DEV)
10731 + /*
10732 + * Inode state bits. Protected by inode->i_lock
10734 +@@ -2031,6 +2061,7 @@ extern struct file *file_open_name(struc
10735 + extern struct file *filp_open(const char *, int, umode_t);
10736 + extern struct file *file_open_root(struct dentry *, struct vfsmount *,
10737 + const char *, int);
10738 ++extern int vfs_open(const struct path *, struct file *, const struct cred *);
10739 + extern struct file * dentry_open(const struct path *, int, const struct cred *);
10740 + extern int filp_close(struct file *, fl_owner_t id);
10742 +@@ -2244,7 +2275,9 @@ extern sector_t bmap(struct inode *, sec
10743 + #endif
10744 + extern int notify_change(struct dentry *, struct iattr *, struct inode **);
10745 + extern int inode_permission(struct inode *, int);
10746 ++extern int __inode_permission(struct inode *, int);
10747 + extern int generic_permission(struct inode *, int);
10748 ++extern int __check_sticky(struct inode *dir, struct inode *inode);
10750 + static inline bool execute_ok(struct inode *inode)
10752 +@@ -2442,6 +2475,9 @@ extern ssize_t iter_file_splice_write(st
10753 + struct file *, loff_t *, size_t, unsigned int);
10754 + extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
10755 + struct file *out, loff_t *, size_t len, unsigned int flags);
10756 ++extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
10757 ++ loff_t *opos, size_t len, unsigned int flags);
10760 + extern void
10761 + file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
10762 +@@ -2726,6 +2762,14 @@ static inline int is_sxid(umode_t mode)
10763 + return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP));
10766 ++static inline int check_sticky(struct inode *dir, struct inode *inode)
10768 ++ if (!(dir->i_mode & S_ISVTX))
10769 ++ return 0;
10771 ++ return __check_sticky(dir, inode);
10774 + static inline void inode_has_no_xattr(struct inode *inode)
10776 + if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC))
10777 +--- a/include/linux/mount.h
10778 ++++ b/include/linux/mount.h
10779 +@@ -74,6 +74,9 @@ extern void mnt_pin(struct vfsmount *mnt
10780 + extern void mnt_unpin(struct vfsmount *mnt);
10781 + extern int __mnt_is_readonly(struct vfsmount *mnt);
10783 ++struct path;
10784 ++extern struct vfsmount *clone_private_mount(struct path *path);
10786 + struct file_system_type;
10787 + extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
10788 + int flags, const char *name,
10789 +--- a/include/uapi/linux/fs.h
10790 ++++ b/include/uapi/linux/fs.h
10791 +@@ -37,6 +37,7 @@
10793 + #define RENAME_NOREPLACE (1 << 0) /* Don't overwrite target */
10794 + #define RENAME_EXCHANGE (1 << 1) /* Exchange source and dest */
10795 ++#define RENAME_WHITEOUT (1 << 2) /* Whiteout source */
10797 + struct fstrim_range {
10798 + __u64 start;
10799 diff --git a/target/linux/generic/patches-3.16/102-ehci_hcd_ignore_oc.patch b/target/linux/generic/patches-3.16/102-ehci_hcd_ignore_oc.patch
10800 new file mode 100644
10801 index 000000000000..f498d4eac600
10802 --- /dev/null
10803 +++ b/target/linux/generic/patches-3.16/102-ehci_hcd_ignore_oc.patch
10804 @@ -0,0 +1,82 @@
10805 +From 1e311820ec3055e3f08e687de6564692a7cec675 Mon Sep 17 00:00:00 2001
10806 +From: Florian Fainelli <florian@openwrt.org>
10807 +Date: Mon, 28 Jan 2013 20:06:29 +0100
10808 +Subject: [PATCH 11/12] USB: EHCI: add ignore_oc flag to disable overcurrent
10809 + checking
10811 +This patch adds an ignore_oc flag which can be set by EHCI controller
10812 +not supporting or wanting to disable overcurrent checking. The EHCI
10813 +platform data in include/linux/usb/ehci_pdriver.h is also augmented to
10814 +take advantage of this new flag.
10816 +Signed-off-by: Florian Fainelli <florian@openwrt.org>
10817 +---
10818 + drivers/usb/host/ehci-hcd.c | 2 +-
10819 + drivers/usb/host/ehci-hub.c | 4 ++--
10820 + drivers/usb/host/ehci-platform.c | 1 +
10821 + drivers/usb/host/ehci.h | 1 +
10822 + include/linux/usb/ehci_pdriver.h | 1 +
10823 + 5 files changed, 6 insertions(+), 3 deletions(-)
10825 +--- a/drivers/usb/host/ehci-hcd.c
10826 ++++ b/drivers/usb/host/ehci-hcd.c
10827 +@@ -633,7 +633,7 @@ static int ehci_run (struct usb_hcd *hcd
10828 + "USB %x.%x started, EHCI %x.%02x%s\n",
10829 + ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
10830 + temp >> 8, temp & 0xff,
10831 +- ignore_oc ? ", overcurrent ignored" : "");
10832 ++ (ignore_oc || ehci->ignore_oc) ? ", overcurrent ignored" : "");
10834 + ehci_writel(ehci, INTR_MASK,
10835 + &ehci->regs->intr_enable); /* Turn On Interrupts */
10836 +--- a/drivers/usb/host/ehci-hub.c
10837 ++++ b/drivers/usb/host/ehci-hub.c
10838 +@@ -632,7 +632,7 @@ ehci_hub_status_data (struct usb_hcd *hc
10839 + * always set, seem to clear PORT_OCC and PORT_CSC when writing to
10840 + * PORT_POWER; that's surprising, but maybe within-spec.
10841 + */
10842 +- if (!ignore_oc)
10843 ++ if (!ignore_oc && !ehci->ignore_oc)
10844 + mask = PORT_CSC | PORT_PEC | PORT_OCC;
10845 + else
10846 + mask = PORT_CSC | PORT_PEC;
10847 +@@ -992,7 +992,7 @@ int ehci_hub_control(
10848 + if (temp & PORT_PEC)
10849 + status |= USB_PORT_STAT_C_ENABLE << 16;
10851 +- if ((temp & PORT_OCC) && !ignore_oc){
10852 ++ if ((temp & PORT_OCC) && (!ignore_oc && !ehci->ignore_oc)){
10853 + status |= USB_PORT_STAT_C_OVERCURRENT << 16;
10855 + /*
10856 +--- a/drivers/usb/host/ehci-platform.c
10857 ++++ b/drivers/usb/host/ehci-platform.c
10858 +@@ -226,6 +226,8 @@ static int ehci_platform_probe(struct pl
10859 + ehci->big_endian_desc = 1;
10860 + if (pdata->big_endian_mmio)
10861 + ehci->big_endian_mmio = 1;
10862 ++ if (pdata->ignore_oc)
10863 ++ ehci->ignore_oc = 1;
10865 + #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
10866 + if (ehci->big_endian_mmio) {
10867 +--- a/drivers/usb/host/ehci.h
10868 ++++ b/drivers/usb/host/ehci.h
10869 +@@ -226,6 +226,7 @@ struct ehci_hcd { /* one per controlle
10870 + unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */
10871 + unsigned need_oc_pp_cycle:1; /* MPC834X port power */
10872 + unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
10873 ++ unsigned ignore_oc:1;
10875 + /* required for usb32 quirk */
10876 + #define OHCI_CTRL_HCFS (3 << 6)
10877 +--- a/include/linux/usb/ehci_pdriver.h
10878 ++++ b/include/linux/usb/ehci_pdriver.h
10879 +@@ -45,6 +45,7 @@ struct usb_ehci_pdata {
10880 + unsigned big_endian_desc:1;
10881 + unsigned big_endian_mmio:1;
10882 + unsigned no_io_watchdog:1;
10883 ++ unsigned ignore_oc:1;
10885 + /* Turn on all power and clocks */
10886 + int (*power_on)(struct platform_device *pdev);
10887 diff --git a/target/linux/generic/patches-3.16/120-bridge_allow_receiption_on_disabled_port.patch b/target/linux/generic/patches-3.16/120-bridge_allow_receiption_on_disabled_port.patch
10888 new file mode 100644
10889 index 000000000000..3823d7b318a5
10890 --- /dev/null
10891 +++ b/target/linux/generic/patches-3.16/120-bridge_allow_receiption_on_disabled_port.patch
10892 @@ -0,0 +1,54 @@
10893 +From: Stephen Hemminger <stephen@networkplumber.org>
10894 +Subject: bridge: allow receiption on disabled port
10896 +When an ethernet device is enslaved to a bridge, and the bridge STP
10897 +detects loss of carrier (or operational state down), then normally
10898 +packet receiption is blocked.
10900 +This breaks control applications like WPA which maybe expecting to
10901 +receive packets to negotiate to bring link up. The bridge needs to
10902 +block forwarding packets from these disabled ports, but there is no
10903 +hard requirement to not allow local packet delivery.
10905 +Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10906 +Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10908 +--- a/net/bridge/br_input.c
10909 ++++ b/net/bridge/br_input.c
10910 +@@ -145,11 +145,13 @@ drop:
10911 + static int br_handle_local_finish(struct sk_buff *skb)
10913 + struct net_bridge_port *p = br_port_get_rcu(skb->dev);
10914 +- u16 vid = 0;
10915 ++ if (p->state != BR_STATE_DISABLED) {
10916 ++ u16 vid = 0;
10918 +- /* check if vlan is allowed, to avoid spoofing */
10919 +- if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid))
10920 +- br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false);
10921 ++ /* check if vlan is allowed, to avoid spoofing */
10922 ++ if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid))
10923 ++ br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false);
10924 ++ }
10925 + return 0; /* process further */
10928 +@@ -223,6 +225,18 @@ rx_handler_result_t br_handle_frame(stru
10930 + forward:
10931 + switch (p->state) {
10932 ++ case BR_STATE_DISABLED:
10933 ++ if (ether_addr_equal(p->br->dev->dev_addr, dest))
10934 ++ skb->pkt_type = PACKET_HOST;
10936 ++ if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
10937 ++ br_handle_local_finish))
10938 ++ break;
10940 ++ BR_INPUT_SKB_CB(skb)->brdev = p->br->dev;
10941 ++ br_pass_frame_up(skb);
10942 ++ break;
10944 + case BR_STATE_FORWARDING:
10945 + rhook = rcu_dereference(br_should_route_hook);
10946 + if (rhook) {
10947 diff --git a/target/linux/generic/patches-3.16/132-mips_inline_dma_ops.patch b/target/linux/generic/patches-3.16/132-mips_inline_dma_ops.patch
10948 new file mode 100644
10949 index 000000000000..2f9b8c35f94c
10950 --- /dev/null
10951 +++ b/target/linux/generic/patches-3.16/132-mips_inline_dma_ops.patch
10952 @@ -0,0 +1,660 @@
10953 +--- a/arch/mips/Kconfig
10954 ++++ b/arch/mips/Kconfig
10955 +@@ -1698,6 +1698,9 @@ config MIPS_MALTA_PM
10956 + bool
10957 + default y
10959 ++config SYS_HAS_DMA_OPS
10960 ++ bool
10963 + # CPU may reorder R->R, R->W, W->R, W->W
10964 + # Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
10965 +--- a/arch/mips/include/asm/dma-mapping.h
10966 ++++ b/arch/mips/include/asm/dma-mapping.h
10967 +@@ -1,9 +1,16 @@
10968 + #ifndef _ASM_DMA_MAPPING_H
10969 + #define _ASM_DMA_MAPPING_H
10971 ++#include <linux/kmemcheck.h>
10972 ++#include <linux/bug.h>
10973 ++#include <linux/scatterlist.h>
10974 ++#include <linux/dma-debug.h>
10975 ++#include <linux/dma-attrs.h>
10977 + #include <asm/scatterlist.h>
10978 + #include <asm/dma-coherence.h>
10979 + #include <asm/cache.h>
10980 ++#include <asm/cpu-type.h>
10981 + #include <asm-generic/dma-coherent.h>
10983 + #ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */
10984 +@@ -12,12 +19,48 @@
10986 + extern struct dma_map_ops *mips_dma_map_ops;
10988 ++void __dma_sync(struct page *page, unsigned long offset, size_t size,
10989 ++ enum dma_data_direction direction);
10990 ++void *mips_dma_alloc_coherent(struct device *dev, size_t size,
10991 ++ dma_addr_t *dma_handle, gfp_t gfp,
10992 ++ struct dma_attrs *attrs);
10993 ++void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
10994 ++ dma_addr_t dma_handle, struct dma_attrs *attrs);
10996 + static inline struct dma_map_ops *get_dma_ops(struct device *dev)
10998 ++#ifdef CONFIG_SYS_HAS_DMA_OPS
10999 + if (dev && dev->archdata.dma_ops)
11000 + return dev->archdata.dma_ops;
11001 + else
11002 + return mips_dma_map_ops;
11003 ++#else
11004 ++ return NULL;
11005 ++#endif
11008 ++/*
11009 ++ * Warning on the terminology - Linux calls an uncached area coherent;
11010 ++ * MIPS terminology calls memory areas with hardware maintained coherency
11011 ++ * coherent.
11012 ++ */
11014 ++static inline int cpu_needs_post_dma_flush(struct device *dev)
11016 ++#ifndef CONFIG_SYS_HAS_CPU_R10000
11017 ++ return 0;
11018 ++#endif
11019 ++ return !plat_device_is_coherent(dev) &&
11020 ++ (boot_cpu_type() == CPU_R10000 ||
11021 ++ boot_cpu_type() == CPU_R12000 ||
11022 ++ boot_cpu_type() == CPU_BMIPS5000);
11025 ++static inline struct page *dma_addr_to_page(struct device *dev,
11026 ++ dma_addr_t dma_addr)
11028 ++ return pfn_to_page(
11029 ++ plat_dma_addr_to_phys(dev, dma_addr) >> PAGE_SHIFT);
11032 + static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
11033 +@@ -30,12 +73,312 @@ static inline bool dma_capable(struct de
11035 + static inline void dma_mark_clean(void *addr, size_t size) {}
11037 +-#include <asm-generic/dma-mapping-common.h>
11038 ++static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
11039 ++ size_t size,
11040 ++ enum dma_data_direction dir,
11041 ++ struct dma_attrs *attrs)
11043 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11044 ++ unsigned long offset = (unsigned long)ptr & ~PAGE_MASK;
11045 ++ struct page *page = virt_to_page(ptr);
11046 ++ dma_addr_t addr;
11048 ++ kmemcheck_mark_initialized(ptr, size);
11049 ++ BUG_ON(!valid_dma_direction(dir));
11050 ++ if (ops) {
11051 ++ addr = ops->map_page(dev, page, offset, size, dir, attrs);
11052 ++ } else {
11053 ++ if (!plat_device_is_coherent(dev))
11054 ++ __dma_sync(page, offset, size, dir);
11056 ++ addr = plat_map_dma_mem_page(dev, page) + offset;
11057 ++ }
11058 ++ debug_dma_map_page(dev, page, offset, size, dir, addr, true);
11059 ++ return addr;
11062 ++static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
11063 ++ size_t size,
11064 ++ enum dma_data_direction dir,
11065 ++ struct dma_attrs *attrs)
11067 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11069 ++ BUG_ON(!valid_dma_direction(dir));
11070 ++ if (ops) {
11071 ++ ops->unmap_page(dev, addr, size, dir, attrs);
11072 ++ } else {
11073 ++ if (cpu_needs_post_dma_flush(dev))
11074 ++ __dma_sync(dma_addr_to_page(dev, addr),
11075 ++ addr & ~PAGE_MASK, size, dir);
11077 ++ plat_unmap_dma_mem(dev, addr, size, dir);
11078 ++ }
11079 ++ debug_dma_unmap_page(dev, addr, size, dir, true);
11082 ++static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
11083 ++ int nents, enum dma_data_direction dir,
11084 ++ struct dma_attrs *attrs)
11086 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11087 ++ int i, ents;
11088 ++ struct scatterlist *s;
11090 ++ for_each_sg(sg, s, nents, i)
11091 ++ kmemcheck_mark_initialized(sg_virt(s), s->length);
11092 ++ BUG_ON(!valid_dma_direction(dir));
11093 ++ if (ops) {
11094 ++ ents = ops->map_sg(dev, sg, nents, dir, attrs);
11095 ++ } else {
11096 ++ for_each_sg(sg, s, nents, i) {
11097 ++ struct page *page = sg_page(s);
11099 ++ if (!plat_device_is_coherent(dev))
11100 ++ __dma_sync(page, s->offset, s->length, dir);
11101 ++#ifdef CONFIG_NEED_SG_DMA_LENGTH
11102 ++ s->dma_length = s->length;
11103 ++#endif
11104 ++ s->dma_address =
11105 ++ plat_map_dma_mem_page(dev, page) + s->offset;
11106 ++ }
11107 ++ ents = nents;
11108 ++ }
11109 ++ debug_dma_map_sg(dev, sg, nents, ents, dir);
11111 ++ return ents;
11114 ++static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
11115 ++ int nents, enum dma_data_direction dir,
11116 ++ struct dma_attrs *attrs)
11118 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11119 ++ struct scatterlist *s;
11120 ++ int i;
11122 ++ BUG_ON(!valid_dma_direction(dir));
11123 ++ debug_dma_unmap_sg(dev, sg, nents, dir);
11124 ++ if (ops) {
11125 ++ ops->unmap_sg(dev, sg, nents, dir, attrs);
11126 ++ return;
11127 ++ }
11129 ++ for_each_sg(sg, s, nents, i) {
11130 ++ if (!plat_device_is_coherent(dev) && dir != DMA_TO_DEVICE)
11131 ++ __dma_sync(sg_page(s), s->offset, s->length, dir);
11132 ++ plat_unmap_dma_mem(dev, s->dma_address, s->length, dir);
11133 ++ }
11136 ++static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
11137 ++ size_t offset, size_t size,
11138 ++ enum dma_data_direction dir)
11140 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11141 ++ dma_addr_t addr;
11143 ++ kmemcheck_mark_initialized(page_address(page) + offset, size);
11144 ++ BUG_ON(!valid_dma_direction(dir));
11145 ++ if (ops) {
11146 ++ addr = ops->map_page(dev, page, offset, size, dir, NULL);
11147 ++ } else {
11148 ++ if (!plat_device_is_coherent(dev))
11149 ++ __dma_sync(page, offset, size, dir);
11151 ++ addr = plat_map_dma_mem_page(dev, page) + offset;
11152 ++ }
11153 ++ debug_dma_map_page(dev, page, offset, size, dir, addr, false);
11155 ++ return addr;
11158 ++static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
11159 ++ size_t size, enum dma_data_direction dir)
11161 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11163 ++ BUG_ON(!valid_dma_direction(dir));
11164 ++ if (ops) {
11165 ++ ops->unmap_page(dev, addr, size, dir, NULL);
11166 ++ } else {
11167 ++ if (cpu_needs_post_dma_flush(dev))
11168 ++ __dma_sync(dma_addr_to_page(dev, addr),
11169 ++ addr & ~PAGE_MASK, size, dir);
11171 ++ plat_unmap_dma_mem(dev, addr, size, dir);
11172 ++ }
11173 ++ debug_dma_unmap_page(dev, addr, size, dir, false);
11176 ++static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
11177 ++ size_t size,
11178 ++ enum dma_data_direction dir)
11180 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11182 ++ BUG_ON(!valid_dma_direction(dir));
11183 ++ if (ops)
11184 ++ ops->sync_single_for_cpu(dev, addr, size, dir);
11185 ++ else if (cpu_needs_post_dma_flush(dev))
11186 ++ __dma_sync(dma_addr_to_page(dev, addr),
11187 ++ addr & ~PAGE_MASK, size, dir);
11188 ++ debug_dma_sync_single_for_cpu(dev, addr, size, dir);
11191 ++static inline void dma_sync_single_for_device(struct device *dev,
11192 ++ dma_addr_t addr, size_t size,
11193 ++ enum dma_data_direction dir)
11195 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11197 ++ BUG_ON(!valid_dma_direction(dir));
11198 ++ if (ops)
11199 ++ ops->sync_single_for_device(dev, addr, size, dir);
11200 ++ else if (!plat_device_is_coherent(dev))
11201 ++ __dma_sync(dma_addr_to_page(dev, addr),
11202 ++ addr & ~PAGE_MASK, size, dir);
11203 ++ debug_dma_sync_single_for_device(dev, addr, size, dir);
11206 ++static inline void dma_sync_single_range_for_cpu(struct device *dev,
11207 ++ dma_addr_t addr,
11208 ++ unsigned long offset,
11209 ++ size_t size,
11210 ++ enum dma_data_direction dir)
11212 ++ const struct dma_map_ops *ops = get_dma_ops(dev);
11214 ++ BUG_ON(!valid_dma_direction(dir));
11215 ++ if (ops)
11216 ++ ops->sync_single_for_cpu(dev, addr + offset, size, dir);
11217 ++ else if (cpu_needs_post_dma_flush(dev))
11218 ++ __dma_sync(dma_addr_to_page(dev, addr + offset),
11219 ++ (addr + offset) & ~PAGE_MASK, size, dir);
11220 ++ debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir);
11223 ++static inline void dma_sync_single_range_for_device(struct device *dev,
11224 ++ dma_addr_t addr,
11225 ++ unsigned long offset,
11226 ++ size_t size,
11227 ++ enum dma_data_direction dir)
11229 ++ const struct dma_map_ops *ops = get_dma_ops(dev);
11231 ++ BUG_ON(!valid_dma_direction(dir));
11232 ++ if (ops)
11233 ++ ops->sync_single_for_device(dev, addr + offset, size, dir);
11234 ++ else if (!plat_device_is_coherent(dev))
11235 ++ __dma_sync(dma_addr_to_page(dev, addr + offset),
11236 ++ (addr + offset) & ~PAGE_MASK, size, dir);
11237 ++ debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir);
11240 ++static inline void
11241 ++dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
11242 ++ int nelems, enum dma_data_direction dir)
11244 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11245 ++ struct scatterlist *s;
11246 ++ int i;
11248 ++ BUG_ON(!valid_dma_direction(dir));
11249 ++ if (ops)
11250 ++ ops->sync_sg_for_cpu(dev, sg, nelems, dir);
11251 ++ else if (cpu_needs_post_dma_flush(dev)) {
11252 ++ for_each_sg(sg, s, nelems, i)
11253 ++ __dma_sync(sg_page(s), s->offset, s->length, dir);
11254 ++ }
11255 ++ debug_dma_sync_sg_for_cpu(dev, sg, nelems, dir);
11258 ++static inline void
11259 ++dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
11260 ++ int nelems, enum dma_data_direction dir)
11262 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11263 ++ struct scatterlist *s;
11264 ++ int i;
11266 ++ BUG_ON(!valid_dma_direction(dir));
11267 ++ if (ops)
11268 ++ ops->sync_sg_for_device(dev, sg, nelems, dir);
11269 ++ else if (!plat_device_is_coherent(dev)) {
11270 ++ for_each_sg(sg, s, nelems, i)
11271 ++ __dma_sync(sg_page(s), s->offset, s->length, dir);
11272 ++ }
11273 ++ debug_dma_sync_sg_for_device(dev, sg, nelems, dir);
11277 ++#define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL)
11278 ++#define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL)
11279 ++#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL)
11280 ++#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL)
11282 ++extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
11283 ++ void *cpu_addr, dma_addr_t dma_addr, size_t size);
11285 ++/**
11286 ++ * dma_mmap_attrs - map a coherent DMA allocation into user space
11287 ++ * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
11288 ++ * @vma: vm_area_struct describing requested user mapping
11289 ++ * @cpu_addr: kernel CPU-view address returned from dma_alloc_attrs
11290 ++ * @handle: device-view address returned from dma_alloc_attrs
11291 ++ * @size: size of memory originally requested in dma_alloc_attrs
11292 ++ * @attrs: attributes of mapping properties requested in dma_alloc_attrs
11293 ++ *
11294 ++ * Map a coherent DMA buffer previously allocated by dma_alloc_attrs
11295 ++ * into user space. The coherent DMA buffer must not be freed by the
11296 ++ * driver until the user space mapping has been released.
11297 ++ */
11298 ++static inline int
11299 ++dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr,
11300 ++ dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
11302 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11303 ++ BUG_ON(!ops);
11304 ++ if (ops && ops->mmap)
11305 ++ return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
11306 ++ return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size);
11309 ++#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
11311 ++static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma,
11312 ++ void *cpu_addr, dma_addr_t dma_addr, size_t size)
11314 ++ DEFINE_DMA_ATTRS(attrs);
11315 ++ dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
11316 ++ return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
11319 ++int
11320 ++dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
11321 ++ void *cpu_addr, dma_addr_t dma_addr, size_t size);
11323 ++static inline int
11324 ++dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr,
11325 ++ dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
11327 ++ struct dma_map_ops *ops = get_dma_ops(dev);
11328 ++ BUG_ON(!ops);
11329 ++ if (ops && ops->get_sgtable)
11330 ++ return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size,
11331 ++ attrs);
11332 ++ return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, size);
11335 ++#define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL)
11338 + static inline int dma_supported(struct device *dev, u64 mask)
11340 + struct dma_map_ops *ops = get_dma_ops(dev);
11341 +- return ops->dma_supported(dev, mask);
11342 ++ if (ops)
11343 ++ return ops->dma_supported(dev, mask);
11344 ++ return plat_dma_supported(dev, mask);
11347 + static inline int dma_mapping_error(struct device *dev, u64 mask)
11348 +@@ -43,7 +386,9 @@ static inline int dma_mapping_error(stru
11349 + struct dma_map_ops *ops = get_dma_ops(dev);
11351 + debug_dma_mapping_error(dev, mask);
11352 +- return ops->mapping_error(dev, mask);
11353 ++ if (ops)
11354 ++ return ops->mapping_error(dev, mask);
11355 ++ return 0;
11358 + static inline int
11359 +@@ -74,7 +419,11 @@ static inline void *dma_alloc_attrs(stru
11360 + void *ret;
11361 + struct dma_map_ops *ops = get_dma_ops(dev);
11363 +- ret = ops->alloc(dev, size, dma_handle, gfp, attrs);
11364 ++ if (ops)
11365 ++ ret = ops->alloc(dev, size, dma_handle, gfp, attrs);
11366 ++ else
11367 ++ ret = mips_dma_alloc_coherent(dev, size, dma_handle, gfp,
11368 ++ attrs);
11370 + debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
11372 +@@ -89,7 +438,10 @@ static inline void dma_free_attrs(struct
11374 + struct dma_map_ops *ops = get_dma_ops(dev);
11376 +- ops->free(dev, size, vaddr, dma_handle, attrs);
11377 ++ if (ops)
11378 ++ ops->free(dev, size, vaddr, dma_handle, attrs);
11379 ++ else
11380 ++ mips_dma_free_coherent(dev, size, vaddr, dma_handle, attrs);
11382 + debug_dma_free_coherent(dev, size, vaddr, dma_handle);
11384 +--- a/arch/mips/mm/dma-default.c
11385 ++++ b/arch/mips/mm/dma-default.c
11386 +@@ -25,7 +25,7 @@
11388 + #ifdef CONFIG_DMA_MAYBE_COHERENT
11389 + int coherentio = 0; /* User defined DMA coherency from command line. */
11390 +-EXPORT_SYMBOL_GPL(coherentio);
11391 ++EXPORT_SYMBOL(coherentio);
11392 + int hw_coherentio = 0; /* Actual hardware supported DMA coherency setting. */
11394 + static int __init setcoherentio(char *str)
11395 +@@ -45,30 +45,6 @@ static int __init setnocoherentio(char *
11396 + early_param("nocoherentio", setnocoherentio);
11397 + #endif
11399 +-static inline struct page *dma_addr_to_page(struct device *dev,
11400 +- dma_addr_t dma_addr)
11402 +- return pfn_to_page(
11403 +- plat_dma_addr_to_phys(dev, dma_addr) >> PAGE_SHIFT);
11406 +-/*
11407 +- * The affected CPUs below in 'cpu_needs_post_dma_flush()' can
11408 +- * speculatively fill random cachelines with stale data at any time,
11409 +- * requiring an extra flush post-DMA.
11410 +- *
11411 +- * Warning on the terminology - Linux calls an uncached area coherent;
11412 +- * MIPS terminology calls memory areas with hardware maintained coherency
11413 +- * coherent.
11414 +- */
11415 +-static inline int cpu_needs_post_dma_flush(struct device *dev)
11417 +- return !plat_device_is_coherent(dev) &&
11418 +- (boot_cpu_type() == CPU_R10000 ||
11419 +- boot_cpu_type() == CPU_R12000 ||
11420 +- boot_cpu_type() == CPU_BMIPS5000);
11423 + static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
11425 + gfp_t dma_flag;
11426 +@@ -124,8 +100,9 @@ void *dma_alloc_noncoherent(struct devic
11428 + EXPORT_SYMBOL(dma_alloc_noncoherent);
11430 +-static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
11431 +- dma_addr_t * dma_handle, gfp_t gfp, struct dma_attrs *attrs)
11432 ++void *mips_dma_alloc_coherent(struct device *dev, size_t size,
11433 ++ dma_addr_t *dma_handle, gfp_t gfp,
11434 ++ struct dma_attrs *attrs)
11436 + void *ret;
11438 +@@ -149,6 +126,7 @@ static void *mips_dma_alloc_coherent(str
11440 + return ret;
11442 ++EXPORT_SYMBOL(mips_dma_alloc_coherent);
11445 + void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
11446 +@@ -159,8 +137,8 @@ void dma_free_noncoherent(struct device
11448 + EXPORT_SYMBOL(dma_free_noncoherent);
11450 +-static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
11451 +- dma_addr_t dma_handle, struct dma_attrs *attrs)
11452 ++void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
11453 ++ dma_addr_t dma_handle, struct dma_attrs *attrs)
11455 + unsigned long addr = (unsigned long) vaddr;
11456 + int order = get_order(size);
11457 +@@ -175,6 +153,7 @@ static void mips_dma_free_coherent(struc
11459 + free_pages(addr, get_order(size));
11461 ++EXPORT_SYMBOL(mips_dma_free_coherent);
11463 + static inline void __dma_sync_virtual(void *addr, size_t size,
11464 + enum dma_data_direction direction)
11465 +@@ -203,8 +182,8 @@ static inline void __dma_sync_virtual(vo
11466 + * If highmem is not configured then the bulk of this loop gets
11467 + * optimized out.
11468 + */
11469 +-static inline void __dma_sync(struct page *page,
11470 +- unsigned long offset, size_t size, enum dma_data_direction direction)
11471 ++void __dma_sync(struct page *page, unsigned long offset, size_t size,
11472 ++ enum dma_data_direction direction)
11474 + size_t left = size;
11476 +@@ -233,108 +212,7 @@ static inline void __dma_sync(struct pag
11477 + left -= len;
11478 + } while (left);
11481 +-static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
11482 +- size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
11484 +- if (cpu_needs_post_dma_flush(dev))
11485 +- __dma_sync(dma_addr_to_page(dev, dma_addr),
11486 +- dma_addr & ~PAGE_MASK, size, direction);
11488 +- plat_unmap_dma_mem(dev, dma_addr, size, direction);
11491 +-static int mips_dma_map_sg(struct device *dev, struct scatterlist *sg,
11492 +- int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
11494 +- int i;
11496 +- for (i = 0; i < nents; i++, sg++) {
11497 +- if (!plat_device_is_coherent(dev))
11498 +- __dma_sync(sg_page(sg), sg->offset, sg->length,
11499 +- direction);
11500 +-#ifdef CONFIG_NEED_SG_DMA_LENGTH
11501 +- sg->dma_length = sg->length;
11502 +-#endif
11503 +- sg->dma_address = plat_map_dma_mem_page(dev, sg_page(sg)) +
11504 +- sg->offset;
11505 +- }
11507 +- return nents;
11510 +-static dma_addr_t mips_dma_map_page(struct device *dev, struct page *page,
11511 +- unsigned long offset, size_t size, enum dma_data_direction direction,
11512 +- struct dma_attrs *attrs)
11514 +- if (!plat_device_is_coherent(dev))
11515 +- __dma_sync(page, offset, size, direction);
11517 +- return plat_map_dma_mem_page(dev, page) + offset;
11520 +-static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
11521 +- int nhwentries, enum dma_data_direction direction,
11522 +- struct dma_attrs *attrs)
11524 +- int i;
11526 +- for (i = 0; i < nhwentries; i++, sg++) {
11527 +- if (!plat_device_is_coherent(dev) &&
11528 +- direction != DMA_TO_DEVICE)
11529 +- __dma_sync(sg_page(sg), sg->offset, sg->length,
11530 +- direction);
11531 +- plat_unmap_dma_mem(dev, sg->dma_address, sg->length, direction);
11532 +- }
11535 +-static void mips_dma_sync_single_for_cpu(struct device *dev,
11536 +- dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
11538 +- if (cpu_needs_post_dma_flush(dev))
11539 +- __dma_sync(dma_addr_to_page(dev, dma_handle),
11540 +- dma_handle & ~PAGE_MASK, size, direction);
11543 +-static void mips_dma_sync_single_for_device(struct device *dev,
11544 +- dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
11546 +- if (!plat_device_is_coherent(dev))
11547 +- __dma_sync(dma_addr_to_page(dev, dma_handle),
11548 +- dma_handle & ~PAGE_MASK, size, direction);
11551 +-static void mips_dma_sync_sg_for_cpu(struct device *dev,
11552 +- struct scatterlist *sg, int nelems, enum dma_data_direction direction)
11554 +- int i;
11556 +- if (cpu_needs_post_dma_flush(dev))
11557 +- for (i = 0; i < nelems; i++, sg++)
11558 +- __dma_sync(sg_page(sg), sg->offset, sg->length,
11559 +- direction);
11562 +-static void mips_dma_sync_sg_for_device(struct device *dev,
11563 +- struct scatterlist *sg, int nelems, enum dma_data_direction direction)
11565 +- int i;
11567 +- if (!plat_device_is_coherent(dev))
11568 +- for (i = 0; i < nelems; i++, sg++)
11569 +- __dma_sync(sg_page(sg), sg->offset, sg->length,
11570 +- direction);
11573 +-int mips_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
11575 +- return 0;
11578 +-int mips_dma_supported(struct device *dev, u64 mask)
11580 +- return plat_dma_supported(dev, mask);
11582 ++EXPORT_SYMBOL(__dma_sync);
11584 + void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
11585 + enum dma_data_direction direction)
11586 +@@ -347,23 +225,10 @@ void dma_cache_sync(struct device *dev,
11588 + EXPORT_SYMBOL(dma_cache_sync);
11590 +-static struct dma_map_ops mips_default_dma_map_ops = {
11591 +- .alloc = mips_dma_alloc_coherent,
11592 +- .free = mips_dma_free_coherent,
11593 +- .map_page = mips_dma_map_page,
11594 +- .unmap_page = mips_dma_unmap_page,
11595 +- .map_sg = mips_dma_map_sg,
11596 +- .unmap_sg = mips_dma_unmap_sg,
11597 +- .sync_single_for_cpu = mips_dma_sync_single_for_cpu,
11598 +- .sync_single_for_device = mips_dma_sync_single_for_device,
11599 +- .sync_sg_for_cpu = mips_dma_sync_sg_for_cpu,
11600 +- .sync_sg_for_device = mips_dma_sync_sg_for_device,
11601 +- .mapping_error = mips_dma_mapping_error,
11602 +- .dma_supported = mips_dma_supported
11603 +-};
11605 +-struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
11606 ++#ifdef CONFIG_SYS_HAS_DMA_OPS
11607 ++struct dma_map_ops *mips_dma_map_ops = NULL;
11608 + EXPORT_SYMBOL(mips_dma_map_ops);
11609 ++#endif
11611 + #define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
11613 diff --git a/target/linux/generic/patches-3.16/200-fix_localversion.patch b/target/linux/generic/patches-3.16/200-fix_localversion.patch
11614 new file mode 100644
11615 index 000000000000..70228bb5f47e
11616 --- /dev/null
11617 +++ b/target/linux/generic/patches-3.16/200-fix_localversion.patch
11618 @@ -0,0 +1,11 @@
11619 +--- a/scripts/setlocalversion
11620 ++++ b/scripts/setlocalversion
11621 +@@ -165,7 +165,7 @@ else
11622 + # annotated or signed tagged state (as git describe only
11623 + # looks at signed or annotated tags - git tag -a/-s) and
11624 + # LOCALVERSION= is not specified
11625 +- if test "${LOCALVERSION+set}" != "set"; then
11626 ++ if test "${CONFIG_LOCALVERSION+set}" != "set"; then
11627 + scm=$(scm_version --short)
11628 + res="$res${scm:++}"
11629 + fi
11630 diff --git a/target/linux/generic/patches-3.16/201-extra_optimization.patch b/target/linux/generic/patches-3.16/201-extra_optimization.patch
11631 new file mode 100644
11632 index 000000000000..cec343cf0572
11633 --- /dev/null
11634 +++ b/target/linux/generic/patches-3.16/201-extra_optimization.patch
11635 @@ -0,0 +1,14 @@
11636 +--- a/Makefile
11637 ++++ b/Makefile
11638 +@@ -580,9 +580,9 @@ endif # $(dot-config)
11639 + all: vmlinux
11641 + ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
11642 +-KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
11643 ++KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION) $(call cc-disable-warning,maybe-uninitialized,)
11644 + else
11645 +-KBUILD_CFLAGS += -O2
11646 ++KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION)
11647 + endif
11649 + include $(srctree)/arch/$(SRCARCH)/Makefile
11650 diff --git a/target/linux/generic/patches-3.16/202-reduce_module_size.patch b/target/linux/generic/patches-3.16/202-reduce_module_size.patch
11651 new file mode 100644
11652 index 000000000000..49fe6d53ecf0
11653 --- /dev/null
11654 +++ b/target/linux/generic/patches-3.16/202-reduce_module_size.patch
11655 @@ -0,0 +1,11 @@
11656 +--- a/Makefile
11657 ++++ b/Makefile
11658 +@@ -388,7 +388,7 @@ KBUILD_CFLAGS_KERNEL :=
11659 + KBUILD_AFLAGS := -D__ASSEMBLY__
11660 + KBUILD_AFLAGS_MODULE := -DMODULE
11661 + KBUILD_CFLAGS_MODULE := -DMODULE
11662 +-KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
11663 ++KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if $(CONFIG_PROFILING),,-s)
11665 + # Read KERNELRELEASE from include/config/kernel.release (if it exists)
11666 + KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
11667 diff --git a/target/linux/generic/patches-3.16/203-kallsyms_uncompressed.patch b/target/linux/generic/patches-3.16/203-kallsyms_uncompressed.patch
11668 new file mode 100644
11669 index 000000000000..96b87c0772d1
11670 --- /dev/null
11671 +++ b/target/linux/generic/patches-3.16/203-kallsyms_uncompressed.patch
11672 @@ -0,0 +1,108 @@
11673 +--- a/scripts/kallsyms.c
11674 ++++ b/scripts/kallsyms.c
11675 +@@ -59,6 +59,7 @@ static struct sym_entry *table;
11676 + static unsigned int table_size, table_cnt;
11677 + static int all_symbols = 0;
11678 + static int absolute_percpu = 0;
11679 ++static int uncompressed = 0;
11680 + static char symbol_prefix_char = '\0';
11681 + static unsigned long long kernel_start_addr = 0;
11683 +@@ -392,6 +393,9 @@ static void write_src(void)
11685 + free(markers);
11687 ++ if (uncompressed)
11688 ++ return;
11690 + output_label("kallsyms_token_table");
11691 + off = 0;
11692 + for (i = 0; i < 256; i++) {
11693 +@@ -450,6 +454,9 @@ static void *find_token(unsigned char *s
11695 + int i;
11697 ++ if (uncompressed)
11698 ++ return NULL;
11700 + for (i = 0; i < len - 1; i++) {
11701 + if (str[i] == token[0] && str[i+1] == token[1])
11702 + return &str[i];
11703 +@@ -522,6 +529,9 @@ static void optimize_result(void)
11705 + int i, best;
11707 ++ if (uncompressed)
11708 ++ return;
11710 + /* using the '\0' symbol last allows compress_symbols to use standard
11711 + * fast string functions */
11712 + for (i = 255; i >= 0; i--) {
11713 +@@ -692,7 +702,9 @@ int main(int argc, char **argv)
11714 + } else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
11715 + const char *p = &argv[i][14];
11716 + kernel_start_addr = strtoull(p, NULL, 16);
11717 +- } else
11718 ++ } else if (strcmp(argv[i], "--uncompressed") == 0)
11719 ++ uncompressed = 1;
11720 ++ else
11721 + usage();
11723 + } else if (argc != 1)
11724 +--- a/init/Kconfig
11725 ++++ b/init/Kconfig
11726 +@@ -1293,6 +1293,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
11727 + the unaligned access emulation.
11728 + see arch/parisc/kernel/unaligned.c for reference
11730 ++config KALLSYMS_UNCOMPRESSED
11731 ++ bool "Keep kallsyms uncompressed"
11732 ++ depends on KALLSYMS
11733 ++ help
11734 ++ Normally kallsyms contains compressed symbols (using a token table),
11735 ++ reducing the uncompressed kernel image size. Keeping the symbol table
11736 ++ uncompressed significantly improves the size of this part in compressed
11737 ++ kernel images.
11739 ++ Say N unless you need compressed kernel images to be small.
11741 + config HAVE_PCSPKR_PLATFORM
11742 + bool
11744 +--- a/scripts/link-vmlinux.sh
11745 ++++ b/scripts/link-vmlinux.sh
11746 +@@ -90,6 +90,10 @@ kallsyms()
11747 + kallsymopt="${kallsymopt} --absolute-percpu"
11748 + fi
11750 ++ if [ -n "${CONFIG_KALLSYMS_UNCOMPRESSED}" ]; then
11751 ++ kallsymopt="${kallsymopt} --uncompressed"
11752 ++ fi
11754 + local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
11755 + ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
11757 +--- a/kernel/kallsyms.c
11758 ++++ b/kernel/kallsyms.c
11759 +@@ -109,6 +109,11 @@ static unsigned int kallsyms_expand_symb
11760 + * For every byte on the compressed symbol data, copy the table
11761 + * entry for that byte.
11762 + */
11763 ++#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
11764 ++ memcpy(result, data + 1, len - 1);
11765 ++ result += len - 1;
11766 ++ len = 0;
11767 ++#endif
11768 + while (len) {
11769 + tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
11770 + data++;
11771 +@@ -141,6 +146,9 @@ tail:
11772 + */
11773 + static char kallsyms_get_symbol_type(unsigned int off)
11775 ++#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
11776 ++ return kallsyms_names[off + 1];
11777 ++#endif
11778 + /*
11779 + * Get just the first code, look it up in the token table,
11780 + * and return the first char from this token.
11781 diff --git a/target/linux/generic/patches-3.16/204-module_strip.patch b/target/linux/generic/patches-3.16/204-module_strip.patch
11782 new file mode 100644
11783 index 000000000000..dcf17dd4714a
11784 --- /dev/null
11785 +++ b/target/linux/generic/patches-3.16/204-module_strip.patch
11786 @@ -0,0 +1,194 @@
11787 +From: Felix Fietkau <nbd@openwrt.org>
11788 +Subject: [PATCH] build: add a hack for removing non-essential module info
11790 +Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11791 +---
11792 +--- a/include/linux/module.h
11793 ++++ b/include/linux/module.h
11794 +@@ -84,9 +84,10 @@ void trim_init_extable(struct module *m)
11796 + /* Generic info of form tag = "info" */
11797 + #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
11798 ++#define MODULE_INFO_STRIP(tag, info) __MODULE_INFO_STRIP(tag, tag, info)
11800 + /* For userspace: you can also call me... */
11801 +-#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
11802 ++#define MODULE_ALIAS(_alias) MODULE_INFO_STRIP(alias, _alias)
11804 + /* Soft module dependencies. See man modprobe.d for details.
11805 + * Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
11806 +@@ -127,12 +128,12 @@ void trim_init_extable(struct module *m)
11807 + * Author(s), use "Name <email>" or just "Name", for multiple
11808 + * authors use multiple MODULE_AUTHOR() statements/lines.
11809 + */
11810 +-#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
11811 ++#define MODULE_AUTHOR(_author) MODULE_INFO_STRIP(author, _author)
11813 + /* What your module does. */
11814 +-#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
11815 ++#define MODULE_DESCRIPTION(_description) MODULE_INFO_STRIP(description, _description)
11817 +-#ifdef MODULE
11818 ++#if defined(MODULE) && !defined(CONFIG_MODULE_STRIPPED)
11819 + /* Creates an alias so file2alias.c can find device table. */
11820 + #define MODULE_DEVICE_TABLE(type, name) \
11821 + extern const struct type##_device_id __mod_##type##__##name##_device_table \
11822 +@@ -159,7 +160,9 @@ void trim_init_extable(struct module *m)
11823 + */
11825 + #if defined(MODULE) || !defined(CONFIG_SYSFS)
11826 +-#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
11827 ++#define MODULE_VERSION(_version) MODULE_INFO_STRIP(version, _version)
11828 ++#elif defined(CONFIG_MODULE_STRIPPED)
11829 ++#define MODULE_VERSION(_version) __MODULE_INFO_DISABLED(version)
11830 + #else
11831 + #define MODULE_VERSION(_version) \
11832 + static struct module_version_attribute ___modver_attr = { \
11833 +@@ -181,7 +184,7 @@ void trim_init_extable(struct module *m)
11834 + /* Optional firmware file (or files) needed by the module
11835 + * format is simply firmware file name. Multiple firmware
11836 + * files require multiple MODULE_FIRMWARE() specifiers */
11837 +-#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
11838 ++#define MODULE_FIRMWARE(_firmware) MODULE_INFO_STRIP(firmware, _firmware)
11840 + /* Given an address, look for it in the exception tables */
11841 + const struct exception_table_entry *search_exception_tables(unsigned long add);
11842 +--- a/include/linux/moduleparam.h
11843 ++++ b/include/linux/moduleparam.h
11844 +@@ -16,6 +16,16 @@
11845 + /* Chosen so that structs with an unsigned long line up. */
11846 + #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
11848 ++/* This struct is here for syntactic coherency, it is not used */
11849 ++#define __MODULE_INFO_DISABLED(name) \
11850 ++ struct __UNIQUE_ID(name) {}
11852 ++#ifdef CONFIG_MODULE_STRIPPED
11853 ++#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO_DISABLED(name)
11854 ++#else
11855 ++#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO(tag, name, info)
11856 ++#endif
11858 + #ifdef MODULE
11859 + #define __MODULE_INFO(tag, name, info) \
11860 + static const char __UNIQUE_ID(name)[] \
11861 +@@ -23,8 +33,7 @@ static const char __UNIQUE_ID(name)[]
11862 + = __stringify(tag) "=" info
11863 + #else /* !MODULE */
11864 + /* This struct is here for syntactic coherency, it is not used */
11865 +-#define __MODULE_INFO(tag, name, info) \
11866 +- struct __UNIQUE_ID(name) {}
11867 ++#define __MODULE_INFO(tag, name, info) __MODULE_INFO_DISABLED(name)
11868 + #endif
11869 + #define __MODULE_PARM_TYPE(name, _type) \
11870 + __MODULE_INFO(parmtype, name##type, #name ":" _type)
11871 +@@ -32,7 +41,7 @@ static const char __UNIQUE_ID(name)[]
11872 + /* One for each parameter, describing how to use it. Some files do
11873 + multiple of these per line, so can't just use MODULE_INFO. */
11874 + #define MODULE_PARM_DESC(_parm, desc) \
11875 +- __MODULE_INFO(parm, _parm, #_parm ":" desc)
11876 ++ __MODULE_INFO_STRIP(parm, _parm, #_parm ":" desc)
11878 + struct kernel_param;
11880 +--- a/init/Kconfig
11881 ++++ b/init/Kconfig
11882 +@@ -1874,6 +1874,13 @@ config MODULE_SIG_HASH
11883 + default "sha384" if MODULE_SIG_SHA384
11884 + default "sha512" if MODULE_SIG_SHA512
11886 ++config MODULE_STRIPPED
11887 ++ bool "Reduce module size"
11888 ++ depends on MODULES
11889 ++ help
11890 ++ Remove module parameter descriptions, author info, version, aliases,
11891 ++ device tables, etc.
11893 + endif # MODULES
11895 + config INIT_ALL_POSSIBLE
11896 +--- a/kernel/module.c
11897 ++++ b/kernel/module.c
11898 +@@ -2667,6 +2667,7 @@ static struct module *setup_load_info(st
11900 + static int check_modinfo(struct module *mod, struct load_info *info, int flags)
11902 ++#ifndef CONFIG_MODULE_STRIPPED
11903 + const char *modmagic = get_modinfo(info, "vermagic");
11904 + int err;
11906 +@@ -2692,6 +2693,7 @@ static int check_modinfo(struct module *
11907 + pr_warn("%s: module is from the staging directory, the quality "
11908 + "is unknown, you have been warned.\n", mod->name);
11910 ++#endif
11912 + /* Set up license info based on the info section */
11913 + set_license(mod, get_modinfo(info, "license"));
11914 +--- a/scripts/mod/modpost.c
11915 ++++ b/scripts/mod/modpost.c
11916 +@@ -1755,7 +1755,9 @@ static void read_symbols(char *modname)
11917 + symname = remove_dot(info.strtab + sym->st_name);
11919 + handle_modversions(mod, &info, sym, symname);
11920 ++#ifndef CONFIG_MODULE_STRIPPED
11921 + handle_moddevtable(mod, &info, sym, symname);
11922 ++#endif
11924 + if (!is_vmlinux(modname) ||
11925 + (is_vmlinux(modname) && vmlinux_section_warnings))
11926 +@@ -1899,7 +1901,9 @@ static void add_header(struct buffer *b,
11927 + buf_printf(b, "#include <linux/vermagic.h>\n");
11928 + buf_printf(b, "#include <linux/compiler.h>\n");
11929 + buf_printf(b, "\n");
11930 ++#ifndef CONFIG_MODULE_STRIPPED
11931 + buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
11932 ++#endif
11933 + buf_printf(b, "\n");
11934 + buf_printf(b, "__visible struct module __this_module\n");
11935 + buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
11936 +@@ -1916,16 +1920,20 @@ static void add_header(struct buffer *b,
11938 + static void add_intree_flag(struct buffer *b, int is_intree)
11940 ++#ifndef CONFIG_MODULE_STRIPPED
11941 + if (is_intree)
11942 + buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
11943 ++#endif
11946 + static void add_staging_flag(struct buffer *b, const char *name)
11948 ++#ifndef CONFIG_MODULE_STRIPPED
11949 + static const char *staging_dir = "drivers/staging";
11951 + if (strncmp(staging_dir, name, strlen(staging_dir)) == 0)
11952 + buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
11953 ++#endif
11956 + /**
11957 +@@ -2018,11 +2026,13 @@ static void add_depends(struct buffer *b
11959 + static void add_srcversion(struct buffer *b, struct module *mod)
11961 ++#ifndef CONFIG_MODULE_STRIPPED
11962 + if (mod->srcversion[0]) {
11963 + buf_printf(b, "\n");
11964 + buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n",
11965 + mod->srcversion);
11967 ++#endif
11970 + static void write_if_changed(struct buffer *b, const char *fname)
11971 +@@ -2253,7 +2263,9 @@ int main(int argc, char **argv)
11972 + add_staging_flag(&buf, mod->name);
11973 + err |= add_versions(&buf, mod);
11974 + add_depends(&buf, mod, modules);
11975 ++#ifndef CONFIG_MODULE_STRIPPED
11976 + add_moddevtable(&buf, mod);
11977 ++#endif
11978 + add_srcversion(&buf, mod);
11980 + sprintf(fname, "%s.mod.c", mod->name);
11981 diff --git a/target/linux/generic/patches-3.16/210-darwin_scripts_include.patch b/target/linux/generic/patches-3.16/210-darwin_scripts_include.patch
11982 new file mode 100644
11983 index 000000000000..f358e0a0948f
11984 --- /dev/null
11985 +++ b/target/linux/generic/patches-3.16/210-darwin_scripts_include.patch
11986 @@ -0,0 +1,3088 @@
11987 +--- a/scripts/kallsyms.c
11988 ++++ b/scripts/kallsyms.c
11989 +@@ -22,6 +22,35 @@
11990 + #include <stdlib.h>
11991 + #include <string.h>
11992 + #include <ctype.h>
11993 ++#ifdef __APPLE__
11994 ++/* Darwin has no memmem implementation, this one is ripped of the uClibc-0.9.28 source */
11995 ++void *memmem (const void *haystack, size_t haystack_len,
11996 ++ const void *needle, size_t needle_len)
11998 ++ const char *begin;
11999 ++ const char *const last_possible
12000 ++ = (const char *) haystack + haystack_len - needle_len;
12002 ++ if (needle_len == 0)
12003 ++ /* The first occurrence of the empty string is deemed to occur at
12004 ++ the beginning of the string. */
12005 ++ return (void *) haystack;
12007 ++ /* Sanity check, otherwise the loop might search through the whole
12008 ++ memory. */
12009 ++ if (__builtin_expect (haystack_len < needle_len, 0))
12010 ++ return NULL;
12012 ++ for (begin = (const char *) haystack; begin <= last_possible; ++begin)
12013 ++ if (begin[0] == ((const char *) needle)[0] &&
12014 ++ !memcmp ((const void *) &begin[1],
12015 ++ (const void *) ((const char *) needle + 1),
12016 ++ needle_len - 1))
12017 ++ return (void *) begin;
12019 ++ return NULL;
12021 ++#endif
12023 + #ifndef ARRAY_SIZE
12024 + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
12025 +--- a/scripts/kconfig/Makefile
12026 ++++ b/scripts/kconfig/Makefile
12027 +@@ -132,6 +132,9 @@ check-lxdialog := $(srctree)/$(src)/lxd
12028 + # we really need to do so. (Do not call gcc as part of make mrproper)
12029 + HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
12030 + -DLOCALE
12031 ++ifeq ($(shell uname -s),Darwin)
12032 ++HOST_LOADLIBES += -lncurses
12033 ++endif
12035 + # ===========================================================================
12036 + # Shared Makefile for the various kconfig executables:
12037 +--- a/scripts/mod/mk_elfconfig.c
12038 ++++ b/scripts/mod/mk_elfconfig.c
12039 +@@ -1,7 +1,11 @@
12040 + #include <stdio.h>
12041 + #include <stdlib.h>
12042 + #include <string.h>
12043 ++#ifndef __APPLE__
12044 + #include <elf.h>
12045 ++#else
12046 ++#include "elf.h"
12047 ++#endif
12049 + int
12050 + main(int argc, char **argv)
12051 +--- a/scripts/mod/modpost.h
12052 ++++ b/scripts/mod/modpost.h
12053 +@@ -7,7 +7,11 @@
12054 + #include <sys/mman.h>
12055 + #include <fcntl.h>
12056 + #include <unistd.h>
12057 ++#if !(defined(__APPLE__) || defined(__CYGWIN__))
12058 + #include <elf.h>
12059 ++#else
12060 ++#include "elf.h"
12061 ++#endif
12063 + #include "elfconfig.h"
12065 +--- /dev/null
12066 ++++ b/scripts/mod/elf.h
12067 +@@ -0,0 +1,3007 @@
12068 ++/* This file defines standard ELF types, structures, and macros.
12069 ++ Copyright (C) 1995-2012 Free Software Foundation, Inc.
12070 ++ This file is part of the GNU C Library.
12072 ++ The GNU C Library is free software; you can redistribute it and/or
12073 ++ modify it under the terms of the GNU Lesser General Public
12074 ++ License as published by the Free Software Foundation; either
12075 ++ version 2.1 of the License, or (at your option) any later version.
12077 ++ The GNU C Library is distributed in the hope that it will be useful,
12078 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
12079 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12080 ++ Lesser General Public License for more details.
12082 ++ You should have received a copy of the GNU Lesser General Public
12083 ++ License along with the GNU C Library; if not, see
12084 ++ <http://www.gnu.org/licenses/>. */
12086 ++#ifndef _ELF_H
12087 ++#define _ELF_H 1
12089 ++/* Standard ELF types. */
12091 ++#include <stdint.h>
12093 ++/* Type for a 16-bit quantity. */
12094 ++typedef uint16_t Elf32_Half;
12095 ++typedef uint16_t Elf64_Half;
12097 ++/* Types for signed and unsigned 32-bit quantities. */
12098 ++typedef uint32_t Elf32_Word;
12099 ++typedef int32_t Elf32_Sword;
12100 ++typedef uint32_t Elf64_Word;
12101 ++typedef int32_t Elf64_Sword;
12103 ++/* Types for signed and unsigned 64-bit quantities. */
12104 ++typedef uint64_t Elf32_Xword;
12105 ++typedef int64_t Elf32_Sxword;
12106 ++typedef uint64_t Elf64_Xword;
12107 ++typedef int64_t Elf64_Sxword;
12109 ++/* Type of addresses. */
12110 ++typedef uint32_t Elf32_Addr;
12111 ++typedef uint64_t Elf64_Addr;
12113 ++/* Type of file offsets. */
12114 ++typedef uint32_t Elf32_Off;
12115 ++typedef uint64_t Elf64_Off;
12117 ++/* Type for section indices, which are 16-bit quantities. */
12118 ++typedef uint16_t Elf32_Section;
12119 ++typedef uint16_t Elf64_Section;
12121 ++/* Type for version symbol information. */
12122 ++typedef Elf32_Half Elf32_Versym;
12123 ++typedef Elf64_Half Elf64_Versym;
12126 ++/* The ELF file header. This appears at the start of every ELF file. */
12128 ++#define EI_NIDENT (16)
12130 ++typedef struct
12132 ++ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
12133 ++ Elf32_Half e_type; /* Object file type */
12134 ++ Elf32_Half e_machine; /* Architecture */
12135 ++ Elf32_Word e_version; /* Object file version */
12136 ++ Elf32_Addr e_entry; /* Entry point virtual address */
12137 ++ Elf32_Off e_phoff; /* Program header table file offset */
12138 ++ Elf32_Off e_shoff; /* Section header table file offset */
12139 ++ Elf32_Word e_flags; /* Processor-specific flags */
12140 ++ Elf32_Half e_ehsize; /* ELF header size in bytes */
12141 ++ Elf32_Half e_phentsize; /* Program header table entry size */
12142 ++ Elf32_Half e_phnum; /* Program header table entry count */
12143 ++ Elf32_Half e_shentsize; /* Section header table entry size */
12144 ++ Elf32_Half e_shnum; /* Section header table entry count */
12145 ++ Elf32_Half e_shstrndx; /* Section header string table index */
12146 ++} Elf32_Ehdr;
12148 ++typedef struct
12150 ++ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
12151 ++ Elf64_Half e_type; /* Object file type */
12152 ++ Elf64_Half e_machine; /* Architecture */
12153 ++ Elf64_Word e_version; /* Object file version */
12154 ++ Elf64_Addr e_entry; /* Entry point virtual address */
12155 ++ Elf64_Off e_phoff; /* Program header table file offset */
12156 ++ Elf64_Off e_shoff; /* Section header table file offset */
12157 ++ Elf64_Word e_flags; /* Processor-specific flags */
12158 ++ Elf64_Half e_ehsize; /* ELF header size in bytes */
12159 ++ Elf64_Half e_phentsize; /* Program header table entry size */
12160 ++ Elf64_Half e_phnum; /* Program header table entry count */
12161 ++ Elf64_Half e_shentsize; /* Section header table entry size */
12162 ++ Elf64_Half e_shnum; /* Section header table entry count */
12163 ++ Elf64_Half e_shstrndx; /* Section header string table index */
12164 ++} Elf64_Ehdr;
12166 ++/* Fields in the e_ident array. The EI_* macros are indices into the
12167 ++ array. The macros under each EI_* macro are the values the byte
12168 ++ may have. */
12170 ++#define EI_MAG0 0 /* File identification byte 0 index */
12171 ++#define ELFMAG0 0x7f /* Magic number byte 0 */
12173 ++#define EI_MAG1 1 /* File identification byte 1 index */
12174 ++#define ELFMAG1 'E' /* Magic number byte 1 */
12176 ++#define EI_MAG2 2 /* File identification byte 2 index */
12177 ++#define ELFMAG2 'L' /* Magic number byte 2 */
12179 ++#define EI_MAG3 3 /* File identification byte 3 index */
12180 ++#define ELFMAG3 'F' /* Magic number byte 3 */
12182 ++/* Conglomeration of the identification bytes, for easy testing as a word. */
12183 ++#define ELFMAG "\177ELF"
12184 ++#define SELFMAG 4
12186 ++#define EI_CLASS 4 /* File class byte index */
12187 ++#define ELFCLASSNONE 0 /* Invalid class */
12188 ++#define ELFCLASS32 1 /* 32-bit objects */
12189 ++#define ELFCLASS64 2 /* 64-bit objects */
12190 ++#define ELFCLASSNUM 3
12192 ++#define EI_DATA 5 /* Data encoding byte index */
12193 ++#define ELFDATANONE 0 /* Invalid data encoding */
12194 ++#define ELFDATA2LSB 1 /* 2's complement, little endian */
12195 ++#define ELFDATA2MSB 2 /* 2's complement, big endian */
12196 ++#define ELFDATANUM 3
12198 ++#define EI_VERSION 6 /* File version byte index */
12199 ++ /* Value must be EV_CURRENT */
12201 ++#define EI_OSABI 7 /* OS ABI identification */
12202 ++#define ELFOSABI_NONE 0 /* UNIX System V ABI */
12203 ++#define ELFOSABI_SYSV 0 /* Alias. */
12204 ++#define ELFOSABI_HPUX 1 /* HP-UX */
12205 ++#define ELFOSABI_NETBSD 2 /* NetBSD. */
12206 ++#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
12207 ++#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
12208 ++#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
12209 ++#define ELFOSABI_AIX 7 /* IBM AIX. */
12210 ++#define ELFOSABI_IRIX 8 /* SGI Irix. */
12211 ++#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
12212 ++#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
12213 ++#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
12214 ++#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
12215 ++#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
12216 ++#define ELFOSABI_ARM 97 /* ARM */
12217 ++#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
12219 ++#define EI_ABIVERSION 8 /* ABI version */
12221 ++#define EI_PAD 9 /* Byte index of padding bytes */
12223 ++/* Legal values for e_type (object file type). */
12225 ++#define ET_NONE 0 /* No file type */
12226 ++#define ET_REL 1 /* Relocatable file */
12227 ++#define ET_EXEC 2 /* Executable file */
12228 ++#define ET_DYN 3 /* Shared object file */
12229 ++#define ET_CORE 4 /* Core file */
12230 ++#define ET_NUM 5 /* Number of defined types */
12231 ++#define ET_LOOS 0xfe00 /* OS-specific range start */
12232 ++#define ET_HIOS 0xfeff /* OS-specific range end */
12233 ++#define ET_LOPROC 0xff00 /* Processor-specific range start */
12234 ++#define ET_HIPROC 0xffff /* Processor-specific range end */
12236 ++/* Legal values for e_machine (architecture). */
12238 ++#define EM_NONE 0 /* No machine */
12239 ++#define EM_M32 1 /* AT&T WE 32100 */
12240 ++#define EM_SPARC 2 /* SUN SPARC */
12241 ++#define EM_386 3 /* Intel 80386 */
12242 ++#define EM_68K 4 /* Motorola m68k family */
12243 ++#define EM_88K 5 /* Motorola m88k family */
12244 ++#define EM_860 7 /* Intel 80860 */
12245 ++#define EM_MIPS 8 /* MIPS R3000 big-endian */
12246 ++#define EM_S370 9 /* IBM System/370 */
12247 ++#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
12249 ++#define EM_PARISC 15 /* HPPA */
12250 ++#define EM_VPP500 17 /* Fujitsu VPP500 */
12251 ++#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
12252 ++#define EM_960 19 /* Intel 80960 */
12253 ++#define EM_PPC 20 /* PowerPC */
12254 ++#define EM_PPC64 21 /* PowerPC 64-bit */
12255 ++#define EM_S390 22 /* IBM S390 */
12257 ++#define EM_V800 36 /* NEC V800 series */
12258 ++#define EM_FR20 37 /* Fujitsu FR20 */
12259 ++#define EM_RH32 38 /* TRW RH-32 */
12260 ++#define EM_RCE 39 /* Motorola RCE */
12261 ++#define EM_ARM 40 /* ARM */
12262 ++#define EM_FAKE_ALPHA 41 /* Digital Alpha */
12263 ++#define EM_SH 42 /* Hitachi SH */
12264 ++#define EM_SPARCV9 43 /* SPARC v9 64-bit */
12265 ++#define EM_TRICORE 44 /* Siemens Tricore */
12266 ++#define EM_ARC 45 /* Argonaut RISC Core */
12267 ++#define EM_H8_300 46 /* Hitachi H8/300 */
12268 ++#define EM_H8_300H 47 /* Hitachi H8/300H */
12269 ++#define EM_H8S 48 /* Hitachi H8S */
12270 ++#define EM_H8_500 49 /* Hitachi H8/500 */
12271 ++#define EM_IA_64 50 /* Intel Merced */
12272 ++#define EM_MIPS_X 51 /* Stanford MIPS-X */
12273 ++#define EM_COLDFIRE 52 /* Motorola Coldfire */
12274 ++#define EM_68HC12 53 /* Motorola M68HC12 */
12275 ++#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
12276 ++#define EM_PCP 55 /* Siemens PCP */
12277 ++#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
12278 ++#define EM_NDR1 57 /* Denso NDR1 microprocessor */
12279 ++#define EM_STARCORE 58 /* Motorola Start*Core processor */
12280 ++#define EM_ME16 59 /* Toyota ME16 processor */
12281 ++#define EM_ST100 60 /* STMicroelectronic ST100 processor */
12282 ++#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
12283 ++#define EM_X86_64 62 /* AMD x86-64 architecture */
12284 ++#define EM_PDSP 63 /* Sony DSP Processor */
12286 ++#define EM_FX66 66 /* Siemens FX66 microcontroller */
12287 ++#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
12288 ++#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
12289 ++#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
12290 ++#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
12291 ++#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
12292 ++#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
12293 ++#define EM_SVX 73 /* Silicon Graphics SVx */
12294 ++#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
12295 ++#define EM_VAX 75 /* Digital VAX */
12296 ++#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
12297 ++#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
12298 ++#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
12299 ++#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
12300 ++#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
12301 ++#define EM_HUANY 81 /* Harvard University machine-independent object files */
12302 ++#define EM_PRISM 82 /* SiTera Prism */
12303 ++#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
12304 ++#define EM_FR30 84 /* Fujitsu FR30 */
12305 ++#define EM_D10V 85 /* Mitsubishi D10V */
12306 ++#define EM_D30V 86 /* Mitsubishi D30V */
12307 ++#define EM_V850 87 /* NEC v850 */
12308 ++#define EM_M32R 88 /* Mitsubishi M32R */
12309 ++#define EM_MN10300 89 /* Matsushita MN10300 */
12310 ++#define EM_MN10200 90 /* Matsushita MN10200 */
12311 ++#define EM_PJ 91 /* picoJava */
12312 ++#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
12313 ++#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
12314 ++#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
12315 ++#define EM_TILEPRO 188 /* Tilera TILEPro */
12316 ++#define EM_TILEGX 191 /* Tilera TILE-Gx */
12317 ++#define EM_NUM 192
12319 ++/* If it is necessary to assign new unofficial EM_* values, please
12320 ++ pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
12321 ++ chances of collision with official or non-GNU unofficial values. */
12323 ++#define EM_ALPHA 0x9026
12325 ++/* Legal values for e_version (version). */
12327 ++#define EV_NONE 0 /* Invalid ELF version */
12328 ++#define EV_CURRENT 1 /* Current version */
12329 ++#define EV_NUM 2
12331 ++/* Section header. */
12333 ++typedef struct
12335 ++ Elf32_Word sh_name; /* Section name (string tbl index) */
12336 ++ Elf32_Word sh_type; /* Section type */
12337 ++ Elf32_Word sh_flags; /* Section flags */
12338 ++ Elf32_Addr sh_addr; /* Section virtual addr at execution */
12339 ++ Elf32_Off sh_offset; /* Section file offset */
12340 ++ Elf32_Word sh_size; /* Section size in bytes */
12341 ++ Elf32_Word sh_link; /* Link to another section */
12342 ++ Elf32_Word sh_info; /* Additional section information */
12343 ++ Elf32_Word sh_addralign; /* Section alignment */
12344 ++ Elf32_Word sh_entsize; /* Entry size if section holds table */
12345 ++} Elf32_Shdr;
12347 ++typedef struct
12349 ++ Elf64_Word sh_name; /* Section name (string tbl index) */
12350 ++ Elf64_Word sh_type; /* Section type */
12351 ++ Elf64_Xword sh_flags; /* Section flags */
12352 ++ Elf64_Addr sh_addr; /* Section virtual addr at execution */
12353 ++ Elf64_Off sh_offset; /* Section file offset */
12354 ++ Elf64_Xword sh_size; /* Section size in bytes */
12355 ++ Elf64_Word sh_link; /* Link to another section */
12356 ++ Elf64_Word sh_info; /* Additional section information */
12357 ++ Elf64_Xword sh_addralign; /* Section alignment */
12358 ++ Elf64_Xword sh_entsize; /* Entry size if section holds table */
12359 ++} Elf64_Shdr;
12361 ++/* Special section indices. */
12363 ++#define SHN_UNDEF 0 /* Undefined section */
12364 ++#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
12365 ++#define SHN_LOPROC 0xff00 /* Start of processor-specific */
12366 ++#define SHN_BEFORE 0xff00 /* Order section before all others
12367 ++ (Solaris). */
12368 ++#define SHN_AFTER 0xff01 /* Order section after all others
12369 ++ (Solaris). */
12370 ++#define SHN_HIPROC 0xff1f /* End of processor-specific */
12371 ++#define SHN_LOOS 0xff20 /* Start of OS-specific */
12372 ++#define SHN_HIOS 0xff3f /* End of OS-specific */
12373 ++#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
12374 ++#define SHN_COMMON 0xfff2 /* Associated symbol is common */
12375 ++#define SHN_XINDEX 0xffff /* Index is in extra table. */
12376 ++#define SHN_HIRESERVE 0xffff /* End of reserved indices */
12378 ++/* Legal values for sh_type (section type). */
12380 ++#define SHT_NULL 0 /* Section header table entry unused */
12381 ++#define SHT_PROGBITS 1 /* Program data */
12382 ++#define SHT_SYMTAB 2 /* Symbol table */
12383 ++#define SHT_STRTAB 3 /* String table */
12384 ++#define SHT_RELA 4 /* Relocation entries with addends */
12385 ++#define SHT_HASH 5 /* Symbol hash table */
12386 ++#define SHT_DYNAMIC 6 /* Dynamic linking information */
12387 ++#define SHT_NOTE 7 /* Notes */
12388 ++#define SHT_NOBITS 8 /* Program space with no data (bss) */
12389 ++#define SHT_REL 9 /* Relocation entries, no addends */
12390 ++#define SHT_SHLIB 10 /* Reserved */
12391 ++#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
12392 ++#define SHT_INIT_ARRAY 14 /* Array of constructors */
12393 ++#define SHT_FINI_ARRAY 15 /* Array of destructors */
12394 ++#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
12395 ++#define SHT_GROUP 17 /* Section group */
12396 ++#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
12397 ++#define SHT_NUM 19 /* Number of defined types. */
12398 ++#define SHT_LOOS 0x60000000 /* Start OS-specific. */
12399 ++#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
12400 ++#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
12401 ++#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
12402 ++#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
12403 ++#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
12404 ++#define SHT_SUNW_move 0x6ffffffa
12405 ++#define SHT_SUNW_COMDAT 0x6ffffffb
12406 ++#define SHT_SUNW_syminfo 0x6ffffffc
12407 ++#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
12408 ++#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
12409 ++#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
12410 ++#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
12411 ++#define SHT_HIOS 0x6fffffff /* End OS-specific type */
12412 ++#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
12413 ++#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
12414 ++#define SHT_LOUSER 0x80000000 /* Start of application-specific */
12415 ++#define SHT_HIUSER 0x8fffffff /* End of application-specific */
12417 ++/* Legal values for sh_flags (section flags). */
12419 ++#define SHF_WRITE (1 << 0) /* Writable */
12420 ++#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
12421 ++#define SHF_EXECINSTR (1 << 2) /* Executable */
12422 ++#define SHF_MERGE (1 << 4) /* Might be merged */
12423 ++#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
12424 ++#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
12425 ++#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
12426 ++#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
12427 ++ required */
12428 ++#define SHF_GROUP (1 << 9) /* Section is member of a group. */
12429 ++#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
12430 ++#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
12431 ++#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
12432 ++#define SHF_ORDERED (1 << 30) /* Special ordering requirement
12433 ++ (Solaris). */
12434 ++#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless
12435 ++ referenced or allocated (Solaris).*/
12437 ++/* Section group handling. */
12438 ++#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
12440 ++/* Symbol table entry. */
12442 ++typedef struct
12444 ++ Elf32_Word st_name; /* Symbol name (string tbl index) */
12445 ++ Elf32_Addr st_value; /* Symbol value */
12446 ++ Elf32_Word st_size; /* Symbol size */
12447 ++ unsigned char st_info; /* Symbol type and binding */
12448 ++ unsigned char st_other; /* Symbol visibility */
12449 ++ Elf32_Section st_shndx; /* Section index */
12450 ++} Elf32_Sym;
12452 ++typedef struct
12454 ++ Elf64_Word st_name; /* Symbol name (string tbl index) */
12455 ++ unsigned char st_info; /* Symbol type and binding */
12456 ++ unsigned char st_other; /* Symbol visibility */
12457 ++ Elf64_Section st_shndx; /* Section index */
12458 ++ Elf64_Addr st_value; /* Symbol value */
12459 ++ Elf64_Xword st_size; /* Symbol size */
12460 ++} Elf64_Sym;
12462 ++/* The syminfo section if available contains additional information about
12463 ++ every dynamic symbol. */
12465 ++typedef struct
12467 ++ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
12468 ++ Elf32_Half si_flags; /* Per symbol flags */
12469 ++} Elf32_Syminfo;
12471 ++typedef struct
12473 ++ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
12474 ++ Elf64_Half si_flags; /* Per symbol flags */
12475 ++} Elf64_Syminfo;
12477 ++/* Possible values for si_boundto. */
12478 ++#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
12479 ++#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
12480 ++#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
12482 ++/* Possible bitmasks for si_flags. */
12483 ++#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
12484 ++#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
12485 ++#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
12486 ++#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
12487 ++ loaded */
12488 ++/* Syminfo version values. */
12489 ++#define SYMINFO_NONE 0
12490 ++#define SYMINFO_CURRENT 1
12491 ++#define SYMINFO_NUM 2
12494 ++/* How to extract and insert information held in the st_info field. */
12496 ++#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
12497 ++#define ELF32_ST_TYPE(val) ((val) & 0xf)
12498 ++#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
12500 ++/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
12501 ++#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
12502 ++#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
12503 ++#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
12505 ++/* Legal values for ST_BIND subfield of st_info (symbol binding). */
12507 ++#define STB_LOCAL 0 /* Local symbol */
12508 ++#define STB_GLOBAL 1 /* Global symbol */
12509 ++#define STB_WEAK 2 /* Weak symbol */
12510 ++#define STB_NUM 3 /* Number of defined types. */
12511 ++#define STB_LOOS 10 /* Start of OS-specific */
12512 ++#define STB_GNU_UNIQUE 10 /* Unique symbol. */
12513 ++#define STB_HIOS 12 /* End of OS-specific */
12514 ++#define STB_LOPROC 13 /* Start of processor-specific */
12515 ++#define STB_HIPROC 15 /* End of processor-specific */
12517 ++/* Legal values for ST_TYPE subfield of st_info (symbol type). */
12519 ++#define STT_NOTYPE 0 /* Symbol type is unspecified */
12520 ++#define STT_OBJECT 1 /* Symbol is a data object */
12521 ++#define STT_FUNC 2 /* Symbol is a code object */
12522 ++#define STT_SECTION 3 /* Symbol associated with a section */
12523 ++#define STT_FILE 4 /* Symbol's name is file name */
12524 ++#define STT_COMMON 5 /* Symbol is a common data object */
12525 ++#define STT_TLS 6 /* Symbol is thread-local data object*/
12526 ++#define STT_NUM 7 /* Number of defined types. */
12527 ++#define STT_LOOS 10 /* Start of OS-specific */
12528 ++#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
12529 ++#define STT_HIOS 12 /* End of OS-specific */
12530 ++#define STT_LOPROC 13 /* Start of processor-specific */
12531 ++#define STT_HIPROC 15 /* End of processor-specific */
12534 ++/* Symbol table indices are found in the hash buckets and chain table
12535 ++ of a symbol hash table section. This special index value indicates
12536 ++ the end of a chain, meaning no further symbols are found in that bucket. */
12538 ++#define STN_UNDEF 0 /* End of a chain. */
12541 ++/* How to extract and insert information held in the st_other field. */
12543 ++#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
12545 ++/* For ELF64 the definitions are the same. */
12546 ++#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
12548 ++/* Symbol visibility specification encoded in the st_other field. */
12549 ++#define STV_DEFAULT 0 /* Default symbol visibility rules */
12550 ++#define STV_INTERNAL 1 /* Processor specific hidden class */
12551 ++#define STV_HIDDEN 2 /* Sym unavailable in other modules */
12552 ++#define STV_PROTECTED 3 /* Not preemptible, not exported */
12555 ++/* Relocation table entry without addend (in section of type SHT_REL). */
12557 ++typedef struct
12559 ++ Elf32_Addr r_offset; /* Address */
12560 ++ Elf32_Word r_info; /* Relocation type and symbol index */
12561 ++} Elf32_Rel;
12563 ++/* I have seen two different definitions of the Elf64_Rel and
12564 ++ Elf64_Rela structures, so we'll leave them out until Novell (or
12565 ++ whoever) gets their act together. */
12566 ++/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
12568 ++typedef struct
12570 ++ Elf64_Addr r_offset; /* Address */
12571 ++ Elf64_Xword r_info; /* Relocation type and symbol index */
12572 ++} Elf64_Rel;
12574 ++/* Relocation table entry with addend (in section of type SHT_RELA). */
12576 ++typedef struct
12578 ++ Elf32_Addr r_offset; /* Address */
12579 ++ Elf32_Word r_info; /* Relocation type and symbol index */
12580 ++ Elf32_Sword r_addend; /* Addend */
12581 ++} Elf32_Rela;
12583 ++typedef struct
12585 ++ Elf64_Addr r_offset; /* Address */
12586 ++ Elf64_Xword r_info; /* Relocation type and symbol index */
12587 ++ Elf64_Sxword r_addend; /* Addend */
12588 ++} Elf64_Rela;
12590 ++/* How to extract and insert information held in the r_info field. */
12592 ++#define ELF32_R_SYM(val) ((val) >> 8)
12593 ++#define ELF32_R_TYPE(val) ((val) & 0xff)
12594 ++#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
12596 ++#define ELF64_R_SYM(i) ((i) >> 32)
12597 ++#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
12598 ++#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
12600 ++/* Program segment header. */
12602 ++typedef struct
12604 ++ Elf32_Word p_type; /* Segment type */
12605 ++ Elf32_Off p_offset; /* Segment file offset */
12606 ++ Elf32_Addr p_vaddr; /* Segment virtual address */
12607 ++ Elf32_Addr p_paddr; /* Segment physical address */
12608 ++ Elf32_Word p_filesz; /* Segment size in file */
12609 ++ Elf32_Word p_memsz; /* Segment size in memory */
12610 ++ Elf32_Word p_flags; /* Segment flags */
12611 ++ Elf32_Word p_align; /* Segment alignment */
12612 ++} Elf32_Phdr;
12614 ++typedef struct
12616 ++ Elf64_Word p_type; /* Segment type */
12617 ++ Elf64_Word p_flags; /* Segment flags */
12618 ++ Elf64_Off p_offset; /* Segment file offset */
12619 ++ Elf64_Addr p_vaddr; /* Segment virtual address */
12620 ++ Elf64_Addr p_paddr; /* Segment physical address */
12621 ++ Elf64_Xword p_filesz; /* Segment size in file */
12622 ++ Elf64_Xword p_memsz; /* Segment size in memory */
12623 ++ Elf64_Xword p_align; /* Segment alignment */
12624 ++} Elf64_Phdr;
12626 ++/* Special value for e_phnum. This indicates that the real number of
12627 ++ program headers is too large to fit into e_phnum. Instead the real
12628 ++ value is in the field sh_info of section 0. */
12630 ++#define PN_XNUM 0xffff
12632 ++/* Legal values for p_type (segment type). */
12634 ++#define PT_NULL 0 /* Program header table entry unused */
12635 ++#define PT_LOAD 1 /* Loadable program segment */
12636 ++#define PT_DYNAMIC 2 /* Dynamic linking information */
12637 ++#define PT_INTERP 3 /* Program interpreter */
12638 ++#define PT_NOTE 4 /* Auxiliary information */
12639 ++#define PT_SHLIB 5 /* Reserved */
12640 ++#define PT_PHDR 6 /* Entry for header table itself */
12641 ++#define PT_TLS 7 /* Thread-local storage segment */
12642 ++#define PT_NUM 8 /* Number of defined types */
12643 ++#define PT_LOOS 0x60000000 /* Start of OS-specific */
12644 ++#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
12645 ++#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
12646 ++#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
12647 ++#define PT_LOSUNW 0x6ffffffa
12648 ++#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
12649 ++#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
12650 ++#define PT_HISUNW 0x6fffffff
12651 ++#define PT_HIOS 0x6fffffff /* End of OS-specific */
12652 ++#define PT_LOPROC 0x70000000 /* Start of processor-specific */
12653 ++#define PT_HIPROC 0x7fffffff /* End of processor-specific */
12655 ++/* Legal values for p_flags (segment flags). */
12657 ++#define PF_X (1 << 0) /* Segment is executable */
12658 ++#define PF_W (1 << 1) /* Segment is writable */
12659 ++#define PF_R (1 << 2) /* Segment is readable */
12660 ++#define PF_MASKOS 0x0ff00000 /* OS-specific */
12661 ++#define PF_MASKPROC 0xf0000000 /* Processor-specific */
12663 ++/* Legal values for note segment descriptor types for core files. */
12665 ++#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
12666 ++#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
12667 ++#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
12668 ++#define NT_PRXREG 4 /* Contains copy of prxregset struct */
12669 ++#define NT_TASKSTRUCT 4 /* Contains copy of task structure */
12670 ++#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
12671 ++#define NT_AUXV 6 /* Contains copy of auxv array */
12672 ++#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
12673 ++#define NT_ASRS 8 /* Contains copy of asrset struct */
12674 ++#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
12675 ++#define NT_PSINFO 13 /* Contains copy of psinfo struct */
12676 ++#define NT_PRCRED 14 /* Contains copy of prcred struct */
12677 ++#define NT_UTSNAME 15 /* Contains copy of utsname struct */
12678 ++#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
12679 ++#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
12680 ++#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */
12681 ++#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */
12682 ++#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
12683 ++#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
12684 ++#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
12685 ++#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
12686 ++#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
12687 ++#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
12689 ++/* Legal values for the note segment descriptor types for object files. */
12691 ++#define NT_VERSION 1 /* Contains a version string. */
12694 ++/* Dynamic section entry. */
12696 ++typedef struct
12698 ++ Elf32_Sword d_tag; /* Dynamic entry type */
12699 ++ union
12700 ++ {
12701 ++ Elf32_Word d_val; /* Integer value */
12702 ++ Elf32_Addr d_ptr; /* Address value */
12703 ++ } d_un;
12704 ++} Elf32_Dyn;
12706 ++typedef struct
12708 ++ Elf64_Sxword d_tag; /* Dynamic entry type */
12709 ++ union
12710 ++ {
12711 ++ Elf64_Xword d_val; /* Integer value */
12712 ++ Elf64_Addr d_ptr; /* Address value */
12713 ++ } d_un;
12714 ++} Elf64_Dyn;
12716 ++/* Legal values for d_tag (dynamic entry type). */
12718 ++#define DT_NULL 0 /* Marks end of dynamic section */
12719 ++#define DT_NEEDED 1 /* Name of needed library */
12720 ++#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
12721 ++#define DT_PLTGOT 3 /* Processor defined value */
12722 ++#define DT_HASH 4 /* Address of symbol hash table */
12723 ++#define DT_STRTAB 5 /* Address of string table */
12724 ++#define DT_SYMTAB 6 /* Address of symbol table */
12725 ++#define DT_RELA 7 /* Address of Rela relocs */
12726 ++#define DT_RELASZ 8 /* Total size of Rela relocs */
12727 ++#define DT_RELAENT 9 /* Size of one Rela reloc */
12728 ++#define DT_STRSZ 10 /* Size of string table */
12729 ++#define DT_SYMENT 11 /* Size of one symbol table entry */
12730 ++#define DT_INIT 12 /* Address of init function */
12731 ++#define DT_FINI 13 /* Address of termination function */
12732 ++#define DT_SONAME 14 /* Name of shared object */
12733 ++#define DT_RPATH 15 /* Library search path (deprecated) */
12734 ++#define DT_SYMBOLIC 16 /* Start symbol search here */
12735 ++#define DT_REL 17 /* Address of Rel relocs */
12736 ++#define DT_RELSZ 18 /* Total size of Rel relocs */
12737 ++#define DT_RELENT 19 /* Size of one Rel reloc */
12738 ++#define DT_PLTREL 20 /* Type of reloc in PLT */
12739 ++#define DT_DEBUG 21 /* For debugging; unspecified */
12740 ++#define DT_TEXTREL 22 /* Reloc might modify .text */
12741 ++#define DT_JMPREL 23 /* Address of PLT relocs */
12742 ++#define DT_BIND_NOW 24 /* Process relocations of object */
12743 ++#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
12744 ++#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
12745 ++#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
12746 ++#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
12747 ++#define DT_RUNPATH 29 /* Library search path */
12748 ++#define DT_FLAGS 30 /* Flags for the object being loaded */
12749 ++#define DT_ENCODING 32 /* Start of encoded range */
12750 ++#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
12751 ++#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
12752 ++#define DT_NUM 34 /* Number used */
12753 ++#define DT_LOOS 0x6000000d /* Start of OS-specific */
12754 ++#define DT_HIOS 0x6ffff000 /* End of OS-specific */
12755 ++#define DT_LOPROC 0x70000000 /* Start of processor-specific */
12756 ++#define DT_HIPROC 0x7fffffff /* End of processor-specific */
12757 ++#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
12759 ++/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
12760 ++ Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
12761 ++ approach. */
12762 ++#define DT_VALRNGLO 0x6ffffd00
12763 ++#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
12764 ++#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
12765 ++#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
12766 ++#define DT_CHECKSUM 0x6ffffdf8
12767 ++#define DT_PLTPADSZ 0x6ffffdf9
12768 ++#define DT_MOVEENT 0x6ffffdfa
12769 ++#define DT_MOVESZ 0x6ffffdfb
12770 ++#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
12771 ++#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
12772 ++ the following DT_* entry. */
12773 ++#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
12774 ++#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
12775 ++#define DT_VALRNGHI 0x6ffffdff
12776 ++#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
12777 ++#define DT_VALNUM 12
12779 ++/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
12780 ++ Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
12782 ++ If any adjustment is made to the ELF object after it has been
12783 ++ built these entries will need to be adjusted. */
12784 ++#define DT_ADDRRNGLO 0x6ffffe00
12785 ++#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
12786 ++#define DT_TLSDESC_PLT 0x6ffffef6
12787 ++#define DT_TLSDESC_GOT 0x6ffffef7
12788 ++#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
12789 ++#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
12790 ++#define DT_CONFIG 0x6ffffefa /* Configuration information. */
12791 ++#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
12792 ++#define DT_AUDIT 0x6ffffefc /* Object auditing. */
12793 ++#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
12794 ++#define DT_MOVETAB 0x6ffffefe /* Move table. */
12795 ++#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
12796 ++#define DT_ADDRRNGHI 0x6ffffeff
12797 ++#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
12798 ++#define DT_ADDRNUM 11
12800 ++/* The versioning entry types. The next are defined as part of the
12801 ++ GNU extension. */
12802 ++#define DT_VERSYM 0x6ffffff0
12804 ++#define DT_RELACOUNT 0x6ffffff9
12805 ++#define DT_RELCOUNT 0x6ffffffa
12807 ++/* These were chosen by Sun. */
12808 ++#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
12809 ++#define DT_VERDEF 0x6ffffffc /* Address of version definition
12810 ++ table */
12811 ++#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
12812 ++#define DT_VERNEED 0x6ffffffe /* Address of table with needed
12813 ++ versions */
12814 ++#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
12815 ++#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
12816 ++#define DT_VERSIONTAGNUM 16
12818 ++/* Sun added these machine-independent extensions in the "processor-specific"
12819 ++ range. Be compatible. */
12820 ++#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
12821 ++#define DT_FILTER 0x7fffffff /* Shared object to get values from */
12822 ++#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
12823 ++#define DT_EXTRANUM 3
12825 ++/* Values of `d_un.d_val' in the DT_FLAGS entry. */
12826 ++#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
12827 ++#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
12828 ++#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
12829 ++#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
12830 ++#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
12832 ++/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
12833 ++ entry in the dynamic section. */
12834 ++#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
12835 ++#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
12836 ++#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
12837 ++#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
12838 ++#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
12839 ++#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
12840 ++#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
12841 ++#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
12842 ++#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
12843 ++#define DF_1_TRANS 0x00000200
12844 ++#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
12845 ++#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
12846 ++#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
12847 ++#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
12848 ++#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
12849 ++#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
12850 ++#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
12852 ++/* Flags for the feature selection in DT_FEATURE_1. */
12853 ++#define DTF_1_PARINIT 0x00000001
12854 ++#define DTF_1_CONFEXP 0x00000002
12856 ++/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
12857 ++#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
12858 ++#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
12859 ++ generally available. */
12861 ++/* Version definition sections. */
12863 ++typedef struct
12865 ++ Elf32_Half vd_version; /* Version revision */
12866 ++ Elf32_Half vd_flags; /* Version information */
12867 ++ Elf32_Half vd_ndx; /* Version Index */
12868 ++ Elf32_Half vd_cnt; /* Number of associated aux entries */
12869 ++ Elf32_Word vd_hash; /* Version name hash value */
12870 ++ Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
12871 ++ Elf32_Word vd_next; /* Offset in bytes to next verdef
12872 ++ entry */
12873 ++} Elf32_Verdef;
12875 ++typedef struct
12877 ++ Elf64_Half vd_version; /* Version revision */
12878 ++ Elf64_Half vd_flags; /* Version information */
12879 ++ Elf64_Half vd_ndx; /* Version Index */
12880 ++ Elf64_Half vd_cnt; /* Number of associated aux entries */
12881 ++ Elf64_Word vd_hash; /* Version name hash value */
12882 ++ Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
12883 ++ Elf64_Word vd_next; /* Offset in bytes to next verdef
12884 ++ entry */
12885 ++} Elf64_Verdef;
12888 ++/* Legal values for vd_version (version revision). */
12889 ++#define VER_DEF_NONE 0 /* No version */
12890 ++#define VER_DEF_CURRENT 1 /* Current version */
12891 ++#define VER_DEF_NUM 2 /* Given version number */
12893 ++/* Legal values for vd_flags (version information flags). */
12894 ++#define VER_FLG_BASE 0x1 /* Version definition of file itself */
12895 ++#define VER_FLG_WEAK 0x2 /* Weak version identifier */
12897 ++/* Versym symbol index values. */
12898 ++#define VER_NDX_LOCAL 0 /* Symbol is local. */
12899 ++#define VER_NDX_GLOBAL 1 /* Symbol is global. */
12900 ++#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
12901 ++#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
12903 ++/* Auxialiary version information. */
12905 ++typedef struct
12907 ++ Elf32_Word vda_name; /* Version or dependency names */
12908 ++ Elf32_Word vda_next; /* Offset in bytes to next verdaux
12909 ++ entry */
12910 ++} Elf32_Verdaux;
12912 ++typedef struct
12914 ++ Elf64_Word vda_name; /* Version or dependency names */
12915 ++ Elf64_Word vda_next; /* Offset in bytes to next verdaux
12916 ++ entry */
12917 ++} Elf64_Verdaux;
12920 ++/* Version dependency section. */
12922 ++typedef struct
12924 ++ Elf32_Half vn_version; /* Version of structure */
12925 ++ Elf32_Half vn_cnt; /* Number of associated aux entries */
12926 ++ Elf32_Word vn_file; /* Offset of filename for this
12927 ++ dependency */
12928 ++ Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
12929 ++ Elf32_Word vn_next; /* Offset in bytes to next verneed
12930 ++ entry */
12931 ++} Elf32_Verneed;
12933 ++typedef struct
12935 ++ Elf64_Half vn_version; /* Version of structure */
12936 ++ Elf64_Half vn_cnt; /* Number of associated aux entries */
12937 ++ Elf64_Word vn_file; /* Offset of filename for this
12938 ++ dependency */
12939 ++ Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
12940 ++ Elf64_Word vn_next; /* Offset in bytes to next verneed
12941 ++ entry */
12942 ++} Elf64_Verneed;
12945 ++/* Legal values for vn_version (version revision). */
12946 ++#define VER_NEED_NONE 0 /* No version */
12947 ++#define VER_NEED_CURRENT 1 /* Current version */
12948 ++#define VER_NEED_NUM 2 /* Given version number */
12950 ++/* Auxiliary needed version information. */
12952 ++typedef struct
12954 ++ Elf32_Word vna_hash; /* Hash value of dependency name */
12955 ++ Elf32_Half vna_flags; /* Dependency specific information */
12956 ++ Elf32_Half vna_other; /* Unused */
12957 ++ Elf32_Word vna_name; /* Dependency name string offset */
12958 ++ Elf32_Word vna_next; /* Offset in bytes to next vernaux
12959 ++ entry */
12960 ++} Elf32_Vernaux;
12962 ++typedef struct
12964 ++ Elf64_Word vna_hash; /* Hash value of dependency name */
12965 ++ Elf64_Half vna_flags; /* Dependency specific information */
12966 ++ Elf64_Half vna_other; /* Unused */
12967 ++ Elf64_Word vna_name; /* Dependency name string offset */
12968 ++ Elf64_Word vna_next; /* Offset in bytes to next vernaux
12969 ++ entry */
12970 ++} Elf64_Vernaux;
12973 ++/* Legal values for vna_flags. */
12974 ++#define VER_FLG_WEAK 0x2 /* Weak version identifier */
12977 ++/* Auxiliary vector. */
12979 ++/* This vector is normally only used by the program interpreter. The
12980 ++ usual definition in an ABI supplement uses the name auxv_t. The
12981 ++ vector is not usually defined in a standard <elf.h> file, but it
12982 ++ can't hurt. We rename it to avoid conflicts. The sizes of these
12983 ++ types are an arrangement between the exec server and the program
12984 ++ interpreter, so we don't fully specify them here. */
12986 ++typedef struct
12988 ++ uint32_t a_type; /* Entry type */
12989 ++ union
12990 ++ {
12991 ++ uint32_t a_val; /* Integer value */
12992 ++ /* We use to have pointer elements added here. We cannot do that,
12993 ++ though, since it does not work when using 32-bit definitions
12994 ++ on 64-bit platforms and vice versa. */
12995 ++ } a_un;
12996 ++} Elf32_auxv_t;
12998 ++typedef struct
13000 ++ uint64_t a_type; /* Entry type */
13001 ++ union
13002 ++ {
13003 ++ uint64_t a_val; /* Integer value */
13004 ++ /* We use to have pointer elements added here. We cannot do that,
13005 ++ though, since it does not work when using 32-bit definitions
13006 ++ on 64-bit platforms and vice versa. */
13007 ++ } a_un;
13008 ++} Elf64_auxv_t;
13010 ++/* Legal values for a_type (entry type). */
13012 ++#define AT_NULL 0 /* End of vector */
13013 ++#define AT_IGNORE 1 /* Entry should be ignored */
13014 ++#define AT_EXECFD 2 /* File descriptor of program */
13015 ++#define AT_PHDR 3 /* Program headers for program */
13016 ++#define AT_PHENT 4 /* Size of program header entry */
13017 ++#define AT_PHNUM 5 /* Number of program headers */
13018 ++#define AT_PAGESZ 6 /* System page size */
13019 ++#define AT_BASE 7 /* Base address of interpreter */
13020 ++#define AT_FLAGS 8 /* Flags */
13021 ++#define AT_ENTRY 9 /* Entry point of program */
13022 ++#define AT_NOTELF 10 /* Program is not ELF */
13023 ++#define AT_UID 11 /* Real uid */
13024 ++#define AT_EUID 12 /* Effective uid */
13025 ++#define AT_GID 13 /* Real gid */
13026 ++#define AT_EGID 14 /* Effective gid */
13027 ++#define AT_CLKTCK 17 /* Frequency of times() */
13029 ++/* Some more special a_type values describing the hardware. */
13030 ++#define AT_PLATFORM 15 /* String identifying platform. */
13031 ++#define AT_HWCAP 16 /* Machine dependent hints about
13032 ++ processor capabilities. */
13034 ++/* This entry gives some information about the FPU initialization
13035 ++ performed by the kernel. */
13036 ++#define AT_FPUCW 18 /* Used FPU control word. */
13038 ++/* Cache block sizes. */
13039 ++#define AT_DCACHEBSIZE 19 /* Data cache block size. */
13040 ++#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
13041 ++#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
13043 ++/* A special ignored value for PPC, used by the kernel to control the
13044 ++ interpretation of the AUXV. Must be > 16. */
13045 ++#define AT_IGNOREPPC 22 /* Entry should be ignored. */
13047 ++#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
13049 ++#define AT_BASE_PLATFORM 24 /* String identifying real platforms.*/
13051 ++#define AT_RANDOM 25 /* Address of 16 random bytes. */
13053 ++#define AT_EXECFN 31 /* Filename of executable. */
13055 ++/* Pointer to the global system page used for system calls and other
13056 ++ nice things. */
13057 ++#define AT_SYSINFO 32
13058 ++#define AT_SYSINFO_EHDR 33
13060 ++/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains
13061 ++ log2 of line size; mask those to get cache size. */
13062 ++#define AT_L1I_CACHESHAPE 34
13063 ++#define AT_L1D_CACHESHAPE 35
13064 ++#define AT_L2_CACHESHAPE 36
13065 ++#define AT_L3_CACHESHAPE 37
13067 ++/* Note section contents. Each entry in the note section begins with
13068 ++ a header of a fixed form. */
13070 ++typedef struct
13072 ++ Elf32_Word n_namesz; /* Length of the note's name. */
13073 ++ Elf32_Word n_descsz; /* Length of the note's descriptor. */
13074 ++ Elf32_Word n_type; /* Type of the note. */
13075 ++} Elf32_Nhdr;
13077 ++typedef struct
13079 ++ Elf64_Word n_namesz; /* Length of the note's name. */
13080 ++ Elf64_Word n_descsz; /* Length of the note's descriptor. */
13081 ++ Elf64_Word n_type; /* Type of the note. */
13082 ++} Elf64_Nhdr;
13084 ++/* Known names of notes. */
13086 ++/* Solaris entries in the note section have this name. */
13087 ++#define ELF_NOTE_SOLARIS "SUNW Solaris"
13089 ++/* Note entries for GNU systems have this name. */
13090 ++#define ELF_NOTE_GNU "GNU"
13093 ++/* Defined types of notes for Solaris. */
13095 ++/* Value of descriptor (one word) is desired pagesize for the binary. */
13096 ++#define ELF_NOTE_PAGESIZE_HINT 1
13099 ++/* Defined note types for GNU systems. */
13101 ++/* ABI information. The descriptor consists of words:
13102 ++ word 0: OS descriptor
13103 ++ word 1: major version of the ABI
13104 ++ word 2: minor version of the ABI
13105 ++ word 3: subminor version of the ABI
13106 ++*/
13107 ++#define NT_GNU_ABI_TAG 1
13108 ++#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */
13110 ++/* Known OSes. These values can appear in word 0 of an
13111 ++ NT_GNU_ABI_TAG note section entry. */
13112 ++#define ELF_NOTE_OS_LINUX 0
13113 ++#define ELF_NOTE_OS_GNU 1
13114 ++#define ELF_NOTE_OS_SOLARIS2 2
13115 ++#define ELF_NOTE_OS_FREEBSD 3
13117 ++/* Synthetic hwcap information. The descriptor begins with two words:
13118 ++ word 0: number of entries
13119 ++ word 1: bitmask of enabled entries
13120 ++ Then follow variable-length entries, one byte followed by a
13121 ++ '\0'-terminated hwcap name string. The byte gives the bit
13122 ++ number to test if enabled, (1U << bit) & bitmask. */
13123 ++#define NT_GNU_HWCAP 2
13125 ++/* Build ID bits as generated by ld --build-id.
13126 ++ The descriptor consists of any nonzero number of bytes. */
13127 ++#define NT_GNU_BUILD_ID 3
13129 ++/* Version note generated by GNU gold containing a version string. */
13130 ++#define NT_GNU_GOLD_VERSION 4
13133 ++/* Move records. */
13134 ++typedef struct
13136 ++ Elf32_Xword m_value; /* Symbol value. */
13137 ++ Elf32_Word m_info; /* Size and index. */
13138 ++ Elf32_Word m_poffset; /* Symbol offset. */
13139 ++ Elf32_Half m_repeat; /* Repeat count. */
13140 ++ Elf32_Half m_stride; /* Stride info. */
13141 ++} Elf32_Move;
13143 ++typedef struct
13145 ++ Elf64_Xword m_value; /* Symbol value. */
13146 ++ Elf64_Xword m_info; /* Size and index. */
13147 ++ Elf64_Xword m_poffset; /* Symbol offset. */
13148 ++ Elf64_Half m_repeat; /* Repeat count. */
13149 ++ Elf64_Half m_stride; /* Stride info. */
13150 ++} Elf64_Move;
13152 ++/* Macro to construct move records. */
13153 ++#define ELF32_M_SYM(info) ((info) >> 8)
13154 ++#define ELF32_M_SIZE(info) ((unsigned char) (info))
13155 ++#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
13157 ++#define ELF64_M_SYM(info) ELF32_M_SYM (info)
13158 ++#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
13159 ++#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
13162 ++/* Motorola 68k specific definitions. */
13164 ++/* Values for Elf32_Ehdr.e_flags. */
13165 ++#define EF_CPU32 0x00810000
13167 ++/* m68k relocs. */
13169 ++#define R_68K_NONE 0 /* No reloc */
13170 ++#define R_68K_32 1 /* Direct 32 bit */
13171 ++#define R_68K_16 2 /* Direct 16 bit */
13172 ++#define R_68K_8 3 /* Direct 8 bit */
13173 ++#define R_68K_PC32 4 /* PC relative 32 bit */
13174 ++#define R_68K_PC16 5 /* PC relative 16 bit */
13175 ++#define R_68K_PC8 6 /* PC relative 8 bit */
13176 ++#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
13177 ++#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
13178 ++#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
13179 ++#define R_68K_GOT32O 10 /* 32 bit GOT offset */
13180 ++#define R_68K_GOT16O 11 /* 16 bit GOT offset */
13181 ++#define R_68K_GOT8O 12 /* 8 bit GOT offset */
13182 ++#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
13183 ++#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
13184 ++#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
13185 ++#define R_68K_PLT32O 16 /* 32 bit PLT offset */
13186 ++#define R_68K_PLT16O 17 /* 16 bit PLT offset */
13187 ++#define R_68K_PLT8O 18 /* 8 bit PLT offset */
13188 ++#define R_68K_COPY 19 /* Copy symbol at runtime */
13189 ++#define R_68K_GLOB_DAT 20 /* Create GOT entry */
13190 ++#define R_68K_JMP_SLOT 21 /* Create PLT entry */
13191 ++#define R_68K_RELATIVE 22 /* Adjust by program base */
13192 ++#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
13193 ++#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
13194 ++#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
13195 ++#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */
13196 ++#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */
13197 ++#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */
13198 ++#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */
13199 ++#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */
13200 ++#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */
13201 ++#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */
13202 ++#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */
13203 ++#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */
13204 ++#define R_68K_TLS_LE32 37 /* 32 bit offset relative to
13205 ++ static TLS block */
13206 ++#define R_68K_TLS_LE16 38 /* 16 bit offset relative to
13207 ++ static TLS block */
13208 ++#define R_68K_TLS_LE8 39 /* 8 bit offset relative to
13209 ++ static TLS block */
13210 ++#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */
13211 ++#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */
13212 ++#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */
13213 ++/* Keep this the last entry. */
13214 ++#define R_68K_NUM 43
13216 ++/* Intel 80386 specific definitions. */
13218 ++/* i386 relocs. */
13220 ++#define R_386_NONE 0 /* No reloc */
13221 ++#define R_386_32 1 /* Direct 32 bit */
13222 ++#define R_386_PC32 2 /* PC relative 32 bit */
13223 ++#define R_386_GOT32 3 /* 32 bit GOT entry */
13224 ++#define R_386_PLT32 4 /* 32 bit PLT address */
13225 ++#define R_386_COPY 5 /* Copy symbol at runtime */
13226 ++#define R_386_GLOB_DAT 6 /* Create GOT entry */
13227 ++#define R_386_JMP_SLOT 7 /* Create PLT entry */
13228 ++#define R_386_RELATIVE 8 /* Adjust by program base */
13229 ++#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
13230 ++#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
13231 ++#define R_386_32PLT 11
13232 ++#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
13233 ++#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
13234 ++ block offset */
13235 ++#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
13236 ++ offset */
13237 ++#define R_386_TLS_LE 17 /* Offset relative to static TLS
13238 ++ block */
13239 ++#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
13240 ++ general dynamic thread local data */
13241 ++#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
13242 ++ local dynamic thread local data
13243 ++ in LE code */
13244 ++#define R_386_16 20
13245 ++#define R_386_PC16 21
13246 ++#define R_386_8 22
13247 ++#define R_386_PC8 23
13248 ++#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
13249 ++ thread local data */
13250 ++#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
13251 ++#define R_386_TLS_GD_CALL 26 /* Relocation for call to
13252 ++ __tls_get_addr() */
13253 ++#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
13254 ++#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
13255 ++ thread local data in LE code */
13256 ++#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
13257 ++#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
13258 ++ __tls_get_addr() in LDM code */
13259 ++#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
13260 ++#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
13261 ++#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
13262 ++ block offset */
13263 ++#define R_386_TLS_LE_32 34 /* Negated offset relative to static
13264 ++ TLS block */
13265 ++#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
13266 ++#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
13267 ++#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
13268 ++/* 38? */
13269 ++#define R_386_TLS_GOTDESC 39 /* GOT offset for TLS descriptor. */
13270 ++#define R_386_TLS_DESC_CALL 40 /* Marker of call through TLS
13271 ++ descriptor for
13272 ++ relaxation. */
13273 ++#define R_386_TLS_DESC 41 /* TLS descriptor containing
13274 ++ pointer to code and to
13275 ++ argument, returning the TLS
13276 ++ offset for the symbol. */
13277 ++#define R_386_IRELATIVE 42 /* Adjust indirectly by program base */
13278 ++/* Keep this the last entry. */
13279 ++#define R_386_NUM 43
13281 ++/* SUN SPARC specific definitions. */
13283 ++/* Legal values for ST_TYPE subfield of st_info (symbol type). */
13285 ++#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */
13287 ++/* Values for Elf64_Ehdr.e_flags. */
13289 ++#define EF_SPARCV9_MM 3
13290 ++#define EF_SPARCV9_TSO 0
13291 ++#define EF_SPARCV9_PSO 1
13292 ++#define EF_SPARCV9_RMO 2
13293 ++#define EF_SPARC_LEDATA 0x800000 /* little endian data */
13294 ++#define EF_SPARC_EXT_MASK 0xFFFF00
13295 ++#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
13296 ++#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
13297 ++#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
13298 ++#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
13300 ++/* SPARC relocs. */
13302 ++#define R_SPARC_NONE 0 /* No reloc */
13303 ++#define R_SPARC_8 1 /* Direct 8 bit */
13304 ++#define R_SPARC_16 2 /* Direct 16 bit */
13305 ++#define R_SPARC_32 3 /* Direct 32 bit */
13306 ++#define R_SPARC_DISP8 4 /* PC relative 8 bit */
13307 ++#define R_SPARC_DISP16 5 /* PC relative 16 bit */
13308 ++#define R_SPARC_DISP32 6 /* PC relative 32 bit */
13309 ++#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
13310 ++#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
13311 ++#define R_SPARC_HI22 9 /* High 22 bit */
13312 ++#define R_SPARC_22 10 /* Direct 22 bit */
13313 ++#define R_SPARC_13 11 /* Direct 13 bit */
13314 ++#define R_SPARC_LO10 12 /* Truncated 10 bit */
13315 ++#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
13316 ++#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
13317 ++#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
13318 ++#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
13319 ++#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
13320 ++#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
13321 ++#define R_SPARC_COPY 19 /* Copy symbol at runtime */
13322 ++#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
13323 ++#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
13324 ++#define R_SPARC_RELATIVE 22 /* Adjust by program base */
13325 ++#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
13327 ++/* Additional Sparc64 relocs. */
13329 ++#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
13330 ++#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
13331 ++#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
13332 ++#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
13333 ++#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
13334 ++#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
13335 ++#define R_SPARC_10 30 /* Direct 10 bit */
13336 ++#define R_SPARC_11 31 /* Direct 11 bit */
13337 ++#define R_SPARC_64 32 /* Direct 64 bit */
13338 ++#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
13339 ++#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
13340 ++#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
13341 ++#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
13342 ++#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
13343 ++#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
13344 ++#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
13345 ++#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
13346 ++#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
13347 ++#define R_SPARC_GLOB_JMP 42 /* was part of v9 ABI but was removed */
13348 ++#define R_SPARC_7 43 /* Direct 7 bit */
13349 ++#define R_SPARC_5 44 /* Direct 5 bit */
13350 ++#define R_SPARC_6 45 /* Direct 6 bit */
13351 ++#define R_SPARC_DISP64 46 /* PC relative 64 bit */
13352 ++#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
13353 ++#define R_SPARC_HIX22 48 /* High 22 bit complemented */
13354 ++#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
13355 ++#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
13356 ++#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
13357 ++#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
13358 ++#define R_SPARC_REGISTER 53 /* Global register usage */
13359 ++#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
13360 ++#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
13361 ++#define R_SPARC_TLS_GD_HI22 56
13362 ++#define R_SPARC_TLS_GD_LO10 57
13363 ++#define R_SPARC_TLS_GD_ADD 58
13364 ++#define R_SPARC_TLS_GD_CALL 59
13365 ++#define R_SPARC_TLS_LDM_HI22 60
13366 ++#define R_SPARC_TLS_LDM_LO10 61
13367 ++#define R_SPARC_TLS_LDM_ADD 62
13368 ++#define R_SPARC_TLS_LDM_CALL 63
13369 ++#define R_SPARC_TLS_LDO_HIX22 64
13370 ++#define R_SPARC_TLS_LDO_LOX10 65
13371 ++#define R_SPARC_TLS_LDO_ADD 66
13372 ++#define R_SPARC_TLS_IE_HI22 67
13373 ++#define R_SPARC_TLS_IE_LO10 68
13374 ++#define R_SPARC_TLS_IE_LD 69
13375 ++#define R_SPARC_TLS_IE_LDX 70
13376 ++#define R_SPARC_TLS_IE_ADD 71
13377 ++#define R_SPARC_TLS_LE_HIX22 72
13378 ++#define R_SPARC_TLS_LE_LOX10 73
13379 ++#define R_SPARC_TLS_DTPMOD32 74
13380 ++#define R_SPARC_TLS_DTPMOD64 75
13381 ++#define R_SPARC_TLS_DTPOFF32 76
13382 ++#define R_SPARC_TLS_DTPOFF64 77
13383 ++#define R_SPARC_TLS_TPOFF32 78
13384 ++#define R_SPARC_TLS_TPOFF64 79
13385 ++#define R_SPARC_GOTDATA_HIX22 80
13386 ++#define R_SPARC_GOTDATA_LOX10 81
13387 ++#define R_SPARC_GOTDATA_OP_HIX22 82
13388 ++#define R_SPARC_GOTDATA_OP_LOX10 83
13389 ++#define R_SPARC_GOTDATA_OP 84
13390 ++#define R_SPARC_H34 85
13391 ++#define R_SPARC_SIZE32 86
13392 ++#define R_SPARC_SIZE64 87
13393 ++#define R_SPARC_WDISP10 88
13394 ++#define R_SPARC_JMP_IREL 248
13395 ++#define R_SPARC_IRELATIVE 249
13396 ++#define R_SPARC_GNU_VTINHERIT 250
13397 ++#define R_SPARC_GNU_VTENTRY 251
13398 ++#define R_SPARC_REV32 252
13399 ++/* Keep this the last entry. */
13400 ++#define R_SPARC_NUM 253
13402 ++/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
13404 ++#define DT_SPARC_REGISTER 0x70000001
13405 ++#define DT_SPARC_NUM 2
13407 ++/* MIPS R3000 specific definitions. */
13409 ++/* Legal values for e_flags field of Elf32_Ehdr. */
13411 ++#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */
13412 ++#define EF_MIPS_PIC 2 /* Contains PIC code */
13413 ++#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */
13414 ++#define EF_MIPS_XGOT 8
13415 ++#define EF_MIPS_64BIT_WHIRL 16
13416 ++#define EF_MIPS_ABI2 32
13417 ++#define EF_MIPS_ABI_ON32 64
13418 ++#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
13420 ++/* Legal values for MIPS architecture level. */
13422 ++#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
13423 ++#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
13424 ++#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
13425 ++#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
13426 ++#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
13427 ++#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
13428 ++#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
13430 ++/* The following are non-official names and should not be used. */
13432 ++#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
13433 ++#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
13434 ++#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
13435 ++#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
13436 ++#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
13437 ++#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
13438 ++#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
13440 ++/* Special section indices. */
13442 ++#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
13443 ++#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
13444 ++#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
13445 ++#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
13446 ++#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
13448 ++/* Legal values for sh_type field of Elf32_Shdr. */
13450 ++#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
13451 ++#define SHT_MIPS_MSYM 0x70000001
13452 ++#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
13453 ++#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
13454 ++#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
13455 ++#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/
13456 ++#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
13457 ++#define SHT_MIPS_PACKAGE 0x70000007
13458 ++#define SHT_MIPS_PACKSYM 0x70000008
13459 ++#define SHT_MIPS_RELD 0x70000009
13460 ++#define SHT_MIPS_IFACE 0x7000000b
13461 ++#define SHT_MIPS_CONTENT 0x7000000c
13462 ++#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
13463 ++#define SHT_MIPS_SHDR 0x70000010
13464 ++#define SHT_MIPS_FDESC 0x70000011
13465 ++#define SHT_MIPS_EXTSYM 0x70000012
13466 ++#define SHT_MIPS_DENSE 0x70000013
13467 ++#define SHT_MIPS_PDESC 0x70000014
13468 ++#define SHT_MIPS_LOCSYM 0x70000015
13469 ++#define SHT_MIPS_AUXSYM 0x70000016
13470 ++#define SHT_MIPS_OPTSYM 0x70000017
13471 ++#define SHT_MIPS_LOCSTR 0x70000018
13472 ++#define SHT_MIPS_LINE 0x70000019
13473 ++#define SHT_MIPS_RFDESC 0x7000001a
13474 ++#define SHT_MIPS_DELTASYM 0x7000001b
13475 ++#define SHT_MIPS_DELTAINST 0x7000001c
13476 ++#define SHT_MIPS_DELTACLASS 0x7000001d
13477 ++#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
13478 ++#define SHT_MIPS_DELTADECL 0x7000001f
13479 ++#define SHT_MIPS_SYMBOL_LIB 0x70000020
13480 ++#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
13481 ++#define SHT_MIPS_TRANSLATE 0x70000022
13482 ++#define SHT_MIPS_PIXIE 0x70000023
13483 ++#define SHT_MIPS_XLATE 0x70000024
13484 ++#define SHT_MIPS_XLATE_DEBUG 0x70000025
13485 ++#define SHT_MIPS_WHIRL 0x70000026
13486 ++#define SHT_MIPS_EH_REGION 0x70000027
13487 ++#define SHT_MIPS_XLATE_OLD 0x70000028
13488 ++#define SHT_MIPS_PDR_EXCEPTION 0x70000029
13490 ++/* Legal values for sh_flags field of Elf32_Shdr. */
13492 ++#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
13493 ++#define SHF_MIPS_MERGE 0x20000000
13494 ++#define SHF_MIPS_ADDR 0x40000000
13495 ++#define SHF_MIPS_STRINGS 0x80000000
13496 ++#define SHF_MIPS_NOSTRIP 0x08000000
13497 ++#define SHF_MIPS_LOCAL 0x04000000
13498 ++#define SHF_MIPS_NAMES 0x02000000
13499 ++#define SHF_MIPS_NODUPE 0x01000000
13502 ++/* Symbol tables. */
13504 ++/* MIPS specific values for `st_other'. */
13505 ++#define STO_MIPS_DEFAULT 0x0
13506 ++#define STO_MIPS_INTERNAL 0x1
13507 ++#define STO_MIPS_HIDDEN 0x2
13508 ++#define STO_MIPS_PROTECTED 0x3
13509 ++#define STO_MIPS_PLT 0x8
13510 ++#define STO_MIPS_SC_ALIGN_UNUSED 0xff
13512 ++/* MIPS specific values for `st_info'. */
13513 ++#define STB_MIPS_SPLIT_COMMON 13
13515 ++/* Entries found in sections of type SHT_MIPS_GPTAB. */
13517 ++typedef union
13519 ++ struct
13520 ++ {
13521 ++ Elf32_Word gt_current_g_value; /* -G value used for compilation */
13522 ++ Elf32_Word gt_unused; /* Not used */
13523 ++ } gt_header; /* First entry in section */
13524 ++ struct
13525 ++ {
13526 ++ Elf32_Word gt_g_value; /* If this value were used for -G */
13527 ++ Elf32_Word gt_bytes; /* This many bytes would be used */
13528 ++ } gt_entry; /* Subsequent entries in section */
13529 ++} Elf32_gptab;
13531 ++/* Entry found in sections of type SHT_MIPS_REGINFO. */
13533 ++typedef struct
13535 ++ Elf32_Word ri_gprmask; /* General registers used */
13536 ++ Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
13537 ++ Elf32_Sword ri_gp_value; /* $gp register value */
13538 ++} Elf32_RegInfo;
13540 ++/* Entries found in sections of type SHT_MIPS_OPTIONS. */
13542 ++typedef struct
13544 ++ unsigned char kind; /* Determines interpretation of the
13545 ++ variable part of descriptor. */
13546 ++ unsigned char size; /* Size of descriptor, including header. */
13547 ++ Elf32_Section section; /* Section header index of section affected,
13548 ++ 0 for global options. */
13549 ++ Elf32_Word info; /* Kind-specific information. */
13550 ++} Elf_Options;
13552 ++/* Values for `kind' field in Elf_Options. */
13554 ++#define ODK_NULL 0 /* Undefined. */
13555 ++#define ODK_REGINFO 1 /* Register usage information. */
13556 ++#define ODK_EXCEPTIONS 2 /* Exception processing options. */
13557 ++#define ODK_PAD 3 /* Section padding options. */
13558 ++#define ODK_HWPATCH 4 /* Hardware workarounds performed */
13559 ++#define ODK_FILL 5 /* record the fill value used by the linker. */
13560 ++#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
13561 ++#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
13562 ++#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
13564 ++/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
13566 ++#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
13567 ++#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
13568 ++#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
13569 ++#define OEX_SMM 0x20000 /* Force sequential memory mode? */
13570 ++#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
13571 ++#define OEX_PRECISEFP OEX_FPDBUG
13572 ++#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
13574 ++#define OEX_FPU_INVAL 0x10
13575 ++#define OEX_FPU_DIV0 0x08
13576 ++#define OEX_FPU_OFLO 0x04
13577 ++#define OEX_FPU_UFLO 0x02
13578 ++#define OEX_FPU_INEX 0x01
13580 ++/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
13582 ++#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
13583 ++#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
13584 ++#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
13585 ++#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
13587 ++#define OPAD_PREFIX 0x1
13588 ++#define OPAD_POSTFIX 0x2
13589 ++#define OPAD_SYMBOL 0x4
13591 ++/* Entry found in `.options' section. */
13593 ++typedef struct
13595 ++ Elf32_Word hwp_flags1; /* Extra flags. */
13596 ++ Elf32_Word hwp_flags2; /* Extra flags. */
13597 ++} Elf_Options_Hw;
13599 ++/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
13601 ++#define OHWA0_R4KEOP_CHECKED 0x00000001
13602 ++#define OHWA1_R4KEOP_CLEAN 0x00000002
13604 ++/* MIPS relocs. */
13606 ++#define R_MIPS_NONE 0 /* No reloc */
13607 ++#define R_MIPS_16 1 /* Direct 16 bit */
13608 ++#define R_MIPS_32 2 /* Direct 32 bit */
13609 ++#define R_MIPS_REL32 3 /* PC relative 32 bit */
13610 ++#define R_MIPS_26 4 /* Direct 26 bit shifted */
13611 ++#define R_MIPS_HI16 5 /* High 16 bit */
13612 ++#define R_MIPS_LO16 6 /* Low 16 bit */
13613 ++#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
13614 ++#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
13615 ++#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
13616 ++#define R_MIPS_PC16 10 /* PC relative 16 bit */
13617 ++#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
13618 ++#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
13620 ++#define R_MIPS_SHIFT5 16
13621 ++#define R_MIPS_SHIFT6 17
13622 ++#define R_MIPS_64 18
13623 ++#define R_MIPS_GOT_DISP 19
13624 ++#define R_MIPS_GOT_PAGE 20
13625 ++#define R_MIPS_GOT_OFST 21
13626 ++#define R_MIPS_GOT_HI16 22
13627 ++#define R_MIPS_GOT_LO16 23
13628 ++#define R_MIPS_SUB 24
13629 ++#define R_MIPS_INSERT_A 25
13630 ++#define R_MIPS_INSERT_B 26
13631 ++#define R_MIPS_DELETE 27
13632 ++#define R_MIPS_HIGHER 28
13633 ++#define R_MIPS_HIGHEST 29
13634 ++#define R_MIPS_CALL_HI16 30
13635 ++#define R_MIPS_CALL_LO16 31
13636 ++#define R_MIPS_SCN_DISP 32
13637 ++#define R_MIPS_REL16 33
13638 ++#define R_MIPS_ADD_IMMEDIATE 34
13639 ++#define R_MIPS_PJUMP 35
13640 ++#define R_MIPS_RELGOT 36
13641 ++#define R_MIPS_JALR 37
13642 ++#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */
13643 ++#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */
13644 ++#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */
13645 ++#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */
13646 ++#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */
13647 ++#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */
13648 ++#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */
13649 ++#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */
13650 ++#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */
13651 ++#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */
13652 ++#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */
13653 ++#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
13654 ++#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
13655 ++#define R_MIPS_GLOB_DAT 51
13656 ++#define R_MIPS_COPY 126
13657 ++#define R_MIPS_JUMP_SLOT 127
13658 ++/* Keep this the last entry. */
13659 ++#define R_MIPS_NUM 128
13661 ++/* Legal values for p_type field of Elf32_Phdr. */
13663 ++#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
13664 ++#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
13665 ++#define PT_MIPS_OPTIONS 0x70000002
13667 ++/* Special program header types. */
13669 ++#define PF_MIPS_LOCAL 0x10000000
13671 ++/* Legal values for d_tag field of Elf32_Dyn. */
13673 ++#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
13674 ++#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
13675 ++#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
13676 ++#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
13677 ++#define DT_MIPS_FLAGS 0x70000005 /* Flags */
13678 ++#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
13679 ++#define DT_MIPS_MSYM 0x70000007
13680 ++#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
13681 ++#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
13682 ++#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
13683 ++#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
13684 ++#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
13685 ++#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
13686 ++#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
13687 ++#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
13688 ++#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
13689 ++#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
13690 ++#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
13691 ++#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
13692 ++ DT_MIPS_DELTA_CLASS. */
13693 ++#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
13694 ++#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
13695 ++ DT_MIPS_DELTA_INSTANCE. */
13696 ++#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
13697 ++#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
13698 ++ DT_MIPS_DELTA_RELOC. */
13699 ++#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
13700 ++ relocations refer to. */
13701 ++#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
13702 ++ DT_MIPS_DELTA_SYM. */
13703 ++#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
13704 ++ class declaration. */
13705 ++#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
13706 ++ DT_MIPS_DELTA_CLASSSYM. */
13707 ++#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
13708 ++#define DT_MIPS_PIXIE_INIT 0x70000023
13709 ++#define DT_MIPS_SYMBOL_LIB 0x70000024
13710 ++#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
13711 ++#define DT_MIPS_LOCAL_GOTIDX 0x70000026
13712 ++#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
13713 ++#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
13714 ++#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
13715 ++#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
13716 ++#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
13717 ++#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
13718 ++#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
13719 ++ function stored in GOT. */
13720 ++#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
13721 ++ by rld on dlopen() calls. */
13722 ++#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
13723 ++#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
13724 ++#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
13725 ++/* The address of .got.plt in an executable using the new non-PIC ABI. */
13726 ++#define DT_MIPS_PLTGOT 0x70000032
13727 ++/* The base of the PLT in an executable using the new non-PIC ABI if that
13728 ++ PLT is writable. For a non-writable PLT, this is omitted or has a zero
13729 ++ value. */
13730 ++#define DT_MIPS_RWPLT 0x70000034
13731 ++#define DT_MIPS_NUM 0x35
13733 ++/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
13735 ++#define RHF_NONE 0 /* No flags */
13736 ++#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
13737 ++#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
13738 ++#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
13739 ++#define RHF_NO_MOVE (1 << 3)
13740 ++#define RHF_SGI_ONLY (1 << 4)
13741 ++#define RHF_GUARANTEE_INIT (1 << 5)
13742 ++#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
13743 ++#define RHF_GUARANTEE_START_INIT (1 << 7)
13744 ++#define RHF_PIXIE (1 << 8)
13745 ++#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
13746 ++#define RHF_REQUICKSTART (1 << 10)
13747 ++#define RHF_REQUICKSTARTED (1 << 11)
13748 ++#define RHF_CORD (1 << 12)
13749 ++#define RHF_NO_UNRES_UNDEF (1 << 13)
13750 ++#define RHF_RLD_ORDER_SAFE (1 << 14)
13752 ++/* Entries found in sections of type SHT_MIPS_LIBLIST. */
13754 ++typedef struct
13756 ++ Elf32_Word l_name; /* Name (string table index) */
13757 ++ Elf32_Word l_time_stamp; /* Timestamp */
13758 ++ Elf32_Word l_checksum; /* Checksum */
13759 ++ Elf32_Word l_version; /* Interface version */
13760 ++ Elf32_Word l_flags; /* Flags */
13761 ++} Elf32_Lib;
13763 ++typedef struct
13765 ++ Elf64_Word l_name; /* Name (string table index) */
13766 ++ Elf64_Word l_time_stamp; /* Timestamp */
13767 ++ Elf64_Word l_checksum; /* Checksum */
13768 ++ Elf64_Word l_version; /* Interface version */
13769 ++ Elf64_Word l_flags; /* Flags */
13770 ++} Elf64_Lib;
13773 ++/* Legal values for l_flags. */
13775 ++#define LL_NONE 0
13776 ++#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
13777 ++#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
13778 ++#define LL_REQUIRE_MINOR (1 << 2)
13779 ++#define LL_EXPORTS (1 << 3)
13780 ++#define LL_DELAY_LOAD (1 << 4)
13781 ++#define LL_DELTA (1 << 5)
13783 ++/* Entries found in sections of type SHT_MIPS_CONFLICT. */
13785 ++typedef Elf32_Addr Elf32_Conflict;
13788 ++/* HPPA specific definitions. */
13790 ++/* Legal values for e_flags field of Elf32_Ehdr. */
13792 ++#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
13793 ++#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
13794 ++#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
13795 ++#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
13796 ++#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
13797 ++ prediction. */
13798 ++#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
13799 ++#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
13801 ++/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
13803 ++#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
13804 ++#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
13805 ++#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
13807 ++/* Additional section indeces. */
13809 ++#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
13810 ++ symbols in ANSI C. */
13811 ++#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
13813 ++/* Legal values for sh_type field of Elf32_Shdr. */
13815 ++#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
13816 ++#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
13817 ++#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
13819 ++/* Legal values for sh_flags field of Elf32_Shdr. */
13821 ++#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
13822 ++#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
13823 ++#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
13825 ++/* Legal values for ST_TYPE subfield of st_info (symbol type). */
13827 ++#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
13829 ++#define STT_HP_OPAQUE (STT_LOOS + 0x1)
13830 ++#define STT_HP_STUB (STT_LOOS + 0x2)
13832 ++/* HPPA relocs. */
13834 ++#define R_PARISC_NONE 0 /* No reloc. */
13835 ++#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
13836 ++#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
13837 ++#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
13838 ++#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
13839 ++#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
13840 ++#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
13841 ++#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
13842 ++#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
13843 ++#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
13844 ++#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
13845 ++#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
13846 ++#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
13847 ++#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
13848 ++#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
13849 ++#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
13850 ++#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
13851 ++#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
13852 ++#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
13853 ++#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
13854 ++#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
13855 ++#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
13856 ++#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
13857 ++#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
13858 ++#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
13859 ++#define R_PARISC_FPTR64 64 /* 64 bits function address. */
13860 ++#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
13861 ++#define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
13862 ++#define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
13863 ++#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
13864 ++#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
13865 ++#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
13866 ++#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
13867 ++#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
13868 ++#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
13869 ++#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
13870 ++#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
13871 ++#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
13872 ++#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
13873 ++#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
13874 ++#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
13875 ++#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
13876 ++#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
13877 ++#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
13878 ++#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
13879 ++#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
13880 ++#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
13881 ++#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
13882 ++#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
13883 ++#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
13884 ++#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
13885 ++#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
13886 ++#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
13887 ++#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
13888 ++#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
13889 ++#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
13890 ++#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
13891 ++#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
13892 ++#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
13893 ++#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
13894 ++#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
13895 ++#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
13896 ++#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
13897 ++#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
13898 ++#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
13899 ++#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
13900 ++#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
13901 ++#define R_PARISC_LORESERVE 128
13902 ++#define R_PARISC_COPY 128 /* Copy relocation. */
13903 ++#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
13904 ++#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
13905 ++#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
13906 ++#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
13907 ++#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
13908 ++#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
13909 ++#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
13910 ++#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
13911 ++#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
13912 ++#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
13913 ++#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
13914 ++#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
13915 ++#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
13916 ++#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
13917 ++#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
13918 ++#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
13919 ++#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
13920 ++#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
13921 ++#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
13922 ++#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
13923 ++#define R_PARISC_GNU_VTENTRY 232
13924 ++#define R_PARISC_GNU_VTINHERIT 233
13925 ++#define R_PARISC_TLS_GD21L 234 /* GD 21-bit left. */
13926 ++#define R_PARISC_TLS_GD14R 235 /* GD 14-bit right. */
13927 ++#define R_PARISC_TLS_GDCALL 236 /* GD call to __t_g_a. */
13928 ++#define R_PARISC_TLS_LDM21L 237 /* LD module 21-bit left. */
13929 ++#define R_PARISC_TLS_LDM14R 238 /* LD module 14-bit right. */
13930 ++#define R_PARISC_TLS_LDMCALL 239 /* LD module call to __t_g_a. */
13931 ++#define R_PARISC_TLS_LDO21L 240 /* LD offset 21-bit left. */
13932 ++#define R_PARISC_TLS_LDO14R 241 /* LD offset 14-bit right. */
13933 ++#define R_PARISC_TLS_DTPMOD32 242 /* DTP module 32-bit. */
13934 ++#define R_PARISC_TLS_DTPMOD64 243 /* DTP module 64-bit. */
13935 ++#define R_PARISC_TLS_DTPOFF32 244 /* DTP offset 32-bit. */
13936 ++#define R_PARISC_TLS_DTPOFF64 245 /* DTP offset 32-bit. */
13937 ++#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L
13938 ++#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R
13939 ++#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L
13940 ++#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R
13941 ++#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32
13942 ++#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64
13943 ++#define R_PARISC_HIRESERVE 255
13945 ++/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
13947 ++#define PT_HP_TLS (PT_LOOS + 0x0)
13948 ++#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
13949 ++#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
13950 ++#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
13951 ++#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
13952 ++#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
13953 ++#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
13954 ++#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
13955 ++#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
13956 ++#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
13957 ++#define PT_HP_PARALLEL (PT_LOOS + 0x10)
13958 ++#define PT_HP_FASTBIND (PT_LOOS + 0x11)
13959 ++#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
13960 ++#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
13961 ++#define PT_HP_STACK (PT_LOOS + 0x14)
13963 ++#define PT_PARISC_ARCHEXT 0x70000000
13964 ++#define PT_PARISC_UNWIND 0x70000001
13966 ++/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
13968 ++#define PF_PARISC_SBP 0x08000000
13970 ++#define PF_HP_PAGE_SIZE 0x00100000
13971 ++#define PF_HP_FAR_SHARED 0x00200000
13972 ++#define PF_HP_NEAR_SHARED 0x00400000
13973 ++#define PF_HP_CODE 0x01000000
13974 ++#define PF_HP_MODIFY 0x02000000
13975 ++#define PF_HP_LAZYSWAP 0x04000000
13976 ++#define PF_HP_SBP 0x08000000
13979 ++/* Alpha specific definitions. */
13981 ++/* Legal values for e_flags field of Elf64_Ehdr. */
13983 ++#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
13984 ++#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
13986 ++/* Legal values for sh_type field of Elf64_Shdr. */
13988 ++/* These two are primerily concerned with ECOFF debugging info. */
13989 ++#define SHT_ALPHA_DEBUG 0x70000001
13990 ++#define SHT_ALPHA_REGINFO 0x70000002
13992 ++/* Legal values for sh_flags field of Elf64_Shdr. */
13994 ++#define SHF_ALPHA_GPREL 0x10000000
13996 ++/* Legal values for st_other field of Elf64_Sym. */
13997 ++#define STO_ALPHA_NOPV 0x80 /* No PV required. */
13998 ++#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
14000 ++/* Alpha relocs. */
14002 ++#define R_ALPHA_NONE 0 /* No reloc */
14003 ++#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
14004 ++#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
14005 ++#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
14006 ++#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
14007 ++#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
14008 ++#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
14009 ++#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
14010 ++#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
14011 ++#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
14012 ++#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
14013 ++#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
14014 ++#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
14015 ++#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
14016 ++#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */
14017 ++#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
14018 ++#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
14019 ++#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
14020 ++#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
14021 ++#define R_ALPHA_TLS_GD_HI 28
14022 ++#define R_ALPHA_TLSGD 29
14023 ++#define R_ALPHA_TLS_LDM 30
14024 ++#define R_ALPHA_DTPMOD64 31
14025 ++#define R_ALPHA_GOTDTPREL 32
14026 ++#define R_ALPHA_DTPREL64 33
14027 ++#define R_ALPHA_DTPRELHI 34
14028 ++#define R_ALPHA_DTPRELLO 35
14029 ++#define R_ALPHA_DTPREL16 36
14030 ++#define R_ALPHA_GOTTPREL 37
14031 ++#define R_ALPHA_TPREL64 38
14032 ++#define R_ALPHA_TPRELHI 39
14033 ++#define R_ALPHA_TPRELLO 40
14034 ++#define R_ALPHA_TPREL16 41
14035 ++/* Keep this the last entry. */
14036 ++#define R_ALPHA_NUM 46
14038 ++/* Magic values of the LITUSE relocation addend. */
14039 ++#define LITUSE_ALPHA_ADDR 0
14040 ++#define LITUSE_ALPHA_BASE 1
14041 ++#define LITUSE_ALPHA_BYTOFF 2
14042 ++#define LITUSE_ALPHA_JSR 3
14043 ++#define LITUSE_ALPHA_TLS_GD 4
14044 ++#define LITUSE_ALPHA_TLS_LDM 5
14046 ++/* Legal values for d_tag of Elf64_Dyn. */
14047 ++#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
14048 ++#define DT_ALPHA_NUM 1
14050 ++/* PowerPC specific declarations */
14052 ++/* Values for Elf32/64_Ehdr.e_flags. */
14053 ++#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
14055 ++/* Cygnus local bits below */
14056 ++#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
14057 ++#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
14058 ++ flag */
14060 ++/* PowerPC relocations defined by the ABIs */
14061 ++#define R_PPC_NONE 0
14062 ++#define R_PPC_ADDR32 1 /* 32bit absolute address */
14063 ++#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
14064 ++#define R_PPC_ADDR16 3 /* 16bit absolute address */
14065 ++#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
14066 ++#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
14067 ++#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
14068 ++#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
14069 ++#define R_PPC_ADDR14_BRTAKEN 8
14070 ++#define R_PPC_ADDR14_BRNTAKEN 9
14071 ++#define R_PPC_REL24 10 /* PC relative 26 bit */
14072 ++#define R_PPC_REL14 11 /* PC relative 16 bit */
14073 ++#define R_PPC_REL14_BRTAKEN 12
14074 ++#define R_PPC_REL14_BRNTAKEN 13
14075 ++#define R_PPC_GOT16 14
14076 ++#define R_PPC_GOT16_LO 15
14077 ++#define R_PPC_GOT16_HI 16
14078 ++#define R_PPC_GOT16_HA 17
14079 ++#define R_PPC_PLTREL24 18
14080 ++#define R_PPC_COPY 19
14081 ++#define R_PPC_GLOB_DAT 20
14082 ++#define R_PPC_JMP_SLOT 21
14083 ++#define R_PPC_RELATIVE 22
14084 ++#define R_PPC_LOCAL24PC 23
14085 ++#define R_PPC_UADDR32 24
14086 ++#define R_PPC_UADDR16 25
14087 ++#define R_PPC_REL32 26
14088 ++#define R_PPC_PLT32 27
14089 ++#define R_PPC_PLTREL32 28
14090 ++#define R_PPC_PLT16_LO 29
14091 ++#define R_PPC_PLT16_HI 30
14092 ++#define R_PPC_PLT16_HA 31
14093 ++#define R_PPC_SDAREL16 32
14094 ++#define R_PPC_SECTOFF 33
14095 ++#define R_PPC_SECTOFF_LO 34
14096 ++#define R_PPC_SECTOFF_HI 35
14097 ++#define R_PPC_SECTOFF_HA 36
14099 ++/* PowerPC relocations defined for the TLS access ABI. */
14100 ++#define R_PPC_TLS 67 /* none (sym+add)@tls */
14101 ++#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */
14102 ++#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */
14103 ++#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
14104 ++#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
14105 ++#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
14106 ++#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */
14107 ++#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */
14108 ++#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
14109 ++#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
14110 ++#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
14111 ++#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */
14112 ++#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
14113 ++#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
14114 ++#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
14115 ++#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
14116 ++#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
14117 ++#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
14118 ++#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
14119 ++#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
14120 ++#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */
14121 ++#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */
14122 ++#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
14123 ++#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
14124 ++#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */
14125 ++#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */
14126 ++#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */
14127 ++#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */
14129 ++/* The remaining relocs are from the Embedded ELF ABI, and are not
14130 ++ in the SVR4 ELF ABI. */
14131 ++#define R_PPC_EMB_NADDR32 101
14132 ++#define R_PPC_EMB_NADDR16 102
14133 ++#define R_PPC_EMB_NADDR16_LO 103
14134 ++#define R_PPC_EMB_NADDR16_HI 104
14135 ++#define R_PPC_EMB_NADDR16_HA 105
14136 ++#define R_PPC_EMB_SDAI16 106
14137 ++#define R_PPC_EMB_SDA2I16 107
14138 ++#define R_PPC_EMB_SDA2REL 108
14139 ++#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
14140 ++#define R_PPC_EMB_MRKREF 110
14141 ++#define R_PPC_EMB_RELSEC16 111
14142 ++#define R_PPC_EMB_RELST_LO 112
14143 ++#define R_PPC_EMB_RELST_HI 113
14144 ++#define R_PPC_EMB_RELST_HA 114
14145 ++#define R_PPC_EMB_BIT_FLD 115
14146 ++#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
14148 ++/* Diab tool relocations. */
14149 ++#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
14150 ++#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
14151 ++#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
14152 ++#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
14153 ++#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
14154 ++#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
14156 ++/* GNU extension to support local ifunc. */
14157 ++#define R_PPC_IRELATIVE 248
14159 ++/* GNU relocs used in PIC code sequences. */
14160 ++#define R_PPC_REL16 249 /* half16 (sym+add-.) */
14161 ++#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */
14162 ++#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */
14163 ++#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */
14165 ++/* This is a phony reloc to handle any old fashioned TOC16 references
14166 ++ that may still be in object files. */
14167 ++#define R_PPC_TOC16 255
14169 ++/* PowerPC specific values for the Dyn d_tag field. */
14170 ++#define DT_PPC_GOT (DT_LOPROC + 0)
14171 ++#define DT_PPC_NUM 1
14173 ++/* PowerPC64 relocations defined by the ABIs */
14174 ++#define R_PPC64_NONE R_PPC_NONE
14175 ++#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */
14176 ++#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */
14177 ++#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */
14178 ++#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */
14179 ++#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */
14180 ++#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
14181 ++#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */
14182 ++#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
14183 ++#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
14184 ++#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
14185 ++#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */
14186 ++#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
14187 ++#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
14188 ++#define R_PPC64_GOT16 R_PPC_GOT16
14189 ++#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
14190 ++#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
14191 ++#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
14193 ++#define R_PPC64_COPY R_PPC_COPY
14194 ++#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
14195 ++#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
14196 ++#define R_PPC64_RELATIVE R_PPC_RELATIVE
14198 ++#define R_PPC64_UADDR32 R_PPC_UADDR32
14199 ++#define R_PPC64_UADDR16 R_PPC_UADDR16
14200 ++#define R_PPC64_REL32 R_PPC_REL32
14201 ++#define R_PPC64_PLT32 R_PPC_PLT32
14202 ++#define R_PPC64_PLTREL32 R_PPC_PLTREL32
14203 ++#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
14204 ++#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
14205 ++#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
14207 ++#define R_PPC64_SECTOFF R_PPC_SECTOFF
14208 ++#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
14209 ++#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
14210 ++#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
14211 ++#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */
14212 ++#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
14213 ++#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */
14214 ++#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */
14215 ++#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */
14216 ++#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */
14217 ++#define R_PPC64_UADDR64 43 /* doubleword64 S + A */
14218 ++#define R_PPC64_REL64 44 /* doubleword64 S + A - P */
14219 ++#define R_PPC64_PLT64 45 /* doubleword64 L + A */
14220 ++#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */
14221 ++#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */
14222 ++#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */
14223 ++#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */
14224 ++#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */
14225 ++#define R_PPC64_TOC 51 /* doubleword64 .TOC */
14226 ++#define R_PPC64_PLTGOT16 52 /* half16* M + A */
14227 ++#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */
14228 ++#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */
14229 ++#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */
14231 ++#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */
14232 ++#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */
14233 ++#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */
14234 ++#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */
14235 ++#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */
14236 ++#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */
14237 ++#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */
14238 ++#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */
14239 ++#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */
14240 ++#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */
14241 ++#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */
14243 ++/* PowerPC64 relocations defined for the TLS access ABI. */
14244 ++#define R_PPC64_TLS 67 /* none (sym+add)@tls */
14245 ++#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */
14246 ++#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */
14247 ++#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
14248 ++#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
14249 ++#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
14250 ++#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */
14251 ++#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */
14252 ++#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
14253 ++#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
14254 ++#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
14255 ++#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */
14256 ++#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
14257 ++#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
14258 ++#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
14259 ++#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
14260 ++#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
14261 ++#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
14262 ++#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
14263 ++#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
14264 ++#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
14265 ++#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
14266 ++#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
14267 ++#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
14268 ++#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */
14269 ++#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
14270 ++#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */
14271 ++#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */
14272 ++#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */
14273 ++#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */
14274 ++#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */
14275 ++#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */
14276 ++#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */
14277 ++#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
14278 ++#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */
14279 ++#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
14280 ++#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */
14281 ++#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
14282 ++#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
14283 ++#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
14285 ++/* GNU extension to support local ifunc. */
14286 ++#define R_PPC64_JMP_IREL 247
14287 ++#define R_PPC64_IRELATIVE 248
14288 ++#define R_PPC64_REL16 249 /* half16 (sym+add-.) */
14289 ++#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */
14290 ++#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */
14291 ++#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */
14293 ++/* PowerPC64 specific values for the Dyn d_tag field. */
14294 ++#define DT_PPC64_GLINK (DT_LOPROC + 0)
14295 ++#define DT_PPC64_OPD (DT_LOPROC + 1)
14296 ++#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
14297 ++#define DT_PPC64_NUM 3
14300 ++/* ARM specific declarations */
14302 ++/* Processor specific flags for the ELF header e_flags field. */
14303 ++#define EF_ARM_RELEXEC 0x01
14304 ++#define EF_ARM_HASENTRY 0x02
14305 ++#define EF_ARM_INTERWORK 0x04
14306 ++#define EF_ARM_APCS_26 0x08
14307 ++#define EF_ARM_APCS_FLOAT 0x10
14308 ++#define EF_ARM_PIC 0x20
14309 ++#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
14310 ++#define EF_ARM_NEW_ABI 0x80
14311 ++#define EF_ARM_OLD_ABI 0x100
14312 ++#define EF_ARM_SOFT_FLOAT 0x200
14313 ++#define EF_ARM_VFP_FLOAT 0x400
14314 ++#define EF_ARM_MAVERICK_FLOAT 0x800
14317 ++/* Other constants defined in the ARM ELF spec. version B-01. */
14318 ++/* NB. These conflict with values defined above. */
14319 ++#define EF_ARM_SYMSARESORTED 0x04
14320 ++#define EF_ARM_DYNSYMSUSESEGIDX 0x08
14321 ++#define EF_ARM_MAPSYMSFIRST 0x10
14322 ++#define EF_ARM_EABIMASK 0XFF000000
14324 ++/* Constants defined in AAELF. */
14325 ++#define EF_ARM_BE8 0x00800000
14326 ++#define EF_ARM_LE8 0x00400000
14328 ++#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
14329 ++#define EF_ARM_EABI_UNKNOWN 0x00000000
14330 ++#define EF_ARM_EABI_VER1 0x01000000
14331 ++#define EF_ARM_EABI_VER2 0x02000000
14332 ++#define EF_ARM_EABI_VER3 0x03000000
14333 ++#define EF_ARM_EABI_VER4 0x04000000
14334 ++#define EF_ARM_EABI_VER5 0x05000000
14336 ++/* Additional symbol types for Thumb. */
14337 ++#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
14338 ++#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
14340 ++/* ARM-specific values for sh_flags */
14341 ++#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
14342 ++#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
14343 ++ in the input to a link step. */
14345 ++/* ARM-specific program header flags */
14346 ++#define PF_ARM_SB 0x10000000 /* Segment contains the location
14347 ++ addressed by the static base. */
14348 ++#define PF_ARM_PI 0x20000000 /* Position-independent segment. */
14349 ++#define PF_ARM_ABS 0x40000000 /* Absolute segment. */
14351 ++/* Processor specific values for the Phdr p_type field. */
14352 ++#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
14354 ++/* Processor specific values for the Shdr sh_type field. */
14355 ++#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
14356 ++#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
14357 ++#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
14360 ++/* ARM relocs. */
14362 ++#define R_ARM_NONE 0 /* No reloc */
14363 ++#define R_ARM_PC24 1 /* PC relative 26 bit branch */
14364 ++#define R_ARM_ABS32 2 /* Direct 32 bit */
14365 ++#define R_ARM_REL32 3 /* PC relative 32 bit */
14366 ++#define R_ARM_PC13 4
14367 ++#define R_ARM_ABS16 5 /* Direct 16 bit */
14368 ++#define R_ARM_ABS12 6 /* Direct 12 bit */
14369 ++#define R_ARM_THM_ABS5 7
14370 ++#define R_ARM_ABS8 8 /* Direct 8 bit */
14371 ++#define R_ARM_SBREL32 9
14372 ++#define R_ARM_THM_PC22 10
14373 ++#define R_ARM_THM_PC8 11
14374 ++#define R_ARM_AMP_VCALL9 12
14375 ++#define R_ARM_SWI24 13 /* Obsolete static relocation. */
14376 ++#define R_ARM_TLS_DESC 13 /* Dynamic relocation. */
14377 ++#define R_ARM_THM_SWI8 14
14378 ++#define R_ARM_XPC25 15
14379 ++#define R_ARM_THM_XPC22 16
14380 ++#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */
14381 ++#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */
14382 ++#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */
14383 ++#define R_ARM_COPY 20 /* Copy symbol at runtime */
14384 ++#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
14385 ++#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
14386 ++#define R_ARM_RELATIVE 23 /* Adjust by program base */
14387 ++#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
14388 ++#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
14389 ++#define R_ARM_GOT32 26 /* 32 bit GOT entry */
14390 ++#define R_ARM_PLT32 27 /* 32 bit PLT address */
14391 ++#define R_ARM_ALU_PCREL_7_0 32
14392 ++#define R_ARM_ALU_PCREL_15_8 33
14393 ++#define R_ARM_ALU_PCREL_23_15 34
14394 ++#define R_ARM_LDR_SBREL_11_0 35
14395 ++#define R_ARM_ALU_SBREL_19_12 36
14396 ++#define R_ARM_ALU_SBREL_27_20 37
14397 ++#define R_ARM_TLS_GOTDESC 90
14398 ++#define R_ARM_TLS_CALL 91
14399 ++#define R_ARM_TLS_DESCSEQ 92
14400 ++#define R_ARM_THM_TLS_CALL 93
14401 ++#define R_ARM_GNU_VTENTRY 100
14402 ++#define R_ARM_GNU_VTINHERIT 101
14403 ++#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
14404 ++#define R_ARM_THM_PC9 103 /* thumb conditional branch */
14405 ++#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic
14406 ++ thread local data */
14407 ++#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic
14408 ++ thread local data */
14409 ++#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS
14410 ++ block */
14411 ++#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of
14412 ++ static TLS block offset */
14413 ++#define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static
14414 ++ TLS block */
14415 ++#define R_ARM_THM_TLS_DESCSEQ 129
14416 ++#define R_ARM_IRELATIVE 160
14417 ++#define R_ARM_RXPC25 249
14418 ++#define R_ARM_RSBREL32 250
14419 ++#define R_ARM_THM_RPC22 251
14420 ++#define R_ARM_RREL32 252
14421 ++#define R_ARM_RABS22 253
14422 ++#define R_ARM_RPC24 254
14423 ++#define R_ARM_RBASE 255
14424 ++/* Keep this the last entry. */
14425 ++#define R_ARM_NUM 256
14427 ++/* IA-64 specific declarations. */
14429 ++/* Processor specific flags for the Ehdr e_flags field. */
14430 ++#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
14431 ++#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
14432 ++#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
14434 ++/* Processor specific values for the Phdr p_type field. */
14435 ++#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
14436 ++#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
14437 ++#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12)
14438 ++#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13)
14439 ++#define PT_IA_64_HP_STACK (PT_LOOS + 0x14)
14441 ++/* Processor specific flags for the Phdr p_flags field. */
14442 ++#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
14444 ++/* Processor specific values for the Shdr sh_type field. */
14445 ++#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
14446 ++#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
14448 ++/* Processor specific flags for the Shdr sh_flags field. */
14449 ++#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
14450 ++#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
14452 ++/* Processor specific values for the Dyn d_tag field. */
14453 ++#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
14454 ++#define DT_IA_64_NUM 1
14456 ++/* IA-64 relocations. */
14457 ++#define R_IA64_NONE 0x00 /* none */
14458 ++#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
14459 ++#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
14460 ++#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
14461 ++#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
14462 ++#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
14463 ++#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
14464 ++#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
14465 ++#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
14466 ++#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
14467 ++#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
14468 ++#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
14469 ++#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
14470 ++#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
14471 ++#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
14472 ++#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
14473 ++#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
14474 ++#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
14475 ++#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
14476 ++#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
14477 ++#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
14478 ++#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
14479 ++#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
14480 ++#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
14481 ++#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
14482 ++#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
14483 ++#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
14484 ++#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
14485 ++#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
14486 ++#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
14487 ++#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
14488 ++#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
14489 ++#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
14490 ++#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
14491 ++#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
14492 ++#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
14493 ++#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
14494 ++#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
14495 ++#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
14496 ++#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
14497 ++#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
14498 ++#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
14499 ++#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
14500 ++#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
14501 ++#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
14502 ++#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
14503 ++#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
14504 ++#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
14505 ++#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
14506 ++#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
14507 ++#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
14508 ++#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
14509 ++#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
14510 ++#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
14511 ++#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
14512 ++#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
14513 ++#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
14514 ++#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
14515 ++#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
14516 ++#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
14517 ++#define R_IA64_COPY 0x84 /* copy relocation */
14518 ++#define R_IA64_SUB 0x85 /* Addend and symbol difference */
14519 ++#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
14520 ++#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
14521 ++#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
14522 ++#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
14523 ++#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
14524 ++#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
14525 ++#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
14526 ++#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
14527 ++#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
14528 ++#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
14529 ++#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
14530 ++#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
14531 ++#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
14532 ++#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
14533 ++#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
14534 ++#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
14535 ++#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
14536 ++#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
14537 ++#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
14539 ++/* SH specific declarations */
14541 ++/* Processor specific flags for the ELF header e_flags field. */
14542 ++#define EF_SH_MACH_MASK 0x1f
14543 ++#define EF_SH_UNKNOWN 0x0
14544 ++#define EF_SH1 0x1
14545 ++#define EF_SH2 0x2
14546 ++#define EF_SH3 0x3
14547 ++#define EF_SH_DSP 0x4
14548 ++#define EF_SH3_DSP 0x5
14549 ++#define EF_SH4AL_DSP 0x6
14550 ++#define EF_SH3E 0x8
14551 ++#define EF_SH4 0x9
14552 ++#define EF_SH2E 0xb
14553 ++#define EF_SH4A 0xc
14554 ++#define EF_SH2A 0xd
14555 ++#define EF_SH4_NOFPU 0x10
14556 ++#define EF_SH4A_NOFPU 0x11
14557 ++#define EF_SH4_NOMMU_NOFPU 0x12
14558 ++#define EF_SH2A_NOFPU 0x13
14559 ++#define EF_SH3_NOMMU 0x14
14560 ++#define EF_SH2A_SH4_NOFPU 0x15
14561 ++#define EF_SH2A_SH3_NOFPU 0x16
14562 ++#define EF_SH2A_SH4 0x17
14563 ++#define EF_SH2A_SH3E 0x18
14565 ++/* SH relocs. */
14566 ++#define R_SH_NONE 0
14567 ++#define R_SH_DIR32 1
14568 ++#define R_SH_REL32 2
14569 ++#define R_SH_DIR8WPN 3
14570 ++#define R_SH_IND12W 4
14571 ++#define R_SH_DIR8WPL 5
14572 ++#define R_SH_DIR8WPZ 6
14573 ++#define R_SH_DIR8BP 7
14574 ++#define R_SH_DIR8W 8
14575 ++#define R_SH_DIR8L 9
14576 ++#define R_SH_SWITCH16 25
14577 ++#define R_SH_SWITCH32 26
14578 ++#define R_SH_USES 27
14579 ++#define R_SH_COUNT 28
14580 ++#define R_SH_ALIGN 29
14581 ++#define R_SH_CODE 30
14582 ++#define R_SH_DATA 31
14583 ++#define R_SH_LABEL 32
14584 ++#define R_SH_SWITCH8 33
14585 ++#define R_SH_GNU_VTINHERIT 34
14586 ++#define R_SH_GNU_VTENTRY 35
14587 ++#define R_SH_TLS_GD_32 144
14588 ++#define R_SH_TLS_LD_32 145
14589 ++#define R_SH_TLS_LDO_32 146
14590 ++#define R_SH_TLS_IE_32 147
14591 ++#define R_SH_TLS_LE_32 148
14592 ++#define R_SH_TLS_DTPMOD32 149
14593 ++#define R_SH_TLS_DTPOFF32 150
14594 ++#define R_SH_TLS_TPOFF32 151
14595 ++#define R_SH_GOT32 160
14596 ++#define R_SH_PLT32 161
14597 ++#define R_SH_COPY 162
14598 ++#define R_SH_GLOB_DAT 163
14599 ++#define R_SH_JMP_SLOT 164
14600 ++#define R_SH_RELATIVE 165
14601 ++#define R_SH_GOTOFF 166
14602 ++#define R_SH_GOTPC 167
14603 ++/* Keep this the last entry. */
14604 ++#define R_SH_NUM 256
14606 ++/* S/390 specific definitions. */
14608 ++/* Valid values for the e_flags field. */
14610 ++#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */
14612 ++/* Additional s390 relocs */
14614 ++#define R_390_NONE 0 /* No reloc. */
14615 ++#define R_390_8 1 /* Direct 8 bit. */
14616 ++#define R_390_12 2 /* Direct 12 bit. */
14617 ++#define R_390_16 3 /* Direct 16 bit. */
14618 ++#define R_390_32 4 /* Direct 32 bit. */
14619 ++#define R_390_PC32 5 /* PC relative 32 bit. */
14620 ++#define R_390_GOT12 6 /* 12 bit GOT offset. */
14621 ++#define R_390_GOT32 7 /* 32 bit GOT offset. */
14622 ++#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
14623 ++#define R_390_COPY 9 /* Copy symbol at runtime. */
14624 ++#define R_390_GLOB_DAT 10 /* Create GOT entry. */
14625 ++#define R_390_JMP_SLOT 11 /* Create PLT entry. */
14626 ++#define R_390_RELATIVE 12 /* Adjust by program base. */
14627 ++#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */
14628 ++#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
14629 ++#define R_390_GOT16 15 /* 16 bit GOT offset. */
14630 ++#define R_390_PC16 16 /* PC relative 16 bit. */
14631 ++#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
14632 ++#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
14633 ++#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
14634 ++#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
14635 ++#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
14636 ++#define R_390_64 22 /* Direct 64 bit. */
14637 ++#define R_390_PC64 23 /* PC relative 64 bit. */
14638 ++#define R_390_GOT64 24 /* 64 bit GOT offset. */
14639 ++#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
14640 ++#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
14641 ++#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */
14642 ++#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */
14643 ++#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */
14644 ++#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */
14645 ++#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */
14646 ++#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */
14647 ++#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */
14648 ++#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */
14649 ++#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */
14650 ++#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */
14651 ++#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */
14652 ++#define R_390_TLS_GDCALL 38 /* Tag for function call in general
14653 ++ dynamic TLS code. */
14654 ++#define R_390_TLS_LDCALL 39 /* Tag for function call in local
14655 ++ dynamic TLS code. */
14656 ++#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic
14657 ++ thread local data. */
14658 ++#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic
14659 ++ thread local data. */
14660 ++#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS
14661 ++ block offset. */
14662 ++#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS
14663 ++ block offset. */
14664 ++#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS
14665 ++ block offset. */
14666 ++#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic
14667 ++ thread local data in LE code. */
14668 ++#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic
14669 ++ thread local data in LE code. */
14670 ++#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for
14671 ++ negated static TLS block offset. */
14672 ++#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for
14673 ++ negated static TLS block offset. */
14674 ++#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for
14675 ++ negated static TLS block offset. */
14676 ++#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to
14677 ++ static TLS block. */
14678 ++#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to
14679 ++ static TLS block. */
14680 ++#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS
14681 ++ block. */
14682 ++#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS
14683 ++ block. */
14684 ++#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */
14685 ++#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */
14686 ++#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS
14687 ++ block. */
14688 ++#define R_390_20 57 /* Direct 20 bit. */
14689 ++#define R_390_GOT20 58 /* 20 bit GOT offset. */
14690 ++#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */
14691 ++#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS
14692 ++ block offset. */
14693 ++#define R_390_IRELATIVE 61 /* STT_GNU_IFUNC relocation. */
14694 ++/* Keep this the last entry. */
14695 ++#define R_390_NUM 62
14698 ++/* CRIS relocations. */
14699 ++#define R_CRIS_NONE 0
14700 ++#define R_CRIS_8 1
14701 ++#define R_CRIS_16 2
14702 ++#define R_CRIS_32 3
14703 ++#define R_CRIS_8_PCREL 4
14704 ++#define R_CRIS_16_PCREL 5
14705 ++#define R_CRIS_32_PCREL 6
14706 ++#define R_CRIS_GNU_VTINHERIT 7
14707 ++#define R_CRIS_GNU_VTENTRY 8
14708 ++#define R_CRIS_COPY 9
14709 ++#define R_CRIS_GLOB_DAT 10
14710 ++#define R_CRIS_JUMP_SLOT 11
14711 ++#define R_CRIS_RELATIVE 12
14712 ++#define R_CRIS_16_GOT 13
14713 ++#define R_CRIS_32_GOT 14
14714 ++#define R_CRIS_16_GOTPLT 15
14715 ++#define R_CRIS_32_GOTPLT 16
14716 ++#define R_CRIS_32_GOTREL 17
14717 ++#define R_CRIS_32_PLT_GOTREL 18
14718 ++#define R_CRIS_32_PLT_PCREL 19
14720 ++#define R_CRIS_NUM 20
14723 ++/* AMD x86-64 relocations. */
14724 ++#define R_X86_64_NONE 0 /* No reloc */
14725 ++#define R_X86_64_64 1 /* Direct 64 bit */
14726 ++#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
14727 ++#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
14728 ++#define R_X86_64_PLT32 4 /* 32 bit PLT address */
14729 ++#define R_X86_64_COPY 5 /* Copy symbol at runtime */
14730 ++#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
14731 ++#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
14732 ++#define R_X86_64_RELATIVE 8 /* Adjust by program base */
14733 ++#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative
14734 ++ offset to GOT */
14735 ++#define R_X86_64_32 10 /* Direct 32 bit zero extended */
14736 ++#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
14737 ++#define R_X86_64_16 12 /* Direct 16 bit zero extended */
14738 ++#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
14739 ++#define R_X86_64_8 14 /* Direct 8 bit sign extended */
14740 ++#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
14741 ++#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
14742 ++#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
14743 ++#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
14744 ++#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
14745 ++ to two GOT entries for GD symbol */
14746 ++#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
14747 ++ to two GOT entries for LD symbol */
14748 ++#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
14749 ++#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
14750 ++ to GOT entry for IE symbol */
14751 ++#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
14752 ++#define R_X86_64_PC64 24 /* PC relative 64 bit */
14753 ++#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */
14754 ++#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative
14755 ++ offset to GOT */
14756 ++#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */
14757 ++#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset
14758 ++ to GOT entry */
14759 ++#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */
14760 ++#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */
14761 ++#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset
14762 ++ to PLT entry */
14763 ++#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */
14764 ++#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */
14765 ++#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */
14766 ++#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS
14767 ++ descriptor. */
14768 ++#define R_X86_64_TLSDESC 36 /* TLS descriptor. */
14769 ++#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
14770 ++#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */
14772 ++#define R_X86_64_NUM 39
14775 ++/* AM33 relocations. */
14776 ++#define R_MN10300_NONE 0 /* No reloc. */
14777 ++#define R_MN10300_32 1 /* Direct 32 bit. */
14778 ++#define R_MN10300_16 2 /* Direct 16 bit. */
14779 ++#define R_MN10300_8 3 /* Direct 8 bit. */
14780 ++#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */
14781 ++#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */
14782 ++#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */
14783 ++#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */
14784 ++#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */
14785 ++#define R_MN10300_24 9 /* Direct 24 bit. */
14786 ++#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */
14787 ++#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */
14788 ++#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */
14789 ++#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */
14790 ++#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */
14791 ++#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */
14792 ++#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */
14793 ++#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */
14794 ++#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */
14795 ++#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */
14796 ++#define R_MN10300_COPY 20 /* Copy symbol at runtime. */
14797 ++#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */
14798 ++#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */
14799 ++#define R_MN10300_RELATIVE 23 /* Adjust by program base. */
14801 ++#define R_MN10300_NUM 24
14804 ++/* M32R relocs. */
14805 ++#define R_M32R_NONE 0 /* No reloc. */
14806 ++#define R_M32R_16 1 /* Direct 16 bit. */
14807 ++#define R_M32R_32 2 /* Direct 32 bit. */
14808 ++#define R_M32R_24 3 /* Direct 24 bit. */
14809 ++#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */
14810 ++#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */
14811 ++#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */
14812 ++#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */
14813 ++#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */
14814 ++#define R_M32R_LO16 9 /* Low 16 bit. */
14815 ++#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */
14816 ++#define R_M32R_GNU_VTINHERIT 11
14817 ++#define R_M32R_GNU_VTENTRY 12
14818 ++/* M32R relocs use SHT_RELA. */
14819 ++#define R_M32R_16_RELA 33 /* Direct 16 bit. */
14820 ++#define R_M32R_32_RELA 34 /* Direct 32 bit. */
14821 ++#define R_M32R_24_RELA 35 /* Direct 24 bit. */
14822 ++#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */
14823 ++#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */
14824 ++#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */
14825 ++#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */
14826 ++#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */
14827 ++#define R_M32R_LO16_RELA 41 /* Low 16 bit */
14828 ++#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */
14829 ++#define R_M32R_RELA_GNU_VTINHERIT 43
14830 ++#define R_M32R_RELA_GNU_VTENTRY 44
14831 ++#define R_M32R_REL32 45 /* PC relative 32 bit. */
14833 ++#define R_M32R_GOT24 48 /* 24 bit GOT entry */
14834 ++#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */
14835 ++#define R_M32R_COPY 50 /* Copy symbol at runtime */
14836 ++#define R_M32R_GLOB_DAT 51 /* Create GOT entry */
14837 ++#define R_M32R_JMP_SLOT 52 /* Create PLT entry */
14838 ++#define R_M32R_RELATIVE 53 /* Adjust by program base */
14839 ++#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */
14840 ++#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */
14841 ++#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned
14842 ++ low */
14843 ++#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed
14844 ++ low */
14845 ++#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */
14846 ++#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to
14847 ++ GOT with unsigned low */
14848 ++#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to
14849 ++ GOT with signed low */
14850 ++#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to
14851 ++ GOT */
14852 ++#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT
14853 ++ with unsigned low */
14854 ++#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT
14855 ++ with signed low */
14856 ++#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */
14857 ++#define R_M32R_NUM 256 /* Keep this the last entry. */
14860 ++/* TILEPro relocations. */
14861 ++#define R_TILEPRO_NONE 0 /* No reloc */
14862 ++#define R_TILEPRO_32 1 /* Direct 32 bit */
14863 ++#define R_TILEPRO_16 2 /* Direct 16 bit */
14864 ++#define R_TILEPRO_8 3 /* Direct 8 bit */
14865 ++#define R_TILEPRO_32_PCREL 4 /* PC relative 32 bit */
14866 ++#define R_TILEPRO_16_PCREL 5 /* PC relative 16 bit */
14867 ++#define R_TILEPRO_8_PCREL 6 /* PC relative 8 bit */
14868 ++#define R_TILEPRO_LO16 7 /* Low 16 bit */
14869 ++#define R_TILEPRO_HI16 8 /* High 16 bit */
14870 ++#define R_TILEPRO_HA16 9 /* High 16 bit, adjusted */
14871 ++#define R_TILEPRO_COPY 10 /* Copy relocation */
14872 ++#define R_TILEPRO_GLOB_DAT 11 /* Create GOT entry */
14873 ++#define R_TILEPRO_JMP_SLOT 12 /* Create PLT entry */
14874 ++#define R_TILEPRO_RELATIVE 13 /* Adjust by program base */
14875 ++#define R_TILEPRO_BROFF_X1 14 /* X1 pipe branch offset */
14876 ++#define R_TILEPRO_JOFFLONG_X1 15 /* X1 pipe jump offset */
14877 ++#define R_TILEPRO_JOFFLONG_X1_PLT 16 /* X1 pipe jump offset to PLT */
14878 ++#define R_TILEPRO_IMM8_X0 17 /* X0 pipe 8-bit */
14879 ++#define R_TILEPRO_IMM8_Y0 18 /* Y0 pipe 8-bit */
14880 ++#define R_TILEPRO_IMM8_X1 19 /* X1 pipe 8-bit */
14881 ++#define R_TILEPRO_IMM8_Y1 20 /* Y1 pipe 8-bit */
14882 ++#define R_TILEPRO_MT_IMM15_X1 21 /* X1 pipe mtspr */
14883 ++#define R_TILEPRO_MF_IMM15_X1 22 /* X1 pipe mfspr */
14884 ++#define R_TILEPRO_IMM16_X0 23 /* X0 pipe 16-bit */
14885 ++#define R_TILEPRO_IMM16_X1 24 /* X1 pipe 16-bit */
14886 ++#define R_TILEPRO_IMM16_X0_LO 25 /* X0 pipe low 16-bit */
14887 ++#define R_TILEPRO_IMM16_X1_LO 26 /* X1 pipe low 16-bit */
14888 ++#define R_TILEPRO_IMM16_X0_HI 27 /* X0 pipe high 16-bit */
14889 ++#define R_TILEPRO_IMM16_X1_HI 28 /* X1 pipe high 16-bit */
14890 ++#define R_TILEPRO_IMM16_X0_HA 29 /* X0 pipe high 16-bit, adjusted */
14891 ++#define R_TILEPRO_IMM16_X1_HA 30 /* X1 pipe high 16-bit, adjusted */
14892 ++#define R_TILEPRO_IMM16_X0_PCREL 31 /* X0 pipe PC relative 16 bit */
14893 ++#define R_TILEPRO_IMM16_X1_PCREL 32 /* X1 pipe PC relative 16 bit */
14894 ++#define R_TILEPRO_IMM16_X0_LO_PCREL 33 /* X0 pipe PC relative low 16 bit */
14895 ++#define R_TILEPRO_IMM16_X1_LO_PCREL 34 /* X1 pipe PC relative low 16 bit */
14896 ++#define R_TILEPRO_IMM16_X0_HI_PCREL 35 /* X0 pipe PC relative high 16 bit */
14897 ++#define R_TILEPRO_IMM16_X1_HI_PCREL 36 /* X1 pipe PC relative high 16 bit */
14898 ++#define R_TILEPRO_IMM16_X0_HA_PCREL 37 /* X0 pipe PC relative ha() 16 bit */
14899 ++#define R_TILEPRO_IMM16_X1_HA_PCREL 38 /* X1 pipe PC relative ha() 16 bit */
14900 ++#define R_TILEPRO_IMM16_X0_GOT 39 /* X0 pipe 16-bit GOT offset */
14901 ++#define R_TILEPRO_IMM16_X1_GOT 40 /* X1 pipe 16-bit GOT offset */
14902 ++#define R_TILEPRO_IMM16_X0_GOT_LO 41 /* X0 pipe low 16-bit GOT offset */
14903 ++#define R_TILEPRO_IMM16_X1_GOT_LO 42 /* X1 pipe low 16-bit GOT offset */
14904 ++#define R_TILEPRO_IMM16_X0_GOT_HI 43 /* X0 pipe high 16-bit GOT offset */
14905 ++#define R_TILEPRO_IMM16_X1_GOT_HI 44 /* X1 pipe high 16-bit GOT offset */
14906 ++#define R_TILEPRO_IMM16_X0_GOT_HA 45 /* X0 pipe ha() 16-bit GOT offset */
14907 ++#define R_TILEPRO_IMM16_X1_GOT_HA 46 /* X1 pipe ha() 16-bit GOT offset */
14908 ++#define R_TILEPRO_MMSTART_X0 47 /* X0 pipe mm "start" */
14909 ++#define R_TILEPRO_MMEND_X0 48 /* X0 pipe mm "end" */
14910 ++#define R_TILEPRO_MMSTART_X1 49 /* X1 pipe mm "start" */
14911 ++#define R_TILEPRO_MMEND_X1 50 /* X1 pipe mm "end" */
14912 ++#define R_TILEPRO_SHAMT_X0 51 /* X0 pipe shift amount */
14913 ++#define R_TILEPRO_SHAMT_X1 52 /* X1 pipe shift amount */
14914 ++#define R_TILEPRO_SHAMT_Y0 53 /* Y0 pipe shift amount */
14915 ++#define R_TILEPRO_SHAMT_Y1 54 /* Y1 pipe shift amount */
14916 ++#define R_TILEPRO_DEST_IMM8_X1 55 /* X1 pipe destination 8-bit */
14917 ++/* Relocs 56-59 are currently not defined. */
14918 ++#define R_TILEPRO_TLS_GD_CALL 60 /* "jal" for TLS GD */
14919 ++#define R_TILEPRO_IMM8_X0_TLS_GD_ADD 61 /* X0 pipe "addi" for TLS GD */
14920 ++#define R_TILEPRO_IMM8_X1_TLS_GD_ADD 62 /* X1 pipe "addi" for TLS GD */
14921 ++#define R_TILEPRO_IMM8_Y0_TLS_GD_ADD 63 /* Y0 pipe "addi" for TLS GD */
14922 ++#define R_TILEPRO_IMM8_Y1_TLS_GD_ADD 64 /* Y1 pipe "addi" for TLS GD */
14923 ++#define R_TILEPRO_TLS_IE_LOAD 65 /* "lw_tls" for TLS IE */
14924 ++#define R_TILEPRO_IMM16_X0_TLS_GD 66 /* X0 pipe 16-bit TLS GD offset */
14925 ++#define R_TILEPRO_IMM16_X1_TLS_GD 67 /* X1 pipe 16-bit TLS GD offset */
14926 ++#define R_TILEPRO_IMM16_X0_TLS_GD_LO 68 /* X0 pipe low 16-bit TLS GD offset */
14927 ++#define R_TILEPRO_IMM16_X1_TLS_GD_LO 69 /* X1 pipe low 16-bit TLS GD offset */
14928 ++#define R_TILEPRO_IMM16_X0_TLS_GD_HI 70 /* X0 pipe high 16-bit TLS GD offset */
14929 ++#define R_TILEPRO_IMM16_X1_TLS_GD_HI 71 /* X1 pipe high 16-bit TLS GD offset */
14930 ++#define R_TILEPRO_IMM16_X0_TLS_GD_HA 72 /* X0 pipe ha() 16-bit TLS GD offset */
14931 ++#define R_TILEPRO_IMM16_X1_TLS_GD_HA 73 /* X1 pipe ha() 16-bit TLS GD offset */
14932 ++#define R_TILEPRO_IMM16_X0_TLS_IE 74 /* X0 pipe 16-bit TLS IE offset */
14933 ++#define R_TILEPRO_IMM16_X1_TLS_IE 75 /* X1 pipe 16-bit TLS IE offset */
14934 ++#define R_TILEPRO_IMM16_X0_TLS_IE_LO 76 /* X0 pipe low 16-bit TLS IE offset */
14935 ++#define R_TILEPRO_IMM16_X1_TLS_IE_LO 77 /* X1 pipe low 16-bit TLS IE offset */
14936 ++#define R_TILEPRO_IMM16_X0_TLS_IE_HI 78 /* X0 pipe high 16-bit TLS IE offset */
14937 ++#define R_TILEPRO_IMM16_X1_TLS_IE_HI 79 /* X1 pipe high 16-bit TLS IE offset */
14938 ++#define R_TILEPRO_IMM16_X0_TLS_IE_HA 80 /* X0 pipe ha() 16-bit TLS IE offset */
14939 ++#define R_TILEPRO_IMM16_X1_TLS_IE_HA 81 /* X1 pipe ha() 16-bit TLS IE offset */
14940 ++#define R_TILEPRO_TLS_DTPMOD32 82 /* ID of module containing symbol */
14941 ++#define R_TILEPRO_TLS_DTPOFF32 83 /* Offset in TLS block */
14942 ++#define R_TILEPRO_TLS_TPOFF32 84 /* Offset in static TLS block */
14943 ++#define R_TILEPRO_IMM16_X0_TLS_LE 85 /* X0 pipe 16-bit TLS LE offset */
14944 ++#define R_TILEPRO_IMM16_X1_TLS_LE 86 /* X1 pipe 16-bit TLS LE offset */
14945 ++#define R_TILEPRO_IMM16_X0_TLS_LE_LO 87 /* X0 pipe low 16-bit TLS LE offset */
14946 ++#define R_TILEPRO_IMM16_X1_TLS_LE_LO 88 /* X1 pipe low 16-bit TLS LE offset */
14947 ++#define R_TILEPRO_IMM16_X0_TLS_LE_HI 89 /* X0 pipe high 16-bit TLS LE offset */
14948 ++#define R_TILEPRO_IMM16_X1_TLS_LE_HI 90 /* X1 pipe high 16-bit TLS LE offset */
14949 ++#define R_TILEPRO_IMM16_X0_TLS_LE_HA 91 /* X0 pipe ha() 16-bit TLS LE offset */
14950 ++#define R_TILEPRO_IMM16_X1_TLS_LE_HA 92 /* X1 pipe ha() 16-bit TLS LE offset */
14952 ++#define R_TILEPRO_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
14953 ++#define R_TILEPRO_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
14955 ++#define R_TILEPRO_NUM 130
14958 ++/* TILE-Gx relocations. */
14959 ++#define R_TILEGX_NONE 0 /* No reloc */
14960 ++#define R_TILEGX_64 1 /* Direct 64 bit */
14961 ++#define R_TILEGX_32 2 /* Direct 32 bit */
14962 ++#define R_TILEGX_16 3 /* Direct 16 bit */
14963 ++#define R_TILEGX_8 4 /* Direct 8 bit */
14964 ++#define R_TILEGX_64_PCREL 5 /* PC relative 64 bit */
14965 ++#define R_TILEGX_32_PCREL 6 /* PC relative 32 bit */
14966 ++#define R_TILEGX_16_PCREL 7 /* PC relative 16 bit */
14967 ++#define R_TILEGX_8_PCREL 8 /* PC relative 8 bit */
14968 ++#define R_TILEGX_HW0 9 /* hword 0 16-bit */
14969 ++#define R_TILEGX_HW1 10 /* hword 1 16-bit */
14970 ++#define R_TILEGX_HW2 11 /* hword 2 16-bit */
14971 ++#define R_TILEGX_HW3 12 /* hword 3 16-bit */
14972 ++#define R_TILEGX_HW0_LAST 13 /* last hword 0 16-bit */
14973 ++#define R_TILEGX_HW1_LAST 14 /* last hword 1 16-bit */
14974 ++#define R_TILEGX_HW2_LAST 15 /* last hword 2 16-bit */
14975 ++#define R_TILEGX_COPY 16 /* Copy relocation */
14976 ++#define R_TILEGX_GLOB_DAT 17 /* Create GOT entry */
14977 ++#define R_TILEGX_JMP_SLOT 18 /* Create PLT entry */
14978 ++#define R_TILEGX_RELATIVE 19 /* Adjust by program base */
14979 ++#define R_TILEGX_BROFF_X1 20 /* X1 pipe branch offset */
14980 ++#define R_TILEGX_JUMPOFF_X1 21 /* X1 pipe jump offset */
14981 ++#define R_TILEGX_JUMPOFF_X1_PLT 22 /* X1 pipe jump offset to PLT */
14982 ++#define R_TILEGX_IMM8_X0 23 /* X0 pipe 8-bit */
14983 ++#define R_TILEGX_IMM8_Y0 24 /* Y0 pipe 8-bit */
14984 ++#define R_TILEGX_IMM8_X1 25 /* X1 pipe 8-bit */
14985 ++#define R_TILEGX_IMM8_Y1 26 /* Y1 pipe 8-bit */
14986 ++#define R_TILEGX_DEST_IMM8_X1 27 /* X1 pipe destination 8-bit */
14987 ++#define R_TILEGX_MT_IMM14_X1 28 /* X1 pipe mtspr */
14988 ++#define R_TILEGX_MF_IMM14_X1 29 /* X1 pipe mfspr */
14989 ++#define R_TILEGX_MMSTART_X0 30 /* X0 pipe mm "start" */
14990 ++#define R_TILEGX_MMEND_X0 31 /* X0 pipe mm "end" */
14991 ++#define R_TILEGX_SHAMT_X0 32 /* X0 pipe shift amount */
14992 ++#define R_TILEGX_SHAMT_X1 33 /* X1 pipe shift amount */
14993 ++#define R_TILEGX_SHAMT_Y0 34 /* Y0 pipe shift amount */
14994 ++#define R_TILEGX_SHAMT_Y1 35 /* Y1 pipe shift amount */
14995 ++#define R_TILEGX_IMM16_X0_HW0 36 /* X0 pipe hword 0 */
14996 ++#define R_TILEGX_IMM16_X1_HW0 37 /* X1 pipe hword 0 */
14997 ++#define R_TILEGX_IMM16_X0_HW1 38 /* X0 pipe hword 1 */
14998 ++#define R_TILEGX_IMM16_X1_HW1 39 /* X1 pipe hword 1 */
14999 ++#define R_TILEGX_IMM16_X0_HW2 40 /* X0 pipe hword 2 */
15000 ++#define R_TILEGX_IMM16_X1_HW2 41 /* X1 pipe hword 2 */
15001 ++#define R_TILEGX_IMM16_X0_HW3 42 /* X0 pipe hword 3 */
15002 ++#define R_TILEGX_IMM16_X1_HW3 43 /* X1 pipe hword 3 */
15003 ++#define R_TILEGX_IMM16_X0_HW0_LAST 44 /* X0 pipe last hword 0 */
15004 ++#define R_TILEGX_IMM16_X1_HW0_LAST 45 /* X1 pipe last hword 0 */
15005 ++#define R_TILEGX_IMM16_X0_HW1_LAST 46 /* X0 pipe last hword 1 */
15006 ++#define R_TILEGX_IMM16_X1_HW1_LAST 47 /* X1 pipe last hword 1 */
15007 ++#define R_TILEGX_IMM16_X0_HW2_LAST 48 /* X0 pipe last hword 2 */
15008 ++#define R_TILEGX_IMM16_X1_HW2_LAST 49 /* X1 pipe last hword 2 */
15009 ++#define R_TILEGX_IMM16_X0_HW0_PCREL 50 /* X0 pipe PC relative hword 0 */
15010 ++#define R_TILEGX_IMM16_X1_HW0_PCREL 51 /* X1 pipe PC relative hword 0 */
15011 ++#define R_TILEGX_IMM16_X0_HW1_PCREL 52 /* X0 pipe PC relative hword 1 */
15012 ++#define R_TILEGX_IMM16_X1_HW1_PCREL 53 /* X1 pipe PC relative hword 1 */
15013 ++#define R_TILEGX_IMM16_X0_HW2_PCREL 54 /* X0 pipe PC relative hword 2 */
15014 ++#define R_TILEGX_IMM16_X1_HW2_PCREL 55 /* X1 pipe PC relative hword 2 */
15015 ++#define R_TILEGX_IMM16_X0_HW3_PCREL 56 /* X0 pipe PC relative hword 3 */
15016 ++#define R_TILEGX_IMM16_X1_HW3_PCREL 57 /* X1 pipe PC relative hword 3 */
15017 ++#define R_TILEGX_IMM16_X0_HW0_LAST_PCREL 58 /* X0 pipe PC-rel last hword 0 */
15018 ++#define R_TILEGX_IMM16_X1_HW0_LAST_PCREL 59 /* X1 pipe PC-rel last hword 0 */
15019 ++#define R_TILEGX_IMM16_X0_HW1_LAST_PCREL 60 /* X0 pipe PC-rel last hword 1 */
15020 ++#define R_TILEGX_IMM16_X1_HW1_LAST_PCREL 61 /* X1 pipe PC-rel last hword 1 */
15021 ++#define R_TILEGX_IMM16_X0_HW2_LAST_PCREL 62 /* X0 pipe PC-rel last hword 2 */
15022 ++#define R_TILEGX_IMM16_X1_HW2_LAST_PCREL 63 /* X1 pipe PC-rel last hword 2 */
15023 ++#define R_TILEGX_IMM16_X0_HW0_GOT 64 /* X0 pipe hword 0 GOT offset */
15024 ++#define R_TILEGX_IMM16_X1_HW0_GOT 65 /* X1 pipe hword 0 GOT offset */
15025 ++/* Relocs 66-71 are currently not defined. */
15026 ++#define R_TILEGX_IMM16_X0_HW0_LAST_GOT 72 /* X0 pipe last hword 0 GOT offset */
15027 ++#define R_TILEGX_IMM16_X1_HW0_LAST_GOT 73 /* X1 pipe last hword 0 GOT offset */
15028 ++#define R_TILEGX_IMM16_X0_HW1_LAST_GOT 74 /* X0 pipe last hword 1 GOT offset */
15029 ++#define R_TILEGX_IMM16_X1_HW1_LAST_GOT 75 /* X1 pipe last hword 1 GOT offset */
15030 ++/* Relocs 76-77 are currently not defined. */
15031 ++#define R_TILEGX_IMM16_X0_HW0_TLS_GD 78 /* X0 pipe hword 0 TLS GD offset */
15032 ++#define R_TILEGX_IMM16_X1_HW0_TLS_GD 79 /* X1 pipe hword 0 TLS GD offset */
15033 ++#define R_TILEGX_IMM16_X0_HW0_TLS_LE 80 /* X0 pipe hword 0 TLS LE offset */
15034 ++#define R_TILEGX_IMM16_X1_HW0_TLS_LE 81 /* X1 pipe hword 0 TLS LE offset */
15035 ++#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE 82 /* X0 pipe last hword 0 LE off */
15036 ++#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE 83 /* X1 pipe last hword 0 LE off */
15037 ++#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE 84 /* X0 pipe last hword 1 LE off */
15038 ++#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE 85 /* X1 pipe last hword 1 LE off */
15039 ++#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD 86 /* X0 pipe last hword 0 GD off */
15040 ++#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD 87 /* X1 pipe last hword 0 GD off */
15041 ++#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD 88 /* X0 pipe last hword 1 GD off */
15042 ++#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD 89 /* X1 pipe last hword 1 GD off */
15043 ++/* Relocs 90-91 are currently not defined. */
15044 ++#define R_TILEGX_IMM16_X0_HW0_TLS_IE 92 /* X0 pipe hword 0 TLS IE offset */
15045 ++#define R_TILEGX_IMM16_X1_HW0_TLS_IE 93 /* X1 pipe hword 0 TLS IE offset */
15046 ++/* Relocs 94-99 are currently not defined. */
15047 ++#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE 100 /* X0 pipe last hword 0 IE off */
15048 ++#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE 101 /* X1 pipe last hword 0 IE off */
15049 ++#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE 102 /* X0 pipe last hword 1 IE off */
15050 ++#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE 103 /* X1 pipe last hword 1 IE off */
15051 ++/* Relocs 104-105 are currently not defined. */
15052 ++#define R_TILEGX_TLS_DTPMOD64 106 /* 64-bit ID of symbol's module */
15053 ++#define R_TILEGX_TLS_DTPOFF64 107 /* 64-bit offset in TLS block */
15054 ++#define R_TILEGX_TLS_TPOFF64 108 /* 64-bit offset in static TLS block */
15055 ++#define R_TILEGX_TLS_DTPMOD32 109 /* 32-bit ID of symbol's module */
15056 ++#define R_TILEGX_TLS_DTPOFF32 110 /* 32-bit offset in TLS block */
15057 ++#define R_TILEGX_TLS_TPOFF32 111 /* 32-bit offset in static TLS block */
15058 ++#define R_TILEGX_TLS_GD_CALL 112 /* "jal" for TLS GD */
15059 ++#define R_TILEGX_IMM8_X0_TLS_GD_ADD 113 /* X0 pipe "addi" for TLS GD */
15060 ++#define R_TILEGX_IMM8_X1_TLS_GD_ADD 114 /* X1 pipe "addi" for TLS GD */
15061 ++#define R_TILEGX_IMM8_Y0_TLS_GD_ADD 115 /* Y0 pipe "addi" for TLS GD */
15062 ++#define R_TILEGX_IMM8_Y1_TLS_GD_ADD 116 /* Y1 pipe "addi" for TLS GD */
15063 ++#define R_TILEGX_TLS_IE_LOAD 117 /* "ld_tls" for TLS IE */
15064 ++#define R_TILEGX_IMM8_X0_TLS_ADD 118 /* X0 pipe "addi" for TLS GD/IE */
15065 ++#define R_TILEGX_IMM8_X1_TLS_ADD 119 /* X1 pipe "addi" for TLS GD/IE */
15066 ++#define R_TILEGX_IMM8_Y0_TLS_ADD 120 /* Y0 pipe "addi" for TLS GD/IE */
15067 ++#define R_TILEGX_IMM8_Y1_TLS_ADD 121 /* Y1 pipe "addi" for TLS GD/IE */
15069 ++#define R_TILEGX_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
15070 ++#define R_TILEGX_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
15072 ++#define R_TILEGX_NUM 130
15074 ++#endif /* elf.h */
15075 diff --git a/target/linux/generic/patches-3.16/212-byteshift_portability.patch b/target/linux/generic/patches-3.16/212-byteshift_portability.patch
15076 new file mode 100644
15077 index 000000000000..0f23ba9be98b
15078 --- /dev/null
15079 +++ b/target/linux/generic/patches-3.16/212-byteshift_portability.patch
15080 @@ -0,0 +1,51 @@
15081 +--- a/tools/include/tools/be_byteshift.h
15082 ++++ b/tools/include/tools/be_byteshift.h
15083 +@@ -1,6 +1,10 @@
15084 + #ifndef _TOOLS_BE_BYTESHIFT_H
15085 + #define _TOOLS_BE_BYTESHIFT_H
15087 ++#ifndef __linux__
15088 ++#include "linux_types.h"
15089 ++#endif
15091 + #include <stdint.h>
15093 + static inline uint16_t __get_unaligned_be16(const uint8_t *p)
15094 +--- a/tools/include/tools/le_byteshift.h
15095 ++++ b/tools/include/tools/le_byteshift.h
15096 +@@ -1,6 +1,10 @@
15097 + #ifndef _TOOLS_LE_BYTESHIFT_H
15098 + #define _TOOLS_LE_BYTESHIFT_H
15100 ++#ifndef __linux__
15101 ++#include "linux_types.h"
15102 ++#endif
15104 + #include <stdint.h>
15106 + static inline uint16_t __get_unaligned_le16(const uint8_t *p)
15107 +--- /dev/null
15108 ++++ b/tools/include/tools/linux_types.h
15109 +@@ -0,0 +1,22 @@
15110 ++#ifndef __LINUX_TYPES_H
15111 ++#define __LINUX_TYPES_H
15113 ++#include <stdint.h>
15115 ++typedef uint8_t __u8;
15116 ++typedef uint8_t __be8;
15117 ++typedef uint8_t __le8;
15119 ++typedef uint16_t __u16;
15120 ++typedef uint16_t __be16;
15121 ++typedef uint16_t __le16;
15123 ++typedef uint32_t __u32;
15124 ++typedef uint32_t __be32;
15125 ++typedef uint32_t __le32;
15127 ++typedef uint64_t __u64;
15128 ++typedef uint64_t __be64;
15129 ++typedef uint64_t __le64;
15131 ++#endif
15132 diff --git a/target/linux/generic/patches-3.16/220-gc_sections.patch b/target/linux/generic/patches-3.16/220-gc_sections.patch
15133 new file mode 100644
15134 index 000000000000..c3585a242d7e
15135 --- /dev/null
15136 +++ b/target/linux/generic/patches-3.16/220-gc_sections.patch
15137 @@ -0,0 +1,509 @@
15138 +From: Felix Fietkau <nbd@openwrt.org>
15140 +use -ffunction-sections, -fdata-sections and --gc-sections --sort-section=name
15142 +In combination with kernel symbol export stripping this significantly reduces
15143 +the kernel image size. Used on both ARM and MIPS architectures.
15145 +Signed-off-by: Felix Fietkau <nbd@openwrt.org>
15146 +Signed-off-by: Jonas Gorski <jogo@openwrt.org>
15147 +Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
15148 +---
15150 +--- a/arch/mips/Makefile
15151 ++++ b/arch/mips/Makefile
15152 +@@ -89,10 +89,14 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
15154 + cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
15155 + cflags-y += -msoft-float
15156 +-LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
15157 ++LDFLAGS_vmlinux += -G 0 -static -n -nostdlib --gc-sections --sort-section=name
15158 + KBUILD_AFLAGS_MODULE += -mlong-calls
15159 + KBUILD_CFLAGS_MODULE += -mlong-calls
15161 ++ifndef CONFIG_FUNCTION_TRACER
15162 ++KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
15163 ++endif
15165 + cflags-y += -ffreestanding
15168 +--- a/arch/mips/kernel/vmlinux.lds.S
15169 ++++ b/arch/mips/kernel/vmlinux.lds.S
15170 +@@ -67,7 +67,7 @@ SECTIONS
15171 + /* Exception table for data bus errors */
15172 + __dbe_table : {
15173 + __start___dbe_table = .;
15174 +- *(__dbe_table)
15175 ++ KEEP(*(__dbe_table))
15176 + __stop___dbe_table = .;
15179 +@@ -112,7 +112,7 @@ SECTIONS
15180 + . = ALIGN(4);
15181 + .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
15182 + __mips_machines_start = .;
15183 +- *(.mips.machines.init)
15184 ++ KEEP(*(.mips.machines.init))
15185 + __mips_machines_end = .;
15188 +--- a/include/asm-generic/vmlinux.lds.h
15189 ++++ b/include/asm-generic/vmlinux.lds.h
15190 +@@ -87,7 +87,7 @@
15191 + #ifdef CONFIG_FTRACE_MCOUNT_RECORD
15192 + #define MCOUNT_REC() . = ALIGN(8); \
15193 + VMLINUX_SYMBOL(__start_mcount_loc) = .; \
15194 +- *(__mcount_loc) \
15195 ++ KEEP(*(__mcount_loc)) \
15196 + VMLINUX_SYMBOL(__stop_mcount_loc) = .;
15197 + #else
15198 + #define MCOUNT_REC()
15199 +@@ -95,7 +95,7 @@
15201 + #ifdef CONFIG_TRACE_BRANCH_PROFILING
15202 + #define LIKELY_PROFILE() VMLINUX_SYMBOL(__start_annotated_branch_profile) = .; \
15203 +- *(_ftrace_annotated_branch) \
15204 ++ KEEP(*(_ftrace_annotated_branch)) \
15205 + VMLINUX_SYMBOL(__stop_annotated_branch_profile) = .;
15206 + #else
15207 + #define LIKELY_PROFILE()
15208 +@@ -103,7 +103,7 @@
15210 + #ifdef CONFIG_PROFILE_ALL_BRANCHES
15211 + #define BRANCH_PROFILE() VMLINUX_SYMBOL(__start_branch_profile) = .; \
15212 +- *(_ftrace_branch) \
15213 ++ KEEP(*(_ftrace_branch)) \
15214 + VMLINUX_SYMBOL(__stop_branch_profile) = .;
15215 + #else
15216 + #define BRANCH_PROFILE()
15217 +@@ -121,7 +121,7 @@
15218 + #ifdef CONFIG_EVENT_TRACING
15219 + #define FTRACE_EVENTS() . = ALIGN(8); \
15220 + VMLINUX_SYMBOL(__start_ftrace_events) = .; \
15221 +- *(_ftrace_events) \
15222 ++ KEEP(*(_ftrace_events)) \
15223 + VMLINUX_SYMBOL(__stop_ftrace_events) = .;
15224 + #else
15225 + #define FTRACE_EVENTS()
15226 +@@ -129,7 +129,7 @@
15228 + #ifdef CONFIG_TRACING
15229 + #define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \
15230 +- *(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
15231 ++ KEEP(*(__trace_printk_fmt)) /* Trace_printk fmt' pointer */ \
15232 + VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
15233 + #define TRACEPOINT_STR() VMLINUX_SYMBOL(__start___tracepoint_str) = .; \
15234 + *(__tracepoint_str) /* Trace_printk fmt' pointer */ \
15235 +@@ -142,7 +142,7 @@
15236 + #ifdef CONFIG_FTRACE_SYSCALLS
15237 + #define TRACE_SYSCALLS() . = ALIGN(8); \
15238 + VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \
15239 +- *(__syscalls_metadata) \
15240 ++ KEEP(*(__syscalls_metadata)) \
15241 + VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
15242 + #else
15243 + #define TRACE_SYSCALLS()
15244 +@@ -156,8 +156,8 @@
15245 + #define _OF_TABLE_1(name) \
15246 + . = ALIGN(8); \
15247 + VMLINUX_SYMBOL(__##name##_of_table) = .; \
15248 +- *(__##name##_of_table) \
15249 +- *(__##name##_of_table_end)
15250 ++ KEEP(*(__##name##_of_table)) \
15251 ++ KEEP(*(__##name##_of_table_end))
15253 + #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc)
15254 + #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
15255 +@@ -169,7 +169,7 @@
15256 + #define KERNEL_DTB() \
15257 + STRUCT_ALIGN(); \
15258 + VMLINUX_SYMBOL(__dtb_start) = .; \
15259 +- *(.dtb.init.rodata) \
15260 ++ KEEP(*(.dtb.init.rodata)) \
15261 + VMLINUX_SYMBOL(__dtb_end) = .;
15263 + /* .data section */
15264 +@@ -185,16 +185,17 @@
15265 + /* implement dynamic printk debug */ \
15266 + . = ALIGN(8); \
15267 + VMLINUX_SYMBOL(__start___jump_table) = .; \
15268 +- *(__jump_table) \
15269 ++ KEEP(*(__jump_table)) \
15270 + VMLINUX_SYMBOL(__stop___jump_table) = .; \
15271 + . = ALIGN(8); \
15272 + VMLINUX_SYMBOL(__start___verbose) = .; \
15273 +- *(__verbose) \
15274 ++ KEEP(*(__verbose)) \
15275 + VMLINUX_SYMBOL(__stop___verbose) = .; \
15276 + LIKELY_PROFILE() \
15277 + BRANCH_PROFILE() \
15278 + TRACE_PRINTKS() \
15279 +- TRACEPOINT_STR()
15280 ++ TRACEPOINT_STR() \
15281 ++ *(.data.[a-zA-Z_]*)
15283 + /*
15284 + * Data section helpers
15285 +@@ -248,32 +249,32 @@
15286 + /* PCI quirks */ \
15287 + .pci_fixup : AT(ADDR(.pci_fixup) - LOAD_OFFSET) { \
15288 + VMLINUX_SYMBOL(__start_pci_fixups_early) = .; \
15289 +- *(.pci_fixup_early) \
15290 ++ KEEP(*(.pci_fixup_early)) \
15291 + VMLINUX_SYMBOL(__end_pci_fixups_early) = .; \
15292 + VMLINUX_SYMBOL(__start_pci_fixups_header) = .; \
15293 +- *(.pci_fixup_header) \
15294 ++ KEEP(*(.pci_fixup_header)) \
15295 + VMLINUX_SYMBOL(__end_pci_fixups_header) = .; \
15296 + VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
15297 +- *(.pci_fixup_final) \
15298 ++ KEEP(*(.pci_fixup_final)) \
15299 + VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
15300 + VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
15301 +- *(.pci_fixup_enable) \
15302 ++ KEEP(*(.pci_fixup_enable)) \
15303 + VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
15304 + VMLINUX_SYMBOL(__start_pci_fixups_resume) = .; \
15305 +- *(.pci_fixup_resume) \
15306 ++ KEEP(*(.pci_fixup_resume)) \
15307 + VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \
15308 + VMLINUX_SYMBOL(__start_pci_fixups_resume_early) = .; \
15309 +- *(.pci_fixup_resume_early) \
15310 ++ KEEP(*(.pci_fixup_resume_early)) \
15311 + VMLINUX_SYMBOL(__end_pci_fixups_resume_early) = .; \
15312 + VMLINUX_SYMBOL(__start_pci_fixups_suspend) = .; \
15313 +- *(.pci_fixup_suspend) \
15314 ++ KEEP(*(.pci_fixup_suspend)) \
15315 + VMLINUX_SYMBOL(__end_pci_fixups_suspend) = .; \
15316 + } \
15318 + /* Built-in firmware blobs */ \
15319 + .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \
15320 + VMLINUX_SYMBOL(__start_builtin_fw) = .; \
15321 +- *(.builtin_fw) \
15322 ++ KEEP(*(.builtin_fw)) \
15323 + VMLINUX_SYMBOL(__end_builtin_fw) = .; \
15324 + } \
15326 +@@ -282,49 +283,49 @@
15327 + /* Kernel symbol table: Normal symbols */ \
15328 + __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
15329 + VMLINUX_SYMBOL(__start___ksymtab) = .; \
15330 +- *(SORT(___ksymtab+*)) \
15331 ++ KEEP(*(SORT(___ksymtab+*))) \
15332 + VMLINUX_SYMBOL(__stop___ksymtab) = .; \
15333 + } \
15335 + /* Kernel symbol table: GPL-only symbols */ \
15336 + __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
15337 + VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
15338 +- *(SORT(___ksymtab_gpl+*)) \
15339 ++ KEEP(*(SORT(___ksymtab_gpl+*))) \
15340 + VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
15341 + } \
15343 + /* Kernel symbol table: Normal unused symbols */ \
15344 + __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
15345 + VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
15346 +- *(SORT(___ksymtab_unused+*)) \
15347 ++ KEEP(*(SORT(___ksymtab_unused+*))) \
15348 + VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
15349 + } \
15351 + /* Kernel symbol table: GPL-only unused symbols */ \
15352 + __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
15353 + VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
15354 +- *(SORT(___ksymtab_unused_gpl+*)) \
15355 ++ KEEP(*(SORT(___ksymtab_unused_gpl+*))) \
15356 + VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
15357 + } \
15359 + /* Kernel symbol table: GPL-future-only symbols */ \
15360 + __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
15361 + VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
15362 +- *(SORT(___ksymtab_gpl_future+*)) \
15363 ++ KEEP(*(SORT(___ksymtab_gpl_future+*))) \
15364 + VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
15365 + } \
15367 + /* Kernel symbol table: Normal symbols */ \
15368 + __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
15369 + VMLINUX_SYMBOL(__start___kcrctab) = .; \
15370 +- *(SORT(___kcrctab+*)) \
15371 ++ KEEP(*(SORT(___kcrctab+*))) \
15372 + VMLINUX_SYMBOL(__stop___kcrctab) = .; \
15373 + } \
15375 + /* Kernel symbol table: GPL-only symbols */ \
15376 + __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
15377 + VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
15378 +- *(SORT(___kcrctab_gpl+*)) \
15379 ++ KEEP(*(SORT(___kcrctab_gpl+*))) \
15380 + VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
15381 + } \
15383 +@@ -338,14 +339,14 @@
15384 + /* Kernel symbol table: GPL-only unused symbols */ \
15385 + __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
15386 + VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
15387 +- *(SORT(___kcrctab_unused_gpl+*)) \
15388 ++ KEEP(*(SORT(___kcrctab_unused_gpl+*))) \
15389 + VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
15390 + } \
15392 + /* Kernel symbol table: GPL-future-only symbols */ \
15393 + __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
15394 + VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
15395 +- *(SORT(___kcrctab_gpl_future+*)) \
15396 ++ KEEP(*(SORT(___kcrctab_gpl_future+*))) \
15397 + VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
15398 + } \
15400 +@@ -364,14 +365,14 @@
15401 + /* Built-in module parameters. */ \
15402 + __param : AT(ADDR(__param) - LOAD_OFFSET) { \
15403 + VMLINUX_SYMBOL(__start___param) = .; \
15404 +- *(__param) \
15405 ++ KEEP(*(__param)) \
15406 + VMLINUX_SYMBOL(__stop___param) = .; \
15407 + } \
15409 + /* Built-in module versions. */ \
15410 + __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
15411 + VMLINUX_SYMBOL(__start___modver) = .; \
15412 +- *(__modver) \
15413 ++ KEEP(*(__modver)) \
15414 + VMLINUX_SYMBOL(__stop___modver) = .; \
15415 + . = ALIGN((align)); \
15416 + VMLINUX_SYMBOL(__end_rodata) = .; \
15417 +@@ -427,7 +428,7 @@
15418 + #define ENTRY_TEXT \
15419 + ALIGN_FUNCTION(); \
15420 + VMLINUX_SYMBOL(__entry_text_start) = .; \
15421 +- *(.entry.text) \
15422 ++ KEEP(*(.entry.text)) \
15423 + VMLINUX_SYMBOL(__entry_text_end) = .;
15425 + #ifdef CONFIG_FUNCTION_GRAPH_TRACER
15426 +@@ -455,7 +456,7 @@
15427 + . = ALIGN(align); \
15428 + __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \
15429 + VMLINUX_SYMBOL(__start___ex_table) = .; \
15430 +- *(__ex_table) \
15431 ++ KEEP(*(__ex_table)) \
15432 + VMLINUX_SYMBOL(__stop___ex_table) = .; \
15435 +@@ -471,8 +472,8 @@
15436 + #ifdef CONFIG_CONSTRUCTORS
15437 + #define KERNEL_CTORS() . = ALIGN(8); \
15438 + VMLINUX_SYMBOL(__ctors_start) = .; \
15439 +- *(.ctors) \
15440 +- *(.init_array) \
15441 ++ KEEP(*(.ctors)) \
15442 ++ KEEP(*(.init_array)) \
15443 + VMLINUX_SYMBOL(__ctors_end) = .;
15444 + #else
15445 + #define KERNEL_CTORS()
15446 +@@ -520,7 +521,7 @@
15447 + #define SBSS(sbss_align) \
15448 + . = ALIGN(sbss_align); \
15449 + .sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
15450 +- *(.sbss) \
15451 ++ *(.sbss .sbss.*) \
15452 + *(.scommon) \
15455 +@@ -538,7 +539,7 @@
15456 + BSS_FIRST_SECTIONS \
15457 + *(.bss..page_aligned) \
15458 + *(.dynbss) \
15459 +- *(.bss) \
15460 ++ *(.bss .bss.*) \
15461 + *(COMMON) \
15464 +@@ -599,7 +600,7 @@
15465 + . = ALIGN(4); \
15466 + .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \
15467 + VMLINUX_SYMBOL(__tracedata_start) = .; \
15468 +- *(.tracedata) \
15469 ++ KEEP(*(.tracedata)) \
15470 + VMLINUX_SYMBOL(__tracedata_end) = .; \
15472 + #else
15473 +@@ -616,17 +617,17 @@
15474 + #define INIT_SETUP(initsetup_align) \
15475 + . = ALIGN(initsetup_align); \
15476 + VMLINUX_SYMBOL(__setup_start) = .; \
15477 +- *(.init.setup) \
15478 ++ KEEP(*(.init.setup)) \
15479 + VMLINUX_SYMBOL(__setup_end) = .;
15481 + #define INIT_CALLS_LEVEL(level) \
15482 + VMLINUX_SYMBOL(__initcall##level##_start) = .; \
15483 +- *(.initcall##level##.init) \
15484 +- *(.initcall##level##s.init) \
15485 ++ KEEP(*(.initcall##level##.init)) \
15486 ++ KEEP(*(.initcall##level##s.init)) \
15488 + #define INIT_CALLS \
15489 + VMLINUX_SYMBOL(__initcall_start) = .; \
15490 +- *(.initcallearly.init) \
15491 ++ KEEP(*(.initcallearly.init)) \
15492 + INIT_CALLS_LEVEL(0) \
15493 + INIT_CALLS_LEVEL(1) \
15494 + INIT_CALLS_LEVEL(2) \
15495 +@@ -640,21 +641,21 @@
15497 + #define CON_INITCALL \
15498 + VMLINUX_SYMBOL(__con_initcall_start) = .; \
15499 +- *(.con_initcall.init) \
15500 ++ KEEP(*(.con_initcall.init)) \
15501 + VMLINUX_SYMBOL(__con_initcall_end) = .;
15503 + #define SECURITY_INITCALL \
15504 + VMLINUX_SYMBOL(__security_initcall_start) = .; \
15505 +- *(.security_initcall.init) \
15506 ++ KEEP(*(.security_initcall.init)) \
15507 + VMLINUX_SYMBOL(__security_initcall_end) = .;
15509 + #ifdef CONFIG_BLK_DEV_INITRD
15510 + #define INIT_RAM_FS \
15511 + . = ALIGN(4); \
15512 + VMLINUX_SYMBOL(__initramfs_start) = .; \
15513 +- *(.init.ramfs) \
15514 ++ KEEP(*(.init.ramfs)) \
15515 + . = ALIGN(8); \
15516 +- *(.init.ramfs.info)
15517 ++ KEEP(*(.init.ramfs.info))
15518 + #else
15519 + #define INIT_RAM_FS
15520 + #endif
15521 +--- a/arch/arm/Makefile
15522 ++++ b/arch/arm/Makefile
15523 +@@ -18,11 +18,16 @@ ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
15524 + LDFLAGS_vmlinux += --be8
15525 + LDFLAGS_MODULE += --be8
15526 + endif
15527 ++LDFLAGS_vmlinux += --gc-sections --sort-section=name
15529 + OBJCOPYFLAGS :=-O binary -R .comment -S
15530 + GZFLAGS :=-9
15531 + #KBUILD_CFLAGS +=-pipe
15533 ++ifndef CONFIG_FUNCTION_TRACER
15534 ++KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
15535 ++endif
15537 + # Never generate .eh_frame
15538 + KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
15540 +--- a/arch/arm/kernel/vmlinux.lds.S
15541 ++++ b/arch/arm/kernel/vmlinux.lds.S
15542 +@@ -12,13 +12,13 @@
15543 + #define PROC_INFO \
15544 + . = ALIGN(4); \
15545 + VMLINUX_SYMBOL(__proc_info_begin) = .; \
15546 +- *(.proc.info.init) \
15547 ++ KEEP(*(.proc.info.init)) \
15548 + VMLINUX_SYMBOL(__proc_info_end) = .;
15550 + #define IDMAP_TEXT \
15551 + ALIGN_FUNCTION(); \
15552 + VMLINUX_SYMBOL(__idmap_text_start) = .; \
15553 +- *(.idmap.text) \
15554 ++ KEEP(*(.idmap.text)) \
15555 + VMLINUX_SYMBOL(__idmap_text_end) = .; \
15556 + . = ALIGN(32); \
15557 + VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
15558 +@@ -93,7 +93,7 @@ SECTIONS
15559 + .text : { /* Real text segment */
15560 + _stext = .; /* Text and read-only data */
15561 + __exception_text_start = .;
15562 +- *(.exception.text)
15563 ++ KEEP(*(.exception.text))
15564 + __exception_text_end = .;
15565 + IRQENTRY_TEXT
15566 + TEXT_TEXT
15567 +@@ -118,7 +118,7 @@ SECTIONS
15568 + __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
15569 + __start___ex_table = .;
15570 + #ifdef CONFIG_MMU
15571 +- *(__ex_table)
15572 ++ KEEP(*(__ex_table))
15573 + #endif
15574 + __stop___ex_table = .;
15576 +@@ -130,12 +130,12 @@ SECTIONS
15577 + . = ALIGN(8);
15578 + .ARM.unwind_idx : {
15579 + __start_unwind_idx = .;
15580 +- *(.ARM.exidx*)
15581 ++ KEEP(*(.ARM.exidx*))
15582 + __stop_unwind_idx = .;
15584 + .ARM.unwind_tab : {
15585 + __start_unwind_tab = .;
15586 +- *(.ARM.extab*)
15587 ++ KEEP(*(.ARM.extab*))
15588 + __stop_unwind_tab = .;
15590 + #endif
15591 +@@ -154,14 +154,14 @@ SECTIONS
15592 + */
15593 + __vectors_start = .;
15594 + .vectors 0 : AT(__vectors_start) {
15595 +- *(.vectors)
15596 ++ KEEP(*(.vectors))
15598 + . = __vectors_start + SIZEOF(.vectors);
15599 + __vectors_end = .;
15601 + __stubs_start = .;
15602 + .stubs 0x1000 : AT(__stubs_start) {
15603 +- *(.stubs)
15604 ++ KEEP(*(.stubs))
15606 + . = __stubs_start + SIZEOF(.stubs);
15607 + __stubs_end = .;
15608 +@@ -175,24 +175,24 @@ SECTIONS
15610 + .init.arch.info : {
15611 + __arch_info_begin = .;
15612 +- *(.arch.info.init)
15613 ++ KEEP(*(.arch.info.init))
15614 + __arch_info_end = .;
15616 + .init.tagtable : {
15617 + __tagtable_begin = .;
15618 +- *(.taglist.init)
15619 ++ KEEP(*(.taglist.init))
15620 + __tagtable_end = .;
15622 + #ifdef CONFIG_SMP_ON_UP
15623 + .init.smpalt : {
15624 + __smpalt_begin = .;
15625 +- *(.alt.smp.init)
15626 ++ KEEP(*(.alt.smp.init))
15627 + __smpalt_end = .;
15629 + #endif
15630 + .init.pv_table : {
15631 + __pv_table_begin = .;
15632 +- *(.pv_table)
15633 ++ KEEP(*(.pv_table))
15634 + __pv_table_end = .;
15636 + .init.data : {
15637 +--- a/arch/arm/boot/compressed/Makefile
15638 ++++ b/arch/arm/boot/compressed/Makefile
15639 +@@ -120,6 +120,7 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
15640 + ORIG_CFLAGS := $(KBUILD_CFLAGS)
15641 + KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
15642 + endif
15643 ++KBUILD_CFLAGS_KERNEL := $(patsubst -f%-sections,,$(KBUILD_CFLAGS_KERNEL))
15645 + ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
15646 + asflags-y := -DZIMAGE
15647 diff --git a/target/linux/generic/patches-3.16/221-module_exports.patch b/target/linux/generic/patches-3.16/221-module_exports.patch
15648 new file mode 100644
15649 index 000000000000..b5380030af41
15650 --- /dev/null
15651 +++ b/target/linux/generic/patches-3.16/221-module_exports.patch
15652 @@ -0,0 +1,88 @@
15653 +--- a/include/asm-generic/vmlinux.lds.h
15654 ++++ b/include/asm-generic/vmlinux.lds.h
15655 +@@ -52,6 +52,16 @@
15656 + #define LOAD_OFFSET 0
15657 + #endif
15659 ++#ifndef SYMTAB_KEEP
15660 ++#define SYMTAB_KEEP KEEP(*(SORT(___ksymtab+*)))
15661 ++#define SYMTAB_KEEP_GPL KEEP(*(SORT(___ksymtab_gpl+*)))
15662 ++#endif
15664 ++#ifndef SYMTAB_DISCARD
15665 ++#define SYMTAB_DISCARD
15666 ++#define SYMTAB_DISCARD_GPL
15667 ++#endif
15669 + #include <linux/export.h>
15671 + /* Align . to a 8 byte boundary equals to maximum function alignment. */
15672 +@@ -284,14 +294,14 @@
15673 + /* Kernel symbol table: Normal symbols */ \
15674 + __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
15675 + VMLINUX_SYMBOL(__start___ksymtab) = .; \
15676 +- KEEP(*(SORT(___ksymtab+*))) \
15677 ++ SYMTAB_KEEP \
15678 + VMLINUX_SYMBOL(__stop___ksymtab) = .; \
15679 + } \
15681 + /* Kernel symbol table: GPL-only symbols */ \
15682 + __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
15683 + VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
15684 +- KEEP(*(SORT(___ksymtab_gpl+*))) \
15685 ++ SYMTAB_KEEP_GPL \
15686 + VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
15687 + } \
15689 +@@ -353,7 +363,7 @@
15691 + /* Kernel symbol table: strings */ \
15692 + __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
15693 +- *(__ksymtab_strings) \
15694 ++ *(__ksymtab_strings+*) \
15695 + } \
15697 + /* __*init sections */ \
15698 +@@ -671,6 +681,8 @@
15699 + EXIT_TEXT \
15700 + EXIT_DATA \
15701 + EXIT_CALL \
15702 ++ SYMTAB_DISCARD \
15703 ++ SYMTAB_DISCARD_GPL \
15704 + *(.discard) \
15705 + *(.discard.*) \
15707 +--- a/scripts/Makefile.build
15708 ++++ b/scripts/Makefile.build
15709 +@@ -349,7 +349,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(
15710 + # Linker scripts preprocessor (.lds.S -> .lds)
15711 + # ---------------------------------------------------------------------------
15712 + quiet_cmd_cpp_lds_S = LDS $@
15713 +- cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
15714 ++ cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \
15715 + -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
15717 + $(obj)/%.lds: $(src)/%.lds.S FORCE
15718 +--- a/include/linux/export.h
15719 ++++ b/include/linux/export.h
15720 +@@ -52,12 +52,19 @@ extern struct module __this_module;
15721 + #define __CRC_SYMBOL(sym, sec)
15722 + #endif
15724 ++#ifdef MODULE
15725 ++#define __EXPORT_SUFFIX(sym)
15726 ++#else
15727 ++#define __EXPORT_SUFFIX(sym) "+" #sym
15728 ++#endif
15730 + /* For every exported symbol, place a struct in the __ksymtab section */
15731 + #define __EXPORT_SYMBOL(sym, sec) \
15732 + extern typeof(sym) sym; \
15733 + __CRC_SYMBOL(sym, sec) \
15734 + static const char __kstrtab_##sym[] \
15735 +- __attribute__((section("__ksymtab_strings"), aligned(1))) \
15736 ++ __attribute__((section("__ksymtab_strings" \
15737 ++ __EXPORT_SUFFIX(sym)), aligned(1))) \
15738 + = VMLINUX_SYMBOL_STR(sym); \
15739 + extern const struct kernel_symbol __ksymtab_##sym; \
15740 + __visible const struct kernel_symbol __ksymtab_##sym \
15741 diff --git a/target/linux/generic/patches-3.16/230-openwrt_lzma_options.patch b/target/linux/generic/patches-3.16/230-openwrt_lzma_options.patch
15742 new file mode 100644
15743 index 000000000000..1e6ad3922842
15744 --- /dev/null
15745 +++ b/target/linux/generic/patches-3.16/230-openwrt_lzma_options.patch
15746 @@ -0,0 +1,58 @@
15747 +--- a/scripts/Makefile.lib
15748 ++++ b/scripts/Makefile.lib
15749 +@@ -304,7 +304,7 @@ cmd_bzip2 = (cat $(filter-out FORCE,$^)
15751 + quiet_cmd_lzma = LZMA $@
15752 + cmd_lzma = (cat $(filter-out FORCE,$^) | \
15753 +- lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
15754 ++ lzma e -d20 -lc1 -lp2 -pb2 -eos -si -so && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
15755 + (rm -f $@ ; false)
15757 + quiet_cmd_lzo = LZO $@
15758 +--- a/scripts/gen_initramfs_list.sh
15759 ++++ b/scripts/gen_initramfs_list.sh
15760 +@@ -226,7 +226,7 @@ cpio_list=
15761 + output="/dev/stdout"
15762 + output_file=""
15763 + is_cpio_compressed=
15764 +-compr="gzip -n -9 -f"
15765 ++compr="gzip -n -9 -f -"
15767 + arg="$1"
15768 + case "$arg" in
15769 +@@ -242,13 +242,13 @@ case "$arg" in
15770 + output=${cpio_list}
15771 + echo "$output_file" | grep -q "\.gz$" \
15772 + && [ -x "`which gzip 2> /dev/null`" ] \
15773 +- && compr="gzip -n -9 -f"
15774 ++ && compr="gzip -n -9 -f -"
15775 + echo "$output_file" | grep -q "\.bz2$" \
15776 + && [ -x "`which bzip2 2> /dev/null`" ] \
15777 +- && compr="bzip2 -9 -f"
15778 ++ && compr="bzip2 -9 -f -"
15779 + echo "$output_file" | grep -q "\.lzma$" \
15780 + && [ -x "`which lzma 2> /dev/null`" ] \
15781 +- && compr="lzma -9 -f"
15782 ++ && compr="lzma e -d20 -lc1 -lp2 -pb2 -eos -si -so"
15783 + echo "$output_file" | grep -q "\.xz$" \
15784 + && [ -x "`which xz 2> /dev/null`" ] \
15785 + && compr="xz --check=crc32 --lzma2=dict=1MiB"
15786 +@@ -315,7 +315,7 @@ if [ ! -z ${output_file} ]; then
15787 + if [ "${is_cpio_compressed}" = "compressed" ]; then
15788 + cat ${cpio_tfile} > ${output_file}
15789 + else
15790 +- (cat ${cpio_tfile} | ${compr} - > ${output_file}) \
15791 ++ (cat ${cpio_tfile} | ${compr} > ${output_file}) \
15792 + || (rm -f ${output_file} ; false)
15793 + fi
15794 + [ -z ${cpio_file} ] && rm ${cpio_tfile}
15795 +--- a/lib/decompress.c
15796 ++++ b/lib/decompress.c
15797 +@@ -47,6 +47,7 @@ static const struct compress_format comp
15798 + { {037, 0236}, "gzip", gunzip },
15799 + { {0x42, 0x5a}, "bzip2", bunzip2 },
15800 + { {0x5d, 0x00}, "lzma", unlzma },
15801 ++ { {0x6d, 0x00}, "lzma-openwrt", unlzma },
15802 + { {0xfd, 0x37}, "xz", unxz },
15803 + { {0x89, 0x4c}, "lzo", unlzo },
15804 + { {0x02, 0x21}, "lz4", unlz4 },
15805 diff --git a/target/linux/generic/patches-3.16/250-netfilter_depends.patch b/target/linux/generic/patches-3.16/250-netfilter_depends.patch
15806 new file mode 100644
15807 index 000000000000..6edd9c6b020e
15808 --- /dev/null
15809 +++ b/target/linux/generic/patches-3.16/250-netfilter_depends.patch
15810 @@ -0,0 +1,18 @@
15811 +--- a/net/netfilter/Kconfig
15812 ++++ b/net/netfilter/Kconfig
15813 +@@ -195,7 +195,6 @@ config NF_CONNTRACK_FTP
15815 + config NF_CONNTRACK_H323
15816 + tristate "H.323 protocol support"
15817 +- depends on (IPV6 || IPV6=n)
15818 + depends on NETFILTER_ADVANCED
15819 + help
15820 + H.323 is a VoIP signalling protocol from ITU-T. As one of the most
15821 +@@ -871,7 +870,6 @@ config NETFILTER_XT_TARGET_SECMARK
15823 + config NETFILTER_XT_TARGET_TCPMSS
15824 + tristate '"TCPMSS" target support'
15825 +- depends on (IPV6 || IPV6=n)
15826 + default m if NETFILTER_ADVANCED=n
15827 + ---help---
15828 + This option adds a `TCPMSS' target, which allows you to alter the
15829 diff --git a/target/linux/generic/patches-3.16/251-sound_kconfig.patch b/target/linux/generic/patches-3.16/251-sound_kconfig.patch
15830 new file mode 100644
15831 index 000000000000..c2ebacecd1ee
15832 --- /dev/null
15833 +++ b/target/linux/generic/patches-3.16/251-sound_kconfig.patch
15834 @@ -0,0 +1,18 @@
15835 +--- a/sound/core/Kconfig
15836 ++++ b/sound/core/Kconfig
15837 +@@ -10,13 +10,13 @@ config SND_DMAENGINE_PCM
15838 + tristate
15840 + config SND_HWDEP
15841 +- tristate
15842 ++ tristate "Sound hardware support"
15844 + config SND_RAWMIDI
15845 + tristate
15847 + config SND_COMPRESS_OFFLOAD
15848 +- tristate
15849 ++ tristate "Compression offloading support"
15851 + # To be effective this also requires INPUT - users should say:
15852 + # select SND_JACK if INPUT=y || INPUT=SND
15853 diff --git a/target/linux/generic/patches-3.16/252-mv_cesa_depends.patch b/target/linux/generic/patches-3.16/252-mv_cesa_depends.patch
15854 new file mode 100644
15855 index 000000000000..fee28db12014
15856 --- /dev/null
15857 +++ b/target/linux/generic/patches-3.16/252-mv_cesa_depends.patch
15858 @@ -0,0 +1,10 @@
15859 +--- a/drivers/crypto/Kconfig
15860 ++++ b/drivers/crypto/Kconfig
15861 +@@ -164,6 +164,7 @@ config CRYPTO_DEV_MV_CESA
15862 + depends on PLAT_ORION
15863 + select CRYPTO_ALGAPI
15864 + select CRYPTO_AES
15865 ++ select CRYPTO_HASH2
15866 + select CRYPTO_BLKCIPHER2
15867 + select CRYPTO_HASH
15868 + help
15869 diff --git a/target/linux/generic/patches-3.16/253-ssb_b43_default_on.patch b/target/linux/generic/patches-3.16/253-ssb_b43_default_on.patch
15870 new file mode 100644
15871 index 000000000000..29d2a41a3b01
15872 --- /dev/null
15873 +++ b/target/linux/generic/patches-3.16/253-ssb_b43_default_on.patch
15874 @@ -0,0 +1,29 @@
15875 +--- a/drivers/ssb/Kconfig
15876 ++++ b/drivers/ssb/Kconfig
15877 +@@ -29,6 +29,7 @@ config SSB_SPROM
15878 + config SSB_BLOCKIO
15879 + bool
15880 + depends on SSB
15881 ++ default y
15883 + config SSB_PCIHOST_POSSIBLE
15884 + bool
15885 +@@ -49,7 +50,7 @@ config SSB_PCIHOST
15886 + config SSB_B43_PCI_BRIDGE
15887 + bool
15888 + depends on SSB_PCIHOST
15889 +- default n
15890 ++ default y
15892 + config SSB_PCMCIAHOST_POSSIBLE
15893 + bool
15894 +--- a/drivers/bcma/Kconfig
15895 ++++ b/drivers/bcma/Kconfig
15896 +@@ -17,6 +17,7 @@ config BCMA
15897 + config BCMA_BLOCKIO
15898 + bool
15899 + depends on BCMA
15900 ++ default y
15902 + config BCMA_HOST_PCI_POSSIBLE
15903 + bool
15904 diff --git a/target/linux/generic/patches-3.16/254-textsearch_kconfig_hacks.patch b/target/linux/generic/patches-3.16/254-textsearch_kconfig_hacks.patch
15905 new file mode 100644
15906 index 000000000000..00e24b4813a8
15907 --- /dev/null
15908 +++ b/target/linux/generic/patches-3.16/254-textsearch_kconfig_hacks.patch
15909 @@ -0,0 +1,23 @@
15910 +--- a/lib/Kconfig
15911 ++++ b/lib/Kconfig
15912 +@@ -308,16 +308,16 @@ config BCH_CONST_T
15913 + # Textsearch support is select'ed if needed
15915 + config TEXTSEARCH
15916 +- boolean
15917 ++ boolean "Textsearch support"
15919 + config TEXTSEARCH_KMP
15920 +- tristate
15921 ++ tristate "Textsearch KMP"
15923 + config TEXTSEARCH_BM
15924 +- tristate
15925 ++ tristate "Textsearch BM"
15927 + config TEXTSEARCH_FSM
15928 +- tristate
15929 ++ tristate "Textsearch FSM"
15931 + config BTREE
15932 + boolean
15933 diff --git a/target/linux/generic/patches-3.16/255-lib80211_kconfig_hacks.patch b/target/linux/generic/patches-3.16/255-lib80211_kconfig_hacks.patch
15934 new file mode 100644
15935 index 000000000000..8cc6ba351333
15936 --- /dev/null
15937 +++ b/target/linux/generic/patches-3.16/255-lib80211_kconfig_hacks.patch
15938 @@ -0,0 +1,19 @@
15939 +--- a/net/wireless/Kconfig
15940 ++++ b/net/wireless/Kconfig
15941 +@@ -149,13 +149,13 @@ config LIB80211
15942 + Drivers should select this themselves if needed.
15944 + config LIB80211_CRYPT_WEP
15945 +- tristate
15946 ++ tristate "LIB80211_CRYPT_WEP"
15948 + config LIB80211_CRYPT_CCMP
15949 +- tristate
15950 ++ tristate "LIB80211_CRYPT_CCMP"
15952 + config LIB80211_CRYPT_TKIP
15953 +- tristate
15954 ++ tristate "LIB80211_CRYPT_TKIP"
15956 + config LIB80211_DEBUG
15957 + bool "lib80211 debugging messages"
15958 diff --git a/target/linux/generic/patches-3.16/256-crypto_add_kconfig_prompts.patch b/target/linux/generic/patches-3.16/256-crypto_add_kconfig_prompts.patch
15959 new file mode 100644
15960 index 000000000000..8462c711f021
15961 --- /dev/null
15962 +++ b/target/linux/generic/patches-3.16/256-crypto_add_kconfig_prompts.patch
15963 @@ -0,0 +1,47 @@
15964 +--- a/crypto/Kconfig
15965 ++++ b/crypto/Kconfig
15966 +@@ -31,7 +31,7 @@ config CRYPTO_FIPS
15967 + this is.
15969 + config CRYPTO_ALGAPI
15970 +- tristate
15971 ++ tristate "ALGAPI"
15972 + select CRYPTO_ALGAPI2
15973 + help
15974 + This option provides the API for cryptographic algorithms.
15975 +@@ -40,7 +40,7 @@ config CRYPTO_ALGAPI2
15976 + tristate
15978 + config CRYPTO_AEAD
15979 +- tristate
15980 ++ tristate "AEAD"
15981 + select CRYPTO_AEAD2
15982 + select CRYPTO_ALGAPI
15984 +@@ -49,7 +49,7 @@ config CRYPTO_AEAD2
15985 + select CRYPTO_ALGAPI2
15987 + config CRYPTO_BLKCIPHER
15988 +- tristate
15989 ++ tristate "BLKCIPHER"
15990 + select CRYPTO_BLKCIPHER2
15991 + select CRYPTO_ALGAPI
15993 +@@ -60,7 +60,7 @@ config CRYPTO_BLKCIPHER2
15994 + select CRYPTO_WORKQUEUE
15996 + config CRYPTO_HASH
15997 +- tristate
15998 ++ tristate "HASH"
15999 + select CRYPTO_HASH2
16000 + select CRYPTO_ALGAPI
16002 +@@ -69,7 +69,7 @@ config CRYPTO_HASH2
16003 + select CRYPTO_ALGAPI2
16005 + config CRYPTO_RNG
16006 +- tristate
16007 ++ tristate "RNG"
16008 + select CRYPTO_RNG2
16009 + select CRYPTO_ALGAPI
16011 diff --git a/target/linux/generic/patches-3.16/257-wireless_ext_kconfig_hack.patch b/target/linux/generic/patches-3.16/257-wireless_ext_kconfig_hack.patch
16012 new file mode 100644
16013 index 000000000000..daac5898aea5
16014 --- /dev/null
16015 +++ b/target/linux/generic/patches-3.16/257-wireless_ext_kconfig_hack.patch
16016 @@ -0,0 +1,22 @@
16017 +--- a/net/wireless/Kconfig
16018 ++++ b/net/wireless/Kconfig
16019 +@@ -1,5 +1,5 @@
16020 + config WIRELESS_EXT
16021 +- bool
16022 ++ bool "Wireless extensions"
16024 + config WEXT_CORE
16025 + def_bool y
16026 +@@ -11,10 +11,10 @@ config WEXT_PROC
16027 + depends on WEXT_CORE
16029 + config WEXT_SPY
16030 +- bool
16031 ++ bool "WEXT_SPY"
16033 + config WEXT_PRIV
16034 +- bool
16035 ++ bool "WEXT_PRIV"
16037 + config CFG80211
16038 + tristate "cfg80211 - wireless configuration API"
16039 diff --git a/target/linux/generic/patches-3.16/258-netfilter_netlink_kconfig_hack.patch b/target/linux/generic/patches-3.16/258-netfilter_netlink_kconfig_hack.patch
16040 new file mode 100644
16041 index 000000000000..9d827c253b25
16042 --- /dev/null
16043 +++ b/target/linux/generic/patches-3.16/258-netfilter_netlink_kconfig_hack.patch
16044 @@ -0,0 +1,11 @@
16045 +--- a/net/netfilter/Kconfig
16046 ++++ b/net/netfilter/Kconfig
16047 +@@ -2,7 +2,7 @@ menu "Core Netfilter Configuration"
16048 + depends on NET && INET && NETFILTER
16050 + config NETFILTER_NETLINK
16051 +- tristate
16052 ++ tristate "Netfilter NFNETLINK interface"
16054 + config NETFILTER_NETLINK_ACCT
16055 + tristate "Netfilter NFACCT over NFNETLINK interface"
16056 diff --git a/target/linux/generic/patches-3.16/259-regmap_dynamic.patch b/target/linux/generic/patches-3.16/259-regmap_dynamic.patch
16057 new file mode 100644
16058 index 000000000000..e7f5bcee97aa
16059 --- /dev/null
16060 +++ b/target/linux/generic/patches-3.16/259-regmap_dynamic.patch
16061 @@ -0,0 +1,76 @@
16062 +--- a/drivers/base/regmap/Kconfig
16063 ++++ b/drivers/base/regmap/Kconfig
16064 +@@ -3,23 +3,28 @@
16065 + # subsystems should select the appropriate symbols.
16067 + config REGMAP
16068 +- default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_MMIO || REGMAP_IRQ)
16069 + select LZO_COMPRESS
16070 + select LZO_DECOMPRESS
16071 + select IRQ_DOMAIN if REGMAP_IRQ
16072 +- bool
16073 ++ tristate "Regmap"
16075 + config REGMAP_I2C
16076 +- tristate
16077 ++ select REGMAP
16078 ++ tristate "Regmap I2C
16080 + config REGMAP_SPI
16081 +- tristate
16082 ++ select REGMAP
16083 ++ depends on SPI_MASTER
16084 ++ tristate "Regmap SPI"
16086 + config REGMAP_SPMI
16087 ++ select REGMAP
16088 + tristate
16090 + config REGMAP_MMIO
16091 ++ select REGMAP
16092 + tristate
16094 + config REGMAP_IRQ
16095 ++ select REGMAP
16096 + bool
16097 +--- a/include/linux/regmap.h
16098 ++++ b/include/linux/regmap.h
16099 +@@ -49,7 +49,7 @@ struct reg_default {
16100 + unsigned int def;
16101 + };
16103 +-#ifdef CONFIG_REGMAP
16104 ++#if IS_ENABLED(CONFIG_REGMAP)
16106 + enum regmap_endian {
16107 + /* Unspecified -> 0 -> Backwards compatible default */
16108 +--- a/drivers/base/regmap/Makefile
16109 ++++ b/drivers/base/regmap/Makefile
16110 +@@ -1,6 +1,8 @@
16111 +-obj-$(CONFIG_REGMAP) += regmap.o regcache.o
16112 +-obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o regcache-flat.o
16113 +-obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
16114 ++regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-lzo.o regcache-flat.o
16115 ++ifdef CONFIG_DEBUG_FS
16116 ++regmap-core-objs += regmap-debugfs.o
16117 ++endif
16118 ++obj-$(CONFIG_REGMAP) += regmap-core.o
16119 + obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
16120 + obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o
16121 + obj-$(CONFIG_REGMAP_SPMI) += regmap-spmi.o
16122 +--- a/drivers/base/regmap/regmap.c
16123 ++++ b/drivers/base/regmap/regmap.c
16124 +@@ -13,6 +13,7 @@
16125 + #include <linux/device.h>
16126 + #include <linux/slab.h>
16127 + #include <linux/export.h>
16128 ++#include <linux/module.h>
16129 + #include <linux/mutex.h>
16130 + #include <linux/err.h>
16131 + #include <linux/rbtree.h>
16132 +@@ -2247,3 +2248,5 @@ static int __init regmap_initcall(void)
16133 + return 0;
16135 + postcore_initcall(regmap_initcall);
16137 ++MODULE_LICENSE("GPL");
16138 diff --git a/target/linux/generic/patches-3.16/260-crypto_test_dependencies.patch b/target/linux/generic/patches-3.16/260-crypto_test_dependencies.patch
16139 new file mode 100644
16140 index 000000000000..a28f69308c26
16141 --- /dev/null
16142 +++ b/target/linux/generic/patches-3.16/260-crypto_test_dependencies.patch
16143 @@ -0,0 +1,37 @@
16144 +--- a/crypto/Kconfig
16145 ++++ b/crypto/Kconfig
16146 +@@ -95,10 +95,10 @@ config CRYPTO_MANAGER
16148 + config CRYPTO_MANAGER2
16149 + def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y)
16150 +- select CRYPTO_AEAD2
16151 +- select CRYPTO_HASH2
16152 +- select CRYPTO_BLKCIPHER2
16153 +- select CRYPTO_PCOMP2
16154 ++ select CRYPTO_AEAD2 if !CRYPTO_MANAGER_DISABLE_TESTS
16155 ++ select CRYPTO_HASH2 if !CRYPTO_MANAGER_DISABLE_TESTS
16156 ++ select CRYPTO_BLKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS
16157 ++ select CRYPTO_PCOMP2 if !CRYPTO_MANAGER_DISABLE_TESTS
16159 + config CRYPTO_USER
16160 + tristate "Userspace cryptographic algorithm configuration"
16161 +--- a/crypto/algboss.c
16162 ++++ b/crypto/algboss.c
16163 +@@ -248,6 +248,9 @@ static int cryptomgr_schedule_test(struc
16164 + type = alg->cra_flags;
16166 + /* This piece of crap needs to disappear into per-type test hooks. */
16167 ++#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
16168 ++ type |= CRYPTO_ALG_TESTED;
16169 ++#else
16170 + if ((!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) &
16171 + CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV) &&
16172 + ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
16173 +@@ -256,6 +259,7 @@ static int cryptomgr_schedule_test(struc
16174 + (!((type ^ CRYPTO_ALG_TYPE_AEAD) & CRYPTO_ALG_TYPE_MASK) &&
16175 + alg->cra_type == &crypto_nivaead_type && alg->cra_aead.ivsize))
16176 + type |= CRYPTO_ALG_TESTED;
16177 ++#endif
16179 + param->type = type;
16181 diff --git a/target/linux/generic/patches-3.16/261-move_bcm963xx_tag.patch b/target/linux/generic/patches-3.16/261-move_bcm963xx_tag.patch
16182 new file mode 100644
16183 index 000000000000..96f2ad209b71
16184 --- /dev/null
16185 +++ b/target/linux/generic/patches-3.16/261-move_bcm963xx_tag.patch
16186 @@ -0,0 +1,219 @@
16187 +--- a/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h
16188 ++++ /dev/null
16189 +@@ -1,96 +0,0 @@
16190 +-#ifndef __BCM963XX_TAG_H
16191 +-#define __BCM963XX_TAG_H
16193 +-#define TAGVER_LEN 4 /* Length of Tag Version */
16194 +-#define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */
16195 +-#define SIG1_LEN 20 /* Company Signature 1 Length */
16196 +-#define SIG2_LEN 14 /* Company Signature 2 Length */
16197 +-#define BOARDID_LEN 16 /* Length of BoardId */
16198 +-#define ENDIANFLAG_LEN 2 /* Endian Flag Length */
16199 +-#define CHIPID_LEN 6 /* Chip Id Length */
16200 +-#define IMAGE_LEN 10 /* Length of Length Field */
16201 +-#define ADDRESS_LEN 12 /* Length of Address field */
16202 +-#define DUALFLAG_LEN 2 /* Dual Image flag Length */
16203 +-#define INACTIVEFLAG_LEN 2 /* Inactie Flag Length */
16204 +-#define RSASIG_LEN 20 /* Length of RSA Signature in tag */
16205 +-#define TAGINFO1_LEN 30 /* Length of vendor information field1 in tag */
16206 +-#define FLASHLAYOUTVER_LEN 4 /* Length of Flash Layout Version String tag */
16207 +-#define TAGINFO2_LEN 16 /* Length of vendor information field2 in tag */
16208 +-#define ALTTAGINFO_LEN 54 /* Alternate length for vendor information; Pirelli */
16210 +-#define NUM_PIRELLI 2
16211 +-#define IMAGETAG_CRC_START 0xFFFFFFFF
16213 +-#define PIRELLI_BOARDS { \
16214 +- "AGPF-S0", \
16215 +- "DWV-S0", \
16218 +-/*
16219 +- * The broadcom firmware assumes the rootfs starts the image,
16220 +- * therefore uses the rootfs start (flash_image_address)
16221 +- * to determine where to flash the image. Since we have the kernel first
16222 +- * we have to give it the kernel address, but the crc uses the length
16223 +- * associated with this address (root_length), which is added to the kernel
16224 +- * length (kernel_length) to determine the length of image to flash and thus
16225 +- * needs to be rootfs + deadcode (jffs2 EOF marker)
16226 +-*/
16228 +-struct bcm_tag {
16229 +- /* 0-3: Version of the image tag */
16230 +- char tag_version[TAGVER_LEN];
16231 +- /* 4-23: Company Line 1 */
16232 +- char sig_1[SIG1_LEN];
16233 +- /* 24-37: Company Line 2 */
16234 +- char sig_2[SIG2_LEN];
16235 +- /* 38-43: Chip this image is for */
16236 +- char chip_id[CHIPID_LEN];
16237 +- /* 44-59: Board name */
16238 +- char board_id[BOARDID_LEN];
16239 +- /* 60-61: Map endianness -- 1 BE 0 LE */
16240 +- char big_endian[ENDIANFLAG_LEN];
16241 +- /* 62-71: Total length of image */
16242 +- char total_length[IMAGE_LEN];
16243 +- /* 72-83: Address in memory of CFE */
16244 +- char cfe__address[ADDRESS_LEN];
16245 +- /* 84-93: Size of CFE */
16246 +- char cfe_length[IMAGE_LEN];
16247 +- /* 94-105: Address in memory of image start
16248 +- * (kernel for OpenWRT, rootfs for stock firmware)
16249 +- */
16250 +- char flash_image_start[ADDRESS_LEN];
16251 +- /* 106-115: Size of rootfs */
16252 +- char root_length[IMAGE_LEN];
16253 +- /* 116-127: Address in memory of kernel */
16254 +- char kernel_address[ADDRESS_LEN];
16255 +- /* 128-137: Size of kernel */
16256 +- char kernel_length[IMAGE_LEN];
16257 +- /* 138-139: Unused at the moment */
16258 +- char dual_image[DUALFLAG_LEN];
16259 +- /* 140-141: Unused at the moment */
16260 +- char inactive_flag[INACTIVEFLAG_LEN];
16261 +- /* 142-161: RSA Signature (not used; some vendors may use this) */
16262 +- char rsa_signature[RSASIG_LEN];
16263 +- /* 162-191: Compilation and related information (not used in OpenWrt) */
16264 +- char information1[TAGINFO1_LEN];
16265 +- /* 192-195: Version flash layout */
16266 +- char flash_layout_ver[FLASHLAYOUTVER_LEN];
16267 +- /* 196-199: kernel+rootfs CRC32 */
16268 +- __u32 fskernel_crc;
16269 +- /* 200-215: Unused except on Alice Gate where is is information */
16270 +- char information2[TAGINFO2_LEN];
16271 +- /* 216-219: CRC32 of image less imagetag (kernel for Alice Gate) */
16272 +- __u32 image_crc;
16273 +- /* 220-223: CRC32 of rootfs partition */
16274 +- __u32 rootfs_crc;
16275 +- /* 224-227: CRC32 of kernel partition */
16276 +- __u32 kernel_crc;
16277 +- /* 228-235: Unused at present */
16278 +- char reserved1[8];
16279 +- /* 236-239: CRC32 of header excluding last 20 bytes */
16280 +- __u32 header_crc;
16281 +- /* 240-255: Unused at present */
16282 +- char reserved2[16];
16283 +-};
16285 +-#endif /* __BCM63XX_TAG_H */
16286 +--- a/drivers/mtd/bcm63xxpart.c
16287 ++++ b/drivers/mtd/bcm63xxpart.c
16288 +@@ -34,7 +34,7 @@
16289 + #include <linux/mtd/partitions.h>
16291 + #include <asm/mach-bcm63xx/bcm63xx_nvram.h>
16292 +-#include <asm/mach-bcm63xx/bcm963xx_tag.h>
16293 ++#include <linux/bcm963xx_tag.h>
16294 + #include <asm/mach-bcm63xx/board_bcm963xx.h>
16296 + #define BCM63XX_EXTENDED_SIZE 0xBFC00000 /* Extended flash address */
16297 +--- a/include/uapi/linux/Kbuild
16298 ++++ b/include/uapi/linux/Kbuild
16299 +@@ -68,6 +68,7 @@ header-y += binfmts.h
16300 + header-y += blkpg.h
16301 + header-y += blktrace_api.h
16302 + header-y += bpqether.h
16303 ++header-y += bcm963xx_tag.h
16304 + header-y += bsg.h
16305 + header-y += btrfs.h
16306 + header-y += can.h
16307 +--- /dev/null
16308 ++++ b/include/uapi/linux/bcm963xx_tag.h
16309 +@@ -0,0 +1,96 @@
16310 ++#ifndef __BCM963XX_TAG_H
16311 ++#define __BCM963XX_TAG_H
16313 ++#define TAGVER_LEN 4 /* Length of Tag Version */
16314 ++#define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */
16315 ++#define SIG1_LEN 20 /* Company Signature 1 Length */
16316 ++#define SIG2_LEN 14 /* Company Signature 2 Length */
16317 ++#define BOARDID_LEN 16 /* Length of BoardId */
16318 ++#define ENDIANFLAG_LEN 2 /* Endian Flag Length */
16319 ++#define CHIPID_LEN 6 /* Chip Id Length */
16320 ++#define IMAGE_LEN 10 /* Length of Length Field */
16321 ++#define ADDRESS_LEN 12 /* Length of Address field */
16322 ++#define DUALFLAG_LEN 2 /* Dual Image flag Length */
16323 ++#define INACTIVEFLAG_LEN 2 /* Inactie Flag Length */
16324 ++#define RSASIG_LEN 20 /* Length of RSA Signature in tag */
16325 ++#define TAGINFO1_LEN 30 /* Length of vendor information field1 in tag */
16326 ++#define FLASHLAYOUTVER_LEN 4 /* Length of Flash Layout Version String tag */
16327 ++#define TAGINFO2_LEN 16 /* Length of vendor information field2 in tag */
16328 ++#define ALTTAGINFO_LEN 54 /* Alternate length for vendor information; Pirelli */
16330 ++#define NUM_PIRELLI 2
16331 ++#define IMAGETAG_CRC_START 0xFFFFFFFF
16333 ++#define PIRELLI_BOARDS { \
16334 ++ "AGPF-S0", \
16335 ++ "DWV-S0", \
16338 ++/*
16339 ++ * The broadcom firmware assumes the rootfs starts the image,
16340 ++ * therefore uses the rootfs start (flash_image_address)
16341 ++ * to determine where to flash the image. Since we have the kernel first
16342 ++ * we have to give it the kernel address, but the crc uses the length
16343 ++ * associated with this address (root_length), which is added to the kernel
16344 ++ * length (kernel_length) to determine the length of image to flash and thus
16345 ++ * needs to be rootfs + deadcode (jffs2 EOF marker)
16346 ++*/
16348 ++struct bcm_tag {
16349 ++ /* 0-3: Version of the image tag */
16350 ++ char tag_version[TAGVER_LEN];
16351 ++ /* 4-23: Company Line 1 */
16352 ++ char sig_1[SIG1_LEN];
16353 ++ /* 24-37: Company Line 2 */
16354 ++ char sig_2[SIG2_LEN];
16355 ++ /* 38-43: Chip this image is for */
16356 ++ char chip_id[CHIPID_LEN];
16357 ++ /* 44-59: Board name */
16358 ++ char board_id[BOARDID_LEN];
16359 ++ /* 60-61: Map endianness -- 1 BE 0 LE */
16360 ++ char big_endian[ENDIANFLAG_LEN];
16361 ++ /* 62-71: Total length of image */
16362 ++ char total_length[IMAGE_LEN];
16363 ++ /* 72-83: Address in memory of CFE */
16364 ++ char cfe__address[ADDRESS_LEN];
16365 ++ /* 84-93: Size of CFE */
16366 ++ char cfe_length[IMAGE_LEN];
16367 ++ /* 94-105: Address in memory of image start
16368 ++ * (kernel for OpenWRT, rootfs for stock firmware)
16369 ++ */
16370 ++ char flash_image_start[ADDRESS_LEN];
16371 ++ /* 106-115: Size of rootfs */
16372 ++ char root_length[IMAGE_LEN];
16373 ++ /* 116-127: Address in memory of kernel */
16374 ++ char kernel_address[ADDRESS_LEN];
16375 ++ /* 128-137: Size of kernel */
16376 ++ char kernel_length[IMAGE_LEN];
16377 ++ /* 138-139: Unused at the moment */
16378 ++ char dual_image[DUALFLAG_LEN];
16379 ++ /* 140-141: Unused at the moment */
16380 ++ char inactive_flag[INACTIVEFLAG_LEN];
16381 ++ /* 142-161: RSA Signature (not used; some vendors may use this) */
16382 ++ char rsa_signature[RSASIG_LEN];
16383 ++ /* 162-191: Compilation and related information (not used in OpenWrt) */
16384 ++ char information1[TAGINFO1_LEN];
16385 ++ /* 192-195: Version flash layout */
16386 ++ char flash_layout_ver[FLASHLAYOUTVER_LEN];
16387 ++ /* 196-199: kernel+rootfs CRC32 */
16388 ++ __u32 fskernel_crc;
16389 ++ /* 200-215: Unused except on Alice Gate where is is information */
16390 ++ char information2[TAGINFO2_LEN];
16391 ++ /* 216-219: CRC32 of image less imagetag (kernel for Alice Gate) */
16392 ++ __u32 image_crc;
16393 ++ /* 220-223: CRC32 of rootfs partition */
16394 ++ __u32 rootfs_crc;
16395 ++ /* 224-227: CRC32 of kernel partition */
16396 ++ __u32 kernel_crc;
16397 ++ /* 228-235: Unused at present */
16398 ++ char reserved1[8];
16399 ++ /* 236-239: CRC32 of header excluding last 20 bytes */
16400 ++ __u32 header_crc;
16401 ++ /* 240-255: Unused at present */
16402 ++ char reserved2[16];
16403 ++};
16405 ++#endif /* __BCM63XX_TAG_H */
16406 diff --git a/target/linux/generic/patches-3.16/262-compressor_kconfig_hack.patch b/target/linux/generic/patches-3.16/262-compressor_kconfig_hack.patch
16407 new file mode 100644
16408 index 000000000000..654608fcf0f9
16409 --- /dev/null
16410 +++ b/target/linux/generic/patches-3.16/262-compressor_kconfig_hack.patch
16411 @@ -0,0 +1,23 @@
16412 +--- a/lib/Kconfig
16413 ++++ b/lib/Kconfig
16414 +@@ -193,16 +193,16 @@ config RANDOM32_SELFTEST
16415 + # compression support is select'ed if needed
16417 + config ZLIB_INFLATE
16418 +- tristate
16419 ++ tristate "ZLIB inflate support"
16421 + config ZLIB_DEFLATE
16422 +- tristate
16423 ++ tristate "ZLIB deflate support"
16425 + config LZO_COMPRESS
16426 +- tristate
16427 ++ tristate "LZO compress support"
16429 + config LZO_DECOMPRESS
16430 +- tristate
16431 ++ tristate "LZO decompress support"
16433 + config LZ4_COMPRESS
16434 + tristate
16435 diff --git a/target/linux/generic/patches-3.16/300-mips_expose_boot_raw.patch b/target/linux/generic/patches-3.16/300-mips_expose_boot_raw.patch
16436 new file mode 100644
16437 index 000000000000..4b4ac951a145
16438 --- /dev/null
16439 +++ b/target/linux/generic/patches-3.16/300-mips_expose_boot_raw.patch
16440 @@ -0,0 +1,39 @@
16441 +From: Mark Miller <mark@mirell.org>
16443 +This exposes the CONFIG_BOOT_RAW symbol in Kconfig. This is needed on
16444 +certain Broadcom chipsets running CFE in order to load the kernel.
16446 +Signed-off-by: Mark Miller <mark@mirell.org>
16447 +Acked-by: Rob Landley <rob@landley.net>
16448 +---
16449 +--- a/arch/mips/Kconfig
16450 ++++ b/arch/mips/Kconfig
16451 +@@ -852,9 +852,6 @@ config FW_ARC
16452 + config ARCH_MAY_HAVE_PC_FDC
16453 + bool
16455 +-config BOOT_RAW
16456 +- bool
16458 + config CEVT_BCM1480
16459 + bool
16461 +@@ -2384,6 +2381,18 @@ config USE_OF
16462 + select OF_EARLY_FLATTREE
16463 + select IRQ_DOMAIN
16465 ++config BOOT_RAW
16466 ++ bool "Enable the kernel to be executed from the load address"
16467 ++ default n
16468 ++ help
16469 ++ Allow the kernel to be executed from the load address for
16470 ++ bootloaders which cannot read the ELF format. This places
16471 ++ a jump to start_kernel at the load address.
16473 ++ If unsure, say N.
16477 + endmenu
16479 + config LOCKDEP_SUPPORT
16480 diff --git a/target/linux/generic/patches-3.16/301-mips_image_cmdline_hack.patch b/target/linux/generic/patches-3.16/301-mips_image_cmdline_hack.patch
16481 new file mode 100644
16482 index 000000000000..60571cb8e0b2
16483 --- /dev/null
16484 +++ b/target/linux/generic/patches-3.16/301-mips_image_cmdline_hack.patch
16485 @@ -0,0 +1,28 @@
16486 +--- a/arch/mips/Kconfig
16487 ++++ b/arch/mips/Kconfig
16488 +@@ -946,6 +946,10 @@ config SYNC_R4K
16489 + config MIPS_MACHINE
16490 + def_bool n
16492 ++config IMAGE_CMDLINE_HACK
16493 ++ bool "OpenWrt specific image command line hack"
16494 ++ default n
16496 + config NO_IOPORT_MAP
16497 + def_bool n
16499 +--- a/arch/mips/kernel/head.S
16500 ++++ b/arch/mips/kernel/head.S
16501 +@@ -101,6 +101,12 @@ FEXPORT(__kernel_entry)
16502 + j kernel_entry
16503 + #endif
16505 ++#ifdef CONFIG_IMAGE_CMDLINE_HACK
16506 ++ .ascii "CMDLINE:"
16507 ++EXPORT(__image_cmdline)
16508 ++ .fill 0x400
16509 ++#endif /* CONFIG_IMAGE_CMDLINE_HACK */
16511 + __REF
16513 + NESTED(kernel_entry, 16, sp) # kernel entry point
16514 diff --git a/target/linux/generic/patches-3.16/302-mips_no_branch_likely.patch b/target/linux/generic/patches-3.16/302-mips_no_branch_likely.patch
16515 new file mode 100644
16516 index 000000000000..19adcb800b92
16517 --- /dev/null
16518 +++ b/target/linux/generic/patches-3.16/302-mips_no_branch_likely.patch
16519 @@ -0,0 +1,11 @@
16520 +--- a/arch/mips/Makefile
16521 ++++ b/arch/mips/Makefile
16522 +@@ -87,7 +87,7 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
16523 + # machines may also. Since BFD is incredibly buggy with respect to
16524 + # crossformat linking we rely on the elf2ecoff tool for format conversion.
16526 +-cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
16527 ++cflags-y += -G 0 -mno-abicalls -fno-pic -pipe -mno-branch-likely
16528 + cflags-y += -msoft-float
16529 + LDFLAGS_vmlinux += -G 0 -static -n -nostdlib --gc-sections --sort-section=name
16530 + KBUILD_AFLAGS_MODULE += -mlong-calls
16531 diff --git a/target/linux/generic/patches-3.16/304-mips_disable_fpu.patch b/target/linux/generic/patches-3.16/304-mips_disable_fpu.patch
16532 new file mode 100644
16533 index 000000000000..2dd3ce233012
16534 --- /dev/null
16535 +++ b/target/linux/generic/patches-3.16/304-mips_disable_fpu.patch
16536 @@ -0,0 +1,129 @@
16537 +MIPS: allow disabling the kernel FPU emulator
16539 +This patch allows turning off the in-kernel Algorithmics
16540 +FPU emulator support, which allows one to save a couple of
16541 +precious blocks on an embedded system.
16543 +Signed-off-by: Florian Fainelli <florian@openwrt.org>
16545 +--- a/arch/mips/Kconfig
16546 ++++ b/arch/mips/Kconfig
16547 +@@ -969,6 +969,17 @@ config I8259
16548 + config MIPS_BONITO64
16549 + bool
16551 ++config MIPS_FPU_EMU
16552 ++ bool "Enable FPU emulation"
16553 ++ default y
16554 ++ help
16555 ++ This option allows building a kernel with or without the Algorithmics
16556 ++ FPU emulator enabled. Turning off this option results in a kernel which
16557 ++ does not catch floating operations exceptions. Make sure that your toolchain
16558 ++ is configured to enable software floating point emulation in that case.
16560 ++ If unsure say Y here.
16562 + config MIPS_MSC
16563 + bool
16565 +--- a/arch/mips/math-emu/Makefile
16566 ++++ b/arch/mips/math-emu/Makefile
16567 +@@ -2,7 +2,7 @@
16568 + # Makefile for the Linux/MIPS kernel FPU emulation.
16571 +-obj-y += cp1emu.o ieee754dp.o ieee754sp.o ieee754.o dp_div.o dp_mul.o \
16572 ++obj-$(CONFIG_MIPS_FPU_EMU) += cp1emu.o ieee754dp.o ieee754sp.o ieee754.o dp_div.o dp_mul.o \
16573 + dp_sub.o dp_add.o dp_fsp.o dp_cmp.o dp_simple.o dp_tint.o \
16574 + dp_fint.o dp_tlong.o dp_flong.o sp_div.o sp_mul.o sp_sub.o \
16575 + sp_add.o sp_fdp.o sp_cmp.o sp_simple.o sp_tint.o sp_fint.o \
16576 +--- a/arch/mips/include/asm/fpu_emulator.h
16577 ++++ b/arch/mips/include/asm/fpu_emulator.h
16578 +@@ -30,6 +30,8 @@
16579 + #include <asm/local.h>
16580 + #include <asm/processor.h>
16582 ++#ifdef CONFIG_MIPS_FPU_EMU
16584 + #ifdef CONFIG_DEBUG_FS
16586 + struct mips_fpu_emulator_stats {
16587 +@@ -68,6 +70,38 @@ extern int fpu_emulator_cop1Handler(stru
16588 + int process_fpemu_return(int sig, void __user *fault_addr);
16589 + int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
16590 + unsigned long *contpc);
16591 ++#else
16592 ++static inline int mips_dsemul(struct pt_regs *regs, mips_instruction ir,
16593 ++ unsigned long cpc)
16595 ++ return 0;
16598 ++static inline int do_dsemulret(struct pt_regs *xcp)
16600 ++ return 0;
16603 ++static inline int fpu_emulator_cop1Handler(struct pt_regs *xcp,
16604 ++ struct mips_fpu_struct *ctx,
16605 ++ int has_fpu,
16606 ++ void *__user *fault_addr)
16608 ++ return 0;
16611 ++static inline int process_fpemu_return(int sig, void __user *fault_addr)
16613 ++ return -EINVAL;
16616 ++static inline int mm_isBranchInstr(struct pt_regs *regs,
16617 ++ struct mm_decoded_insn dec_insn,
16618 ++ unsigned long *contpc)
16620 ++ return 0;
16622 ++#endif /* CONFIG_MIPS_FPU_EMU */
16624 + /*
16625 + * Instruction inserted following the badinst to further tag the sequence
16626 +@@ -81,6 +115,7 @@ int mm_isBranchInstr(struct pt_regs *reg
16628 + #define SIGNALLING_NAN 0x7ff800007ff80000LL
16630 ++#ifdef CONFIG_MIPS_FPU_EMU
16631 + static inline void fpu_emulator_init_fpu(void)
16633 + struct task_struct *t = current;
16634 +@@ -91,5 +126,13 @@ static inline void fpu_emulator_init_fpu
16635 + for (i = 0; i < 32; i++)
16636 + set_fpr64(&t->thread.fpu.fpr[i], 0, SIGNALLING_NAN);
16638 ++#else
16639 ++static inline void fpu_emulator_init_fpu(void)
16641 ++ printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
16642 ++ "was compiled with software floating point support (soft-float)\n");
16643 ++ return;
16645 ++#endif /* CONFIG_MIPS_FPU_EMU */
16647 + #endif /* _ASM_FPU_EMULATOR_H */
16648 +--- a/arch/mips/kernel/traps.c
16649 ++++ b/arch/mips/kernel/traps.c
16650 +@@ -697,6 +697,7 @@ asmlinkage void do_ov(struct pt_regs *re
16651 + exception_exit(prev_state);
16654 ++#ifdef CONFIG_MIPS_FPU_EMU
16655 + int process_fpemu_return(int sig, void __user *fault_addr)
16657 + if (sig == SIGSEGV || sig == SIGBUS) {
16658 +@@ -722,6 +723,7 @@ int process_fpemu_return(int sig, void _
16659 + return 0;
16662 ++#endif /* CONFIG_MIPS_FPU_EMU */
16664 + /*
16665 + * XXX Delayed fp exceptions when doing a lazy ctx switch XXX
16666 diff --git a/target/linux/generic/patches-3.16/305-mips_module_reloc.patch b/target/linux/generic/patches-3.16/305-mips_module_reloc.patch
16667 new file mode 100644
16668 index 000000000000..2e92916f9703
16669 --- /dev/null
16670 +++ b/target/linux/generic/patches-3.16/305-mips_module_reloc.patch
16671 @@ -0,0 +1,352 @@
16672 +--- a/arch/mips/Makefile
16673 ++++ b/arch/mips/Makefile
16674 +@@ -90,8 +90,13 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
16675 + cflags-y += -G 0 -mno-abicalls -fno-pic -pipe -mno-branch-likely
16676 + cflags-y += -msoft-float
16677 + LDFLAGS_vmlinux += -G 0 -static -n -nostdlib --gc-sections --sort-section=name
16678 ++ifdef CONFIG_64BIT
16679 + KBUILD_AFLAGS_MODULE += -mlong-calls
16680 + KBUILD_CFLAGS_MODULE += -mlong-calls
16681 ++else
16682 ++KBUILD_AFLAGS_MODULE += -mno-long-calls
16683 ++KBUILD_CFLAGS_MODULE += -mno-long-calls
16684 ++endif
16686 + ifndef CONFIG_FUNCTION_TRACER
16687 + KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
16688 +--- a/arch/mips/include/asm/module.h
16689 ++++ b/arch/mips/include/asm/module.h
16690 +@@ -11,6 +11,11 @@ struct mod_arch_specific {
16691 + const struct exception_table_entry *dbe_start;
16692 + const struct exception_table_entry *dbe_end;
16693 + struct mips_hi16 *r_mips_hi16_list;
16695 ++ void *phys_plt_tbl;
16696 ++ void *virt_plt_tbl;
16697 ++ unsigned int phys_plt_offset;
16698 ++ unsigned int virt_plt_offset;
16699 + };
16701 + typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */
16702 +--- a/arch/mips/kernel/module.c
16703 ++++ b/arch/mips/kernel/module.c
16704 +@@ -43,14 +43,222 @@ struct mips_hi16 {
16705 + static LIST_HEAD(dbe_list);
16706 + static DEFINE_SPINLOCK(dbe_lock);
16708 +-#ifdef MODULE_START
16709 ++/*
16710 ++ * Get the potential max trampolines size required of the init and
16711 ++ * non-init sections. Only used if we cannot find enough contiguous
16712 ++ * physically mapped memory to put the module into.
16713 ++ */
16714 ++static unsigned int
16715 ++get_plt_size(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
16716 ++ const char *secstrings, unsigned int symindex, bool is_init)
16718 ++ unsigned long ret = 0;
16719 ++ unsigned int i, j;
16720 ++ Elf_Sym *syms;
16722 ++ /* Everything marked ALLOC (this includes the exported symbols) */
16723 ++ for (i = 1; i < hdr->e_shnum; ++i) {
16724 ++ unsigned int info = sechdrs[i].sh_info;
16726 ++ if (sechdrs[i].sh_type != SHT_REL
16727 ++ && sechdrs[i].sh_type != SHT_RELA)
16728 ++ continue;
16730 ++ /* Not a valid relocation section? */
16731 ++ if (info >= hdr->e_shnum)
16732 ++ continue;
16734 ++ /* Don't bother with non-allocated sections */
16735 ++ if (!(sechdrs[info].sh_flags & SHF_ALLOC))
16736 ++ continue;
16738 ++ /* If it's called *.init*, and we're not init, we're
16739 ++ not interested */
16740 ++ if ((strstr(secstrings + sechdrs[i].sh_name, ".init") != 0)
16741 ++ != is_init)
16742 ++ continue;
16744 ++ syms = (Elf_Sym *) sechdrs[symindex].sh_addr;
16745 ++ if (sechdrs[i].sh_type == SHT_REL) {
16746 ++ Elf_Mips_Rel *rel = (void *) sechdrs[i].sh_addr;
16747 ++ unsigned int size = sechdrs[i].sh_size / sizeof(*rel);
16749 ++ for (j = 0; j < size; ++j) {
16750 ++ Elf_Sym *sym;
16752 ++ if (ELF_MIPS_R_TYPE(rel[j]) != R_MIPS_26)
16753 ++ continue;
16755 ++ sym = syms + ELF_MIPS_R_SYM(rel[j]);
16756 ++ if (!is_init && sym->st_shndx != SHN_UNDEF)
16757 ++ continue;
16759 ++ ret += 4 * sizeof(int);
16760 ++ }
16761 ++ } else {
16762 ++ Elf_Mips_Rela *rela = (void *) sechdrs[i].sh_addr;
16763 ++ unsigned int size = sechdrs[i].sh_size / sizeof(*rela);
16765 ++ for (j = 0; j < size; ++j) {
16766 ++ Elf_Sym *sym;
16768 ++ if (ELF_MIPS_R_TYPE(rela[j]) != R_MIPS_26)
16769 ++ continue;
16771 ++ sym = syms + ELF_MIPS_R_SYM(rela[j]);
16772 ++ if (!is_init && sym->st_shndx != SHN_UNDEF)
16773 ++ continue;
16775 ++ ret += 4 * sizeof(int);
16776 ++ }
16777 ++ }
16778 ++ }
16780 ++ return ret;
16783 ++#ifndef MODULE_START
16784 ++static void *alloc_phys(unsigned long size)
16786 ++ unsigned order;
16787 ++ struct page *page;
16788 ++ struct page *p;
16790 ++ size = PAGE_ALIGN(size);
16791 ++ order = get_order(size);
16793 ++ page = alloc_pages(GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN |
16794 ++ __GFP_THISNODE, order);
16795 ++ if (!page)
16796 ++ return NULL;
16798 ++ split_page(page, order);
16800 ++ for (p = page + (size >> PAGE_SHIFT); p < page + (1 << order); ++p)
16801 ++ __free_page(p);
16803 ++ return page_address(page);
16805 ++#endif
16807 ++static void free_phys(void *ptr, unsigned long size)
16809 ++ struct page *page;
16810 ++ struct page *end;
16812 ++ page = virt_to_page(ptr);
16813 ++ end = page + (PAGE_ALIGN(size) >> PAGE_SHIFT);
16815 ++ for (; page < end; ++page)
16816 ++ __free_page(page);
16820 + void *module_alloc(unsigned long size)
16822 ++#ifdef MODULE_START
16823 + return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END,
16824 + GFP_KERNEL, PAGE_KERNEL, NUMA_NO_NODE,
16825 + __builtin_return_address(0));
16826 ++#else
16827 ++ void *ptr;
16829 ++ if (size == 0)
16830 ++ return NULL;
16832 ++ ptr = alloc_phys(size);
16834 ++ /* If we failed to allocate physically contiguous memory,
16835 ++ * fall back to regular vmalloc. The module loader code will
16836 ++ * create jump tables to handle long jumps */
16837 ++ if (!ptr)
16838 ++ return vmalloc(size);
16840 ++ return ptr;
16841 ++#endif
16844 ++static inline bool is_phys_addr(void *ptr)
16846 ++#ifdef CONFIG_64BIT
16847 ++ return (KSEGX((unsigned long)ptr) == CKSEG0);
16848 ++#else
16849 ++ return (KSEGX(ptr) == KSEG0);
16850 + #endif
16853 ++/* Free memory returned from module_alloc */
16854 ++void module_free(struct module *mod, void *module_region)
16856 ++ if (is_phys_addr(module_region)) {
16857 ++ if (mod->module_init == module_region)
16858 ++ free_phys(module_region, mod->init_size);
16859 ++ else if (mod->module_core == module_region)
16860 ++ free_phys(module_region, mod->core_size);
16861 ++ else
16862 ++ BUG();
16863 ++ } else {
16864 ++ vfree(module_region);
16865 ++ }
16868 ++static void *__module_alloc(int size, bool phys)
16870 ++ void *ptr;
16872 ++ if (phys)
16873 ++ ptr = kmalloc(size, GFP_KERNEL);
16874 ++ else
16875 ++ ptr = vmalloc(size);
16876 ++ return ptr;
16879 ++static void __module_free(void *ptr)
16881 ++ if (is_phys_addr(ptr))
16882 ++ kfree(ptr);
16883 ++ else
16884 ++ vfree(ptr);
16887 ++int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
16888 ++ char *secstrings, struct module *mod)
16890 ++ unsigned int symindex = 0;
16891 ++ unsigned int core_size, init_size;
16892 ++ int i;
16894 ++ mod->arch.phys_plt_offset = 0;
16895 ++ mod->arch.virt_plt_offset = 0;
16896 ++ mod->arch.phys_plt_tbl = NULL;
16897 ++ mod->arch.virt_plt_tbl = NULL;
16899 ++ if (IS_ENABLED(CONFIG_64BIT))
16900 ++ return 0;
16902 ++ for (i = 1; i < hdr->e_shnum; i++)
16903 ++ if (sechdrs[i].sh_type == SHT_SYMTAB)
16904 ++ symindex = i;
16906 ++ core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false);
16907 ++ init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true);
16909 ++ if ((core_size + init_size) == 0)
16910 ++ return 0;
16912 ++ mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1);
16913 ++ if (!mod->arch.phys_plt_tbl)
16914 ++ return -ENOMEM;
16916 ++ mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0);
16917 ++ if (!mod->arch.virt_plt_tbl) {
16918 ++ __module_free(mod->arch.phys_plt_tbl);
16919 ++ mod->arch.phys_plt_tbl = NULL;
16920 ++ return -ENOMEM;
16921 ++ }
16923 ++ return 0;
16926 + int apply_r_mips_none(struct module *me, u32 *location, Elf_Addr v)
16928 +@@ -64,8 +272,39 @@ static int apply_r_mips_32_rel(struct mo
16929 + return 0;
16932 ++static Elf_Addr add_plt_entry_to(unsigned *plt_offset,
16933 ++ void *start, Elf_Addr v)
16935 ++ unsigned *tramp = start + *plt_offset;
16936 ++ *plt_offset += 4 * sizeof(int);
16938 ++ /* adjust carry for addiu */
16939 ++ if (v & 0x00008000)
16940 ++ v += 0x10000;
16942 ++ tramp[0] = 0x3c190000 | (v >> 16); /* lui t9, hi16 */
16943 ++ tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */
16944 ++ tramp[2] = 0x03200008; /* jr t9 */
16945 ++ tramp[3] = 0x00000000; /* nop */
16947 ++ return (Elf_Addr) tramp;
16950 ++static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v)
16952 ++ if (is_phys_addr(location))
16953 ++ return add_plt_entry_to(&me->arch.phys_plt_offset,
16954 ++ me->arch.phys_plt_tbl, v);
16955 ++ else
16956 ++ return add_plt_entry_to(&me->arch.virt_plt_offset,
16957 ++ me->arch.virt_plt_tbl, v);
16961 + static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
16963 ++ u32 ofs = *location & 0x03ffffff;
16965 + if (v % 4) {
16966 + pr_err("module %s: dangerous R_MIPS_26 REL relocation\n",
16967 + me->name);
16968 +@@ -73,14 +312,17 @@ static int apply_r_mips_26_rel(struct mo
16971 + if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) {
16972 +- printk(KERN_ERR
16973 +- "module %s: relocation overflow\n",
16974 +- me->name);
16975 +- return -ENOEXEC;
16976 ++ v = add_plt_entry(me, location, v + (ofs << 2));
16977 ++ if (!v) {
16978 ++ printk(KERN_ERR
16979 ++ "module %s: relocation overflow\n", me->name);
16980 ++ return -ENOEXEC;
16981 ++ }
16982 ++ ofs = 0;
16985 + *location = (*location & ~0x03ffffff) |
16986 +- ((*location + (v >> 2)) & 0x03ffffff);
16987 ++ ((ofs + (v >> 2)) & 0x03ffffff);
16989 + return 0;
16991 +@@ -287,11 +529,32 @@ int module_finalize(const Elf_Ehdr *hdr,
16992 + list_add(&me->arch.dbe_list, &dbe_list);
16993 + spin_unlock_irq(&dbe_lock);
16996 ++ /* Get rid of the fixup trampoline if we're running the module
16997 ++ * from physically mapped address space */
16998 ++ if (me->arch.phys_plt_offset == 0) {
16999 ++ __module_free(me->arch.phys_plt_tbl);
17000 ++ me->arch.phys_plt_tbl = NULL;
17001 ++ }
17002 ++ if (me->arch.virt_plt_offset == 0) {
17003 ++ __module_free(me->arch.virt_plt_tbl);
17004 ++ me->arch.virt_plt_tbl = NULL;
17005 ++ }
17007 + return 0;
17010 + void module_arch_cleanup(struct module *mod)
17012 ++ if (mod->arch.phys_plt_tbl) {
17013 ++ __module_free(mod->arch.phys_plt_tbl);
17014 ++ mod->arch.phys_plt_tbl = NULL;
17015 ++ }
17016 ++ if (mod->arch.virt_plt_tbl) {
17017 ++ __module_free(mod->arch.virt_plt_tbl);
17018 ++ mod->arch.virt_plt_tbl = NULL;
17019 ++ }
17021 + spin_lock_irq(&dbe_lock);
17022 + list_del(&mod->arch.dbe_list);
17023 + spin_unlock_irq(&dbe_lock);
17024 diff --git a/target/linux/generic/patches-3.16/306-mips_mem_functions_performance.patch b/target/linux/generic/patches-3.16/306-mips_mem_functions_performance.patch
17025 new file mode 100644
17026 index 000000000000..981867742531
17027 --- /dev/null
17028 +++ b/target/linux/generic/patches-3.16/306-mips_mem_functions_performance.patch
17029 @@ -0,0 +1,83 @@
17030 +--- a/arch/mips/include/asm/string.h
17031 ++++ b/arch/mips/include/asm/string.h
17032 +@@ -133,11 +133,44 @@ strncmp(__const__ char *__cs, __const__
17034 + #define __HAVE_ARCH_MEMSET
17035 + extern void *memset(void *__s, int __c, size_t __count);
17036 ++#define memset(__s, __c, len) \
17037 ++({ \
17038 ++ size_t __len = (len); \
17039 ++ void *__ret; \
17040 ++ if (__builtin_constant_p(len) && __len >= 64) \
17041 ++ __ret = memset((__s), (__c), __len); \
17042 ++ else \
17043 ++ __ret = __builtin_memset((__s), (__c), __len); \
17044 ++ __ret; \
17045 ++})
17047 + #define __HAVE_ARCH_MEMCPY
17048 + extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
17049 ++#define memcpy(dst, src, len) \
17050 ++({ \
17051 ++ size_t __len = (len); \
17052 ++ void *__ret; \
17053 ++ if (__builtin_constant_p(len) && __len >= 64) \
17054 ++ __ret = memcpy((dst), (src), __len); \
17055 ++ else \
17056 ++ __ret = __builtin_memcpy((dst), (src), __len); \
17057 ++ __ret; \
17058 ++})
17060 + #define __HAVE_ARCH_MEMMOVE
17061 + extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
17062 ++#define memmove(dst, src, len) \
17063 ++({ \
17064 ++ size_t __len = (len); \
17065 ++ void *__ret; \
17066 ++ if (__builtin_constant_p(len) && __len >= 64) \
17067 ++ __ret = memmove((dst), (src), __len); \
17068 ++ else \
17069 ++ __ret = __builtin_memmove((dst), (src), __len); \
17070 ++ __ret; \
17071 ++})
17073 ++#define __HAVE_ARCH_MEMCMP
17074 ++#define memcmp(src1, src2, len) __builtin_memcmp((src1), (src2), (len))
17076 + #endif /* _ASM_STRING_H */
17077 +--- a/arch/mips/lib/Makefile
17078 ++++ b/arch/mips/lib/Makefile
17079 +@@ -4,7 +4,7 @@
17081 + lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \
17082 + mips-atomic.o strlen_user.o strncpy_user.o \
17083 +- strnlen_user.o uncached.o
17084 ++ strnlen_user.o uncached.o memcmp.o
17086 + obj-y += iomap.o
17087 + obj-$(CONFIG_PCI) += iomap-pci.o
17088 +--- /dev/null
17089 ++++ b/arch/mips/lib/memcmp.c
17090 +@@ -0,0 +1,22 @@
17091 ++/*
17092 ++ * copied from linux/lib/string.c
17093 ++ *
17094 ++ * Copyright (C) 1991, 1992 Linus Torvalds
17095 ++ */
17097 ++#include <linux/module.h>
17098 ++#include <linux/string.h>
17100 ++#undef memcmp
17101 ++int memcmp(const void *cs, const void *ct, size_t count)
17103 ++ const unsigned char *su1, *su2;
17104 ++ int res = 0;
17106 ++ for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
17107 ++ if ((res = *su1 - *su2) != 0)
17108 ++ break;
17109 ++ return res;
17111 ++EXPORT_SYMBOL(memcmp);
17113 diff --git a/target/linux/generic/patches-3.16/309-mips_fuse_workaround.patch b/target/linux/generic/patches-3.16/309-mips_fuse_workaround.patch
17114 new file mode 100644
17115 index 000000000000..b78e9947aa38
17116 --- /dev/null
17117 +++ b/target/linux/generic/patches-3.16/309-mips_fuse_workaround.patch
17118 @@ -0,0 +1,33 @@
17119 +--- a/arch/mips/mm/cache.c
17120 ++++ b/arch/mips/mm/cache.c
17121 +@@ -23,6 +23,8 @@
17122 + /* Cache operations. */
17123 + void (*flush_cache_all)(void);
17124 + void (*__flush_cache_all)(void);
17125 ++EXPORT_SYMBOL(__flush_cache_all);
17127 + void (*flush_cache_mm)(struct mm_struct *mm);
17128 + void (*flush_cache_range)(struct vm_area_struct *vma, unsigned long start,
17129 + unsigned long end);
17130 +--- a/fs/fuse/dev.c
17131 ++++ b/fs/fuse/dev.c
17132 +@@ -20,6 +20,9 @@
17133 + #include <linux/swap.h>
17134 + #include <linux/splice.h>
17135 + #include <linux/aio.h>
17136 ++#ifdef CONFIG_MIPS
17137 ++#include <asm/cacheflush.h>
17138 ++#endif
17140 + MODULE_ALIAS_MISCDEV(FUSE_MINOR);
17141 + MODULE_ALIAS("devname:fuse");
17142 +@@ -749,6 +752,9 @@ static int fuse_copy_fill(struct fuse_co
17143 + static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size)
17145 + unsigned ncpy = min(*size, cs->len);
17146 ++#ifdef CONFIG_MIPS
17147 ++ __flush_cache_all();
17148 ++#endif
17149 + if (val) {
17150 + void *pgaddr = kmap_atomic(cs->pg);
17151 + void *buf = pgaddr + cs->offset;
17152 diff --git a/target/linux/generic/patches-3.16/310-arm_module_unresolved_weak_sym.patch b/target/linux/generic/patches-3.16/310-arm_module_unresolved_weak_sym.patch
17153 new file mode 100644
17154 index 000000000000..9210c1d2d322
17155 --- /dev/null
17156 +++ b/target/linux/generic/patches-3.16/310-arm_module_unresolved_weak_sym.patch
17157 @@ -0,0 +1,13 @@
17158 +--- a/arch/arm/kernel/module.c
17159 ++++ b/arch/arm/kernel/module.c
17160 +@@ -83,6 +83,10 @@ apply_relocate(Elf32_Shdr *sechdrs, cons
17161 + return -ENOEXEC;
17164 ++ if ((IS_ERR_VALUE(sym->st_value) || !sym->st_value) &&
17165 ++ ELF_ST_BIND(sym->st_info) == STB_WEAK)
17166 ++ continue;
17168 + loc = dstsec->sh_addr + rel->r_offset;
17170 + switch (ELF32_R_TYPE(rel->r_info)) {
17171 diff --git a/target/linux/generic/patches-3.16/320-ppc4xx_optimization.patch b/target/linux/generic/patches-3.16/320-ppc4xx_optimization.patch
17172 new file mode 100644
17173 index 000000000000..064cc796490a
17174 --- /dev/null
17175 +++ b/target/linux/generic/patches-3.16/320-ppc4xx_optimization.patch
17176 @@ -0,0 +1,31 @@
17177 +Upstream doesn't optimize the kernel and bootwrappers for ppc44x because
17178 +they still want to support gcc 3.3 -- well, we don't.
17180 +--- a/arch/powerpc/Makefile
17181 ++++ b/arch/powerpc/Makefile
17182 +@@ -191,7 +191,8 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
17183 + KBUILD_CFLAGS += -mno-sched-epilog
17184 + endif
17186 +-cpu-as-$(CONFIG_4xx) += -Wa,-m405
17187 ++cpu-as-$(CONFIG_40x) += -Wa,-m405
17188 ++cpu-as-$(CONFIG_44x) += -Wa,-m440
17189 + cpu-as-$(CONFIG_ALTIVEC) += -Wa,-maltivec
17190 + cpu-as-$(CONFIG_E200) += -Wa,-me200
17192 +--- a/arch/powerpc/boot/Makefile
17193 ++++ b/arch/powerpc/boot/Makefile
17194 +@@ -39,10 +39,10 @@ BOOTCFLAGS += -I$(obj) -I$(srctree)/$(ob
17195 + DTC_FLAGS ?= -p 1024
17197 + $(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
17198 +-$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
17199 ++$(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
17200 + $(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
17201 +-$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
17202 +-$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
17203 ++$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=440
17204 ++$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=440
17205 + $(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
17206 + $(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
17207 + $(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
17208 diff --git a/target/linux/generic/patches-3.16/321-powerpc_crtsavres_prereq.patch b/target/linux/generic/patches-3.16/321-powerpc_crtsavres_prereq.patch
17209 new file mode 100644
17210 index 000000000000..b999b8596123
17211 --- /dev/null
17212 +++ b/target/linux/generic/patches-3.16/321-powerpc_crtsavres_prereq.patch
17213 @@ -0,0 +1,10 @@
17214 +--- a/arch/powerpc/Makefile
17215 ++++ b/arch/powerpc/Makefile
17216 +@@ -158,7 +158,6 @@ CPP = $(CC) -E $(KBUILD_CFLAGS)
17218 + CHECKFLAGS += -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
17220 +-KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
17222 + # No AltiVec or VSX instructions when building kernel
17223 + KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
17224 diff --git a/target/linux/generic/patches-3.16/400-mtd-add-rootfs-split-support.patch b/target/linux/generic/patches-3.16/400-mtd-add-rootfs-split-support.patch
17225 new file mode 100644
17226 index 000000000000..4e68d8cbd5a6
17227 --- /dev/null
17228 +++ b/target/linux/generic/patches-3.16/400-mtd-add-rootfs-split-support.patch
17229 @@ -0,0 +1,263 @@
17230 +--- a/drivers/mtd/Kconfig
17231 ++++ b/drivers/mtd/Kconfig
17232 +@@ -12,6 +12,33 @@ menuconfig MTD
17234 + if MTD
17236 ++menu "OpenWrt specific MTD options"
17238 ++config MTD_ROOTFS_ROOT_DEV
17239 ++ bool "Automatically set 'rootfs' partition to be root filesystem"
17240 ++ default y
17242 ++config MTD_ROOTFS_SPLIT
17243 ++ bool "Automatically split 'rootfs' partition for squashfs"
17244 ++ select MTD_SPLIT
17245 ++ default y
17247 ++config MTD_SPLIT_FIRMWARE
17248 ++ bool "Automatically split firmware partition for kernel+rootfs"
17249 ++ default y
17251 ++config MTD_SPLIT_FIRMWARE_NAME
17252 ++ string "Firmware partition name"
17253 ++ depends on MTD_SPLIT_FIRMWARE
17254 ++ default "firmware"
17256 ++config MTD_UIMAGE_SPLIT
17257 ++ bool "Enable split support for firmware partitions containing a uImage"
17258 ++ depends on MTD_SPLIT_FIRMWARE
17259 ++ default y
17261 ++endmenu
17263 + config MTD_TESTS
17264 + tristate "MTD tests support (DANGEROUS)"
17265 + depends on m
17266 +--- a/drivers/mtd/mtdpart.c
17267 ++++ b/drivers/mtd/mtdpart.c
17268 +@@ -29,9 +29,11 @@
17269 + #include <linux/kmod.h>
17270 + #include <linux/mtd/mtd.h>
17271 + #include <linux/mtd/partitions.h>
17272 ++#include <linux/magic.h>
17273 + #include <linux/err.h>
17275 + #include "mtdcore.h"
17276 ++#include "mtdsplit.h"
17278 + /* Our partition linked list */
17279 + static LIST_HEAD(mtd_partitions);
17280 +@@ -45,13 +47,14 @@ struct mtd_part {
17281 + struct list_head list;
17282 + };
17284 ++static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part);
17286 + /*
17287 + * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
17288 + * the pointer to that structure with this macro.
17289 + */
17290 + #define PART(x) ((struct mtd_part *)(x))
17293 + /*
17294 + * MTD methods which simply translate the effective address and pass through
17295 + * to the _real_ device.
17296 +@@ -534,8 +537,10 @@ out_register:
17297 + return slave;
17300 +-int mtd_add_partition(struct mtd_info *master, const char *name,
17301 +- long long offset, long long length)
17303 ++static int
17304 ++__mtd_add_partition(struct mtd_info *master, const char *name,
17305 ++ long long offset, long long length, bool dup_check)
17307 + struct mtd_partition part;
17308 + struct mtd_part *p, *new;
17309 +@@ -567,21 +572,24 @@ int mtd_add_partition(struct mtd_info *m
17310 + end = offset + length;
17312 + mutex_lock(&mtd_partitions_mutex);
17313 +- list_for_each_entry(p, &mtd_partitions, list)
17314 +- if (p->master == master) {
17315 +- if ((start >= p->offset) &&
17316 +- (start < (p->offset + p->mtd.size)))
17317 +- goto err_inv;
17319 +- if ((end >= p->offset) &&
17320 +- (end < (p->offset + p->mtd.size)))
17321 +- goto err_inv;
17322 +- }
17323 ++ if (dup_check) {
17324 ++ list_for_each_entry(p, &mtd_partitions, list)
17325 ++ if (p->master == master) {
17326 ++ if ((start >= p->offset) &&
17327 ++ (start < (p->offset + p->mtd.size)))
17328 ++ goto err_inv;
17330 ++ if ((end >= p->offset) &&
17331 ++ (end < (p->offset + p->mtd.size)))
17332 ++ goto err_inv;
17333 ++ }
17334 ++ }
17336 + list_add(&new->list, &mtd_partitions);
17337 + mutex_unlock(&mtd_partitions_mutex);
17339 + add_mtd_device(&new->mtd);
17340 ++ mtd_partition_split(master, new);
17342 + return ret;
17343 + err_inv:
17344 +@@ -591,6 +599,12 @@ err_inv:
17346 + EXPORT_SYMBOL_GPL(mtd_add_partition);
17348 ++int mtd_add_partition(struct mtd_info *master, const char *name,
17349 ++ long long offset, long long length)
17351 ++ return __mtd_add_partition(master, name, offset, length, true);
17354 + int mtd_del_partition(struct mtd_info *master, int partno)
17356 + struct mtd_part *slave, *next;
17357 +@@ -614,6 +628,117 @@ int mtd_del_partition(struct mtd_info *m
17359 + EXPORT_SYMBOL_GPL(mtd_del_partition);
17361 ++static inline unsigned long
17362 ++mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
17364 ++ unsigned long mask = mtd->erasesize - 1;
17366 ++ len += offset & mask;
17367 ++ len = (len + mask) & ~mask;
17368 ++ len -= offset & mask;
17369 ++ return len;
17372 ++static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
17374 ++ size_t squashfs_len;
17375 ++ int len, ret;
17377 ++ ret = mtd_get_squashfs_len(master, offset, &squashfs_len);
17378 ++ if (ret)
17379 ++ return ret;
17381 ++ len = mtd_pad_erasesize(master, offset, squashfs_len);
17382 ++ *split_offset = offset + len;
17384 ++ return 0;
17387 ++static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part)
17389 ++ unsigned int split_offset = 0;
17390 ++ unsigned int split_size;
17391 ++ int ret;
17393 ++ ret = split_squashfs(master, part->offset, &split_offset);
17394 ++ if (ret)
17395 ++ return;
17397 ++ if (split_offset <= 0)
17398 ++ return;
17400 ++ split_size = part->mtd.size - (split_offset - part->offset);
17401 ++ printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n",
17402 ++ ROOTFS_SPLIT_NAME, split_offset, split_size);
17404 ++ __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset,
17405 ++ split_size, false);
17408 ++#define UBOOT_MAGIC 0x27051956
17410 ++static void split_uimage(struct mtd_info *master, struct mtd_part *part)
17412 ++ struct {
17413 ++ __be32 magic;
17414 ++ __be32 pad[2];
17415 ++ __be32 size;
17416 ++ } hdr;
17417 ++ size_t len;
17419 ++ if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
17420 ++ return;
17422 ++ if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC))
17423 ++ return;
17425 ++ len = be32_to_cpu(hdr.size) + 0x40;
17426 ++ len = mtd_pad_erasesize(master, part->offset, len);
17427 ++ if (len + master->erasesize > part->mtd.size)
17428 ++ return;
17430 ++ __mtd_add_partition(master, "rootfs", part->offset + len,
17431 ++ part->mtd.size - len, false);
17434 ++#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
17435 ++#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
17436 ++#else
17437 ++#define SPLIT_FIRMWARE_NAME "unused"
17438 ++#endif
17440 ++static void split_firmware(struct mtd_info *master, struct mtd_part *part)
17442 ++ if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
17443 ++ split_uimage(master, part);
17446 ++void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
17447 ++ int offset, int size)
17451 ++static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part)
17453 ++ static int rootfs_found = 0;
17455 ++ if (rootfs_found)
17456 ++ return;
17458 ++ if (!strcmp(part->mtd.name, "rootfs")) {
17459 ++ rootfs_found = 1;
17461 ++ if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
17462 ++ split_rootfs_data(master, part);
17463 ++ }
17465 ++ if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) &&
17466 ++ config_enabled(CONFIG_MTD_SPLIT_FIRMWARE))
17467 ++ split_firmware(master, part);
17469 ++ arch_split_mtd_part(master, part->mtd.name, part->offset,
17470 ++ part->mtd.size);
17472 + /*
17473 + * This function, given a master MTD object and a partition table, creates
17474 + * and registers slave MTD objects which are bound to the master according to
17475 +@@ -643,6 +768,7 @@ int add_mtd_partitions(struct mtd_info *
17476 + mutex_unlock(&mtd_partitions_mutex);
17478 + add_mtd_device(&slave->mtd);
17479 ++ mtd_partition_split(master, slave);
17481 + cur_offset = slave->offset + slave->mtd.size;
17483 +--- a/include/linux/mtd/partitions.h
17484 ++++ b/include/linux/mtd/partitions.h
17485 +@@ -84,5 +84,7 @@ int mtd_add_partition(struct mtd_info *m
17486 + long long offset, long long length);
17487 + int mtd_del_partition(struct mtd_info *master, int partno);
17488 + uint64_t mtd_get_device_size(const struct mtd_info *mtd);
17489 ++extern void __weak arch_split_mtd_part(struct mtd_info *master,
17490 ++ const char *name, int offset, int size);
17492 + #endif
17493 diff --git a/target/linux/generic/patches-3.16/401-mtd-add-support-for-different-partition-parser-types.patch b/target/linux/generic/patches-3.16/401-mtd-add-support-for-different-partition-parser-types.patch
17494 new file mode 100644
17495 index 000000000000..a434f6e392d3
17496 --- /dev/null
17497 +++ b/target/linux/generic/patches-3.16/401-mtd-add-support-for-different-partition-parser-types.patch
17498 @@ -0,0 +1,113 @@
17499 +From 02cff0ccaa6d364f5c1eeea83f47ac80ccc967d4 Mon Sep 17 00:00:00 2001
17500 +From: Gabor Juhos <juhosg@openwrt.org>
17501 +Date: Tue, 3 Sep 2013 18:11:50 +0200
17502 +Subject: [PATCH] mtd: add support for different partition parser types
17504 +Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
17505 +---
17506 + drivers/mtd/mtdpart.c | 56 ++++++++++++++++++++++++++++++++++++++++
17507 + include/linux/mtd/partitions.h | 11 ++++++++
17508 + 2 files changed, 67 insertions(+)
17510 +--- a/drivers/mtd/mtdpart.c
17511 ++++ b/drivers/mtd/mtdpart.c
17512 +@@ -798,6 +798,30 @@ static struct mtd_part_parser *get_parti
17514 + #define put_partition_parser(p) do { module_put((p)->owner); } while (0)
17516 ++static struct mtd_part_parser *
17517 ++get_partition_parser_by_type(enum mtd_parser_type type,
17518 ++ struct mtd_part_parser *start)
17520 ++ struct mtd_part_parser *p, *ret = NULL;
17522 ++ spin_lock(&part_parser_lock);
17524 ++ p = list_prepare_entry(start, &part_parsers, list);
17525 ++ if (start)
17526 ++ put_partition_parser(start);
17528 ++ list_for_each_entry_continue(p, &part_parsers, list) {
17529 ++ if (p->type == type && try_module_get(p->owner)) {
17530 ++ ret = p;
17531 ++ break;
17532 ++ }
17533 ++ }
17535 ++ spin_unlock(&part_parser_lock);
17537 ++ return ret;
17540 + void register_mtd_parser(struct mtd_part_parser *p)
17542 + spin_lock(&part_parser_lock);
17543 +@@ -871,6 +895,38 @@ int parse_mtd_partitions(struct mtd_info
17544 + return ret;
17547 ++int parse_mtd_partitions_by_type(struct mtd_info *master,
17548 ++ enum mtd_parser_type type,
17549 ++ struct mtd_partition **pparts,
17550 ++ struct mtd_part_parser_data *data)
17552 ++ struct mtd_part_parser *prev = NULL;
17553 ++ int ret = 0;
17555 ++ while (1) {
17556 ++ struct mtd_part_parser *parser;
17558 ++ parser = get_partition_parser_by_type(type, prev);
17559 ++ if (!parser)
17560 ++ break;
17562 ++ ret = (*parser->parse_fn)(master, pparts, data);
17564 ++ if (ret > 0) {
17565 ++ put_partition_parser(parser);
17566 ++ printk(KERN_NOTICE
17567 ++ "%d %s partitions found on MTD device %s\n",
17568 ++ ret, parser->name, master->name);
17569 ++ break;
17570 ++ }
17572 ++ prev = parser;
17573 ++ }
17575 ++ return ret;
17577 ++EXPORT_SYMBOL_GPL(parse_mtd_partitions_by_type);
17579 + int mtd_is_partition(const struct mtd_info *mtd)
17581 + struct mtd_part *part;
17582 +--- a/include/linux/mtd/partitions.h
17583 ++++ b/include/linux/mtd/partitions.h
17584 +@@ -68,12 +68,17 @@ struct mtd_part_parser_data {
17585 + * Functions dealing with the various ways of partitioning the space
17586 + */
17588 ++enum mtd_parser_type {
17589 ++ MTD_PARSER_TYPE_DEVICE = 0,
17590 ++};
17592 + struct mtd_part_parser {
17593 + struct list_head list;
17594 + struct module *owner;
17595 + const char *name;
17596 + int (*parse_fn)(struct mtd_info *, struct mtd_partition **,
17597 + struct mtd_part_parser_data *);
17598 ++ enum mtd_parser_type type;
17599 + };
17601 + extern void register_mtd_parser(struct mtd_part_parser *parser);
17602 +@@ -87,4 +92,9 @@ uint64_t mtd_get_device_size(const struc
17603 + extern void __weak arch_split_mtd_part(struct mtd_info *master,
17604 + const char *name, int offset, int size);
17606 ++int parse_mtd_partitions_by_type(struct mtd_info *master,
17607 ++ enum mtd_parser_type type,
17608 ++ struct mtd_partition **pparts,
17609 ++ struct mtd_part_parser_data *data);
17611 + #endif
17612 diff --git a/target/linux/generic/patches-3.16/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch b/target/linux/generic/patches-3.16/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch
17613 new file mode 100644
17614 index 000000000000..92a3ee7633ff
17615 --- /dev/null
17616 +++ b/target/linux/generic/patches-3.16/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch
17617 @@ -0,0 +1,75 @@
17618 +--- a/drivers/mtd/mtdpart.c
17619 ++++ b/drivers/mtd/mtdpart.c
17620 +@@ -628,6 +628,37 @@ int mtd_del_partition(struct mtd_info *m
17622 + EXPORT_SYMBOL_GPL(mtd_del_partition);
17624 ++static int
17625 ++run_parsers_by_type(struct mtd_part *slave, enum mtd_parser_type type)
17627 ++ struct mtd_partition *parts;
17628 ++ int nr_parts;
17629 ++ int i;
17631 ++ nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, &parts,
17632 ++ NULL);
17633 ++ if (nr_parts <= 0)
17634 ++ return nr_parts;
17636 ++ if (WARN_ON(!parts))
17637 ++ return 0;
17639 ++ for (i = 0; i < nr_parts; i++) {
17640 ++ /* adjust partition offsets */
17641 ++ parts[i].offset += slave->offset;
17643 ++ __mtd_add_partition(slave->master,
17644 ++ parts[i].name,
17645 ++ parts[i].offset,
17646 ++ parts[i].size,
17647 ++ false);
17648 ++ }
17650 ++ kfree(parts);
17652 ++ return nr_parts;
17655 + static inline unsigned long
17656 + mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
17658 +@@ -660,6 +691,10 @@ static void split_rootfs_data(struct mtd
17659 + unsigned int split_size;
17660 + int ret;
17662 ++ ret = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
17663 ++ if (ret > 0)
17664 ++ return;
17666 + ret = split_squashfs(master, part->offset, &split_offset);
17667 + if (ret)
17668 + return;
17669 +@@ -709,6 +744,12 @@ static void split_uimage(struct mtd_info
17671 + static void split_firmware(struct mtd_info *master, struct mtd_part *part)
17673 ++ int ret;
17675 ++ ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
17676 ++ if (ret > 0)
17677 ++ return;
17679 + if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
17680 + split_uimage(master, part);
17682 +--- a/include/linux/mtd/partitions.h
17683 ++++ b/include/linux/mtd/partitions.h
17684 +@@ -70,6 +70,8 @@ struct mtd_part_parser_data {
17686 + enum mtd_parser_type {
17687 + MTD_PARSER_TYPE_DEVICE = 0,
17688 ++ MTD_PARSER_TYPE_ROOTFS,
17689 ++ MTD_PARSER_TYPE_FIRMWARE,
17690 + };
17692 + struct mtd_part_parser {
17693 diff --git a/target/linux/generic/patches-3.16/403-mtd-hook-mtdsplit-to-Kbuild.patch b/target/linux/generic/patches-3.16/403-mtd-hook-mtdsplit-to-Kbuild.patch
17694 new file mode 100644
17695 index 000000000000..be2ee69d6c7f
17696 --- /dev/null
17697 +++ b/target/linux/generic/patches-3.16/403-mtd-hook-mtdsplit-to-Kbuild.patch
17698 @@ -0,0 +1,25 @@
17699 +--- a/drivers/mtd/Kconfig
17700 ++++ b/drivers/mtd/Kconfig
17701 +@@ -37,6 +37,11 @@ config MTD_UIMAGE_SPLIT
17702 + depends on MTD_SPLIT_FIRMWARE
17703 + default y
17705 ++config MTD_SPLIT
17706 ++ def_bool n
17707 ++ help
17708 ++ Generic MTD split support.
17710 + endmenu
17712 + config MTD_TESTS
17713 +--- a/drivers/mtd/Makefile
17714 ++++ b/drivers/mtd/Makefile
17715 +@@ -6,6 +6,8 @@
17716 + obj-$(CONFIG_MTD) += mtd.o
17717 + mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
17719 ++mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o
17721 + obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o
17722 + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
17723 + obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
17724 diff --git a/target/linux/generic/patches-3.16/405-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.16/405-mtd-add-more-helper-functions.patch
17725 new file mode 100644
17726 index 000000000000..c6ce8728bb3a
17727 --- /dev/null
17728 +++ b/target/linux/generic/patches-3.16/405-mtd-add-more-helper-functions.patch
17729 @@ -0,0 +1,83 @@
17730 +--- a/drivers/mtd/mtdpart.c
17731 ++++ b/drivers/mtd/mtdpart.c
17732 +@@ -434,14 +434,12 @@ static struct mtd_part *allocate_partiti
17733 + if (slave->offset == MTDPART_OFS_APPEND)
17734 + slave->offset = cur_offset;
17735 + if (slave->offset == MTDPART_OFS_NXTBLK) {
17736 +- slave->offset = cur_offset;
17737 +- if (mtd_mod_by_eb(cur_offset, master) != 0) {
17738 +- /* Round up to next erasesize */
17739 +- slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
17740 ++ /* Round up to next erasesize */
17741 ++ slave->offset = mtd_roundup_to_eb(cur_offset, master);
17742 ++ if (slave->offset != cur_offset)
17743 + printk(KERN_NOTICE "Moving partition %d: "
17744 + "0x%012llx -> 0x%012llx\n", partno,
17745 + (unsigned long long)cur_offset, (unsigned long long)slave->offset);
17746 +- }
17748 + if (slave->offset == MTDPART_OFS_RETAIN) {
17749 + slave->offset = cur_offset;
17750 +@@ -985,6 +983,24 @@ int mtd_is_partition(const struct mtd_in
17752 + EXPORT_SYMBOL_GPL(mtd_is_partition);
17754 ++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd)
17756 ++ if (!mtd_is_partition(mtd))
17757 ++ return (struct mtd_info *)mtd;
17759 ++ return PART(mtd)->master;
17761 ++EXPORT_SYMBOL_GPL(mtdpart_get_master);
17763 ++uint64_t mtdpart_get_offset(const struct mtd_info *mtd)
17765 ++ if (!mtd_is_partition(mtd))
17766 ++ return 0;
17768 ++ return PART(mtd)->offset;
17770 ++EXPORT_SYMBOL_GPL(mtdpart_get_offset);
17772 + /* Returns the size of the entire flash chip */
17773 + uint64_t mtd_get_device_size(const struct mtd_info *mtd)
17775 +--- a/include/linux/mtd/partitions.h
17776 ++++ b/include/linux/mtd/partitions.h
17777 +@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in
17778 + int mtd_add_partition(struct mtd_info *master, const char *name,
17779 + long long offset, long long length);
17780 + int mtd_del_partition(struct mtd_info *master, int partno);
17781 ++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd);
17782 ++uint64_t mtdpart_get_offset(const struct mtd_info *mtd);
17783 + uint64_t mtd_get_device_size(const struct mtd_info *mtd);
17784 + extern void __weak arch_split_mtd_part(struct mtd_info *master,
17785 + const char *name, int offset, int size);
17786 +--- a/include/linux/mtd/mtd.h
17787 ++++ b/include/linux/mtd/mtd.h
17788 +@@ -331,6 +331,24 @@ static inline uint32_t mtd_mod_by_eb(uin
17789 + return do_div(sz, mtd->erasesize);
17792 ++static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd)
17794 ++ if (mtd_mod_by_eb(sz, mtd) == 0)
17795 ++ return sz;
17797 ++ /* Round up to next erase block */
17798 ++ return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize;
17801 ++static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd)
17803 ++ if (mtd_mod_by_eb(sz, mtd) == 0)
17804 ++ return sz;
17806 ++ /* Round down to the start of the current erase block */
17807 ++ return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize;
17810 + static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
17812 + if (mtd->writesize_shift)
17813 diff --git a/target/linux/generic/patches-3.16/406-mtd-hook-mtdsplit-into-Kbuild.patch b/target/linux/generic/patches-3.16/406-mtd-hook-mtdsplit-into-Kbuild.patch
17814 new file mode 100644
17815 index 000000000000..eac31d742081
17816 --- /dev/null
17817 +++ b/target/linux/generic/patches-3.16/406-mtd-hook-mtdsplit-into-Kbuild.patch
17818 @@ -0,0 +1,24 @@
17819 +--- a/drivers/mtd/Kconfig
17820 ++++ b/drivers/mtd/Kconfig
17821 +@@ -37,6 +37,8 @@ config MTD_UIMAGE_SPLIT
17822 + depends on MTD_SPLIT_FIRMWARE
17823 + default y
17825 ++source "drivers/mtd/mtdsplit/Kconfig"
17827 + config MTD_SPLIT
17828 + def_bool n
17829 + help
17830 +--- a/drivers/mtd/Makefile
17831 ++++ b/drivers/mtd/Makefile
17832 +@@ -7,6 +7,10 @@ obj-$(CONFIG_MTD) += mtd.o
17833 + mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o
17835 + mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o
17836 ++mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o
17837 ++mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o
17838 ++mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o
17839 ++mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
17841 + obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o
17842 + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
17843 diff --git a/target/linux/generic/patches-3.16/410-mtd-move-forward-declaration-of-struct-mtd_info.patch b/target/linux/generic/patches-3.16/410-mtd-move-forward-declaration-of-struct-mtd_info.patch
17844 new file mode 100644
17845 index 000000000000..78ebbf88ca9d
17846 --- /dev/null
17847 +++ b/target/linux/generic/patches-3.16/410-mtd-move-forward-declaration-of-struct-mtd_info.patch
17848 @@ -0,0 +1,18 @@
17849 +--- a/include/linux/mtd/partitions.h
17850 ++++ b/include/linux/mtd/partitions.h
17851 +@@ -35,6 +35,7 @@
17852 + * Note: writeable partitions require their size and offset be
17853 + * erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK).
17854 + */
17855 ++struct mtd_info;
17857 + struct mtd_partition {
17858 + const char *name; /* identifier string */
17859 +@@ -50,7 +51,6 @@ struct mtd_partition {
17860 + #define MTDPART_SIZ_FULL (0)
17863 +-struct mtd_info;
17864 + struct device_node;
17866 + /**
17867 diff --git a/target/linux/generic/patches-3.16/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/patches-3.16/411-mtd-partial_eraseblock_write.patch
17868 new file mode 100644
17869 index 000000000000..8da080b2ade8
17870 --- /dev/null
17871 +++ b/target/linux/generic/patches-3.16/411-mtd-partial_eraseblock_write.patch
17872 @@ -0,0 +1,146 @@
17873 +--- a/drivers/mtd/mtdpart.c
17874 ++++ b/drivers/mtd/mtdpart.c
17875 +@@ -35,6 +35,8 @@
17876 + #include "mtdcore.h"
17877 + #include "mtdsplit.h"
17879 ++#define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an erase block */
17881 + /* Our partition linked list */
17882 + static LIST_HEAD(mtd_partitions);
17883 + static DEFINE_MUTEX(mtd_partitions_mutex);
17884 +@@ -231,13 +233,61 @@ static int part_erase(struct mtd_info *m
17885 + struct mtd_part *part = PART(mtd);
17886 + int ret;
17889 ++ instr->partial_start = false;
17890 ++ if (mtd->flags & MTD_ERASE_PARTIAL) {
17891 ++ size_t readlen = 0;
17892 ++ u64 mtd_ofs;
17894 ++ instr->erase_buf = kmalloc(part->master->erasesize, GFP_ATOMIC);
17895 ++ if (!instr->erase_buf)
17896 ++ return -ENOMEM;
17898 ++ mtd_ofs = part->offset + instr->addr;
17899 ++ instr->erase_buf_ofs = do_div(mtd_ofs, part->master->erasesize);
17901 ++ if (instr->erase_buf_ofs > 0) {
17902 ++ instr->addr -= instr->erase_buf_ofs;
17903 ++ ret = mtd_read(part->master,
17904 ++ instr->addr + part->offset,
17905 ++ part->master->erasesize,
17906 ++ &readlen, instr->erase_buf);
17908 ++ instr->len += instr->erase_buf_ofs;
17909 ++ instr->partial_start = true;
17910 ++ } else {
17911 ++ mtd_ofs = part->offset + part->mtd.size;
17912 ++ instr->erase_buf_ofs = part->master->erasesize -
17913 ++ do_div(mtd_ofs, part->master->erasesize);
17915 ++ if (instr->erase_buf_ofs > 0) {
17916 ++ instr->len += instr->erase_buf_ofs;
17917 ++ ret = mtd_read(part->master,
17918 ++ part->offset + instr->addr +
17919 ++ instr->len - part->master->erasesize,
17920 ++ part->master->erasesize, &readlen,
17921 ++ instr->erase_buf);
17922 ++ } else {
17923 ++ ret = 0;
17924 ++ }
17925 ++ }
17926 ++ if (ret < 0) {
17927 ++ kfree(instr->erase_buf);
17928 ++ return ret;
17929 ++ }
17931 ++ }
17933 + instr->addr += part->offset;
17934 + ret = part->master->_erase(part->master, instr);
17935 + if (ret) {
17936 + if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
17937 + instr->fail_addr -= part->offset;
17938 + instr->addr -= part->offset;
17939 ++ if (mtd->flags & MTD_ERASE_PARTIAL)
17940 ++ kfree(instr->erase_buf);
17943 + return ret;
17946 +@@ -245,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
17948 + if (instr->mtd->_erase == part_erase) {
17949 + struct mtd_part *part = PART(instr->mtd);
17950 ++ size_t wrlen = 0;
17952 ++ if (instr->mtd->flags & MTD_ERASE_PARTIAL) {
17953 ++ if (instr->partial_start) {
17954 ++ part->master->_write(part->master,
17955 ++ instr->addr, instr->erase_buf_ofs,
17956 ++ &wrlen, instr->erase_buf);
17957 ++ instr->addr += instr->erase_buf_ofs;
17958 ++ } else {
17959 ++ instr->len -= instr->erase_buf_ofs;
17960 ++ part->master->_write(part->master,
17961 ++ instr->addr + instr->len,
17962 ++ instr->erase_buf_ofs, &wrlen,
17963 ++ instr->erase_buf +
17964 ++ part->master->erasesize -
17965 ++ instr->erase_buf_ofs);
17966 ++ }
17967 ++ kfree(instr->erase_buf);
17968 ++ }
17969 + if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
17970 + instr->fail_addr -= part->offset;
17971 + instr->addr -= part->offset;
17972 +@@ -503,18 +571,24 @@ static struct mtd_part *allocate_partiti
17973 + if ((slave->mtd.flags & MTD_WRITEABLE) &&
17974 + mtd_mod_by_eb(slave->offset, &slave->mtd)) {
17975 + /* Doesn't start on a boundary of major erase size */
17976 +- /* FIXME: Let it be writable if it is on a boundary of
17977 +- * _minor_ erase size though */
17978 +- slave->mtd.flags &= ~MTD_WRITEABLE;
17979 +- printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
17980 +- part->name);
17981 ++ slave->mtd.flags |= MTD_ERASE_PARTIAL;
17982 ++ if (((u32) slave->mtd.size) > master->erasesize)
17983 ++ slave->mtd.flags &= ~MTD_WRITEABLE;
17984 ++ else
17985 ++ slave->mtd.erasesize = slave->mtd.size;
17987 + if ((slave->mtd.flags & MTD_WRITEABLE) &&
17988 +- mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) {
17989 +- slave->mtd.flags &= ~MTD_WRITEABLE;
17990 +- printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
17991 +- part->name);
17992 ++ mtd_mod_by_eb(slave->offset + slave->mtd.size, &slave->mtd)) {
17993 ++ slave->mtd.flags |= MTD_ERASE_PARTIAL;
17995 ++ if ((u32) slave->mtd.size > master->erasesize)
17996 ++ slave->mtd.flags &= ~MTD_WRITEABLE;
17997 ++ else
17998 ++ slave->mtd.erasesize = slave->mtd.size;
18000 ++ if ((slave->mtd.flags & (MTD_ERASE_PARTIAL|MTD_WRITEABLE)) == MTD_ERASE_PARTIAL)
18001 ++ printk(KERN_WARNING"mtd: partition \"%s\" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only\n",
18002 ++ part->name);
18004 + slave->mtd.ecclayout = master->ecclayout;
18005 + slave->mtd.ecc_step_size = master->ecc_step_size;
18006 +--- a/include/linux/mtd/mtd.h
18007 ++++ b/include/linux/mtd/mtd.h
18008 +@@ -55,6 +55,10 @@ struct erase_info {
18009 + u_long priv;
18010 + u_char state;
18011 + struct erase_info *next;
18013 ++ u8 *erase_buf;
18014 ++ u32 erase_buf_ofs;
18015 ++ bool partial_start;
18016 + };
18018 + struct mtd_erase_region_info {
18019 diff --git a/target/linux/generic/patches-3.16/412-mtd-partial_eraseblock_unlock.patch b/target/linux/generic/patches-3.16/412-mtd-partial_eraseblock_unlock.patch
18020 new file mode 100644
18021 index 000000000000..87c8257fe115
18022 --- /dev/null
18023 +++ b/target/linux/generic/patches-3.16/412-mtd-partial_eraseblock_unlock.patch
18024 @@ -0,0 +1,18 @@
18025 +--- a/drivers/mtd/mtdpart.c
18026 ++++ b/drivers/mtd/mtdpart.c
18027 +@@ -332,7 +332,14 @@ static int part_lock(struct mtd_info *mt
18028 + static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
18030 + struct mtd_part *part = PART(mtd);
18031 +- return part->master->_unlock(part->master, ofs + part->offset, len);
18033 ++ ofs += part->offset;
18034 ++ if (mtd->flags & MTD_ERASE_PARTIAL) {
18035 ++ /* round up len to next erasesize and round down offset to prev block */
18036 ++ len = (mtd_div_by_eb(len, part->master) + 1) * part->master->erasesize;
18037 ++ ofs &= ~(part->master->erasesize - 1);
18038 ++ }
18039 ++ return part->master->_unlock(part->master, ofs, len);
18042 + static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
18043 diff --git a/target/linux/generic/patches-3.16/420-mtd-redboot_space.patch b/target/linux/generic/patches-3.16/420-mtd-redboot_space.patch
18044 new file mode 100644
18045 index 000000000000..f74affcef70e
18046 --- /dev/null
18047 +++ b/target/linux/generic/patches-3.16/420-mtd-redboot_space.patch
18048 @@ -0,0 +1,30 @@
18049 +--- a/drivers/mtd/redboot.c
18050 ++++ b/drivers/mtd/redboot.c
18051 +@@ -265,14 +265,21 @@ static int parse_redboot_partitions(stru
18052 + #endif
18053 + names += strlen(names)+1;
18055 +-#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
18056 + if(fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) {
18057 +- i++;
18058 +- parts[i].offset = parts[i-1].size + parts[i-1].offset;
18059 +- parts[i].size = fl->next->img->flash_base - parts[i].offset;
18060 +- parts[i].name = nullname;
18061 +- }
18062 ++ if (!strcmp(parts[i].name, "rootfs")) {
18063 ++ parts[i].size = fl->next->img->flash_base;
18064 ++ parts[i].size &= ~(master->erasesize - 1);
18065 ++ parts[i].size -= parts[i].offset;
18066 ++#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
18067 ++ nrparts--;
18068 ++ } else {
18069 ++ i++;
18070 ++ parts[i].offset = parts[i-1].size + parts[i-1].offset;
18071 ++ parts[i].size = fl->next->img->flash_base - parts[i].offset;
18072 ++ parts[i].name = nullname;
18073 + #endif
18074 ++ }
18075 ++ }
18076 + tmp_fl = fl;
18077 + fl = fl->next;
18078 + kfree(tmp_fl);
18079 diff --git a/target/linux/generic/patches-3.16/430-mtd-add-myloader-partition-parser.patch b/target/linux/generic/patches-3.16/430-mtd-add-myloader-partition-parser.patch
18080 new file mode 100644
18081 index 000000000000..ffc9e2199cf7
18082 --- /dev/null
18083 +++ b/target/linux/generic/patches-3.16/430-mtd-add-myloader-partition-parser.patch
18084 @@ -0,0 +1,35 @@
18085 +--- a/drivers/mtd/Kconfig
18086 ++++ b/drivers/mtd/Kconfig
18087 +@@ -189,6 +189,22 @@ config MTD_BCM47XX_PARTS
18088 + This provides partitions parser for devices based on BCM47xx
18089 + boards.
18091 ++config MTD_MYLOADER_PARTS
18092 ++ tristate "MyLoader partition parsing"
18093 ++ depends on ADM5120 || ATHEROS_AR231X || ATHEROS_AR71XX || ATH79
18094 ++ ---help---
18095 ++ MyLoader is a bootloader which allows the user to define partitions
18096 ++ in flash devices, by putting a table in the second erase block
18097 ++ on the device, similar to a partition table. This table gives the
18098 ++ offsets and lengths of the user defined partitions.
18100 ++ If you need code which can detect and parse these tables, and
18101 ++ register MTD 'partitions' corresponding to each image detected,
18102 ++ enable this option.
18104 ++ You will still need the parsing functions to be called by the driver
18105 ++ for your particular device. It won't happen automatically.
18107 + comment "User Modules And Translation Layers"
18110 +--- a/drivers/mtd/Makefile
18111 ++++ b/drivers/mtd/Makefile
18112 +@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
18113 + obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o
18114 + obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o
18115 + obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o
18116 ++obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o
18118 + # 'Users' - code which presents functionality to userspace.
18119 + obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o
18120 diff --git a/target/linux/generic/patches-3.16/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch b/target/linux/generic/patches-3.16/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch
18121 new file mode 100644
18122 index 000000000000..8c6380318f8f
18123 --- /dev/null
18124 +++ b/target/linux/generic/patches-3.16/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch
18125 @@ -0,0 +1,66 @@
18126 +--- a/drivers/mtd/bcm47xxpart.c
18127 ++++ b/drivers/mtd/bcm47xxpart.c
18128 +@@ -36,6 +36,7 @@
18129 + #define ML_MAGIC2 0x26594131
18130 + #define TRX_MAGIC 0x30524448
18131 + #define SQSH_MAGIC 0x71736873 /* shsq */
18132 ++#define UBI_EC_MAGIC 0x23494255 /* UBI# */
18134 + struct trx_header {
18135 + uint32_t magic;
18136 +@@ -46,7 +47,7 @@ struct trx_header {
18137 + uint32_t offset[3];
18138 + } __packed;
18140 +-static void bcm47xxpart_add_part(struct mtd_partition *part, char *name,
18141 ++static void bcm47xxpart_add_part(struct mtd_partition *part, const char *name,
18142 + u64 offset, uint32_t mask_flags)
18144 + part->name = name;
18145 +@@ -54,6 +55,26 @@ static void bcm47xxpart_add_part(struct
18146 + part->mask_flags = mask_flags;
18149 ++static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
18150 ++ size_t offset)
18152 ++ uint32_t buf;
18153 ++ size_t bytes_read;
18155 ++ if (mtd_read(master, offset, sizeof(&buf), &bytes_read,
18156 ++ (uint8_t *)&buf) < 0) {
18157 ++ pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
18158 ++ offset);
18159 ++ goto out_default;
18160 ++ }
18162 ++ if (buf == UBI_EC_MAGIC)
18163 ++ return "ubi";
18165 ++out_default:
18166 ++ return "rootfs";
18169 + static int bcm47xxpart_parse(struct mtd_info *master,
18170 + struct mtd_partition **pparts,
18171 + struct mtd_part_parser_data *data)
18172 +@@ -147,6 +168,8 @@ static int bcm47xxpart_parse(struct mtd_
18174 + /* TRX */
18175 + if (buf[0x000 / 4] == TRX_MAGIC) {
18176 ++ const char *name;
18178 + if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
18179 + pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
18180 + break;
18181 +@@ -177,7 +200,9 @@ static int bcm47xxpart_parse(struct mtd_
18182 + * trx->length - trx->offset[i]. We don't fill it as
18183 + * we want to have jffs2 (overlay) in the same mtd.
18184 + */
18185 +- bcm47xxpart_add_part(&parts[curr_part++], "rootfs",
18186 ++ name = bcm47xxpart_trx_data_part_name(master,
18187 ++ offset + trx->offset[i]);
18188 ++ bcm47xxpart_add_part(&parts[curr_part++], name,
18189 + offset + trx->offset[i], 0);
18190 + i++;
18192 diff --git a/target/linux/generic/patches-3.16/440-block2mtd_init.patch b/target/linux/generic/patches-3.16/440-block2mtd_init.patch
18193 new file mode 100644
18194 index 000000000000..9bbbb782a1e3
18195 --- /dev/null
18196 +++ b/target/linux/generic/patches-3.16/440-block2mtd_init.patch
18197 @@ -0,0 +1,107 @@
18198 +--- a/drivers/mtd/devices/block2mtd.c
18199 ++++ b/drivers/mtd/devices/block2mtd.c
18200 +@@ -17,6 +17,7 @@
18201 + #include <linux/list.h>
18202 + #include <linux/init.h>
18203 + #include <linux/mtd/mtd.h>
18204 ++#include <linux/mtd/partitions.h>
18205 + #include <linux/mutex.h>
18206 + #include <linux/mount.h>
18207 + #include <linux/slab.h>
18208 +@@ -208,12 +209,12 @@ static void block2mtd_free_device(struct
18209 + kfree(dev);
18213 +-static struct block2mtd_dev *add_device(char *devname, int erase_size)
18214 ++static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
18216 + const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
18217 + struct block_device *bdev;
18218 + struct block2mtd_dev *dev;
18219 ++ struct mtd_partition *part;
18220 + char *name;
18222 + if (!devname)
18223 +@@ -258,12 +259,14 @@ static struct block2mtd_dev *add_device(
18224 + /* Setup the MTD structure */
18225 + /* make the name contain the block device in */
18226 + name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
18227 +- if (!name)
18228 +- goto err_destroy_mutex;
18229 ++ if (!mtdname)
18230 ++ mtdname = devname;
18231 ++ name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
18233 ++ strcpy(name, mtdname);
18234 + dev->mtd.name = name;
18236 +- dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
18237 ++ dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1);
18238 + dev->mtd.erasesize = erase_size;
18239 + dev->mtd.writesize = 1;
18240 + dev->mtd.writebufsize = PAGE_SIZE;
18241 +@@ -276,15 +279,18 @@ static struct block2mtd_dev *add_device(
18242 + dev->mtd.priv = dev;
18243 + dev->mtd.owner = THIS_MODULE;
18245 +- if (mtd_device_register(&dev->mtd, NULL, 0)) {
18246 ++ part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
18247 ++ part->name = name;
18248 ++ part->offset = 0;
18249 ++ part->size = dev->mtd.size;
18250 ++ if (mtd_device_register(&dev->mtd, part, 1)) {
18251 + /* Device didn't get added, so free the entry */
18252 + goto err_destroy_mutex;
18254 + list_add(&dev->list, &blkmtd_device_list);
18255 + pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n",
18256 + dev->mtd.index,
18257 +- dev->mtd.name + strlen("block2mtd: "),
18258 +- dev->mtd.erasesize >> 10, dev->mtd.erasesize);
18259 ++ mtdname, dev->mtd.erasesize >> 10, dev->mtd.erasesize);
18260 + return dev;
18262 + err_destroy_mutex:
18263 +@@ -353,9 +359,9 @@ static char block2mtd_paramline[80 + 12]
18265 + static int block2mtd_setup2(const char *val)
18267 +- char buf[80 + 12]; /* 80 for device, 12 for erase size */
18268 ++ char buf[80 + 12 + 80]; /* 80 for device, 12 for erase size, 80 for name */
18269 + char *str = buf;
18270 +- char *token[2];
18271 ++ char *token[3];
18272 + char *name;
18273 + size_t erase_size = PAGE_SIZE;
18274 + int i, ret;
18275 +@@ -368,7 +374,7 @@ static int block2mtd_setup2(const char *
18276 + strcpy(str, val);
18277 + kill_final_newline(str);
18279 +- for (i = 0; i < 2; i++)
18280 ++ for (i = 0; i < 3; i++)
18281 + token[i] = strsep(&str, ",");
18283 + if (str) {
18284 +@@ -394,8 +400,10 @@ static int block2mtd_setup2(const char *
18285 + return 0;
18288 ++ if (token[2] && (strlen(token[2]) + 1 > 80))
18289 ++ pr_err("mtd device name too long\n");
18291 +- add_device(name, erase_size);
18292 ++ add_device(name, erase_size, token[2]);
18294 + return 0;
18296 +@@ -429,7 +437,7 @@ static int block2mtd_setup(const char *v
18299 + module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
18300 +-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
18301 ++MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
18303 + static int __init block2mtd_init(void)
18305 diff --git a/target/linux/generic/patches-3.16/441-block2mtd_probe.patch b/target/linux/generic/patches-3.16/441-block2mtd_probe.patch
18306 new file mode 100644
18307 index 000000000000..1c81ccde129e
18308 --- /dev/null
18309 +++ b/target/linux/generic/patches-3.16/441-block2mtd_probe.patch
18310 @@ -0,0 +1,108 @@
18311 +--- a/drivers/mtd/devices/block2mtd.c
18312 ++++ b/drivers/mtd/devices/block2mtd.c
18313 +@@ -10,6 +10,7 @@
18314 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18316 + #include <linux/module.h>
18317 ++#include <linux/delay.h>
18318 + #include <linux/fs.h>
18319 + #include <linux/blkdev.h>
18320 + #include <linux/bio.h>
18321 +@@ -209,13 +210,14 @@ static void block2mtd_free_device(struct
18322 + kfree(dev);
18325 +-static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
18326 ++static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname, int timeout)
18328 + const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
18329 +- struct block_device *bdev;
18330 ++ struct block_device *bdev = ERR_PTR(-ENODEV);
18331 + struct block2mtd_dev *dev;
18332 + struct mtd_partition *part;
18333 + char *name;
18334 ++ int i;
18336 + if (!devname)
18337 + return NULL;
18338 +@@ -226,15 +228,20 @@ static struct block2mtd_dev *add_device(
18340 + /* Get a handle on the device */
18341 + bdev = blkdev_get_by_path(devname, mode, dev);
18343 + #ifndef MODULE
18344 +- if (IS_ERR(bdev)) {
18345 ++ for (i = 0; IS_ERR(bdev) && i <= timeout; i++) {
18346 ++ dev_t devt;
18348 +- /* We might not have rootfs mounted at this point. Try
18349 +- to resolve the device name by other means. */
18350 ++ if (i)
18351 ++ msleep(1000);
18352 ++ wait_for_device_probe();
18354 ++ devt = name_to_dev_t(devname);
18355 ++ if (!devt)
18356 ++ continue;
18358 +- dev_t devt = name_to_dev_t(devname);
18359 +- if (devt)
18360 +- bdev = blkdev_get_by_dev(devt, mode, dev);
18361 ++ bdev = blkdev_get_by_dev(devt, mode, dev);
18363 + #endif
18365 +@@ -359,11 +366,12 @@ static char block2mtd_paramline[80 + 12]
18367 + static int block2mtd_setup2(const char *val)
18369 +- char buf[80 + 12 + 80]; /* 80 for device, 12 for erase size, 80 for name */
18370 ++ char buf[80 + 12 + 80 + 8]; /* 80 for device, 12 for erase size, 80 for name, 8 for timeout */
18371 + char *str = buf;
18372 +- char *token[3];
18373 ++ char *token[4];
18374 + char *name;
18375 + size_t erase_size = PAGE_SIZE;
18376 ++ unsigned long timeout = 0;
18377 + int i, ret;
18379 + if (strnlen(val, sizeof(buf)) >= sizeof(buf)) {
18380 +@@ -374,7 +382,7 @@ static int block2mtd_setup2(const char *
18381 + strcpy(str, val);
18382 + kill_final_newline(str);
18384 +- for (i = 0; i < 3; i++)
18385 ++ for (i = 0; i < 4; i++)
18386 + token[i] = strsep(&str, ",");
18388 + if (str) {
18389 +@@ -403,7 +411,10 @@ static int block2mtd_setup2(const char *
18390 + if (token[2] && (strlen(token[2]) + 1 > 80))
18391 + pr_err("mtd device name too long\n");
18393 +- add_device(name, erase_size, token[2]);
18394 ++ if (token[3] && kstrtoul(token[3], 0, &timeout))
18395 ++ pr_err("invalid timeout\n");
18397 ++ add_device(name, erase_size, token[2], timeout);
18399 + return 0;
18401 +@@ -437,7 +448,7 @@ static int block2mtd_setup(const char *v
18404 + module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
18405 +-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
18406 ++MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>[,<timeout>]]]\"");
18408 + static int __init block2mtd_init(void)
18410 +@@ -472,7 +483,7 @@ static void block2mtd_exit(void)
18414 +-module_init(block2mtd_init);
18415 ++late_initcall(block2mtd_init);
18416 + module_exit(block2mtd_exit);
18418 + MODULE_LICENSE("GPL");
18419 diff --git a/target/linux/generic/patches-3.16/450-mtd-nand-allow-to-use-platform-specific-chip-fixup.patch b/target/linux/generic/patches-3.16/450-mtd-nand-allow-to-use-platform-specific-chip-fixup.patch
18420 new file mode 100644
18421 index 000000000000..1c23bb549b08
18422 --- /dev/null
18423 +++ b/target/linux/generic/patches-3.16/450-mtd-nand-allow-to-use-platform-specific-chip-fixup.patch
18424 @@ -0,0 +1,37 @@
18425 +---
18426 + drivers/mtd/nand/plat_nand.c | 13 ++++++++++++-
18427 + include/linux/mtd/nand.h | 1 +
18428 + 2 files changed, 13 insertions(+), 1 deletion(-)
18430 +--- a/include/linux/mtd/nand.h
18431 ++++ b/include/linux/mtd/nand.h
18432 +@@ -756,6 +756,7 @@ struct platform_nand_chip {
18433 + unsigned int options;
18434 + unsigned int bbt_options;
18435 + const char **part_probe_types;
18436 ++ int (*chip_fixup)(struct mtd_info *mtd);
18437 + };
18439 + /* Keep gcc happy */
18440 +--- a/drivers/mtd/nand/plat_nand.c
18441 ++++ b/drivers/mtd/nand/plat_nand.c
18442 +@@ -90,7 +90,18 @@ static int plat_nand_probe(struct platfo
18445 + /* Scan to find existence of the device */
18446 +- if (nand_scan(&data->mtd, pdata->chip.nr_chips)) {
18447 ++ if (nand_scan_ident(&data->mtd, pdata->chip.nr_chips, NULL)) {
18448 ++ err = -ENXIO;
18449 ++ goto out;
18450 ++ }
18452 ++ if (pdata->chip.chip_fixup) {
18453 ++ err = pdata->chip.chip_fixup(&data->mtd);
18454 ++ if (err)
18455 ++ goto out;
18456 ++ }
18458 ++ if (nand_scan_tail(&data->mtd)) {
18459 + err = -ENXIO;
18460 + goto out;
18462 diff --git a/target/linux/generic/patches-3.16/451-mtd-nand-fix-return-code-of-nand_correct_data-function.patch b/target/linux/generic/patches-3.16/451-mtd-nand-fix-return-code-of-nand_correct_data-function.patch
18463 new file mode 100644
18464 index 000000000000..6a2092ce20e4
18465 --- /dev/null
18466 +++ b/target/linux/generic/patches-3.16/451-mtd-nand-fix-return-code-of-nand_correct_data-function.patch
18467 @@ -0,0 +1,11 @@
18468 +--- a/drivers/mtd/nand/nand_ecc.c
18469 ++++ b/drivers/mtd/nand/nand_ecc.c
18470 +@@ -507,7 +507,7 @@ int __nand_correct_data(unsigned char *b
18471 + return 1; /* error in ECC data; no action needed */
18473 + pr_err("%s: uncorrectable ECC error\n", __func__);
18474 +- return -1;
18475 ++ return -EBADMSG;
18477 + EXPORT_SYMBOL(__nand_correct_data);
18479 diff --git a/target/linux/generic/patches-3.16/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch b/target/linux/generic/patches-3.16/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch
18480 new file mode 100644
18481 index 000000000000..0854a564c6a2
18482 --- /dev/null
18483 +++ b/target/linux/generic/patches-3.16/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch
18484 @@ -0,0 +1,11 @@
18485 +--- a/drivers/mtd/chips/cfi_cmdset_0002.c
18486 ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c
18487 +@@ -780,7 +780,7 @@ static int get_chip(struct map_info *map
18488 + return 0;
18490 + case FL_ERASING:
18491 +- if (!cfip || !(cfip->EraseSuspend & (0x1|0x2)) ||
18492 ++ if (1 /* no suspend */ || !cfip || !(cfip->EraseSuspend & (0x1|0x2)) ||
18493 + !(mode == FL_READY || mode == FL_POINT ||
18494 + (mode == FL_WRITING && (cfip->EraseSuspend & 0x2))))
18495 + goto sleep;
18496 diff --git a/target/linux/generic/patches-3.16/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch b/target/linux/generic/patches-3.16/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch
18497 new file mode 100644
18498 index 000000000000..b5fae8aee753
18499 --- /dev/null
18500 +++ b/target/linux/generic/patches-3.16/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch
18501 @@ -0,0 +1,18 @@
18502 +From: George Kashperko <george@znau.edu.ua>
18504 +Issue map read after Write Buffer Load command to ensure chip is ready
18505 +to receive data.
18506 +Signed-off-by: George Kashperko <george@znau.edu.ua>
18507 +---
18508 + drivers/mtd/chips/cfi_cmdset_0002.c | 1 +
18509 + 1 file changed, 1 insertion(+)
18510 +--- a/drivers/mtd/chips/cfi_cmdset_0002.c
18511 ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c
18512 +@@ -1498,6 +1498,7 @@ static int __xipram do_write_buffer(stru
18514 + /* Write Buffer Load */
18515 + map_write(map, CMD(0x25), cmd_adr);
18516 ++ (void) map_read(map, cmd_adr);
18518 + chip->state = FL_WRITING_TO_BUFFER;
18520 diff --git a/target/linux/generic/patches-3.16/471-mtd-spi-nor-allow-to-disable-small-sector-erase.patch b/target/linux/generic/patches-3.16/471-mtd-spi-nor-allow-to-disable-small-sector-erase.patch
18521 new file mode 100644
18522 index 000000000000..726b628844b5
18523 --- /dev/null
18524 +++ b/target/linux/generic/patches-3.16/471-mtd-spi-nor-allow-to-disable-small-sector-erase.patch
18525 @@ -0,0 +1,27 @@
18526 +--- a/drivers/mtd/spi-nor/Kconfig
18527 ++++ b/drivers/mtd/spi-nor/Kconfig
18528 +@@ -7,6 +7,13 @@ menuconfig MTD_SPI_NOR
18530 + if MTD_SPI_NOR
18532 ++config MTD_SPI_NOR_PREFER_SMALL_SECTOR_ERASE
18533 ++ bool "Prefer small sector erase"
18534 ++ default y
18535 ++ help
18536 ++ This option enables use of the small erase sectors if that is
18537 ++ supported by the flash chip.
18539 + config SPI_FSL_QUADSPI
18540 + tristate "Freescale Quad SPI controller"
18541 + depends on ARCH_MXC
18542 +--- a/drivers/mtd/spi-nor/spi-nor.c
18543 ++++ b/drivers/mtd/spi-nor/spi-nor.c
18544 +@@ -966,7 +966,7 @@ int spi_nor_scan(struct spi_nor *nor, co
18545 + mtd->_write = spi_nor_write;
18547 + /* prefer "small sector" erase if possible */
18548 +- if (info->flags & SECT_4K) {
18549 ++ if (IS_ENABLED(CONFIG_MTD_SPI_NOR_PREFER_SMALL_SECTOR_ERASE) && (info->flags & SECT_4K)) {
18550 + nor->erase_opcode = SPINOR_OP_BE_4K;
18551 + mtd->erasesize = 4096;
18552 + } else if (info->flags & SECT_4K_PMC) {
18553 diff --git a/target/linux/generic/patches-3.16/472-mtd-spi-nor-add-support-for-Winbond-W25X05-flash.patch b/target/linux/generic/patches-3.16/472-mtd-spi-nor-add-support-for-Winbond-W25X05-flash.patch
18554 new file mode 100644
18555 index 000000000000..af61b11be701
18556 --- /dev/null
18557 +++ b/target/linux/generic/patches-3.16/472-mtd-spi-nor-add-support-for-Winbond-W25X05-flash.patch
18558 @@ -0,0 +1,20 @@
18559 +From f9ba2cb809cdb5e7141dcb90dcd614349a6db8f8 Mon Sep 17 00:00:00 2001
18560 +From: Gabor Juhos <juhosg@openwrt.org>
18561 +Date: Wed, 11 Dec 2013 19:05:59 +0100
18562 +Subject: [PATCH] spi-nor: add support for the Winbond W25X05 flash
18564 +Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
18565 +---
18566 + drivers/mtd/spi-nor/spi-nor.c | 1 +
18567 + 1 file changed, 1 insertion(+)
18569 +--- a/drivers/mtd/spi-nor/spi-nor.c
18570 ++++ b/drivers/mtd/spi-nor/spi-nor.c
18571 +@@ -564,6 +564,7 @@ const struct spi_device_id spi_nor_ids[]
18572 + { "m25px64", INFO(0x207117, 0, 64 * 1024, 128, 0) },
18574 + /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
18575 ++ { "w25x05", INFO(0xef3010, 0, 64 * 1024, 1, SECT_4K) },
18576 + { "w25x10", INFO(0xef3011, 0, 64 * 1024, 2, SECT_4K) },
18577 + { "w25x20", INFO(0xef3012, 0, 64 * 1024, 4, SECT_4K) },
18578 + { "w25x40", INFO(0xef3013, 0, 64 * 1024, 8, SECT_4K) },
18579 diff --git a/target/linux/generic/patches-3.16/473-mtd-spi-nor-add-support-for-EON-EN25QH128-flash.patch b/target/linux/generic/patches-3.16/473-mtd-spi-nor-add-support-for-EON-EN25QH128-flash.patch
18580 new file mode 100644
18581 index 000000000000..f478cd89a0de
18582 --- /dev/null
18583 +++ b/target/linux/generic/patches-3.16/473-mtd-spi-nor-add-support-for-EON-EN25QH128-flash.patch
18584 @@ -0,0 +1,20 @@
18585 +From dc84306ee8b6a0217a324684289eb850c21a9601 Mon Sep 17 00:00:00 2001
18586 +From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
18587 +Date: Wed, 11 Jun 2014 02:23:00 +0400
18588 +Subject: [PATCH] mtd: spi-nor: add support for EON EN25QH128
18590 +Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
18591 +---
18592 + drivers/mtd/spi-nor/spi-nor.c | 1 +
18593 + 1 file changed, 1 insertion(+)
18595 +--- a/drivers/mtd/spi-nor/spi-nor.c
18596 ++++ b/drivers/mtd/spi-nor/spi-nor.c
18597 +@@ -449,6 +449,7 @@ const struct spi_device_id spi_nor_ids[]
18598 + { "en25q32b", INFO(0x1c3016, 0, 64 * 1024, 64, 0) },
18599 + { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) },
18600 + { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) },
18601 ++ { "en25qh128", INFO(0x1c7018, 0, 64 * 1024, 256, 0) },
18602 + { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) },
18604 + /* ESMT */
18605 diff --git a/target/linux/generic/patches-3.16/480-mtd-set-rootfs-to-be-root-dev.patch b/target/linux/generic/patches-3.16/480-mtd-set-rootfs-to-be-root-dev.patch
18606 new file mode 100644
18607 index 000000000000..b7cff8c11979
18608 --- /dev/null
18609 +++ b/target/linux/generic/patches-3.16/480-mtd-set-rootfs-to-be-root-dev.patch
18610 @@ -0,0 +1,26 @@
18611 +--- a/drivers/mtd/mtdcore.c
18612 ++++ b/drivers/mtd/mtdcore.c
18613 +@@ -37,6 +37,7 @@
18614 + #include <linux/backing-dev.h>
18615 + #include <linux/gfp.h>
18616 + #include <linux/slab.h>
18617 ++#include <linux/root_dev.h>
18619 + #include <linux/mtd/mtd.h>
18620 + #include <linux/mtd/partitions.h>
18621 +@@ -414,6 +415,15 @@ int add_mtd_device(struct mtd_info *mtd)
18622 + of this try_ nonsense, and no bitching about it
18623 + either. :) */
18624 + __module_get(THIS_MODULE);
18626 ++ if (!strcmp(mtd->name, "rootfs") &&
18627 ++ config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
18628 ++ ROOT_DEV == 0) {
18629 ++ pr_notice("mtd: device %d (%s) set to be root filesystem\n",
18630 ++ mtd->index, mtd->name);
18631 ++ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
18632 ++ }
18634 + return 0;
18636 + fail_added:
18637 diff --git a/target/linux/generic/patches-3.16/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch b/target/linux/generic/patches-3.16/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
18638 new file mode 100644
18639 index 000000000000..ed836666615e
18640 --- /dev/null
18641 +++ b/target/linux/generic/patches-3.16/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
18642 @@ -0,0 +1,63 @@
18643 +From 8a52e4100d7c3a4a1dfddfa02b8864a9b0068c13 Mon Sep 17 00:00:00 2001
18644 +From: Daniel Golle <daniel@makrotopia.org>
18645 +Date: Sat, 17 May 2014 03:36:18 +0200
18646 +Subject: [PATCH 1/5] ubi: auto-attach mtd device named "ubi" or "data" on boot
18647 +To: openwrt-devel@lists.openwrt.org
18649 +Signed-off-by: Daniel Golle <daniel@makrotopia.org>
18650 +---
18651 + drivers/mtd/ubi/build.c | 36 ++++++++++++++++++++++++++++++++++++
18652 + 1 file changed, 36 insertions(+)
18654 +--- a/drivers/mtd/ubi/build.c
18655 ++++ b/drivers/mtd/ubi/build.c
18656 +@@ -1209,6 +1209,36 @@ static struct mtd_info * __init open_mtd
18657 + return mtd;
18660 ++/*
18661 ++ * This function tries attaching mtd partitions named either "ubi" or "data"
18662 ++ * during boot.
18663 ++ */
18664 ++static void __init ubi_auto_attach(void)
18666 ++ int err;
18667 ++ struct mtd_info *mtd;
18668 ++ /* try attaching mtd device named "ubi" or "data" */
18669 ++ mtd = open_mtd_device("ubi");
18670 ++ if (IS_ERR(mtd))
18671 ++ mtd = open_mtd_device("data");
18673 ++ if (!IS_ERR(mtd)) {
18674 ++ /* auto-add only media types where UBI makes sense */
18675 ++ if (mtd->type == MTD_NANDFLASH ||
18676 ++ mtd->type == MTD_DATAFLASH ||
18677 ++ mtd->type == MTD_MLCNANDFLASH) {
18678 ++ mutex_lock(&ubi_devices_mutex);
18679 ++ ubi_msg("auto-attach mtd%d", mtd->index);
18680 ++ err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 0, 0);
18681 ++ mutex_unlock(&ubi_devices_mutex);
18682 ++ if (err < 0) {
18683 ++ ubi_err("cannot attach mtd%d", mtd->index);
18684 ++ put_mtd_device(mtd);
18685 ++ }
18686 ++ }
18687 ++ }
18690 + static int __init ubi_init(void)
18692 + int err, i, k;
18693 +@@ -1298,6 +1328,12 @@ static int __init ubi_init(void)
18697 ++ /* auto-attach mtd devices only if built-in to the kernel and no ubi.mtd
18698 ++ * parameter was given */
18699 ++ if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
18700 ++ !ubi_is_module() && !mtd_devs)
18701 ++ ubi_auto_attach();
18703 + err = ubiblock_init();
18704 + if (err) {
18705 + ubi_err("block: cannot initialize, error %d", err);
18706 diff --git a/target/linux/generic/patches-3.16/491-ubi-auto-create-ubiblock-device-for-rootfs.patch b/target/linux/generic/patches-3.16/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
18707 new file mode 100644
18708 index 000000000000..3d59b44472b1
18709 --- /dev/null
18710 +++ b/target/linux/generic/patches-3.16/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
18711 @@ -0,0 +1,69 @@
18712 +From 0f3966579815f889bb2fcb4846152c35f65e79c4 Mon Sep 17 00:00:00 2001
18713 +From: Daniel Golle <daniel@makrotopia.org>
18714 +Date: Thu, 15 May 2014 21:06:33 +0200
18715 +Subject: [PATCH 2/5] ubi: auto-create ubiblock device for rootfs
18716 +To: openwrt-devel@lists.openwrt.org
18718 +Signed-off-by: Daniel Golle <daniel@makrotopia.org>
18719 +---
18720 + drivers/mtd/ubi/block.c | 42 ++++++++++++++++++++++++++++++++++++++++++
18721 + 1 file changed, 42 insertions(+)
18723 +--- a/drivers/mtd/ubi/block.c
18724 ++++ b/drivers/mtd/ubi/block.c
18725 +@@ -593,6 +593,44 @@ static int __init ubiblock_create_from_p
18726 + return ret;
18729 ++#define UBIFS_NODE_MAGIC 0x06101831
18730 ++static inline int ubi_vol_is_ubifs(struct ubi_volume_desc *desc)
18732 ++ int ret;
18733 ++ uint32_t magic_of, magic;
18734 ++ ret = ubi_read(desc, 0, (char *)&magic_of, 0, 4);
18735 ++ if (ret)
18736 ++ return 0;
18737 ++ magic = le32_to_cpu(magic_of);
18738 ++ return magic == UBIFS_NODE_MAGIC;
18741 ++static void __init ubiblock_create_auto_rootfs(void)
18743 ++ int ubi_num, ret, is_ubifs;
18744 ++ struct ubi_volume_desc *desc;
18745 ++ struct ubi_volume_info vi;
18747 ++ for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++) {
18748 ++ desc = ubi_open_volume_nm(ubi_num, "rootfs", UBI_READONLY);
18749 ++ if (IS_ERR(desc))
18750 ++ continue;
18752 ++ ubi_get_volume_info(desc, &vi);
18753 ++ is_ubifs = ubi_vol_is_ubifs(desc);
18754 ++ ubi_close_volume(desc);
18755 ++ if (is_ubifs)
18756 ++ break;
18758 ++ ret = ubiblock_create(&vi);
18759 ++ if (ret)
18760 ++ ubi_err("block: can't add '%s' volume, err=%d\n",
18761 ++ vi.name, ret);
18762 ++ /* always break if we get here */
18763 ++ break;
18764 ++ }
18767 + static void ubiblock_remove_all(void)
18769 + struct ubiblock *next;
18770 +@@ -623,6 +661,10 @@ int __init ubiblock_init(void)
18771 + if (ret)
18772 + goto err_remove;
18774 ++ /* auto-attach "rootfs" volume if existing and non-ubifs */
18775 ++ if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV))
18776 ++ ubiblock_create_auto_rootfs();
18778 + /*
18779 + * Block devices are only created upon user requests, so we ignore
18780 + * existing volumes.
18781 diff --git a/target/linux/generic/patches-3.16/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch b/target/linux/generic/patches-3.16/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch
18782 new file mode 100644
18783 index 000000000000..c36dbe3243e4
18784 --- /dev/null
18785 +++ b/target/linux/generic/patches-3.16/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch
18786 @@ -0,0 +1,53 @@
18787 +From eea9e1785e4c05c2a3444506aabafa0ae958538f Mon Sep 17 00:00:00 2001
18788 +From: Daniel Golle <daniel@makrotopia.org>
18789 +Date: Sat, 17 May 2014 03:35:02 +0200
18790 +Subject: [PATCH 4/5] try auto-mounting ubi0:rootfs in init/do_mounts.c
18791 +To: openwrt-devel@lists.openwrt.org
18793 +Signed-off-by: Daniel Golle <daniel@makrotopia.org>
18794 +---
18795 + init/do_mounts.c | 26 +++++++++++++++++++++++++-
18796 + 1 file changed, 25 insertions(+), 1 deletion(-)
18798 +--- a/init/do_mounts.c
18799 ++++ b/init/do_mounts.c
18800 +@@ -432,7 +432,27 @@ retry:
18801 + out:
18802 + put_page(page);
18806 ++static int __init mount_ubi_rootfs(void)
18808 ++ int flags = MS_SILENT;
18809 ++ int err, tried = 0;
18811 ++ while (tried < 2) {
18812 ++ err = do_mount_root("ubi0:rootfs", "ubifs", flags, \
18813 ++ root_mount_data);
18814 ++ switch (err) {
18815 ++ case -EACCES:
18816 ++ flags |= MS_RDONLY;
18817 ++ tried++;
18818 ++ default:
18819 ++ return err;
18820 ++ }
18821 ++ }
18823 ++ return -EINVAL;
18826 + #ifdef CONFIG_ROOT_NFS
18828 + #define NFSROOT_TIMEOUT_MIN 5
18829 +@@ -526,6 +546,10 @@ void __init mount_root(void)
18830 + change_floppy("root floppy");
18832 + #endif
18833 ++#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
18834 ++ if (!mount_ubi_rootfs())
18835 ++ return;
18836 ++#endif
18837 + #ifdef CONFIG_BLOCK
18838 + create_dev("/dev/root", ROOT_DEV);
18839 + mount_block_root("/dev/root", root_mountflags);
18840 diff --git a/target/linux/generic/patches-3.16/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch b/target/linux/generic/patches-3.16/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch
18841 new file mode 100644
18842 index 000000000000..cea598d67425
18843 --- /dev/null
18844 +++ b/target/linux/generic/patches-3.16/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch
18845 @@ -0,0 +1,37 @@
18846 +From cd68d1b12b5ea4c01a664c064179ada42bf55d3d Mon Sep 17 00:00:00 2001
18847 +From: Daniel Golle <daniel@makrotopia.org>
18848 +Date: Thu, 15 May 2014 20:55:42 +0200
18849 +Subject: [PATCH 5/5] ubi: set ROOT_DEV to ubiblock "rootfs" if unset
18850 +To: openwrt-devel@lists.openwrt.org
18852 +Signed-off-by: Daniel Golle <daniel@makrotopia.org>
18853 +---
18854 + drivers/mtd/ubi/block.c | 10 ++++++++++
18855 + 1 file changed, 10 insertions(+)
18857 +--- a/drivers/mtd/ubi/block.c
18858 ++++ b/drivers/mtd/ubi/block.c
18859 +@@ -48,6 +48,7 @@
18860 + #include <linux/blkdev.h>
18861 + #include <linux/hdreg.h>
18862 + #include <asm/div64.h>
18863 ++#include <linux/root_dev.h>
18865 + #include "ubi-media.h"
18866 + #include "ubi.h"
18867 +@@ -444,6 +445,15 @@ int ubiblock_create(struct ubi_volume_in
18868 + add_disk(dev->gd);
18869 + ubi_msg("%s created from ubi%d:%d(%s)",
18870 + dev->gd->disk_name, dev->ubi_num, dev->vol_id, vi->name);
18872 ++ if (!strcmp(vi->name, "rootfs") &&
18873 ++ config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
18874 ++ ROOT_DEV == 0) {
18875 ++ pr_notice("ubiblock: device ubiblock%d_%d (%s) set to be root filesystem\n",
18876 ++ dev->ubi_num, dev->vol_id, vi->name);
18877 ++ ROOT_DEV = MKDEV(gd->major, gd->first_minor);
18878 ++ }
18880 + return 0;
18882 + out_free_queue:
18883 diff --git a/target/linux/generic/patches-3.16/500-yaffs-Kbuild-integration.patch b/target/linux/generic/patches-3.16/500-yaffs-Kbuild-integration.patch
18884 new file mode 100644
18885 index 000000000000..de6643a41e62
18886 --- /dev/null
18887 +++ b/target/linux/generic/patches-3.16/500-yaffs-Kbuild-integration.patch
18888 @@ -0,0 +1,18 @@
18889 +--- a/fs/Kconfig
18890 ++++ b/fs/Kconfig
18891 +@@ -39,6 +39,7 @@ source "fs/gfs2/Kconfig"
18892 + source "fs/ocfs2/Kconfig"
18893 + source "fs/btrfs/Kconfig"
18894 + source "fs/nilfs2/Kconfig"
18895 ++source "fs/yaffs2/Kconfig"
18897 + endif # BLOCK
18899 +--- a/fs/Makefile
18900 ++++ b/fs/Makefile
18901 +@@ -126,3 +126,5 @@ obj-y += exofs/ # Multiple modules
18902 + obj-$(CONFIG_CEPH_FS) += ceph/
18903 + obj-$(CONFIG_PSTORE) += pstore/
18904 + obj-$(CONFIG_EFIVAR_FS) += efivarfs/
18905 ++obj-$(CONFIG_YAFFS_FS) += yaffs2/
18907 diff --git a/target/linux/generic/patches-3.16/501-yaffs-3.5-convert-to-use-kuid_t-kgid_t.patch b/target/linux/generic/patches-3.16/501-yaffs-3.5-convert-to-use-kuid_t-kgid_t.patch
18908 new file mode 100644
18909 index 000000000000..c1f7367dd8d0
18910 --- /dev/null
18911 +++ b/target/linux/generic/patches-3.16/501-yaffs-3.5-convert-to-use-kuid_t-kgid_t.patch
18912 @@ -0,0 +1,155 @@
18913 +--- a/fs/yaffs2/yaffs_vfs.c
18914 ++++ b/fs/yaffs2/yaffs_vfs.c
18915 +@@ -329,6 +329,33 @@ static int yaffs_readpage(struct file *f
18916 + return ret;
18919 ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0))
18920 ++#define YCRED_FSUID() from_kuid(&init_user_ns, current_fsuid())
18921 ++#define YCRED_FSGID() from_kgid(&init_user_ns, current_fsgid())
18922 ++#else
18923 ++#define YCRED_FSUID() YCRED(current)->fsuid
18924 ++#define YCRED_FSGID() YCRED(current)->fsgid
18926 ++static inline uid_t i_uid_read(const struct inode *inode)
18928 ++ return inode->i_uid;
18931 ++static inline gid_t i_gid_read(const struct inode *inode)
18933 ++ return inode->i_gid;
18936 ++static inline void i_uid_write(struct inode *inode, uid_t uid)
18938 ++ inode->i_uid = uid;
18941 ++static inline void i_gid_write(struct inode *inode, gid_t gid)
18943 ++ inode->i_gid = gid;
18945 ++#endif
18947 + static void yaffs_set_super_dirty_val(struct yaffs_dev *dev, int val)
18949 +@@ -1225,9 +1252,9 @@ static int yaffs_mknod(struct inode *dir
18950 + struct yaffs_obj *parent = yaffs_inode_to_obj(dir);
18952 + int error = -ENOSPC;
18953 +- uid_t uid = YCRED(current)->fsuid;
18954 ++ uid_t uid = YCRED_FSUID();
18955 + gid_t gid =
18956 +- (dir->i_mode & S_ISGID) ? dir->i_gid : YCRED(current)->fsgid;
18957 ++ (dir->i_mode & S_ISGID) ? i_gid_read(dir) : YCRED_FSGID();
18959 + if ((dir->i_mode & S_ISGID) && S_ISDIR(mode))
18960 + mode |= S_ISGID;
18961 +@@ -1424,9 +1451,9 @@ static int yaffs_symlink(struct inode *d
18963 + struct yaffs_obj *obj;
18964 + struct yaffs_dev *dev;
18965 +- uid_t uid = YCRED(current)->fsuid;
18966 ++ uid_t uid = YCRED_FSUID();
18967 + gid_t gid =
18968 +- (dir->i_mode & S_ISGID) ? dir->i_gid : YCRED(current)->fsgid;
18969 ++ (dir->i_mode & S_ISGID) ? i_gid_read(dir) : YCRED_FSGID();
18971 + yaffs_trace(YAFFS_TRACE_OS, "yaffs_symlink");
18973 +@@ -1829,8 +1856,8 @@ static void yaffs_fill_inode_from_obj(st
18975 + inode->i_ino = obj->obj_id;
18976 + inode->i_mode = obj->yst_mode;
18977 +- inode->i_uid = obj->yst_uid;
18978 +- inode->i_gid = obj->yst_gid;
18979 ++ i_uid_write(inode, obj->yst_uid);
18980 ++ i_gid_write(inode, obj->yst_gid);
18981 + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
18982 + inode->i_blksize = inode->i_sb->s_blocksize;
18983 + #endif
18984 +@@ -1856,7 +1883,7 @@ static void yaffs_fill_inode_from_obj(st
18986 + yaffs_trace(YAFFS_TRACE_OS,
18987 + "yaffs_fill_inode mode %x uid %d gid %d size %lld count %d",
18988 +- inode->i_mode, inode->i_uid, inode->i_gid,
18989 ++ inode->i_mode, i_uid_read(inode), i_gid_read(inode),
18990 + inode->i_size, atomic_read(&inode->i_count));
18992 + switch (obj->yst_mode & S_IFMT) {
18993 +--- a/fs/yaffs2/yaffs_attribs.c
18994 ++++ b/fs/yaffs2/yaffs_attribs.c
18995 +@@ -14,6 +14,48 @@
18996 + #include "yaffs_guts.h"
18997 + #include "yaffs_attribs.h"
18999 ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0))
19000 ++static inline uid_t ia_uid_read(const struct iattr *iattr)
19002 ++ return from_kuid(&init_user_ns, iattr->ia_uid);
19005 ++static inline gid_t ia_gid_read(const struct iattr *iattr)
19007 ++ return from_kgid(&init_user_ns, iattr->ia_gid);
19010 ++static inline void ia_uid_write(struct iattr *iattr, uid_t uid)
19012 ++ iattr->ia_uid = make_kuid(&init_user_ns, uid);
19015 ++static inline void ia_gid_write(struct iattr *iattr, gid_t gid)
19017 ++ iattr->ia_gid = make_kgid(&init_user_ns, gid);
19019 ++#else
19020 ++static inline uid_t ia_uid_read(const struct iattr *iattr)
19022 ++ return iattr->ia_uid;
19025 ++static inline gid_t ia_gid_read(const struct iattr *inode)
19027 ++ return iattr->ia_gid;
19030 ++static inline void ia_uid_write(struct iattr *iattr, uid_t uid)
19032 ++ iattr->ia_uid = uid;
19035 ++static inline void ia_gid_write(struct iattr *iattr, gid_t gid)
19037 ++ iattr->ia_gid = gid;
19039 ++#endif
19041 + void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
19043 + obj->yst_uid = oh->yst_uid;
19044 +@@ -77,9 +119,9 @@ int yaffs_set_attribs(struct yaffs_obj *
19045 + if (valid & ATTR_MODE)
19046 + obj->yst_mode = attr->ia_mode;
19047 + if (valid & ATTR_UID)
19048 +- obj->yst_uid = attr->ia_uid;
19049 ++ obj->yst_uid = ia_uid_read(attr);
19050 + if (valid & ATTR_GID)
19051 +- obj->yst_gid = attr->ia_gid;
19052 ++ obj->yst_gid = ia_gid_read(attr);
19054 + if (valid & ATTR_ATIME)
19055 + obj->yst_atime = Y_TIME_CONVERT(attr->ia_atime);
19056 +@@ -103,9 +145,9 @@ int yaffs_get_attribs(struct yaffs_obj *
19058 + attr->ia_mode = obj->yst_mode;
19059 + valid |= ATTR_MODE;
19060 +- attr->ia_uid = obj->yst_uid;
19061 ++ ia_uid_write(attr, obj->yst_uid);
19062 + valid |= ATTR_UID;
19063 +- attr->ia_gid = obj->yst_gid;
19064 ++ ia_gid_write(attr, obj->yst_gid);
19065 + valid |= ATTR_GID;
19067 + Y_TIME_CONVERT(attr->ia_atime) = obj->yst_atime;
19068 diff --git a/target/linux/generic/patches-3.16/502-yaffs-3.10-disable-proc-entry.patch b/target/linux/generic/patches-3.16/502-yaffs-3.10-disable-proc-entry.patch
19069 new file mode 100644
19070 index 000000000000..5b73d3898b42
19071 --- /dev/null
19072 +++ b/target/linux/generic/patches-3.16/502-yaffs-3.10-disable-proc-entry.patch
19073 @@ -0,0 +1,44 @@
19074 +--- a/fs/yaffs2/yaffs_vfs.c
19075 ++++ b/fs/yaffs2/yaffs_vfs.c
19076 +@@ -3025,6 +3025,7 @@ static DECLARE_FSTYPE(yaffs2_fs_type, "y
19077 + #endif
19080 ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
19081 + static struct proc_dir_entry *my_proc_entry;
19083 + static char *yaffs_dump_dev_part0(char *buf, struct yaffs_dev *dev)
19084 +@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file
19085 + return yaffs_proc_debug_write(file, buf, count, data);
19086 + return yaffs_proc_write_trace_options(file, buf, count, data);
19088 ++#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)) */
19090 + /* Stuff to handle installation of file systems */
19091 + struct file_system_to_install {
19092 +@@ -3421,6 +3423,7 @@ static int __init init_yaffs_fs(void)
19094 + mutex_init(&yaffs_context_lock);
19096 ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
19097 + /* Install the proc_fs entries */
19098 + my_proc_entry = create_proc_entry("yaffs",
19099 + S_IRUGO | S_IFREG, YPROC_ROOT);
19100 +@@ -3432,6 +3435,7 @@ static int __init init_yaffs_fs(void)
19101 + } else {
19102 + return -ENOMEM;
19104 ++#endif
19106 + /* Now add the file system entries */
19108 +@@ -3468,7 +3472,9 @@ static void __exit exit_yaffs_fs(void)
19109 + yaffs_trace(YAFFS_TRACE_ALWAYS,
19110 + "yaffs built " __DATE__ " " __TIME__ " removing.");
19112 ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
19113 + remove_proc_entry("yaffs", YPROC_ROOT);
19114 ++#endif
19116 + fsinst = fs_to_install;
19118 diff --git a/target/linux/generic/patches-3.16/503-yaffs-3.12-convert-readdir-to-iterate.patch b/target/linux/generic/patches-3.16/503-yaffs-3.12-convert-readdir-to-iterate.patch
19119 new file mode 100644
19120 index 000000000000..586c141e0a4a
19121 --- /dev/null
19122 +++ b/target/linux/generic/patches-3.16/503-yaffs-3.12-convert-readdir-to-iterate.patch
19123 @@ -0,0 +1,129 @@
19124 +--- a/fs/yaffs2/yaffs_vfs.c
19125 ++++ b/fs/yaffs2/yaffs_vfs.c
19126 +@@ -1701,6 +1701,110 @@ static void yaffs_remove_obj_callback(st
19128 + /*-----------------------------------------------------------------*/
19130 ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
19131 ++static int yaffs_readdir(struct file *file, struct dir_context *ctx)
19133 ++ struct yaffs_obj *obj;
19134 ++ struct yaffs_dev *dev;
19135 ++ struct yaffs_search_context *sc;
19136 ++ struct inode *inode = file->f_dentry->d_inode;
19137 ++ unsigned long offset, curoffs;
19138 ++ struct yaffs_obj *l;
19139 ++ int ret_val = 0;
19141 ++ char name[YAFFS_MAX_NAME_LENGTH + 1];
19143 ++ obj = yaffs_dentry_to_obj(file->f_dentry);
19144 ++ dev = obj->my_dev;
19146 ++ yaffs_gross_lock(dev);
19148 ++ yaffs_dev_to_lc(dev)->readdir_process = current;
19150 ++ offset = ctx->pos;
19152 ++ sc = yaffs_new_search(obj);
19153 ++ if (!sc) {
19154 ++ ret_val = -ENOMEM;
19155 ++ goto out;
19156 ++ }
19158 ++ yaffs_trace(YAFFS_TRACE_OS,
19159 ++ "yaffs_readdir: starting at %d", (int)offset);
19161 ++ if (offset == 0) {
19162 ++ yaffs_trace(YAFFS_TRACE_OS,
19163 ++ "yaffs_readdir: entry . ino %d",
19164 ++ (int)inode->i_ino);
19165 ++ yaffs_gross_unlock(dev);
19166 ++ if (!dir_emit_dot(file, ctx)) {
19167 ++ yaffs_gross_lock(dev);
19168 ++ goto out;
19169 ++ }
19170 ++ yaffs_gross_lock(dev);
19171 ++ offset++;
19172 ++ ctx->pos++;
19173 ++ }
19174 ++ if (offset == 1) {
19175 ++ yaffs_trace(YAFFS_TRACE_OS,
19176 ++ "yaffs_readdir: entry .. ino %d",
19177 ++ (int)file->f_dentry->d_parent->d_inode->i_ino);
19178 ++ yaffs_gross_unlock(dev);
19179 ++ if (!dir_emit_dotdot(file, ctx)) {
19180 ++ yaffs_gross_lock(dev);
19181 ++ goto out;
19182 ++ }
19183 ++ yaffs_gross_lock(dev);
19184 ++ offset++;
19185 ++ ctx->pos++;
19186 ++ }
19188 ++ curoffs = 1;
19190 ++ /* If the directory has changed since the open or last call to
19191 ++ readdir, rewind to after the 2 canned entries. */
19192 ++ if (file->f_version != inode->i_version) {
19193 ++ offset = 2;
19194 ++ ctx->pos = offset;
19195 ++ file->f_version = inode->i_version;
19196 ++ }
19198 ++ while (sc->next_return) {
19199 ++ curoffs++;
19200 ++ l = sc->next_return;
19201 ++ if (curoffs >= offset) {
19202 ++ int this_inode = yaffs_get_obj_inode(l);
19203 ++ int this_type = yaffs_get_obj_type(l);
19205 ++ yaffs_get_obj_name(l, name, YAFFS_MAX_NAME_LENGTH + 1);
19206 ++ yaffs_trace(YAFFS_TRACE_OS,
19207 ++ "yaffs_readdir: %s inode %d",
19208 ++ name, yaffs_get_obj_inode(l));
19210 ++ yaffs_gross_unlock(dev);
19212 ++ if (!dir_emit(ctx, name, strlen(name),
19213 ++ this_inode, this_type) < 0) {
19214 ++ yaffs_gross_lock(dev);
19215 ++ goto out;
19216 ++ }
19218 ++ yaffs_gross_lock(dev);
19220 ++ offset++;
19221 ++ ctx->pos++;
19222 ++ }
19223 ++ yaffs_search_advance(sc);
19224 ++ }
19226 ++out:
19227 ++ yaffs_search_end(sc);
19228 ++ yaffs_dev_to_lc(dev)->readdir_process = NULL;
19229 ++ yaffs_gross_unlock(dev);
19231 ++ return ret_val;
19233 ++#else
19234 + static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
19236 + struct yaffs_obj *obj;
19237 +@@ -1807,10 +1911,15 @@ out:
19239 + return ret_val;
19241 ++#endif
19243 + static const struct file_operations yaffs_dir_operations = {
19244 + .read = generic_read_dir,
19245 ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
19246 ++ .iterate = yaffs_readdir,
19247 ++#else
19248 + .readdir = yaffs_readdir,
19249 ++#endif
19250 + .fsync = yaffs_sync_object,
19251 + .llseek = generic_file_llseek,
19252 + };
19253 diff --git a/target/linux/generic/patches-3.16/503-yaffs-add-tags-9bytes-mount-option.patch b/target/linux/generic/patches-3.16/503-yaffs-add-tags-9bytes-mount-option.patch
19254 new file mode 100644
19255 index 000000000000..5a15b516b533
19256 --- /dev/null
19257 +++ b/target/linux/generic/patches-3.16/503-yaffs-add-tags-9bytes-mount-option.patch
19258 @@ -0,0 +1,115 @@
19259 +Subject: yaffs: add support for tags-9bytes mount option
19261 +Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
19262 +---
19263 +--- a/fs/yaffs2/yaffs_vfs.c
19264 ++++ b/fs/yaffs2/yaffs_vfs.c
19265 +@@ -2634,6 +2634,7 @@ static const struct super_operations yaf
19267 + struct yaffs_options {
19268 + int inband_tags;
19269 ++ int tags_9bytes;
19270 + int skip_checkpoint_read;
19271 + int skip_checkpoint_write;
19272 + int no_cache;
19273 +@@ -2673,6 +2674,8 @@ static int yaffs_parse_options(struct ya
19275 + if (!strcmp(cur_opt, "inband-tags")) {
19276 + options->inband_tags = 1;
19277 ++ } else if (!strcmp(cur_opt, "tags-9bytes")) {
19278 ++ options->tags_9bytes = 1;
19279 + } else if (!strcmp(cur_opt, "tags-ecc-off")) {
19280 + options->tags_ecc_on = 0;
19281 + options->tags_ecc_overridden = 1;
19282 +@@ -2746,7 +2749,6 @@ static struct super_block *yaffs_interna
19283 + struct yaffs_param *param;
19285 + int read_only = 0;
19286 +- int inband_tags = 0;
19288 + struct yaffs_options options;
19290 +@@ -2786,6 +2788,9 @@ static struct super_block *yaffs_interna
19292 + memset(&options, 0, sizeof(options));
19294 ++ if (IS_ENABLED(CONFIG_YAFFS_9BYTE_TAGS))
19295 ++ options.tags_9bytes = 1;
19297 + if (yaffs_parse_options(&options, data_str)) {
19298 + /* Option parsing failed */
19299 + return NULL;
19300 +@@ -2819,17 +2824,22 @@ static struct super_block *yaffs_interna
19303 + /* Added NCB 26/5/2006 for completeness */
19304 +- if (yaffs_version == 2 && !options.inband_tags
19305 +- && WRITE_SIZE(mtd) == 512) {
19306 ++ if (yaffs_version == 2 &&
19307 ++ (!options.inband_tags || options.tags_9bytes) &&
19308 ++ WRITE_SIZE(mtd) == 512) {
19309 + yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting yaffs1");
19310 + yaffs_version = 1;
19313 +- if (mtd->oobavail < sizeof(struct yaffs_packed_tags2) ||
19314 +- options.inband_tags)
19315 +- inband_tags = 1;
19316 ++ if (yaffs_version == 2 &&
19317 ++ mtd->oobavail < sizeof(struct yaffs_packed_tags2)) {
19318 ++ yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting inband tags");
19319 ++ options.inband_tags = 1;
19320 ++ }
19322 +- if(yaffs_verify_mtd(mtd, yaffs_version, inband_tags) < 0)
19323 ++ err = yaffs_verify_mtd(mtd, yaffs_version, options.inband_tags,
19324 ++ options.tags_9bytes);
19325 ++ if (err < 0)
19326 + return NULL;
19328 + /* OK, so if we got here, we have an MTD that's NAND and looks
19329 +@@ -2890,7 +2900,8 @@ static struct super_block *yaffs_interna
19331 + param->n_reserved_blocks = 5;
19332 + param->n_caches = (options.no_cache) ? 0 : 10;
19333 +- param->inband_tags = inband_tags;
19334 ++ param->inband_tags = options.inband_tags;
19335 ++ param->tags_9bytes = options.tags_9bytes;
19337 + param->enable_xattr = 1;
19338 + if (options.lazy_loading_overridden)
19339 +--- a/fs/yaffs2/yaffs_mtdif.c
19340 ++++ b/fs/yaffs2/yaffs_mtdif.c
19341 +@@ -276,7 +276,8 @@ struct mtd_info * yaffs_get_mtd_device(d
19342 + return mtd;
19345 +-int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags)
19346 ++int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
19347 ++ int tags_9bytes)
19349 + if (yaffs_version == 2) {
19350 + if ((WRITE_SIZE(mtd) < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
19351 +@@ -295,6 +296,12 @@ int yaffs_verify_mtd(struct mtd_info *mt
19352 + );
19353 + return -1;
19356 ++ if (tags_9bytes && mtd->oobavail < 9) {
19357 ++ yaffs_trace(YAFFS_TRACE_ALWAYS,
19358 ++ "MTD device does not support 9-byte tags");
19359 ++ return -1;
19360 ++ }
19363 + return 0;
19364 +--- a/fs/yaffs2/yaffs_mtdif.h
19365 ++++ b/fs/yaffs2/yaffs_mtdif.h
19366 +@@ -21,5 +21,6 @@
19367 + void yaffs_mtd_drv_install(struct yaffs_dev *dev);
19368 + struct mtd_info * yaffs_get_mtd_device(dev_t sdev);
19369 + void yaffs_put_mtd_device(struct mtd_info *mtd);
19370 +-int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags);
19371 ++int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
19372 ++ int tags_9bytes);
19373 + #endif
19374 diff --git a/target/linux/generic/patches-3.16/504-yaffs-fix-compat-tags-handling.patch b/target/linux/generic/patches-3.16/504-yaffs-fix-compat-tags-handling.patch
19375 new file mode 100644
19376 index 000000000000..a18cf6fd7bbb
19377 --- /dev/null
19378 +++ b/target/linux/generic/patches-3.16/504-yaffs-fix-compat-tags-handling.patch
19379 @@ -0,0 +1,239 @@
19380 +Subject: yaffs: fix compat tags handling
19382 +Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
19383 +---
19384 +--- a/fs/yaffs2/yaffs_tagscompat.c
19385 ++++ b/fs/yaffs2/yaffs_tagscompat.c
19386 +@@ -17,7 +17,9 @@
19387 + #include "yaffs_getblockinfo.h"
19388 + #include "yaffs_trace.h"
19390 ++#if 0
19391 + static void yaffs_handle_rd_data_error(struct yaffs_dev *dev, int nand_chunk);
19392 ++#endif
19395 + /********** Tags ECC calculations *********/
19396 +@@ -71,6 +73,7 @@ int yaffs_check_tags_ecc(struct yaffs_ta
19397 + return 0;
19400 ++#if 0
19401 + /********** Tags **********/
19403 + static void yaffs_load_tags_to_spare(struct yaffs_spare *spare_ptr,
19404 +@@ -379,3 +382,214 @@ void yaffs_tags_compat_install(struct ya
19405 + if(!dev->tagger.mark_bad_fn)
19406 + dev->tagger.mark_bad_fn = yaffs_tags_compat_mark_bad;
19408 ++#else
19410 ++#include "yaffs_packedtags1.h"
19412 ++static int yaffs_tags_compat_write(struct yaffs_dev *dev,
19413 ++ int nand_chunk,
19414 ++ const u8 *data,
19415 ++ const struct yaffs_ext_tags *tags)
19417 ++ struct yaffs_packed_tags1 pt1;
19418 ++ u8 tag_buf[9];
19419 ++ int retval;
19421 ++ /* we assume that yaffs_packed_tags1 and yaffs_tags are compatible */
19422 ++ compile_time_assertion(sizeof(struct yaffs_packed_tags1) == 12);
19423 ++ compile_time_assertion(sizeof(struct yaffs_tags) == 8);
19425 ++ yaffs_pack_tags1(&pt1, tags);
19426 ++ yaffs_calc_tags_ecc((struct yaffs_tags *)&pt1);
19428 ++ /* When deleting a chunk, the upper layer provides only skeletal
19429 ++ * tags, one with is_deleted set. However, we need to update the
19430 ++ * tags, not erase them completely. So we use the NAND write property
19431 ++ * that only zeroed-bits stick and set tag bytes to all-ones and
19432 ++ * zero just the (not) deleted bit.
19433 ++ */
19434 ++ if (!dev->param.tags_9bytes) {
19435 ++ if (tags->is_deleted) {
19436 ++ memset(&pt1, 0xff, 8);
19437 ++ /* clear delete status bit to indicate deleted */
19438 ++ pt1.deleted = 0;
19439 ++ }
19440 ++ memcpy(tag_buf, &pt1, 8);
19441 ++ } else {
19442 ++ if (tags->is_deleted) {
19443 ++ memset(tag_buf, 0xff, 8);
19444 ++ tag_buf[8] = 0;
19445 ++ } else {
19446 ++ memcpy(tag_buf, &pt1, 8);
19447 ++ tag_buf[8] = 0xff;
19448 ++ }
19449 ++ }
19451 ++ retval = dev->drv.drv_write_chunk_fn(dev, nand_chunk,
19452 ++ data,
19453 ++ (data) ? dev->data_bytes_per_chunk : 0,
19454 ++ tag_buf,
19455 ++ (dev->param.tags_9bytes) ? 9 : 8);
19457 ++ return retval;
19460 ++/* Return with empty extended tags but add ecc_result.
19461 ++ */
19462 ++static int return_empty_tags(struct yaffs_ext_tags *tags,
19463 ++ enum yaffs_ecc_result ecc_result,
19464 ++ int retval)
19466 ++ if (tags) {
19467 ++ memset(tags, 0, sizeof(*tags));
19468 ++ tags->ecc_result = ecc_result;
19469 ++ }
19471 ++ return retval;
19474 ++static int yaffs_tags_compat_read(struct yaffs_dev *dev,
19475 ++ int nand_chunk,
19476 ++ u8 *data,
19477 ++ struct yaffs_ext_tags *tags)
19479 ++ struct yaffs_packed_tags1 pt1;
19480 ++ enum yaffs_ecc_result ecc_result;
19481 ++ int retval;
19482 ++ int deleted;
19483 ++ u8 tag_buf[9];
19485 ++ retval = dev->drv.drv_read_chunk_fn(dev, nand_chunk,
19486 ++ data, dev->param.total_bytes_per_chunk,
19487 ++ tag_buf,
19488 ++ (dev->param.tags_9bytes) ? 9 : 8,
19489 ++ &ecc_result);
19491 ++ switch (ecc_result) {
19492 ++ case YAFFS_ECC_RESULT_NO_ERROR:
19493 ++ case YAFFS_ECC_RESULT_FIXED:
19494 ++ break;
19496 ++ case YAFFS_ECC_RESULT_UNFIXED:
19497 ++ default:
19498 ++ return_empty_tags(tags, YAFFS_ECC_RESULT_UNFIXED, 0);
19499 ++ tags->block_bad = dev->drv.drv_check_bad_fn(dev, nand_chunk);
19500 ++ return YAFFS_FAIL;
19501 ++ }
19503 ++ /* Check for a blank/erased chunk. */
19504 ++ if (yaffs_check_ff(tag_buf, 8)) {
19505 ++ /* when blank, upper layers want ecc_result to be <= NO_ERROR */
19506 ++ return return_empty_tags(tags, YAFFS_ECC_RESULT_NO_ERROR,
19507 ++ YAFFS_OK);
19508 ++ }
19510 ++ memcpy(&pt1, tag_buf, 8);
19512 ++ if (!dev->param.tags_9bytes) {
19513 ++ /* Read deleted status (bit) then return it to it's non-deleted
19514 ++ * state before performing tags mini-ECC check. pt1.deleted is
19515 ++ * inverted.
19516 ++ */
19517 ++ deleted = !pt1.deleted;
19518 ++ pt1.deleted = 1;
19519 ++ } else {
19520 ++ deleted = (hweight8(tag_buf[8]) < 7) ? 1 : 0;
19521 ++ }
19523 ++ /* Check the packed tags mini-ECC and correct if necessary/possible. */
19524 ++ retval = yaffs_check_tags_ecc((struct yaffs_tags *)&pt1);
19525 ++ switch (retval) {
19526 ++ case 0:
19527 ++ /* no tags error, use MTD result */
19528 ++ break;
19529 ++ case 1:
19530 ++ /* recovered tags-ECC error */
19531 ++ dev->n_tags_ecc_fixed++;
19532 ++ if (ecc_result == YAFFS_ECC_RESULT_NO_ERROR)
19533 ++ ecc_result = YAFFS_ECC_RESULT_FIXED;
19534 ++ break;
19535 ++ default:
19536 ++ /* unrecovered tags-ECC error */
19537 ++ dev->n_tags_ecc_unfixed++;
19538 ++ return return_empty_tags(tags, YAFFS_ECC_RESULT_UNFIXED,
19539 ++ YAFFS_FAIL);
19540 ++ }
19542 ++ /* Unpack the tags to extended form and set ECC result.
19543 ++ * [set should_be_ff just to keep yaffs_unpack_tags1 happy]
19544 ++ */
19545 ++ pt1.should_be_ff = 0xffffffff;
19546 ++ yaffs_unpack_tags1(tags, &pt1);
19547 ++ tags->ecc_result = ecc_result;
19549 ++ /* Set deleted state */
19550 ++ tags->is_deleted = deleted;
19551 ++ return YAFFS_OK;
19554 ++static int yaffs_tags_compat_mark_bad(struct yaffs_dev *dev, int block_no)
19556 ++ return dev->drv.drv_mark_bad_fn(dev, block_no);
19559 ++static int yaffs_tags_compat_query_block(struct yaffs_dev *dev,
19560 ++ int block_no,
19561 ++ enum yaffs_block_state *state,
19562 ++ u32 *seq_number)
19564 ++ struct yaffs_ext_tags tags;
19565 ++ int retval;
19567 ++ yaffs_trace(YAFFS_TRACE_MTD, "%s %d", __func__, block_no);
19569 ++ *seq_number = 0;
19571 ++ retval = dev->drv.drv_check_bad_fn(dev, block_no);
19572 ++ if (retval == YAFFS_FAIL) {
19573 ++ *state = YAFFS_BLOCK_STATE_DEAD;
19574 ++ goto out;
19575 ++ }
19577 ++ yaffs_tags_compat_read(dev, block_no * dev->param.chunks_per_block,
19578 ++ NULL, &tags);
19580 ++ if (tags.ecc_result != YAFFS_ECC_RESULT_NO_ERROR) {
19581 ++ yaffs_trace(YAFFS_TRACE_MTD, "block %d is marked bad",
19582 ++ block_no);
19583 ++ *state = YAFFS_BLOCK_STATE_NEEDS_SCAN;
19584 ++ } else if (tags.chunk_used) {
19585 ++ *seq_number = tags.seq_number;
19586 ++ *state = YAFFS_BLOCK_STATE_NEEDS_SCAN;
19587 ++ } else {
19588 ++ *state = YAFFS_BLOCK_STATE_EMPTY;
19589 ++ }
19591 ++ retval = YAFFS_OK;
19593 ++out:
19594 ++ yaffs_trace(YAFFS_TRACE_MTD,
19595 ++ "block query returns seq %u state %d",
19596 ++ *seq_number, *state);
19598 ++ return retval;
19601 ++void yaffs_tags_compat_install(struct yaffs_dev *dev)
19603 ++ if (dev->param.is_yaffs2)
19604 ++ return;
19606 ++ if (!dev->tagger.write_chunk_tags_fn)
19607 ++ dev->tagger.write_chunk_tags_fn = yaffs_tags_compat_write;
19609 ++ if (!dev->tagger.read_chunk_tags_fn)
19610 ++ dev->tagger.read_chunk_tags_fn = yaffs_tags_compat_read;
19612 ++ if (!dev->tagger.query_block_fn)
19613 ++ dev->tagger.query_block_fn = yaffs_tags_compat_query_block;
19615 ++ if (!dev->tagger.mark_bad_fn)
19616 ++ dev->tagger.mark_bad_fn = yaffs_tags_compat_mark_bad;
19618 ++#endif
19619 diff --git a/target/linux/generic/patches-3.16/520-squashfs_update_xz_comp_opts.patch b/target/linux/generic/patches-3.16/520-squashfs_update_xz_comp_opts.patch
19620 new file mode 100644
19621 index 000000000000..ad11b30281ce
19622 --- /dev/null
19623 +++ b/target/linux/generic/patches-3.16/520-squashfs_update_xz_comp_opts.patch
19624 @@ -0,0 +1,25 @@
19625 +From f31b7c0efa255dd17a5f584022a319387f09b0d8 Mon Sep 17 00:00:00 2001
19626 +From: Jonas Gorski <jonas.gorski@gmail.com>
19627 +Date: Tue, 12 Apr 2011 19:55:41 +0200
19628 +Subject: [PATCH] squashfs: update xz compressor options struct.
19630 +Update the xz compressor options struct to match the squashfs userspace
19631 +one.
19632 +---
19633 + fs/squashfs/xz_wrapper.c | 4 +++-
19634 + 1 files changed, 3 insertions(+), 1 deletions(-)
19636 +--- a/fs/squashfs/xz_wrapper.c
19637 ++++ b/fs/squashfs/xz_wrapper.c
19638 +@@ -40,8 +40,10 @@ struct squashfs_xz {
19639 + };
19641 + struct disk_comp_opts {
19642 +- __le32 dictionary_size;
19643 + __le32 flags;
19644 ++ __le16 bit_opts;
19645 ++ __le16 fb;
19646 ++ __le32 dictionary_size;
19647 + };
19649 + struct comp_opts {
19650 diff --git a/target/linux/generic/patches-3.16/530-jffs2_make_lzma_available.patch b/target/linux/generic/patches-3.16/530-jffs2_make_lzma_available.patch
19651 new file mode 100644
19652 index 000000000000..e3e99ec4a0b3
19653 --- /dev/null
19654 +++ b/target/linux/generic/patches-3.16/530-jffs2_make_lzma_available.patch
19655 @@ -0,0 +1,5142 @@
19656 +--- a/fs/jffs2/Kconfig
19657 ++++ b/fs/jffs2/Kconfig
19658 +@@ -139,6 +139,15 @@ config JFFS2_LZO
19659 + This feature was added in July, 2007. Say 'N' if you need
19660 + compatibility with older bootloaders or kernels.
19662 ++config JFFS2_LZMA
19663 ++ bool "JFFS2 LZMA compression support" if JFFS2_COMPRESSION_OPTIONS
19664 ++ select LZMA_COMPRESS
19665 ++ select LZMA_DECOMPRESS
19666 ++ depends on JFFS2_FS
19667 ++ default n
19668 ++ help
19669 ++ JFFS2 wrapper to the LZMA C SDK
19671 + config JFFS2_RTIME
19672 + bool "JFFS2 RTIME compression support" if JFFS2_COMPRESSION_OPTIONS
19673 + depends on JFFS2_FS
19674 +--- a/fs/jffs2/Makefile
19675 ++++ b/fs/jffs2/Makefile
19676 +@@ -18,4 +18,7 @@ jffs2-$(CONFIG_JFFS2_RUBIN) += compr_rub
19677 + jffs2-$(CONFIG_JFFS2_RTIME) += compr_rtime.o
19678 + jffs2-$(CONFIG_JFFS2_ZLIB) += compr_zlib.o
19679 + jffs2-$(CONFIG_JFFS2_LZO) += compr_lzo.o
19680 ++jffs2-$(CONFIG_JFFS2_LZMA) += compr_lzma.o
19681 + jffs2-$(CONFIG_JFFS2_SUMMARY) += summary.o
19683 ++CFLAGS_compr_lzma.o += -Iinclude/linux -Ilib/lzma
19684 +--- a/fs/jffs2/compr.c
19685 ++++ b/fs/jffs2/compr.c
19686 +@@ -378,6 +378,9 @@ int __init jffs2_compressors_init(void)
19687 + #ifdef CONFIG_JFFS2_LZO
19688 + jffs2_lzo_init();
19689 + #endif
19690 ++#ifdef CONFIG_JFFS2_LZMA
19691 ++ jffs2_lzma_init();
19692 ++#endif
19693 + /* Setting default compression mode */
19694 + #ifdef CONFIG_JFFS2_CMODE_NONE
19695 + jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;
19696 +@@ -401,6 +404,9 @@ int __init jffs2_compressors_init(void)
19697 + int jffs2_compressors_exit(void)
19699 + /* Unregistering compressors */
19700 ++#ifdef CONFIG_JFFS2_LZMA
19701 ++ jffs2_lzma_exit();
19702 ++#endif
19703 + #ifdef CONFIG_JFFS2_LZO
19704 + jffs2_lzo_exit();
19705 + #endif
19706 +--- a/fs/jffs2/compr.h
19707 ++++ b/fs/jffs2/compr.h
19708 +@@ -29,9 +29,9 @@
19709 + #define JFFS2_DYNRUBIN_PRIORITY 20
19710 + #define JFFS2_LZARI_PRIORITY 30
19711 + #define JFFS2_RTIME_PRIORITY 50
19712 +-#define JFFS2_ZLIB_PRIORITY 60
19713 +-#define JFFS2_LZO_PRIORITY 80
19715 ++#define JFFS2_LZMA_PRIORITY 70
19716 ++#define JFFS2_ZLIB_PRIORITY 80
19717 ++#define JFFS2_LZO_PRIORITY 90
19719 + #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */
19720 + #define JFFS2_DYNRUBIN_DISABLED /* for decompression */
19721 +@@ -101,5 +101,9 @@ void jffs2_zlib_exit(void);
19722 + int jffs2_lzo_init(void);
19723 + void jffs2_lzo_exit(void);
19724 + #endif
19725 ++#ifdef CONFIG_JFFS2_LZMA
19726 ++int jffs2_lzma_init(void);
19727 ++void jffs2_lzma_exit(void);
19728 ++#endif
19730 + #endif /* __JFFS2_COMPR_H__ */
19731 +--- /dev/null
19732 ++++ b/fs/jffs2/compr_lzma.c
19733 +@@ -0,0 +1,128 @@
19734 ++/*
19735 ++ * JFFS2 -- Journalling Flash File System, Version 2.
19736 ++ *
19737 ++ * For licensing information, see the file 'LICENCE' in this directory.
19738 ++ *
19739 ++ * JFFS2 wrapper to the LZMA C SDK
19740 ++ *
19741 ++ */
19743 ++#include <linux/lzma.h>
19744 ++#include "compr.h"
19746 ++#ifdef __KERNEL__
19747 ++ static DEFINE_MUTEX(deflate_mutex);
19748 ++#endif
19750 ++CLzmaEncHandle *p;
19751 ++Byte propsEncoded[LZMA_PROPS_SIZE];
19752 ++SizeT propsSize = sizeof(propsEncoded);
19754 ++STATIC void lzma_free_workspace(void)
19756 ++ LzmaEnc_Destroy(p, &lzma_alloc, &lzma_alloc);
19759 ++STATIC int INIT lzma_alloc_workspace(CLzmaEncProps *props)
19761 ++ if ((p = (CLzmaEncHandle *)LzmaEnc_Create(&lzma_alloc)) == NULL)
19762 ++ {
19763 ++ PRINT_ERROR("Failed to allocate lzma deflate workspace\n");
19764 ++ return -ENOMEM;
19765 ++ }
19767 ++ if (LzmaEnc_SetProps(p, props) != SZ_OK)
19768 ++ {
19769 ++ lzma_free_workspace();
19770 ++ return -1;
19771 ++ }
19773 ++ if (LzmaEnc_WriteProperties(p, propsEncoded, &propsSize) != SZ_OK)
19774 ++ {
19775 ++ lzma_free_workspace();
19776 ++ return -1;
19777 ++ }
19779 ++ return 0;
19782 ++STATIC int jffs2_lzma_compress(unsigned char *data_in, unsigned char *cpage_out,
19783 ++ uint32_t *sourcelen, uint32_t *dstlen)
19785 ++ SizeT compress_size = (SizeT)(*dstlen);
19786 ++ int ret;
19788 ++ #ifdef __KERNEL__
19789 ++ mutex_lock(&deflate_mutex);
19790 ++ #endif
19792 ++ ret = LzmaEnc_MemEncode(p, cpage_out, &compress_size, data_in, *sourcelen,
19793 ++ 0, NULL, &lzma_alloc, &lzma_alloc);
19795 ++ #ifdef __KERNEL__
19796 ++ mutex_unlock(&deflate_mutex);
19797 ++ #endif
19799 ++ if (ret != SZ_OK)
19800 ++ return -1;
19802 ++ *dstlen = (uint32_t)compress_size;
19804 ++ return 0;
19807 ++STATIC int jffs2_lzma_decompress(unsigned char *data_in, unsigned char *cpage_out,
19808 ++ uint32_t srclen, uint32_t destlen)
19810 ++ int ret;
19811 ++ SizeT dl = (SizeT)destlen;
19812 ++ SizeT sl = (SizeT)srclen;
19813 ++ ELzmaStatus status;
19815 ++ ret = LzmaDecode(cpage_out, &dl, data_in, &sl, propsEncoded,
19816 ++ propsSize, LZMA_FINISH_ANY, &status, &lzma_alloc);
19818 ++ if (ret != SZ_OK || status == LZMA_STATUS_NOT_FINISHED || dl != (SizeT)destlen)
19819 ++ return -1;
19821 ++ return 0;
19824 ++static struct jffs2_compressor jffs2_lzma_comp = {
19825 ++ .priority = JFFS2_LZMA_PRIORITY,
19826 ++ .name = "lzma",
19827 ++ .compr = JFFS2_COMPR_LZMA,
19828 ++ .compress = &jffs2_lzma_compress,
19829 ++ .decompress = &jffs2_lzma_decompress,
19830 ++ .disabled = 0,
19831 ++};
19833 ++int INIT jffs2_lzma_init(void)
19835 ++ int ret;
19836 ++ CLzmaEncProps props;
19837 ++ LzmaEncProps_Init(&props);
19839 ++ props.dictSize = LZMA_BEST_DICT(0x2000);
19840 ++ props.level = LZMA_BEST_LEVEL;
19841 ++ props.lc = LZMA_BEST_LC;
19842 ++ props.lp = LZMA_BEST_LP;
19843 ++ props.pb = LZMA_BEST_PB;
19844 ++ props.fb = LZMA_BEST_FB;
19846 ++ ret = lzma_alloc_workspace(&props);
19847 ++ if (ret < 0)
19848 ++ return ret;
19850 ++ ret = jffs2_register_compressor(&jffs2_lzma_comp);
19851 ++ if (ret)
19852 ++ lzma_free_workspace();
19854 ++ return ret;
19857 ++void jffs2_lzma_exit(void)
19859 ++ jffs2_unregister_compressor(&jffs2_lzma_comp);
19860 ++ lzma_free_workspace();
19862 +--- a/fs/jffs2/super.c
19863 ++++ b/fs/jffs2/super.c
19864 +@@ -374,14 +374,41 @@ static int __init init_jffs2_fs(void)
19865 + BUILD_BUG_ON(sizeof(struct jffs2_raw_inode) != 68);
19866 + BUILD_BUG_ON(sizeof(struct jffs2_raw_summary) != 32);
19868 +- pr_info("version 2.2."
19869 ++ pr_info("version 2.2"
19870 + #ifdef CONFIG_JFFS2_FS_WRITEBUFFER
19871 + " (NAND)"
19872 + #endif
19873 + #ifdef CONFIG_JFFS2_SUMMARY
19874 +- " (SUMMARY) "
19875 ++ " (SUMMARY)"
19876 + #endif
19877 +- " © 2001-2006 Red Hat, Inc.\n");
19878 ++#ifdef CONFIG_JFFS2_ZLIB
19879 ++ " (ZLIB)"
19880 ++#endif
19881 ++#ifdef CONFIG_JFFS2_LZO
19882 ++ " (LZO)"
19883 ++#endif
19884 ++#ifdef CONFIG_JFFS2_LZMA
19885 ++ " (LZMA)"
19886 ++#endif
19887 ++#ifdef CONFIG_JFFS2_RTIME
19888 ++ " (RTIME)"
19889 ++#endif
19890 ++#ifdef CONFIG_JFFS2_RUBIN
19891 ++ " (RUBIN)"
19892 ++#endif
19893 ++#ifdef CONFIG_JFFS2_CMODE_NONE
19894 ++ " (CMODE_NONE)"
19895 ++#endif
19896 ++#ifdef CONFIG_JFFS2_CMODE_PRIORITY
19897 ++ " (CMODE_PRIORITY)"
19898 ++#endif
19899 ++#ifdef CONFIG_JFFS2_CMODE_SIZE
19900 ++ " (CMODE_SIZE)"
19901 ++#endif
19902 ++#ifdef CONFIG_JFFS2_CMODE_FAVOURLZO
19903 ++ " (CMODE_FAVOURLZO)"
19904 ++#endif
19905 ++ " (c) 2001-2006 Red Hat, Inc.\n");
19907 + jffs2_inode_cachep = kmem_cache_create("jffs2_i",
19908 + sizeof(struct jffs2_inode_info),
19909 +--- a/include/uapi/linux/jffs2.h
19910 ++++ b/include/uapi/linux/jffs2.h
19911 +@@ -46,6 +46,7 @@
19912 + #define JFFS2_COMPR_DYNRUBIN 0x05
19913 + #define JFFS2_COMPR_ZLIB 0x06
19914 + #define JFFS2_COMPR_LZO 0x07
19915 ++#define JFFS2_COMPR_LZMA 0x08
19916 + /* Compatibility flags. */
19917 + #define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
19918 + #define JFFS2_NODE_ACCURATE 0x2000
19919 +--- /dev/null
19920 ++++ b/include/linux/lzma.h
19921 +@@ -0,0 +1,62 @@
19922 ++#ifndef __LZMA_H__
19923 ++#define __LZMA_H__
19925 ++#ifdef __KERNEL__
19926 ++ #include <linux/kernel.h>
19927 ++ #include <linux/sched.h>
19928 ++ #include <linux/slab.h>
19929 ++ #include <linux/vmalloc.h>
19930 ++ #include <linux/init.h>
19931 ++ #define LZMA_MALLOC vmalloc
19932 ++ #define LZMA_FREE vfree
19933 ++ #define PRINT_ERROR(msg) printk(KERN_WARNING #msg)
19934 ++ #define INIT __init
19935 ++ #define STATIC static
19936 ++#else
19937 ++ #include <stdint.h>
19938 ++ #include <stdlib.h>
19939 ++ #include <stdio.h>
19940 ++ #include <unistd.h>
19941 ++ #include <string.h>
19942 ++ #include <asm/types.h>
19943 ++ #include <errno.h>
19944 ++ #include <linux/jffs2.h>
19945 ++ #ifndef PAGE_SIZE
19946 ++ extern int page_size;
19947 ++ #define PAGE_SIZE page_size
19948 ++ #endif
19949 ++ #define LZMA_MALLOC malloc
19950 ++ #define LZMA_FREE free
19951 ++ #define PRINT_ERROR(msg) fprintf(stderr, msg)
19952 ++ #define INIT
19953 ++ #define STATIC
19954 ++#endif
19956 ++#include "lzma/LzmaDec.h"
19957 ++#include "lzma/LzmaEnc.h"
19959 ++#define LZMA_BEST_LEVEL (9)
19960 ++#define LZMA_BEST_LC (0)
19961 ++#define LZMA_BEST_LP (0)
19962 ++#define LZMA_BEST_PB (0)
19963 ++#define LZMA_BEST_FB (273)
19965 ++#define LZMA_BEST_DICT(n) (((int)((n) / 2)) * 2)
19967 ++static void *p_lzma_malloc(void *p, size_t size)
19969 ++ if (size == 0)
19970 ++ return NULL;
19972 ++ return LZMA_MALLOC(size);
19975 ++static void p_lzma_free(void *p, void *address)
19977 ++ if (address != NULL)
19978 ++ LZMA_FREE(address);
19981 ++static ISzAlloc lzma_alloc = {p_lzma_malloc, p_lzma_free};
19983 ++#endif
19984 +--- /dev/null
19985 ++++ b/include/linux/lzma/LzFind.h
19986 +@@ -0,0 +1,115 @@
19987 ++/* LzFind.h -- Match finder for LZ algorithms
19988 ++2009-04-22 : Igor Pavlov : Public domain */
19990 ++#ifndef __LZ_FIND_H
19991 ++#define __LZ_FIND_H
19993 ++#include "Types.h"
19995 ++#ifdef __cplusplus
19996 ++extern "C" {
19997 ++#endif
19999 ++typedef UInt32 CLzRef;
20001 ++typedef struct _CMatchFinder
20003 ++ Byte *buffer;
20004 ++ UInt32 pos;
20005 ++ UInt32 posLimit;
20006 ++ UInt32 streamPos;
20007 ++ UInt32 lenLimit;
20009 ++ UInt32 cyclicBufferPos;
20010 ++ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
20012 ++ UInt32 matchMaxLen;
20013 ++ CLzRef *hash;
20014 ++ CLzRef *son;
20015 ++ UInt32 hashMask;
20016 ++ UInt32 cutValue;
20018 ++ Byte *bufferBase;
20019 ++ ISeqInStream *stream;
20020 ++ int streamEndWasReached;
20022 ++ UInt32 blockSize;
20023 ++ UInt32 keepSizeBefore;
20024 ++ UInt32 keepSizeAfter;
20026 ++ UInt32 numHashBytes;
20027 ++ int directInput;
20028 ++ size_t directInputRem;
20029 ++ int btMode;
20030 ++ int bigHash;
20031 ++ UInt32 historySize;
20032 ++ UInt32 fixedHashSize;
20033 ++ UInt32 hashSizeSum;
20034 ++ UInt32 numSons;
20035 ++ SRes result;
20036 ++ UInt32 crc[256];
20037 ++} CMatchFinder;
20039 ++#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
20040 ++#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
20042 ++#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
20044 ++int MatchFinder_NeedMove(CMatchFinder *p);
20045 ++Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
20046 ++void MatchFinder_MoveBlock(CMatchFinder *p);
20047 ++void MatchFinder_ReadIfRequired(CMatchFinder *p);
20049 ++void MatchFinder_Construct(CMatchFinder *p);
20051 ++/* Conditions:
20052 ++ historySize <= 3 GB
20053 ++ keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
20054 ++*/
20055 ++int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
20056 ++ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
20057 ++ ISzAlloc *alloc);
20058 ++void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
20059 ++void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
20060 ++void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
20062 ++UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
20063 ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
20064 ++ UInt32 *distances, UInt32 maxLen);
20066 ++/*
20067 ++Conditions:
20068 ++ Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
20069 ++ Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
20070 ++*/
20072 ++typedef void (*Mf_Init_Func)(void *object);
20073 ++typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
20074 ++typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
20075 ++typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
20076 ++typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
20077 ++typedef void (*Mf_Skip_Func)(void *object, UInt32);
20079 ++typedef struct _IMatchFinder
20081 ++ Mf_Init_Func Init;
20082 ++ Mf_GetIndexByte_Func GetIndexByte;
20083 ++ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
20084 ++ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
20085 ++ Mf_GetMatches_Func GetMatches;
20086 ++ Mf_Skip_Func Skip;
20087 ++} IMatchFinder;
20089 ++void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
20091 ++void MatchFinder_Init(CMatchFinder *p);
20092 ++UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
20093 ++UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
20094 ++void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
20095 ++void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
20097 ++#ifdef __cplusplus
20099 ++#endif
20101 ++#endif
20102 +--- /dev/null
20103 ++++ b/include/linux/lzma/LzHash.h
20104 +@@ -0,0 +1,54 @@
20105 ++/* LzHash.h -- HASH functions for LZ algorithms
20106 ++2009-02-07 : Igor Pavlov : Public domain */
20108 ++#ifndef __LZ_HASH_H
20109 ++#define __LZ_HASH_H
20111 ++#define kHash2Size (1 << 10)
20112 ++#define kHash3Size (1 << 16)
20113 ++#define kHash4Size (1 << 20)
20115 ++#define kFix3HashSize (kHash2Size)
20116 ++#define kFix4HashSize (kHash2Size + kHash3Size)
20117 ++#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
20119 ++#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
20121 ++#define HASH3_CALC { \
20122 ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
20123 ++ hash2Value = temp & (kHash2Size - 1); \
20124 ++ hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
20126 ++#define HASH4_CALC { \
20127 ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
20128 ++ hash2Value = temp & (kHash2Size - 1); \
20129 ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
20130 ++ hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
20132 ++#define HASH5_CALC { \
20133 ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
20134 ++ hash2Value = temp & (kHash2Size - 1); \
20135 ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
20136 ++ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
20137 ++ hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
20138 ++ hash4Value &= (kHash4Size - 1); }
20140 ++/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
20141 ++#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
20144 ++#define MT_HASH2_CALC \
20145 ++ hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
20147 ++#define MT_HASH3_CALC { \
20148 ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
20149 ++ hash2Value = temp & (kHash2Size - 1); \
20150 ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
20152 ++#define MT_HASH4_CALC { \
20153 ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
20154 ++ hash2Value = temp & (kHash2Size - 1); \
20155 ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
20156 ++ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
20158 ++#endif
20159 +--- /dev/null
20160 ++++ b/include/linux/lzma/LzmaDec.h
20161 +@@ -0,0 +1,231 @@
20162 ++/* LzmaDec.h -- LZMA Decoder
20163 ++2009-02-07 : Igor Pavlov : Public domain */
20165 ++#ifndef __LZMA_DEC_H
20166 ++#define __LZMA_DEC_H
20168 ++#include "Types.h"
20170 ++#ifdef __cplusplus
20171 ++extern "C" {
20172 ++#endif
20174 ++/* #define _LZMA_PROB32 */
20175 ++/* _LZMA_PROB32 can increase the speed on some CPUs,
20176 ++ but memory usage for CLzmaDec::probs will be doubled in that case */
20178 ++#ifdef _LZMA_PROB32
20179 ++#define CLzmaProb UInt32
20180 ++#else
20181 ++#define CLzmaProb UInt16
20182 ++#endif
20185 ++/* ---------- LZMA Properties ---------- */
20187 ++#define LZMA_PROPS_SIZE 5
20189 ++typedef struct _CLzmaProps
20191 ++ unsigned lc, lp, pb;
20192 ++ UInt32 dicSize;
20193 ++} CLzmaProps;
20195 ++/* LzmaProps_Decode - decodes properties
20196 ++Returns:
20197 ++ SZ_OK
20198 ++ SZ_ERROR_UNSUPPORTED - Unsupported properties
20199 ++*/
20201 ++SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
20204 ++/* ---------- LZMA Decoder state ---------- */
20206 ++/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
20207 ++ Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
20209 ++#define LZMA_REQUIRED_INPUT_MAX 20
20211 ++typedef struct
20213 ++ CLzmaProps prop;
20214 ++ CLzmaProb *probs;
20215 ++ Byte *dic;
20216 ++ const Byte *buf;
20217 ++ UInt32 range, code;
20218 ++ SizeT dicPos;
20219 ++ SizeT dicBufSize;
20220 ++ UInt32 processedPos;
20221 ++ UInt32 checkDicSize;
20222 ++ unsigned state;
20223 ++ UInt32 reps[4];
20224 ++ unsigned remainLen;
20225 ++ int needFlush;
20226 ++ int needInitState;
20227 ++ UInt32 numProbs;
20228 ++ unsigned tempBufSize;
20229 ++ Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
20230 ++} CLzmaDec;
20232 ++#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
20234 ++void LzmaDec_Init(CLzmaDec *p);
20236 ++/* There are two types of LZMA streams:
20237 ++ 0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
20238 ++ 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
20240 ++typedef enum
20242 ++ LZMA_FINISH_ANY, /* finish at any point */
20243 ++ LZMA_FINISH_END /* block must be finished at the end */
20244 ++} ELzmaFinishMode;
20246 ++/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
20248 ++ You must use LZMA_FINISH_END, when you know that current output buffer
20249 ++ covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
20251 ++ If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
20252 ++ and output value of destLen will be less than output buffer size limit.
20253 ++ You can check status result also.
20255 ++ You can use multiple checks to test data integrity after full decompression:
20256 ++ 1) Check Result and "status" variable.
20257 ++ 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
20258 ++ 3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
20259 ++ You must use correct finish mode in that case. */
20261 ++typedef enum
20263 ++ LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
20264 ++ LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
20265 ++ LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
20266 ++ LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
20267 ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
20268 ++} ELzmaStatus;
20270 ++/* ELzmaStatus is used only as output value for function call */
20273 ++/* ---------- Interfaces ---------- */
20275 ++/* There are 3 levels of interfaces:
20276 ++ 1) Dictionary Interface
20277 ++ 2) Buffer Interface
20278 ++ 3) One Call Interface
20279 ++ You can select any of these interfaces, but don't mix functions from different
20280 ++ groups for same object. */
20283 ++/* There are two variants to allocate state for Dictionary Interface:
20284 ++ 1) LzmaDec_Allocate / LzmaDec_Free
20285 ++ 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
20286 ++ You can use variant 2, if you set dictionary buffer manually.
20287 ++ For Buffer Interface you must always use variant 1.
20289 ++LzmaDec_Allocate* can return:
20290 ++ SZ_OK
20291 ++ SZ_ERROR_MEM - Memory allocation error
20292 ++ SZ_ERROR_UNSUPPORTED - Unsupported properties
20293 ++*/
20295 ++SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
20296 ++void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
20298 ++SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
20299 ++void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
20301 ++/* ---------- Dictionary Interface ---------- */
20303 ++/* You can use it, if you want to eliminate the overhead for data copying from
20304 ++ dictionary to some other external buffer.
20305 ++ You must work with CLzmaDec variables directly in this interface.
20307 ++ STEPS:
20308 ++ LzmaDec_Constr()
20309 ++ LzmaDec_Allocate()
20310 ++ for (each new stream)
20311 ++ {
20312 ++ LzmaDec_Init()
20313 ++ while (it needs more decompression)
20314 ++ {
20315 ++ LzmaDec_DecodeToDic()
20316 ++ use data from CLzmaDec::dic and update CLzmaDec::dicPos
20317 ++ }
20318 ++ }
20319 ++ LzmaDec_Free()
20320 ++*/
20322 ++/* LzmaDec_DecodeToDic
20324 ++ The decoding to internal dictionary buffer (CLzmaDec::dic).
20325 ++ You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
20327 ++finishMode:
20328 ++ It has meaning only if the decoding reaches output limit (dicLimit).
20329 ++ LZMA_FINISH_ANY - Decode just dicLimit bytes.
20330 ++ LZMA_FINISH_END - Stream must be finished after dicLimit.
20332 ++Returns:
20333 ++ SZ_OK
20334 ++ status:
20335 ++ LZMA_STATUS_FINISHED_WITH_MARK
20336 ++ LZMA_STATUS_NOT_FINISHED
20337 ++ LZMA_STATUS_NEEDS_MORE_INPUT
20338 ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
20339 ++ SZ_ERROR_DATA - Data error
20340 ++*/
20342 ++SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
20343 ++ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
20346 ++/* ---------- Buffer Interface ---------- */
20348 ++/* It's zlib-like interface.
20349 ++ See LzmaDec_DecodeToDic description for information about STEPS and return results,
20350 ++ but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
20351 ++ to work with CLzmaDec variables manually.
20353 ++finishMode:
20354 ++ It has meaning only if the decoding reaches output limit (*destLen).
20355 ++ LZMA_FINISH_ANY - Decode just destLen bytes.
20356 ++ LZMA_FINISH_END - Stream must be finished after (*destLen).
20357 ++*/
20359 ++SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
20360 ++ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
20363 ++/* ---------- One Call Interface ---------- */
20365 ++/* LzmaDecode
20367 ++finishMode:
20368 ++ It has meaning only if the decoding reaches output limit (*destLen).
20369 ++ LZMA_FINISH_ANY - Decode just destLen bytes.
20370 ++ LZMA_FINISH_END - Stream must be finished after (*destLen).
20372 ++Returns:
20373 ++ SZ_OK
20374 ++ status:
20375 ++ LZMA_STATUS_FINISHED_WITH_MARK
20376 ++ LZMA_STATUS_NOT_FINISHED
20377 ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
20378 ++ SZ_ERROR_DATA - Data error
20379 ++ SZ_ERROR_MEM - Memory allocation error
20380 ++ SZ_ERROR_UNSUPPORTED - Unsupported properties
20381 ++ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
20382 ++*/
20384 ++SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
20385 ++ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
20386 ++ ELzmaStatus *status, ISzAlloc *alloc);
20388 ++#ifdef __cplusplus
20390 ++#endif
20392 ++#endif
20393 +--- /dev/null
20394 ++++ b/include/linux/lzma/LzmaEnc.h
20395 +@@ -0,0 +1,80 @@
20396 ++/* LzmaEnc.h -- LZMA Encoder
20397 ++2009-02-07 : Igor Pavlov : Public domain */
20399 ++#ifndef __LZMA_ENC_H
20400 ++#define __LZMA_ENC_H
20402 ++#include "Types.h"
20404 ++#ifdef __cplusplus
20405 ++extern "C" {
20406 ++#endif
20408 ++#define LZMA_PROPS_SIZE 5
20410 ++typedef struct _CLzmaEncProps
20412 ++ int level; /* 0 <= level <= 9 */
20413 ++ UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
20414 ++ (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
20415 ++ default = (1 << 24) */
20416 ++ int lc; /* 0 <= lc <= 8, default = 3 */
20417 ++ int lp; /* 0 <= lp <= 4, default = 0 */
20418 ++ int pb; /* 0 <= pb <= 4, default = 2 */
20419 ++ int algo; /* 0 - fast, 1 - normal, default = 1 */
20420 ++ int fb; /* 5 <= fb <= 273, default = 32 */
20421 ++ int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
20422 ++ int numHashBytes; /* 2, 3 or 4, default = 4 */
20423 ++ UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
20424 ++ unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
20425 ++ int numThreads; /* 1 or 2, default = 2 */
20426 ++} CLzmaEncProps;
20428 ++void LzmaEncProps_Init(CLzmaEncProps *p);
20429 ++void LzmaEncProps_Normalize(CLzmaEncProps *p);
20430 ++UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
20433 ++/* ---------- CLzmaEncHandle Interface ---------- */
20435 ++/* LzmaEnc_* functions can return the following exit codes:
20436 ++Returns:
20437 ++ SZ_OK - OK
20438 ++ SZ_ERROR_MEM - Memory allocation error
20439 ++ SZ_ERROR_PARAM - Incorrect paramater in props
20440 ++ SZ_ERROR_WRITE - Write callback error.
20441 ++ SZ_ERROR_PROGRESS - some break from progress callback
20442 ++ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
20443 ++*/
20445 ++typedef void * CLzmaEncHandle;
20447 ++CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
20448 ++void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
20449 ++SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
20450 ++SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
20451 ++SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
20452 ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
20453 ++SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
20454 ++ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
20456 ++/* ---------- One Call Interface ---------- */
20458 ++/* LzmaEncode
20459 ++Return code:
20460 ++ SZ_OK - OK
20461 ++ SZ_ERROR_MEM - Memory allocation error
20462 ++ SZ_ERROR_PARAM - Incorrect paramater
20463 ++ SZ_ERROR_OUTPUT_EOF - output buffer overflow
20464 ++ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
20465 ++*/
20467 ++SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
20468 ++ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
20469 ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
20471 ++#ifdef __cplusplus
20473 ++#endif
20475 ++#endif
20476 +--- /dev/null
20477 ++++ b/include/linux/lzma/Types.h
20478 +@@ -0,0 +1,226 @@
20479 ++/* Types.h -- Basic types
20480 ++2009-11-23 : Igor Pavlov : Public domain */
20482 ++#ifndef __7Z_TYPES_H
20483 ++#define __7Z_TYPES_H
20485 ++#include <stddef.h>
20487 ++#ifdef _WIN32
20488 ++#include <windows.h>
20489 ++#endif
20491 ++#ifndef EXTERN_C_BEGIN
20492 ++#ifdef __cplusplus
20493 ++#define EXTERN_C_BEGIN extern "C" {
20494 ++#define EXTERN_C_END }
20495 ++#else
20496 ++#define EXTERN_C_BEGIN
20497 ++#define EXTERN_C_END
20498 ++#endif
20499 ++#endif
20501 ++EXTERN_C_BEGIN
20503 ++#define SZ_OK 0
20505 ++#define SZ_ERROR_DATA 1
20506 ++#define SZ_ERROR_MEM 2
20507 ++#define SZ_ERROR_CRC 3
20508 ++#define SZ_ERROR_UNSUPPORTED 4
20509 ++#define SZ_ERROR_PARAM 5
20510 ++#define SZ_ERROR_INPUT_EOF 6
20511 ++#define SZ_ERROR_OUTPUT_EOF 7
20512 ++#define SZ_ERROR_READ 8
20513 ++#define SZ_ERROR_WRITE 9
20514 ++#define SZ_ERROR_PROGRESS 10
20515 ++#define SZ_ERROR_FAIL 11
20516 ++#define SZ_ERROR_THREAD 12
20518 ++#define SZ_ERROR_ARCHIVE 16
20519 ++#define SZ_ERROR_NO_ARCHIVE 17
20521 ++typedef int SRes;
20523 ++#ifdef _WIN32
20524 ++typedef DWORD WRes;
20525 ++#else
20526 ++typedef int WRes;
20527 ++#endif
20529 ++#ifndef RINOK
20530 ++#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
20531 ++#endif
20533 ++typedef unsigned char Byte;
20534 ++typedef short Int16;
20535 ++typedef unsigned short UInt16;
20537 ++#ifdef _LZMA_UINT32_IS_ULONG
20538 ++typedef long Int32;
20539 ++typedef unsigned long UInt32;
20540 ++#else
20541 ++typedef int Int32;
20542 ++typedef unsigned int UInt32;
20543 ++#endif
20545 ++#ifdef _SZ_NO_INT_64
20547 ++/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
20548 ++ NOTES: Some code will work incorrectly in that case! */
20550 ++typedef long Int64;
20551 ++typedef unsigned long UInt64;
20553 ++#else
20555 ++#if defined(_MSC_VER) || defined(__BORLANDC__)
20556 ++typedef __int64 Int64;
20557 ++typedef unsigned __int64 UInt64;
20558 ++#else
20559 ++typedef long long int Int64;
20560 ++typedef unsigned long long int UInt64;
20561 ++#endif
20563 ++#endif
20565 ++#ifdef _LZMA_NO_SYSTEM_SIZE_T
20566 ++typedef UInt32 SizeT;
20567 ++#else
20568 ++typedef size_t SizeT;
20569 ++#endif
20571 ++typedef int Bool;
20572 ++#define True 1
20573 ++#define False 0
20576 ++#ifdef _WIN32
20577 ++#define MY_STD_CALL __stdcall
20578 ++#else
20579 ++#define MY_STD_CALL
20580 ++#endif
20582 ++#ifdef _MSC_VER
20584 ++#if _MSC_VER >= 1300
20585 ++#define MY_NO_INLINE __declspec(noinline)
20586 ++#else
20587 ++#define MY_NO_INLINE
20588 ++#endif
20590 ++#define MY_CDECL __cdecl
20591 ++#define MY_FAST_CALL __fastcall
20593 ++#else
20595 ++#define MY_CDECL
20596 ++#define MY_FAST_CALL
20598 ++#endif
20601 ++/* The following interfaces use first parameter as pointer to structure */
20603 ++typedef struct
20605 ++ SRes (*Read)(void *p, void *buf, size_t *size);
20606 ++ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
20607 ++ (output(*size) < input(*size)) is allowed */
20608 ++} ISeqInStream;
20610 ++/* it can return SZ_ERROR_INPUT_EOF */
20611 ++SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
20612 ++SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
20613 ++SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
20615 ++typedef struct
20617 ++ size_t (*Write)(void *p, const void *buf, size_t size);
20618 ++ /* Returns: result - the number of actually written bytes.
20619 ++ (result < size) means error */
20620 ++} ISeqOutStream;
20622 ++typedef enum
20624 ++ SZ_SEEK_SET = 0,
20625 ++ SZ_SEEK_CUR = 1,
20626 ++ SZ_SEEK_END = 2
20627 ++} ESzSeek;
20629 ++typedef struct
20631 ++ SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
20632 ++ SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
20633 ++} ISeekInStream;
20635 ++typedef struct
20637 ++ SRes (*Look)(void *p, void **buf, size_t *size);
20638 ++ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
20639 ++ (output(*size) > input(*size)) is not allowed
20640 ++ (output(*size) < input(*size)) is allowed */
20641 ++ SRes (*Skip)(void *p, size_t offset);
20642 ++ /* offset must be <= output(*size) of Look */
20644 ++ SRes (*Read)(void *p, void *buf, size_t *size);
20645 ++ /* reads directly (without buffer). It's same as ISeqInStream::Read */
20646 ++ SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
20647 ++} ILookInStream;
20649 ++SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
20650 ++SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
20652 ++/* reads via ILookInStream::Read */
20653 ++SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
20654 ++SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
20656 ++#define LookToRead_BUF_SIZE (1 << 14)
20658 ++typedef struct
20660 ++ ILookInStream s;
20661 ++ ISeekInStream *realStream;
20662 ++ size_t pos;
20663 ++ size_t size;
20664 ++ Byte buf[LookToRead_BUF_SIZE];
20665 ++} CLookToRead;
20667 ++void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
20668 ++void LookToRead_Init(CLookToRead *p);
20670 ++typedef struct
20672 ++ ISeqInStream s;
20673 ++ ILookInStream *realStream;
20674 ++} CSecToLook;
20676 ++void SecToLook_CreateVTable(CSecToLook *p);
20678 ++typedef struct
20680 ++ ISeqInStream s;
20681 ++ ILookInStream *realStream;
20682 ++} CSecToRead;
20684 ++void SecToRead_CreateVTable(CSecToRead *p);
20686 ++typedef struct
20688 ++ SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
20689 ++ /* Returns: result. (result != SZ_OK) means break.
20690 ++ Value (UInt64)(Int64)-1 for size means unknown value. */
20691 ++} ICompressProgress;
20693 ++typedef struct
20695 ++ void *(*Alloc)(void *p, size_t size);
20696 ++ void (*Free)(void *p, void *address); /* address can be 0 */
20697 ++} ISzAlloc;
20699 ++#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
20700 ++#define IAlloc_Free(p, a) (p)->Free((p), a)
20702 ++EXTERN_C_END
20704 ++#endif
20705 +--- a/lib/Kconfig
20706 ++++ b/lib/Kconfig
20707 +@@ -215,6 +215,12 @@ config LZ4_DECOMPRESS
20709 + source "lib/xz/Kconfig"
20711 ++config LZMA_COMPRESS
20712 ++ tristate
20714 ++config LZMA_DECOMPRESS
20715 ++ tristate
20718 + # These all provide a common interface (hence the apparent duplication with
20719 + # ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
20720 +--- a/lib/Makefile
20721 ++++ b/lib/Makefile
20722 +@@ -2,6 +2,16 @@
20723 + # Makefile for some libs needed in the kernel.
20726 ++ifdef CONFIG_JFFS2_ZLIB
20727 ++ CONFIG_ZLIB_INFLATE:=y
20728 ++ CONFIG_ZLIB_DEFLATE:=y
20729 ++endif
20731 ++ifdef CONFIG_JFFS2_LZMA
20732 ++ CONFIG_LZMA_DECOMPRESS:=y
20733 ++ CONFIG_LZMA_COMPRESS:=y
20734 ++endif
20736 + ifdef CONFIG_FUNCTION_TRACER
20737 + ORIG_CFLAGS := $(KBUILD_CFLAGS)
20738 + KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))
20739 +@@ -82,6 +92,8 @@ obj-$(CONFIG_LZ4HC_COMPRESS) += lz4/
20740 + obj-$(CONFIG_LZ4_DECOMPRESS) += lz4/
20741 + obj-$(CONFIG_XZ_DEC) += xz/
20742 + obj-$(CONFIG_RAID6_PQ) += raid6/
20743 ++obj-$(CONFIG_LZMA_COMPRESS) += lzma/
20744 ++obj-$(CONFIG_LZMA_DECOMPRESS) += lzma/
20746 + lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
20747 + lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
20748 +--- /dev/null
20749 ++++ b/lib/lzma/LzFind.c
20750 +@@ -0,0 +1,761 @@
20751 ++/* LzFind.c -- Match finder for LZ algorithms
20752 ++2009-04-22 : Igor Pavlov : Public domain */
20754 ++#include <string.h>
20756 ++#include "LzFind.h"
20757 ++#include "LzHash.h"
20759 ++#define kEmptyHashValue 0
20760 ++#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
20761 ++#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
20762 ++#define kNormalizeMask (~(kNormalizeStepMin - 1))
20763 ++#define kMaxHistorySize ((UInt32)3 << 30)
20765 ++#define kStartMaxLen 3
20767 ++static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
20769 ++ if (!p->directInput)
20770 ++ {
20771 ++ alloc->Free(alloc, p->bufferBase);
20772 ++ p->bufferBase = 0;
20773 ++ }
20776 ++/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
20778 ++static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
20780 ++ UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
20781 ++ if (p->directInput)
20782 ++ {
20783 ++ p->blockSize = blockSize;
20784 ++ return 1;
20785 ++ }
20786 ++ if (p->bufferBase == 0 || p->blockSize != blockSize)
20787 ++ {
20788 ++ LzInWindow_Free(p, alloc);
20789 ++ p->blockSize = blockSize;
20790 ++ p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize);
20791 ++ }
20792 ++ return (p->bufferBase != 0);
20795 ++Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
20796 ++Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
20798 ++UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
20800 ++void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
20802 ++ p->posLimit -= subValue;
20803 ++ p->pos -= subValue;
20804 ++ p->streamPos -= subValue;
20807 ++static void MatchFinder_ReadBlock(CMatchFinder *p)
20809 ++ if (p->streamEndWasReached || p->result != SZ_OK)
20810 ++ return;
20811 ++ if (p->directInput)
20812 ++ {
20813 ++ UInt32 curSize = 0xFFFFFFFF - p->streamPos;
20814 ++ if (curSize > p->directInputRem)
20815 ++ curSize = (UInt32)p->directInputRem;
20816 ++ p->directInputRem -= curSize;
20817 ++ p->streamPos += curSize;
20818 ++ if (p->directInputRem == 0)
20819 ++ p->streamEndWasReached = 1;
20820 ++ return;
20821 ++ }
20822 ++ for (;;)
20823 ++ {
20824 ++ Byte *dest = p->buffer + (p->streamPos - p->pos);
20825 ++ size_t size = (p->bufferBase + p->blockSize - dest);
20826 ++ if (size == 0)
20827 ++ return;
20828 ++ p->result = p->stream->Read(p->stream, dest, &size);
20829 ++ if (p->result != SZ_OK)
20830 ++ return;
20831 ++ if (size == 0)
20832 ++ {
20833 ++ p->streamEndWasReached = 1;
20834 ++ return;
20835 ++ }
20836 ++ p->streamPos += (UInt32)size;
20837 ++ if (p->streamPos - p->pos > p->keepSizeAfter)
20838 ++ return;
20839 ++ }
20842 ++void MatchFinder_MoveBlock(CMatchFinder *p)
20844 ++ memmove(p->bufferBase,
20845 ++ p->buffer - p->keepSizeBefore,
20846 ++ (size_t)(p->streamPos - p->pos + p->keepSizeBefore));
20847 ++ p->buffer = p->bufferBase + p->keepSizeBefore;
20850 ++int MatchFinder_NeedMove(CMatchFinder *p)
20852 ++ if (p->directInput)
20853 ++ return 0;
20854 ++ /* if (p->streamEndWasReached) return 0; */
20855 ++ return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
20858 ++void MatchFinder_ReadIfRequired(CMatchFinder *p)
20860 ++ if (p->streamEndWasReached)
20861 ++ return;
20862 ++ if (p->keepSizeAfter >= p->streamPos - p->pos)
20863 ++ MatchFinder_ReadBlock(p);
20866 ++static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
20868 ++ if (MatchFinder_NeedMove(p))
20869 ++ MatchFinder_MoveBlock(p);
20870 ++ MatchFinder_ReadBlock(p);
20873 ++static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
20875 ++ p->cutValue = 32;
20876 ++ p->btMode = 1;
20877 ++ p->numHashBytes = 4;
20878 ++ p->bigHash = 0;
20881 ++#define kCrcPoly 0xEDB88320
20883 ++void MatchFinder_Construct(CMatchFinder *p)
20885 ++ UInt32 i;
20886 ++ p->bufferBase = 0;
20887 ++ p->directInput = 0;
20888 ++ p->hash = 0;
20889 ++ MatchFinder_SetDefaultSettings(p);
20891 ++ for (i = 0; i < 256; i++)
20892 ++ {
20893 ++ UInt32 r = i;
20894 ++ int j;
20895 ++ for (j = 0; j < 8; j++)
20896 ++ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
20897 ++ p->crc[i] = r;
20898 ++ }
20901 ++static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
20903 ++ alloc->Free(alloc, p->hash);
20904 ++ p->hash = 0;
20907 ++void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
20909 ++ MatchFinder_FreeThisClassMemory(p, alloc);
20910 ++ LzInWindow_Free(p, alloc);
20913 ++static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc)
20915 ++ size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
20916 ++ if (sizeInBytes / sizeof(CLzRef) != num)
20917 ++ return 0;
20918 ++ return (CLzRef *)alloc->Alloc(alloc, sizeInBytes);
20921 ++int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
20922 ++ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
20923 ++ ISzAlloc *alloc)
20925 ++ UInt32 sizeReserv;
20926 ++ if (historySize > kMaxHistorySize)
20927 ++ {
20928 ++ MatchFinder_Free(p, alloc);
20929 ++ return 0;
20930 ++ }
20931 ++ sizeReserv = historySize >> 1;
20932 ++ if (historySize > ((UInt32)2 << 30))
20933 ++ sizeReserv = historySize >> 2;
20934 ++ sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
20936 ++ p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
20937 ++ p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
20938 ++ /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
20939 ++ if (LzInWindow_Create(p, sizeReserv, alloc))
20940 ++ {
20941 ++ UInt32 newCyclicBufferSize = historySize + 1;
20942 ++ UInt32 hs;
20943 ++ p->matchMaxLen = matchMaxLen;
20944 ++ {
20945 ++ p->fixedHashSize = 0;
20946 ++ if (p->numHashBytes == 2)
20947 ++ hs = (1 << 16) - 1;
20948 ++ else
20949 ++ {
20950 ++ hs = historySize - 1;
20951 ++ hs |= (hs >> 1);
20952 ++ hs |= (hs >> 2);
20953 ++ hs |= (hs >> 4);
20954 ++ hs |= (hs >> 8);
20955 ++ hs >>= 1;
20956 ++ hs |= 0xFFFF; /* don't change it! It's required for Deflate */
20957 ++ if (hs > (1 << 24))
20958 ++ {
20959 ++ if (p->numHashBytes == 3)
20960 ++ hs = (1 << 24) - 1;
20961 ++ else
20962 ++ hs >>= 1;
20963 ++ }
20964 ++ }
20965 ++ p->hashMask = hs;
20966 ++ hs++;
20967 ++ if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;
20968 ++ if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;
20969 ++ if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;
20970 ++ hs += p->fixedHashSize;
20971 ++ }
20973 ++ {
20974 ++ UInt32 prevSize = p->hashSizeSum + p->numSons;
20975 ++ UInt32 newSize;
20976 ++ p->historySize = historySize;
20977 ++ p->hashSizeSum = hs;
20978 ++ p->cyclicBufferSize = newCyclicBufferSize;
20979 ++ p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize);
20980 ++ newSize = p->hashSizeSum + p->numSons;
20981 ++ if (p->hash != 0 && prevSize == newSize)
20982 ++ return 1;
20983 ++ MatchFinder_FreeThisClassMemory(p, alloc);
20984 ++ p->hash = AllocRefs(newSize, alloc);
20985 ++ if (p->hash != 0)
20986 ++ {
20987 ++ p->son = p->hash + p->hashSizeSum;
20988 ++ return 1;
20989 ++ }
20990 ++ }
20991 ++ }
20992 ++ MatchFinder_Free(p, alloc);
20993 ++ return 0;
20996 ++static void MatchFinder_SetLimits(CMatchFinder *p)
20998 ++ UInt32 limit = kMaxValForNormalize - p->pos;
20999 ++ UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
21000 ++ if (limit2 < limit)
21001 ++ limit = limit2;
21002 ++ limit2 = p->streamPos - p->pos;
21003 ++ if (limit2 <= p->keepSizeAfter)
21004 ++ {
21005 ++ if (limit2 > 0)
21006 ++ limit2 = 1;
21007 ++ }
21008 ++ else
21009 ++ limit2 -= p->keepSizeAfter;
21010 ++ if (limit2 < limit)
21011 ++ limit = limit2;
21012 ++ {
21013 ++ UInt32 lenLimit = p->streamPos - p->pos;
21014 ++ if (lenLimit > p->matchMaxLen)
21015 ++ lenLimit = p->matchMaxLen;
21016 ++ p->lenLimit = lenLimit;
21017 ++ }
21018 ++ p->posLimit = p->pos + limit;
21021 ++void MatchFinder_Init(CMatchFinder *p)
21023 ++ UInt32 i;
21024 ++ for (i = 0; i < p->hashSizeSum; i++)
21025 ++ p->hash[i] = kEmptyHashValue;
21026 ++ p->cyclicBufferPos = 0;
21027 ++ p->buffer = p->bufferBase;
21028 ++ p->pos = p->streamPos = p->cyclicBufferSize;
21029 ++ p->result = SZ_OK;
21030 ++ p->streamEndWasReached = 0;
21031 ++ MatchFinder_ReadBlock(p);
21032 ++ MatchFinder_SetLimits(p);
21035 ++static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
21037 ++ return (p->pos - p->historySize - 1) & kNormalizeMask;
21040 ++void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
21042 ++ UInt32 i;
21043 ++ for (i = 0; i < numItems; i++)
21044 ++ {
21045 ++ UInt32 value = items[i];
21046 ++ if (value <= subValue)
21047 ++ value = kEmptyHashValue;
21048 ++ else
21049 ++ value -= subValue;
21050 ++ items[i] = value;
21051 ++ }
21054 ++static void MatchFinder_Normalize(CMatchFinder *p)
21056 ++ UInt32 subValue = MatchFinder_GetSubValue(p);
21057 ++ MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
21058 ++ MatchFinder_ReduceOffsets(p, subValue);
21061 ++static void MatchFinder_CheckLimits(CMatchFinder *p)
21063 ++ if (p->pos == kMaxValForNormalize)
21064 ++ MatchFinder_Normalize(p);
21065 ++ if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)
21066 ++ MatchFinder_CheckAndMoveAndRead(p);
21067 ++ if (p->cyclicBufferPos == p->cyclicBufferSize)
21068 ++ p->cyclicBufferPos = 0;
21069 ++ MatchFinder_SetLimits(p);
21072 ++static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
21073 ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
21074 ++ UInt32 *distances, UInt32 maxLen)
21076 ++ son[_cyclicBufferPos] = curMatch;
21077 ++ for (;;)
21078 ++ {
21079 ++ UInt32 delta = pos - curMatch;
21080 ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
21081 ++ return distances;
21082 ++ {
21083 ++ const Byte *pb = cur - delta;
21084 ++ curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
21085 ++ if (pb[maxLen] == cur[maxLen] && *pb == *cur)
21086 ++ {
21087 ++ UInt32 len = 0;
21088 ++ while (++len != lenLimit)
21089 ++ if (pb[len] != cur[len])
21090 ++ break;
21091 ++ if (maxLen < len)
21092 ++ {
21093 ++ *distances++ = maxLen = len;
21094 ++ *distances++ = delta - 1;
21095 ++ if (len == lenLimit)
21096 ++ return distances;
21097 ++ }
21098 ++ }
21099 ++ }
21100 ++ }
21103 ++UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
21104 ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
21105 ++ UInt32 *distances, UInt32 maxLen)
21107 ++ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
21108 ++ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
21109 ++ UInt32 len0 = 0, len1 = 0;
21110 ++ for (;;)
21111 ++ {
21112 ++ UInt32 delta = pos - curMatch;
21113 ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
21114 ++ {
21115 ++ *ptr0 = *ptr1 = kEmptyHashValue;
21116 ++ return distances;
21117 ++ }
21118 ++ {
21119 ++ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
21120 ++ const Byte *pb = cur - delta;
21121 ++ UInt32 len = (len0 < len1 ? len0 : len1);
21122 ++ if (pb[len] == cur[len])
21123 ++ {
21124 ++ if (++len != lenLimit && pb[len] == cur[len])
21125 ++ while (++len != lenLimit)
21126 ++ if (pb[len] != cur[len])
21127 ++ break;
21128 ++ if (maxLen < len)
21129 ++ {
21130 ++ *distances++ = maxLen = len;
21131 ++ *distances++ = delta - 1;
21132 ++ if (len == lenLimit)
21133 ++ {
21134 ++ *ptr1 = pair[0];
21135 ++ *ptr0 = pair[1];
21136 ++ return distances;
21137 ++ }
21138 ++ }
21139 ++ }
21140 ++ if (pb[len] < cur[len])
21141 ++ {
21142 ++ *ptr1 = curMatch;
21143 ++ ptr1 = pair + 1;
21144 ++ curMatch = *ptr1;
21145 ++ len1 = len;
21146 ++ }
21147 ++ else
21148 ++ {
21149 ++ *ptr0 = curMatch;
21150 ++ ptr0 = pair;
21151 ++ curMatch = *ptr0;
21152 ++ len0 = len;
21153 ++ }
21154 ++ }
21155 ++ }
21158 ++static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
21159 ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
21161 ++ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
21162 ++ CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
21163 ++ UInt32 len0 = 0, len1 = 0;
21164 ++ for (;;)
21165 ++ {
21166 ++ UInt32 delta = pos - curMatch;
21167 ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize)
21168 ++ {
21169 ++ *ptr0 = *ptr1 = kEmptyHashValue;
21170 ++ return;
21171 ++ }
21172 ++ {
21173 ++ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
21174 ++ const Byte *pb = cur - delta;
21175 ++ UInt32 len = (len0 < len1 ? len0 : len1);
21176 ++ if (pb[len] == cur[len])
21177 ++ {
21178 ++ while (++len != lenLimit)
21179 ++ if (pb[len] != cur[len])
21180 ++ break;
21181 ++ {
21182 ++ if (len == lenLimit)
21183 ++ {
21184 ++ *ptr1 = pair[0];
21185 ++ *ptr0 = pair[1];
21186 ++ return;
21187 ++ }
21188 ++ }
21189 ++ }
21190 ++ if (pb[len] < cur[len])
21191 ++ {
21192 ++ *ptr1 = curMatch;
21193 ++ ptr1 = pair + 1;
21194 ++ curMatch = *ptr1;
21195 ++ len1 = len;
21196 ++ }
21197 ++ else
21198 ++ {
21199 ++ *ptr0 = curMatch;
21200 ++ ptr0 = pair;
21201 ++ curMatch = *ptr0;
21202 ++ len0 = len;
21203 ++ }
21204 ++ }
21205 ++ }
21208 ++#define MOVE_POS \
21209 ++ ++p->cyclicBufferPos; \
21210 ++ p->buffer++; \
21211 ++ if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
21213 ++#define MOVE_POS_RET MOVE_POS return offset;
21215 ++static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
21217 ++#define GET_MATCHES_HEADER2(minLen, ret_op) \
21218 ++ UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
21219 ++ lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
21220 ++ cur = p->buffer;
21222 ++#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
21223 ++#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue)
21225 ++#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
21227 ++#define GET_MATCHES_FOOTER(offset, maxLen) \
21228 ++ offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
21229 ++ distances + offset, maxLen) - distances); MOVE_POS_RET;
21231 ++#define SKIP_FOOTER \
21232 ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
21234 ++static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
21236 ++ UInt32 offset;
21237 ++ GET_MATCHES_HEADER(2)
21238 ++ HASH2_CALC;
21239 ++ curMatch = p->hash[hashValue];
21240 ++ p->hash[hashValue] = p->pos;
21241 ++ offset = 0;
21242 ++ GET_MATCHES_FOOTER(offset, 1)
21245 ++UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
21247 ++ UInt32 offset;
21248 ++ GET_MATCHES_HEADER(3)
21249 ++ HASH_ZIP_CALC;
21250 ++ curMatch = p->hash[hashValue];
21251 ++ p->hash[hashValue] = p->pos;
21252 ++ offset = 0;
21253 ++ GET_MATCHES_FOOTER(offset, 2)
21256 ++static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
21258 ++ UInt32 hash2Value, delta2, maxLen, offset;
21259 ++ GET_MATCHES_HEADER(3)
21261 ++ HASH3_CALC;
21263 ++ delta2 = p->pos - p->hash[hash2Value];
21264 ++ curMatch = p->hash[kFix3HashSize + hashValue];
21266 ++ p->hash[hash2Value] =
21267 ++ p->hash[kFix3HashSize + hashValue] = p->pos;
21270 ++ maxLen = 2;
21271 ++ offset = 0;
21272 ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
21273 ++ {
21274 ++ for (; maxLen != lenLimit; maxLen++)
21275 ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
21276 ++ break;
21277 ++ distances[0] = maxLen;
21278 ++ distances[1] = delta2 - 1;
21279 ++ offset = 2;
21280 ++ if (maxLen == lenLimit)
21281 ++ {
21282 ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
21283 ++ MOVE_POS_RET;
21284 ++ }
21285 ++ }
21286 ++ GET_MATCHES_FOOTER(offset, maxLen)
21289 ++static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
21291 ++ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
21292 ++ GET_MATCHES_HEADER(4)
21294 ++ HASH4_CALC;
21296 ++ delta2 = p->pos - p->hash[ hash2Value];
21297 ++ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
21298 ++ curMatch = p->hash[kFix4HashSize + hashValue];
21300 ++ p->hash[ hash2Value] =
21301 ++ p->hash[kFix3HashSize + hash3Value] =
21302 ++ p->hash[kFix4HashSize + hashValue] = p->pos;
21304 ++ maxLen = 1;
21305 ++ offset = 0;
21306 ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
21307 ++ {
21308 ++ distances[0] = maxLen = 2;
21309 ++ distances[1] = delta2 - 1;
21310 ++ offset = 2;
21311 ++ }
21312 ++ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
21313 ++ {
21314 ++ maxLen = 3;
21315 ++ distances[offset + 1] = delta3 - 1;
21316 ++ offset += 2;
21317 ++ delta2 = delta3;
21318 ++ }
21319 ++ if (offset != 0)
21320 ++ {
21321 ++ for (; maxLen != lenLimit; maxLen++)
21322 ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
21323 ++ break;
21324 ++ distances[offset - 2] = maxLen;
21325 ++ if (maxLen == lenLimit)
21326 ++ {
21327 ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
21328 ++ MOVE_POS_RET;
21329 ++ }
21330 ++ }
21331 ++ if (maxLen < 3)
21332 ++ maxLen = 3;
21333 ++ GET_MATCHES_FOOTER(offset, maxLen)
21336 ++static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
21338 ++ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
21339 ++ GET_MATCHES_HEADER(4)
21341 ++ HASH4_CALC;
21343 ++ delta2 = p->pos - p->hash[ hash2Value];
21344 ++ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
21345 ++ curMatch = p->hash[kFix4HashSize + hashValue];
21347 ++ p->hash[ hash2Value] =
21348 ++ p->hash[kFix3HashSize + hash3Value] =
21349 ++ p->hash[kFix4HashSize + hashValue] = p->pos;
21351 ++ maxLen = 1;
21352 ++ offset = 0;
21353 ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
21354 ++ {
21355 ++ distances[0] = maxLen = 2;
21356 ++ distances[1] = delta2 - 1;
21357 ++ offset = 2;
21358 ++ }
21359 ++ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
21360 ++ {
21361 ++ maxLen = 3;
21362 ++ distances[offset + 1] = delta3 - 1;
21363 ++ offset += 2;
21364 ++ delta2 = delta3;
21365 ++ }
21366 ++ if (offset != 0)
21367 ++ {
21368 ++ for (; maxLen != lenLimit; maxLen++)
21369 ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
21370 ++ break;
21371 ++ distances[offset - 2] = maxLen;
21372 ++ if (maxLen == lenLimit)
21373 ++ {
21374 ++ p->son[p->cyclicBufferPos] = curMatch;
21375 ++ MOVE_POS_RET;
21376 ++ }
21377 ++ }
21378 ++ if (maxLen < 3)
21379 ++ maxLen = 3;
21380 ++ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
21381 ++ distances + offset, maxLen) - (distances));
21382 ++ MOVE_POS_RET
21385 ++UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
21387 ++ UInt32 offset;
21388 ++ GET_MATCHES_HEADER(3)
21389 ++ HASH_ZIP_CALC;
21390 ++ curMatch = p->hash[hashValue];
21391 ++ p->hash[hashValue] = p->pos;
21392 ++ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
21393 ++ distances, 2) - (distances));
21394 ++ MOVE_POS_RET
21397 ++static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
21399 ++ do
21400 ++ {
21401 ++ SKIP_HEADER(2)
21402 ++ HASH2_CALC;
21403 ++ curMatch = p->hash[hashValue];
21404 ++ p->hash[hashValue] = p->pos;
21405 ++ SKIP_FOOTER
21406 ++ }
21407 ++ while (--num != 0);
21410 ++void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
21412 ++ do
21413 ++ {
21414 ++ SKIP_HEADER(3)
21415 ++ HASH_ZIP_CALC;
21416 ++ curMatch = p->hash[hashValue];
21417 ++ p->hash[hashValue] = p->pos;
21418 ++ SKIP_FOOTER
21419 ++ }
21420 ++ while (--num != 0);
21423 ++static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
21425 ++ do
21426 ++ {
21427 ++ UInt32 hash2Value;
21428 ++ SKIP_HEADER(3)
21429 ++ HASH3_CALC;
21430 ++ curMatch = p->hash[kFix3HashSize + hashValue];
21431 ++ p->hash[hash2Value] =
21432 ++ p->hash[kFix3HashSize + hashValue] = p->pos;
21433 ++ SKIP_FOOTER
21434 ++ }
21435 ++ while (--num != 0);
21438 ++static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
21440 ++ do
21441 ++ {
21442 ++ UInt32 hash2Value, hash3Value;
21443 ++ SKIP_HEADER(4)
21444 ++ HASH4_CALC;
21445 ++ curMatch = p->hash[kFix4HashSize + hashValue];
21446 ++ p->hash[ hash2Value] =
21447 ++ p->hash[kFix3HashSize + hash3Value] = p->pos;
21448 ++ p->hash[kFix4HashSize + hashValue] = p->pos;
21449 ++ SKIP_FOOTER
21450 ++ }
21451 ++ while (--num != 0);
21454 ++static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
21456 ++ do
21457 ++ {
21458 ++ UInt32 hash2Value, hash3Value;
21459 ++ SKIP_HEADER(4)
21460 ++ HASH4_CALC;
21461 ++ curMatch = p->hash[kFix4HashSize + hashValue];
21462 ++ p->hash[ hash2Value] =
21463 ++ p->hash[kFix3HashSize + hash3Value] =
21464 ++ p->hash[kFix4HashSize + hashValue] = p->pos;
21465 ++ p->son[p->cyclicBufferPos] = curMatch;
21466 ++ MOVE_POS
21467 ++ }
21468 ++ while (--num != 0);
21471 ++void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
21473 ++ do
21474 ++ {
21475 ++ SKIP_HEADER(3)
21476 ++ HASH_ZIP_CALC;
21477 ++ curMatch = p->hash[hashValue];
21478 ++ p->hash[hashValue] = p->pos;
21479 ++ p->son[p->cyclicBufferPos] = curMatch;
21480 ++ MOVE_POS
21481 ++ }
21482 ++ while (--num != 0);
21485 ++void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
21487 ++ vTable->Init = (Mf_Init_Func)MatchFinder_Init;
21488 ++ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
21489 ++ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
21490 ++ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
21491 ++ if (!p->btMode)
21492 ++ {
21493 ++ vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
21494 ++ vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
21495 ++ }
21496 ++ else if (p->numHashBytes == 2)
21497 ++ {
21498 ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
21499 ++ vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
21500 ++ }
21501 ++ else if (p->numHashBytes == 3)
21502 ++ {
21503 ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
21504 ++ vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
21505 ++ }
21506 ++ else
21507 ++ {
21508 ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
21509 ++ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
21510 ++ }
21512 +--- /dev/null
21513 ++++ b/lib/lzma/LzmaDec.c
21514 +@@ -0,0 +1,999 @@
21515 ++/* LzmaDec.c -- LZMA Decoder
21516 ++2009-09-20 : Igor Pavlov : Public domain */
21518 ++#include "LzmaDec.h"
21520 ++#include <string.h>
21522 ++#define kNumTopBits 24
21523 ++#define kTopValue ((UInt32)1 << kNumTopBits)
21525 ++#define kNumBitModelTotalBits 11
21526 ++#define kBitModelTotal (1 << kNumBitModelTotalBits)
21527 ++#define kNumMoveBits 5
21529 ++#define RC_INIT_SIZE 5
21531 ++#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
21533 ++#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
21534 ++#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
21535 ++#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
21536 ++#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
21537 ++ { UPDATE_0(p); i = (i + i); A0; } else \
21538 ++ { UPDATE_1(p); i = (i + i) + 1; A1; }
21539 ++#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)
21541 ++#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }
21542 ++#define TREE_DECODE(probs, limit, i) \
21543 ++ { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
21545 ++/* #define _LZMA_SIZE_OPT */
21547 ++#ifdef _LZMA_SIZE_OPT
21548 ++#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
21549 ++#else
21550 ++#define TREE_6_DECODE(probs, i) \
21551 ++ { i = 1; \
21552 ++ TREE_GET_BIT(probs, i); \
21553 ++ TREE_GET_BIT(probs, i); \
21554 ++ TREE_GET_BIT(probs, i); \
21555 ++ TREE_GET_BIT(probs, i); \
21556 ++ TREE_GET_BIT(probs, i); \
21557 ++ TREE_GET_BIT(probs, i); \
21558 ++ i -= 0x40; }
21559 ++#endif
21561 ++#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
21563 ++#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
21564 ++#define UPDATE_0_CHECK range = bound;
21565 ++#define UPDATE_1_CHECK range -= bound; code -= bound;
21566 ++#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
21567 ++ { UPDATE_0_CHECK; i = (i + i); A0; } else \
21568 ++ { UPDATE_1_CHECK; i = (i + i) + 1; A1; }
21569 ++#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
21570 ++#define TREE_DECODE_CHECK(probs, limit, i) \
21571 ++ { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
21574 ++#define kNumPosBitsMax 4
21575 ++#define kNumPosStatesMax (1 << kNumPosBitsMax)
21577 ++#define kLenNumLowBits 3
21578 ++#define kLenNumLowSymbols (1 << kLenNumLowBits)
21579 ++#define kLenNumMidBits 3
21580 ++#define kLenNumMidSymbols (1 << kLenNumMidBits)
21581 ++#define kLenNumHighBits 8
21582 ++#define kLenNumHighSymbols (1 << kLenNumHighBits)
21584 ++#define LenChoice 0
21585 ++#define LenChoice2 (LenChoice + 1)
21586 ++#define LenLow (LenChoice2 + 1)
21587 ++#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
21588 ++#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
21589 ++#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
21592 ++#define kNumStates 12
21593 ++#define kNumLitStates 7
21595 ++#define kStartPosModelIndex 4
21596 ++#define kEndPosModelIndex 14
21597 ++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
21599 ++#define kNumPosSlotBits 6
21600 ++#define kNumLenToPosStates 4
21602 ++#define kNumAlignBits 4
21603 ++#define kAlignTableSize (1 << kNumAlignBits)
21605 ++#define kMatchMinLen 2
21606 ++#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
21608 ++#define IsMatch 0
21609 ++#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
21610 ++#define IsRepG0 (IsRep + kNumStates)
21611 ++#define IsRepG1 (IsRepG0 + kNumStates)
21612 ++#define IsRepG2 (IsRepG1 + kNumStates)
21613 ++#define IsRep0Long (IsRepG2 + kNumStates)
21614 ++#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
21615 ++#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
21616 ++#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
21617 ++#define LenCoder (Align + kAlignTableSize)
21618 ++#define RepLenCoder (LenCoder + kNumLenProbs)
21619 ++#define Literal (RepLenCoder + kNumLenProbs)
21621 ++#define LZMA_BASE_SIZE 1846
21622 ++#define LZMA_LIT_SIZE 768
21624 ++#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
21626 ++#if Literal != LZMA_BASE_SIZE
21627 ++StopCompilingDueBUG
21628 ++#endif
21630 ++#define LZMA_DIC_MIN (1 << 12)
21632 ++/* First LZMA-symbol is always decoded.
21633 ++And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
21634 ++Out:
21635 ++ Result:
21636 ++ SZ_OK - OK
21637 ++ SZ_ERROR_DATA - Error
21638 ++ p->remainLen:
21639 ++ < kMatchSpecLenStart : normal remain
21640 ++ = kMatchSpecLenStart : finished
21641 ++ = kMatchSpecLenStart + 1 : Flush marker
21642 ++ = kMatchSpecLenStart + 2 : State Init Marker
21643 ++*/
21645 ++static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
21647 ++ CLzmaProb *probs = p->probs;
21649 ++ unsigned state = p->state;
21650 ++ UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
21651 ++ unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
21652 ++ unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
21653 ++ unsigned lc = p->prop.lc;
21655 ++ Byte *dic = p->dic;
21656 ++ SizeT dicBufSize = p->dicBufSize;
21657 ++ SizeT dicPos = p->dicPos;
21659 ++ UInt32 processedPos = p->processedPos;
21660 ++ UInt32 checkDicSize = p->checkDicSize;
21661 ++ unsigned len = 0;
21663 ++ const Byte *buf = p->buf;
21664 ++ UInt32 range = p->range;
21665 ++ UInt32 code = p->code;
21667 ++ do
21668 ++ {
21669 ++ CLzmaProb *prob;
21670 ++ UInt32 bound;
21671 ++ unsigned ttt;
21672 ++ unsigned posState = processedPos & pbMask;
21674 ++ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
21675 ++ IF_BIT_0(prob)
21676 ++ {
21677 ++ unsigned symbol;
21678 ++ UPDATE_0(prob);
21679 ++ prob = probs + Literal;
21680 ++ if (checkDicSize != 0 || processedPos != 0)
21681 ++ prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
21682 ++ (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
21684 ++ if (state < kNumLitStates)
21685 ++ {
21686 ++ state -= (state < 4) ? state : 3;
21687 ++ symbol = 1;
21688 ++ do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
21689 ++ }
21690 ++ else
21691 ++ {
21692 ++ unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
21693 ++ unsigned offs = 0x100;
21694 ++ state -= (state < 10) ? 3 : 6;
21695 ++ symbol = 1;
21696 ++ do
21697 ++ {
21698 ++ unsigned bit;
21699 ++ CLzmaProb *probLit;
21700 ++ matchByte <<= 1;
21701 ++ bit = (matchByte & offs);
21702 ++ probLit = prob + offs + bit + symbol;
21703 ++ GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
21704 ++ }
21705 ++ while (symbol < 0x100);
21706 ++ }
21707 ++ dic[dicPos++] = (Byte)symbol;
21708 ++ processedPos++;
21709 ++ continue;
21710 ++ }
21711 ++ else
21712 ++ {
21713 ++ UPDATE_1(prob);
21714 ++ prob = probs + IsRep + state;
21715 ++ IF_BIT_0(prob)
21716 ++ {
21717 ++ UPDATE_0(prob);
21718 ++ state += kNumStates;
21719 ++ prob = probs + LenCoder;
21720 ++ }
21721 ++ else
21722 ++ {
21723 ++ UPDATE_1(prob);
21724 ++ if (checkDicSize == 0 && processedPos == 0)
21725 ++ return SZ_ERROR_DATA;
21726 ++ prob = probs + IsRepG0 + state;
21727 ++ IF_BIT_0(prob)
21728 ++ {
21729 ++ UPDATE_0(prob);
21730 ++ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
21731 ++ IF_BIT_0(prob)
21732 ++ {
21733 ++ UPDATE_0(prob);
21734 ++ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
21735 ++ dicPos++;
21736 ++ processedPos++;
21737 ++ state = state < kNumLitStates ? 9 : 11;
21738 ++ continue;
21739 ++ }
21740 ++ UPDATE_1(prob);
21741 ++ }
21742 ++ else
21743 ++ {
21744 ++ UInt32 distance;
21745 ++ UPDATE_1(prob);
21746 ++ prob = probs + IsRepG1 + state;
21747 ++ IF_BIT_0(prob)
21748 ++ {
21749 ++ UPDATE_0(prob);
21750 ++ distance = rep1;
21751 ++ }
21752 ++ else
21753 ++ {
21754 ++ UPDATE_1(prob);
21755 ++ prob = probs + IsRepG2 + state;
21756 ++ IF_BIT_0(prob)
21757 ++ {
21758 ++ UPDATE_0(prob);
21759 ++ distance = rep2;
21760 ++ }
21761 ++ else
21762 ++ {
21763 ++ UPDATE_1(prob);
21764 ++ distance = rep3;
21765 ++ rep3 = rep2;
21766 ++ }
21767 ++ rep2 = rep1;
21768 ++ }
21769 ++ rep1 = rep0;
21770 ++ rep0 = distance;
21771 ++ }
21772 ++ state = state < kNumLitStates ? 8 : 11;
21773 ++ prob = probs + RepLenCoder;
21774 ++ }
21775 ++ {
21776 ++ unsigned limit, offset;
21777 ++ CLzmaProb *probLen = prob + LenChoice;
21778 ++ IF_BIT_0(probLen)
21779 ++ {
21780 ++ UPDATE_0(probLen);
21781 ++ probLen = prob + LenLow + (posState << kLenNumLowBits);
21782 ++ offset = 0;
21783 ++ limit = (1 << kLenNumLowBits);
21784 ++ }
21785 ++ else
21786 ++ {
21787 ++ UPDATE_1(probLen);
21788 ++ probLen = prob + LenChoice2;
21789 ++ IF_BIT_0(probLen)
21790 ++ {
21791 ++ UPDATE_0(probLen);
21792 ++ probLen = prob + LenMid + (posState << kLenNumMidBits);
21793 ++ offset = kLenNumLowSymbols;
21794 ++ limit = (1 << kLenNumMidBits);
21795 ++ }
21796 ++ else
21797 ++ {
21798 ++ UPDATE_1(probLen);
21799 ++ probLen = prob + LenHigh;
21800 ++ offset = kLenNumLowSymbols + kLenNumMidSymbols;
21801 ++ limit = (1 << kLenNumHighBits);
21802 ++ }
21803 ++ }
21804 ++ TREE_DECODE(probLen, limit, len);
21805 ++ len += offset;
21806 ++ }
21808 ++ if (state >= kNumStates)
21809 ++ {
21810 ++ UInt32 distance;
21811 ++ prob = probs + PosSlot +
21812 ++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
21813 ++ TREE_6_DECODE(prob, distance);
21814 ++ if (distance >= kStartPosModelIndex)
21815 ++ {
21816 ++ unsigned posSlot = (unsigned)distance;
21817 ++ int numDirectBits = (int)(((distance >> 1) - 1));
21818 ++ distance = (2 | (distance & 1));
21819 ++ if (posSlot < kEndPosModelIndex)
21820 ++ {
21821 ++ distance <<= numDirectBits;
21822 ++ prob = probs + SpecPos + distance - posSlot - 1;
21823 ++ {
21824 ++ UInt32 mask = 1;
21825 ++ unsigned i = 1;
21826 ++ do
21827 ++ {
21828 ++ GET_BIT2(prob + i, i, ; , distance |= mask);
21829 ++ mask <<= 1;
21830 ++ }
21831 ++ while (--numDirectBits != 0);
21832 ++ }
21833 ++ }
21834 ++ else
21835 ++ {
21836 ++ numDirectBits -= kNumAlignBits;
21837 ++ do
21838 ++ {
21839 ++ NORMALIZE
21840 ++ range >>= 1;
21842 ++ {
21843 ++ UInt32 t;
21844 ++ code -= range;
21845 ++ t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
21846 ++ distance = (distance << 1) + (t + 1);
21847 ++ code += range & t;
21848 ++ }
21849 ++ /*
21850 ++ distance <<= 1;
21851 ++ if (code >= range)
21852 ++ {
21853 ++ code -= range;
21854 ++ distance |= 1;
21855 ++ }
21856 ++ */
21857 ++ }
21858 ++ while (--numDirectBits != 0);
21859 ++ prob = probs + Align;
21860 ++ distance <<= kNumAlignBits;
21861 ++ {
21862 ++ unsigned i = 1;
21863 ++ GET_BIT2(prob + i, i, ; , distance |= 1);
21864 ++ GET_BIT2(prob + i, i, ; , distance |= 2);
21865 ++ GET_BIT2(prob + i, i, ; , distance |= 4);
21866 ++ GET_BIT2(prob + i, i, ; , distance |= 8);
21867 ++ }
21868 ++ if (distance == (UInt32)0xFFFFFFFF)
21869 ++ {
21870 ++ len += kMatchSpecLenStart;
21871 ++ state -= kNumStates;
21872 ++ break;
21873 ++ }
21874 ++ }
21875 ++ }
21876 ++ rep3 = rep2;
21877 ++ rep2 = rep1;
21878 ++ rep1 = rep0;
21879 ++ rep0 = distance + 1;
21880 ++ if (checkDicSize == 0)
21881 ++ {
21882 ++ if (distance >= processedPos)
21883 ++ return SZ_ERROR_DATA;
21884 ++ }
21885 ++ else if (distance >= checkDicSize)
21886 ++ return SZ_ERROR_DATA;
21887 ++ state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
21888 ++ }
21890 ++ len += kMatchMinLen;
21892 ++ if (limit == dicPos)
21893 ++ return SZ_ERROR_DATA;
21894 ++ {
21895 ++ SizeT rem = limit - dicPos;
21896 ++ unsigned curLen = ((rem < len) ? (unsigned)rem : len);
21897 ++ SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
21899 ++ processedPos += curLen;
21901 ++ len -= curLen;
21902 ++ if (pos + curLen <= dicBufSize)
21903 ++ {
21904 ++ Byte *dest = dic + dicPos;
21905 ++ ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
21906 ++ const Byte *lim = dest + curLen;
21907 ++ dicPos += curLen;
21908 ++ do
21909 ++ *(dest) = (Byte)*(dest + src);
21910 ++ while (++dest != lim);
21911 ++ }
21912 ++ else
21913 ++ {
21914 ++ do
21915 ++ {
21916 ++ dic[dicPos++] = dic[pos];
21917 ++ if (++pos == dicBufSize)
21918 ++ pos = 0;
21919 ++ }
21920 ++ while (--curLen != 0);
21921 ++ }
21922 ++ }
21923 ++ }
21924 ++ }
21925 ++ while (dicPos < limit && buf < bufLimit);
21926 ++ NORMALIZE;
21927 ++ p->buf = buf;
21928 ++ p->range = range;
21929 ++ p->code = code;
21930 ++ p->remainLen = len;
21931 ++ p->dicPos = dicPos;
21932 ++ p->processedPos = processedPos;
21933 ++ p->reps[0] = rep0;
21934 ++ p->reps[1] = rep1;
21935 ++ p->reps[2] = rep2;
21936 ++ p->reps[3] = rep3;
21937 ++ p->state = state;
21939 ++ return SZ_OK;
21942 ++static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
21944 ++ if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
21945 ++ {
21946 ++ Byte *dic = p->dic;
21947 ++ SizeT dicPos = p->dicPos;
21948 ++ SizeT dicBufSize = p->dicBufSize;
21949 ++ unsigned len = p->remainLen;
21950 ++ UInt32 rep0 = p->reps[0];
21951 ++ if (limit - dicPos < len)
21952 ++ len = (unsigned)(limit - dicPos);
21954 ++ if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
21955 ++ p->checkDicSize = p->prop.dicSize;
21957 ++ p->processedPos += len;
21958 ++ p->remainLen -= len;
21959 ++ while (len-- != 0)
21960 ++ {
21961 ++ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
21962 ++ dicPos++;
21963 ++ }
21964 ++ p->dicPos = dicPos;
21965 ++ }
21968 ++static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
21970 ++ do
21971 ++ {
21972 ++ SizeT limit2 = limit;
21973 ++ if (p->checkDicSize == 0)
21974 ++ {
21975 ++ UInt32 rem = p->prop.dicSize - p->processedPos;
21976 ++ if (limit - p->dicPos > rem)
21977 ++ limit2 = p->dicPos + rem;
21978 ++ }
21979 ++ RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
21980 ++ if (p->processedPos >= p->prop.dicSize)
21981 ++ p->checkDicSize = p->prop.dicSize;
21982 ++ LzmaDec_WriteRem(p, limit);
21983 ++ }
21984 ++ while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
21986 ++ if (p->remainLen > kMatchSpecLenStart)
21987 ++ {
21988 ++ p->remainLen = kMatchSpecLenStart;
21989 ++ }
21990 ++ return 0;
21993 ++typedef enum
21995 ++ DUMMY_ERROR, /* unexpected end of input stream */
21996 ++ DUMMY_LIT,
21997 ++ DUMMY_MATCH,
21998 ++ DUMMY_REP
21999 ++} ELzmaDummy;
22001 ++static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
22003 ++ UInt32 range = p->range;
22004 ++ UInt32 code = p->code;
22005 ++ const Byte *bufLimit = buf + inSize;
22006 ++ CLzmaProb *probs = p->probs;
22007 ++ unsigned state = p->state;
22008 ++ ELzmaDummy res;
22010 ++ {
22011 ++ CLzmaProb *prob;
22012 ++ UInt32 bound;
22013 ++ unsigned ttt;
22014 ++ unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
22016 ++ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
22017 ++ IF_BIT_0_CHECK(prob)
22018 ++ {
22019 ++ UPDATE_0_CHECK
22021 ++ /* if (bufLimit - buf >= 7) return DUMMY_LIT; */
22023 ++ prob = probs + Literal;
22024 ++ if (p->checkDicSize != 0 || p->processedPos != 0)
22025 ++ prob += (LZMA_LIT_SIZE *
22026 ++ ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
22027 ++ (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
22029 ++ if (state < kNumLitStates)
22030 ++ {
22031 ++ unsigned symbol = 1;
22032 ++ do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
22033 ++ }
22034 ++ else
22035 ++ {
22036 ++ unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
22037 ++ ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
22038 ++ unsigned offs = 0x100;
22039 ++ unsigned symbol = 1;
22040 ++ do
22041 ++ {
22042 ++ unsigned bit;
22043 ++ CLzmaProb *probLit;
22044 ++ matchByte <<= 1;
22045 ++ bit = (matchByte & offs);
22046 ++ probLit = prob + offs + bit + symbol;
22047 ++ GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
22048 ++ }
22049 ++ while (symbol < 0x100);
22050 ++ }
22051 ++ res = DUMMY_LIT;
22052 ++ }
22053 ++ else
22054 ++ {
22055 ++ unsigned len;
22056 ++ UPDATE_1_CHECK;
22058 ++ prob = probs + IsRep + state;
22059 ++ IF_BIT_0_CHECK(prob)
22060 ++ {
22061 ++ UPDATE_0_CHECK;
22062 ++ state = 0;
22063 ++ prob = probs + LenCoder;
22064 ++ res = DUMMY_MATCH;
22065 ++ }
22066 ++ else
22067 ++ {
22068 ++ UPDATE_1_CHECK;
22069 ++ res = DUMMY_REP;
22070 ++ prob = probs + IsRepG0 + state;
22071 ++ IF_BIT_0_CHECK(prob)
22072 ++ {
22073 ++ UPDATE_0_CHECK;
22074 ++ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
22075 ++ IF_BIT_0_CHECK(prob)
22076 ++ {
22077 ++ UPDATE_0_CHECK;
22078 ++ NORMALIZE_CHECK;
22079 ++ return DUMMY_REP;
22080 ++ }
22081 ++ else
22082 ++ {
22083 ++ UPDATE_1_CHECK;
22084 ++ }
22085 ++ }
22086 ++ else
22087 ++ {
22088 ++ UPDATE_1_CHECK;
22089 ++ prob = probs + IsRepG1 + state;
22090 ++ IF_BIT_0_CHECK(prob)
22091 ++ {
22092 ++ UPDATE_0_CHECK;
22093 ++ }
22094 ++ else
22095 ++ {
22096 ++ UPDATE_1_CHECK;
22097 ++ prob = probs + IsRepG2 + state;
22098 ++ IF_BIT_0_CHECK(prob)
22099 ++ {
22100 ++ UPDATE_0_CHECK;
22101 ++ }
22102 ++ else
22103 ++ {
22104 ++ UPDATE_1_CHECK;
22105 ++ }
22106 ++ }
22107 ++ }
22108 ++ state = kNumStates;
22109 ++ prob = probs + RepLenCoder;
22110 ++ }
22111 ++ {
22112 ++ unsigned limit, offset;
22113 ++ CLzmaProb *probLen = prob + LenChoice;
22114 ++ IF_BIT_0_CHECK(probLen)
22115 ++ {
22116 ++ UPDATE_0_CHECK;
22117 ++ probLen = prob + LenLow + (posState << kLenNumLowBits);
22118 ++ offset = 0;
22119 ++ limit = 1 << kLenNumLowBits;
22120 ++ }
22121 ++ else
22122 ++ {
22123 ++ UPDATE_1_CHECK;
22124 ++ probLen = prob + LenChoice2;
22125 ++ IF_BIT_0_CHECK(probLen)
22126 ++ {
22127 ++ UPDATE_0_CHECK;
22128 ++ probLen = prob + LenMid + (posState << kLenNumMidBits);
22129 ++ offset = kLenNumLowSymbols;
22130 ++ limit = 1 << kLenNumMidBits;
22131 ++ }
22132 ++ else
22133 ++ {
22134 ++ UPDATE_1_CHECK;
22135 ++ probLen = prob + LenHigh;
22136 ++ offset = kLenNumLowSymbols + kLenNumMidSymbols;
22137 ++ limit = 1 << kLenNumHighBits;
22138 ++ }
22139 ++ }
22140 ++ TREE_DECODE_CHECK(probLen, limit, len);
22141 ++ len += offset;
22142 ++ }
22144 ++ if (state < 4)
22145 ++ {
22146 ++ unsigned posSlot;
22147 ++ prob = probs + PosSlot +
22148 ++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
22149 ++ kNumPosSlotBits);
22150 ++ TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
22151 ++ if (posSlot >= kStartPosModelIndex)
22152 ++ {
22153 ++ int numDirectBits = ((posSlot >> 1) - 1);
22155 ++ /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
22157 ++ if (posSlot < kEndPosModelIndex)
22158 ++ {
22159 ++ prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
22160 ++ }
22161 ++ else
22162 ++ {
22163 ++ numDirectBits -= kNumAlignBits;
22164 ++ do
22165 ++ {
22166 ++ NORMALIZE_CHECK
22167 ++ range >>= 1;
22168 ++ code -= range & (((code - range) >> 31) - 1);
22169 ++ /* if (code >= range) code -= range; */
22170 ++ }
22171 ++ while (--numDirectBits != 0);
22172 ++ prob = probs + Align;
22173 ++ numDirectBits = kNumAlignBits;
22174 ++ }
22175 ++ {
22176 ++ unsigned i = 1;
22177 ++ do
22178 ++ {
22179 ++ GET_BIT_CHECK(prob + i, i);
22180 ++ }
22181 ++ while (--numDirectBits != 0);
22182 ++ }
22183 ++ }
22184 ++ }
22185 ++ }
22186 ++ }
22187 ++ NORMALIZE_CHECK;
22188 ++ return res;
22192 ++static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
22194 ++ p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
22195 ++ p->range = 0xFFFFFFFF;
22196 ++ p->needFlush = 0;
22199 ++void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
22201 ++ p->needFlush = 1;
22202 ++ p->remainLen = 0;
22203 ++ p->tempBufSize = 0;
22205 ++ if (initDic)
22206 ++ {
22207 ++ p->processedPos = 0;
22208 ++ p->checkDicSize = 0;
22209 ++ p->needInitState = 1;
22210 ++ }
22211 ++ if (initState)
22212 ++ p->needInitState = 1;
22215 ++void LzmaDec_Init(CLzmaDec *p)
22217 ++ p->dicPos = 0;
22218 ++ LzmaDec_InitDicAndState(p, True, True);
22221 ++static void LzmaDec_InitStateReal(CLzmaDec *p)
22223 ++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
22224 ++ UInt32 i;
22225 ++ CLzmaProb *probs = p->probs;
22226 ++ for (i = 0; i < numProbs; i++)
22227 ++ probs[i] = kBitModelTotal >> 1;
22228 ++ p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
22229 ++ p->state = 0;
22230 ++ p->needInitState = 0;
22233 ++SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
22234 ++ ELzmaFinishMode finishMode, ELzmaStatus *status)
22236 ++ SizeT inSize = *srcLen;
22237 ++ (*srcLen) = 0;
22238 ++ LzmaDec_WriteRem(p, dicLimit);
22240 ++ *status = LZMA_STATUS_NOT_SPECIFIED;
22242 ++ while (p->remainLen != kMatchSpecLenStart)
22243 ++ {
22244 ++ int checkEndMarkNow;
22246 ++ if (p->needFlush != 0)
22247 ++ {
22248 ++ for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
22249 ++ p->tempBuf[p->tempBufSize++] = *src++;
22250 ++ if (p->tempBufSize < RC_INIT_SIZE)
22251 ++ {
22252 ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
22253 ++ return SZ_OK;
22254 ++ }
22255 ++ if (p->tempBuf[0] != 0)
22256 ++ return SZ_ERROR_DATA;
22258 ++ LzmaDec_InitRc(p, p->tempBuf);
22259 ++ p->tempBufSize = 0;
22260 ++ }
22262 ++ checkEndMarkNow = 0;
22263 ++ if (p->dicPos >= dicLimit)
22264 ++ {
22265 ++ if (p->remainLen == 0 && p->code == 0)
22266 ++ {
22267 ++ *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
22268 ++ return SZ_OK;
22269 ++ }
22270 ++ if (finishMode == LZMA_FINISH_ANY)
22271 ++ {
22272 ++ *status = LZMA_STATUS_NOT_FINISHED;
22273 ++ return SZ_OK;
22274 ++ }
22275 ++ if (p->remainLen != 0)
22276 ++ {
22277 ++ *status = LZMA_STATUS_NOT_FINISHED;
22278 ++ return SZ_ERROR_DATA;
22279 ++ }
22280 ++ checkEndMarkNow = 1;
22281 ++ }
22283 ++ if (p->needInitState)
22284 ++ LzmaDec_InitStateReal(p);
22286 ++ if (p->tempBufSize == 0)
22287 ++ {
22288 ++ SizeT processed;
22289 ++ const Byte *bufLimit;
22290 ++ if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
22291 ++ {
22292 ++ int dummyRes = LzmaDec_TryDummy(p, src, inSize);
22293 ++ if (dummyRes == DUMMY_ERROR)
22294 ++ {
22295 ++ memcpy(p->tempBuf, src, inSize);
22296 ++ p->tempBufSize = (unsigned)inSize;
22297 ++ (*srcLen) += inSize;
22298 ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
22299 ++ return SZ_OK;
22300 ++ }
22301 ++ if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
22302 ++ {
22303 ++ *status = LZMA_STATUS_NOT_FINISHED;
22304 ++ return SZ_ERROR_DATA;
22305 ++ }
22306 ++ bufLimit = src;
22307 ++ }
22308 ++ else
22309 ++ bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
22310 ++ p->buf = src;
22311 ++ if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
22312 ++ return SZ_ERROR_DATA;
22313 ++ processed = (SizeT)(p->buf - src);
22314 ++ (*srcLen) += processed;
22315 ++ src += processed;
22316 ++ inSize -= processed;
22317 ++ }
22318 ++ else
22319 ++ {
22320 ++ unsigned rem = p->tempBufSize, lookAhead = 0;
22321 ++ while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
22322 ++ p->tempBuf[rem++] = src[lookAhead++];
22323 ++ p->tempBufSize = rem;
22324 ++ if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
22325 ++ {
22326 ++ int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
22327 ++ if (dummyRes == DUMMY_ERROR)
22328 ++ {
22329 ++ (*srcLen) += lookAhead;
22330 ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
22331 ++ return SZ_OK;
22332 ++ }
22333 ++ if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
22334 ++ {
22335 ++ *status = LZMA_STATUS_NOT_FINISHED;
22336 ++ return SZ_ERROR_DATA;
22337 ++ }
22338 ++ }
22339 ++ p->buf = p->tempBuf;
22340 ++ if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
22341 ++ return SZ_ERROR_DATA;
22342 ++ lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf));
22343 ++ (*srcLen) += lookAhead;
22344 ++ src += lookAhead;
22345 ++ inSize -= lookAhead;
22346 ++ p->tempBufSize = 0;
22347 ++ }
22348 ++ }
22349 ++ if (p->code == 0)
22350 ++ *status = LZMA_STATUS_FINISHED_WITH_MARK;
22351 ++ return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
22354 ++SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
22356 ++ SizeT outSize = *destLen;
22357 ++ SizeT inSize = *srcLen;
22358 ++ *srcLen = *destLen = 0;
22359 ++ for (;;)
22360 ++ {
22361 ++ SizeT inSizeCur = inSize, outSizeCur, dicPos;
22362 ++ ELzmaFinishMode curFinishMode;
22363 ++ SRes res;
22364 ++ if (p->dicPos == p->dicBufSize)
22365 ++ p->dicPos = 0;
22366 ++ dicPos = p->dicPos;
22367 ++ if (outSize > p->dicBufSize - dicPos)
22368 ++ {
22369 ++ outSizeCur = p->dicBufSize;
22370 ++ curFinishMode = LZMA_FINISH_ANY;
22371 ++ }
22372 ++ else
22373 ++ {
22374 ++ outSizeCur = dicPos + outSize;
22375 ++ curFinishMode = finishMode;
22376 ++ }
22378 ++ res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
22379 ++ src += inSizeCur;
22380 ++ inSize -= inSizeCur;
22381 ++ *srcLen += inSizeCur;
22382 ++ outSizeCur = p->dicPos - dicPos;
22383 ++ memcpy(dest, p->dic + dicPos, outSizeCur);
22384 ++ dest += outSizeCur;
22385 ++ outSize -= outSizeCur;
22386 ++ *destLen += outSizeCur;
22387 ++ if (res != 0)
22388 ++ return res;
22389 ++ if (outSizeCur == 0 || outSize == 0)
22390 ++ return SZ_OK;
22391 ++ }
22394 ++void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
22396 ++ alloc->Free(alloc, p->probs);
22397 ++ p->probs = 0;
22400 ++static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
22402 ++ alloc->Free(alloc, p->dic);
22403 ++ p->dic = 0;
22406 ++void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
22408 ++ LzmaDec_FreeProbs(p, alloc);
22409 ++ LzmaDec_FreeDict(p, alloc);
22412 ++SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
22414 ++ UInt32 dicSize;
22415 ++ Byte d;
22417 ++ if (size < LZMA_PROPS_SIZE)
22418 ++ return SZ_ERROR_UNSUPPORTED;
22419 ++ else
22420 ++ dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
22422 ++ if (dicSize < LZMA_DIC_MIN)
22423 ++ dicSize = LZMA_DIC_MIN;
22424 ++ p->dicSize = dicSize;
22426 ++ d = data[0];
22427 ++ if (d >= (9 * 5 * 5))
22428 ++ return SZ_ERROR_UNSUPPORTED;
22430 ++ p->lc = d % 9;
22431 ++ d /= 9;
22432 ++ p->pb = d / 5;
22433 ++ p->lp = d % 5;
22435 ++ return SZ_OK;
22438 ++static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
22440 ++ UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
22441 ++ if (p->probs == 0 || numProbs != p->numProbs)
22442 ++ {
22443 ++ LzmaDec_FreeProbs(p, alloc);
22444 ++ p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));
22445 ++ p->numProbs = numProbs;
22446 ++ if (p->probs == 0)
22447 ++ return SZ_ERROR_MEM;
22448 ++ }
22449 ++ return SZ_OK;
22452 ++SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
22454 ++ CLzmaProps propNew;
22455 ++ RINOK(LzmaProps_Decode(&propNew, props, propsSize));
22456 ++ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
22457 ++ p->prop = propNew;
22458 ++ return SZ_OK;
22461 ++SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
22463 ++ CLzmaProps propNew;
22464 ++ SizeT dicBufSize;
22465 ++ RINOK(LzmaProps_Decode(&propNew, props, propsSize));
22466 ++ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
22467 ++ dicBufSize = propNew.dicSize;
22468 ++ if (p->dic == 0 || dicBufSize != p->dicBufSize)
22469 ++ {
22470 ++ LzmaDec_FreeDict(p, alloc);
22471 ++ p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
22472 ++ if (p->dic == 0)
22473 ++ {
22474 ++ LzmaDec_FreeProbs(p, alloc);
22475 ++ return SZ_ERROR_MEM;
22476 ++ }
22477 ++ }
22478 ++ p->dicBufSize = dicBufSize;
22479 ++ p->prop = propNew;
22480 ++ return SZ_OK;
22483 ++SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
22484 ++ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
22485 ++ ELzmaStatus *status, ISzAlloc *alloc)
22487 ++ CLzmaDec p;
22488 ++ SRes res;
22489 ++ SizeT inSize = *srcLen;
22490 ++ SizeT outSize = *destLen;
22491 ++ *srcLen = *destLen = 0;
22492 ++ if (inSize < RC_INIT_SIZE)
22493 ++ return SZ_ERROR_INPUT_EOF;
22495 ++ LzmaDec_Construct(&p);
22496 ++ res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
22497 ++ if (res != 0)
22498 ++ return res;
22499 ++ p.dic = dest;
22500 ++ p.dicBufSize = outSize;
22502 ++ LzmaDec_Init(&p);
22504 ++ *srcLen = inSize;
22505 ++ res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
22507 ++ if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
22508 ++ res = SZ_ERROR_INPUT_EOF;
22510 ++ (*destLen) = p.dicPos;
22511 ++ LzmaDec_FreeProbs(&p, alloc);
22512 ++ return res;
22514 +--- /dev/null
22515 ++++ b/lib/lzma/LzmaEnc.c
22516 +@@ -0,0 +1,2271 @@
22517 ++/* LzmaEnc.c -- LZMA Encoder
22518 ++2009-11-24 : Igor Pavlov : Public domain */
22520 ++#include <string.h>
22522 ++/* #define SHOW_STAT */
22523 ++/* #define SHOW_STAT2 */
22525 ++#if defined(SHOW_STAT) || defined(SHOW_STAT2)
22526 ++#include <stdio.h>
22527 ++#endif
22529 ++#include "LzmaEnc.h"
22531 ++/* disable MT */
22532 ++#define _7ZIP_ST
22534 ++#include "LzFind.h"
22535 ++#ifndef _7ZIP_ST
22536 ++#include "LzFindMt.h"
22537 ++#endif
22539 ++#ifdef SHOW_STAT
22540 ++static int ttt = 0;
22541 ++#endif
22543 ++#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1)
22545 ++#define kBlockSize (9 << 10)
22546 ++#define kUnpackBlockSize (1 << 18)
22547 ++#define kMatchArraySize (1 << 21)
22548 ++#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX)
22550 ++#define kNumMaxDirectBits (31)
22552 ++#define kNumTopBits 24
22553 ++#define kTopValue ((UInt32)1 << kNumTopBits)
22555 ++#define kNumBitModelTotalBits 11
22556 ++#define kBitModelTotal (1 << kNumBitModelTotalBits)
22557 ++#define kNumMoveBits 5
22558 ++#define kProbInitValue (kBitModelTotal >> 1)
22560 ++#define kNumMoveReducingBits 4
22561 ++#define kNumBitPriceShiftBits 4
22562 ++#define kBitPrice (1 << kNumBitPriceShiftBits)
22564 ++void LzmaEncProps_Init(CLzmaEncProps *p)
22566 ++ p->level = 5;
22567 ++ p->dictSize = p->mc = 0;
22568 ++ p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
22569 ++ p->writeEndMark = 0;
22572 ++void LzmaEncProps_Normalize(CLzmaEncProps *p)
22574 ++ int level = p->level;
22575 ++ if (level < 0) level = 5;
22576 ++ p->level = level;
22577 ++ if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
22578 ++ if (p->lc < 0) p->lc = 3;
22579 ++ if (p->lp < 0) p->lp = 0;
22580 ++ if (p->pb < 0) p->pb = 2;
22581 ++ if (p->algo < 0) p->algo = (level < 5 ? 0 : 1);
22582 ++ if (p->fb < 0) p->fb = (level < 7 ? 32 : 64);
22583 ++ if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);
22584 ++ if (p->numHashBytes < 0) p->numHashBytes = 4;
22585 ++ if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);
22586 ++ if (p->numThreads < 0)
22587 ++ p->numThreads =
22588 ++ #ifndef _7ZIP_ST
22589 ++ ((p->btMode && p->algo) ? 2 : 1);
22590 ++ #else
22591 ++ 1;
22592 ++ #endif
22595 ++UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
22597 ++ CLzmaEncProps props = *props2;
22598 ++ LzmaEncProps_Normalize(&props);
22599 ++ return props.dictSize;
22602 ++/* #define LZMA_LOG_BSR */
22603 ++/* Define it for Intel's CPU */
22606 ++#ifdef LZMA_LOG_BSR
22608 ++#define kDicLogSizeMaxCompress 30
22610 ++#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
22612 ++UInt32 GetPosSlot1(UInt32 pos)
22614 ++ UInt32 res;
22615 ++ BSR2_RET(pos, res);
22616 ++ return res;
22618 ++#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
22619 ++#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); }
22621 ++#else
22623 ++#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
22624 ++#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
22626 ++void LzmaEnc_FastPosInit(Byte *g_FastPos)
22628 ++ int c = 2, slotFast;
22629 ++ g_FastPos[0] = 0;
22630 ++ g_FastPos[1] = 1;
22632 ++ for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++)
22633 ++ {
22634 ++ UInt32 k = (1 << ((slotFast >> 1) - 1));
22635 ++ UInt32 j;
22636 ++ for (j = 0; j < k; j++, c++)
22637 ++ g_FastPos[c] = (Byte)slotFast;
22638 ++ }
22641 ++#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
22642 ++ (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
22643 ++ res = p->g_FastPos[pos >> i] + (i * 2); }
22644 ++/*
22645 ++#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
22646 ++ p->g_FastPos[pos >> 6] + 12 : \
22647 ++ p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; }
22648 ++*/
22650 ++#define GetPosSlot1(pos) p->g_FastPos[pos]
22651 ++#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
22652 ++#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); }
22654 ++#endif
22657 ++#define LZMA_NUM_REPS 4
22659 ++typedef unsigned CState;
22661 ++typedef struct
22663 ++ UInt32 price;
22665 ++ CState state;
22666 ++ int prev1IsChar;
22667 ++ int prev2;
22669 ++ UInt32 posPrev2;
22670 ++ UInt32 backPrev2;
22672 ++ UInt32 posPrev;
22673 ++ UInt32 backPrev;
22674 ++ UInt32 backs[LZMA_NUM_REPS];
22675 ++} COptimal;
22677 ++#define kNumOpts (1 << 12)
22679 ++#define kNumLenToPosStates 4
22680 ++#define kNumPosSlotBits 6
22681 ++#define kDicLogSizeMin 0
22682 ++#define kDicLogSizeMax 32
22683 ++#define kDistTableSizeMax (kDicLogSizeMax * 2)
22686 ++#define kNumAlignBits 4
22687 ++#define kAlignTableSize (1 << kNumAlignBits)
22688 ++#define kAlignMask (kAlignTableSize - 1)
22690 ++#define kStartPosModelIndex 4
22691 ++#define kEndPosModelIndex 14
22692 ++#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex)
22694 ++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
22696 ++#ifdef _LZMA_PROB32
22697 ++#define CLzmaProb UInt32
22698 ++#else
22699 ++#define CLzmaProb UInt16
22700 ++#endif
22702 ++#define LZMA_PB_MAX 4
22703 ++#define LZMA_LC_MAX 8
22704 ++#define LZMA_LP_MAX 4
22706 ++#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX)
22709 ++#define kLenNumLowBits 3
22710 ++#define kLenNumLowSymbols (1 << kLenNumLowBits)
22711 ++#define kLenNumMidBits 3
22712 ++#define kLenNumMidSymbols (1 << kLenNumMidBits)
22713 ++#define kLenNumHighBits 8
22714 ++#define kLenNumHighSymbols (1 << kLenNumHighBits)
22716 ++#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
22718 ++#define LZMA_MATCH_LEN_MIN 2
22719 ++#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1)
22721 ++#define kNumStates 12
22723 ++typedef struct
22725 ++ CLzmaProb choice;
22726 ++ CLzmaProb choice2;
22727 ++ CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits];
22728 ++ CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits];
22729 ++ CLzmaProb high[kLenNumHighSymbols];
22730 ++} CLenEnc;
22732 ++typedef struct
22734 ++ CLenEnc p;
22735 ++ UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];
22736 ++ UInt32 tableSize;
22737 ++ UInt32 counters[LZMA_NUM_PB_STATES_MAX];
22738 ++} CLenPriceEnc;
22740 ++typedef struct
22742 ++ UInt32 range;
22743 ++ Byte cache;
22744 ++ UInt64 low;
22745 ++ UInt64 cacheSize;
22746 ++ Byte *buf;
22747 ++ Byte *bufLim;
22748 ++ Byte *bufBase;
22749 ++ ISeqOutStream *outStream;
22750 ++ UInt64 processed;
22751 ++ SRes res;
22752 ++} CRangeEnc;
22754 ++typedef struct
22756 ++ CLzmaProb *litProbs;
22758 ++ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
22759 ++ CLzmaProb isRep[kNumStates];
22760 ++ CLzmaProb isRepG0[kNumStates];
22761 ++ CLzmaProb isRepG1[kNumStates];
22762 ++ CLzmaProb isRepG2[kNumStates];
22763 ++ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
22765 ++ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
22766 ++ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
22767 ++ CLzmaProb posAlignEncoder[1 << kNumAlignBits];
22769 ++ CLenPriceEnc lenEnc;
22770 ++ CLenPriceEnc repLenEnc;
22772 ++ UInt32 reps[LZMA_NUM_REPS];
22773 ++ UInt32 state;
22774 ++} CSaveState;
22776 ++typedef struct
22778 ++ IMatchFinder matchFinder;
22779 ++ void *matchFinderObj;
22781 ++ #ifndef _7ZIP_ST
22782 ++ Bool mtMode;
22783 ++ CMatchFinderMt matchFinderMt;
22784 ++ #endif
22786 ++ CMatchFinder matchFinderBase;
22788 ++ #ifndef _7ZIP_ST
22789 ++ Byte pad[128];
22790 ++ #endif
22792 ++ UInt32 optimumEndIndex;
22793 ++ UInt32 optimumCurrentIndex;
22795 ++ UInt32 longestMatchLength;
22796 ++ UInt32 numPairs;
22797 ++ UInt32 numAvail;
22798 ++ COptimal opt[kNumOpts];
22800 ++ #ifndef LZMA_LOG_BSR
22801 ++ Byte g_FastPos[1 << kNumLogBits];
22802 ++ #endif
22804 ++ UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
22805 ++ UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1];
22806 ++ UInt32 numFastBytes;
22807 ++ UInt32 additionalOffset;
22808 ++ UInt32 reps[LZMA_NUM_REPS];
22809 ++ UInt32 state;
22811 ++ UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
22812 ++ UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances];
22813 ++ UInt32 alignPrices[kAlignTableSize];
22814 ++ UInt32 alignPriceCount;
22816 ++ UInt32 distTableSize;
22818 ++ unsigned lc, lp, pb;
22819 ++ unsigned lpMask, pbMask;
22821 ++ CLzmaProb *litProbs;
22823 ++ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];
22824 ++ CLzmaProb isRep[kNumStates];
22825 ++ CLzmaProb isRepG0[kNumStates];
22826 ++ CLzmaProb isRepG1[kNumStates];
22827 ++ CLzmaProb isRepG2[kNumStates];
22828 ++ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];
22830 ++ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];
22831 ++ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
22832 ++ CLzmaProb posAlignEncoder[1 << kNumAlignBits];
22834 ++ CLenPriceEnc lenEnc;
22835 ++ CLenPriceEnc repLenEnc;
22837 ++ unsigned lclp;
22839 ++ Bool fastMode;
22841 ++ CRangeEnc rc;
22843 ++ Bool writeEndMark;
22844 ++ UInt64 nowPos64;
22845 ++ UInt32 matchPriceCount;
22846 ++ Bool finished;
22847 ++ Bool multiThread;
22849 ++ SRes result;
22850 ++ UInt32 dictSize;
22851 ++ UInt32 matchFinderCycles;
22853 ++ int needInit;
22855 ++ CSaveState saveState;
22856 ++} CLzmaEnc;
22858 ++void LzmaEnc_SaveState(CLzmaEncHandle pp)
22860 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
22861 ++ CSaveState *dest = &p->saveState;
22862 ++ int i;
22863 ++ dest->lenEnc = p->lenEnc;
22864 ++ dest->repLenEnc = p->repLenEnc;
22865 ++ dest->state = p->state;
22867 ++ for (i = 0; i < kNumStates; i++)
22868 ++ {
22869 ++ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
22870 ++ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
22871 ++ }
22872 ++ for (i = 0; i < kNumLenToPosStates; i++)
22873 ++ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
22874 ++ memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
22875 ++ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
22876 ++ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
22877 ++ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
22878 ++ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
22879 ++ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
22880 ++ memcpy(dest->reps, p->reps, sizeof(p->reps));
22881 ++ memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
22884 ++void LzmaEnc_RestoreState(CLzmaEncHandle pp)
22886 ++ CLzmaEnc *dest = (CLzmaEnc *)pp;
22887 ++ const CSaveState *p = &dest->saveState;
22888 ++ int i;
22889 ++ dest->lenEnc = p->lenEnc;
22890 ++ dest->repLenEnc = p->repLenEnc;
22891 ++ dest->state = p->state;
22893 ++ for (i = 0; i < kNumStates; i++)
22894 ++ {
22895 ++ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
22896 ++ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
22897 ++ }
22898 ++ for (i = 0; i < kNumLenToPosStates; i++)
22899 ++ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
22900 ++ memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
22901 ++ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
22902 ++ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
22903 ++ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
22904 ++ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
22905 ++ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
22906 ++ memcpy(dest->reps, p->reps, sizeof(p->reps));
22907 ++ memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
22910 ++SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
22912 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
22913 ++ CLzmaEncProps props = *props2;
22914 ++ LzmaEncProps_Normalize(&props);
22916 ++ if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
22917 ++ props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30))
22918 ++ return SZ_ERROR_PARAM;
22919 ++ p->dictSize = props.dictSize;
22920 ++ p->matchFinderCycles = props.mc;
22921 ++ {
22922 ++ unsigned fb = props.fb;
22923 ++ if (fb < 5)
22924 ++ fb = 5;
22925 ++ if (fb > LZMA_MATCH_LEN_MAX)
22926 ++ fb = LZMA_MATCH_LEN_MAX;
22927 ++ p->numFastBytes = fb;
22928 ++ }
22929 ++ p->lc = props.lc;
22930 ++ p->lp = props.lp;
22931 ++ p->pb = props.pb;
22932 ++ p->fastMode = (props.algo == 0);
22933 ++ p->matchFinderBase.btMode = props.btMode;
22934 ++ {
22935 ++ UInt32 numHashBytes = 4;
22936 ++ if (props.btMode)
22937 ++ {
22938 ++ if (props.numHashBytes < 2)
22939 ++ numHashBytes = 2;
22940 ++ else if (props.numHashBytes < 4)
22941 ++ numHashBytes = props.numHashBytes;
22942 ++ }
22943 ++ p->matchFinderBase.numHashBytes = numHashBytes;
22944 ++ }
22946 ++ p->matchFinderBase.cutValue = props.mc;
22948 ++ p->writeEndMark = props.writeEndMark;
22950 ++ #ifndef _7ZIP_ST
22951 ++ /*
22952 ++ if (newMultiThread != _multiThread)
22953 ++ {
22954 ++ ReleaseMatchFinder();
22955 ++ _multiThread = newMultiThread;
22956 ++ }
22957 ++ */
22958 ++ p->multiThread = (props.numThreads > 1);
22959 ++ #endif
22961 ++ return SZ_OK;
22964 ++static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
22965 ++static const int kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
22966 ++static const int kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
22967 ++static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
22969 ++#define IsCharState(s) ((s) < 7)
22971 ++#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1)
22973 ++#define kInfinityPrice (1 << 30)
22975 ++static void RangeEnc_Construct(CRangeEnc *p)
22977 ++ p->outStream = 0;
22978 ++ p->bufBase = 0;
22981 ++#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)
22983 ++#define RC_BUF_SIZE (1 << 16)
22984 ++static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
22986 ++ if (p->bufBase == 0)
22987 ++ {
22988 ++ p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
22989 ++ if (p->bufBase == 0)
22990 ++ return 0;
22991 ++ p->bufLim = p->bufBase + RC_BUF_SIZE;
22992 ++ }
22993 ++ return 1;
22996 ++static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc)
22998 ++ alloc->Free(alloc, p->bufBase);
22999 ++ p->bufBase = 0;
23002 ++static void RangeEnc_Init(CRangeEnc *p)
23004 ++ /* Stream.Init(); */
23005 ++ p->low = 0;
23006 ++ p->range = 0xFFFFFFFF;
23007 ++ p->cacheSize = 1;
23008 ++ p->cache = 0;
23010 ++ p->buf = p->bufBase;
23012 ++ p->processed = 0;
23013 ++ p->res = SZ_OK;
23016 ++static void RangeEnc_FlushStream(CRangeEnc *p)
23018 ++ size_t num;
23019 ++ if (p->res != SZ_OK)
23020 ++ return;
23021 ++ num = p->buf - p->bufBase;
23022 ++ if (num != p->outStream->Write(p->outStream, p->bufBase, num))
23023 ++ p->res = SZ_ERROR_WRITE;
23024 ++ p->processed += num;
23025 ++ p->buf = p->bufBase;
23028 ++static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)
23030 ++ if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0)
23031 ++ {
23032 ++ Byte temp = p->cache;
23033 ++ do
23034 ++ {
23035 ++ Byte *buf = p->buf;
23036 ++ *buf++ = (Byte)(temp + (Byte)(p->low >> 32));
23037 ++ p->buf = buf;
23038 ++ if (buf == p->bufLim)
23039 ++ RangeEnc_FlushStream(p);
23040 ++ temp = 0xFF;
23041 ++ }
23042 ++ while (--p->cacheSize != 0);
23043 ++ p->cache = (Byte)((UInt32)p->low >> 24);
23044 ++ }
23045 ++ p->cacheSize++;
23046 ++ p->low = (UInt32)p->low << 8;
23049 ++static void RangeEnc_FlushData(CRangeEnc *p)
23051 ++ int i;
23052 ++ for (i = 0; i < 5; i++)
23053 ++ RangeEnc_ShiftLow(p);
23056 ++static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
23058 ++ do
23059 ++ {
23060 ++ p->range >>= 1;
23061 ++ p->low += p->range & (0 - ((value >> --numBits) & 1));
23062 ++ if (p->range < kTopValue)
23063 ++ {
23064 ++ p->range <<= 8;
23065 ++ RangeEnc_ShiftLow(p);
23066 ++ }
23067 ++ }
23068 ++ while (numBits != 0);
23071 ++static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)
23073 ++ UInt32 ttt = *prob;
23074 ++ UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt;
23075 ++ if (symbol == 0)
23076 ++ {
23077 ++ p->range = newBound;
23078 ++ ttt += (kBitModelTotal - ttt) >> kNumMoveBits;
23079 ++ }
23080 ++ else
23081 ++ {
23082 ++ p->low += newBound;
23083 ++ p->range -= newBound;
23084 ++ ttt -= ttt >> kNumMoveBits;
23085 ++ }
23086 ++ *prob = (CLzmaProb)ttt;
23087 ++ if (p->range < kTopValue)
23088 ++ {
23089 ++ p->range <<= 8;
23090 ++ RangeEnc_ShiftLow(p);
23091 ++ }
23094 ++static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)
23096 ++ symbol |= 0x100;
23097 ++ do
23098 ++ {
23099 ++ RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);
23100 ++ symbol <<= 1;
23101 ++ }
23102 ++ while (symbol < 0x10000);
23105 ++static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)
23107 ++ UInt32 offs = 0x100;
23108 ++ symbol |= 0x100;
23109 ++ do
23110 ++ {
23111 ++ matchByte <<= 1;
23112 ++ RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);
23113 ++ symbol <<= 1;
23114 ++ offs &= ~(matchByte ^ symbol);
23115 ++ }
23116 ++ while (symbol < 0x10000);
23119 ++void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
23121 ++ UInt32 i;
23122 ++ for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
23123 ++ {
23124 ++ const int kCyclesBits = kNumBitPriceShiftBits;
23125 ++ UInt32 w = i;
23126 ++ UInt32 bitCount = 0;
23127 ++ int j;
23128 ++ for (j = 0; j < kCyclesBits; j++)
23129 ++ {
23130 ++ w = w * w;
23131 ++ bitCount <<= 1;
23132 ++ while (w >= ((UInt32)1 << 16))
23133 ++ {
23134 ++ w >>= 1;
23135 ++ bitCount++;
23136 ++ }
23137 ++ }
23138 ++ ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount);
23139 ++ }
23143 ++#define GET_PRICE(prob, symbol) \
23144 ++ p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
23146 ++#define GET_PRICEa(prob, symbol) \
23147 ++ ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
23149 ++#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits]
23150 ++#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
23152 ++#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits]
23153 ++#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
23155 ++static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices)
23157 ++ UInt32 price = 0;
23158 ++ symbol |= 0x100;
23159 ++ do
23160 ++ {
23161 ++ price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1);
23162 ++ symbol <<= 1;
23163 ++ }
23164 ++ while (symbol < 0x10000);
23165 ++ return price;
23168 ++static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices)
23170 ++ UInt32 price = 0;
23171 ++ UInt32 offs = 0x100;
23172 ++ symbol |= 0x100;
23173 ++ do
23174 ++ {
23175 ++ matchByte <<= 1;
23176 ++ price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);
23177 ++ symbol <<= 1;
23178 ++ offs &= ~(matchByte ^ symbol);
23179 ++ }
23180 ++ while (symbol < 0x10000);
23181 ++ return price;
23185 ++static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
23187 ++ UInt32 m = 1;
23188 ++ int i;
23189 ++ for (i = numBitLevels; i != 0;)
23190 ++ {
23191 ++ UInt32 bit;
23192 ++ i--;
23193 ++ bit = (symbol >> i) & 1;
23194 ++ RangeEnc_EncodeBit(rc, probs + m, bit);
23195 ++ m = (m << 1) | bit;
23196 ++ }
23199 ++static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
23201 ++ UInt32 m = 1;
23202 ++ int i;
23203 ++ for (i = 0; i < numBitLevels; i++)
23204 ++ {
23205 ++ UInt32 bit = symbol & 1;
23206 ++ RangeEnc_EncodeBit(rc, probs + m, bit);
23207 ++ m = (m << 1) | bit;
23208 ++ symbol >>= 1;
23209 ++ }
23212 ++static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
23214 ++ UInt32 price = 0;
23215 ++ symbol |= (1 << numBitLevels);
23216 ++ while (symbol != 1)
23217 ++ {
23218 ++ price += GET_PRICEa(probs[symbol >> 1], symbol & 1);
23219 ++ symbol >>= 1;
23220 ++ }
23221 ++ return price;
23224 ++static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
23226 ++ UInt32 price = 0;
23227 ++ UInt32 m = 1;
23228 ++ int i;
23229 ++ for (i = numBitLevels; i != 0; i--)
23230 ++ {
23231 ++ UInt32 bit = symbol & 1;
23232 ++ symbol >>= 1;
23233 ++ price += GET_PRICEa(probs[m], bit);
23234 ++ m = (m << 1) | bit;
23235 ++ }
23236 ++ return price;
23240 ++static void LenEnc_Init(CLenEnc *p)
23242 ++ unsigned i;
23243 ++ p->choice = p->choice2 = kProbInitValue;
23244 ++ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++)
23245 ++ p->low[i] = kProbInitValue;
23246 ++ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++)
23247 ++ p->mid[i] = kProbInitValue;
23248 ++ for (i = 0; i < kLenNumHighSymbols; i++)
23249 ++ p->high[i] = kProbInitValue;
23252 ++static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState)
23254 ++ if (symbol < kLenNumLowSymbols)
23255 ++ {
23256 ++ RangeEnc_EncodeBit(rc, &p->choice, 0);
23257 ++ RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol);
23258 ++ }
23259 ++ else
23260 ++ {
23261 ++ RangeEnc_EncodeBit(rc, &p->choice, 1);
23262 ++ if (symbol < kLenNumLowSymbols + kLenNumMidSymbols)
23263 ++ {
23264 ++ RangeEnc_EncodeBit(rc, &p->choice2, 0);
23265 ++ RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols);
23266 ++ }
23267 ++ else
23268 ++ {
23269 ++ RangeEnc_EncodeBit(rc, &p->choice2, 1);
23270 ++ RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols);
23271 ++ }
23272 ++ }
23275 ++static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices)
23277 ++ UInt32 a0 = GET_PRICE_0a(p->choice);
23278 ++ UInt32 a1 = GET_PRICE_1a(p->choice);
23279 ++ UInt32 b0 = a1 + GET_PRICE_0a(p->choice2);
23280 ++ UInt32 b1 = a1 + GET_PRICE_1a(p->choice2);
23281 ++ UInt32 i = 0;
23282 ++ for (i = 0; i < kLenNumLowSymbols; i++)
23283 ++ {
23284 ++ if (i >= numSymbols)
23285 ++ return;
23286 ++ prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices);
23287 ++ }
23288 ++ for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++)
23289 ++ {
23290 ++ if (i >= numSymbols)
23291 ++ return;
23292 ++ prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices);
23293 ++ }
23294 ++ for (; i < numSymbols; i++)
23295 ++ prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices);
23298 ++static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices)
23300 ++ LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices);
23301 ++ p->counters[posState] = p->tableSize;
23304 ++static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices)
23306 ++ UInt32 posState;
23307 ++ for (posState = 0; posState < numPosStates; posState++)
23308 ++ LenPriceEnc_UpdateTable(p, posState, ProbPrices);
23311 ++static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices)
23313 ++ LenEnc_Encode(&p->p, rc, symbol, posState);
23314 ++ if (updatePrice)
23315 ++ if (--p->counters[posState] == 0)
23316 ++ LenPriceEnc_UpdateTable(p, posState, ProbPrices);
23322 ++static void MovePos(CLzmaEnc *p, UInt32 num)
23324 ++ #ifdef SHOW_STAT
23325 ++ ttt += num;
23326 ++ printf("\n MovePos %d", num);
23327 ++ #endif
23328 ++ if (num != 0)
23329 ++ {
23330 ++ p->additionalOffset += num;
23331 ++ p->matchFinder.Skip(p->matchFinderObj, num);
23332 ++ }
23335 ++static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
23337 ++ UInt32 lenRes = 0, numPairs;
23338 ++ p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
23339 ++ numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
23340 ++ #ifdef SHOW_STAT
23341 ++ printf("\n i = %d numPairs = %d ", ttt, numPairs / 2);
23342 ++ ttt++;
23343 ++ {
23344 ++ UInt32 i;
23345 ++ for (i = 0; i < numPairs; i += 2)
23346 ++ printf("%2d %6d | ", p->matches[i], p->matches[i + 1]);
23347 ++ }
23348 ++ #endif
23349 ++ if (numPairs > 0)
23350 ++ {
23351 ++ lenRes = p->matches[numPairs - 2];
23352 ++ if (lenRes == p->numFastBytes)
23353 ++ {
23354 ++ const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
23355 ++ UInt32 distance = p->matches[numPairs - 1] + 1;
23356 ++ UInt32 numAvail = p->numAvail;
23357 ++ if (numAvail > LZMA_MATCH_LEN_MAX)
23358 ++ numAvail = LZMA_MATCH_LEN_MAX;
23359 ++ {
23360 ++ const Byte *pby2 = pby - distance;
23361 ++ for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++);
23362 ++ }
23363 ++ }
23364 ++ }
23365 ++ p->additionalOffset++;
23366 ++ *numDistancePairsRes = numPairs;
23367 ++ return lenRes;
23371 ++#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False;
23372 ++#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False;
23373 ++#define IsShortRep(p) ((p)->backPrev == 0)
23375 ++static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState)
23377 ++ return
23378 ++ GET_PRICE_0(p->isRepG0[state]) +
23379 ++ GET_PRICE_0(p->isRep0Long[state][posState]);
23382 ++static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState)
23384 ++ UInt32 price;
23385 ++ if (repIndex == 0)
23386 ++ {
23387 ++ price = GET_PRICE_0(p->isRepG0[state]);
23388 ++ price += GET_PRICE_1(p->isRep0Long[state][posState]);
23389 ++ }
23390 ++ else
23391 ++ {
23392 ++ price = GET_PRICE_1(p->isRepG0[state]);
23393 ++ if (repIndex == 1)
23394 ++ price += GET_PRICE_0(p->isRepG1[state]);
23395 ++ else
23396 ++ {
23397 ++ price += GET_PRICE_1(p->isRepG1[state]);
23398 ++ price += GET_PRICE(p->isRepG2[state], repIndex - 2);
23399 ++ }
23400 ++ }
23401 ++ return price;
23404 ++static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState)
23406 ++ return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] +
23407 ++ GetPureRepPrice(p, repIndex, state, posState);
23410 ++static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
23412 ++ UInt32 posMem = p->opt[cur].posPrev;
23413 ++ UInt32 backMem = p->opt[cur].backPrev;
23414 ++ p->optimumEndIndex = cur;
23415 ++ do
23416 ++ {
23417 ++ if (p->opt[cur].prev1IsChar)
23418 ++ {
23419 ++ MakeAsChar(&p->opt[posMem])
23420 ++ p->opt[posMem].posPrev = posMem - 1;
23421 ++ if (p->opt[cur].prev2)
23422 ++ {
23423 ++ p->opt[posMem - 1].prev1IsChar = False;
23424 ++ p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2;
23425 ++ p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2;
23426 ++ }
23427 ++ }
23428 ++ {
23429 ++ UInt32 posPrev = posMem;
23430 ++ UInt32 backCur = backMem;
23432 ++ backMem = p->opt[posPrev].backPrev;
23433 ++ posMem = p->opt[posPrev].posPrev;
23435 ++ p->opt[posPrev].backPrev = backCur;
23436 ++ p->opt[posPrev].posPrev = cur;
23437 ++ cur = posPrev;
23438 ++ }
23439 ++ }
23440 ++ while (cur != 0);
23441 ++ *backRes = p->opt[0].backPrev;
23442 ++ p->optimumCurrentIndex = p->opt[0].posPrev;
23443 ++ return p->optimumCurrentIndex;
23446 ++#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300)
23448 ++static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
23450 ++ UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
23451 ++ UInt32 matchPrice, repMatchPrice, normalMatchPrice;
23452 ++ UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
23453 ++ UInt32 *matches;
23454 ++ const Byte *data;
23455 ++ Byte curByte, matchByte;
23456 ++ if (p->optimumEndIndex != p->optimumCurrentIndex)
23457 ++ {
23458 ++ const COptimal *opt = &p->opt[p->optimumCurrentIndex];
23459 ++ UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex;
23460 ++ *backRes = opt->backPrev;
23461 ++ p->optimumCurrentIndex = opt->posPrev;
23462 ++ return lenRes;
23463 ++ }
23464 ++ p->optimumCurrentIndex = p->optimumEndIndex = 0;
23466 ++ if (p->additionalOffset == 0)
23467 ++ mainLen = ReadMatchDistances(p, &numPairs);
23468 ++ else
23469 ++ {
23470 ++ mainLen = p->longestMatchLength;
23471 ++ numPairs = p->numPairs;
23472 ++ }
23474 ++ numAvail = p->numAvail;
23475 ++ if (numAvail < 2)
23476 ++ {
23477 ++ *backRes = (UInt32)(-1);
23478 ++ return 1;
23479 ++ }
23480 ++ if (numAvail > LZMA_MATCH_LEN_MAX)
23481 ++ numAvail = LZMA_MATCH_LEN_MAX;
23483 ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
23484 ++ repMaxIndex = 0;
23485 ++ for (i = 0; i < LZMA_NUM_REPS; i++)
23486 ++ {
23487 ++ UInt32 lenTest;
23488 ++ const Byte *data2;
23489 ++ reps[i] = p->reps[i];
23490 ++ data2 = data - (reps[i] + 1);
23491 ++ if (data[0] != data2[0] || data[1] != data2[1])
23492 ++ {
23493 ++ repLens[i] = 0;
23494 ++ continue;
23495 ++ }
23496 ++ for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);
23497 ++ repLens[i] = lenTest;
23498 ++ if (lenTest > repLens[repMaxIndex])
23499 ++ repMaxIndex = i;
23500 ++ }
23501 ++ if (repLens[repMaxIndex] >= p->numFastBytes)
23502 ++ {
23503 ++ UInt32 lenRes;
23504 ++ *backRes = repMaxIndex;
23505 ++ lenRes = repLens[repMaxIndex];
23506 ++ MovePos(p, lenRes - 1);
23507 ++ return lenRes;
23508 ++ }
23510 ++ matches = p->matches;
23511 ++ if (mainLen >= p->numFastBytes)
23512 ++ {
23513 ++ *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
23514 ++ MovePos(p, mainLen - 1);
23515 ++ return mainLen;
23516 ++ }
23517 ++ curByte = *data;
23518 ++ matchByte = *(data - (reps[0] + 1));
23520 ++ if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2)
23521 ++ {
23522 ++ *backRes = (UInt32)-1;
23523 ++ return 1;
23524 ++ }
23526 ++ p->opt[0].state = (CState)p->state;
23528 ++ posState = (position & p->pbMask);
23530 ++ {
23531 ++ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
23532 ++ p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) +
23533 ++ (!IsCharState(p->state) ?
23534 ++ LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
23535 ++ LitEnc_GetPrice(probs, curByte, p->ProbPrices));
23536 ++ }
23538 ++ MakeAsChar(&p->opt[1]);
23540 ++ matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]);
23541 ++ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]);
23543 ++ if (matchByte == curByte)
23544 ++ {
23545 ++ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState);
23546 ++ if (shortRepPrice < p->opt[1].price)
23547 ++ {
23548 ++ p->opt[1].price = shortRepPrice;
23549 ++ MakeAsShortRep(&p->opt[1]);
23550 ++ }
23551 ++ }
23552 ++ lenEnd = ((mainLen >= repLens[repMaxIndex]) ? mainLen : repLens[repMaxIndex]);
23554 ++ if (lenEnd < 2)
23555 ++ {
23556 ++ *backRes = p->opt[1].backPrev;
23557 ++ return 1;
23558 ++ }
23560 ++ p->opt[1].posPrev = 0;
23561 ++ for (i = 0; i < LZMA_NUM_REPS; i++)
23562 ++ p->opt[0].backs[i] = reps[i];
23564 ++ len = lenEnd;
23565 ++ do
23566 ++ p->opt[len--].price = kInfinityPrice;
23567 ++ while (len >= 2);
23569 ++ for (i = 0; i < LZMA_NUM_REPS; i++)
23570 ++ {
23571 ++ UInt32 repLen = repLens[i];
23572 ++ UInt32 price;
23573 ++ if (repLen < 2)
23574 ++ continue;
23575 ++ price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState);
23576 ++ do
23577 ++ {
23578 ++ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];
23579 ++ COptimal *opt = &p->opt[repLen];
23580 ++ if (curAndLenPrice < opt->price)
23581 ++ {
23582 ++ opt->price = curAndLenPrice;
23583 ++ opt->posPrev = 0;
23584 ++ opt->backPrev = i;
23585 ++ opt->prev1IsChar = False;
23586 ++ }
23587 ++ }
23588 ++ while (--repLen >= 2);
23589 ++ }
23591 ++ normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]);
23593 ++ len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
23594 ++ if (len <= mainLen)
23595 ++ {
23596 ++ UInt32 offs = 0;
23597 ++ while (len > matches[offs])
23598 ++ offs += 2;
23599 ++ for (; ; len++)
23600 ++ {
23601 ++ COptimal *opt;
23602 ++ UInt32 distance = matches[offs + 1];
23604 ++ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];
23605 ++ UInt32 lenToPosState = GetLenToPosState(len);
23606 ++ if (distance < kNumFullDistances)
23607 ++ curAndLenPrice += p->distancesPrices[lenToPosState][distance];
23608 ++ else
23609 ++ {
23610 ++ UInt32 slot;
23611 ++ GetPosSlot2(distance, slot);
23612 ++ curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot];
23613 ++ }
23614 ++ opt = &p->opt[len];
23615 ++ if (curAndLenPrice < opt->price)
23616 ++ {
23617 ++ opt->price = curAndLenPrice;
23618 ++ opt->posPrev = 0;
23619 ++ opt->backPrev = distance + LZMA_NUM_REPS;
23620 ++ opt->prev1IsChar = False;
23621 ++ }
23622 ++ if (len == matches[offs])
23623 ++ {
23624 ++ offs += 2;
23625 ++ if (offs == numPairs)
23626 ++ break;
23627 ++ }
23628 ++ }
23629 ++ }
23631 ++ cur = 0;
23633 ++ #ifdef SHOW_STAT2
23634 ++ if (position >= 0)
23635 ++ {
23636 ++ unsigned i;
23637 ++ printf("\n pos = %4X", position);
23638 ++ for (i = cur; i <= lenEnd; i++)
23639 ++ printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price);
23640 ++ }
23641 ++ #endif
23643 ++ for (;;)
23644 ++ {
23645 ++ UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
23646 ++ UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
23647 ++ Bool nextIsChar;
23648 ++ Byte curByte, matchByte;
23649 ++ const Byte *data;
23650 ++ COptimal *curOpt;
23651 ++ COptimal *nextOpt;
23653 ++ cur++;
23654 ++ if (cur == lenEnd)
23655 ++ return Backward(p, backRes, cur);
23657 ++ newLen = ReadMatchDistances(p, &numPairs);
23658 ++ if (newLen >= p->numFastBytes)
23659 ++ {
23660 ++ p->numPairs = numPairs;
23661 ++ p->longestMatchLength = newLen;
23662 ++ return Backward(p, backRes, cur);
23663 ++ }
23664 ++ position++;
23665 ++ curOpt = &p->opt[cur];
23666 ++ posPrev = curOpt->posPrev;
23667 ++ if (curOpt->prev1IsChar)
23668 ++ {
23669 ++ posPrev--;
23670 ++ if (curOpt->prev2)
23671 ++ {
23672 ++ state = p->opt[curOpt->posPrev2].state;
23673 ++ if (curOpt->backPrev2 < LZMA_NUM_REPS)
23674 ++ state = kRepNextStates[state];
23675 ++ else
23676 ++ state = kMatchNextStates[state];
23677 ++ }
23678 ++ else
23679 ++ state = p->opt[posPrev].state;
23680 ++ state = kLiteralNextStates[state];
23681 ++ }
23682 ++ else
23683 ++ state = p->opt[posPrev].state;
23684 ++ if (posPrev == cur - 1)
23685 ++ {
23686 ++ if (IsShortRep(curOpt))
23687 ++ state = kShortRepNextStates[state];
23688 ++ else
23689 ++ state = kLiteralNextStates[state];
23690 ++ }
23691 ++ else
23692 ++ {
23693 ++ UInt32 pos;
23694 ++ const COptimal *prevOpt;
23695 ++ if (curOpt->prev1IsChar && curOpt->prev2)
23696 ++ {
23697 ++ posPrev = curOpt->posPrev2;
23698 ++ pos = curOpt->backPrev2;
23699 ++ state = kRepNextStates[state];
23700 ++ }
23701 ++ else
23702 ++ {
23703 ++ pos = curOpt->backPrev;
23704 ++ if (pos < LZMA_NUM_REPS)
23705 ++ state = kRepNextStates[state];
23706 ++ else
23707 ++ state = kMatchNextStates[state];
23708 ++ }
23709 ++ prevOpt = &p->opt[posPrev];
23710 ++ if (pos < LZMA_NUM_REPS)
23711 ++ {
23712 ++ UInt32 i;
23713 ++ reps[0] = prevOpt->backs[pos];
23714 ++ for (i = 1; i <= pos; i++)
23715 ++ reps[i] = prevOpt->backs[i - 1];
23716 ++ for (; i < LZMA_NUM_REPS; i++)
23717 ++ reps[i] = prevOpt->backs[i];
23718 ++ }
23719 ++ else
23720 ++ {
23721 ++ UInt32 i;
23722 ++ reps[0] = (pos - LZMA_NUM_REPS);
23723 ++ for (i = 1; i < LZMA_NUM_REPS; i++)
23724 ++ reps[i] = prevOpt->backs[i - 1];
23725 ++ }
23726 ++ }
23727 ++ curOpt->state = (CState)state;
23729 ++ curOpt->backs[0] = reps[0];
23730 ++ curOpt->backs[1] = reps[1];
23731 ++ curOpt->backs[2] = reps[2];
23732 ++ curOpt->backs[3] = reps[3];
23734 ++ curPrice = curOpt->price;
23735 ++ nextIsChar = False;
23736 ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
23737 ++ curByte = *data;
23738 ++ matchByte = *(data - (reps[0] + 1));
23740 ++ posState = (position & p->pbMask);
23742 ++ curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]);
23743 ++ {
23744 ++ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
23745 ++ curAnd1Price +=
23746 ++ (!IsCharState(state) ?
23747 ++ LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
23748 ++ LitEnc_GetPrice(probs, curByte, p->ProbPrices));
23749 ++ }
23751 ++ nextOpt = &p->opt[cur + 1];
23753 ++ if (curAnd1Price < nextOpt->price)
23754 ++ {
23755 ++ nextOpt->price = curAnd1Price;
23756 ++ nextOpt->posPrev = cur;
23757 ++ MakeAsChar(nextOpt);
23758 ++ nextIsChar = True;
23759 ++ }
23761 ++ matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);
23762 ++ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);
23764 ++ if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
23765 ++ {
23766 ++ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
23767 ++ if (shortRepPrice <= nextOpt->price)
23768 ++ {
23769 ++ nextOpt->price = shortRepPrice;
23770 ++ nextOpt->posPrev = cur;
23771 ++ MakeAsShortRep(nextOpt);
23772 ++ nextIsChar = True;
23773 ++ }
23774 ++ }
23775 ++ numAvailFull = p->numAvail;
23776 ++ {
23777 ++ UInt32 temp = kNumOpts - 1 - cur;
23778 ++ if (temp < numAvailFull)
23779 ++ numAvailFull = temp;
23780 ++ }
23782 ++ if (numAvailFull < 2)
23783 ++ continue;
23784 ++ numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes);
23786 ++ if (!nextIsChar && matchByte != curByte) /* speed optimization */
23787 ++ {
23788 ++ /* try Literal + rep0 */
23789 ++ UInt32 temp;
23790 ++ UInt32 lenTest2;
23791 ++ const Byte *data2 = data - (reps[0] + 1);
23792 ++ UInt32 limit = p->numFastBytes + 1;
23793 ++ if (limit > numAvailFull)
23794 ++ limit = numAvailFull;
23796 ++ for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++);
23797 ++ lenTest2 = temp - 1;
23798 ++ if (lenTest2 >= 2)
23799 ++ {
23800 ++ UInt32 state2 = kLiteralNextStates[state];
23801 ++ UInt32 posStateNext = (position + 1) & p->pbMask;
23802 ++ UInt32 nextRepMatchPrice = curAnd1Price +
23803 ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
23804 ++ GET_PRICE_1(p->isRep[state2]);
23805 ++ /* for (; lenTest2 >= 2; lenTest2--) */
23806 ++ {
23807 ++ UInt32 curAndLenPrice;
23808 ++ COptimal *opt;
23809 ++ UInt32 offset = cur + 1 + lenTest2;
23810 ++ while (lenEnd < offset)
23811 ++ p->opt[++lenEnd].price = kInfinityPrice;
23812 ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
23813 ++ opt = &p->opt[offset];
23814 ++ if (curAndLenPrice < opt->price)
23815 ++ {
23816 ++ opt->price = curAndLenPrice;
23817 ++ opt->posPrev = cur + 1;
23818 ++ opt->backPrev = 0;
23819 ++ opt->prev1IsChar = True;
23820 ++ opt->prev2 = False;
23821 ++ }
23822 ++ }
23823 ++ }
23824 ++ }
23826 ++ startLen = 2; /* speed optimization */
23827 ++ {
23828 ++ UInt32 repIndex;
23829 ++ for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++)
23830 ++ {
23831 ++ UInt32 lenTest;
23832 ++ UInt32 lenTestTemp;
23833 ++ UInt32 price;
23834 ++ const Byte *data2 = data - (reps[repIndex] + 1);
23835 ++ if (data[0] != data2[0] || data[1] != data2[1])
23836 ++ continue;
23837 ++ for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);
23838 ++ while (lenEnd < cur + lenTest)
23839 ++ p->opt[++lenEnd].price = kInfinityPrice;
23840 ++ lenTestTemp = lenTest;
23841 ++ price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState);
23842 ++ do
23843 ++ {
23844 ++ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];
23845 ++ COptimal *opt = &p->opt[cur + lenTest];
23846 ++ if (curAndLenPrice < opt->price)
23847 ++ {
23848 ++ opt->price = curAndLenPrice;
23849 ++ opt->posPrev = cur;
23850 ++ opt->backPrev = repIndex;
23851 ++ opt->prev1IsChar = False;
23852 ++ }
23853 ++ }
23854 ++ while (--lenTest >= 2);
23855 ++ lenTest = lenTestTemp;
23857 ++ if (repIndex == 0)
23858 ++ startLen = lenTest + 1;
23860 ++ /* if (_maxMode) */
23861 ++ {
23862 ++ UInt32 lenTest2 = lenTest + 1;
23863 ++ UInt32 limit = lenTest2 + p->numFastBytes;
23864 ++ UInt32 nextRepMatchPrice;
23865 ++ if (limit > numAvailFull)
23866 ++ limit = numAvailFull;
23867 ++ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
23868 ++ lenTest2 -= lenTest + 1;
23869 ++ if (lenTest2 >= 2)
23870 ++ {
23871 ++ UInt32 state2 = kRepNextStates[state];
23872 ++ UInt32 posStateNext = (position + lenTest) & p->pbMask;
23873 ++ UInt32 curAndLenCharPrice =
23874 ++ price + p->repLenEnc.prices[posState][lenTest - 2] +
23875 ++ GET_PRICE_0(p->isMatch[state2][posStateNext]) +
23876 ++ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
23877 ++ data[lenTest], data2[lenTest], p->ProbPrices);
23878 ++ state2 = kLiteralNextStates[state2];
23879 ++ posStateNext = (position + lenTest + 1) & p->pbMask;
23880 ++ nextRepMatchPrice = curAndLenCharPrice +
23881 ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
23882 ++ GET_PRICE_1(p->isRep[state2]);
23884 ++ /* for (; lenTest2 >= 2; lenTest2--) */
23885 ++ {
23886 ++ UInt32 curAndLenPrice;
23887 ++ COptimal *opt;
23888 ++ UInt32 offset = cur + lenTest + 1 + lenTest2;
23889 ++ while (lenEnd < offset)
23890 ++ p->opt[++lenEnd].price = kInfinityPrice;
23891 ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
23892 ++ opt = &p->opt[offset];
23893 ++ if (curAndLenPrice < opt->price)
23894 ++ {
23895 ++ opt->price = curAndLenPrice;
23896 ++ opt->posPrev = cur + lenTest + 1;
23897 ++ opt->backPrev = 0;
23898 ++ opt->prev1IsChar = True;
23899 ++ opt->prev2 = True;
23900 ++ opt->posPrev2 = cur;
23901 ++ opt->backPrev2 = repIndex;
23902 ++ }
23903 ++ }
23904 ++ }
23905 ++ }
23906 ++ }
23907 ++ }
23908 ++ /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */
23909 ++ if (newLen > numAvail)
23910 ++ {
23911 ++ newLen = numAvail;
23912 ++ for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2);
23913 ++ matches[numPairs] = newLen;
23914 ++ numPairs += 2;
23915 ++ }
23916 ++ if (newLen >= startLen)
23917 ++ {
23918 ++ UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);
23919 ++ UInt32 offs, curBack, posSlot;
23920 ++ UInt32 lenTest;
23921 ++ while (lenEnd < cur + newLen)
23922 ++ p->opt[++lenEnd].price = kInfinityPrice;
23924 ++ offs = 0;
23925 ++ while (startLen > matches[offs])
23926 ++ offs += 2;
23927 ++ curBack = matches[offs + 1];
23928 ++ GetPosSlot2(curBack, posSlot);
23929 ++ for (lenTest = /*2*/ startLen; ; lenTest++)
23930 ++ {
23931 ++ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
23932 ++ UInt32 lenToPosState = GetLenToPosState(lenTest);
23933 ++ COptimal *opt;
23934 ++ if (curBack < kNumFullDistances)
23935 ++ curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
23936 ++ else
23937 ++ curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask];
23939 ++ opt = &p->opt[cur + lenTest];
23940 ++ if (curAndLenPrice < opt->price)
23941 ++ {
23942 ++ opt->price = curAndLenPrice;
23943 ++ opt->posPrev = cur;
23944 ++ opt->backPrev = curBack + LZMA_NUM_REPS;
23945 ++ opt->prev1IsChar = False;
23946 ++ }
23948 ++ if (/*_maxMode && */lenTest == matches[offs])
23949 ++ {
23950 ++ /* Try Match + Literal + Rep0 */
23951 ++ const Byte *data2 = data - (curBack + 1);
23952 ++ UInt32 lenTest2 = lenTest + 1;
23953 ++ UInt32 limit = lenTest2 + p->numFastBytes;
23954 ++ UInt32 nextRepMatchPrice;
23955 ++ if (limit > numAvailFull)
23956 ++ limit = numAvailFull;
23957 ++ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
23958 ++ lenTest2 -= lenTest + 1;
23959 ++ if (lenTest2 >= 2)
23960 ++ {
23961 ++ UInt32 state2 = kMatchNextStates[state];
23962 ++ UInt32 posStateNext = (position + lenTest) & p->pbMask;
23963 ++ UInt32 curAndLenCharPrice = curAndLenPrice +
23964 ++ GET_PRICE_0(p->isMatch[state2][posStateNext]) +
23965 ++ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
23966 ++ data[lenTest], data2[lenTest], p->ProbPrices);
23967 ++ state2 = kLiteralNextStates[state2];
23968 ++ posStateNext = (posStateNext + 1) & p->pbMask;
23969 ++ nextRepMatchPrice = curAndLenCharPrice +
23970 ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) +
23971 ++ GET_PRICE_1(p->isRep[state2]);
23973 ++ /* for (; lenTest2 >= 2; lenTest2--) */
23974 ++ {
23975 ++ UInt32 offset = cur + lenTest + 1 + lenTest2;
23976 ++ UInt32 curAndLenPrice;
23977 ++ COptimal *opt;
23978 ++ while (lenEnd < offset)
23979 ++ p->opt[++lenEnd].price = kInfinityPrice;
23980 ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
23981 ++ opt = &p->opt[offset];
23982 ++ if (curAndLenPrice < opt->price)
23983 ++ {
23984 ++ opt->price = curAndLenPrice;
23985 ++ opt->posPrev = cur + lenTest + 1;
23986 ++ opt->backPrev = 0;
23987 ++ opt->prev1IsChar = True;
23988 ++ opt->prev2 = True;
23989 ++ opt->posPrev2 = cur;
23990 ++ opt->backPrev2 = curBack + LZMA_NUM_REPS;
23991 ++ }
23992 ++ }
23993 ++ }
23994 ++ offs += 2;
23995 ++ if (offs == numPairs)
23996 ++ break;
23997 ++ curBack = matches[offs + 1];
23998 ++ if (curBack >= kNumFullDistances)
23999 ++ GetPosSlot2(curBack, posSlot);
24000 ++ }
24001 ++ }
24002 ++ }
24003 ++ }
24006 ++#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist))
24008 ++static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
24010 ++ UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i;
24011 ++ const Byte *data;
24012 ++ const UInt32 *matches;
24014 ++ if (p->additionalOffset == 0)
24015 ++ mainLen = ReadMatchDistances(p, &numPairs);
24016 ++ else
24017 ++ {
24018 ++ mainLen = p->longestMatchLength;
24019 ++ numPairs = p->numPairs;
24020 ++ }
24022 ++ numAvail = p->numAvail;
24023 ++ *backRes = (UInt32)-1;
24024 ++ if (numAvail < 2)
24025 ++ return 1;
24026 ++ if (numAvail > LZMA_MATCH_LEN_MAX)
24027 ++ numAvail = LZMA_MATCH_LEN_MAX;
24028 ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
24030 ++ repLen = repIndex = 0;
24031 ++ for (i = 0; i < LZMA_NUM_REPS; i++)
24032 ++ {
24033 ++ UInt32 len;
24034 ++ const Byte *data2 = data - (p->reps[i] + 1);
24035 ++ if (data[0] != data2[0] || data[1] != data2[1])
24036 ++ continue;
24037 ++ for (len = 2; len < numAvail && data[len] == data2[len]; len++);
24038 ++ if (len >= p->numFastBytes)
24039 ++ {
24040 ++ *backRes = i;
24041 ++ MovePos(p, len - 1);
24042 ++ return len;
24043 ++ }
24044 ++ if (len > repLen)
24045 ++ {
24046 ++ repIndex = i;
24047 ++ repLen = len;
24048 ++ }
24049 ++ }
24051 ++ matches = p->matches;
24052 ++ if (mainLen >= p->numFastBytes)
24053 ++ {
24054 ++ *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
24055 ++ MovePos(p, mainLen - 1);
24056 ++ return mainLen;
24057 ++ }
24059 ++ mainDist = 0; /* for GCC */
24060 ++ if (mainLen >= 2)
24061 ++ {
24062 ++ mainDist = matches[numPairs - 1];
24063 ++ while (numPairs > 2 && mainLen == matches[numPairs - 4] + 1)
24064 ++ {
24065 ++ if (!ChangePair(matches[numPairs - 3], mainDist))
24066 ++ break;
24067 ++ numPairs -= 2;
24068 ++ mainLen = matches[numPairs - 2];
24069 ++ mainDist = matches[numPairs - 1];
24070 ++ }
24071 ++ if (mainLen == 2 && mainDist >= 0x80)
24072 ++ mainLen = 1;
24073 ++ }
24075 ++ if (repLen >= 2 && (
24076 ++ (repLen + 1 >= mainLen) ||
24077 ++ (repLen + 2 >= mainLen && mainDist >= (1 << 9)) ||
24078 ++ (repLen + 3 >= mainLen && mainDist >= (1 << 15))))
24079 ++ {
24080 ++ *backRes = repIndex;
24081 ++ MovePos(p, repLen - 1);
24082 ++ return repLen;
24083 ++ }
24085 ++ if (mainLen < 2 || numAvail <= 2)
24086 ++ return 1;
24088 ++ p->longestMatchLength = ReadMatchDistances(p, &p->numPairs);
24089 ++ if (p->longestMatchLength >= 2)
24090 ++ {
24091 ++ UInt32 newDistance = matches[p->numPairs - 1];
24092 ++ if ((p->longestMatchLength >= mainLen && newDistance < mainDist) ||
24093 ++ (p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) ||
24094 ++ (p->longestMatchLength > mainLen + 1) ||
24095 ++ (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist)))
24096 ++ return 1;
24097 ++ }
24099 ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
24100 ++ for (i = 0; i < LZMA_NUM_REPS; i++)
24101 ++ {
24102 ++ UInt32 len, limit;
24103 ++ const Byte *data2 = data - (p->reps[i] + 1);
24104 ++ if (data[0] != data2[0] || data[1] != data2[1])
24105 ++ continue;
24106 ++ limit = mainLen - 1;
24107 ++ for (len = 2; len < limit && data[len] == data2[len]; len++);
24108 ++ if (len >= limit)
24109 ++ return 1;
24110 ++ }
24111 ++ *backRes = mainDist + LZMA_NUM_REPS;
24112 ++ MovePos(p, mainLen - 2);
24113 ++ return mainLen;
24116 ++static void WriteEndMarker(CLzmaEnc *p, UInt32 posState)
24118 ++ UInt32 len;
24119 ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
24120 ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
24121 ++ p->state = kMatchNextStates[p->state];
24122 ++ len = LZMA_MATCH_LEN_MIN;
24123 ++ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
24124 ++ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1);
24125 ++ RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits);
24126 ++ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
24129 ++static SRes CheckErrors(CLzmaEnc *p)
24131 ++ if (p->result != SZ_OK)
24132 ++ return p->result;
24133 ++ if (p->rc.res != SZ_OK)
24134 ++ p->result = SZ_ERROR_WRITE;
24135 ++ if (p->matchFinderBase.result != SZ_OK)
24136 ++ p->result = SZ_ERROR_READ;
24137 ++ if (p->result != SZ_OK)
24138 ++ p->finished = True;
24139 ++ return p->result;
24142 ++static SRes Flush(CLzmaEnc *p, UInt32 nowPos)
24144 ++ /* ReleaseMFStream(); */
24145 ++ p->finished = True;
24146 ++ if (p->writeEndMark)
24147 ++ WriteEndMarker(p, nowPos & p->pbMask);
24148 ++ RangeEnc_FlushData(&p->rc);
24149 ++ RangeEnc_FlushStream(&p->rc);
24150 ++ return CheckErrors(p);
24153 ++static void FillAlignPrices(CLzmaEnc *p)
24155 ++ UInt32 i;
24156 ++ for (i = 0; i < kAlignTableSize; i++)
24157 ++ p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices);
24158 ++ p->alignPriceCount = 0;
24161 ++static void FillDistancesPrices(CLzmaEnc *p)
24163 ++ UInt32 tempPrices[kNumFullDistances];
24164 ++ UInt32 i, lenToPosState;
24165 ++ for (i = kStartPosModelIndex; i < kNumFullDistances; i++)
24166 ++ {
24167 ++ UInt32 posSlot = GetPosSlot1(i);
24168 ++ UInt32 footerBits = ((posSlot >> 1) - 1);
24169 ++ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
24170 ++ tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices);
24171 ++ }
24173 ++ for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
24174 ++ {
24175 ++ UInt32 posSlot;
24176 ++ const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState];
24177 ++ UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState];
24178 ++ for (posSlot = 0; posSlot < p->distTableSize; posSlot++)
24179 ++ posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices);
24180 ++ for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++)
24181 ++ posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits);
24183 ++ {
24184 ++ UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
24185 ++ UInt32 i;
24186 ++ for (i = 0; i < kStartPosModelIndex; i++)
24187 ++ distancesPrices[i] = posSlotPrices[i];
24188 ++ for (; i < kNumFullDistances; i++)
24189 ++ distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i];
24190 ++ }
24191 ++ }
24192 ++ p->matchPriceCount = 0;
24195 ++void LzmaEnc_Construct(CLzmaEnc *p)
24197 ++ RangeEnc_Construct(&p->rc);
24198 ++ MatchFinder_Construct(&p->matchFinderBase);
24199 ++ #ifndef _7ZIP_ST
24200 ++ MatchFinderMt_Construct(&p->matchFinderMt);
24201 ++ p->matchFinderMt.MatchFinder = &p->matchFinderBase;
24202 ++ #endif
24204 ++ {
24205 ++ CLzmaEncProps props;
24206 ++ LzmaEncProps_Init(&props);
24207 ++ LzmaEnc_SetProps(p, &props);
24208 ++ }
24210 ++ #ifndef LZMA_LOG_BSR
24211 ++ LzmaEnc_FastPosInit(p->g_FastPos);
24212 ++ #endif
24214 ++ LzmaEnc_InitPriceTables(p->ProbPrices);
24215 ++ p->litProbs = 0;
24216 ++ p->saveState.litProbs = 0;
24219 ++CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
24221 ++ void *p;
24222 ++ p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
24223 ++ if (p != 0)
24224 ++ LzmaEnc_Construct((CLzmaEnc *)p);
24225 ++ return p;
24228 ++void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
24230 ++ alloc->Free(alloc, p->litProbs);
24231 ++ alloc->Free(alloc, p->saveState.litProbs);
24232 ++ p->litProbs = 0;
24233 ++ p->saveState.litProbs = 0;
24236 ++void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
24238 ++ #ifndef _7ZIP_ST
24239 ++ MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
24240 ++ #endif
24241 ++ MatchFinder_Free(&p->matchFinderBase, allocBig);
24242 ++ LzmaEnc_FreeLits(p, alloc);
24243 ++ RangeEnc_Free(&p->rc, alloc);
24246 ++void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)
24248 ++ LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig);
24249 ++ alloc->Free(alloc, p);
24252 ++static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)
24254 ++ UInt32 nowPos32, startPos32;
24255 ++ if (p->needInit)
24256 ++ {
24257 ++ p->matchFinder.Init(p->matchFinderObj);
24258 ++ p->needInit = 0;
24259 ++ }
24261 ++ if (p->finished)
24262 ++ return p->result;
24263 ++ RINOK(CheckErrors(p));
24265 ++ nowPos32 = (UInt32)p->nowPos64;
24266 ++ startPos32 = nowPos32;
24268 ++ if (p->nowPos64 == 0)
24269 ++ {
24270 ++ UInt32 numPairs;
24271 ++ Byte curByte;
24272 ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
24273 ++ return Flush(p, nowPos32);
24274 ++ ReadMatchDistances(p, &numPairs);
24275 ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0);
24276 ++ p->state = kLiteralNextStates[p->state];
24277 ++ curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset);
24278 ++ LitEnc_Encode(&p->rc, p->litProbs, curByte);
24279 ++ p->additionalOffset--;
24280 ++ nowPos32++;
24281 ++ }
24283 ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0)
24284 ++ for (;;)
24285 ++ {
24286 ++ UInt32 pos, len, posState;
24288 ++ if (p->fastMode)
24289 ++ len = GetOptimumFast(p, &pos);
24290 ++ else
24291 ++ len = GetOptimum(p, nowPos32, &pos);
24293 ++ #ifdef SHOW_STAT2
24294 ++ printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos);
24295 ++ #endif
24297 ++ posState = nowPos32 & p->pbMask;
24298 ++ if (len == 1 && pos == (UInt32)-1)
24299 ++ {
24300 ++ Byte curByte;
24301 ++ CLzmaProb *probs;
24302 ++ const Byte *data;
24304 ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0);
24305 ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
24306 ++ curByte = *data;
24307 ++ probs = LIT_PROBS(nowPos32, *(data - 1));
24308 ++ if (IsCharState(p->state))
24309 ++ LitEnc_Encode(&p->rc, probs, curByte);
24310 ++ else
24311 ++ LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1));
24312 ++ p->state = kLiteralNextStates[p->state];
24313 ++ }
24314 ++ else
24315 ++ {
24316 ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
24317 ++ if (pos < LZMA_NUM_REPS)
24318 ++ {
24319 ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1);
24320 ++ if (pos == 0)
24321 ++ {
24322 ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0);
24323 ++ RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1));
24324 ++ }
24325 ++ else
24326 ++ {
24327 ++ UInt32 distance = p->reps[pos];
24328 ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1);
24329 ++ if (pos == 1)
24330 ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0);
24331 ++ else
24332 ++ {
24333 ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1);
24334 ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2);
24335 ++ if (pos == 3)
24336 ++ p->reps[3] = p->reps[2];
24337 ++ p->reps[2] = p->reps[1];
24338 ++ }
24339 ++ p->reps[1] = p->reps[0];
24340 ++ p->reps[0] = distance;
24341 ++ }
24342 ++ if (len == 1)
24343 ++ p->state = kShortRepNextStates[p->state];
24344 ++ else
24345 ++ {
24346 ++ LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
24347 ++ p->state = kRepNextStates[p->state];
24348 ++ }
24349 ++ }
24350 ++ else
24351 ++ {
24352 ++ UInt32 posSlot;
24353 ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
24354 ++ p->state = kMatchNextStates[p->state];
24355 ++ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
24356 ++ pos -= LZMA_NUM_REPS;
24357 ++ GetPosSlot(pos, posSlot);
24358 ++ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot);
24360 ++ if (posSlot >= kStartPosModelIndex)
24361 ++ {
24362 ++ UInt32 footerBits = ((posSlot >> 1) - 1);
24363 ++ UInt32 base = ((2 | (posSlot & 1)) << footerBits);
24364 ++ UInt32 posReduced = pos - base;
24366 ++ if (posSlot < kEndPosModelIndex)
24367 ++ RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced);
24368 ++ else
24369 ++ {
24370 ++ RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
24371 ++ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask);
24372 ++ p->alignPriceCount++;
24373 ++ }
24374 ++ }
24375 ++ p->reps[3] = p->reps[2];
24376 ++ p->reps[2] = p->reps[1];
24377 ++ p->reps[1] = p->reps[0];
24378 ++ p->reps[0] = pos;
24379 ++ p->matchPriceCount++;
24380 ++ }
24381 ++ }
24382 ++ p->additionalOffset -= len;
24383 ++ nowPos32 += len;
24384 ++ if (p->additionalOffset == 0)
24385 ++ {
24386 ++ UInt32 processed;
24387 ++ if (!p->fastMode)
24388 ++ {
24389 ++ if (p->matchPriceCount >= (1 << 7))
24390 ++ FillDistancesPrices(p);
24391 ++ if (p->alignPriceCount >= kAlignTableSize)
24392 ++ FillAlignPrices(p);
24393 ++ }
24394 ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
24395 ++ break;
24396 ++ processed = nowPos32 - startPos32;
24397 ++ if (useLimits)
24398 ++ {
24399 ++ if (processed + kNumOpts + 300 >= maxUnpackSize ||
24400 ++ RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize)
24401 ++ break;
24402 ++ }
24403 ++ else if (processed >= (1 << 15))
24404 ++ {
24405 ++ p->nowPos64 += nowPos32 - startPos32;
24406 ++ return CheckErrors(p);
24407 ++ }
24408 ++ }
24409 ++ }
24410 ++ p->nowPos64 += nowPos32 - startPos32;
24411 ++ return Flush(p, nowPos32);
24414 ++#define kBigHashDicLimit ((UInt32)1 << 24)
24416 ++static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
24418 ++ UInt32 beforeSize = kNumOpts;
24419 ++ Bool btMode;
24420 ++ if (!RangeEnc_Alloc(&p->rc, alloc))
24421 ++ return SZ_ERROR_MEM;
24422 ++ btMode = (p->matchFinderBase.btMode != 0);
24423 ++ #ifndef _7ZIP_ST
24424 ++ p->mtMode = (p->multiThread && !p->fastMode && btMode);
24425 ++ #endif
24427 ++ {
24428 ++ unsigned lclp = p->lc + p->lp;
24429 ++ if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp)
24430 ++ {
24431 ++ LzmaEnc_FreeLits(p, alloc);
24432 ++ p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
24433 ++ p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb));
24434 ++ if (p->litProbs == 0 || p->saveState.litProbs == 0)
24435 ++ {
24436 ++ LzmaEnc_FreeLits(p, alloc);
24437 ++ return SZ_ERROR_MEM;
24438 ++ }
24439 ++ p->lclp = lclp;
24440 ++ }
24441 ++ }
24443 ++ p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit);
24445 ++ if (beforeSize + p->dictSize < keepWindowSize)
24446 ++ beforeSize = keepWindowSize - p->dictSize;
24448 ++ #ifndef _7ZIP_ST
24449 ++ if (p->mtMode)
24450 ++ {
24451 ++ RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig));
24452 ++ p->matchFinderObj = &p->matchFinderMt;
24453 ++ MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder);
24454 ++ }
24455 ++ else
24456 ++ #endif
24457 ++ {
24458 ++ if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig))
24459 ++ return SZ_ERROR_MEM;
24460 ++ p->matchFinderObj = &p->matchFinderBase;
24461 ++ MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);
24462 ++ }
24463 ++ return SZ_OK;
24466 ++void LzmaEnc_Init(CLzmaEnc *p)
24468 ++ UInt32 i;
24469 ++ p->state = 0;
24470 ++ for (i = 0 ; i < LZMA_NUM_REPS; i++)
24471 ++ p->reps[i] = 0;
24473 ++ RangeEnc_Init(&p->rc);
24476 ++ for (i = 0; i < kNumStates; i++)
24477 ++ {
24478 ++ UInt32 j;
24479 ++ for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++)
24480 ++ {
24481 ++ p->isMatch[i][j] = kProbInitValue;
24482 ++ p->isRep0Long[i][j] = kProbInitValue;
24483 ++ }
24484 ++ p->isRep[i] = kProbInitValue;
24485 ++ p->isRepG0[i] = kProbInitValue;
24486 ++ p->isRepG1[i] = kProbInitValue;
24487 ++ p->isRepG2[i] = kProbInitValue;
24488 ++ }
24490 ++ {
24491 ++ UInt32 num = 0x300 << (p->lp + p->lc);
24492 ++ for (i = 0; i < num; i++)
24493 ++ p->litProbs[i] = kProbInitValue;
24494 ++ }
24496 ++ {
24497 ++ for (i = 0; i < kNumLenToPosStates; i++)
24498 ++ {
24499 ++ CLzmaProb *probs = p->posSlotEncoder[i];
24500 ++ UInt32 j;
24501 ++ for (j = 0; j < (1 << kNumPosSlotBits); j++)
24502 ++ probs[j] = kProbInitValue;
24503 ++ }
24504 ++ }
24505 ++ {
24506 ++ for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
24507 ++ p->posEncoders[i] = kProbInitValue;
24508 ++ }
24510 ++ LenEnc_Init(&p->lenEnc.p);
24511 ++ LenEnc_Init(&p->repLenEnc.p);
24513 ++ for (i = 0; i < (1 << kNumAlignBits); i++)
24514 ++ p->posAlignEncoder[i] = kProbInitValue;
24516 ++ p->optimumEndIndex = 0;
24517 ++ p->optimumCurrentIndex = 0;
24518 ++ p->additionalOffset = 0;
24520 ++ p->pbMask = (1 << p->pb) - 1;
24521 ++ p->lpMask = (1 << p->lp) - 1;
24524 ++void LzmaEnc_InitPrices(CLzmaEnc *p)
24526 ++ if (!p->fastMode)
24527 ++ {
24528 ++ FillDistancesPrices(p);
24529 ++ FillAlignPrices(p);
24530 ++ }
24532 ++ p->lenEnc.tableSize =
24533 ++ p->repLenEnc.tableSize =
24534 ++ p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;
24535 ++ LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices);
24536 ++ LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices);
24539 ++static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
24541 ++ UInt32 i;
24542 ++ for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++)
24543 ++ if (p->dictSize <= ((UInt32)1 << i))
24544 ++ break;
24545 ++ p->distTableSize = i * 2;
24547 ++ p->finished = False;
24548 ++ p->result = SZ_OK;
24549 ++ RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig));
24550 ++ LzmaEnc_Init(p);
24551 ++ LzmaEnc_InitPrices(p);
24552 ++ p->nowPos64 = 0;
24553 ++ return SZ_OK;
24556 ++static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,
24557 ++ ISzAlloc *alloc, ISzAlloc *allocBig)
24559 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
24560 ++ p->matchFinderBase.stream = inStream;
24561 ++ p->needInit = 1;
24562 ++ p->rc.outStream = outStream;
24563 ++ return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
24566 ++SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
24567 ++ ISeqInStream *inStream, UInt32 keepWindowSize,
24568 ++ ISzAlloc *alloc, ISzAlloc *allocBig)
24570 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
24571 ++ p->matchFinderBase.stream = inStream;
24572 ++ p->needInit = 1;
24573 ++ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
24576 ++static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
24578 ++ p->matchFinderBase.directInput = 1;
24579 ++ p->matchFinderBase.bufferBase = (Byte *)src;
24580 ++ p->matchFinderBase.directInputRem = srcLen;
24583 ++SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
24584 ++ UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
24586 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
24587 ++ LzmaEnc_SetInputBuf(p, src, srcLen);
24588 ++ p->needInit = 1;
24590 ++ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
24593 ++void LzmaEnc_Finish(CLzmaEncHandle pp)
24595 ++ #ifndef _7ZIP_ST
24596 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
24597 ++ if (p->mtMode)
24598 ++ MatchFinderMt_ReleaseStream(&p->matchFinderMt);
24599 ++ #else
24600 ++ pp = pp;
24601 ++ #endif
24604 ++typedef struct
24606 ++ ISeqOutStream funcTable;
24607 ++ Byte *data;
24608 ++ SizeT rem;
24609 ++ Bool overflow;
24610 ++} CSeqOutStreamBuf;
24612 ++static size_t MyWrite(void *pp, const void *data, size_t size)
24614 ++ CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp;
24615 ++ if (p->rem < size)
24616 ++ {
24617 ++ size = p->rem;
24618 ++ p->overflow = True;
24619 ++ }
24620 ++ memcpy(p->data, data, size);
24621 ++ p->rem -= size;
24622 ++ p->data += size;
24623 ++ return size;
24627 ++UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
24629 ++ const CLzmaEnc *p = (CLzmaEnc *)pp;
24630 ++ return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
24633 ++const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
24635 ++ const CLzmaEnc *p = (CLzmaEnc *)pp;
24636 ++ return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
24639 ++SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
24640 ++ Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
24642 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
24643 ++ UInt64 nowPos64;
24644 ++ SRes res;
24645 ++ CSeqOutStreamBuf outStream;
24647 ++ outStream.funcTable.Write = MyWrite;
24648 ++ outStream.data = dest;
24649 ++ outStream.rem = *destLen;
24650 ++ outStream.overflow = False;
24652 ++ p->writeEndMark = False;
24653 ++ p->finished = False;
24654 ++ p->result = SZ_OK;
24656 ++ if (reInit)
24657 ++ LzmaEnc_Init(p);
24658 ++ LzmaEnc_InitPrices(p);
24659 ++ nowPos64 = p->nowPos64;
24660 ++ RangeEnc_Init(&p->rc);
24661 ++ p->rc.outStream = &outStream.funcTable;
24663 ++ res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
24665 ++ *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
24666 ++ *destLen -= outStream.rem;
24667 ++ if (outStream.overflow)
24668 ++ return SZ_ERROR_OUTPUT_EOF;
24670 ++ return res;
24673 ++static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
24675 ++ SRes res = SZ_OK;
24677 ++ #ifndef _7ZIP_ST
24678 ++ Byte allocaDummy[0x300];
24679 ++ int i = 0;
24680 ++ for (i = 0; i < 16; i++)
24681 ++ allocaDummy[i] = (Byte)i;
24682 ++ #endif
24684 ++ for (;;)
24685 ++ {
24686 ++ res = LzmaEnc_CodeOneBlock(p, False, 0, 0);
24687 ++ if (res != SZ_OK || p->finished != 0)
24688 ++ break;
24689 ++ if (progress != 0)
24690 ++ {
24691 ++ res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));
24692 ++ if (res != SZ_OK)
24693 ++ {
24694 ++ res = SZ_ERROR_PROGRESS;
24695 ++ break;
24696 ++ }
24697 ++ }
24698 ++ }
24699 ++ LzmaEnc_Finish(p);
24700 ++ return res;
24703 ++SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
24704 ++ ISzAlloc *alloc, ISzAlloc *allocBig)
24706 ++ RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));
24707 ++ return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
24710 ++SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
24712 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
24713 ++ int i;
24714 ++ UInt32 dictSize = p->dictSize;
24715 ++ if (*size < LZMA_PROPS_SIZE)
24716 ++ return SZ_ERROR_PARAM;
24717 ++ *size = LZMA_PROPS_SIZE;
24718 ++ props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc);
24720 ++ for (i = 11; i <= 30; i++)
24721 ++ {
24722 ++ if (dictSize <= ((UInt32)2 << i))
24723 ++ {
24724 ++ dictSize = (2 << i);
24725 ++ break;
24726 ++ }
24727 ++ if (dictSize <= ((UInt32)3 << i))
24728 ++ {
24729 ++ dictSize = (3 << i);
24730 ++ break;
24731 ++ }
24732 ++ }
24734 ++ for (i = 0; i < 4; i++)
24735 ++ props[1 + i] = (Byte)(dictSize >> (8 * i));
24736 ++ return SZ_OK;
24739 ++SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
24740 ++ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
24742 ++ SRes res;
24743 ++ CLzmaEnc *p = (CLzmaEnc *)pp;
24745 ++ CSeqOutStreamBuf outStream;
24747 ++ LzmaEnc_SetInputBuf(p, src, srcLen);
24749 ++ outStream.funcTable.Write = MyWrite;
24750 ++ outStream.data = dest;
24751 ++ outStream.rem = *destLen;
24752 ++ outStream.overflow = False;
24754 ++ p->writeEndMark = writeEndMark;
24756 ++ p->rc.outStream = &outStream.funcTable;
24757 ++ res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);
24758 ++ if (res == SZ_OK)
24759 ++ res = LzmaEnc_Encode2(p, progress);
24761 ++ *destLen -= outStream.rem;
24762 ++ if (outStream.overflow)
24763 ++ return SZ_ERROR_OUTPUT_EOF;
24764 ++ return res;
24767 ++SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
24768 ++ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
24769 ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
24771 ++ CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
24772 ++ SRes res;
24773 ++ if (p == 0)
24774 ++ return SZ_ERROR_MEM;
24776 ++ res = LzmaEnc_SetProps(p, props);
24777 ++ if (res == SZ_OK)
24778 ++ {
24779 ++ res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
24780 ++ if (res == SZ_OK)
24781 ++ res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
24782 ++ writeEndMark, progress, alloc, allocBig);
24783 ++ }
24785 ++ LzmaEnc_Destroy(p, alloc, allocBig);
24786 ++ return res;
24788 +--- /dev/null
24789 ++++ b/lib/lzma/Makefile
24790 +@@ -0,0 +1,7 @@
24791 ++lzma_compress-objs := LzFind.o LzmaEnc.o
24792 ++lzma_decompress-objs := LzmaDec.o
24794 ++obj-$(CONFIG_LZMA_COMPRESS) += lzma_compress.o
24795 ++obj-$(CONFIG_LZMA_DECOMPRESS) += lzma_decompress.o
24797 ++EXTRA_CFLAGS += -Iinclude/linux -Iinclude/linux/lzma -include types.h
24798 diff --git a/target/linux/generic/patches-3.16/531-debloat_lzma.patch b/target/linux/generic/patches-3.16/531-debloat_lzma.patch
24799 new file mode 100644
24800 index 000000000000..aa3c49801636
24801 --- /dev/null
24802 +++ b/target/linux/generic/patches-3.16/531-debloat_lzma.patch
24803 @@ -0,0 +1,1024 @@
24804 +--- a/include/linux/lzma/LzmaDec.h
24805 ++++ b/include/linux/lzma/LzmaDec.h
24806 +@@ -31,14 +31,6 @@ typedef struct _CLzmaProps
24807 + UInt32 dicSize;
24808 + } CLzmaProps;
24810 +-/* LzmaProps_Decode - decodes properties
24811 +-Returns:
24812 +- SZ_OK
24813 +- SZ_ERROR_UNSUPPORTED - Unsupported properties
24814 +-*/
24816 +-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
24819 + /* ---------- LZMA Decoder state ---------- */
24821 +@@ -70,8 +62,6 @@ typedef struct
24823 + #define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
24825 +-void LzmaDec_Init(CLzmaDec *p);
24827 + /* There are two types of LZMA streams:
24828 + 0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
24829 + 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
24830 +@@ -108,97 +98,6 @@ typedef enum
24832 + /* ELzmaStatus is used only as output value for function call */
24835 +-/* ---------- Interfaces ---------- */
24837 +-/* There are 3 levels of interfaces:
24838 +- 1) Dictionary Interface
24839 +- 2) Buffer Interface
24840 +- 3) One Call Interface
24841 +- You can select any of these interfaces, but don't mix functions from different
24842 +- groups for same object. */
24845 +-/* There are two variants to allocate state for Dictionary Interface:
24846 +- 1) LzmaDec_Allocate / LzmaDec_Free
24847 +- 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
24848 +- You can use variant 2, if you set dictionary buffer manually.
24849 +- For Buffer Interface you must always use variant 1.
24851 +-LzmaDec_Allocate* can return:
24852 +- SZ_OK
24853 +- SZ_ERROR_MEM - Memory allocation error
24854 +- SZ_ERROR_UNSUPPORTED - Unsupported properties
24855 +-*/
24857 +-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
24858 +-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
24860 +-SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
24861 +-void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
24863 +-/* ---------- Dictionary Interface ---------- */
24865 +-/* You can use it, if you want to eliminate the overhead for data copying from
24866 +- dictionary to some other external buffer.
24867 +- You must work with CLzmaDec variables directly in this interface.
24869 +- STEPS:
24870 +- LzmaDec_Constr()
24871 +- LzmaDec_Allocate()
24872 +- for (each new stream)
24873 +- {
24874 +- LzmaDec_Init()
24875 +- while (it needs more decompression)
24876 +- {
24877 +- LzmaDec_DecodeToDic()
24878 +- use data from CLzmaDec::dic and update CLzmaDec::dicPos
24879 +- }
24880 +- }
24881 +- LzmaDec_Free()
24882 +-*/
24884 +-/* LzmaDec_DecodeToDic
24886 +- The decoding to internal dictionary buffer (CLzmaDec::dic).
24887 +- You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
24889 +-finishMode:
24890 +- It has meaning only if the decoding reaches output limit (dicLimit).
24891 +- LZMA_FINISH_ANY - Decode just dicLimit bytes.
24892 +- LZMA_FINISH_END - Stream must be finished after dicLimit.
24894 +-Returns:
24895 +- SZ_OK
24896 +- status:
24897 +- LZMA_STATUS_FINISHED_WITH_MARK
24898 +- LZMA_STATUS_NOT_FINISHED
24899 +- LZMA_STATUS_NEEDS_MORE_INPUT
24900 +- LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
24901 +- SZ_ERROR_DATA - Data error
24902 +-*/
24904 +-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
24905 +- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
24908 +-/* ---------- Buffer Interface ---------- */
24910 +-/* It's zlib-like interface.
24911 +- See LzmaDec_DecodeToDic description for information about STEPS and return results,
24912 +- but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
24913 +- to work with CLzmaDec variables manually.
24915 +-finishMode:
24916 +- It has meaning only if the decoding reaches output limit (*destLen).
24917 +- LZMA_FINISH_ANY - Decode just destLen bytes.
24918 +- LZMA_FINISH_END - Stream must be finished after (*destLen).
24919 +-*/
24921 +-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
24922 +- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
24925 + /* ---------- One Call Interface ---------- */
24927 + /* LzmaDecode
24928 +--- a/lib/lzma/LzmaDec.c
24929 ++++ b/lib/lzma/LzmaDec.c
24930 +@@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p,
24931 + p->needFlush = 0;
24934 +-void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
24935 ++static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
24937 + p->needFlush = 1;
24938 + p->remainLen = 0;
24939 +@@ -698,7 +698,7 @@ void LzmaDec_InitDicAndState(CLzmaDec *p
24940 + p->needInitState = 1;
24943 +-void LzmaDec_Init(CLzmaDec *p)
24944 ++static void LzmaDec_Init(CLzmaDec *p)
24946 + p->dicPos = 0;
24947 + LzmaDec_InitDicAndState(p, True, True);
24948 +@@ -716,7 +716,7 @@ static void LzmaDec_InitStateReal(CLzmaD
24949 + p->needInitState = 0;
24952 +-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
24953 ++static SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
24954 + ELzmaFinishMode finishMode, ELzmaStatus *status)
24956 + SizeT inSize = *srcLen;
24957 +@@ -837,65 +837,13 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si
24958 + return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
24961 +-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
24963 +- SizeT outSize = *destLen;
24964 +- SizeT inSize = *srcLen;
24965 +- *srcLen = *destLen = 0;
24966 +- for (;;)
24967 +- {
24968 +- SizeT inSizeCur = inSize, outSizeCur, dicPos;
24969 +- ELzmaFinishMode curFinishMode;
24970 +- SRes res;
24971 +- if (p->dicPos == p->dicBufSize)
24972 +- p->dicPos = 0;
24973 +- dicPos = p->dicPos;
24974 +- if (outSize > p->dicBufSize - dicPos)
24975 +- {
24976 +- outSizeCur = p->dicBufSize;
24977 +- curFinishMode = LZMA_FINISH_ANY;
24978 +- }
24979 +- else
24980 +- {
24981 +- outSizeCur = dicPos + outSize;
24982 +- curFinishMode = finishMode;
24983 +- }
24985 +- res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
24986 +- src += inSizeCur;
24987 +- inSize -= inSizeCur;
24988 +- *srcLen += inSizeCur;
24989 +- outSizeCur = p->dicPos - dicPos;
24990 +- memcpy(dest, p->dic + dicPos, outSizeCur);
24991 +- dest += outSizeCur;
24992 +- outSize -= outSizeCur;
24993 +- *destLen += outSizeCur;
24994 +- if (res != 0)
24995 +- return res;
24996 +- if (outSizeCur == 0 || outSize == 0)
24997 +- return SZ_OK;
24998 +- }
25001 +-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
25002 ++static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
25004 + alloc->Free(alloc, p->probs);
25005 + p->probs = 0;
25008 +-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
25010 +- alloc->Free(alloc, p->dic);
25011 +- p->dic = 0;
25014 +-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
25016 +- LzmaDec_FreeProbs(p, alloc);
25017 +- LzmaDec_FreeDict(p, alloc);
25020 +-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
25021 ++static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
25023 + UInt32 dicSize;
25024 + Byte d;
25025 +@@ -935,7 +883,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma
25026 + return SZ_OK;
25029 +-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
25030 ++static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
25032 + CLzmaProps propNew;
25033 + RINOK(LzmaProps_Decode(&propNew, props, propsSize));
25034 +@@ -943,28 +891,6 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p,
25035 + p->prop = propNew;
25036 + return SZ_OK;
25039 +-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
25041 +- CLzmaProps propNew;
25042 +- SizeT dicBufSize;
25043 +- RINOK(LzmaProps_Decode(&propNew, props, propsSize));
25044 +- RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
25045 +- dicBufSize = propNew.dicSize;
25046 +- if (p->dic == 0 || dicBufSize != p->dicBufSize)
25047 +- {
25048 +- LzmaDec_FreeDict(p, alloc);
25049 +- p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
25050 +- if (p->dic == 0)
25051 +- {
25052 +- LzmaDec_FreeProbs(p, alloc);
25053 +- return SZ_ERROR_MEM;
25054 +- }
25055 +- }
25056 +- p->dicBufSize = dicBufSize;
25057 +- p->prop = propNew;
25058 +- return SZ_OK;
25061 + SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
25062 + const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
25063 +--- a/include/linux/lzma/LzmaEnc.h
25064 ++++ b/include/linux/lzma/LzmaEnc.h
25065 +@@ -31,9 +31,6 @@ typedef struct _CLzmaEncProps
25066 + } CLzmaEncProps;
25068 + void LzmaEncProps_Init(CLzmaEncProps *p);
25069 +-void LzmaEncProps_Normalize(CLzmaEncProps *p);
25070 +-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
25073 + /* ---------- CLzmaEncHandle Interface ---------- */
25075 +@@ -53,26 +50,9 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
25076 + void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
25077 + SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
25078 + SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
25079 +-SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
25080 +- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
25081 + SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
25082 + int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
25084 +-/* ---------- One Call Interface ---------- */
25086 +-/* LzmaEncode
25087 +-Return code:
25088 +- SZ_OK - OK
25089 +- SZ_ERROR_MEM - Memory allocation error
25090 +- SZ_ERROR_PARAM - Incorrect paramater
25091 +- SZ_ERROR_OUTPUT_EOF - output buffer overflow
25092 +- SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
25093 +-*/
25095 +-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
25096 +- const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
25097 +- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
25099 + #ifdef __cplusplus
25101 + #endif
25102 +--- a/lib/lzma/LzmaEnc.c
25103 ++++ b/lib/lzma/LzmaEnc.c
25104 +@@ -53,7 +53,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
25105 + p->writeEndMark = 0;
25108 +-void LzmaEncProps_Normalize(CLzmaEncProps *p)
25109 ++static void LzmaEncProps_Normalize(CLzmaEncProps *p)
25111 + int level = p->level;
25112 + if (level < 0) level = 5;
25113 +@@ -76,7 +76,7 @@ void LzmaEncProps_Normalize(CLzmaEncProp
25114 + #endif
25117 +-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
25118 ++static UInt32 __maybe_unused LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
25120 + CLzmaEncProps props = *props2;
25121 + LzmaEncProps_Normalize(&props);
25122 +@@ -93,7 +93,7 @@ UInt32 LzmaEncProps_GetDictSize(const CL
25124 + #define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
25126 +-UInt32 GetPosSlot1(UInt32 pos)
25127 ++static UInt32 GetPosSlot1(UInt32 pos)
25129 + UInt32 res;
25130 + BSR2_RET(pos, res);
25131 +@@ -107,7 +107,7 @@ UInt32 GetPosSlot1(UInt32 pos)
25132 + #define kNumLogBits (9 + (int)sizeof(size_t) / 2)
25133 + #define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
25135 +-void LzmaEnc_FastPosInit(Byte *g_FastPos)
25136 ++static void LzmaEnc_FastPosInit(Byte *g_FastPos)
25138 + int c = 2, slotFast;
25139 + g_FastPos[0] = 0;
25140 +@@ -339,58 +339,6 @@ typedef struct
25141 + CSaveState saveState;
25142 + } CLzmaEnc;
25144 +-void LzmaEnc_SaveState(CLzmaEncHandle pp)
25146 +- CLzmaEnc *p = (CLzmaEnc *)pp;
25147 +- CSaveState *dest = &p->saveState;
25148 +- int i;
25149 +- dest->lenEnc = p->lenEnc;
25150 +- dest->repLenEnc = p->repLenEnc;
25151 +- dest->state = p->state;
25153 +- for (i = 0; i < kNumStates; i++)
25154 +- {
25155 +- memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
25156 +- memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
25157 +- }
25158 +- for (i = 0; i < kNumLenToPosStates; i++)
25159 +- memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
25160 +- memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
25161 +- memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
25162 +- memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
25163 +- memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
25164 +- memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
25165 +- memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
25166 +- memcpy(dest->reps, p->reps, sizeof(p->reps));
25167 +- memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
25170 +-void LzmaEnc_RestoreState(CLzmaEncHandle pp)
25172 +- CLzmaEnc *dest = (CLzmaEnc *)pp;
25173 +- const CSaveState *p = &dest->saveState;
25174 +- int i;
25175 +- dest->lenEnc = p->lenEnc;
25176 +- dest->repLenEnc = p->repLenEnc;
25177 +- dest->state = p->state;
25179 +- for (i = 0; i < kNumStates; i++)
25180 +- {
25181 +- memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));
25182 +- memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));
25183 +- }
25184 +- for (i = 0; i < kNumLenToPosStates; i++)
25185 +- memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));
25186 +- memcpy(dest->isRep, p->isRep, sizeof(p->isRep));
25187 +- memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));
25188 +- memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));
25189 +- memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));
25190 +- memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));
25191 +- memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));
25192 +- memcpy(dest->reps, p->reps, sizeof(p->reps));
25193 +- memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
25196 + SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
25198 + CLzmaEnc *p = (CLzmaEnc *)pp;
25199 +@@ -600,7 +548,7 @@ static void LitEnc_EncodeMatched(CRangeE
25200 + while (symbol < 0x10000);
25203 +-void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
25204 ++static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
25206 + UInt32 i;
25207 + for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
25208 +@@ -1676,7 +1624,7 @@ static void FillDistancesPrices(CLzmaEnc
25209 + p->matchPriceCount = 0;
25212 +-void LzmaEnc_Construct(CLzmaEnc *p)
25213 ++static void LzmaEnc_Construct(CLzmaEnc *p)
25215 + RangeEnc_Construct(&p->rc);
25216 + MatchFinder_Construct(&p->matchFinderBase);
25217 +@@ -1709,7 +1657,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
25218 + return p;
25221 +-void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
25222 ++static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
25224 + alloc->Free(alloc, p->litProbs);
25225 + alloc->Free(alloc, p->saveState.litProbs);
25226 +@@ -1717,7 +1665,7 @@ void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAl
25227 + p->saveState.litProbs = 0;
25230 +-void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
25231 ++static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
25233 + #ifndef _7ZIP_ST
25234 + MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
25235 +@@ -1947,7 +1895,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, U
25236 + return SZ_OK;
25239 +-void LzmaEnc_Init(CLzmaEnc *p)
25240 ++static void LzmaEnc_Init(CLzmaEnc *p)
25242 + UInt32 i;
25243 + p->state = 0;
25244 +@@ -2005,7 +1953,7 @@ void LzmaEnc_Init(CLzmaEnc *p)
25245 + p->lpMask = (1 << p->lp) - 1;
25248 +-void LzmaEnc_InitPrices(CLzmaEnc *p)
25249 ++static void LzmaEnc_InitPrices(CLzmaEnc *p)
25251 + if (!p->fastMode)
25253 +@@ -2037,26 +1985,6 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEn
25254 + return SZ_OK;
25257 +-static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,
25258 +- ISzAlloc *alloc, ISzAlloc *allocBig)
25260 +- CLzmaEnc *p = (CLzmaEnc *)pp;
25261 +- p->matchFinderBase.stream = inStream;
25262 +- p->needInit = 1;
25263 +- p->rc.outStream = outStream;
25264 +- return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
25267 +-SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
25268 +- ISeqInStream *inStream, UInt32 keepWindowSize,
25269 +- ISzAlloc *alloc, ISzAlloc *allocBig)
25271 +- CLzmaEnc *p = (CLzmaEnc *)pp;
25272 +- p->matchFinderBase.stream = inStream;
25273 +- p->needInit = 1;
25274 +- return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
25277 + static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
25279 + p->matchFinderBase.directInput = 1;
25280 +@@ -2064,7 +1992,7 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc
25281 + p->matchFinderBase.directInputRem = srcLen;
25284 +-SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
25285 ++static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
25286 + UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
25288 + CLzmaEnc *p = (CLzmaEnc *)pp;
25289 +@@ -2074,7 +2002,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p
25290 + return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
25293 +-void LzmaEnc_Finish(CLzmaEncHandle pp)
25294 ++static void LzmaEnc_Finish(CLzmaEncHandle pp)
25296 + #ifndef _7ZIP_ST
25297 + CLzmaEnc *p = (CLzmaEnc *)pp;
25298 +@@ -2107,53 +2035,6 @@ static size_t MyWrite(void *pp, const vo
25299 + return size;
25303 +-UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
25305 +- const CLzmaEnc *p = (CLzmaEnc *)pp;
25306 +- return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
25309 +-const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
25311 +- const CLzmaEnc *p = (CLzmaEnc *)pp;
25312 +- return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
25315 +-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
25316 +- Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
25318 +- CLzmaEnc *p = (CLzmaEnc *)pp;
25319 +- UInt64 nowPos64;
25320 +- SRes res;
25321 +- CSeqOutStreamBuf outStream;
25323 +- outStream.funcTable.Write = MyWrite;
25324 +- outStream.data = dest;
25325 +- outStream.rem = *destLen;
25326 +- outStream.overflow = False;
25328 +- p->writeEndMark = False;
25329 +- p->finished = False;
25330 +- p->result = SZ_OK;
25332 +- if (reInit)
25333 +- LzmaEnc_Init(p);
25334 +- LzmaEnc_InitPrices(p);
25335 +- nowPos64 = p->nowPos64;
25336 +- RangeEnc_Init(&p->rc);
25337 +- p->rc.outStream = &outStream.funcTable;
25339 +- res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
25341 +- *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
25342 +- *destLen -= outStream.rem;
25343 +- if (outStream.overflow)
25344 +- return SZ_ERROR_OUTPUT_EOF;
25346 +- return res;
25349 + static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
25351 + SRes res = SZ_OK;
25352 +@@ -2184,13 +2065,6 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p,
25353 + return res;
25356 +-SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
25357 +- ISzAlloc *alloc, ISzAlloc *allocBig)
25359 +- RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));
25360 +- return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
25363 + SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
25365 + CLzmaEnc *p = (CLzmaEnc *)pp;
25366 +@@ -2247,25 +2121,3 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp
25367 + return SZ_ERROR_OUTPUT_EOF;
25368 + return res;
25371 +-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
25372 +- const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
25373 +- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
25375 +- CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
25376 +- SRes res;
25377 +- if (p == 0)
25378 +- return SZ_ERROR_MEM;
25380 +- res = LzmaEnc_SetProps(p, props);
25381 +- if (res == SZ_OK)
25382 +- {
25383 +- res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);
25384 +- if (res == SZ_OK)
25385 +- res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,
25386 +- writeEndMark, progress, alloc, allocBig);
25387 +- }
25389 +- LzmaEnc_Destroy(p, alloc, allocBig);
25390 +- return res;
25392 +--- a/include/linux/lzma/LzFind.h
25393 ++++ b/include/linux/lzma/LzFind.h
25394 +@@ -55,11 +55,6 @@ typedef struct _CMatchFinder
25396 + #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
25398 +-int MatchFinder_NeedMove(CMatchFinder *p);
25399 +-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
25400 +-void MatchFinder_MoveBlock(CMatchFinder *p);
25401 +-void MatchFinder_ReadIfRequired(CMatchFinder *p);
25403 + void MatchFinder_Construct(CMatchFinder *p);
25405 + /* Conditions:
25406 +@@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p,
25407 + UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
25408 + ISzAlloc *alloc);
25409 + void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
25410 +-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
25411 +-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
25413 +-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
25414 +- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
25415 +- UInt32 *distances, UInt32 maxLen);
25417 + /*
25418 + Conditions:
25419 +@@ -102,12 +91,6 @@ typedef struct _IMatchFinder
25421 + void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
25423 +-void MatchFinder_Init(CMatchFinder *p);
25424 +-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
25425 +-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
25426 +-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
25427 +-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
25429 + #ifdef __cplusplus
25431 + #endif
25432 +--- a/lib/lzma/LzFind.c
25433 ++++ b/lib/lzma/LzFind.c
25434 +@@ -14,9 +14,15 @@
25436 + #define kStartMaxLen 3
25438 ++#if 0
25439 ++#define DIRECT_INPUT p->directInput
25440 ++#else
25441 ++#define DIRECT_INPUT 1
25442 ++#endif
25444 + static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
25446 +- if (!p->directInput)
25447 ++ if (!DIRECT_INPUT)
25449 + alloc->Free(alloc, p->bufferBase);
25450 + p->bufferBase = 0;
25451 +@@ -28,7 +34,7 @@ static void LzInWindow_Free(CMatchFinder
25452 + static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
25454 + UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
25455 +- if (p->directInput)
25456 ++ if (DIRECT_INPUT)
25458 + p->blockSize = blockSize;
25459 + return 1;
25460 +@@ -42,12 +48,12 @@ static int LzInWindow_Create(CMatchFinde
25461 + return (p->bufferBase != 0);
25464 +-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
25465 +-Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
25466 ++static Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
25467 ++static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
25469 +-UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
25470 ++static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
25472 +-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
25473 ++static void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
25475 + p->posLimit -= subValue;
25476 + p->pos -= subValue;
25477 +@@ -58,7 +64,7 @@ static void MatchFinder_ReadBlock(CMatch
25479 + if (p->streamEndWasReached || p->result != SZ_OK)
25480 + return;
25481 +- if (p->directInput)
25482 ++ if (DIRECT_INPUT)
25484 + UInt32 curSize = 0xFFFFFFFF - p->streamPos;
25485 + if (curSize > p->directInputRem)
25486 +@@ -89,7 +95,7 @@ static void MatchFinder_ReadBlock(CMatch
25490 +-void MatchFinder_MoveBlock(CMatchFinder *p)
25491 ++static void MatchFinder_MoveBlock(CMatchFinder *p)
25493 + memmove(p->bufferBase,
25494 + p->buffer - p->keepSizeBefore,
25495 +@@ -97,22 +103,14 @@ void MatchFinder_MoveBlock(CMatchFinder
25496 + p->buffer = p->bufferBase + p->keepSizeBefore;
25499 +-int MatchFinder_NeedMove(CMatchFinder *p)
25500 ++static int MatchFinder_NeedMove(CMatchFinder *p)
25502 +- if (p->directInput)
25503 ++ if (DIRECT_INPUT)
25504 + return 0;
25505 + /* if (p->streamEndWasReached) return 0; */
25506 + return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
25509 +-void MatchFinder_ReadIfRequired(CMatchFinder *p)
25511 +- if (p->streamEndWasReached)
25512 +- return;
25513 +- if (p->keepSizeAfter >= p->streamPos - p->pos)
25514 +- MatchFinder_ReadBlock(p);
25517 + static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
25519 + if (MatchFinder_NeedMove(p))
25520 +@@ -268,7 +266,7 @@ static void MatchFinder_SetLimits(CMatch
25521 + p->posLimit = p->pos + limit;
25524 +-void MatchFinder_Init(CMatchFinder *p)
25525 ++static void MatchFinder_Init(CMatchFinder *p)
25527 + UInt32 i;
25528 + for (i = 0; i < p->hashSizeSum; i++)
25529 +@@ -287,7 +285,7 @@ static UInt32 MatchFinder_GetSubValue(CM
25530 + return (p->pos - p->historySize - 1) & kNormalizeMask;
25533 +-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
25534 ++static void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
25536 + UInt32 i;
25537 + for (i = 0; i < numItems; i++)
25538 +@@ -319,38 +317,7 @@ static void MatchFinder_CheckLimits(CMat
25539 + MatchFinder_SetLimits(p);
25542 +-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
25543 +- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
25544 +- UInt32 *distances, UInt32 maxLen)
25546 +- son[_cyclicBufferPos] = curMatch;
25547 +- for (;;)
25548 +- {
25549 +- UInt32 delta = pos - curMatch;
25550 +- if (cutValue-- == 0 || delta >= _cyclicBufferSize)
25551 +- return distances;
25552 +- {
25553 +- const Byte *pb = cur - delta;
25554 +- curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
25555 +- if (pb[maxLen] == cur[maxLen] && *pb == *cur)
25556 +- {
25557 +- UInt32 len = 0;
25558 +- while (++len != lenLimit)
25559 +- if (pb[len] != cur[len])
25560 +- break;
25561 +- if (maxLen < len)
25562 +- {
25563 +- *distances++ = maxLen = len;
25564 +- *distances++ = delta - 1;
25565 +- if (len == lenLimit)
25566 +- return distances;
25567 +- }
25568 +- }
25569 +- }
25570 +- }
25573 +-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
25574 ++static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
25575 + UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
25576 + UInt32 *distances, UInt32 maxLen)
25578 +@@ -460,10 +427,10 @@ static void SkipMatchesSpec(UInt32 lenLi
25579 + p->buffer++; \
25580 + if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
25582 +-#define MOVE_POS_RET MOVE_POS return offset;
25584 + static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
25586 ++#define MOVE_POS_RET MatchFinder_MovePos(p); return offset;
25588 + #define GET_MATCHES_HEADER2(minLen, ret_op) \
25589 + UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
25590 + lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
25591 +@@ -479,62 +446,7 @@ static void MatchFinder_MovePos(CMatchFi
25592 + distances + offset, maxLen) - distances); MOVE_POS_RET;
25594 + #define SKIP_FOOTER \
25595 +- SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
25597 +-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
25599 +- UInt32 offset;
25600 +- GET_MATCHES_HEADER(2)
25601 +- HASH2_CALC;
25602 +- curMatch = p->hash[hashValue];
25603 +- p->hash[hashValue] = p->pos;
25604 +- offset = 0;
25605 +- GET_MATCHES_FOOTER(offset, 1)
25608 +-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
25610 +- UInt32 offset;
25611 +- GET_MATCHES_HEADER(3)
25612 +- HASH_ZIP_CALC;
25613 +- curMatch = p->hash[hashValue];
25614 +- p->hash[hashValue] = p->pos;
25615 +- offset = 0;
25616 +- GET_MATCHES_FOOTER(offset, 2)
25619 +-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
25621 +- UInt32 hash2Value, delta2, maxLen, offset;
25622 +- GET_MATCHES_HEADER(3)
25624 +- HASH3_CALC;
25626 +- delta2 = p->pos - p->hash[hash2Value];
25627 +- curMatch = p->hash[kFix3HashSize + hashValue];
25629 +- p->hash[hash2Value] =
25630 +- p->hash[kFix3HashSize + hashValue] = p->pos;
25633 +- maxLen = 2;
25634 +- offset = 0;
25635 +- if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
25636 +- {
25637 +- for (; maxLen != lenLimit; maxLen++)
25638 +- if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
25639 +- break;
25640 +- distances[0] = maxLen;
25641 +- distances[1] = delta2 - 1;
25642 +- offset = 2;
25643 +- if (maxLen == lenLimit)
25644 +- {
25645 +- SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
25646 +- MOVE_POS_RET;
25647 +- }
25648 +- }
25649 +- GET_MATCHES_FOOTER(offset, maxLen)
25651 ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MatchFinder_MovePos(p);
25653 + static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
25655 +@@ -583,108 +495,6 @@ static UInt32 Bt4_MatchFinder_GetMatches
25656 + GET_MATCHES_FOOTER(offset, maxLen)
25659 +-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
25661 +- UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
25662 +- GET_MATCHES_HEADER(4)
25664 +- HASH4_CALC;
25666 +- delta2 = p->pos - p->hash[ hash2Value];
25667 +- delta3 = p->pos - p->hash[kFix3HashSize + hash3Value];
25668 +- curMatch = p->hash[kFix4HashSize + hashValue];
25670 +- p->hash[ hash2Value] =
25671 +- p->hash[kFix3HashSize + hash3Value] =
25672 +- p->hash[kFix4HashSize + hashValue] = p->pos;
25674 +- maxLen = 1;
25675 +- offset = 0;
25676 +- if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
25677 +- {
25678 +- distances[0] = maxLen = 2;
25679 +- distances[1] = delta2 - 1;
25680 +- offset = 2;
25681 +- }
25682 +- if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur)
25683 +- {
25684 +- maxLen = 3;
25685 +- distances[offset + 1] = delta3 - 1;
25686 +- offset += 2;
25687 +- delta2 = delta3;
25688 +- }
25689 +- if (offset != 0)
25690 +- {
25691 +- for (; maxLen != lenLimit; maxLen++)
25692 +- if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
25693 +- break;
25694 +- distances[offset - 2] = maxLen;
25695 +- if (maxLen == lenLimit)
25696 +- {
25697 +- p->son[p->cyclicBufferPos] = curMatch;
25698 +- MOVE_POS_RET;
25699 +- }
25700 +- }
25701 +- if (maxLen < 3)
25702 +- maxLen = 3;
25703 +- offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
25704 +- distances + offset, maxLen) - (distances));
25705 +- MOVE_POS_RET
25708 +-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
25710 +- UInt32 offset;
25711 +- GET_MATCHES_HEADER(3)
25712 +- HASH_ZIP_CALC;
25713 +- curMatch = p->hash[hashValue];
25714 +- p->hash[hashValue] = p->pos;
25715 +- offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
25716 +- distances, 2) - (distances));
25717 +- MOVE_POS_RET
25720 +-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
25722 +- do
25723 +- {
25724 +- SKIP_HEADER(2)
25725 +- HASH2_CALC;
25726 +- curMatch = p->hash[hashValue];
25727 +- p->hash[hashValue] = p->pos;
25728 +- SKIP_FOOTER
25729 +- }
25730 +- while (--num != 0);
25733 +-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
25735 +- do
25736 +- {
25737 +- SKIP_HEADER(3)
25738 +- HASH_ZIP_CALC;
25739 +- curMatch = p->hash[hashValue];
25740 +- p->hash[hashValue] = p->pos;
25741 +- SKIP_FOOTER
25742 +- }
25743 +- while (--num != 0);
25746 +-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
25748 +- do
25749 +- {
25750 +- UInt32 hash2Value;
25751 +- SKIP_HEADER(3)
25752 +- HASH3_CALC;
25753 +- curMatch = p->hash[kFix3HashSize + hashValue];
25754 +- p->hash[hash2Value] =
25755 +- p->hash[kFix3HashSize + hashValue] = p->pos;
25756 +- SKIP_FOOTER
25757 +- }
25758 +- while (--num != 0);
25761 + static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
25763 + do
25764 +@@ -701,61 +511,12 @@ static void Bt4_MatchFinder_Skip(CMatchF
25765 + while (--num != 0);
25768 +-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
25770 +- do
25771 +- {
25772 +- UInt32 hash2Value, hash3Value;
25773 +- SKIP_HEADER(4)
25774 +- HASH4_CALC;
25775 +- curMatch = p->hash[kFix4HashSize + hashValue];
25776 +- p->hash[ hash2Value] =
25777 +- p->hash[kFix3HashSize + hash3Value] =
25778 +- p->hash[kFix4HashSize + hashValue] = p->pos;
25779 +- p->son[p->cyclicBufferPos] = curMatch;
25780 +- MOVE_POS
25781 +- }
25782 +- while (--num != 0);
25785 +-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
25787 +- do
25788 +- {
25789 +- SKIP_HEADER(3)
25790 +- HASH_ZIP_CALC;
25791 +- curMatch = p->hash[hashValue];
25792 +- p->hash[hashValue] = p->pos;
25793 +- p->son[p->cyclicBufferPos] = curMatch;
25794 +- MOVE_POS
25795 +- }
25796 +- while (--num != 0);
25799 + void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
25801 + vTable->Init = (Mf_Init_Func)MatchFinder_Init;
25802 + vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
25803 + vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
25804 + vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
25805 +- if (!p->btMode)
25806 +- {
25807 +- vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
25808 +- vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
25809 +- }
25810 +- else if (p->numHashBytes == 2)
25811 +- {
25812 +- vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
25813 +- vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
25814 +- }
25815 +- else if (p->numHashBytes == 3)
25816 +- {
25817 +- vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
25818 +- vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
25819 +- }
25820 +- else
25821 +- {
25822 +- vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
25823 +- vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
25824 +- }
25825 ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
25826 ++ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
25828 diff --git a/target/linux/generic/patches-3.16/532-jffs2_eofdetect.patch b/target/linux/generic/patches-3.16/532-jffs2_eofdetect.patch
25829 new file mode 100644
25830 index 000000000000..269179063cd4
25831 --- /dev/null
25832 +++ b/target/linux/generic/patches-3.16/532-jffs2_eofdetect.patch
25833 @@ -0,0 +1,56 @@
25834 +--- a/fs/jffs2/build.c
25835 ++++ b/fs/jffs2/build.c
25836 +@@ -114,6 +114,16 @@ static int jffs2_build_filesystem(struct
25837 + dbg_fsbuild("scanned flash completely\n");
25838 + jffs2_dbg_dump_block_lists_nolock(c);
25840 ++ if (c->flags & (1 << 7)) {
25841 ++ printk("%s(): unlocking the mtd device... ", __func__);
25842 ++ mtd_unlock(c->mtd, 0, c->mtd->size);
25843 ++ printk("done.\n");
25845 ++ printk("%s(): erasing all blocks after the end marker... ", __func__);
25846 ++ jffs2_erase_pending_blocks(c, -1);
25847 ++ printk("done.\n");
25848 ++ }
25850 + dbg_fsbuild("pass 1 starting\n");
25851 + c->flags |= JFFS2_SB_FLAG_BUILDING;
25852 + /* Now scan the directory tree, increasing nlink according to every dirent found. */
25853 +--- a/fs/jffs2/scan.c
25854 ++++ b/fs/jffs2/scan.c
25855 +@@ -148,8 +148,14 @@ int jffs2_scan_medium(struct jffs2_sb_in
25856 + /* reset summary info for next eraseblock scan */
25857 + jffs2_sum_reset_collected(s);
25859 +- ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
25860 +- buf_size, s);
25861 ++ if (c->flags & (1 << 7)) {
25862 ++ if (mtd_block_isbad(c->mtd, jeb->offset))
25863 ++ ret = BLK_STATE_BADBLOCK;
25864 ++ else
25865 ++ ret = BLK_STATE_ALLFF;
25866 ++ } else
25867 ++ ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
25868 ++ buf_size, s);
25870 + if (ret < 0)
25871 + goto out;
25872 +@@ -556,6 +562,17 @@ static int jffs2_scan_eraseblock (struct
25873 + return err;
25876 ++ if ((buf[0] == 0xde) &&
25877 ++ (buf[1] == 0xad) &&
25878 ++ (buf[2] == 0xc0) &&
25879 ++ (buf[3] == 0xde)) {
25880 ++ /* end of filesystem. erase everything after this point */
25881 ++ printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
25882 ++ c->flags |= (1 << 7);
25884 ++ return BLK_STATE_ALLFF;
25885 ++ }
25887 + /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
25888 + ofs = 0;
25889 + max_ofs = EMPTY_SCAN_SIZE(c->sector_size);
25890 diff --git a/target/linux/generic/patches-3.16/540-crypto-xz-decompression-support.patch b/target/linux/generic/patches-3.16/540-crypto-xz-decompression-support.patch
25891 new file mode 100644
25892 index 000000000000..fbbda7699593
25893 --- /dev/null
25894 +++ b/target/linux/generic/patches-3.16/540-crypto-xz-decompression-support.patch
25895 @@ -0,0 +1,146 @@
25896 +--- a/crypto/Kconfig
25897 ++++ b/crypto/Kconfig
25898 +@@ -1367,6 +1367,13 @@ config CRYPTO_LZ4HC
25899 + help
25900 + This is the LZ4 high compression mode algorithm.
25902 ++config CRYPTO_XZ
25903 ++ tristate "XZ compression algorithm"
25904 ++ select CRYPTO_ALGAPI
25905 ++ select XZ_DEC
25906 ++ help
25907 ++ This is the XZ algorithm. Only decompression is supported for now.
25909 + comment "Random Number Generation"
25911 + config CRYPTO_ANSI_CPRNG
25912 +--- a/crypto/Makefile
25913 ++++ b/crypto/Makefile
25914 +@@ -88,6 +88,7 @@ obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.
25915 + obj-$(CONFIG_CRYPTO_LZO) += lzo.o
25916 + obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
25917 + obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
25918 ++obj-$(CONFIG_CRYPTO_XZ) += xz.o
25919 + obj-$(CONFIG_CRYPTO_842) += 842.o
25920 + obj-$(CONFIG_CRYPTO_RNG2) += rng.o
25921 + obj-$(CONFIG_CRYPTO_RNG2) += krng.o
25922 +--- /dev/null
25923 ++++ b/crypto/xz.c
25924 +@@ -0,0 +1,117 @@
25925 ++/*
25926 ++ * Cryptographic API.
25927 ++ *
25928 ++ * XZ decompression support.
25929 ++ *
25930 ++ * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
25931 ++ *
25932 ++ * This program is free software; you can redistribute it and/or modify it
25933 ++ * under the terms of the GNU General Public License version 2 as published by
25934 ++ * the Free Software Foundation.
25935 ++ *
25936 ++ */
25937 ++#include <linux/init.h>
25938 ++#include <linux/module.h>
25939 ++#include <linux/crypto.h>
25940 ++#include <linux/xz.h>
25941 ++#include <linux/interrupt.h>
25942 ++#include <linux/mm.h>
25943 ++#include <linux/net.h>
25945 ++struct xz_comp_ctx {
25946 ++ struct xz_dec *decomp_state;
25947 ++ struct xz_buf decomp_buf;
25948 ++};
25950 ++static int crypto_xz_decomp_init(struct xz_comp_ctx *ctx)
25952 ++ ctx->decomp_state = xz_dec_init(XZ_SINGLE, 0);
25953 ++ if (!ctx->decomp_state)
25954 ++ return -ENOMEM;
25956 ++ return 0;
25959 ++static void crypto_xz_decomp_exit(struct xz_comp_ctx *ctx)
25961 ++ xz_dec_end(ctx->decomp_state);
25964 ++static int crypto_xz_init(struct crypto_tfm *tfm)
25966 ++ struct xz_comp_ctx *ctx = crypto_tfm_ctx(tfm);
25968 ++ return crypto_xz_decomp_init(ctx);
25971 ++static void crypto_xz_exit(struct crypto_tfm *tfm)
25973 ++ struct xz_comp_ctx *ctx = crypto_tfm_ctx(tfm);
25975 ++ crypto_xz_decomp_exit(ctx);
25978 ++static int crypto_xz_compress(struct crypto_tfm *tfm, const u8 *src,
25979 ++ unsigned int slen, u8 *dst, unsigned int *dlen)
25981 ++ return -EOPNOTSUPP;
25984 ++static int crypto_xz_decompress(struct crypto_tfm *tfm, const u8 *src,
25985 ++ unsigned int slen, u8 *dst, unsigned int *dlen)
25987 ++ struct xz_comp_ctx *dctx = crypto_tfm_ctx(tfm);
25988 ++ struct xz_buf *xz_buf = &dctx->decomp_buf;
25989 ++ int ret;
25991 ++ memset(xz_buf, '\0', sizeof(struct xz_buf));
25993 ++ xz_buf->in = (u8 *) src;
25994 ++ xz_buf->in_pos = 0;
25995 ++ xz_buf->in_size = slen;
25996 ++ xz_buf->out = (u8 *) dst;
25997 ++ xz_buf->out_pos = 0;
25998 ++ xz_buf->out_size = *dlen;
26000 ++ ret = xz_dec_run(dctx->decomp_state, xz_buf);
26001 ++ if (ret != XZ_STREAM_END) {
26002 ++ ret = -EINVAL;
26003 ++ goto out;
26004 ++ }
26006 ++ *dlen = xz_buf->out_pos;
26007 ++ ret = 0;
26009 ++out:
26010 ++ return ret;
26013 ++static struct crypto_alg crypto_xz_alg = {
26014 ++ .cra_name = "xz",
26015 ++ .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
26016 ++ .cra_ctxsize = sizeof(struct xz_comp_ctx),
26017 ++ .cra_module = THIS_MODULE,
26018 ++ .cra_list = LIST_HEAD_INIT(crypto_xz_alg.cra_list),
26019 ++ .cra_init = crypto_xz_init,
26020 ++ .cra_exit = crypto_xz_exit,
26021 ++ .cra_u = { .compress = {
26022 ++ .coa_compress = crypto_xz_compress,
26023 ++ .coa_decompress = crypto_xz_decompress } }
26024 ++};
26026 ++static int __init crypto_xz_mod_init(void)
26028 ++ return crypto_register_alg(&crypto_xz_alg);
26031 ++static void __exit crypto_xz_mod_exit(void)
26033 ++ crypto_unregister_alg(&crypto_xz_alg);
26036 ++module_init(crypto_xz_mod_init);
26037 ++module_exit(crypto_xz_mod_exit);
26039 ++MODULE_LICENSE("GPL v2");
26040 ++MODULE_DESCRIPTION("Crypto XZ decompression support");
26041 ++MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
26042 diff --git a/target/linux/generic/patches-3.16/541-ubifs-xz-decompression-support.patch b/target/linux/generic/patches-3.16/541-ubifs-xz-decompression-support.patch
26043 new file mode 100644
26044 index 000000000000..f85689c58663
26045 --- /dev/null
26046 +++ b/target/linux/generic/patches-3.16/541-ubifs-xz-decompression-support.patch
26047 @@ -0,0 +1,92 @@
26048 +--- a/fs/ubifs/Kconfig
26049 ++++ b/fs/ubifs/Kconfig
26050 +@@ -5,8 +5,10 @@ config UBIFS_FS
26051 + select CRYPTO if UBIFS_FS_ADVANCED_COMPR
26052 + select CRYPTO if UBIFS_FS_LZO
26053 + select CRYPTO if UBIFS_FS_ZLIB
26054 ++ select CRYPTO if UBIFS_FS_XZ
26055 + select CRYPTO_LZO if UBIFS_FS_LZO
26056 + select CRYPTO_DEFLATE if UBIFS_FS_ZLIB
26057 ++ select CRYPTO_XZ if UBIFS_FS_XZ
26058 + depends on MTD_UBI
26059 + help
26060 + UBIFS is a file system for flash devices which works on top of UBI.
26061 +@@ -35,3 +37,12 @@ config UBIFS_FS_ZLIB
26062 + default y
26063 + help
26064 + Zlib compresses better than LZO but it is slower. Say 'Y' if unsure.
26066 ++config UBIFS_FS_XZ
26067 ++ bool "XZ decompression support" if UBIFS_FS_ADVANCED_COMPR
26068 ++ depends on UBIFS_FS
26069 ++ default y
26070 ++ help
26071 ++ XZ compresses better the ZLIB but it is slower..
26072 ++ Say 'Y' if unsure.
26074 +--- a/fs/ubifs/compress.c
26075 ++++ b/fs/ubifs/compress.c
26076 +@@ -71,6 +71,24 @@ static struct ubifs_compressor zlib_comp
26077 + };
26078 + #endif
26080 ++#ifdef CONFIG_UBIFS_FS_XZ
26081 ++static DEFINE_MUTEX(xz_enc_mutex);
26082 ++static DEFINE_MUTEX(xz_dec_mutex);
26084 ++static struct ubifs_compressor xz_compr = {
26085 ++ .compr_type = UBIFS_COMPR_XZ,
26086 ++ .comp_mutex = &xz_enc_mutex,
26087 ++ .decomp_mutex = &xz_dec_mutex,
26088 ++ .name = "xz",
26089 ++ .capi_name = "xz",
26090 ++};
26091 ++#else
26092 ++static struct ubifs_compressor xz_compr = {
26093 ++ .compr_type = UBIFS_COMPR_XZ,
26094 ++ .name = "xz",
26095 ++};
26096 ++#endif
26098 + /* All UBIFS compressors */
26099 + struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
26101 +@@ -232,9 +250,15 @@ int __init ubifs_compressors_init(void)
26102 + if (err)
26103 + goto out_lzo;
26105 ++ err = compr_init(&xz_compr);
26106 ++ if (err)
26107 ++ goto out_zlib;
26109 + ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr;
26110 + return 0;
26112 ++out_zlib:
26113 ++ compr_exit(&zlib_compr);
26114 + out_lzo:
26115 + compr_exit(&lzo_compr);
26116 + return err;
26117 +@@ -247,4 +271,5 @@ void ubifs_compressors_exit(void)
26119 + compr_exit(&lzo_compr);
26120 + compr_exit(&zlib_compr);
26121 ++ compr_exit(&xz_compr);
26123 +--- a/fs/ubifs/ubifs-media.h
26124 ++++ b/fs/ubifs/ubifs-media.h
26125 +@@ -332,12 +332,14 @@ enum {
26126 + * UBIFS_COMPR_NONE: no compression
26127 + * UBIFS_COMPR_LZO: LZO compression
26128 + * UBIFS_COMPR_ZLIB: ZLIB compression
26129 ++ * UBIFS_COMPR_XZ: XZ compression
26130 + * UBIFS_COMPR_TYPES_CNT: count of supported compression types
26131 + */
26132 + enum {
26133 + UBIFS_COMPR_NONE,
26134 + UBIFS_COMPR_LZO,
26135 + UBIFS_COMPR_ZLIB,
26136 ++ UBIFS_COMPR_XZ,
26137 + UBIFS_COMPR_TYPES_CNT,
26138 + };
26140 diff --git a/target/linux/generic/patches-3.16/550-ubifs-symlink-xattr-support.patch b/target/linux/generic/patches-3.16/550-ubifs-symlink-xattr-support.patch
26141 new file mode 100644
26142 index 000000000000..0235340aa875
26143 --- /dev/null
26144 +++ b/target/linux/generic/patches-3.16/550-ubifs-symlink-xattr-support.patch
26145 @@ -0,0 +1,65 @@
26146 +--- a/fs/ubifs/file.c
26147 ++++ b/fs/ubifs/file.c
26148 +@@ -1576,6 +1576,10 @@ const struct inode_operations ubifs_syml
26149 + .follow_link = ubifs_follow_link,
26150 + .setattr = ubifs_setattr,
26151 + .getattr = ubifs_getattr,
26152 ++ .setxattr = ubifs_setxattr,
26153 ++ .getxattr = ubifs_getxattr,
26154 ++ .listxattr = ubifs_listxattr,
26155 ++ .removexattr = ubifs_removexattr,
26156 + };
26158 + const struct file_operations ubifs_file_operations = {
26159 +--- a/fs/ubifs/journal.c
26160 ++++ b/fs/ubifs/journal.c
26161 +@@ -553,7 +553,8 @@ int ubifs_jnl_update(struct ubifs_info *
26163 + dbg_jnl("ino %lu, dent '%.*s', data len %d in dir ino %lu",
26164 + inode->i_ino, nm->len, nm->name, ui->data_len, dir->i_ino);
26165 +- ubifs_assert(dir_ui->data_len == 0);
26166 ++ if (!xent)
26167 ++ ubifs_assert(dir_ui->data_len == 0);
26168 + ubifs_assert(mutex_is_locked(&dir_ui->ui_mutex));
26170 + dlen = UBIFS_DENT_NODE_SZ + nm->len + 1;
26171 +@@ -573,6 +574,13 @@ int ubifs_jnl_update(struct ubifs_info *
26172 + aligned_dlen = ALIGN(dlen, 8);
26173 + aligned_ilen = ALIGN(ilen, 8);
26174 + len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ;
26175 ++ if (xent) {
26176 ++ /*
26177 ++ * Make sure to account for dir_ui->data_len in
26178 ++ * length calculation in case there is extended attribute.
26179 ++ */
26180 ++ len += dir_ui->data_len;
26181 ++ }
26182 + dent = kmalloc(len, GFP_NOFS);
26183 + if (!dent)
26184 + return -ENOMEM;
26185 +@@ -649,7 +657,8 @@ int ubifs_jnl_update(struct ubifs_info *
26187 + ino_key_init(c, &ino_key, dir->i_ino);
26188 + ino_offs += aligned_ilen;
26189 +- err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, UBIFS_INO_NODE_SZ);
26190 ++ err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs,
26191 ++ UBIFS_INO_NODE_SZ + dir_ui->data_len);
26192 + if (err)
26193 + goto out_ro;
26195 +--- a/fs/ubifs/xattr.c
26196 ++++ b/fs/ubifs/xattr.c
26197 +@@ -209,12 +209,12 @@ static int change_xattr(struct ubifs_inf
26198 + goto out_free;
26200 + inode->i_size = ui->ui_size = size;
26201 +- ui->data_len = size;
26203 + mutex_lock(&host_ui->ui_mutex);
26204 + host->i_ctime = ubifs_current_time(host);
26205 + host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
26206 + host_ui->xattr_size += CALC_XATTR_BYTES(size);
26207 ++ ui->data_len = size;
26209 + /*
26210 + * It is important to write the host inode after the xattr inode
26211 diff --git a/target/linux/generic/patches-3.16/551-ubifs-fix-default-compression-selection.patch b/target/linux/generic/patches-3.16/551-ubifs-fix-default-compression-selection.patch
26212 new file mode 100644
26213 index 000000000000..1b0f30718cf7
26214 --- /dev/null
26215 +++ b/target/linux/generic/patches-3.16/551-ubifs-fix-default-compression-selection.patch
26216 @@ -0,0 +1,29 @@
26217 +--- a/fs/ubifs/sb.c
26218 ++++ b/fs/ubifs/sb.c
26219 +@@ -63,6 +63,17 @@
26220 + /* Default time granularity in nanoseconds */
26221 + #define DEFAULT_TIME_GRAN 1000000000
26223 ++static int get_default_compressor(void)
26225 ++ if (ubifs_compr_present(UBIFS_COMPR_LZO))
26226 ++ return UBIFS_COMPR_LZO;
26228 ++ if (ubifs_compr_present(UBIFS_COMPR_ZLIB))
26229 ++ return UBIFS_COMPR_ZLIB;
26231 ++ return UBIFS_COMPR_NONE;
26234 + /**
26235 + * create_default_filesystem - format empty UBI volume.
26236 + * @c: UBIFS file-system description object
26237 +@@ -183,7 +194,7 @@ static int create_default_filesystem(str
26238 + if (c->mount_opts.override_compr)
26239 + sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
26240 + else
26241 +- sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
26242 ++ sup->default_compr = cpu_to_le16(get_default_compressor());
26244 + generate_random_uuid(sup->uuid);
26246 diff --git a/target/linux/generic/patches-3.16/600-netfilter_layer7_2.22.patch b/target/linux/generic/patches-3.16/600-netfilter_layer7_2.22.patch
26247 new file mode 100644
26248 index 000000000000..f53f39a8236d
26249 --- /dev/null
26250 +++ b/target/linux/generic/patches-3.16/600-netfilter_layer7_2.22.patch
26251 @@ -0,0 +1,2141 @@
26252 +--- a/net/netfilter/Kconfig
26253 ++++ b/net/netfilter/Kconfig
26254 +@@ -1345,6 +1345,27 @@ config NETFILTER_XT_MATCH_STATE
26256 + To compile it as a module, choose M here. If unsure, say N.
26258 ++config NETFILTER_XT_MATCH_LAYER7
26259 ++ tristate '"layer7" match support'
26260 ++ depends on NETFILTER_XTABLES
26261 ++ depends on EXPERIMENTAL && (IP_NF_CONNTRACK || NF_CONNTRACK)
26262 ++ depends on NETFILTER_ADVANCED
26263 ++ help
26264 ++ Say Y if you want to be able to classify connections (and their
26265 ++ packets) based on regular expression matching of their application
26266 ++ layer data. This is one way to classify applications such as
26267 ++ peer-to-peer filesharing systems that do not always use the same
26268 ++ port.
26270 ++ To compile it as a module, choose M here. If unsure, say N.
26272 ++config NETFILTER_XT_MATCH_LAYER7_DEBUG
26273 ++ bool 'Layer 7 debugging output'
26274 ++ depends on NETFILTER_XT_MATCH_LAYER7
26275 ++ help
26276 ++ Say Y to get lots of debugging output.
26279 + config NETFILTER_XT_MATCH_STATISTIC
26280 + tristate '"statistic" match support'
26281 + depends on NETFILTER_ADVANCED
26282 +--- a/net/netfilter/Makefile
26283 ++++ b/net/netfilter/Makefile
26284 +@@ -158,6 +158,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_RECENT)
26285 + obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o
26286 + obj-$(CONFIG_NETFILTER_XT_MATCH_SOCKET) += xt_socket.o
26287 + obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o
26288 ++obj-$(CONFIG_NETFILTER_XT_MATCH_LAYER7) += xt_layer7.o
26289 + obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o
26290 + obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o
26291 + obj-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += xt_tcpmss.o
26292 +--- /dev/null
26293 ++++ b/net/netfilter/xt_layer7.c
26294 +@@ -0,0 +1,666 @@
26295 ++/*
26296 ++ Kernel module to match application layer (OSI layer 7) data in connections.
26298 ++ http://l7-filter.sf.net
26300 ++ (C) 2003-2009 Matthew Strait and Ethan Sommer.
26302 ++ This program is free software; you can redistribute it and/or
26303 ++ modify it under the terms of the GNU General Public License
26304 ++ as published by the Free Software Foundation; either version
26305 ++ 2 of the License, or (at your option) any later version.
26306 ++ http://www.gnu.org/licenses/gpl.txt
26308 ++ Based on ipt_string.c (C) 2000 Emmanuel Roger <winfield@freegates.be>,
26309 ++ xt_helper.c (C) 2002 Harald Welte and cls_layer7.c (C) 2003 Matthew Strait,
26310 ++ Ethan Sommer, Justin Levandoski.
26311 ++*/
26313 ++#include <linux/spinlock.h>
26314 ++#include <linux/version.h>
26315 ++#include <net/ip.h>
26316 ++#include <net/tcp.h>
26317 ++#include <linux/module.h>
26318 ++#include <linux/skbuff.h>
26319 ++#include <linux/netfilter.h>
26320 ++#include <net/netfilter/nf_conntrack.h>
26321 ++#include <net/netfilter/nf_conntrack_core.h>
26322 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
26323 ++#include <net/netfilter/nf_conntrack_extend.h>
26324 ++#include <net/netfilter/nf_conntrack_acct.h>
26325 ++#endif
26326 ++#include <linux/netfilter/x_tables.h>
26327 ++#include <linux/netfilter/xt_layer7.h>
26328 ++#include <linux/ctype.h>
26329 ++#include <linux/proc_fs.h>
26331 ++#include "regexp/regexp.c"
26333 ++MODULE_LICENSE("GPL");
26334 ++MODULE_AUTHOR("Matthew Strait <quadong@users.sf.net>, Ethan Sommer <sommere@users.sf.net>");
26335 ++MODULE_DESCRIPTION("iptables application layer match module");
26336 ++MODULE_ALIAS("ipt_layer7");
26337 ++MODULE_VERSION("2.21");
26339 ++static int maxdatalen = 2048; // this is the default
26340 ++module_param(maxdatalen, int, 0444);
26341 ++MODULE_PARM_DESC(maxdatalen, "maximum bytes of data looked at by l7-filter");
26342 ++#ifdef CONFIG_NETFILTER_XT_MATCH_LAYER7_DEBUG
26343 ++ #define DPRINTK(format,args...) printk(format,##args)
26344 ++#else
26345 ++ #define DPRINTK(format,args...)
26346 ++#endif
26348 ++/* Number of packets whose data we look at.
26349 ++This can be modified through /proc/net/layer7_numpackets */
26350 ++static int num_packets = 10;
26352 ++static struct pattern_cache {
26353 ++ char * regex_string;
26354 ++ regexp * pattern;
26355 ++ struct pattern_cache * next;
26356 ++} * first_pattern_cache = NULL;
26358 ++DEFINE_SPINLOCK(l7_lock);
26360 ++static int total_acct_packets(struct nf_conn *ct)
26362 ++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 26)
26363 ++ BUG_ON(ct == NULL);
26364 ++ return (ct->counters[IP_CT_DIR_ORIGINAL].packets + ct->counters[IP_CT_DIR_REPLY].packets);
26365 ++#else
26366 ++ struct nf_conn_counter *acct;
26368 ++ BUG_ON(ct == NULL);
26369 ++ acct = nf_conn_acct_find(ct);
26370 ++ if (!acct)
26371 ++ return 0;
26372 ++ return (atomic64_read(&acct[IP_CT_DIR_ORIGINAL].packets) + atomic64_read(&acct[IP_CT_DIR_REPLY].packets));
26373 ++#endif
26376 ++#ifdef CONFIG_IP_NF_MATCH_LAYER7_DEBUG
26377 ++/* Converts an unfriendly string into a friendly one by
26378 ++replacing unprintables with periods and all whitespace with " ". */
26379 ++static char * friendly_print(unsigned char * s)
26381 ++ char * f = kmalloc(strlen(s) + 1, GFP_ATOMIC);
26382 ++ int i;
26384 ++ if(!f) {
26385 ++ if (net_ratelimit())
26386 ++ printk(KERN_ERR "layer7: out of memory in "
26387 ++ "friendly_print, bailing.\n");
26388 ++ return NULL;
26389 ++ }
26391 ++ for(i = 0; i < strlen(s); i++){
26392 ++ if(isprint(s[i]) && s[i] < 128) f[i] = s[i];
26393 ++ else if(isspace(s[i])) f[i] = ' ';
26394 ++ else f[i] = '.';
26395 ++ }
26396 ++ f[i] = '\0';
26397 ++ return f;
26400 ++static char dec2hex(int i)
26402 ++ switch (i) {
26403 ++ case 0 ... 9:
26404 ++ return (i + '0');
26405 ++ break;
26406 ++ case 10 ... 15:
26407 ++ return (i - 10 + 'a');
26408 ++ break;
26409 ++ default:
26410 ++ if (net_ratelimit())
26411 ++ printk("layer7: Problem in dec2hex\n");
26412 ++ return '\0';
26413 ++ }
26416 ++static char * hex_print(unsigned char * s)
26418 ++ char * g = kmalloc(strlen(s)*3 + 1, GFP_ATOMIC);
26419 ++ int i;
26421 ++ if(!g) {
26422 ++ if (net_ratelimit())
26423 ++ printk(KERN_ERR "layer7: out of memory in hex_print, "
26424 ++ "bailing.\n");
26425 ++ return NULL;
26426 ++ }
26428 ++ for(i = 0; i < strlen(s); i++) {
26429 ++ g[i*3 ] = dec2hex(s[i]/16);
26430 ++ g[i*3 + 1] = dec2hex(s[i]%16);
26431 ++ g[i*3 + 2] = ' ';
26432 ++ }
26433 ++ g[i*3] = '\0';
26435 ++ return g;
26437 ++#endif // DEBUG
26439 ++/* Use instead of regcomp. As we expect to be seeing the same regexps over and
26440 ++over again, it make sense to cache the results. */
26441 ++static regexp * compile_and_cache(const char * regex_string,
26442 ++ const char * protocol)
26444 ++ struct pattern_cache * node = first_pattern_cache;
26445 ++ struct pattern_cache * last_pattern_cache = first_pattern_cache;
26446 ++ struct pattern_cache * tmp;
26447 ++ unsigned int len;
26449 ++ while (node != NULL) {
26450 ++ if (!strcmp(node->regex_string, regex_string))
26451 ++ return node->pattern;
26453 ++ last_pattern_cache = node;/* points at the last non-NULL node */
26454 ++ node = node->next;
26455 ++ }
26457 ++ /* If we reach the end of the list, then we have not yet cached
26458 ++ the pattern for this regex. Let's do that now.
26459 ++ Be paranoid about running out of memory to avoid list corruption. */
26460 ++ tmp = kmalloc(sizeof(struct pattern_cache), GFP_ATOMIC);
26462 ++ if(!tmp) {
26463 ++ if (net_ratelimit())
26464 ++ printk(KERN_ERR "layer7: out of memory in "
26465 ++ "compile_and_cache, bailing.\n");
26466 ++ return NULL;
26467 ++ }
26469 ++ tmp->regex_string = kmalloc(strlen(regex_string) + 1, GFP_ATOMIC);
26470 ++ tmp->pattern = kmalloc(sizeof(struct regexp), GFP_ATOMIC);
26471 ++ tmp->next = NULL;
26473 ++ if(!tmp->regex_string || !tmp->pattern) {
26474 ++ if (net_ratelimit())
26475 ++ printk(KERN_ERR "layer7: out of memory in "
26476 ++ "compile_and_cache, bailing.\n");
26477 ++ kfree(tmp->regex_string);
26478 ++ kfree(tmp->pattern);
26479 ++ kfree(tmp);
26480 ++ return NULL;
26481 ++ }
26483 ++ /* Ok. The new node is all ready now. */
26484 ++ node = tmp;
26486 ++ if(first_pattern_cache == NULL) /* list is empty */
26487 ++ first_pattern_cache = node; /* make node the beginning */
26488 ++ else
26489 ++ last_pattern_cache->next = node; /* attach node to the end */
26491 ++ /* copy the string and compile the regex */
26492 ++ len = strlen(regex_string);
26493 ++ DPRINTK("About to compile this: \"%s\"\n", regex_string);
26494 ++ node->pattern = regcomp((char *)regex_string, &len);
26495 ++ if ( !node->pattern ) {
26496 ++ if (net_ratelimit())
26497 ++ printk(KERN_ERR "layer7: Error compiling regexp "
26498 ++ "\"%s\" (%s)\n",
26499 ++ regex_string, protocol);
26500 ++ /* pattern is now cached as NULL, so we won't try again. */
26501 ++ }
26503 ++ strcpy(node->regex_string, regex_string);
26504 ++ return node->pattern;
26507 ++static int can_handle(const struct sk_buff *skb)
26509 ++ if(!ip_hdr(skb)) /* not IP */
26510 ++ return 0;
26511 ++ if(ip_hdr(skb)->protocol != IPPROTO_TCP &&
26512 ++ ip_hdr(skb)->protocol != IPPROTO_UDP &&
26513 ++ ip_hdr(skb)->protocol != IPPROTO_ICMP)
26514 ++ return 0;
26515 ++ return 1;
26518 ++/* Returns offset the into the skb->data that the application data starts */
26519 ++static int app_data_offset(const struct sk_buff *skb)
26521 ++ /* In case we are ported somewhere (ebtables?) where ip_hdr(skb)
26522 ++ isn't set, this can be gotten from 4*(skb->data[0] & 0x0f) as well. */
26523 ++ int ip_hl = 4*ip_hdr(skb)->ihl;
26525 ++ if( ip_hdr(skb)->protocol == IPPROTO_TCP ) {
26526 ++ /* 12 == offset into TCP header for the header length field.
26527 ++ Can't get this with skb->h.th->doff because the tcphdr
26528 ++ struct doesn't get set when routing (this is confirmed to be
26529 ++ true in Netfilter as well as QoS.) */
26530 ++ int tcp_hl = 4*(skb->data[ip_hl + 12] >> 4);
26532 ++ return ip_hl + tcp_hl;
26533 ++ } else if( ip_hdr(skb)->protocol == IPPROTO_UDP ) {
26534 ++ return ip_hl + 8; /* UDP header is always 8 bytes */
26535 ++ } else if( ip_hdr(skb)->protocol == IPPROTO_ICMP ) {
26536 ++ return ip_hl + 8; /* ICMP header is 8 bytes */
26537 ++ } else {
26538 ++ if (net_ratelimit())
26539 ++ printk(KERN_ERR "layer7: tried to handle unknown "
26540 ++ "protocol!\n");
26541 ++ return ip_hl + 8; /* something reasonable */
26542 ++ }
26545 ++/* handles whether there's a match when we aren't appending data anymore */
26546 ++static int match_no_append(struct nf_conn * conntrack,
26547 ++ struct nf_conn * master_conntrack,
26548 ++ enum ip_conntrack_info ctinfo,
26549 ++ enum ip_conntrack_info master_ctinfo,
26550 ++ const struct xt_layer7_info * info)
26552 ++ /* If we're in here, throw the app data away */
26553 ++ if(master_conntrack->layer7.app_data != NULL) {
26555 ++ #ifdef CONFIG_IP_NF_MATCH_LAYER7_DEBUG
26556 ++ if(!master_conntrack->layer7.app_proto) {
26557 ++ char * f =
26558 ++ friendly_print(master_conntrack->layer7.app_data);
26559 ++ char * g =
26560 ++ hex_print(master_conntrack->layer7.app_data);
26561 ++ DPRINTK("\nl7-filter gave up after %d bytes "
26562 ++ "(%d packets):\n%s\n",
26563 ++ strlen(f), total_acct_packets(master_conntrack), f);
26564 ++ kfree(f);
26565 ++ DPRINTK("In hex: %s\n", g);
26566 ++ kfree(g);
26567 ++ }
26568 ++ #endif
26570 ++ kfree(master_conntrack->layer7.app_data);
26571 ++ master_conntrack->layer7.app_data = NULL; /* don't free again */
26572 ++ }
26574 ++ if(master_conntrack->layer7.app_proto){
26575 ++ /* Here child connections set their .app_proto (for /proc) */
26576 ++ if(!conntrack->layer7.app_proto) {
26577 ++ conntrack->layer7.app_proto =
26578 ++ kmalloc(strlen(master_conntrack->layer7.app_proto)+1,
26579 ++ GFP_ATOMIC);
26580 ++ if(!conntrack->layer7.app_proto){
26581 ++ if (net_ratelimit())
26582 ++ printk(KERN_ERR "layer7: out of memory "
26583 ++ "in match_no_append, "
26584 ++ "bailing.\n");
26585 ++ return 1;
26586 ++ }
26587 ++ strcpy(conntrack->layer7.app_proto,
26588 ++ master_conntrack->layer7.app_proto);
26589 ++ }
26591 ++ return (!strcmp(master_conntrack->layer7.app_proto,
26592 ++ info->protocol));
26593 ++ }
26594 ++ else {
26595 ++ /* If not classified, set to "unknown" to distinguish from
26596 ++ connections that are still being tested. */
26597 ++ master_conntrack->layer7.app_proto =
26598 ++ kmalloc(strlen("unknown")+1, GFP_ATOMIC);
26599 ++ if(!master_conntrack->layer7.app_proto){
26600 ++ if (net_ratelimit())
26601 ++ printk(KERN_ERR "layer7: out of memory in "
26602 ++ "match_no_append, bailing.\n");
26603 ++ return 1;
26604 ++ }
26605 ++ strcpy(master_conntrack->layer7.app_proto, "unknown");
26606 ++ return 0;
26607 ++ }
26610 ++/* add the new app data to the conntrack. Return number of bytes added. */
26611 ++static int add_data(struct nf_conn * master_conntrack,
26612 ++ char * app_data, int appdatalen)
26614 ++ int length = 0, i;
26615 ++ int oldlength = master_conntrack->layer7.app_data_len;
26617 ++ /* This is a fix for a race condition by Deti Fliegl. However, I'm not
26618 ++ clear on whether the race condition exists or whether this really
26619 ++ fixes it. I might just be being dense... Anyway, if it's not really
26620 ++ a fix, all it does is waste a very small amount of time. */
26621 ++ if(!master_conntrack->layer7.app_data) return 0;
26623 ++ /* Strip nulls. Make everything lower case (our regex lib doesn't
26624 ++ do case insensitivity). Add it to the end of the current data. */
26625 ++ for(i = 0; i < maxdatalen-oldlength-1 &&
26626 ++ i < appdatalen; i++) {
26627 ++ if(app_data[i] != '\0') {
26628 ++ /* the kernel version of tolower mungs 'upper ascii' */
26629 ++ master_conntrack->layer7.app_data[length+oldlength] =
26630 ++ isascii(app_data[i])?
26631 ++ tolower(app_data[i]) : app_data[i];
26632 ++ length++;
26633 ++ }
26634 ++ }
26636 ++ master_conntrack->layer7.app_data[length+oldlength] = '\0';
26637 ++ master_conntrack->layer7.app_data_len = length + oldlength;
26639 ++ return length;
26642 ++/* taken from drivers/video/modedb.c */
26643 ++static int my_atoi(const char *s)
26645 ++ int val = 0;
26647 ++ for (;; s++) {
26648 ++ switch (*s) {
26649 ++ case '0'...'9':
26650 ++ val = 10*val+(*s-'0');
26651 ++ break;
26652 ++ default:
26653 ++ return val;
26654 ++ }
26655 ++ }
26658 ++/* write out num_packets to userland. */
26659 ++static int layer7_read_proc(char* page, char ** start, off_t off, int count,
26660 ++ int* eof, void * data)
26662 ++ if(num_packets > 99 && net_ratelimit())
26663 ++ printk(KERN_ERR "layer7: NOT REACHED. num_packets too big\n");
26665 ++ page[0] = num_packets/10 + '0';
26666 ++ page[1] = num_packets%10 + '0';
26667 ++ page[2] = '\n';
26668 ++ page[3] = '\0';
26670 ++ *eof=1;
26672 ++ return 3;
26675 ++/* Read in num_packets from userland */
26676 ++static int layer7_write_proc(struct file* file, const char* buffer,
26677 ++ unsigned long count, void *data)
26679 ++ char * foo = kmalloc(count, GFP_ATOMIC);
26681 ++ if(!foo){
26682 ++ if (net_ratelimit())
26683 ++ printk(KERN_ERR "layer7: out of memory, bailing. "
26684 ++ "num_packets unchanged.\n");
26685 ++ return count;
26686 ++ }
26688 ++ if(copy_from_user(foo, buffer, count)) {
26689 ++ return -EFAULT;
26690 ++ }
26693 ++ num_packets = my_atoi(foo);
26694 ++ kfree (foo);
26696 ++ /* This has an arbitrary limit to make the math easier. I'm lazy.
26697 ++ But anyway, 99 is a LOT! If you want more, you're doing it wrong! */
26698 ++ if(num_packets > 99) {
26699 ++ printk(KERN_WARNING "layer7: num_packets can't be > 99.\n");
26700 ++ num_packets = 99;
26701 ++ } else if(num_packets < 1) {
26702 ++ printk(KERN_WARNING "layer7: num_packets can't be < 1.\n");
26703 ++ num_packets = 1;
26704 ++ }
26706 ++ return count;
26709 ++static bool
26710 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
26711 ++match(const struct sk_buff *skbin, const struct xt_match_param *par)
26712 ++#else
26713 ++match(const struct sk_buff *skbin,
26714 ++ const struct net_device *in,
26715 ++ const struct net_device *out,
26716 ++ const struct xt_match *match,
26717 ++ const void *matchinfo,
26718 ++ int offset,
26719 ++ unsigned int protoff,
26720 ++ bool *hotdrop)
26721 ++#endif
26723 ++ /* sidestep const without getting a compiler warning... */
26724 ++ struct sk_buff * skb = (struct sk_buff *)skbin;
26726 ++ const struct xt_layer7_info * info =
26727 ++ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
26728 ++ par->matchinfo;
26729 ++ #else
26730 ++ matchinfo;
26731 ++ #endif
26733 ++ enum ip_conntrack_info master_ctinfo, ctinfo;
26734 ++ struct nf_conn *master_conntrack, *conntrack;
26735 ++ unsigned char * app_data;
26736 ++ unsigned int pattern_result, appdatalen;
26737 ++ regexp * comppattern;
26739 ++ /* Be paranoid/incompetent - lock the entire match function. */
26740 ++ spin_lock_bh(&l7_lock);
26742 ++ if(!can_handle(skb)){
26743 ++ DPRINTK("layer7: This is some protocol I can't handle.\n");
26744 ++ spin_unlock_bh(&l7_lock);
26745 ++ return info->invert;
26746 ++ }
26748 ++ /* Treat parent & all its children together as one connection, except
26749 ++ for the purpose of setting conntrack->layer7.app_proto in the actual
26750 ++ connection. This makes /proc/net/ip_conntrack more satisfying. */
26751 ++ if(!(conntrack = nf_ct_get(skb, &ctinfo)) ||
26752 ++ !(master_conntrack=nf_ct_get(skb,&master_ctinfo))){
26753 ++ DPRINTK("layer7: couldn't get conntrack.\n");
26754 ++ spin_unlock_bh(&l7_lock);
26755 ++ return info->invert;
26756 ++ }
26758 ++ /* Try to get a master conntrack (and its master etc) for FTP, etc. */
26759 ++ while (master_ct(master_conntrack) != NULL)
26760 ++ master_conntrack = master_ct(master_conntrack);
26762 ++ /* if we've classified it or seen too many packets */
26763 ++ if(total_acct_packets(master_conntrack) > num_packets ||
26764 ++ master_conntrack->layer7.app_proto) {
26766 ++ pattern_result = match_no_append(conntrack, master_conntrack,
26767 ++ ctinfo, master_ctinfo, info);
26769 ++ /* skb->cb[0] == seen. Don't do things twice if there are
26770 ++ multiple l7 rules. I'm not sure that using cb for this purpose
26771 ++ is correct, even though it says "put your private variables
26772 ++ there". But it doesn't look like it is being used for anything
26773 ++ else in the skbs that make it here. */
26774 ++ skb->cb[0] = 1; /* marking it seen here's probably irrelevant */
26776 ++ spin_unlock_bh(&l7_lock);
26777 ++ return (pattern_result ^ info->invert);
26778 ++ }
26780 ++ if(skb_is_nonlinear(skb)){
26781 ++ if(skb_linearize(skb) != 0){
26782 ++ if (net_ratelimit())
26783 ++ printk(KERN_ERR "layer7: failed to linearize "
26784 ++ "packet, bailing.\n");
26785 ++ spin_unlock_bh(&l7_lock);
26786 ++ return info->invert;
26787 ++ }
26788 ++ }
26790 ++ /* now that the skb is linearized, it's safe to set these. */
26791 ++ app_data = skb->data + app_data_offset(skb);
26792 ++ appdatalen = skb_tail_pointer(skb) - app_data;
26794 ++ /* the return value gets checked later, when we're ready to use it */
26795 ++ comppattern = compile_and_cache(info->pattern, info->protocol);
26797 ++ /* On the first packet of a connection, allocate space for app data */
26798 ++ if(total_acct_packets(master_conntrack) == 1 && !skb->cb[0] &&
26799 ++ !master_conntrack->layer7.app_data){
26800 ++ master_conntrack->layer7.app_data =
26801 ++ kmalloc(maxdatalen, GFP_ATOMIC);
26802 ++ if(!master_conntrack->layer7.app_data){
26803 ++ if (net_ratelimit())
26804 ++ printk(KERN_ERR "layer7: out of memory in "
26805 ++ "match, bailing.\n");
26806 ++ spin_unlock_bh(&l7_lock);
26807 ++ return info->invert;
26808 ++ }
26810 ++ master_conntrack->layer7.app_data[0] = '\0';
26811 ++ }
26813 ++ /* Can be here, but unallocated, if numpackets is increased near
26814 ++ the beginning of a connection */
26815 ++ if(master_conntrack->layer7.app_data == NULL){
26816 ++ spin_unlock_bh(&l7_lock);
26817 ++ return info->invert; /* unmatched */
26818 ++ }
26820 ++ if(!skb->cb[0]){
26821 ++ int newbytes;
26822 ++ newbytes = add_data(master_conntrack, app_data, appdatalen);
26824 ++ if(newbytes == 0) { /* didn't add any data */
26825 ++ skb->cb[0] = 1;
26826 ++ /* Didn't match before, not going to match now */
26827 ++ spin_unlock_bh(&l7_lock);
26828 ++ return info->invert;
26829 ++ }
26830 ++ }
26832 ++ /* If looking for "unknown", then never match. "Unknown" means that
26833 ++ we've given up; we're still trying with these packets. */
26834 ++ if(!strcmp(info->protocol, "unknown")) {
26835 ++ pattern_result = 0;
26836 ++ /* If looking for "unset", then always match. "Unset" means that we
26837 ++ haven't yet classified the connection. */
26838 ++ } else if(!strcmp(info->protocol, "unset")) {
26839 ++ pattern_result = 2;
26840 ++ DPRINTK("layer7: matched unset: not yet classified "
26841 ++ "(%d/%d packets)\n",
26842 ++ total_acct_packets(master_conntrack), num_packets);
26843 ++ /* If the regexp failed to compile, don't bother running it */
26844 ++ } else if(comppattern &&
26845 ++ regexec(comppattern, master_conntrack->layer7.app_data)){
26846 ++ DPRINTK("layer7: matched %s\n", info->protocol);
26847 ++ pattern_result = 1;
26848 ++ } else pattern_result = 0;
26850 ++ if(pattern_result == 1) {
26851 ++ master_conntrack->layer7.app_proto =
26852 ++ kmalloc(strlen(info->protocol)+1, GFP_ATOMIC);
26853 ++ if(!master_conntrack->layer7.app_proto){
26854 ++ if (net_ratelimit())
26855 ++ printk(KERN_ERR "layer7: out of memory in "
26856 ++ "match, bailing.\n");
26857 ++ spin_unlock_bh(&l7_lock);
26858 ++ return (pattern_result ^ info->invert);
26859 ++ }
26860 ++ strcpy(master_conntrack->layer7.app_proto, info->protocol);
26861 ++ } else if(pattern_result > 1) { /* cleanup from "unset" */
26862 ++ pattern_result = 1;
26863 ++ }
26865 ++ /* mark the packet seen */
26866 ++ skb->cb[0] = 1;
26868 ++ spin_unlock_bh(&l7_lock);
26869 ++ return (pattern_result ^ info->invert);
26872 ++// load nf_conntrack_ipv4
26873 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
26874 ++static bool check(const struct xt_mtchk_param *par)
26876 ++ if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
26877 ++ printk(KERN_WARNING "can't load conntrack support for "
26878 ++ "proto=%d\n", par->match->family);
26879 ++#else
26880 ++static bool check(const char *tablename, const void *inf,
26881 ++ const struct xt_match *match, void *matchinfo,
26882 ++ unsigned int hook_mask)
26884 ++ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
26885 ++ printk(KERN_WARNING "can't load conntrack support for "
26886 ++ "proto=%d\n", match->family);
26887 ++#endif
26888 ++ return 0;
26889 ++ }
26890 ++ return 1;
26894 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
26895 ++ static void destroy(const struct xt_mtdtor_param *par)
26896 ++ {
26897 ++ nf_ct_l3proto_module_put(par->match->family);
26898 ++ }
26899 ++#else
26900 ++ static void destroy(const struct xt_match *match, void *matchinfo)
26901 ++ {
26902 ++ nf_ct_l3proto_module_put(match->family);
26903 ++ }
26904 ++#endif
26906 ++static struct xt_match xt_layer7_match[] __read_mostly = {
26908 ++ .name = "layer7",
26909 ++ .family = AF_INET,
26910 ++ .checkentry = check,
26911 ++ .match = match,
26912 ++ .destroy = destroy,
26913 ++ .matchsize = sizeof(struct xt_layer7_info),
26914 ++ .me = THIS_MODULE
26916 ++};
26918 ++static void layer7_cleanup_proc(void)
26920 ++ remove_proc_entry("layer7_numpackets", init_net.proc_net);
26923 ++/* register the proc file */
26924 ++static void layer7_init_proc(void)
26926 ++ struct proc_dir_entry* entry;
26927 ++ entry = create_proc_entry("layer7_numpackets", 0644, init_net.proc_net);
26928 ++ entry->read_proc = layer7_read_proc;
26929 ++ entry->write_proc = layer7_write_proc;
26932 ++static int __init xt_layer7_init(void)
26934 ++ need_conntrack();
26936 ++ layer7_init_proc();
26937 ++ if(maxdatalen < 1) {
26938 ++ printk(KERN_WARNING "layer7: maxdatalen can't be < 1, "
26939 ++ "using 1\n");
26940 ++ maxdatalen = 1;
26941 ++ }
26942 ++ /* This is not a hard limit. It's just here to prevent people from
26943 ++ bringing their slow machines to a grinding halt. */
26944 ++ else if(maxdatalen > 65536) {
26945 ++ printk(KERN_WARNING "layer7: maxdatalen can't be > 65536, "
26946 ++ "using 65536\n");
26947 ++ maxdatalen = 65536;
26948 ++ }
26949 ++ return xt_register_matches(xt_layer7_match,
26950 ++ ARRAY_SIZE(xt_layer7_match));
26953 ++static void __exit xt_layer7_fini(void)
26955 ++ layer7_cleanup_proc();
26956 ++ xt_unregister_matches(xt_layer7_match, ARRAY_SIZE(xt_layer7_match));
26959 ++module_init(xt_layer7_init);
26960 ++module_exit(xt_layer7_fini);
26961 +--- /dev/null
26962 ++++ b/net/netfilter/regexp/regexp.c
26963 +@@ -0,0 +1,1197 @@
26964 ++/*
26965 ++ * regcomp and regexec -- regsub and regerror are elsewhere
26966 ++ * @(#)regexp.c 1.3 of 18 April 87
26967 ++ *
26968 ++ * Copyright (c) 1986 by University of Toronto.
26969 ++ * Written by Henry Spencer. Not derived from licensed software.
26970 ++ *
26971 ++ * Permission is granted to anyone to use this software for any
26972 ++ * purpose on any computer system, and to redistribute it freely,
26973 ++ * subject to the following restrictions:
26974 ++ *
26975 ++ * 1. The author is not responsible for the consequences of use of
26976 ++ * this software, no matter how awful, even if they arise
26977 ++ * from defects in it.
26978 ++ *
26979 ++ * 2. The origin of this software must not be misrepresented, either
26980 ++ * by explicit claim or by omission.
26981 ++ *
26982 ++ * 3. Altered versions must be plainly marked as such, and must not
26983 ++ * be misrepresented as being the original software.
26984 ++ *
26985 ++ * Beware that some of this code is subtly aware of the way operator
26986 ++ * precedence is structured in regular expressions. Serious changes in
26987 ++ * regular-expression syntax might require a total rethink.
26988 ++ *
26989 ++ * This code was modified by Ethan Sommer to work within the kernel
26990 ++ * (it now uses kmalloc etc..)
26991 ++ *
26992 ++ * Modified slightly by Matthew Strait to use more modern C.
26993 ++ */
26995 ++#include "regexp.h"
26996 ++#include "regmagic.h"
26998 ++/* added by ethan and matt. Lets it work in both kernel and user space.
26999 ++(So iptables can use it, for instance.) Yea, it goes both ways... */
27000 ++#if __KERNEL__
27001 ++ #define malloc(foo) kmalloc(foo,GFP_ATOMIC)
27002 ++#else
27003 ++ #define printk(format,args...) printf(format,##args)
27004 ++#endif
27006 ++void regerror(char * s)
27008 ++ printk("<3>Regexp: %s\n", s);
27009 ++ /* NOTREACHED */
27012 ++/*
27013 ++ * The "internal use only" fields in regexp.h are present to pass info from
27014 ++ * compile to execute that permits the execute phase to run lots faster on
27015 ++ * simple cases. They are:
27016 ++ *
27017 ++ * regstart char that must begin a match; '\0' if none obvious
27018 ++ * reganch is the match anchored (at beginning-of-line only)?
27019 ++ * regmust string (pointer into program) that match must include, or NULL
27020 ++ * regmlen length of regmust string
27021 ++ *
27022 ++ * Regstart and reganch permit very fast decisions on suitable starting points
27023 ++ * for a match, cutting down the work a lot. Regmust permits fast rejection
27024 ++ * of lines that cannot possibly match. The regmust tests are costly enough
27025 ++ * that regcomp() supplies a regmust only if the r.e. contains something
27026 ++ * potentially expensive (at present, the only such thing detected is * or +
27027 ++ * at the start of the r.e., which can involve a lot of backup). Regmlen is
27028 ++ * supplied because the test in regexec() needs it and regcomp() is computing
27029 ++ * it anyway.
27030 ++ */
27032 ++/*
27033 ++ * Structure for regexp "program". This is essentially a linear encoding
27034 ++ * of a nondeterministic finite-state machine (aka syntax charts or
27035 ++ * "railroad normal form" in parsing technology). Each node is an opcode
27036 ++ * plus a "next" pointer, possibly plus an operand. "Next" pointers of
27037 ++ * all nodes except BRANCH implement concatenation; a "next" pointer with
27038 ++ * a BRANCH on both ends of it is connecting two alternatives. (Here we
27039 ++ * have one of the subtle syntax dependencies: an individual BRANCH (as
27040 ++ * opposed to a collection of them) is never concatenated with anything
27041 ++ * because of operator precedence.) The operand of some types of node is
27042 ++ * a literal string; for others, it is a node leading into a sub-FSM. In
27043 ++ * particular, the operand of a BRANCH node is the first node of the branch.
27044 ++ * (NB this is *not* a tree structure: the tail of the branch connects
27045 ++ * to the thing following the set of BRANCHes.) The opcodes are:
27046 ++ */
27048 ++/* definition number opnd? meaning */
27049 ++#define END 0 /* no End of program. */
27050 ++#define BOL 1 /* no Match "" at beginning of line. */
27051 ++#define EOL 2 /* no Match "" at end of line. */
27052 ++#define ANY 3 /* no Match any one character. */
27053 ++#define ANYOF 4 /* str Match any character in this string. */
27054 ++#define ANYBUT 5 /* str Match any character not in this string. */
27055 ++#define BRANCH 6 /* node Match this alternative, or the next... */
27056 ++#define BACK 7 /* no Match "", "next" ptr points backward. */
27057 ++#define EXACTLY 8 /* str Match this string. */
27058 ++#define NOTHING 9 /* no Match empty string. */
27059 ++#define STAR 10 /* node Match this (simple) thing 0 or more times. */
27060 ++#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
27061 ++#define OPEN 20 /* no Mark this point in input as start of #n. */
27062 ++ /* OPEN+1 is number 1, etc. */
27063 ++#define CLOSE 30 /* no Analogous to OPEN. */
27065 ++/*
27066 ++ * Opcode notes:
27067 ++ *
27068 ++ * BRANCH The set of branches constituting a single choice are hooked
27069 ++ * together with their "next" pointers, since precedence prevents
27070 ++ * anything being concatenated to any individual branch. The
27071 ++ * "next" pointer of the last BRANCH in a choice points to the
27072 ++ * thing following the whole choice. This is also where the
27073 ++ * final "next" pointer of each individual branch points; each
27074 ++ * branch starts with the operand node of a BRANCH node.
27075 ++ *
27076 ++ * BACK Normal "next" pointers all implicitly point forward; BACK
27077 ++ * exists to make loop structures possible.
27078 ++ *
27079 ++ * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
27080 ++ * BRANCH structures using BACK. Simple cases (one character
27081 ++ * per match) are implemented with STAR and PLUS for speed
27082 ++ * and to minimize recursive plunges.
27083 ++ *
27084 ++ * OPEN,CLOSE ...are numbered at compile time.
27085 ++ */
27087 ++/*
27088 ++ * A node is one char of opcode followed by two chars of "next" pointer.
27089 ++ * "Next" pointers are stored as two 8-bit pieces, high order first. The
27090 ++ * value is a positive offset from the opcode of the node containing it.
27091 ++ * An operand, if any, simply follows the node. (Note that much of the
27092 ++ * code generation knows about this implicit relationship.)
27093 ++ *
27094 ++ * Using two bytes for the "next" pointer is vast overkill for most things,
27095 ++ * but allows patterns to get big without disasters.
27096 ++ */
27097 ++#define OP(p) (*(p))
27098 ++#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
27099 ++#define OPERAND(p) ((p) + 3)
27101 ++/*
27102 ++ * See regmagic.h for one further detail of program structure.
27103 ++ */
27106 ++/*
27107 ++ * Utility definitions.
27108 ++ */
27109 ++#ifndef CHARBITS
27110 ++#define UCHARAT(p) ((int)*(unsigned char *)(p))
27111 ++#else
27112 ++#define UCHARAT(p) ((int)*(p)&CHARBITS)
27113 ++#endif
27115 ++#define FAIL(m) { regerror(m); return(NULL); }
27116 ++#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
27117 ++#define META "^$.[()|?+*\\"
27119 ++/*
27120 ++ * Flags to be passed up and down.
27121 ++ */
27122 ++#define HASWIDTH 01 /* Known never to match null string. */
27123 ++#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
27124 ++#define SPSTART 04 /* Starts with * or +. */
27125 ++#define WORST 0 /* Worst case. */
27127 ++/*
27128 ++ * Global work variables for regcomp().
27129 ++ */
27130 ++struct match_globals {
27131 ++char *reginput; /* String-input pointer. */
27132 ++char *regbol; /* Beginning of input, for ^ check. */
27133 ++char **regstartp; /* Pointer to startp array. */
27134 ++char **regendp; /* Ditto for endp. */
27135 ++char *regparse; /* Input-scan pointer. */
27136 ++int regnpar; /* () count. */
27137 ++char regdummy;
27138 ++char *regcode; /* Code-emit pointer; &regdummy = don't. */
27139 ++long regsize; /* Code size. */
27140 ++};
27142 ++/*
27143 ++ * Forward declarations for regcomp()'s friends.
27144 ++ */
27145 ++#ifndef STATIC
27146 ++#define STATIC static
27147 ++#endif
27148 ++STATIC char *reg(struct match_globals *g, int paren,int *flagp);
27149 ++STATIC char *regbranch(struct match_globals *g, int *flagp);
27150 ++STATIC char *regpiece(struct match_globals *g, int *flagp);
27151 ++STATIC char *regatom(struct match_globals *g, int *flagp);
27152 ++STATIC char *regnode(struct match_globals *g, char op);
27153 ++STATIC char *regnext(struct match_globals *g, char *p);
27154 ++STATIC void regc(struct match_globals *g, char b);
27155 ++STATIC void reginsert(struct match_globals *g, char op, char *opnd);
27156 ++STATIC void regtail(struct match_globals *g, char *p, char *val);
27157 ++STATIC void regoptail(struct match_globals *g, char *p, char *val);
27160 ++__kernel_size_t my_strcspn(const char *s1,const char *s2)
27162 ++ char *scan1;
27163 ++ char *scan2;
27164 ++ int count;
27166 ++ count = 0;
27167 ++ for (scan1 = (char *)s1; *scan1 != '\0'; scan1++) {
27168 ++ for (scan2 = (char *)s2; *scan2 != '\0';) /* ++ moved down. */
27169 ++ if (*scan1 == *scan2++)
27170 ++ return(count);
27171 ++ count++;
27172 ++ }
27173 ++ return(count);
27176 ++/*
27177 ++ - regcomp - compile a regular expression into internal code
27178 ++ *
27179 ++ * We can't allocate space until we know how big the compiled form will be,
27180 ++ * but we can't compile it (and thus know how big it is) until we've got a
27181 ++ * place to put the code. So we cheat: we compile it twice, once with code
27182 ++ * generation turned off and size counting turned on, and once "for real".
27183 ++ * This also means that we don't allocate space until we are sure that the
27184 ++ * thing really will compile successfully, and we never have to move the
27185 ++ * code and thus invalidate pointers into it. (Note that it has to be in
27186 ++ * one piece because free() must be able to free it all.)
27187 ++ *
27188 ++ * Beware that the optimization-preparation code in here knows about some
27189 ++ * of the structure of the compiled regexp.
27190 ++ */
27191 ++regexp *
27192 ++regcomp(char *exp,int *patternsize)
27194 ++ register regexp *r;
27195 ++ register char *scan;
27196 ++ register char *longest;
27197 ++ register int len;
27198 ++ int flags;
27199 ++ struct match_globals g;
27201 ++ /* commented out by ethan
27202 ++ extern char *malloc();
27203 ++ */
27205 ++ if (exp == NULL)
27206 ++ FAIL("NULL argument");
27208 ++ /* First pass: determine size, legality. */
27209 ++ g.regparse = exp;
27210 ++ g.regnpar = 1;
27211 ++ g.regsize = 0L;
27212 ++ g.regcode = &g.regdummy;
27213 ++ regc(&g, MAGIC);
27214 ++ if (reg(&g, 0, &flags) == NULL)
27215 ++ return(NULL);
27217 ++ /* Small enough for pointer-storage convention? */
27218 ++ if (g.regsize >= 32767L) /* Probably could be 65535L. */
27219 ++ FAIL("regexp too big");
27221 ++ /* Allocate space. */
27222 ++ *patternsize=sizeof(regexp) + (unsigned)g.regsize;
27223 ++ r = (regexp *)malloc(sizeof(regexp) + (unsigned)g.regsize);
27224 ++ if (r == NULL)
27225 ++ FAIL("out of space");
27227 ++ /* Second pass: emit code. */
27228 ++ g.regparse = exp;
27229 ++ g.regnpar = 1;
27230 ++ g.regcode = r->program;
27231 ++ regc(&g, MAGIC);
27232 ++ if (reg(&g, 0, &flags) == NULL)
27233 ++ return(NULL);
27235 ++ /* Dig out information for optimizations. */
27236 ++ r->regstart = '\0'; /* Worst-case defaults. */
27237 ++ r->reganch = 0;
27238 ++ r->regmust = NULL;
27239 ++ r->regmlen = 0;
27240 ++ scan = r->program+1; /* First BRANCH. */
27241 ++ if (OP(regnext(&g, scan)) == END) { /* Only one top-level choice. */
27242 ++ scan = OPERAND(scan);
27244 ++ /* Starting-point info. */
27245 ++ if (OP(scan) == EXACTLY)
27246 ++ r->regstart = *OPERAND(scan);
27247 ++ else if (OP(scan) == BOL)
27248 ++ r->reganch++;
27250 ++ /*
27251 ++ * If there's something expensive in the r.e., find the
27252 ++ * longest literal string that must appear and make it the
27253 ++ * regmust. Resolve ties in favor of later strings, since
27254 ++ * the regstart check works with the beginning of the r.e.
27255 ++ * and avoiding duplication strengthens checking. Not a
27256 ++ * strong reason, but sufficient in the absence of others.
27257 ++ */
27258 ++ if (flags&SPSTART) {
27259 ++ longest = NULL;
27260 ++ len = 0;
27261 ++ for (; scan != NULL; scan = regnext(&g, scan))
27262 ++ if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
27263 ++ longest = OPERAND(scan);
27264 ++ len = strlen(OPERAND(scan));
27265 ++ }
27266 ++ r->regmust = longest;
27267 ++ r->regmlen = len;
27268 ++ }
27269 ++ }
27271 ++ return(r);
27274 ++/*
27275 ++ - reg - regular expression, i.e. main body or parenthesized thing
27276 ++ *
27277 ++ * Caller must absorb opening parenthesis.
27278 ++ *
27279 ++ * Combining parenthesis handling with the base level of regular expression
27280 ++ * is a trifle forced, but the need to tie the tails of the branches to what
27281 ++ * follows makes it hard to avoid.
27282 ++ */
27283 ++static char *
27284 ++reg(struct match_globals *g, int paren, int *flagp /* Parenthesized? */ )
27286 ++ register char *ret;
27287 ++ register char *br;
27288 ++ register char *ender;
27289 ++ register int parno = 0; /* 0 makes gcc happy */
27290 ++ int flags;
27292 ++ *flagp = HASWIDTH; /* Tentatively. */
27294 ++ /* Make an OPEN node, if parenthesized. */
27295 ++ if (paren) {
27296 ++ if (g->regnpar >= NSUBEXP)
27297 ++ FAIL("too many ()");
27298 ++ parno = g->regnpar;
27299 ++ g->regnpar++;
27300 ++ ret = regnode(g, OPEN+parno);
27301 ++ } else
27302 ++ ret = NULL;
27304 ++ /* Pick up the branches, linking them together. */
27305 ++ br = regbranch(g, &flags);
27306 ++ if (br == NULL)
27307 ++ return(NULL);
27308 ++ if (ret != NULL)
27309 ++ regtail(g, ret, br); /* OPEN -> first. */
27310 ++ else
27311 ++ ret = br;
27312 ++ if (!(flags&HASWIDTH))
27313 ++ *flagp &= ~HASWIDTH;
27314 ++ *flagp |= flags&SPSTART;
27315 ++ while (*g->regparse == '|') {
27316 ++ g->regparse++;
27317 ++ br = regbranch(g, &flags);
27318 ++ if (br == NULL)
27319 ++ return(NULL);
27320 ++ regtail(g, ret, br); /* BRANCH -> BRANCH. */
27321 ++ if (!(flags&HASWIDTH))
27322 ++ *flagp &= ~HASWIDTH;
27323 ++ *flagp |= flags&SPSTART;
27324 ++ }
27326 ++ /* Make a closing node, and hook it on the end. */
27327 ++ ender = regnode(g, (paren) ? CLOSE+parno : END);
27328 ++ regtail(g, ret, ender);
27330 ++ /* Hook the tails of the branches to the closing node. */
27331 ++ for (br = ret; br != NULL; br = regnext(g, br))
27332 ++ regoptail(g, br, ender);
27334 ++ /* Check for proper termination. */
27335 ++ if (paren && *g->regparse++ != ')') {
27336 ++ FAIL("unmatched ()");
27337 ++ } else if (!paren && *g->regparse != '\0') {
27338 ++ if (*g->regparse == ')') {
27339 ++ FAIL("unmatched ()");
27340 ++ } else
27341 ++ FAIL("junk on end"); /* "Can't happen". */
27342 ++ /* NOTREACHED */
27343 ++ }
27345 ++ return(ret);
27348 ++/*
27349 ++ - regbranch - one alternative of an | operator
27350 ++ *
27351 ++ * Implements the concatenation operator.
27352 ++ */
27353 ++static char *
27354 ++regbranch(struct match_globals *g, int *flagp)
27356 ++ register char *ret;
27357 ++ register char *chain;
27358 ++ register char *latest;
27359 ++ int flags;
27361 ++ *flagp = WORST; /* Tentatively. */
27363 ++ ret = regnode(g, BRANCH);
27364 ++ chain = NULL;
27365 ++ while (*g->regparse != '\0' && *g->regparse != '|' && *g->regparse != ')') {
27366 ++ latest = regpiece(g, &flags);
27367 ++ if (latest == NULL)
27368 ++ return(NULL);
27369 ++ *flagp |= flags&HASWIDTH;
27370 ++ if (chain == NULL) /* First piece. */
27371 ++ *flagp |= flags&SPSTART;
27372 ++ else
27373 ++ regtail(g, chain, latest);
27374 ++ chain = latest;
27375 ++ }
27376 ++ if (chain == NULL) /* Loop ran zero times. */
27377 ++ (void) regnode(g, NOTHING);
27379 ++ return(ret);
27382 ++/*
27383 ++ - regpiece - something followed by possible [*+?]
27384 ++ *
27385 ++ * Note that the branching code sequences used for ? and the general cases
27386 ++ * of * and + are somewhat optimized: they use the same NOTHING node as
27387 ++ * both the endmarker for their branch list and the body of the last branch.
27388 ++ * It might seem that this node could be dispensed with entirely, but the
27389 ++ * endmarker role is not redundant.
27390 ++ */
27391 ++static char *
27392 ++regpiece(struct match_globals *g, int *flagp)
27394 ++ register char *ret;
27395 ++ register char op;
27396 ++ register char *next;
27397 ++ int flags;
27399 ++ ret = regatom(g, &flags);
27400 ++ if (ret == NULL)
27401 ++ return(NULL);
27403 ++ op = *g->regparse;
27404 ++ if (!ISMULT(op)) {
27405 ++ *flagp = flags;
27406 ++ return(ret);
27407 ++ }
27409 ++ if (!(flags&HASWIDTH) && op != '?')
27410 ++ FAIL("*+ operand could be empty");
27411 ++ *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
27413 ++ if (op == '*' && (flags&SIMPLE))
27414 ++ reginsert(g, STAR, ret);
27415 ++ else if (op == '*') {
27416 ++ /* Emit x* as (x&|), where & means "self". */
27417 ++ reginsert(g, BRANCH, ret); /* Either x */
27418 ++ regoptail(g, ret, regnode(g, BACK)); /* and loop */
27419 ++ regoptail(g, ret, ret); /* back */
27420 ++ regtail(g, ret, regnode(g, BRANCH)); /* or */
27421 ++ regtail(g, ret, regnode(g, NOTHING)); /* null. */
27422 ++ } else if (op == '+' && (flags&SIMPLE))
27423 ++ reginsert(g, PLUS, ret);
27424 ++ else if (op == '+') {
27425 ++ /* Emit x+ as x(&|), where & means "self". */
27426 ++ next = regnode(g, BRANCH); /* Either */
27427 ++ regtail(g, ret, next);
27428 ++ regtail(g, regnode(g, BACK), ret); /* loop back */
27429 ++ regtail(g, next, regnode(g, BRANCH)); /* or */
27430 ++ regtail(g, ret, regnode(g, NOTHING)); /* null. */
27431 ++ } else if (op == '?') {
27432 ++ /* Emit x? as (x|) */
27433 ++ reginsert(g, BRANCH, ret); /* Either x */
27434 ++ regtail(g, ret, regnode(g, BRANCH)); /* or */
27435 ++ next = regnode(g, NOTHING); /* null. */
27436 ++ regtail(g, ret, next);
27437 ++ regoptail(g, ret, next);
27438 ++ }
27439 ++ g->regparse++;
27440 ++ if (ISMULT(*g->regparse))
27441 ++ FAIL("nested *?+");
27443 ++ return(ret);
27446 ++/*
27447 ++ - regatom - the lowest level
27448 ++ *
27449 ++ * Optimization: gobbles an entire sequence of ordinary characters so that
27450 ++ * it can turn them into a single node, which is smaller to store and
27451 ++ * faster to run. Backslashed characters are exceptions, each becoming a
27452 ++ * separate node; the code is simpler that way and it's not worth fixing.
27453 ++ */
27454 ++static char *
27455 ++regatom(struct match_globals *g, int *flagp)
27457 ++ register char *ret;
27458 ++ int flags;
27460 ++ *flagp = WORST; /* Tentatively. */
27462 ++ switch (*g->regparse++) {
27463 ++ case '^':
27464 ++ ret = regnode(g, BOL);
27465 ++ break;
27466 ++ case '$':
27467 ++ ret = regnode(g, EOL);
27468 ++ break;
27469 ++ case '.':
27470 ++ ret = regnode(g, ANY);
27471 ++ *flagp |= HASWIDTH|SIMPLE;
27472 ++ break;
27473 ++ case '[': {
27474 ++ register int class;
27475 ++ register int classend;
27477 ++ if (*g->regparse == '^') { /* Complement of range. */
27478 ++ ret = regnode(g, ANYBUT);
27479 ++ g->regparse++;
27480 ++ } else
27481 ++ ret = regnode(g, ANYOF);
27482 ++ if (*g->regparse == ']' || *g->regparse == '-')
27483 ++ regc(g, *g->regparse++);
27484 ++ while (*g->regparse != '\0' && *g->regparse != ']') {
27485 ++ if (*g->regparse == '-') {
27486 ++ g->regparse++;
27487 ++ if (*g->regparse == ']' || *g->regparse == '\0')
27488 ++ regc(g, '-');
27489 ++ else {
27490 ++ class = UCHARAT(g->regparse-2)+1;
27491 ++ classend = UCHARAT(g->regparse);
27492 ++ if (class > classend+1)
27493 ++ FAIL("invalid [] range");
27494 ++ for (; class <= classend; class++)
27495 ++ regc(g, class);
27496 ++ g->regparse++;
27497 ++ }
27498 ++ } else
27499 ++ regc(g, *g->regparse++);
27500 ++ }
27501 ++ regc(g, '\0');
27502 ++ if (*g->regparse != ']')
27503 ++ FAIL("unmatched []");
27504 ++ g->regparse++;
27505 ++ *flagp |= HASWIDTH|SIMPLE;
27506 ++ }
27507 ++ break;
27508 ++ case '(':
27509 ++ ret = reg(g, 1, &flags);
27510 ++ if (ret == NULL)
27511 ++ return(NULL);
27512 ++ *flagp |= flags&(HASWIDTH|SPSTART);
27513 ++ break;
27514 ++ case '\0':
27515 ++ case '|':
27516 ++ case ')':
27517 ++ FAIL("internal urp"); /* Supposed to be caught earlier. */
27518 ++ break;
27519 ++ case '?':
27520 ++ case '+':
27521 ++ case '*':
27522 ++ FAIL("?+* follows nothing");
27523 ++ break;
27524 ++ case '\\':
27525 ++ if (*g->regparse == '\0')
27526 ++ FAIL("trailing \\");
27527 ++ ret = regnode(g, EXACTLY);
27528 ++ regc(g, *g->regparse++);
27529 ++ regc(g, '\0');
27530 ++ *flagp |= HASWIDTH|SIMPLE;
27531 ++ break;
27532 ++ default: {
27533 ++ register int len;
27534 ++ register char ender;
27536 ++ g->regparse--;
27537 ++ len = my_strcspn((const char *)g->regparse, (const char *)META);
27538 ++ if (len <= 0)
27539 ++ FAIL("internal disaster");
27540 ++ ender = *(g->regparse+len);
27541 ++ if (len > 1 && ISMULT(ender))
27542 ++ len--; /* Back off clear of ?+* operand. */
27543 ++ *flagp |= HASWIDTH;
27544 ++ if (len == 1)
27545 ++ *flagp |= SIMPLE;
27546 ++ ret = regnode(g, EXACTLY);
27547 ++ while (len > 0) {
27548 ++ regc(g, *g->regparse++);
27549 ++ len--;
27550 ++ }
27551 ++ regc(g, '\0');
27552 ++ }
27553 ++ break;
27554 ++ }
27556 ++ return(ret);
27559 ++/*
27560 ++ - regnode - emit a node
27561 ++ */
27562 ++static char * /* Location. */
27563 ++regnode(struct match_globals *g, char op)
27565 ++ register char *ret;
27566 ++ register char *ptr;
27568 ++ ret = g->regcode;
27569 ++ if (ret == &g->regdummy) {
27570 ++ g->regsize += 3;
27571 ++ return(ret);
27572 ++ }
27574 ++ ptr = ret;
27575 ++ *ptr++ = op;
27576 ++ *ptr++ = '\0'; /* Null "next" pointer. */
27577 ++ *ptr++ = '\0';
27578 ++ g->regcode = ptr;
27580 ++ return(ret);
27583 ++/*
27584 ++ - regc - emit (if appropriate) a byte of code
27585 ++ */
27586 ++static void
27587 ++regc(struct match_globals *g, char b)
27589 ++ if (g->regcode != &g->regdummy)
27590 ++ *g->regcode++ = b;
27591 ++ else
27592 ++ g->regsize++;
27595 ++/*
27596 ++ - reginsert - insert an operator in front of already-emitted operand
27597 ++ *
27598 ++ * Means relocating the operand.
27599 ++ */
27600 ++static void
27601 ++reginsert(struct match_globals *g, char op, char* opnd)
27603 ++ register char *src;
27604 ++ register char *dst;
27605 ++ register char *place;
27607 ++ if (g->regcode == &g->regdummy) {
27608 ++ g->regsize += 3;
27609 ++ return;
27610 ++ }
27612 ++ src = g->regcode;
27613 ++ g->regcode += 3;
27614 ++ dst = g->regcode;
27615 ++ while (src > opnd)
27616 ++ *--dst = *--src;
27618 ++ place = opnd; /* Op node, where operand used to be. */
27619 ++ *place++ = op;
27620 ++ *place++ = '\0';
27621 ++ *place++ = '\0';
27624 ++/*
27625 ++ - regtail - set the next-pointer at the end of a node chain
27626 ++ */
27627 ++static void
27628 ++regtail(struct match_globals *g, char *p, char *val)
27630 ++ register char *scan;
27631 ++ register char *temp;
27632 ++ register int offset;
27634 ++ if (p == &g->regdummy)
27635 ++ return;
27637 ++ /* Find last node. */
27638 ++ scan = p;
27639 ++ for (;;) {
27640 ++ temp = regnext(g, scan);
27641 ++ if (temp == NULL)
27642 ++ break;
27643 ++ scan = temp;
27644 ++ }
27646 ++ if (OP(scan) == BACK)
27647 ++ offset = scan - val;
27648 ++ else
27649 ++ offset = val - scan;
27650 ++ *(scan+1) = (offset>>8)&0377;
27651 ++ *(scan+2) = offset&0377;
27654 ++/*
27655 ++ - regoptail - regtail on operand of first argument; nop if operandless
27656 ++ */
27657 ++static void
27658 ++regoptail(struct match_globals *g, char *p, char *val)
27660 ++ /* "Operandless" and "op != BRANCH" are synonymous in practice. */
27661 ++ if (p == NULL || p == &g->regdummy || OP(p) != BRANCH)
27662 ++ return;
27663 ++ regtail(g, OPERAND(p), val);
27666 ++/*
27667 ++ * regexec and friends
27668 ++ */
27671 ++/*
27672 ++ * Forwards.
27673 ++ */
27674 ++STATIC int regtry(struct match_globals *g, regexp *prog, char *string);
27675 ++STATIC int regmatch(struct match_globals *g, char *prog);
27676 ++STATIC int regrepeat(struct match_globals *g, char *p);
27678 ++#ifdef DEBUG
27679 ++int regnarrate = 0;
27680 ++void regdump();
27681 ++STATIC char *regprop(char *op);
27682 ++#endif
27684 ++/*
27685 ++ - regexec - match a regexp against a string
27686 ++ */
27687 ++int
27688 ++regexec(regexp *prog, char *string)
27690 ++ register char *s;
27691 ++ struct match_globals g;
27693 ++ /* Be paranoid... */
27694 ++ if (prog == NULL || string == NULL) {
27695 ++ printk("<3>Regexp: NULL parameter\n");
27696 ++ return(0);
27697 ++ }
27699 ++ /* Check validity of program. */
27700 ++ if (UCHARAT(prog->program) != MAGIC) {
27701 ++ printk("<3>Regexp: corrupted program\n");
27702 ++ return(0);
27703 ++ }
27705 ++ /* If there is a "must appear" string, look for it. */
27706 ++ if (prog->regmust != NULL) {
27707 ++ s = string;
27708 ++ while ((s = strchr(s, prog->regmust[0])) != NULL) {
27709 ++ if (strncmp(s, prog->regmust, prog->regmlen) == 0)
27710 ++ break; /* Found it. */
27711 ++ s++;
27712 ++ }
27713 ++ if (s == NULL) /* Not present. */
27714 ++ return(0);
27715 ++ }
27717 ++ /* Mark beginning of line for ^ . */
27718 ++ g.regbol = string;
27720 ++ /* Simplest case: anchored match need be tried only once. */
27721 ++ if (prog->reganch)
27722 ++ return(regtry(&g, prog, string));
27724 ++ /* Messy cases: unanchored match. */
27725 ++ s = string;
27726 ++ if (prog->regstart != '\0')
27727 ++ /* We know what char it must start with. */
27728 ++ while ((s = strchr(s, prog->regstart)) != NULL) {
27729 ++ if (regtry(&g, prog, s))
27730 ++ return(1);
27731 ++ s++;
27732 ++ }
27733 ++ else
27734 ++ /* We don't -- general case. */
27735 ++ do {
27736 ++ if (regtry(&g, prog, s))
27737 ++ return(1);
27738 ++ } while (*s++ != '\0');
27740 ++ /* Failure. */
27741 ++ return(0);
27744 ++/*
27745 ++ - regtry - try match at specific point
27746 ++ */
27747 ++static int /* 0 failure, 1 success */
27748 ++regtry(struct match_globals *g, regexp *prog, char *string)
27750 ++ register int i;
27751 ++ register char **sp;
27752 ++ register char **ep;
27754 ++ g->reginput = string;
27755 ++ g->regstartp = prog->startp;
27756 ++ g->regendp = prog->endp;
27758 ++ sp = prog->startp;
27759 ++ ep = prog->endp;
27760 ++ for (i = NSUBEXP; i > 0; i--) {
27761 ++ *sp++ = NULL;
27762 ++ *ep++ = NULL;
27763 ++ }
27764 ++ if (regmatch(g, prog->program + 1)) {
27765 ++ prog->startp[0] = string;
27766 ++ prog->endp[0] = g->reginput;
27767 ++ return(1);
27768 ++ } else
27769 ++ return(0);
27772 ++/*
27773 ++ - regmatch - main matching routine
27774 ++ *
27775 ++ * Conceptually the strategy is simple: check to see whether the current
27776 ++ * node matches, call self recursively to see whether the rest matches,
27777 ++ * and then act accordingly. In practice we make some effort to avoid
27778 ++ * recursion, in particular by going through "ordinary" nodes (that don't
27779 ++ * need to know whether the rest of the match failed) by a loop instead of
27780 ++ * by recursion.
27781 ++ */
27782 ++static int /* 0 failure, 1 success */
27783 ++regmatch(struct match_globals *g, char *prog)
27785 ++ register char *scan = prog; /* Current node. */
27786 ++ char *next; /* Next node. */
27788 ++#ifdef DEBUG
27789 ++ if (scan != NULL && regnarrate)
27790 ++ fprintf(stderr, "%s(\n", regprop(scan));
27791 ++#endif
27792 ++ while (scan != NULL) {
27793 ++#ifdef DEBUG
27794 ++ if (regnarrate)
27795 ++ fprintf(stderr, "%s...\n", regprop(scan));
27796 ++#endif
27797 ++ next = regnext(g, scan);
27799 ++ switch (OP(scan)) {
27800 ++ case BOL:
27801 ++ if (g->reginput != g->regbol)
27802 ++ return(0);
27803 ++ break;
27804 ++ case EOL:
27805 ++ if (*g->reginput != '\0')
27806 ++ return(0);
27807 ++ break;
27808 ++ case ANY:
27809 ++ if (*g->reginput == '\0')
27810 ++ return(0);
27811 ++ g->reginput++;
27812 ++ break;
27813 ++ case EXACTLY: {
27814 ++ register int len;
27815 ++ register char *opnd;
27817 ++ opnd = OPERAND(scan);
27818 ++ /* Inline the first character, for speed. */
27819 ++ if (*opnd != *g->reginput)
27820 ++ return(0);
27821 ++ len = strlen(opnd);
27822 ++ if (len > 1 && strncmp(opnd, g->reginput, len) != 0)
27823 ++ return(0);
27824 ++ g->reginput += len;
27825 ++ }
27826 ++ break;
27827 ++ case ANYOF:
27828 ++ if (*g->reginput == '\0' || strchr(OPERAND(scan), *g->reginput) == NULL)
27829 ++ return(0);
27830 ++ g->reginput++;
27831 ++ break;
27832 ++ case ANYBUT:
27833 ++ if (*g->reginput == '\0' || strchr(OPERAND(scan), *g->reginput) != NULL)
27834 ++ return(0);
27835 ++ g->reginput++;
27836 ++ break;
27837 ++ case NOTHING:
27838 ++ case BACK:
27839 ++ break;
27840 ++ case OPEN+1:
27841 ++ case OPEN+2:
27842 ++ case OPEN+3:
27843 ++ case OPEN+4:
27844 ++ case OPEN+5:
27845 ++ case OPEN+6:
27846 ++ case OPEN+7:
27847 ++ case OPEN+8:
27848 ++ case OPEN+9: {
27849 ++ register int no;
27850 ++ register char *save;
27852 ++ no = OP(scan) - OPEN;
27853 ++ save = g->reginput;
27855 ++ if (regmatch(g, next)) {
27856 ++ /*
27857 ++ * Don't set startp if some later
27858 ++ * invocation of the same parentheses
27859 ++ * already has.
27860 ++ */
27861 ++ if (g->regstartp[no] == NULL)
27862 ++ g->regstartp[no] = save;
27863 ++ return(1);
27864 ++ } else
27865 ++ return(0);
27866 ++ }
27867 ++ break;
27868 ++ case CLOSE+1:
27869 ++ case CLOSE+2:
27870 ++ case CLOSE+3:
27871 ++ case CLOSE+4:
27872 ++ case CLOSE+5:
27873 ++ case CLOSE+6:
27874 ++ case CLOSE+7:
27875 ++ case CLOSE+8:
27876 ++ case CLOSE+9:
27877 ++ {
27878 ++ register int no;
27879 ++ register char *save;
27881 ++ no = OP(scan) - CLOSE;
27882 ++ save = g->reginput;
27884 ++ if (regmatch(g, next)) {
27885 ++ /*
27886 ++ * Don't set endp if some later
27887 ++ * invocation of the same parentheses
27888 ++ * already has.
27889 ++ */
27890 ++ if (g->regendp[no] == NULL)
27891 ++ g->regendp[no] = save;
27892 ++ return(1);
27893 ++ } else
27894 ++ return(0);
27895 ++ }
27896 ++ break;
27897 ++ case BRANCH: {
27898 ++ register char *save;
27900 ++ if (OP(next) != BRANCH) /* No choice. */
27901 ++ next = OPERAND(scan); /* Avoid recursion. */
27902 ++ else {
27903 ++ do {
27904 ++ save = g->reginput;
27905 ++ if (regmatch(g, OPERAND(scan)))
27906 ++ return(1);
27907 ++ g->reginput = save;
27908 ++ scan = regnext(g, scan);
27909 ++ } while (scan != NULL && OP(scan) == BRANCH);
27910 ++ return(0);
27911 ++ /* NOTREACHED */
27912 ++ }
27913 ++ }
27914 ++ break;
27915 ++ case STAR:
27916 ++ case PLUS: {
27917 ++ register char nextch;
27918 ++ register int no;
27919 ++ register char *save;
27920 ++ register int min;
27922 ++ /*
27923 ++ * Lookahead to avoid useless match attempts
27924 ++ * when we know what character comes next.
27925 ++ */
27926 ++ nextch = '\0';
27927 ++ if (OP(next) == EXACTLY)
27928 ++ nextch = *OPERAND(next);
27929 ++ min = (OP(scan) == STAR) ? 0 : 1;
27930 ++ save = g->reginput;
27931 ++ no = regrepeat(g, OPERAND(scan));
27932 ++ while (no >= min) {
27933 ++ /* If it could work, try it. */
27934 ++ if (nextch == '\0' || *g->reginput == nextch)
27935 ++ if (regmatch(g, next))
27936 ++ return(1);
27937 ++ /* Couldn't or didn't -- back up. */
27938 ++ no--;
27939 ++ g->reginput = save + no;
27940 ++ }
27941 ++ return(0);
27942 ++ }
27943 ++ break;
27944 ++ case END:
27945 ++ return(1); /* Success! */
27946 ++ break;
27947 ++ default:
27948 ++ printk("<3>Regexp: memory corruption\n");
27949 ++ return(0);
27950 ++ break;
27951 ++ }
27953 ++ scan = next;
27954 ++ }
27956 ++ /*
27957 ++ * We get here only if there's trouble -- normally "case END" is
27958 ++ * the terminating point.
27959 ++ */
27960 ++ printk("<3>Regexp: corrupted pointers\n");
27961 ++ return(0);
27964 ++/*
27965 ++ - regrepeat - repeatedly match something simple, report how many
27966 ++ */
27967 ++static int
27968 ++regrepeat(struct match_globals *g, char *p)
27970 ++ register int count = 0;
27971 ++ register char *scan;
27972 ++ register char *opnd;
27974 ++ scan = g->reginput;
27975 ++ opnd = OPERAND(p);
27976 ++ switch (OP(p)) {
27977 ++ case ANY:
27978 ++ count = strlen(scan);
27979 ++ scan += count;
27980 ++ break;
27981 ++ case EXACTLY:
27982 ++ while (*opnd == *scan) {
27983 ++ count++;
27984 ++ scan++;
27985 ++ }
27986 ++ break;
27987 ++ case ANYOF:
27988 ++ while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
27989 ++ count++;
27990 ++ scan++;
27991 ++ }
27992 ++ break;
27993 ++ case ANYBUT:
27994 ++ while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
27995 ++ count++;
27996 ++ scan++;
27997 ++ }
27998 ++ break;
27999 ++ default: /* Oh dear. Called inappropriately. */
28000 ++ printk("<3>Regexp: internal foulup\n");
28001 ++ count = 0; /* Best compromise. */
28002 ++ break;
28003 ++ }
28004 ++ g->reginput = scan;
28006 ++ return(count);
28009 ++/*
28010 ++ - regnext - dig the "next" pointer out of a node
28011 ++ */
28012 ++static char*
28013 ++regnext(struct match_globals *g, char *p)
28015 ++ register int offset;
28017 ++ if (p == &g->regdummy)
28018 ++ return(NULL);
28020 ++ offset = NEXT(p);
28021 ++ if (offset == 0)
28022 ++ return(NULL);
28024 ++ if (OP(p) == BACK)
28025 ++ return(p-offset);
28026 ++ else
28027 ++ return(p+offset);
28030 ++#ifdef DEBUG
28032 ++STATIC char *regprop();
28034 ++/*
28035 ++ - regdump - dump a regexp onto stdout in vaguely comprehensible form
28036 ++ */
28037 ++void
28038 ++regdump(regexp *r)
28040 ++ register char *s;
28041 ++ register char op = EXACTLY; /* Arbitrary non-END op. */
28042 ++ register char *next;
28043 ++ /* extern char *strchr(); */
28046 ++ s = r->program + 1;
28047 ++ while (op != END) { /* While that wasn't END last time... */
28048 ++ op = OP(s);
28049 ++ printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
28050 ++ next = regnext(s);
28051 ++ if (next == NULL) /* Next ptr. */
28052 ++ printf("(0)");
28053 ++ else
28054 ++ printf("(%d)", (s-r->program)+(next-s));
28055 ++ s += 3;
28056 ++ if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
28057 ++ /* Literal string, where present. */
28058 ++ while (*s != '\0') {
28059 ++ putchar(*s);
28060 ++ s++;
28061 ++ }
28062 ++ s++;
28063 ++ }
28064 ++ putchar('\n');
28065 ++ }
28067 ++ /* Header fields of interest. */
28068 ++ if (r->regstart != '\0')
28069 ++ printf("start `%c' ", r->regstart);
28070 ++ if (r->reganch)
28071 ++ printf("anchored ");
28072 ++ if (r->regmust != NULL)
28073 ++ printf("must have \"%s\"", r->regmust);
28074 ++ printf("\n");
28077 ++/*
28078 ++ - regprop - printable representation of opcode
28079 ++ */
28080 ++static char *
28081 ++regprop(char *op)
28083 ++#define BUFLEN 50
28084 ++ register char *p;
28085 ++ static char buf[BUFLEN];
28087 ++ strcpy(buf, ":");
28089 ++ switch (OP(op)) {
28090 ++ case BOL:
28091 ++ p = "BOL";
28092 ++ break;
28093 ++ case EOL:
28094 ++ p = "EOL";
28095 ++ break;
28096 ++ case ANY:
28097 ++ p = "ANY";
28098 ++ break;
28099 ++ case ANYOF:
28100 ++ p = "ANYOF";
28101 ++ break;
28102 ++ case ANYBUT:
28103 ++ p = "ANYBUT";
28104 ++ break;
28105 ++ case BRANCH:
28106 ++ p = "BRANCH";
28107 ++ break;
28108 ++ case EXACTLY:
28109 ++ p = "EXACTLY";
28110 ++ break;
28111 ++ case NOTHING:
28112 ++ p = "NOTHING";
28113 ++ break;
28114 ++ case BACK:
28115 ++ p = "BACK";
28116 ++ break;
28117 ++ case END:
28118 ++ p = "END";
28119 ++ break;
28120 ++ case OPEN+1:
28121 ++ case OPEN+2:
28122 ++ case OPEN+3:
28123 ++ case OPEN+4:
28124 ++ case OPEN+5:
28125 ++ case OPEN+6:
28126 ++ case OPEN+7:
28127 ++ case OPEN+8:
28128 ++ case OPEN+9:
28129 ++ snprintf(buf+strlen(buf),BUFLEN-strlen(buf), "OPEN%d", OP(op)-OPEN);
28130 ++ p = NULL;
28131 ++ break;
28132 ++ case CLOSE+1:
28133 ++ case CLOSE+2:
28134 ++ case CLOSE+3:
28135 ++ case CLOSE+4:
28136 ++ case CLOSE+5:
28137 ++ case CLOSE+6:
28138 ++ case CLOSE+7:
28139 ++ case CLOSE+8:
28140 ++ case CLOSE+9:
28141 ++ snprintf(buf+strlen(buf),BUFLEN-strlen(buf), "CLOSE%d", OP(op)-CLOSE);
28142 ++ p = NULL;
28143 ++ break;
28144 ++ case STAR:
28145 ++ p = "STAR";
28146 ++ break;
28147 ++ case PLUS:
28148 ++ p = "PLUS";
28149 ++ break;
28150 ++ default:
28151 ++ printk("<3>Regexp: corrupted opcode\n");
28152 ++ break;
28153 ++ }
28154 ++ if (p != NULL)
28155 ++ strncat(buf, p, BUFLEN-strlen(buf));
28156 ++ return(buf);
28158 ++#endif
28161 +--- /dev/null
28162 ++++ b/net/netfilter/regexp/regexp.h
28163 +@@ -0,0 +1,41 @@
28164 ++/*
28165 ++ * Definitions etc. for regexp(3) routines.
28166 ++ *
28167 ++ * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
28168 ++ * not the System V one.
28169 ++ */
28171 ++#ifndef REGEXP_H
28172 ++#define REGEXP_H
28175 ++/*
28176 ++http://www.opensource.apple.com/darwinsource/10.3/expect-1/expect/expect.h ,
28177 ++which contains a version of this library, says:
28179 ++ *
28180 ++ * NSUBEXP must be at least 10, and no greater than 117 or the parser
28181 ++ * will not work properly.
28182 ++ *
28184 ++However, it looks rather like this library is limited to 10. If you think
28185 ++otherwise, let us know.
28186 ++*/
28188 ++#define NSUBEXP 10
28189 ++typedef struct regexp {
28190 ++ char *startp[NSUBEXP];
28191 ++ char *endp[NSUBEXP];
28192 ++ char regstart; /* Internal use only. */
28193 ++ char reganch; /* Internal use only. */
28194 ++ char *regmust; /* Internal use only. */
28195 ++ int regmlen; /* Internal use only. */
28196 ++ char program[1]; /* Unwarranted chumminess with compiler. */
28197 ++} regexp;
28199 ++regexp * regcomp(char *exp, int *patternsize);
28200 ++int regexec(regexp *prog, char *string);
28201 ++void regsub(regexp *prog, char *source, char *dest);
28202 ++void regerror(char *s);
28204 ++#endif
28205 +--- /dev/null
28206 ++++ b/net/netfilter/regexp/regmagic.h
28207 +@@ -0,0 +1,5 @@
28208 ++/*
28209 ++ * The first byte of the regexp internal "program" is actually this magic
28210 ++ * number; the start node begins in the second byte.
28211 ++ */
28212 ++#define MAGIC 0234
28213 +--- /dev/null
28214 ++++ b/net/netfilter/regexp/regsub.c
28215 +@@ -0,0 +1,95 @@
28216 ++/*
28217 ++ * regsub
28218 ++ * @(#)regsub.c 1.3 of 2 April 86
28219 ++ *
28220 ++ * Copyright (c) 1986 by University of Toronto.
28221 ++ * Written by Henry Spencer. Not derived from licensed software.
28222 ++ *
28223 ++ * Permission is granted to anyone to use this software for any
28224 ++ * purpose on any computer system, and to redistribute it freely,
28225 ++ * subject to the following restrictions:
28226 ++ *
28227 ++ * 1. The author is not responsible for the consequences of use of
28228 ++ * this software, no matter how awful, even if they arise
28229 ++ * from defects in it.
28230 ++ *
28231 ++ * 2. The origin of this software must not be misrepresented, either
28232 ++ * by explicit claim or by omission.
28233 ++ *
28234 ++ * 3. Altered versions must be plainly marked as such, and must not
28235 ++ * be misrepresented as being the original software.
28236 ++ *
28237 ++ *
28238 ++ * This code was modified by Ethan Sommer to work within the kernel
28239 ++ * (it now uses kmalloc etc..)
28240 ++ *
28241 ++ */
28242 ++#include "regexp.h"
28243 ++#include "regmagic.h"
28244 ++#include <linux/string.h>
28247 ++#ifndef CHARBITS
28248 ++#define UCHARAT(p) ((int)*(unsigned char *)(p))
28249 ++#else
28250 ++#define UCHARAT(p) ((int)*(p)&CHARBITS)
28251 ++#endif
28253 ++#if 0
28254 ++//void regerror(char * s)
28255 ++//{
28256 ++// printk("regexp(3): %s", s);
28257 ++// /* NOTREACHED */
28258 ++//}
28259 ++#endif
28261 ++/*
28262 ++ - regsub - perform substitutions after a regexp match
28263 ++ */
28264 ++void
28265 ++regsub(regexp * prog, char * source, char * dest)
28267 ++ register char *src;
28268 ++ register char *dst;
28269 ++ register char c;
28270 ++ register int no;
28271 ++ register int len;
28273 ++ /* Not necessary and gcc doesn't like it -MLS */
28274 ++ /*extern char *strncpy();*/
28276 ++ if (prog == NULL || source == NULL || dest == NULL) {
28277 ++ regerror("NULL parm to regsub");
28278 ++ return;
28279 ++ }
28280 ++ if (UCHARAT(prog->program) != MAGIC) {
28281 ++ regerror("damaged regexp fed to regsub");
28282 ++ return;
28283 ++ }
28285 ++ src = source;
28286 ++ dst = dest;
28287 ++ while ((c = *src++) != '\0') {
28288 ++ if (c == '&')
28289 ++ no = 0;
28290 ++ else if (c == '\\' && '0' <= *src && *src <= '9')
28291 ++ no = *src++ - '0';
28292 ++ else
28293 ++ no = -1;
28295 ++ if (no < 0) { /* Ordinary character. */
28296 ++ if (c == '\\' && (*src == '\\' || *src == '&'))
28297 ++ c = *src++;
28298 ++ *dst++ = c;
28299 ++ } else if (prog->startp[no] != NULL && prog->endp[no] != NULL) {
28300 ++ len = prog->endp[no] - prog->startp[no];
28301 ++ (void) strncpy(dst, prog->startp[no], len);
28302 ++ dst += len;
28303 ++ if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */
28304 ++ regerror("damaged match string");
28305 ++ return;
28306 ++ }
28307 ++ }
28308 ++ }
28309 ++ *dst++ = '\0';
28311 +--- a/net/netfilter/nf_conntrack_core.c
28312 ++++ b/net/netfilter/nf_conntrack_core.c
28313 +@@ -220,6 +220,13 @@ destroy_conntrack(struct nf_conntrack *n
28314 + * too. */
28315 + nf_ct_remove_expectations(ct);
28317 ++#if defined(CONFIG_NETFILTER_XT_MATCH_LAYER7) || defined(CONFIG_NETFILTER_XT_MATCH_LAYER7_MODULE)
28318 ++ if(ct->layer7.app_proto)
28319 ++ kfree(ct->layer7.app_proto);
28320 ++ if(ct->layer7.app_data)
28321 ++ kfree(ct->layer7.app_data);
28322 ++#endif
28324 + /* We overload first tuple to link into unconfirmed or dying list.*/
28325 + BUG_ON(hlist_nulls_unhashed(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode));
28326 + hlist_nulls_del_rcu(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode);
28327 +--- a/net/netfilter/nf_conntrack_standalone.c
28328 ++++ b/net/netfilter/nf_conntrack_standalone.c
28329 +@@ -240,6 +240,12 @@ static int ct_seq_show(struct seq_file *
28330 + if (ct_show_delta_time(s, ct))
28331 + goto release;
28333 ++#if defined(CONFIG_NETFILTER_XT_MATCH_LAYER7) || defined(CONFIG_NETFILTER_XT_MATCH_LAYER7_MODULE)
28334 ++ if(ct->layer7.app_proto &&
28335 ++ seq_printf(s, "l7proto=%s ", ct->layer7.app_proto))
28336 ++ return -ENOSPC;
28337 ++#endif
28339 + if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
28340 + goto release;
28342 +--- a/include/net/netfilter/nf_conntrack.h
28343 ++++ b/include/net/netfilter/nf_conntrack.h
28344 +@@ -105,6 +105,22 @@ struct nf_conn {
28345 + struct net *ct_net;
28346 + #endif
28348 ++#if defined(CONFIG_NETFILTER_XT_MATCH_LAYER7) || \
28349 ++ defined(CONFIG_NETFILTER_XT_MATCH_LAYER7_MODULE)
28350 ++ struct {
28351 ++ /*
28352 ++ * e.g. "http". NULL before decision. "unknown" after decision
28353 ++ * if no match.
28354 ++ */
28355 ++ char *app_proto;
28356 ++ /*
28357 ++ * application layer data so far. NULL after match decision.
28358 ++ */
28359 ++ char *app_data;
28360 ++ unsigned int app_data_len;
28361 ++ } layer7;
28362 ++#endif
28364 + /* Storage reserved for other modules, must be the last member */
28365 + union nf_conntrack_proto proto;
28366 + };
28367 +--- /dev/null
28368 ++++ b/include/linux/netfilter/xt_layer7.h
28369 +@@ -0,0 +1,13 @@
28370 ++#ifndef _XT_LAYER7_H
28371 ++#define _XT_LAYER7_H
28373 ++#define MAX_PATTERN_LEN 8192
28374 ++#define MAX_PROTOCOL_LEN 256
28376 ++struct xt_layer7_info {
28377 ++ char protocol[MAX_PROTOCOL_LEN];
28378 ++ char pattern[MAX_PATTERN_LEN];
28379 ++ u_int8_t invert;
28380 ++};
28382 ++#endif /* _XT_LAYER7_H */
28383 +--- a/include/uapi/linux/netfilter/Kbuild
28384 ++++ b/include/uapi/linux/netfilter/Kbuild
28385 +@@ -59,6 +59,7 @@ header-y += xt_ipcomp.h
28386 + header-y += xt_iprange.h
28387 + header-y += xt_ipvs.h
28388 + header-y += xt_l2tp.h
28389 ++header-y += xt_layer7.h
28390 + header-y += xt_length.h
28391 + header-y += xt_limit.h
28392 + header-y += xt_mac.h
28393 diff --git a/target/linux/generic/patches-3.16/601-netfilter_layer7_pktmatch.patch b/target/linux/generic/patches-3.16/601-netfilter_layer7_pktmatch.patch
28394 new file mode 100644
28395 index 000000000000..f65e301fd1fd
28396 --- /dev/null
28397 +++ b/target/linux/generic/patches-3.16/601-netfilter_layer7_pktmatch.patch
28398 @@ -0,0 +1,108 @@
28399 +--- a/include/linux/netfilter/xt_layer7.h
28400 ++++ b/include/linux/netfilter/xt_layer7.h
28401 +@@ -8,6 +8,7 @@ struct xt_layer7_info {
28402 + char protocol[MAX_PROTOCOL_LEN];
28403 + char pattern[MAX_PATTERN_LEN];
28404 + u_int8_t invert;
28405 ++ u_int8_t pkt;
28406 + };
28408 + #endif /* _XT_LAYER7_H */
28409 +--- a/net/netfilter/xt_layer7.c
28410 ++++ b/net/netfilter/xt_layer7.c
28411 +@@ -314,33 +314,35 @@ static int match_no_append(struct nf_con
28414 + /* add the new app data to the conntrack. Return number of bytes added. */
28415 +-static int add_data(struct nf_conn * master_conntrack,
28416 +- char * app_data, int appdatalen)
28417 ++static int add_datastr(char *target, int offset, char *app_data, int len)
28419 + int length = 0, i;
28420 +- int oldlength = master_conntrack->layer7.app_data_len;
28422 +- /* This is a fix for a race condition by Deti Fliegl. However, I'm not
28423 +- clear on whether the race condition exists or whether this really
28424 +- fixes it. I might just be being dense... Anyway, if it's not really
28425 +- a fix, all it does is waste a very small amount of time. */
28426 +- if(!master_conntrack->layer7.app_data) return 0;
28427 ++ if (!target) return 0;
28429 + /* Strip nulls. Make everything lower case (our regex lib doesn't
28430 + do case insensitivity). Add it to the end of the current data. */
28431 +- for(i = 0; i < maxdatalen-oldlength-1 &&
28432 +- i < appdatalen; i++) {
28433 ++ for(i = 0; i < maxdatalen-offset-1 && i < len; i++) {
28434 + if(app_data[i] != '\0') {
28435 + /* the kernel version of tolower mungs 'upper ascii' */
28436 +- master_conntrack->layer7.app_data[length+oldlength] =
28437 ++ target[length+offset] =
28438 + isascii(app_data[i])?
28439 + tolower(app_data[i]) : app_data[i];
28440 + length++;
28443 ++ target[length+offset] = '\0';
28445 ++ return length;
28448 ++/* add the new app data to the conntrack. Return number of bytes added. */
28449 ++static int add_data(struct nf_conn * master_conntrack,
28450 ++ char * app_data, int appdatalen)
28452 ++ int length;
28454 +- master_conntrack->layer7.app_data[length+oldlength] = '\0';
28455 +- master_conntrack->layer7.app_data_len = length + oldlength;
28456 ++ length = add_datastr(master_conntrack->layer7.app_data, master_conntrack->layer7.app_data_len, app_data, appdatalen);
28457 ++ master_conntrack->layer7.app_data_len += length;
28459 + return length;
28461 +@@ -438,7 +440,7 @@ match(const struct sk_buff *skbin,
28463 + enum ip_conntrack_info master_ctinfo, ctinfo;
28464 + struct nf_conn *master_conntrack, *conntrack;
28465 +- unsigned char * app_data;
28466 ++ unsigned char *app_data, *tmp_data;
28467 + unsigned int pattern_result, appdatalen;
28468 + regexp * comppattern;
28470 +@@ -466,8 +468,8 @@ match(const struct sk_buff *skbin,
28471 + master_conntrack = master_ct(master_conntrack);
28473 + /* if we've classified it or seen too many packets */
28474 +- if(total_acct_packets(master_conntrack) > num_packets ||
28475 +- master_conntrack->layer7.app_proto) {
28476 ++ if(!info->pkt && (total_acct_packets(master_conntrack) > num_packets ||
28477 ++ master_conntrack->layer7.app_proto)) {
28479 + pattern_result = match_no_append(conntrack, master_conntrack,
28480 + ctinfo, master_ctinfo, info);
28481 +@@ -500,6 +502,25 @@ match(const struct sk_buff *skbin,
28482 + /* the return value gets checked later, when we're ready to use it */
28483 + comppattern = compile_and_cache(info->pattern, info->protocol);
28485 ++ if (info->pkt) {
28486 ++ tmp_data = kmalloc(maxdatalen, GFP_ATOMIC);
28487 ++ if(!tmp_data){
28488 ++ if (net_ratelimit())
28489 ++ printk(KERN_ERR "layer7: out of memory in match, bailing.\n");
28490 ++ return info->invert;
28491 ++ }
28493 ++ tmp_data[0] = '\0';
28494 ++ add_datastr(tmp_data, 0, app_data, appdatalen);
28495 ++ pattern_result = ((comppattern && regexec(comppattern, tmp_data)) ? 1 : 0);
28497 ++ kfree(tmp_data);
28498 ++ tmp_data = NULL;
28499 ++ spin_unlock_bh(&l7_lock);
28501 ++ return (pattern_result ^ info->invert);
28502 ++ }
28504 + /* On the first packet of a connection, allocate space for app data */
28505 + if(total_acct_packets(master_conntrack) == 1 && !skb->cb[0] &&
28506 + !master_conntrack->layer7.app_data){
28507 diff --git a/target/linux/generic/patches-3.16/602-netfilter_layer7_match.patch b/target/linux/generic/patches-3.16/602-netfilter_layer7_match.patch
28508 new file mode 100644
28509 index 000000000000..b2e48c824f8e
28510 --- /dev/null
28511 +++ b/target/linux/generic/patches-3.16/602-netfilter_layer7_match.patch
28512 @@ -0,0 +1,51 @@
28513 +--- a/net/netfilter/xt_layer7.c
28514 ++++ b/net/netfilter/xt_layer7.c
28515 +@@ -415,7 +415,9 @@ static int layer7_write_proc(struct file
28518 + static bool
28519 +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
28520 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
28521 ++match(const struct sk_buff *skbin, struct xt_action_param *par)
28522 ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
28523 + match(const struct sk_buff *skbin, const struct xt_match_param *par)
28524 + #else
28525 + match(const struct sk_buff *skbin,
28526 +@@ -597,14 +599,19 @@ match(const struct sk_buff *skbin,
28529 + // load nf_conntrack_ipv4
28530 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
28531 ++static int
28532 ++#else
28533 ++static bool
28534 ++#endif
28535 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
28536 +-static bool check(const struct xt_mtchk_param *par)
28537 ++check(const struct xt_mtchk_param *par)
28539 + if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
28540 + printk(KERN_WARNING "can't load conntrack support for "
28541 + "proto=%d\n", par->match->family);
28542 + #else
28543 +-static bool check(const char *tablename, const void *inf,
28544 ++check(const char *tablename, const void *inf,
28545 + const struct xt_match *match, void *matchinfo,
28546 + unsigned int hook_mask)
28548 +@@ -612,9 +619,15 @@ static bool check(const char *tablename,
28549 + printk(KERN_WARNING "can't load conntrack support for "
28550 + "proto=%d\n", match->family);
28551 + #endif
28552 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
28553 ++ return -EINVAL;
28554 ++ }
28555 ++ return 0;
28556 ++#else
28557 + return 0;
28559 + return 1;
28560 ++#endif
28564 diff --git a/target/linux/generic/patches-3.16/603-netfilter_layer7_2.6.36_fix.patch b/target/linux/generic/patches-3.16/603-netfilter_layer7_2.6.36_fix.patch
28565 new file mode 100644
28566 index 000000000000..d7e2ac22b40c
28567 --- /dev/null
28568 +++ b/target/linux/generic/patches-3.16/603-netfilter_layer7_2.6.36_fix.patch
28569 @@ -0,0 +1,61 @@
28570 +--- a/net/netfilter/Kconfig
28571 ++++ b/net/netfilter/Kconfig
28572 +@@ -1151,6 +1151,27 @@ config NETFILTER_XT_MATCH_L2TP
28574 + To compile it as a module, choose M here. If unsure, say N.
28576 ++config NETFILTER_XT_MATCH_LAYER7
28577 ++ tristate '"layer7" match support'
28578 ++ depends on EXPERIMENTAL
28579 ++ depends on NETFILTER_XTABLES
28580 ++ depends on NETFILTER_ADVANCED
28581 ++ depends on NF_CONNTRACK
28582 ++ help
28583 ++ Say Y if you want to be able to classify connections (and their
28584 ++ packets) based on regular expression matching of their application
28585 ++ layer data. This is one way to classify applications such as
28586 ++ peer-to-peer filesharing systems that do not always use the same
28587 ++ port.
28589 ++ To compile it as a module, choose M here. If unsure, say N.
28591 ++config NETFILTER_XT_MATCH_LAYER7_DEBUG
28592 ++ bool 'Layer 7 debugging output'
28593 ++ depends on NETFILTER_XT_MATCH_LAYER7
28594 ++ help
28595 ++ Say Y to get lots of debugging output.
28597 + config NETFILTER_XT_MATCH_LENGTH
28598 + tristate '"length" match support'
28599 + depends on NETFILTER_ADVANCED
28600 +@@ -1345,26 +1366,11 @@ config NETFILTER_XT_MATCH_STATE
28602 + To compile it as a module, choose M here. If unsure, say N.
28604 +-config NETFILTER_XT_MATCH_LAYER7
28605 +- tristate '"layer7" match support'
28606 +- depends on NETFILTER_XTABLES
28607 +- depends on EXPERIMENTAL && (IP_NF_CONNTRACK || NF_CONNTRACK)
28608 +- depends on NETFILTER_ADVANCED
28609 +- help
28610 +- Say Y if you want to be able to classify connections (and their
28611 +- packets) based on regular expression matching of their application
28612 +- layer data. This is one way to classify applications such as
28613 +- peer-to-peer filesharing systems that do not always use the same
28614 +- port.
28616 +- To compile it as a module, choose M here. If unsure, say N.
28618 + config NETFILTER_XT_MATCH_LAYER7_DEBUG
28619 +- bool 'Layer 7 debugging output'
28620 +- depends on NETFILTER_XT_MATCH_LAYER7
28621 +- help
28622 +- Say Y to get lots of debugging output.
28624 ++ bool 'Layer 7 debugging output'
28625 ++ depends on NETFILTER_XT_MATCH_LAYER7
28626 ++ help
28627 ++ Say Y to get lots of debugging output.
28629 + config NETFILTER_XT_MATCH_STATISTIC
28630 + tristate '"statistic" match support'
28631 diff --git a/target/linux/generic/patches-3.16/604-netfilter_conntrack_flush.patch b/target/linux/generic/patches-3.16/604-netfilter_conntrack_flush.patch
28632 new file mode 100644
28633 index 000000000000..83cd04ac8b03
28634 --- /dev/null
28635 +++ b/target/linux/generic/patches-3.16/604-netfilter_conntrack_flush.patch
28636 @@ -0,0 +1,86 @@
28637 +--- a/net/netfilter/nf_conntrack_standalone.c
28638 ++++ b/net/netfilter/nf_conntrack_standalone.c
28639 +@@ -17,6 +17,7 @@
28640 + #include <linux/percpu.h>
28641 + #include <linux/netdevice.h>
28642 + #include <linux/security.h>
28643 ++#include <linux/inet.h>
28644 + #include <net/net_namespace.h>
28645 + #ifdef CONFIG_SYSCTL
28646 + #include <linux/sysctl.h>
28647 +@@ -268,10 +269,66 @@ static int ct_open(struct inode *inode,
28648 + sizeof(struct ct_iter_state));
28651 ++struct kill_request {
28652 ++ u16 family;
28653 ++ union nf_inet_addr addr;
28654 ++};
28656 ++static int kill_matching(struct nf_conn *i, void *data)
28658 ++ struct kill_request *kr = data;
28659 ++ struct nf_conntrack_tuple *t1 = &i->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
28660 ++ struct nf_conntrack_tuple *t2 = &i->tuplehash[IP_CT_DIR_REPLY].tuple;
28662 ++ if (!kr->family)
28663 ++ return 1;
28665 ++ if (t1->src.l3num != kr->family)
28666 ++ return 0;
28668 ++ return (nf_inet_addr_cmp(&kr->addr, &t1->src.u3) ||
28669 ++ nf_inet_addr_cmp(&kr->addr, &t1->dst.u3) ||
28670 ++ nf_inet_addr_cmp(&kr->addr, &t2->src.u3) ||
28671 ++ nf_inet_addr_cmp(&kr->addr, &t2->dst.u3));
28674 ++static ssize_t ct_file_write(struct file *file, const char __user *buf,
28675 ++ size_t count, loff_t *ppos)
28677 ++ struct seq_file *seq = file->private_data;
28678 ++ struct net *net = seq_file_net(seq);
28679 ++ struct kill_request kr = { };
28680 ++ char req[INET6_ADDRSTRLEN] = { };
28682 ++ if (count == 0)
28683 ++ return 0;
28685 ++ if (count >= INET6_ADDRSTRLEN)
28686 ++ count = INET6_ADDRSTRLEN - 1;
28688 ++ if (copy_from_user(req, buf, count))
28689 ++ return -EFAULT;
28691 ++ if (strnchr(req, count, ':')) {
28692 ++ kr.family = AF_INET6;
28693 ++ if (!in6_pton(req, count, (void *)&kr.addr, '\n', NULL))
28694 ++ return -EINVAL;
28695 ++ } else if (strnchr(req, count, '.')) {
28696 ++ kr.family = AF_INET;
28697 ++ if (!in4_pton(req, count, (void *)&kr.addr, '\n', NULL))
28698 ++ return -EINVAL;
28699 ++ }
28701 ++ nf_ct_iterate_cleanup(net, kill_matching, &kr, 0, 0);
28703 ++ return count;
28706 + static const struct file_operations ct_file_ops = {
28707 + .owner = THIS_MODULE,
28708 + .open = ct_open,
28709 + .read = seq_read,
28710 ++ .write = ct_file_write,
28711 + .llseek = seq_lseek,
28712 + .release = seq_release_net,
28713 + };
28714 +@@ -373,7 +430,7 @@ static int nf_conntrack_standalone_init_
28716 + struct proc_dir_entry *pde;
28718 +- pde = proc_create("nf_conntrack", 0440, net->proc_net, &ct_file_ops);
28719 ++ pde = proc_create("nf_conntrack", 0660, net->proc_net, &ct_file_ops);
28720 + if (!pde)
28721 + goto out_nf_conntrack;
28723 diff --git a/target/linux/generic/patches-3.16/610-netfilter_match_bypass_default_checks.patch b/target/linux/generic/patches-3.16/610-netfilter_match_bypass_default_checks.patch
28724 new file mode 100644
28725 index 000000000000..358d64b1a17e
28726 --- /dev/null
28727 +++ b/target/linux/generic/patches-3.16/610-netfilter_match_bypass_default_checks.patch
28728 @@ -0,0 +1,93 @@
28729 +--- a/include/uapi/linux/netfilter_ipv4/ip_tables.h
28730 ++++ b/include/uapi/linux/netfilter_ipv4/ip_tables.h
28731 +@@ -87,6 +87,7 @@ struct ipt_ip {
28732 + #define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */
28733 + #define IPT_F_GOTO 0x02 /* Set if jump is a goto */
28734 + #define IPT_F_MASK 0x03 /* All possible flag bits mask. */
28735 ++#define IPT_F_NO_DEF_MATCH 0x80 /* Internal: no default match rules present */
28737 + /* Values for "inv" field in struct ipt_ip. */
28738 + #define IPT_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */
28739 +--- a/net/ipv4/netfilter/ip_tables.c
28740 ++++ b/net/ipv4/netfilter/ip_tables.c
28741 +@@ -82,6 +82,9 @@ ip_packet_match(const struct iphdr *ip,
28743 + #define FWINV(bool, invflg) ((bool) ^ !!(ipinfo->invflags & (invflg)))
28745 ++ if (ipinfo->flags & IPT_F_NO_DEF_MATCH)
28746 ++ return true;
28748 + if (FWINV((ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr,
28749 + IPT_INV_SRCIP) ||
28750 + FWINV((ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr,
28751 +@@ -135,6 +138,29 @@ ip_packet_match(const struct iphdr *ip,
28752 + return true;
28755 ++static void
28756 ++ip_checkdefault(struct ipt_ip *ip)
28758 ++ static const char iface_mask[IFNAMSIZ] = {};
28760 ++ if (ip->invflags || ip->flags & IPT_F_FRAG)
28761 ++ return;
28763 ++ if (memcmp(ip->iniface_mask, iface_mask, IFNAMSIZ) != 0)
28764 ++ return;
28766 ++ if (memcmp(ip->outiface_mask, iface_mask, IFNAMSIZ) != 0)
28767 ++ return;
28769 ++ if (ip->smsk.s_addr || ip->dmsk.s_addr)
28770 ++ return;
28772 ++ if (ip->proto)
28773 ++ return;
28775 ++ ip->flags |= IPT_F_NO_DEF_MATCH;
28778 + static bool
28779 + ip_checkentry(const struct ipt_ip *ip)
28781 +@@ -565,7 +591,7 @@ static void cleanup_match(struct xt_entr
28784 + static int
28785 +-check_entry(const struct ipt_entry *e, const char *name)
28786 ++check_entry(struct ipt_entry *e, const char *name)
28788 + const struct xt_entry_target *t;
28790 +@@ -574,6 +600,8 @@ check_entry(const struct ipt_entry *e, c
28791 + return -EINVAL;
28794 ++ ip_checkdefault(&e->ip);
28796 + if (e->target_offset + sizeof(struct xt_entry_target) >
28797 + e->next_offset)
28798 + return -EINVAL;
28799 +@@ -935,6 +963,7 @@ copy_entries_to_user(unsigned int total_
28800 + const struct xt_table_info *private = table->private;
28801 + int ret = 0;
28802 + const void *loc_cpu_entry;
28803 ++ u8 flags;
28805 + counters = alloc_counters(table);
28806 + if (IS_ERR(counters))
28807 +@@ -965,6 +994,14 @@ copy_entries_to_user(unsigned int total_
28808 + ret = -EFAULT;
28809 + goto free_counters;
28812 ++ flags = e->ip.flags & IPT_F_MASK;
28813 ++ if (copy_to_user(userptr + off
28814 ++ + offsetof(struct ipt_entry, ip.flags),
28815 ++ &flags, sizeof(flags)) != 0) {
28816 ++ ret = -EFAULT;
28817 ++ goto free_counters;
28818 ++ }
28820 + for (i = sizeof(struct ipt_entry);
28821 + i < e->target_offset;
28822 diff --git a/target/linux/generic/patches-3.16/611-netfilter_match_bypass_default_table.patch b/target/linux/generic/patches-3.16/611-netfilter_match_bypass_default_table.patch
28823 new file mode 100644
28824 index 000000000000..ef993c864b0c
28825 --- /dev/null
28826 +++ b/target/linux/generic/patches-3.16/611-netfilter_match_bypass_default_table.patch
28827 @@ -0,0 +1,94 @@
28828 +--- a/net/ipv4/netfilter/ip_tables.c
28829 ++++ b/net/ipv4/netfilter/ip_tables.c
28830 +@@ -310,6 +310,33 @@ struct ipt_entry *ipt_next_entry(const s
28831 + return (void *)entry + entry->next_offset;
28834 ++static bool
28835 ++ipt_handle_default_rule(struct ipt_entry *e, unsigned int *verdict)
28837 ++ struct xt_entry_target *t;
28838 ++ struct xt_standard_target *st;
28840 ++ if (e->target_offset != sizeof(struct ipt_entry))
28841 ++ return false;
28843 ++ if (!(e->ip.flags & IPT_F_NO_DEF_MATCH))
28844 ++ return false;
28846 ++ t = ipt_get_target(e);
28847 ++ if (t->u.kernel.target->target)
28848 ++ return false;
28850 ++ st = (struct xt_standard_target *) t;
28851 ++ if (st->verdict == XT_RETURN)
28852 ++ return false;
28854 ++ if (st->verdict >= 0)
28855 ++ return false;
28857 ++ *verdict = (unsigned)(-st->verdict) - 1;
28858 ++ return true;
28861 + /* Returns one of the generic firewall policies, like NF_ACCEPT. */
28862 + unsigned int
28863 + ipt_do_table(struct sk_buff *skb,
28864 +@@ -331,9 +358,33 @@ ipt_do_table(struct sk_buff *skb,
28865 + unsigned int addend;
28867 + /* Initialization */
28868 ++ IP_NF_ASSERT(table->valid_hooks & (1 << hook));
28869 ++ local_bh_disable();
28870 ++ private = table->private;
28871 ++ cpu = smp_processor_id();
28872 ++ /*
28873 ++ * Ensure we load private-> members after we've fetched the base
28874 ++ * pointer.
28875 ++ */
28876 ++ smp_read_barrier_depends();
28877 ++ table_base = private->entries[cpu];
28879 ++ e = get_entry(table_base, private->hook_entry[hook]);
28880 ++ if (ipt_handle_default_rule(e, &verdict)) {
28881 ++ ADD_COUNTER(e->counters, skb->len, 1);
28882 ++ local_bh_enable();
28883 ++ return verdict;
28884 ++ }
28886 + ip = ip_hdr(skb);
28887 + indev = in ? in->name : nulldevname;
28888 + outdev = out ? out->name : nulldevname;
28890 ++ addend = xt_write_recseq_begin();
28891 ++ jumpstack = (struct ipt_entry **)private->jumpstack[cpu];
28892 ++ stackptr = per_cpu_ptr(private->stackptr, cpu);
28893 ++ origptr = *stackptr;
28895 + /* We handle fragments by dealing with the first fragment as
28896 + * if it was a normal packet. All other fragments are treated
28897 + * normally, except that they will NEVER match rules that ask
28898 +@@ -348,23 +399,6 @@ ipt_do_table(struct sk_buff *skb,
28899 + acpar.family = NFPROTO_IPV4;
28900 + acpar.hooknum = hook;
28902 +- IP_NF_ASSERT(table->valid_hooks & (1 << hook));
28903 +- local_bh_disable();
28904 +- addend = xt_write_recseq_begin();
28905 +- private = table->private;
28906 +- cpu = smp_processor_id();
28907 +- /*
28908 +- * Ensure we load private-> members after we've fetched the base
28909 +- * pointer.
28910 +- */
28911 +- smp_read_barrier_depends();
28912 +- table_base = private->entries[cpu];
28913 +- jumpstack = (struct ipt_entry **)private->jumpstack[cpu];
28914 +- stackptr = per_cpu_ptr(private->stackptr, cpu);
28915 +- origptr = *stackptr;
28917 +- e = get_entry(table_base, private->hook_entry[hook]);
28919 + pr_debug("Entering %s(hook %u); sp at %u (UF %p)\n",
28920 + table->name, hook, origptr,
28921 + get_entry(table_base, private->underflow[hook]));
28922 diff --git a/target/linux/generic/patches-3.16/612-netfilter_match_reduce_memory_access.patch b/target/linux/generic/patches-3.16/612-netfilter_match_reduce_memory_access.patch
28923 new file mode 100644
28924 index 000000000000..72172d8bb475
28925 --- /dev/null
28926 +++ b/target/linux/generic/patches-3.16/612-netfilter_match_reduce_memory_access.patch
28927 @@ -0,0 +1,16 @@
28928 +--- a/net/ipv4/netfilter/ip_tables.c
28929 ++++ b/net/ipv4/netfilter/ip_tables.c
28930 +@@ -85,9 +85,11 @@ ip_packet_match(const struct iphdr *ip,
28931 + if (ipinfo->flags & IPT_F_NO_DEF_MATCH)
28932 + return true;
28934 +- if (FWINV((ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr,
28935 ++ if (FWINV(ipinfo->smsk.s_addr &&
28936 ++ (ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr,
28937 + IPT_INV_SRCIP) ||
28938 +- FWINV((ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr,
28939 ++ FWINV(ipinfo->dmsk.s_addr &&
28940 ++ (ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr,
28941 + IPT_INV_DSTIP)) {
28942 + dprintf("Source or dest mismatch.\n");
28944 diff --git a/target/linux/generic/patches-3.16/613-netfilter_optional_tcp_window_check.patch b/target/linux/generic/patches-3.16/613-netfilter_optional_tcp_window_check.patch
28945 new file mode 100644
28946 index 000000000000..1d3b37cc10df
28947 --- /dev/null
28948 +++ b/target/linux/generic/patches-3.16/613-netfilter_optional_tcp_window_check.patch
28949 @@ -0,0 +1,36 @@
28950 +--- a/net/netfilter/nf_conntrack_proto_tcp.c
28951 ++++ b/net/netfilter/nf_conntrack_proto_tcp.c
28952 +@@ -33,6 +33,9 @@
28953 + #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
28954 + #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
28956 ++/* Do not check the TCP window for incoming packets */
28957 ++static int nf_ct_tcp_no_window_check __read_mostly = 1;
28959 + /* "Be conservative in what you do,
28960 + be liberal in what you accept from others."
28961 + If it's non-zero, we mark only out of window RST segments as INVALID. */
28962 +@@ -515,6 +518,9 @@ static bool tcp_in_window(const struct n
28963 + s32 receiver_offset;
28964 + bool res, in_recv_win;
28966 ++ if (nf_ct_tcp_no_window_check)
28967 ++ return true;
28969 + /*
28970 + * Get the required data from the packet.
28971 + */
28972 +@@ -1452,6 +1458,13 @@ static struct ctl_table tcp_sysctl_table
28973 + .mode = 0644,
28974 + .proc_handler = proc_dointvec,
28975 + },
28976 ++ {
28977 ++ .procname = "nf_conntrack_tcp_no_window_check",
28978 ++ .data = &nf_ct_tcp_no_window_check,
28979 ++ .maxlen = sizeof(unsigned int),
28980 ++ .mode = 0644,
28981 ++ .proc_handler = proc_dointvec,
28982 ++ },
28983 + { }
28984 + };
28986 diff --git a/target/linux/generic/patches-3.16/615-netfilter_add_xt_id_match.patch b/target/linux/generic/patches-3.16/615-netfilter_add_xt_id_match.patch
28987 new file mode 100644
28988 index 000000000000..ba7697074d5a
28989 --- /dev/null
28990 +++ b/target/linux/generic/patches-3.16/615-netfilter_add_xt_id_match.patch
28991 @@ -0,0 +1,95 @@
28992 +--- a/include/uapi/linux/netfilter/Kbuild
28993 ++++ b/include/uapi/linux/netfilter/Kbuild
28994 +@@ -55,6 +55,7 @@ header-y += xt_ecn.h
28995 + header-y += xt_esp.h
28996 + header-y += xt_hashlimit.h
28997 + header-y += xt_helper.h
28998 ++header-y += xt_id.h
28999 + header-y += xt_ipcomp.h
29000 + header-y += xt_iprange.h
29001 + header-y += xt_ipvs.h
29002 +--- /dev/null
29003 ++++ b/include/uapi/linux/netfilter/xt_id.h
29004 +@@ -0,0 +1,8 @@
29005 ++#ifndef _XT_ID_H
29006 ++#define _XT_ID_H
29008 ++struct xt_id_info {
29009 ++ u32 id;
29010 ++};
29012 ++#endif /* XT_ID_H */
29013 +--- a/net/netfilter/Kconfig
29014 ++++ b/net/netfilter/Kconfig
29015 +@@ -1121,6 +1121,13 @@ config NETFILTER_XT_MATCH_IPCOMP
29017 + To compile it as a module, choose M here. If unsure, say N.
29019 ++config NETFILTER_XT_MATCH_ID
29020 ++ tristate '"id" match support'
29021 ++ depends on NETFILTER_ADVANCED
29022 ++ ---help---
29023 ++ This option adds a `id' dummy-match, which allows you to put
29024 ++ numeric IDs into your iptables ruleset.
29026 + config NETFILTER_XT_MATCH_IPRANGE
29027 + tristate '"iprange" address range match support'
29028 + depends on NETFILTER_ADVANCED
29029 +--- a/net/netfilter/Makefile
29030 ++++ b/net/netfilter/Makefile
29031 +@@ -136,6 +136,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) +=
29032 + obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
29033 + obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
29034 + obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
29035 ++obj-$(CONFIG_NETFILTER_XT_MATCH_ID) += xt_id.o
29036 + obj-$(CONFIG_NETFILTER_XT_MATCH_IPCOMP) += xt_ipcomp.o
29037 + obj-$(CONFIG_NETFILTER_XT_MATCH_IPRANGE) += xt_iprange.o
29038 + obj-$(CONFIG_NETFILTER_XT_MATCH_IPVS) += xt_ipvs.o
29039 +--- /dev/null
29040 ++++ b/net/netfilter/xt_id.c
29041 +@@ -0,0 +1,45 @@
29042 ++/*
29043 ++ * Implements a dummy match to allow attaching IDs to rules
29044 ++ *
29045 ++ * 2014-08-01 Jo-Philipp Wich <jow@openwrt.org>
29046 ++ */
29048 ++#include <linux/module.h>
29049 ++#include <linux/skbuff.h>
29050 ++#include <linux/netfilter/x_tables.h>
29051 ++#include <linux/netfilter/xt_id.h>
29053 ++MODULE_AUTHOR("Jo-Philipp Wich <jow@openwrt.org>");
29054 ++MODULE_DESCRIPTION("Xtables: No-op match which can be tagged with a 32bit ID");
29055 ++MODULE_LICENSE("GPL");
29056 ++MODULE_ALIAS("ipt_id");
29057 ++MODULE_ALIAS("ip6t_id");
29059 ++static bool
29060 ++id_mt(const struct sk_buff *skb, struct xt_action_param *par)
29062 ++ /* We always match */
29063 ++ return true;
29066 ++static struct xt_match id_mt_reg __read_mostly = {
29067 ++ .name = "id",
29068 ++ .revision = 0,
29069 ++ .family = NFPROTO_UNSPEC,
29070 ++ .match = id_mt,
29071 ++ .matchsize = sizeof(struct xt_id_info),
29072 ++ .me = THIS_MODULE,
29073 ++};
29075 ++static int __init id_mt_init(void)
29077 ++ return xt_register_match(&id_mt_reg);
29080 ++static void __exit id_mt_exit(void)
29082 ++ xt_unregister_match(&id_mt_reg);
29085 ++module_init(id_mt_init);
29086 ++module_exit(id_mt_exit);
29087 diff --git a/target/linux/generic/patches-3.16/616-net_optimize_xfrm_calls.patch b/target/linux/generic/patches-3.16/616-net_optimize_xfrm_calls.patch
29088 new file mode 100644
29089 index 000000000000..a4e415730016
29090 --- /dev/null
29091 +++ b/target/linux/generic/patches-3.16/616-net_optimize_xfrm_calls.patch
29092 @@ -0,0 +1,12 @@
29093 +--- a/net/netfilter/nf_nat_core.c
29094 ++++ b/net/netfilter/nf_nat_core.c
29095 +@@ -90,6 +90,9 @@ int nf_xfrm_me_harder(struct sk_buff *sk
29096 + struct dst_entry *dst;
29097 + int err;
29099 ++ if (!dev_net(skb->dev)->xfrm.policy_count[XFRM_POLICY_OUT])
29100 ++ return 0;
29102 + err = xfrm_decode_session(skb, &fl, family);
29103 + if (err < 0)
29104 + return err;
29105 diff --git a/target/linux/generic/patches-3.16/617-netfilter_skip_filter_sysctl.patch b/target/linux/generic/patches-3.16/617-netfilter_skip_filter_sysctl.patch
29106 new file mode 100644
29107 index 000000000000..255eaae52e02
29108 --- /dev/null
29109 +++ b/target/linux/generic/patches-3.16/617-netfilter_skip_filter_sysctl.patch
29110 @@ -0,0 +1,87 @@
29111 +--- a/include/net/netns/conntrack.h
29112 ++++ b/include/net/netns/conntrack.h
29113 +@@ -73,6 +73,7 @@ struct netns_ct {
29114 + struct ctl_table_header *helper_sysctl_header;
29115 + #endif
29116 + char *slabname;
29117 ++ int skip_filter;
29118 + unsigned int sysctl_log_invalid; /* Log invalid packets */
29119 + unsigned int sysctl_events_retry_timeout;
29120 + int sysctl_events;
29121 +--- a/net/ipv4/netfilter/iptable_filter.c
29122 ++++ b/net/ipv4/netfilter/iptable_filter.c
29123 +@@ -15,6 +15,7 @@
29124 + #include <linux/netfilter_ipv4/ip_tables.h>
29125 + #include <linux/slab.h>
29126 + #include <net/ip.h>
29127 ++#include <net/netfilter/nf_conntrack.h>
29129 + MODULE_LICENSE("GPL");
29130 + MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
29131 +@@ -37,6 +38,7 @@ iptable_filter_hook(const struct nf_hook
29132 + const struct net_device *in, const struct net_device *out,
29133 + int (*okfn)(struct sk_buff *))
29135 ++ enum ip_conntrack_info ctinfo;
29136 + const struct net *net;
29138 + if (ops->hooknum == NF_INET_LOCAL_OUT &&
29139 +@@ -46,6 +48,11 @@ iptable_filter_hook(const struct nf_hook
29140 + return NF_ACCEPT;
29142 + net = dev_net((in != NULL) ? in : out);
29143 ++ nf_ct_get(skb, &ctinfo);
29144 ++ if ((ctinfo == IP_CT_ESTABLISHED_REPLY || ctinfo == IP_CT_ESTABLISHED) &&
29145 ++ net->ct.skip_filter)
29146 ++ return NF_ACCEPT;
29148 + return ipt_do_table(skb, ops->hooknum, in, out,
29149 + net->ipv4.iptable_filter);
29151 +--- a/net/ipv6/netfilter/ip6table_filter.c
29152 ++++ b/net/ipv6/netfilter/ip6table_filter.c
29153 +@@ -13,6 +13,7 @@
29154 + #include <linux/moduleparam.h>
29155 + #include <linux/netfilter_ipv6/ip6_tables.h>
29156 + #include <linux/slab.h>
29157 ++#include <net/netfilter/nf_conntrack.h>
29159 + MODULE_LICENSE("GPL");
29160 + MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
29161 +@@ -37,6 +38,12 @@ ip6table_filter_hook(const struct nf_hoo
29162 + int (*okfn)(struct sk_buff *))
29164 + const struct net *net = dev_net((in != NULL) ? in : out);
29165 ++ enum ip_conntrack_info ctinfo;
29167 ++ nf_ct_get(skb, &ctinfo);
29168 ++ if ((ctinfo == IP_CT_ESTABLISHED_REPLY || ctinfo == IP_CT_ESTABLISHED) &&
29169 ++ net->ct.skip_filter)
29170 ++ return NF_ACCEPT;
29172 + return ip6t_do_table(skb, ops->hooknum, in, out,
29173 + net->ipv6.ip6table_filter);
29174 +--- a/net/netfilter/nf_conntrack_standalone.c
29175 ++++ b/net/netfilter/nf_conntrack_standalone.c
29176 +@@ -510,6 +510,13 @@ static struct ctl_table nf_ct_sysctl_tab
29177 + .extra2 = &log_invalid_proto_max,
29178 + },
29180 ++ .procname = "nf_conntrack_skip_filter",
29181 ++ .data = &init_net.ct.skip_filter,
29182 ++ .maxlen = sizeof(int),
29183 ++ .mode = 0644,
29184 ++ .proc_handler = proc_dointvec,
29185 ++ },
29186 ++ {
29187 + .procname = "nf_conntrack_expect_max",
29188 + .data = &nf_ct_expect_max,
29189 + .maxlen = sizeof(int),
29190 +@@ -545,6 +552,7 @@ static int nf_conntrack_standalone_init_
29191 + table[2].data = &net->ct.htable_size;
29192 + table[3].data = &net->ct.sysctl_checksum;
29193 + table[4].data = &net->ct.sysctl_log_invalid;
29194 ++ table[5].data = &net->ct.skip_filter;
29196 + /* Don't export sysctls to unprivileged users */
29197 + if (net->user_ns != &init_user_ns)
29198 diff --git a/target/linux/generic/patches-3.16/620-sched_esfq.patch b/target/linux/generic/patches-3.16/620-sched_esfq.patch
29199 new file mode 100644
29200 index 000000000000..9726e4ac2f74
29201 --- /dev/null
29202 +++ b/target/linux/generic/patches-3.16/620-sched_esfq.patch
29203 @@ -0,0 +1,791 @@
29204 +--- a/include/uapi/linux/pkt_sched.h
29205 ++++ b/include/uapi/linux/pkt_sched.h
29206 +@@ -226,6 +226,33 @@ struct tc_sfq_xstats {
29207 + __s32 allot;
29208 + };
29210 ++/* ESFQ section */
29212 ++enum
29214 ++ /* traditional */
29215 ++ TCA_SFQ_HASH_CLASSIC,
29216 ++ TCA_SFQ_HASH_DST,
29217 ++ TCA_SFQ_HASH_SRC,
29218 ++ TCA_SFQ_HASH_FWMARK,
29219 ++ /* conntrack */
29220 ++ TCA_SFQ_HASH_CTORIGDST,
29221 ++ TCA_SFQ_HASH_CTORIGSRC,
29222 ++ TCA_SFQ_HASH_CTREPLDST,
29223 ++ TCA_SFQ_HASH_CTREPLSRC,
29224 ++ TCA_SFQ_HASH_CTNATCHG,
29225 ++};
29227 ++struct tc_esfq_qopt
29229 ++ unsigned quantum; /* Bytes per round allocated to flow */
29230 ++ int perturb_period; /* Period of hash perturbation */
29231 ++ __u32 limit; /* Maximal packets in queue */
29232 ++ unsigned divisor; /* Hash divisor */
29233 ++ unsigned flows; /* Maximal number of flows */
29234 ++ unsigned hash_kind; /* Hash function to use for flow identification */
29235 ++};
29237 + /* RED section */
29239 + enum {
29240 +--- a/net/sched/Kconfig
29241 ++++ b/net/sched/Kconfig
29242 +@@ -148,6 +148,37 @@ config NET_SCH_SFQ
29243 + To compile this code as a module, choose M here: the
29244 + module will be called sch_sfq.
29246 ++config NET_SCH_ESFQ
29247 ++ tristate "Enhanced Stochastic Fairness Queueing (ESFQ)"
29248 ++ ---help---
29249 ++ Say Y here if you want to use the Enhanced Stochastic Fairness
29250 ++ Queueing (ESFQ) packet scheduling algorithm for some of your network
29251 ++ devices or as a leaf discipline for a classful qdisc such as HTB or
29252 ++ CBQ (see the top of <file:net/sched/sch_esfq.c> for details and
29253 ++ references to the SFQ algorithm).
29255 ++ This is an enchanced SFQ version which allows you to control some
29256 ++ hardcoded values in the SFQ scheduler.
29258 ++ ESFQ also adds control of the hash function used to identify packet
29259 ++ flows. The original SFQ discipline hashes by connection; ESFQ add
29260 ++ several other hashing methods, such as by src IP or by dst IP, which
29261 ++ can be more fair to users in some networking situations.
29263 ++ To compile this code as a module, choose M here: the
29264 ++ module will be called sch_esfq.
29266 ++config NET_SCH_ESFQ_NFCT
29267 ++ bool "Connection Tracking Hash Types"
29268 ++ depends on NET_SCH_ESFQ && NF_CONNTRACK
29269 ++ ---help---
29270 ++ Say Y here to enable support for hashing based on netfilter connection
29271 ++ tracking information. This is useful for a router that is also using
29272 ++ NAT to connect privately-addressed hosts to the Internet. If you want
29273 ++ to provide fair distribution of upstream bandwidth, ESFQ must use
29274 ++ connection tracking information, since all outgoing packets will share
29275 ++ the same source address.
29277 + config NET_SCH_TEQL
29278 + tristate "True Link Equalizer (TEQL)"
29279 + ---help---
29280 +--- a/net/sched/Makefile
29281 ++++ b/net/sched/Makefile
29282 +@@ -26,6 +26,7 @@ obj-$(CONFIG_NET_SCH_INGRESS) += sch_ing
29283 + obj-$(CONFIG_NET_SCH_DSMARK) += sch_dsmark.o
29284 + obj-$(CONFIG_NET_SCH_SFB) += sch_sfb.o
29285 + obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o
29286 ++obj-$(CONFIG_NET_SCH_ESFQ) += sch_esfq.o
29287 + obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o
29288 + obj-$(CONFIG_NET_SCH_TEQL) += sch_teql.o
29289 + obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
29290 +--- /dev/null
29291 ++++ b/net/sched/sch_esfq.c
29292 +@@ -0,0 +1,702 @@
29293 ++/*
29294 ++ * net/sched/sch_esfq.c Extended Stochastic Fairness Queueing discipline.
29295 ++ *
29296 ++ * This program is free software; you can redistribute it and/or
29297 ++ * modify it under the terms of the GNU General Public License
29298 ++ * as published by the Free Software Foundation; either version
29299 ++ * 2 of the License, or (at your option) any later version.
29300 ++ *
29301 ++ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
29302 ++ *
29303 ++ * Changes: Alexander Atanasov, <alex@ssi.bg>
29304 ++ * Added dynamic depth,limit,divisor,hash_kind options.
29305 ++ * Added dst and src hashes.
29306 ++ *
29307 ++ * Alexander Clouter, <alex@digriz.org.uk>
29308 ++ * Ported ESFQ to Linux 2.6.
29309 ++ *
29310 ++ * Corey Hickey, <bugfood-c@fatooh.org>
29311 ++ * Maintenance of the Linux 2.6 port.
29312 ++ * Added fwmark hash (thanks to Robert Kurjata).
29313 ++ * Added usage of jhash.
29314 ++ * Added conntrack support.
29315 ++ * Added ctnatchg hash (thanks to Ben Pfountz).
29316 ++ */
29318 ++#include <linux/module.h>
29319 ++#include <asm/uaccess.h>
29320 ++#include <linux/bitops.h>
29321 ++#include <linux/types.h>
29322 ++#include <linux/kernel.h>
29323 ++#include <linux/jiffies.h>
29324 ++#include <linux/string.h>
29325 ++#include <linux/mm.h>
29326 ++#include <linux/socket.h>
29327 ++#include <linux/sockios.h>
29328 ++#include <linux/in.h>
29329 ++#include <linux/errno.h>
29330 ++#include <linux/interrupt.h>
29331 ++#include <linux/if_ether.h>
29332 ++#include <linux/inet.h>
29333 ++#include <linux/netdevice.h>
29334 ++#include <linux/etherdevice.h>
29335 ++#include <linux/notifier.h>
29336 ++#include <linux/init.h>
29337 ++#include <net/ip.h>
29338 ++#include <net/netlink.h>
29339 ++#include <linux/ipv6.h>
29340 ++#include <net/route.h>
29341 ++#include <linux/skbuff.h>
29342 ++#include <net/sock.h>
29343 ++#include <net/pkt_sched.h>
29344 ++#include <linux/jhash.h>
29345 ++#ifdef CONFIG_NET_SCH_ESFQ_NFCT
29346 ++#include <net/netfilter/nf_conntrack.h>
29347 ++#endif
29349 ++/* Stochastic Fairness Queuing algorithm.
29350 ++ For more comments look at sch_sfq.c.
29351 ++ The difference is that you can change limit, depth,
29352 ++ hash table size and choose alternate hash types.
29354 ++ classic: same as in sch_sfq.c
29355 ++ dst: destination IP address
29356 ++ src: source IP address
29357 ++ fwmark: netfilter mark value
29358 ++ ctorigdst: original destination IP address
29359 ++ ctorigsrc: original source IP address
29360 ++ ctrepldst: reply destination IP address
29361 ++ ctreplsrc: reply source IP
29363 ++*/
29365 ++#define ESFQ_HEAD 0
29366 ++#define ESFQ_TAIL 1
29368 ++/* This type should contain at least SFQ_DEPTH*2 values */
29369 ++typedef unsigned int esfq_index;
29371 ++struct esfq_head
29373 ++ esfq_index next;
29374 ++ esfq_index prev;
29375 ++};
29377 ++struct esfq_sched_data
29379 ++/* Parameters */
29380 ++ int perturb_period;
29381 ++ unsigned quantum; /* Allotment per round: MUST BE >= MTU */
29382 ++ int limit;
29383 ++ unsigned depth;
29384 ++ unsigned hash_divisor;
29385 ++ unsigned hash_kind;
29386 ++/* Variables */
29387 ++ struct timer_list perturb_timer;
29388 ++ int perturbation;
29389 ++ esfq_index tail; /* Index of current slot in round */
29390 ++ esfq_index max_depth; /* Maximal depth */
29392 ++ esfq_index *ht; /* Hash table */
29393 ++ esfq_index *next; /* Active slots link */
29394 ++ short *allot; /* Current allotment per slot */
29395 ++ unsigned short *hash; /* Hash value indexed by slots */
29396 ++ struct sk_buff_head *qs; /* Slot queue */
29397 ++ struct esfq_head *dep; /* Linked list of slots, indexed by depth */
29398 ++};
29400 ++/* This contains the info we will hash. */
29401 ++struct esfq_packet_info
29403 ++ u32 proto; /* protocol or port */
29404 ++ u32 src; /* source from packet header */
29405 ++ u32 dst; /* destination from packet header */
29406 ++ u32 ctorigsrc; /* original source from conntrack */
29407 ++ u32 ctorigdst; /* original destination from conntrack */
29408 ++ u32 ctreplsrc; /* reply source from conntrack */
29409 ++ u32 ctrepldst; /* reply destination from conntrack */
29410 ++ u32 mark; /* netfilter mark (fwmark) */
29411 ++};
29413 ++static __inline__ unsigned esfq_jhash_1word(struct esfq_sched_data *q,u32 a)
29415 ++ return jhash_1word(a, q->perturbation) & (q->hash_divisor-1);
29418 ++static __inline__ unsigned esfq_jhash_2words(struct esfq_sched_data *q, u32 a, u32 b)
29420 ++ return jhash_2words(a, b, q->perturbation) & (q->hash_divisor-1);
29423 ++static __inline__ unsigned esfq_jhash_3words(struct esfq_sched_data *q, u32 a, u32 b, u32 c)
29425 ++ return jhash_3words(a, b, c, q->perturbation) & (q->hash_divisor-1);
29428 ++static unsigned esfq_hash(struct esfq_sched_data *q, struct sk_buff *skb)
29430 ++ struct esfq_packet_info info;
29431 ++#ifdef CONFIG_NET_SCH_ESFQ_NFCT
29432 ++ enum ip_conntrack_info ctinfo;
29433 ++ struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
29434 ++#endif
29436 ++ switch (skb->protocol) {
29437 ++ case __constant_htons(ETH_P_IP):
29438 ++ {
29439 ++ struct iphdr *iph = ip_hdr(skb);
29440 ++ info.dst = iph->daddr;
29441 ++ info.src = iph->saddr;
29442 ++ if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
29443 ++ (iph->protocol == IPPROTO_TCP ||
29444 ++ iph->protocol == IPPROTO_UDP ||
29445 ++ iph->protocol == IPPROTO_SCTP ||
29446 ++ iph->protocol == IPPROTO_DCCP ||
29447 ++ iph->protocol == IPPROTO_ESP))
29448 ++ info.proto = *(((u32*)iph) + iph->ihl);
29449 ++ else
29450 ++ info.proto = iph->protocol;
29451 ++ break;
29452 ++ }
29453 ++ case __constant_htons(ETH_P_IPV6):
29454 ++ {
29455 ++ struct ipv6hdr *iph = ipv6_hdr(skb);
29456 ++ /* Hash ipv6 addresses into a u32. This isn't ideal,
29457 ++ * but the code is simple. */
29458 ++ info.dst = jhash2(iph->daddr.s6_addr32, 4, q->perturbation);
29459 ++ info.src = jhash2(iph->saddr.s6_addr32, 4, q->perturbation);
29460 ++ if (iph->nexthdr == IPPROTO_TCP ||
29461 ++ iph->nexthdr == IPPROTO_UDP ||
29462 ++ iph->nexthdr == IPPROTO_SCTP ||
29463 ++ iph->nexthdr == IPPROTO_DCCP ||
29464 ++ iph->nexthdr == IPPROTO_ESP)
29465 ++ info.proto = *(u32*)&iph[1];
29466 ++ else
29467 ++ info.proto = iph->nexthdr;
29468 ++ break;
29469 ++ }
29470 ++ default:
29471 ++ info.dst = (u32)(unsigned long)skb_dst(skb);
29472 ++ info.src = (u32)(unsigned long)skb->sk;
29473 ++ info.proto = skb->protocol;
29474 ++ }
29476 ++ info.mark = skb->mark;
29478 ++#ifdef CONFIG_NET_SCH_ESFQ_NFCT
29479 ++ /* defaults if there is no conntrack info */
29480 ++ info.ctorigsrc = info.src;
29481 ++ info.ctorigdst = info.dst;
29482 ++ info.ctreplsrc = info.dst;
29483 ++ info.ctrepldst = info.src;
29484 ++ /* collect conntrack info */
29485 ++ if (ct && ct != &nf_conntrack_untracked) {
29486 ++ if (skb->protocol == __constant_htons(ETH_P_IP)) {
29487 ++ info.ctorigsrc = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
29488 ++ info.ctorigdst = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
29489 ++ info.ctreplsrc = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
29490 ++ info.ctrepldst = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
29491 ++ }
29492 ++ else if (skb->protocol == __constant_htons(ETH_P_IPV6)) {
29493 ++ /* Again, hash ipv6 addresses into a single u32. */
29494 ++ info.ctorigsrc = jhash2(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip6, 4, q->perturbation);
29495 ++ info.ctorigdst = jhash2(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip6, 4, q->perturbation);
29496 ++ info.ctreplsrc = jhash2(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip6, 4, q->perturbation);
29497 ++ info.ctrepldst = jhash2(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip6, 4, q->perturbation);
29498 ++ }
29500 ++ }
29501 ++#endif
29503 ++ switch(q->hash_kind) {
29504 ++ case TCA_SFQ_HASH_CLASSIC:
29505 ++ return esfq_jhash_3words(q, info.dst, info.src, info.proto);
29506 ++ case TCA_SFQ_HASH_DST:
29507 ++ return esfq_jhash_1word(q, info.dst);
29508 ++ case TCA_SFQ_HASH_SRC:
29509 ++ return esfq_jhash_1word(q, info.src);
29510 ++ case TCA_SFQ_HASH_FWMARK:
29511 ++ return esfq_jhash_1word(q, info.mark);
29512 ++#ifdef CONFIG_NET_SCH_ESFQ_NFCT
29513 ++ case TCA_SFQ_HASH_CTORIGDST:
29514 ++ return esfq_jhash_1word(q, info.ctorigdst);
29515 ++ case TCA_SFQ_HASH_CTORIGSRC:
29516 ++ return esfq_jhash_1word(q, info.ctorigsrc);
29517 ++ case TCA_SFQ_HASH_CTREPLDST:
29518 ++ return esfq_jhash_1word(q, info.ctrepldst);
29519 ++ case TCA_SFQ_HASH_CTREPLSRC:
29520 ++ return esfq_jhash_1word(q, info.ctreplsrc);
29521 ++ case TCA_SFQ_HASH_CTNATCHG:
29522 ++ {
29523 ++ if (info.ctorigdst == info.ctreplsrc)
29524 ++ return esfq_jhash_1word(q, info.ctorigsrc);
29525 ++ return esfq_jhash_1word(q, info.ctreplsrc);
29526 ++ }
29527 ++#endif
29528 ++ default:
29529 ++ if (net_ratelimit())
29530 ++ printk(KERN_WARNING "ESFQ: Unknown hash method. Falling back to classic.\n");
29531 ++ }
29532 ++ return esfq_jhash_3words(q, info.dst, info.src, info.proto);
29535 ++static inline void esfq_link(struct esfq_sched_data *q, esfq_index x)
29537 ++ esfq_index p, n;
29538 ++ int d = q->qs[x].qlen + q->depth;
29540 ++ p = d;
29541 ++ n = q->dep[d].next;
29542 ++ q->dep[x].next = n;
29543 ++ q->dep[x].prev = p;
29544 ++ q->dep[p].next = q->dep[n].prev = x;
29547 ++static inline void esfq_dec(struct esfq_sched_data *q, esfq_index x)
29549 ++ esfq_index p, n;
29551 ++ n = q->dep[x].next;
29552 ++ p = q->dep[x].prev;
29553 ++ q->dep[p].next = n;
29554 ++ q->dep[n].prev = p;
29556 ++ if (n == p && q->max_depth == q->qs[x].qlen + 1)
29557 ++ q->max_depth--;
29559 ++ esfq_link(q, x);
29562 ++static inline void esfq_inc(struct esfq_sched_data *q, esfq_index x)
29564 ++ esfq_index p, n;
29565 ++ int d;
29567 ++ n = q->dep[x].next;
29568 ++ p = q->dep[x].prev;
29569 ++ q->dep[p].next = n;
29570 ++ q->dep[n].prev = p;
29571 ++ d = q->qs[x].qlen;
29572 ++ if (q->max_depth < d)
29573 ++ q->max_depth = d;
29575 ++ esfq_link(q, x);
29578 ++static unsigned int esfq_drop(struct Qdisc *sch)
29580 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29581 ++ esfq_index d = q->max_depth;
29582 ++ struct sk_buff *skb;
29583 ++ unsigned int len;
29585 ++ /* Queue is full! Find the longest slot and
29586 ++ drop a packet from it */
29588 ++ if (d > 1) {
29589 ++ esfq_index x = q->dep[d+q->depth].next;
29590 ++ skb = q->qs[x].prev;
29591 ++ len = skb->len;
29592 ++ __skb_unlink(skb, &q->qs[x]);
29593 ++ kfree_skb(skb);
29594 ++ esfq_dec(q, x);
29595 ++ sch->q.qlen--;
29596 ++ sch->qstats.drops++;
29597 ++ sch->qstats.backlog -= len;
29598 ++ return len;
29599 ++ }
29601 ++ if (d == 1) {
29602 ++ /* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */
29603 ++ d = q->next[q->tail];
29604 ++ q->next[q->tail] = q->next[d];
29605 ++ q->allot[q->next[d]] += q->quantum;
29606 ++ skb = q->qs[d].prev;
29607 ++ len = skb->len;
29608 ++ __skb_unlink(skb, &q->qs[d]);
29609 ++ kfree_skb(skb);
29610 ++ esfq_dec(q, d);
29611 ++ sch->q.qlen--;
29612 ++ q->ht[q->hash[d]] = q->depth;
29613 ++ sch->qstats.drops++;
29614 ++ sch->qstats.backlog -= len;
29615 ++ return len;
29616 ++ }
29618 ++ return 0;
29621 ++static void esfq_q_enqueue(struct sk_buff *skb, struct esfq_sched_data *q, unsigned int end)
29623 ++ unsigned hash = esfq_hash(q, skb);
29624 ++ unsigned depth = q->depth;
29625 ++ esfq_index x;
29627 ++ x = q->ht[hash];
29628 ++ if (x == depth) {
29629 ++ q->ht[hash] = x = q->dep[depth].next;
29630 ++ q->hash[x] = hash;
29631 ++ }
29633 ++ if (end == ESFQ_TAIL)
29634 ++ __skb_queue_tail(&q->qs[x], skb);
29635 ++ else
29636 ++ __skb_queue_head(&q->qs[x], skb);
29638 ++ esfq_inc(q, x);
29639 ++ if (q->qs[x].qlen == 1) { /* The flow is new */
29640 ++ if (q->tail == depth) { /* It is the first flow */
29641 ++ q->tail = x;
29642 ++ q->next[x] = x;
29643 ++ q->allot[x] = q->quantum;
29644 ++ } else {
29645 ++ q->next[x] = q->next[q->tail];
29646 ++ q->next[q->tail] = x;
29647 ++ q->tail = x;
29648 ++ }
29649 ++ }
29652 ++static int esfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
29654 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29655 ++ esfq_q_enqueue(skb, q, ESFQ_TAIL);
29656 ++ sch->qstats.backlog += skb->len;
29657 ++ if (++sch->q.qlen < q->limit-1) {
29658 ++ sch->bstats.bytes += skb->len;
29659 ++ sch->bstats.packets++;
29660 ++ return 0;
29661 ++ }
29663 ++ sch->qstats.drops++;
29664 ++ esfq_drop(sch);
29665 ++ return NET_XMIT_CN;
29668 ++static struct sk_buff *esfq_peek(struct Qdisc* sch)
29670 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29671 ++ esfq_index a;
29673 ++ /* No active slots */
29674 ++ if (q->tail == q->depth)
29675 ++ return NULL;
29677 ++ a = q->next[q->tail];
29678 ++ return skb_peek(&q->qs[a]);
29681 ++static struct sk_buff *esfq_q_dequeue(struct esfq_sched_data *q)
29683 ++ struct sk_buff *skb;
29684 ++ unsigned depth = q->depth;
29685 ++ esfq_index a, old_a;
29687 ++ /* No active slots */
29688 ++ if (q->tail == depth)
29689 ++ return NULL;
29691 ++ a = old_a = q->next[q->tail];
29693 ++ /* Grab packet */
29694 ++ skb = __skb_dequeue(&q->qs[a]);
29695 ++ esfq_dec(q, a);
29697 ++ /* Is the slot empty? */
29698 ++ if (q->qs[a].qlen == 0) {
29699 ++ q->ht[q->hash[a]] = depth;
29700 ++ a = q->next[a];
29701 ++ if (a == old_a) {
29702 ++ q->tail = depth;
29703 ++ return skb;
29704 ++ }
29705 ++ q->next[q->tail] = a;
29706 ++ q->allot[a] += q->quantum;
29707 ++ } else if ((q->allot[a] -= skb->len) <= 0) {
29708 ++ q->tail = a;
29709 ++ a = q->next[a];
29710 ++ q->allot[a] += q->quantum;
29711 ++ }
29713 ++ return skb;
29716 ++static struct sk_buff *esfq_dequeue(struct Qdisc* sch)
29718 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29719 ++ struct sk_buff *skb;
29721 ++ skb = esfq_q_dequeue(q);
29722 ++ if (skb == NULL)
29723 ++ return NULL;
29724 ++ sch->q.qlen--;
29725 ++ sch->qstats.backlog -= skb->len;
29726 ++ return skb;
29729 ++static void esfq_q_destroy(struct esfq_sched_data *q)
29731 ++ del_timer(&q->perturb_timer);
29732 ++ if(q->ht)
29733 ++ kfree(q->ht);
29734 ++ if(q->dep)
29735 ++ kfree(q->dep);
29736 ++ if(q->next)
29737 ++ kfree(q->next);
29738 ++ if(q->allot)
29739 ++ kfree(q->allot);
29740 ++ if(q->hash)
29741 ++ kfree(q->hash);
29742 ++ if(q->qs)
29743 ++ kfree(q->qs);
29746 ++static void esfq_destroy(struct Qdisc *sch)
29748 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29749 ++ esfq_q_destroy(q);
29753 ++static void esfq_reset(struct Qdisc* sch)
29755 ++ struct sk_buff *skb;
29757 ++ while ((skb = esfq_dequeue(sch)) != NULL)
29758 ++ kfree_skb(skb);
29761 ++static void esfq_perturbation(unsigned long arg)
29763 ++ struct Qdisc *sch = (struct Qdisc*)arg;
29764 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29766 ++ q->perturbation = prandom_u32()&0x1F;
29768 ++ if (q->perturb_period) {
29769 ++ q->perturb_timer.expires = jiffies + q->perturb_period;
29770 ++ add_timer(&q->perturb_timer);
29771 ++ }
29774 ++static unsigned int esfq_check_hash(unsigned int kind)
29776 ++ switch (kind) {
29777 ++ case TCA_SFQ_HASH_CTORIGDST:
29778 ++ case TCA_SFQ_HASH_CTORIGSRC:
29779 ++ case TCA_SFQ_HASH_CTREPLDST:
29780 ++ case TCA_SFQ_HASH_CTREPLSRC:
29781 ++ case TCA_SFQ_HASH_CTNATCHG:
29782 ++#ifndef CONFIG_NET_SCH_ESFQ_NFCT
29783 ++ {
29784 ++ if (net_ratelimit())
29785 ++ printk(KERN_WARNING "ESFQ: Conntrack hash types disabled in kernel config. Falling back to classic.\n");
29786 ++ return TCA_SFQ_HASH_CLASSIC;
29787 ++ }
29788 ++#endif
29789 ++ case TCA_SFQ_HASH_CLASSIC:
29790 ++ case TCA_SFQ_HASH_DST:
29791 ++ case TCA_SFQ_HASH_SRC:
29792 ++ case TCA_SFQ_HASH_FWMARK:
29793 ++ return kind;
29794 ++ default:
29795 ++ {
29796 ++ if (net_ratelimit())
29797 ++ printk(KERN_WARNING "ESFQ: Unknown hash type. Falling back to classic.\n");
29798 ++ return TCA_SFQ_HASH_CLASSIC;
29799 ++ }
29800 ++ }
29803 ++static int esfq_q_init(struct esfq_sched_data *q, struct nlattr *opt)
29805 ++ struct tc_esfq_qopt *ctl = nla_data(opt);
29806 ++ esfq_index p = ~0U/2;
29807 ++ int i;
29809 ++ if (opt && opt->nla_len < nla_attr_size(sizeof(*ctl)))
29810 ++ return -EINVAL;
29812 ++ q->perturbation = 0;
29813 ++ q->hash_kind = TCA_SFQ_HASH_CLASSIC;
29814 ++ q->max_depth = 0;
29815 ++ if (opt == NULL) {
29816 ++ q->perturb_period = 0;
29817 ++ q->hash_divisor = 1024;
29818 ++ q->tail = q->limit = q->depth = 128;
29820 ++ } else {
29821 ++ struct tc_esfq_qopt *ctl = nla_data(opt);
29822 ++ if (ctl->quantum)
29823 ++ q->quantum = ctl->quantum;
29824 ++ q->perturb_period = ctl->perturb_period*HZ;
29825 ++ q->hash_divisor = ctl->divisor ? : 1024;
29826 ++ q->tail = q->limit = q->depth = ctl->flows ? : 128;
29828 ++ if ( q->depth > p - 1 )
29829 ++ return -EINVAL;
29831 ++ if (ctl->limit)
29832 ++ q->limit = min_t(u32, ctl->limit, q->depth);
29834 ++ if (ctl->hash_kind) {
29835 ++ q->hash_kind = esfq_check_hash(ctl->hash_kind);
29836 ++ }
29837 ++ }
29839 ++ q->ht = kmalloc(q->hash_divisor*sizeof(esfq_index), GFP_KERNEL);
29840 ++ if (!q->ht)
29841 ++ goto err_case;
29842 ++ q->dep = kmalloc((1+q->depth*2)*sizeof(struct esfq_head), GFP_KERNEL);
29843 ++ if (!q->dep)
29844 ++ goto err_case;
29845 ++ q->next = kmalloc(q->depth*sizeof(esfq_index), GFP_KERNEL);
29846 ++ if (!q->next)
29847 ++ goto err_case;
29848 ++ q->allot = kmalloc(q->depth*sizeof(short), GFP_KERNEL);
29849 ++ if (!q->allot)
29850 ++ goto err_case;
29851 ++ q->hash = kmalloc(q->depth*sizeof(unsigned short), GFP_KERNEL);
29852 ++ if (!q->hash)
29853 ++ goto err_case;
29854 ++ q->qs = kmalloc(q->depth*sizeof(struct sk_buff_head), GFP_KERNEL);
29855 ++ if (!q->qs)
29856 ++ goto err_case;
29858 ++ for (i=0; i< q->hash_divisor; i++)
29859 ++ q->ht[i] = q->depth;
29860 ++ for (i=0; i<q->depth; i++) {
29861 ++ skb_queue_head_init(&q->qs[i]);
29862 ++ q->dep[i+q->depth].next = i+q->depth;
29863 ++ q->dep[i+q->depth].prev = i+q->depth;
29864 ++ }
29866 ++ for (i=0; i<q->depth; i++)
29867 ++ esfq_link(q, i);
29868 ++ return 0;
29869 ++err_case:
29870 ++ esfq_q_destroy(q);
29871 ++ return -ENOBUFS;
29874 ++static int esfq_init(struct Qdisc *sch, struct nlattr *opt)
29876 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29877 ++ int err;
29879 ++ q->quantum = psched_mtu(qdisc_dev(sch)); /* default */
29880 ++ if ((err = esfq_q_init(q, opt)))
29881 ++ return err;
29883 ++ init_timer(&q->perturb_timer);
29884 ++ q->perturb_timer.data = (unsigned long)sch;
29885 ++ q->perturb_timer.function = esfq_perturbation;
29886 ++ if (q->perturb_period) {
29887 ++ q->perturb_timer.expires = jiffies + q->perturb_period;
29888 ++ add_timer(&q->perturb_timer);
29889 ++ }
29891 ++ return 0;
29894 ++static int esfq_change(struct Qdisc *sch, struct nlattr *opt)
29896 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29897 ++ struct esfq_sched_data new;
29898 ++ struct sk_buff *skb;
29899 ++ int err;
29901 ++ /* set up new queue */
29902 ++ memset(&new, 0, sizeof(struct esfq_sched_data));
29903 ++ new.quantum = psched_mtu(qdisc_dev(sch)); /* default */
29904 ++ if ((err = esfq_q_init(&new, opt)))
29905 ++ return err;
29907 ++ /* copy all packets from the old queue to the new queue */
29908 ++ sch_tree_lock(sch);
29909 ++ while ((skb = esfq_q_dequeue(q)) != NULL)
29910 ++ esfq_q_enqueue(skb, &new, ESFQ_TAIL);
29912 ++ /* clean up the old queue */
29913 ++ esfq_q_destroy(q);
29915 ++ /* copy elements of the new queue into the old queue */
29916 ++ q->perturb_period = new.perturb_period;
29917 ++ q->quantum = new.quantum;
29918 ++ q->limit = new.limit;
29919 ++ q->depth = new.depth;
29920 ++ q->hash_divisor = new.hash_divisor;
29921 ++ q->hash_kind = new.hash_kind;
29922 ++ q->tail = new.tail;
29923 ++ q->max_depth = new.max_depth;
29924 ++ q->ht = new.ht;
29925 ++ q->dep = new.dep;
29926 ++ q->next = new.next;
29927 ++ q->allot = new.allot;
29928 ++ q->hash = new.hash;
29929 ++ q->qs = new.qs;
29931 ++ /* finish up */
29932 ++ if (q->perturb_period) {
29933 ++ q->perturb_timer.expires = jiffies + q->perturb_period;
29934 ++ add_timer(&q->perturb_timer);
29935 ++ } else {
29936 ++ q->perturbation = 0;
29937 ++ }
29938 ++ sch_tree_unlock(sch);
29939 ++ return 0;
29942 ++static int esfq_dump(struct Qdisc *sch, struct sk_buff *skb)
29944 ++ struct esfq_sched_data *q = qdisc_priv(sch);
29945 ++ unsigned char *b = skb_tail_pointer(skb);
29946 ++ struct tc_esfq_qopt opt;
29948 ++ opt.quantum = q->quantum;
29949 ++ opt.perturb_period = q->perturb_period/HZ;
29951 ++ opt.limit = q->limit;
29952 ++ opt.divisor = q->hash_divisor;
29953 ++ opt.flows = q->depth;
29954 ++ opt.hash_kind = q->hash_kind;
29956 ++ if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
29957 ++ goto nla_put_failure;
29959 ++ return skb->len;
29961 ++nla_put_failure:
29962 ++ nlmsg_trim(skb, b);
29963 ++ return -1;
29966 ++static struct Qdisc_ops esfq_qdisc_ops =
29968 ++ .next = NULL,
29969 ++ .cl_ops = NULL,
29970 ++ .id = "esfq",
29971 ++ .priv_size = sizeof(struct esfq_sched_data),
29972 ++ .enqueue = esfq_enqueue,
29973 ++ .dequeue = esfq_dequeue,
29974 ++ .peek = esfq_peek,
29975 ++ .drop = esfq_drop,
29976 ++ .init = esfq_init,
29977 ++ .reset = esfq_reset,
29978 ++ .destroy = esfq_destroy,
29979 ++ .change = esfq_change,
29980 ++ .dump = esfq_dump,
29981 ++ .owner = THIS_MODULE,
29982 ++};
29984 ++static int __init esfq_module_init(void)
29986 ++ return register_qdisc(&esfq_qdisc_ops);
29988 ++static void __exit esfq_module_exit(void)
29990 ++ unregister_qdisc(&esfq_qdisc_ops);
29992 ++module_init(esfq_module_init)
29993 ++module_exit(esfq_module_exit)
29994 ++MODULE_LICENSE("GPL");
29995 diff --git a/target/linux/generic/patches-3.16/630-packet_socket_type.patch b/target/linux/generic/patches-3.16/630-packet_socket_type.patch
29996 new file mode 100644
29997 index 000000000000..4f3f5e8b7f44
29998 --- /dev/null
29999 +++ b/target/linux/generic/patches-3.16/630-packet_socket_type.patch
30000 @@ -0,0 +1,134 @@
30001 +This patch allows the user to specify desired packet types (outgoing,
30002 +broadcast, unicast, etc.) on packet sockets via setsockopt.
30003 +This can reduce the load in situations where only a limited number
30004 +of packet types are necessary
30006 +Signed-off-by: Felix Fietkau <nbd@openwrt.org>
30008 +--- a/include/uapi/linux/if_packet.h
30009 ++++ b/include/uapi/linux/if_packet.h
30010 +@@ -31,6 +31,8 @@ struct sockaddr_ll {
30011 + #define PACKET_KERNEL 7 /* To kernel space */
30012 + /* Unused, PACKET_FASTROUTE and PACKET_LOOPBACK are invisible to user space */
30013 + #define PACKET_FASTROUTE 6 /* Fastrouted frame */
30014 ++#define PACKET_MASK_ANY 0xffffffff /* mask for packet type bits */
30017 + /* Packet socket options */
30019 +@@ -54,6 +56,7 @@ struct sockaddr_ll {
30020 + #define PACKET_FANOUT 18
30021 + #define PACKET_TX_HAS_OFF 19
30022 + #define PACKET_QDISC_BYPASS 20
30023 ++#define PACKET_RECV_TYPE 21
30025 + #define PACKET_FANOUT_HASH 0
30026 + #define PACKET_FANOUT_LB 1
30027 +--- a/net/packet/af_packet.c
30028 ++++ b/net/packet/af_packet.c
30029 +@@ -1539,6 +1539,7 @@ static int packet_rcv_spkt(struct sk_buf
30031 + struct sock *sk;
30032 + struct sockaddr_pkt *spkt;
30033 ++ struct packet_sock *po;
30035 + /*
30036 + * When we registered the protocol we saved the socket in the data
30037 +@@ -1546,6 +1547,7 @@ static int packet_rcv_spkt(struct sk_buf
30038 + */
30040 + sk = pt->af_packet_priv;
30041 ++ po = pkt_sk(sk);
30043 + /*
30044 + * Yank back the headers [hope the device set this
30045 +@@ -1558,7 +1560,7 @@ static int packet_rcv_spkt(struct sk_buf
30046 + * so that this procedure is noop.
30047 + */
30049 +- if (skb->pkt_type == PACKET_LOOPBACK)
30050 ++ if (!(po->pkt_type & (1 << skb->pkt_type)))
30051 + goto out;
30053 + if (!net_eq(dev_net(dev), sock_net(sk)))
30054 +@@ -1765,12 +1767,12 @@ static int packet_rcv(struct sk_buff *sk
30055 + int skb_len = skb->len;
30056 + unsigned int snaplen, res;
30058 +- if (skb->pkt_type == PACKET_LOOPBACK)
30059 +- goto drop;
30061 + sk = pt->af_packet_priv;
30062 + po = pkt_sk(sk);
30064 ++ if (!(po->pkt_type & (1 << skb->pkt_type)))
30065 ++ goto drop;
30067 + if (!net_eq(dev_net(dev), sock_net(sk)))
30068 + goto drop;
30070 +@@ -1890,12 +1892,12 @@ static int tpacket_rcv(struct sk_buff *s
30071 + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32);
30072 + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48);
30074 +- if (skb->pkt_type == PACKET_LOOPBACK)
30075 +- goto drop;
30077 + sk = pt->af_packet_priv;
30078 + po = pkt_sk(sk);
30080 ++ if (!(po->pkt_type & (1 << skb->pkt_type)))
30081 ++ goto drop;
30083 + if (!net_eq(dev_net(dev), sock_net(sk)))
30084 + goto drop;
30086 +@@ -2810,6 +2812,7 @@ static int packet_create(struct net *net
30087 + spin_lock_init(&po->bind_lock);
30088 + mutex_init(&po->pg_vec_lock);
30089 + po->prot_hook.func = packet_rcv;
30090 ++ po->pkt_type = PACKET_MASK_ANY & ~(1 << PACKET_LOOPBACK);
30092 + if (sock->type == SOCK_PACKET)
30093 + po->prot_hook.func = packet_rcv_spkt;
30094 +@@ -3392,6 +3395,16 @@ packet_setsockopt(struct socket *sock, i
30095 + po->xmit = val ? packet_direct_xmit : dev_queue_xmit;
30096 + return 0;
30098 ++ case PACKET_RECV_TYPE:
30099 ++ {
30100 ++ unsigned int val;
30101 ++ if (optlen != sizeof(val))
30102 ++ return -EINVAL;
30103 ++ if (copy_from_user(&val, optval, sizeof(val)))
30104 ++ return -EFAULT;
30105 ++ po->pkt_type = val & ~BIT(PACKET_LOOPBACK);
30106 ++ return 0;
30107 ++ }
30108 + default:
30109 + return -ENOPROTOOPT;
30111 +@@ -3443,6 +3456,13 @@ static int packet_getsockopt(struct sock
30112 + case PACKET_VNET_HDR:
30113 + val = po->has_vnet_hdr;
30114 + break;
30115 ++ case PACKET_RECV_TYPE:
30116 ++ if (len > sizeof(unsigned int))
30117 ++ len = sizeof(unsigned int);
30118 ++ val = po->pkt_type;
30120 ++ data = &val;
30121 ++ break;
30122 + case PACKET_VERSION:
30123 + val = po->tp_version;
30124 + break;
30125 +--- a/net/packet/internal.h
30126 ++++ b/net/packet/internal.h
30127 +@@ -116,6 +116,7 @@ struct packet_sock {
30128 + struct net_device __rcu *cached_dev;
30129 + int (*xmit)(struct sk_buff *skb);
30130 + struct packet_type prot_hook ____cacheline_aligned_in_smp;
30131 ++ unsigned int pkt_type;
30132 + };
30134 + static struct packet_sock *pkt_sk(struct sock *sk)
30135 diff --git a/target/linux/generic/patches-3.16/640-bridge_no_eap_forward.patch b/target/linux/generic/patches-3.16/640-bridge_no_eap_forward.patch
30136 new file mode 100644
30137 index 000000000000..acbf1e206e5c
30138 --- /dev/null
30139 +++ b/target/linux/generic/patches-3.16/640-bridge_no_eap_forward.patch
30140 @@ -0,0 +1,15 @@
30141 +--- a/net/bridge/br_input.c
30142 ++++ b/net/bridge/br_input.c
30143 +@@ -97,7 +97,11 @@ int br_handle_frame_finish(struct sk_buf
30145 + dst = NULL;
30147 +- if (is_broadcast_ether_addr(dest)) {
30148 ++ if (skb->protocol == htons(ETH_P_PAE)) {
30149 ++ skb2 = skb;
30150 ++ /* Do not forward 802.1x/EAP frames */
30152 ++ } else if (is_broadcast_ether_addr(dest)) {
30153 + skb2 = skb;
30154 + unicast = false;
30155 + } else if (is_multicast_ether_addr(dest)) {
30156 diff --git a/target/linux/generic/patches-3.16/641-bridge_always_accept_eap.patch b/target/linux/generic/patches-3.16/641-bridge_always_accept_eap.patch
30157 new file mode 100644
30158 index 000000000000..d20773a49585
30159 --- /dev/null
30160 +++ b/target/linux/generic/patches-3.16/641-bridge_always_accept_eap.patch
30161 @@ -0,0 +1,11 @@
30162 +--- a/net/bridge/br_input.c
30163 ++++ b/net/bridge/br_input.c
30164 +@@ -84,7 +84,7 @@ int br_handle_frame_finish(struct sk_buf
30165 + br_multicast_rcv(br, p, skb, vid))
30166 + goto drop;
30168 +- if (p->state == BR_STATE_LEARNING)
30169 ++ if ((p->state == BR_STATE_LEARNING) && skb->protocol != htons(ETH_P_PAE))
30170 + goto drop;
30172 + BR_INPUT_SKB_CB(skb)->brdev = br->dev;
30173 diff --git a/target/linux/generic/patches-3.16/642-bridge_port_isolate.patch b/target/linux/generic/patches-3.16/642-bridge_port_isolate.patch
30174 new file mode 100644
30175 index 000000000000..027d55015e9e
30176 --- /dev/null
30177 +++ b/target/linux/generic/patches-3.16/642-bridge_port_isolate.patch
30178 @@ -0,0 +1,102 @@
30179 +--- a/net/bridge/br_private.h
30180 ++++ b/net/bridge/br_private.h
30181 +@@ -172,6 +172,7 @@ struct net_bridge_port
30182 + #define BR_FLOOD 0x00000040
30183 + #define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)
30184 + #define BR_PROMISC 0x00000080
30185 ++#define BR_ISOLATE_MODE 0x00000100
30187 + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
30188 + struct bridge_mcast_own_query ip4_own_query;
30189 +--- a/net/bridge/br_sysfs_if.c
30190 ++++ b/net/bridge/br_sysfs_if.c
30191 +@@ -171,6 +171,22 @@ BRPORT_ATTR_FLAG(root_block, BR_ROOT_BLO
30192 + BRPORT_ATTR_FLAG(learning, BR_LEARNING);
30193 + BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD);
30195 ++static ssize_t show_isolate_mode(struct net_bridge_port *p, char *buf)
30197 ++ int isolate_mode = (p->flags & BR_ISOLATE_MODE) ? 1 : 0;
30198 ++ return sprintf(buf, "%d\n", isolate_mode);
30200 ++static ssize_t store_isolate_mode(struct net_bridge_port *p, unsigned long v)
30202 ++ if (v)
30203 ++ p->flags |= BR_ISOLATE_MODE;
30204 ++ else
30205 ++ p->flags &= ~BR_ISOLATE_MODE;
30206 ++ return 0;
30208 ++static BRPORT_ATTR(isolate_mode, S_IRUGO | S_IWUSR,
30209 ++ show_isolate_mode, store_isolate_mode);
30211 + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
30212 + static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
30214 +@@ -213,6 +229,7 @@ static const struct brport_attribute *br
30215 + &brport_attr_multicast_router,
30216 + &brport_attr_multicast_fast_leave,
30217 + #endif
30218 ++ &brport_attr_isolate_mode,
30219 + NULL
30220 + };
30222 +--- a/net/bridge/br_input.c
30223 ++++ b/net/bridge/br_input.c
30224 +@@ -120,8 +120,8 @@ int br_handle_frame_finish(struct sk_buf
30226 + unicast = false;
30227 + br->dev->stats.multicast++;
30228 +- } else if ((dst = __br_fdb_get(br, dest, vid)) &&
30229 +- dst->is_local) {
30230 ++ } else if ((p->flags & BR_ISOLATE_MODE) ||
30231 ++ ((dst = __br_fdb_get(br, dest, vid)) && dst->is_local)) {
30232 + skb2 = skb;
30233 + /* Do not forward the packet since it's local. */
30234 + skb = NULL;
30235 +--- a/net/bridge/br_forward.c
30236 ++++ b/net/bridge/br_forward.c
30237 +@@ -114,7 +114,7 @@ void br_deliver(const struct net_bridge_
30238 + /* called with rcu_read_lock */
30239 + void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0)
30241 +- if (should_deliver(to, skb)) {
30242 ++ if (should_deliver(to, skb) && !(to->flags & BR_ISOLATE_MODE)) {
30243 + if (skb0)
30244 + deliver_clone(to, skb, __br_forward);
30245 + else
30246 +@@ -170,7 +170,7 @@ static void br_flood(struct net_bridge *
30247 + struct sk_buff *skb0,
30248 + void (*__packet_hook)(const struct net_bridge_port *p,
30249 + struct sk_buff *skb),
30250 +- bool unicast)
30251 ++ bool unicast, bool forward)
30253 + struct net_bridge_port *p;
30254 + struct net_bridge_port *prev;
30255 +@@ -178,6 +178,8 @@ static void br_flood(struct net_bridge *
30256 + prev = NULL;
30258 + list_for_each_entry_rcu(p, &br->port_list, list) {
30259 ++ if (forward && (p->flags & BR_ISOLATE_MODE))
30260 ++ continue;
30261 + /* Do not flood unicast traffic to ports that turn it off */
30262 + if (unicast && !(p->flags & BR_FLOOD))
30263 + continue;
30264 +@@ -204,14 +206,14 @@ out:
30265 + /* called with rcu_read_lock */
30266 + void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb, bool unicast)
30268 +- br_flood(br, skb, NULL, __br_deliver, unicast);
30269 ++ br_flood(br, skb, NULL, __br_deliver, unicast, false);
30272 + /* called under bridge lock */
30273 + void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,
30274 + struct sk_buff *skb2, bool unicast)
30276 +- br_flood(br, skb, skb2, __br_forward, unicast);
30277 ++ br_flood(br, skb, skb2, __br_forward, unicast, true);
30280 + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
30281 diff --git a/target/linux/generic/patches-3.16/643-bridge_remove_ipv6_dependency.patch b/target/linux/generic/patches-3.16/643-bridge_remove_ipv6_dependency.patch
30282 new file mode 100644
30283 index 000000000000..5b2a7318c70e
30284 --- /dev/null
30285 +++ b/target/linux/generic/patches-3.16/643-bridge_remove_ipv6_dependency.patch
30286 @@ -0,0 +1,107 @@
30287 +--- a/include/net/addrconf.h
30288 ++++ b/include/net/addrconf.h
30289 +@@ -88,6 +88,12 @@ int ipv6_rcv_saddr_equal(const struct so
30290 + void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr);
30291 + void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr);
30293 ++extern int (*ipv6_dev_get_saddr_hook)(struct net *net,
30294 ++ const struct net_device *dev,
30295 ++ const struct in6_addr *daddr,
30296 ++ unsigned int prefs,
30297 ++ struct in6_addr *saddr);
30299 + static inline unsigned long addrconf_timeout_fixup(u32 timeout,
30300 + unsigned int unit)
30302 +--- a/net/bridge/Kconfig
30303 ++++ b/net/bridge/Kconfig
30304 +@@ -6,7 +6,6 @@ config BRIDGE
30305 + tristate "802.1d Ethernet Bridging"
30306 + select LLC
30307 + select STP
30308 +- depends on IPV6 || IPV6=n
30309 + ---help---
30310 + If you say Y here, then your Linux box will be able to act as an
30311 + Ethernet bridge, which means that the different Ethernet segments it
30312 +--- a/net/ipv6/Makefile
30313 ++++ b/net/ipv6/Makefile
30314 +@@ -45,3 +45,4 @@ obj-y += addrconf_core.o exthdrs_core.o
30315 + obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
30317 + obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
30318 ++obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_stubs.o
30319 +--- a/net/ipv6/addrconf.c
30320 ++++ b/net/ipv6/addrconf.c
30321 +@@ -1311,7 +1311,7 @@ out:
30322 + return ret;
30325 +-int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
30326 ++static int __ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
30327 + const struct in6_addr *daddr, unsigned int prefs,
30328 + struct in6_addr *saddr)
30330 +@@ -1436,7 +1436,6 @@ try_nextdev:
30331 + in6_ifa_put(hiscore->ifa);
30332 + return 0;
30334 +-EXPORT_SYMBOL(ipv6_dev_get_saddr);
30336 + int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
30337 + u32 banned_flags)
30338 +@@ -5385,6 +5384,9 @@ int __init addrconf_init(void)
30340 + ipv6_addr_label_rtnl_register();
30342 ++ BUG_ON(ipv6_dev_get_saddr_hook != NULL);
30343 ++ rcu_assign_pointer(ipv6_dev_get_saddr_hook, __ipv6_dev_get_saddr);
30345 + return 0;
30346 + errout:
30347 + rtnl_af_unregister(&inet6_ops);
30348 +@@ -5404,6 +5406,9 @@ void addrconf_cleanup(void)
30349 + struct net_device *dev;
30350 + int i;
30352 ++ rcu_assign_pointer(ipv6_dev_get_saddr_hook, NULL);
30353 ++ synchronize_rcu();
30355 + unregister_netdevice_notifier(&ipv6_dev_notf);
30356 + unregister_pernet_subsys(&addrconf_ops);
30357 + ipv6_addr_label_cleanup();
30358 +--- /dev/null
30359 ++++ b/net/ipv6/inet6_stubs.c
30360 +@@ -0,0 +1,33 @@
30361 ++/*
30362 ++ * This program is free software; you can redistribute it and/or
30363 ++ * modify it under the terms of the GNU General Public License
30364 ++ * as published by the Free Software Foundation; either version
30365 ++ * 2 of the License, or (at your option) any later version.
30366 ++ */
30367 ++#include <linux/export.h>
30368 ++#include <net/ipv6.h>
30370 ++int (*ipv6_dev_get_saddr_hook)(struct net *net, const struct net_device *dev,
30371 ++ const struct in6_addr *daddr, unsigned int prefs,
30372 ++ struct in6_addr *saddr);
30374 ++EXPORT_SYMBOL(ipv6_dev_get_saddr_hook);
30376 ++int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
30377 ++ const struct in6_addr *daddr, unsigned int prefs,
30378 ++ struct in6_addr *saddr)
30380 ++ int ret = -EADDRNOTAVAIL;
30381 ++ typeof(ipv6_dev_get_saddr_hook) dev_get_saddr;
30383 ++ rcu_read_lock();
30384 ++ dev_get_saddr = rcu_dereference(ipv6_dev_get_saddr_hook);
30386 ++ if (dev_get_saddr)
30387 ++ ret = dev_get_saddr(net, dst_dev, daddr, prefs, saddr);
30389 ++ rcu_read_unlock();
30390 ++ return ret;
30392 ++EXPORT_SYMBOL(ipv6_dev_get_saddr);
30394 diff --git a/target/linux/generic/patches-3.16/644-bridge_optimize_netfilter_hooks.patch b/target/linux/generic/patches-3.16/644-bridge_optimize_netfilter_hooks.patch
30395 new file mode 100644
30396 index 000000000000..9b223fba9723
30397 --- /dev/null
30398 +++ b/target/linux/generic/patches-3.16/644-bridge_optimize_netfilter_hooks.patch
30399 @@ -0,0 +1,155 @@
30400 +--- a/net/bridge/br_forward.c
30401 ++++ b/net/bridge/br_forward.c
30402 +@@ -57,7 +57,7 @@ int br_dev_queue_push_xmit(struct sk_buf
30404 + int br_forward_finish(struct sk_buff *skb)
30406 +- return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
30407 ++ return BR_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
30408 + br_dev_queue_push_xmit);
30411 +@@ -80,7 +80,7 @@ static void __br_deliver(const struct ne
30412 + return;
30415 +- NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
30416 ++ BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
30417 + br_forward_finish);
30420 +@@ -101,7 +101,7 @@ static void __br_forward(const struct ne
30421 + skb->dev = to->dev;
30422 + skb_forward_csum(skb);
30424 +- NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
30425 ++ BR_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
30426 + br_forward_finish);
30429 +--- a/net/bridge/br_input.c
30430 ++++ b/net/bridge/br_input.c
30431 +@@ -53,7 +53,7 @@ static int br_pass_frame_up(struct sk_bu
30432 + if (!skb)
30433 + return NET_RX_DROP;
30435 +- return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
30436 ++ return BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
30437 + netif_receive_skb);
30440 +@@ -214,7 +214,7 @@ rx_handler_result_t br_handle_frame(stru
30443 + /* Deliver packet to local host only */
30444 +- if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
30445 ++ if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
30446 + NULL, br_handle_local_finish)) {
30447 + return RX_HANDLER_CONSUMED; /* consumed by filter */
30448 + } else {
30449 +@@ -229,7 +229,7 @@ forward:
30450 + if (ether_addr_equal(p->br->dev->dev_addr, dest))
30451 + skb->pkt_type = PACKET_HOST;
30453 +- if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
30454 ++ if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
30455 + br_handle_local_finish))
30456 + break;
30458 +@@ -251,7 +251,7 @@ forward:
30459 + if (ether_addr_equal(p->br->dev->dev_addr, dest))
30460 + skb->pkt_type = PACKET_HOST;
30462 +- NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
30463 ++ BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
30464 + br_handle_frame_finish);
30465 + break;
30466 + default:
30467 +--- a/net/bridge/br_multicast.c
30468 ++++ b/net/bridge/br_multicast.c
30469 +@@ -802,7 +802,7 @@ static void __br_multicast_send_query(st
30470 + if (port) {
30471 + __skb_push(skb, sizeof(struct ethhdr));
30472 + skb->dev = port->dev;
30473 +- NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
30474 ++ BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
30475 + dev_queue_xmit);
30476 + } else
30477 + netif_rx(skb);
30478 +--- a/net/bridge/br_netfilter.c
30479 ++++ b/net/bridge/br_netfilter.c
30480 +@@ -73,6 +73,15 @@ static int brnf_pass_vlan_indev __read_m
30481 + #define IS_ARP(skb) \
30482 + (!vlan_tx_tag_present(skb) && skb->protocol == htons(ETH_P_ARP))
30484 ++int brnf_call_ebtables __read_mostly = 0;
30485 ++EXPORT_SYMBOL_GPL(brnf_call_ebtables);
30487 ++bool br_netfilter_run_hooks(void)
30489 ++ return brnf_call_iptables | brnf_call_ip6tables | brnf_call_arptables |
30490 ++ brnf_call_ebtables;
30493 + static inline __be16 vlan_proto(const struct sk_buff *skb)
30495 + if (vlan_tx_tag_present(skb))
30496 +--- a/net/bridge/br_private.h
30497 ++++ b/net/bridge/br_private.h
30498 +@@ -724,15 +724,29 @@ static inline u16 br_get_pvid(const stru
30500 + /* br_netfilter.c */
30501 + #ifdef CONFIG_BRIDGE_NETFILTER
30502 ++extern int brnf_call_ebtables;
30503 + int br_netfilter_init(void);
30504 + void br_netfilter_fini(void);
30505 + void br_netfilter_rtable_init(struct net_bridge *);
30506 ++bool br_netfilter_run_hooks(void);
30507 + #else
30508 + #define br_netfilter_init() (0)
30509 + #define br_netfilter_fini() do { } while (0)
30510 + #define br_netfilter_rtable_init(x)
30511 ++#define br_netfilter_run_hooks() false
30512 + #endif
30514 ++static inline int
30515 ++BR_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
30516 ++ struct net_device *in, struct net_device *out,
30517 ++ int (*okfn)(struct sk_buff *))
30519 ++ if (!br_netfilter_run_hooks())
30520 ++ return okfn(skb);
30522 ++ return NF_HOOK(pf, hook, skb, in, out, okfn);
30525 + /* br_stp.c */
30526 + void br_log_state(const struct net_bridge_port *p);
30527 + struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no);
30528 +--- a/net/bridge/br_stp_bpdu.c
30529 ++++ b/net/bridge/br_stp_bpdu.c
30530 +@@ -54,7 +54,7 @@ static void br_send_bpdu(struct net_brid
30532 + skb_reset_mac_header(skb);
30534 +- NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
30535 ++ BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
30536 + dev_queue_xmit);
30539 +--- a/net/bridge/netfilter/ebtables.c
30540 ++++ b/net/bridge/netfilter/ebtables.c
30541 +@@ -2405,11 +2405,13 @@ static int __init ebtables_init(void)
30544 + printk(KERN_INFO "Ebtables v2.0 registered\n");
30545 ++ brnf_call_ebtables = 1;
30546 + return 0;
30549 + static void __exit ebtables_fini(void)
30551 ++ brnf_call_ebtables = 0;
30552 + nf_unregister_sockopt(&ebt_sockopts);
30553 + xt_unregister_target(&ebt_standard_target);
30554 + printk(KERN_INFO "Ebtables v2.0 unregistered\n");
30555 diff --git a/target/linux/generic/patches-3.16/645-bridge_multicast_to_unicast.patch b/target/linux/generic/patches-3.16/645-bridge_multicast_to_unicast.patch
30556 new file mode 100644
30557 index 000000000000..bb12cc2a12f0
30558 --- /dev/null
30559 +++ b/target/linux/generic/patches-3.16/645-bridge_multicast_to_unicast.patch
30560 @@ -0,0 +1,373 @@
30561 +--- a/net/bridge/br_multicast.c
30562 ++++ b/net/bridge/br_multicast.c
30563 +@@ -635,7 +635,8 @@ struct net_bridge_port_group *br_multica
30564 + struct net_bridge_port *port,
30565 + struct br_ip *group,
30566 + struct net_bridge_port_group __rcu *next,
30567 +- unsigned char state)
30568 ++ unsigned char state,
30569 ++ const unsigned char *src)
30571 + struct net_bridge_port_group *p;
30573 +@@ -650,12 +651,33 @@ struct net_bridge_port_group *br_multica
30574 + hlist_add_head(&p->mglist, &port->mglist);
30575 + setup_timer(&p->timer, br_multicast_port_group_expired,
30576 + (unsigned long)p);
30577 ++ if ((port->flags & BR_MULTICAST_TO_UCAST) && src) {
30578 ++ memcpy(p->eth_addr, src, ETH_ALEN);
30579 ++ p->unicast = true;
30580 ++ }
30581 + return p;
30584 ++static bool br_port_group_equal(struct net_bridge_port_group *p,
30585 ++ struct net_bridge_port *port,
30586 ++ const unsigned char *src)
30588 ++ if (p->port != port)
30589 ++ return false;
30591 ++ if (!p->unicast)
30592 ++ return true;
30594 ++ if (!src)
30595 ++ return false;
30597 ++ return ether_addr_equal(src, p->eth_addr);
30600 + static int br_multicast_add_group(struct net_bridge *br,
30601 + struct net_bridge_port *port,
30602 +- struct br_ip *group)
30603 ++ struct br_ip *group,
30604 ++ const unsigned char *src)
30606 + struct net_bridge_mdb_entry *mp;
30607 + struct net_bridge_port_group *p;
30608 +@@ -682,13 +704,13 @@ static int br_multicast_add_group(struct
30609 + for (pp = &mp->ports;
30610 + (p = mlock_dereference(*pp, br)) != NULL;
30611 + pp = &p->next) {
30612 +- if (p->port == port)
30613 ++ if (br_port_group_equal(p, port, src))
30614 + goto found;
30615 + if ((unsigned long)p->port < (unsigned long)port)
30616 + break;
30619 +- p = br_multicast_new_port_group(port, group, *pp, MDB_TEMPORARY);
30620 ++ p = br_multicast_new_port_group(port, group, *pp, MDB_TEMPORARY, src);
30621 + if (unlikely(!p))
30622 + goto err;
30623 + rcu_assign_pointer(*pp, p);
30624 +@@ -707,7 +729,7 @@ err:
30625 + static int br_ip4_multicast_add_group(struct net_bridge *br,
30626 + struct net_bridge_port *port,
30627 + __be32 group,
30628 +- __u16 vid)
30629 ++ __u16 vid, const unsigned char *src)
30631 + struct br_ip br_group;
30633 +@@ -718,14 +740,14 @@ static int br_ip4_multicast_add_group(st
30634 + br_group.proto = htons(ETH_P_IP);
30635 + br_group.vid = vid;
30637 +- return br_multicast_add_group(br, port, &br_group);
30638 ++ return br_multicast_add_group(br, port, &br_group, src);
30641 + #if IS_ENABLED(CONFIG_IPV6)
30642 + static int br_ip6_multicast_add_group(struct net_bridge *br,
30643 + struct net_bridge_port *port,
30644 + const struct in6_addr *group,
30645 +- __u16 vid)
30646 ++ __u16 vid, const unsigned char *src)
30648 + struct br_ip br_group;
30650 +@@ -736,7 +758,7 @@ static int br_ip6_multicast_add_group(st
30651 + br_group.proto = htons(ETH_P_IPV6);
30652 + br_group.vid = vid;
30654 +- return br_multicast_add_group(br, port, &br_group);
30655 ++ return br_multicast_add_group(br, port, &br_group, src);
30657 + #endif
30659 +@@ -966,6 +988,7 @@ static int br_ip4_multicast_igmp3_report
30660 + struct sk_buff *skb,
30661 + u16 vid)
30663 ++ const unsigned char *src = eth_hdr(skb)->h_source;
30664 + struct igmpv3_report *ih;
30665 + struct igmpv3_grec *grec;
30666 + int i;
30667 +@@ -1009,7 +1032,7 @@ static int br_ip4_multicast_igmp3_report
30668 + continue;
30671 +- err = br_ip4_multicast_add_group(br, port, group, vid);
30672 ++ err = br_ip4_multicast_add_group(br, port, group, vid, src);
30673 + if (err)
30674 + break;
30676 +@@ -1023,6 +1046,7 @@ static int br_ip6_multicast_mld2_report(
30677 + struct sk_buff *skb,
30678 + u16 vid)
30680 ++ const unsigned char *src = eth_hdr(skb)->h_source;
30681 + struct icmp6hdr *icmp6h;
30682 + struct mld2_grec *grec;
30683 + int i;
30684 +@@ -1071,7 +1095,7 @@ static int br_ip6_multicast_mld2_report(
30687 + err = br_ip6_multicast_add_group(br, port, &grec->grec_mca,
30688 +- vid);
30689 ++ vid, src);
30690 + if (!err)
30691 + break;
30693 +@@ -1408,7 +1432,8 @@ br_multicast_leave_group(struct net_brid
30694 + struct net_bridge_port *port,
30695 + struct br_ip *group,
30696 + struct bridge_mcast_other_query *other_query,
30697 +- struct bridge_mcast_own_query *own_query)
30698 ++ struct bridge_mcast_own_query *own_query,
30699 ++ const unsigned char *src)
30701 + struct net_bridge_mdb_htable *mdb;
30702 + struct net_bridge_mdb_entry *mp;
30703 +@@ -1458,7 +1483,7 @@ br_multicast_leave_group(struct net_brid
30704 + for (pp = &mp->ports;
30705 + (p = mlock_dereference(*pp, br)) != NULL;
30706 + pp = &p->next) {
30707 +- if (p->port != port)
30708 ++ if (!br_port_group_equal(p, port, src))
30709 + continue;
30711 + rcu_assign_pointer(*pp, p->next);
30712 +@@ -1492,7 +1517,7 @@ br_multicast_leave_group(struct net_brid
30713 + for (p = mlock_dereference(mp->ports, br);
30714 + p != NULL;
30715 + p = mlock_dereference(p->next, br)) {
30716 +- if (p->port != port)
30717 ++ if (!br_port_group_equal(p, port, src))
30718 + continue;
30720 + if (!hlist_unhashed(&p->mglist) &&
30721 +@@ -1510,8 +1535,8 @@ out:
30723 + static void br_ip4_multicast_leave_group(struct net_bridge *br,
30724 + struct net_bridge_port *port,
30725 +- __be32 group,
30726 +- __u16 vid)
30727 ++ __be32 group, __u16 vid,
30728 ++ const unsigned char *src)
30730 + struct br_ip br_group;
30731 + struct bridge_mcast_own_query *own_query;
30732 +@@ -1526,14 +1551,14 @@ static void br_ip4_multicast_leave_group
30733 + br_group.vid = vid;
30735 + br_multicast_leave_group(br, port, &br_group, &br->ip4_other_query,
30736 +- own_query);
30737 ++ own_query, src);
30740 + #if IS_ENABLED(CONFIG_IPV6)
30741 + static void br_ip6_multicast_leave_group(struct net_bridge *br,
30742 + struct net_bridge_port *port,
30743 + const struct in6_addr *group,
30744 +- __u16 vid)
30745 ++ __u16 vid, const unsigned char *src)
30747 + struct br_ip br_group;
30748 + struct bridge_mcast_own_query *own_query;
30749 +@@ -1548,7 +1573,7 @@ static void br_ip6_multicast_leave_group
30750 + br_group.vid = vid;
30752 + br_multicast_leave_group(br, port, &br_group, &br->ip6_other_query,
30753 +- own_query);
30754 ++ own_query, src);
30756 + #endif
30758 +@@ -1557,6 +1582,7 @@ static int br_multicast_ipv4_rcv(struct
30759 + struct sk_buff *skb,
30760 + u16 vid)
30762 ++ const unsigned char *src = eth_hdr(skb)->h_source;
30763 + struct sk_buff *skb2 = skb;
30764 + const struct iphdr *iph;
30765 + struct igmphdr *ih;
30766 +@@ -1630,7 +1656,7 @@ static int br_multicast_ipv4_rcv(struct
30767 + case IGMP_HOST_MEMBERSHIP_REPORT:
30768 + case IGMPV2_HOST_MEMBERSHIP_REPORT:
30769 + BR_INPUT_SKB_CB(skb)->mrouters_only = 1;
30770 +- err = br_ip4_multicast_add_group(br, port, ih->group, vid);
30771 ++ err = br_ip4_multicast_add_group(br, port, ih->group, vid, src);
30772 + break;
30773 + case IGMPV3_HOST_MEMBERSHIP_REPORT:
30774 + err = br_ip4_multicast_igmp3_report(br, port, skb2, vid);
30775 +@@ -1639,7 +1665,7 @@ static int br_multicast_ipv4_rcv(struct
30776 + err = br_ip4_multicast_query(br, port, skb2, vid);
30777 + break;
30778 + case IGMP_HOST_LEAVE_MESSAGE:
30779 +- br_ip4_multicast_leave_group(br, port, ih->group, vid);
30780 ++ br_ip4_multicast_leave_group(br, port, ih->group, vid, src);
30781 + break;
30784 +@@ -1657,6 +1683,7 @@ static int br_multicast_ipv6_rcv(struct
30785 + struct sk_buff *skb,
30786 + u16 vid)
30788 ++ const unsigned char *src = eth_hdr(skb)->h_source;
30789 + struct sk_buff *skb2;
30790 + const struct ipv6hdr *ip6h;
30791 + u8 icmp6_type;
30792 +@@ -1766,7 +1793,8 @@ static int br_multicast_ipv6_rcv(struct
30794 + mld = (struct mld_msg *)skb_transport_header(skb2);
30795 + BR_INPUT_SKB_CB(skb)->mrouters_only = 1;
30796 +- err = br_ip6_multicast_add_group(br, port, &mld->mld_mca, vid);
30797 ++ err = br_ip6_multicast_add_group(br, port, &mld->mld_mca, vid,
30798 ++ src);
30799 + break;
30801 + case ICMPV6_MLD2_REPORT:
30802 +@@ -1783,7 +1811,7 @@ static int br_multicast_ipv6_rcv(struct
30803 + goto out;
30805 + mld = (struct mld_msg *)skb_transport_header(skb2);
30806 +- br_ip6_multicast_leave_group(br, port, &mld->mld_mca, vid);
30807 ++ br_ip6_multicast_leave_group(br, port, &mld->mld_mca, vid, src);
30811 +--- a/net/bridge/br_private.h
30812 ++++ b/net/bridge/br_private.h
30813 +@@ -112,6 +112,9 @@ struct net_bridge_port_group {
30814 + struct timer_list timer;
30815 + struct br_ip addr;
30816 + unsigned char state;
30818 ++ unsigned char eth_addr[ETH_ALEN];
30819 ++ bool unicast;
30820 + };
30822 + struct net_bridge_mdb_entry
30823 +@@ -173,6 +176,7 @@ struct net_bridge_port
30824 + #define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)
30825 + #define BR_PROMISC 0x00000080
30826 + #define BR_ISOLATE_MODE 0x00000100
30827 ++#define BR_MULTICAST_TO_UCAST 0x00000200
30829 + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
30830 + struct bridge_mcast_own_query ip4_own_query;
30831 +@@ -477,7 +481,8 @@ void br_multicast_free_pg(struct rcu_hea
30832 + struct net_bridge_port_group *
30833 + br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group,
30834 + struct net_bridge_port_group __rcu *next,
30835 +- unsigned char state);
30836 ++ unsigned char state,
30837 ++ const unsigned char *src);
30838 + void br_mdb_init(void);
30839 + void br_mdb_uninit(void);
30840 + void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port,
30841 +--- a/net/bridge/br_mdb.c
30842 ++++ b/net/bridge/br_mdb.c
30843 +@@ -342,7 +342,7 @@ static int br_mdb_add_group(struct net_b
30844 + break;
30847 +- p = br_multicast_new_port_group(port, group, *pp, state);
30848 ++ p = br_multicast_new_port_group(port, group, *pp, state, NULL);
30849 + if (unlikely(!p))
30850 + return -ENOMEM;
30851 + rcu_assign_pointer(*pp, p);
30852 +--- a/net/bridge/br_forward.c
30853 ++++ b/net/bridge/br_forward.c
30854 +@@ -165,6 +165,29 @@ out:
30855 + return p;
30858 ++static struct net_bridge_port *maybe_deliver_addr(
30859 ++ struct net_bridge_port *prev, struct net_bridge_port *p,
30860 ++ struct sk_buff *skb, const unsigned char *addr,
30861 ++ void (*__packet_hook)(const struct net_bridge_port *p,
30862 ++ struct sk_buff *skb))
30864 ++ struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev;
30866 ++ if (!should_deliver(p, skb))
30867 ++ return prev;
30869 ++ skb = skb_copy(skb, GFP_ATOMIC);
30870 ++ if (!skb) {
30871 ++ dev->stats.tx_dropped++;
30872 ++ return prev;
30873 ++ }
30875 ++ memcpy(eth_hdr(skb)->h_dest, addr, ETH_ALEN);
30876 ++ __packet_hook(p, skb);
30878 ++ return prev;
30881 + /* called under bridge lock */
30882 + static void br_flood(struct net_bridge *br, struct sk_buff *skb,
30883 + struct sk_buff *skb0,
30884 +@@ -229,6 +252,7 @@ static void br_multicast_flood(struct ne
30885 + struct net_bridge_port *prev = NULL;
30886 + struct net_bridge_port_group *p;
30887 + struct hlist_node *rp;
30888 ++ const unsigned char *addr;
30890 + rp = rcu_dereference(hlist_first_rcu(&br->router_list));
30891 + p = mdst ? rcu_dereference(mdst->ports) : NULL;
30892 +@@ -239,10 +263,19 @@ static void br_multicast_flood(struct ne
30893 + rport = rp ? hlist_entry(rp, struct net_bridge_port, rlist) :
30894 + NULL;
30896 +- port = (unsigned long)lport > (unsigned long)rport ?
30897 +- lport : rport;
30899 +- prev = maybe_deliver(prev, port, skb, __packet_hook);
30900 ++ if ((unsigned long)lport > (unsigned long)rport) {
30901 ++ port = lport;
30902 ++ addr = p->unicast ? p->eth_addr : NULL;
30903 ++ } else {
30904 ++ port = rport;
30905 ++ addr = NULL;
30906 ++ }
30908 ++ if (addr)
30909 ++ prev = maybe_deliver_addr(prev, port, skb, addr,
30910 ++ __packet_hook);
30911 ++ else
30912 ++ prev = maybe_deliver(prev, port, skb, __packet_hook);
30913 + if (IS_ERR(prev))
30914 + goto out;
30916 +--- a/net/bridge/br_sysfs_if.c
30917 ++++ b/net/bridge/br_sysfs_if.c
30918 +@@ -202,6 +202,7 @@ static BRPORT_ATTR(multicast_router, S_I
30919 + store_multicast_router);
30921 + BRPORT_ATTR_FLAG(multicast_fast_leave, BR_MULTICAST_FAST_LEAVE);
30922 ++BRPORT_ATTR_FLAG(multicast_to_unicast, BR_MULTICAST_TO_UCAST);
30923 + #endif
30925 + static const struct brport_attribute *brport_attrs[] = {
30926 +@@ -228,6 +229,7 @@ static const struct brport_attribute *br
30927 + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
30928 + &brport_attr_multicast_router,
30929 + &brport_attr_multicast_fast_leave,
30930 ++ &brport_attr_multicast_to_unicast,
30931 + #endif
30932 + &brport_attr_isolate_mode,
30933 + NULL
30934 diff --git a/target/linux/generic/patches-3.16/650-pppoe_header_pad.patch b/target/linux/generic/patches-3.16/650-pppoe_header_pad.patch
30935 new file mode 100644
30936 index 000000000000..a89a9f3b7488
30937 --- /dev/null
30938 +++ b/target/linux/generic/patches-3.16/650-pppoe_header_pad.patch
30939 @@ -0,0 +1,20 @@
30940 +--- a/drivers/net/ppp/pppoe.c
30941 ++++ b/drivers/net/ppp/pppoe.c
30942 +@@ -850,7 +850,7 @@ static int pppoe_sendmsg(struct kiocb *i
30943 + goto end;
30946 +- skb = sock_wmalloc(sk, total_len + dev->hard_header_len + 32,
30947 ++ skb = sock_wmalloc(sk, total_len + dev->hard_header_len + 32 + NET_SKB_PAD,
30948 + 0, GFP_KERNEL);
30949 + if (!skb) {
30950 + error = -ENOMEM;
30951 +@@ -858,7 +858,7 @@ static int pppoe_sendmsg(struct kiocb *i
30954 + /* Reserve space for headers. */
30955 +- skb_reserve(skb, dev->hard_header_len);
30956 ++ skb_reserve(skb, dev->hard_header_len + NET_SKB_PAD);
30957 + skb_reset_network_header(skb);
30959 + skb->dev = dev;
30960 diff --git a/target/linux/generic/patches-3.16/651-wireless_mesh_header.patch b/target/linux/generic/patches-3.16/651-wireless_mesh_header.patch
30961 new file mode 100644
30962 index 000000000000..d2d40f539a87
30963 --- /dev/null
30964 +++ b/target/linux/generic/patches-3.16/651-wireless_mesh_header.patch
30965 @@ -0,0 +1,11 @@
30966 +--- a/include/linux/netdevice.h
30967 ++++ b/include/linux/netdevice.h
30968 +@@ -139,7 +139,7 @@ static inline bool dev_xmit_complete(int
30969 + */
30971 + #if defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25)
30972 +-# if defined(CONFIG_MAC80211_MESH)
30973 ++# if 1 || defined(CONFIG_MAC80211_MESH)
30974 + # define LL_MAX_HEADER 128
30975 + # else
30976 + # define LL_MAX_HEADER 96
30977 diff --git a/target/linux/generic/patches-3.16/652-atm_header_changes.patch b/target/linux/generic/patches-3.16/652-atm_header_changes.patch
30978 new file mode 100644
30979 index 000000000000..7e5685922ffc
30980 --- /dev/null
30981 +++ b/target/linux/generic/patches-3.16/652-atm_header_changes.patch
30982 @@ -0,0 +1,12 @@
30983 +--- a/include/uapi/linux/atm.h
30984 ++++ b/include/uapi/linux/atm.h
30985 +@@ -139,6 +139,9 @@ struct atm_trafprm {
30986 + int min_pcr; /* minimum PCR in cells per second */
30987 + int max_cdv; /* maximum CDV in microseconds */
30988 + int max_sdu; /* maximum SDU in bytes */
30989 ++ int scr; /* sustained rate in cells per second */
30990 ++ int mbs; /* maximum burst size (MBS) in cells */
30991 ++ int cdv; /* Cell delay varition */
30992 + /* extra params for ABR */
30993 + unsigned int icr; /* Initial Cell Rate (24-bit) */
30994 + unsigned int tbe; /* Transient Buffer Exposure (24-bit) */
30995 diff --git a/target/linux/generic/patches-3.16/653-disable_netlink_trim.patch b/target/linux/generic/patches-3.16/653-disable_netlink_trim.patch
30996 new file mode 100644
30997 index 000000000000..7ce7c658924a
30998 --- /dev/null
30999 +++ b/target/linux/generic/patches-3.16/653-disable_netlink_trim.patch
31000 @@ -0,0 +1,30 @@
31001 +--- a/net/netlink/af_netlink.c
31002 ++++ b/net/netlink/af_netlink.c
31003 +@@ -1740,27 +1740,7 @@ void netlink_detachskb(struct sock *sk,
31005 + static struct sk_buff *netlink_trim(struct sk_buff *skb, gfp_t allocation)
31007 +- int delta;
31009 + WARN_ON(skb->sk != NULL);
31010 +- if (netlink_skb_is_mmaped(skb))
31011 +- return skb;
31013 +- delta = skb->end - skb->tail;
31014 +- if (is_vmalloc_addr(skb->head) || delta * 2 < skb->truesize)
31015 +- return skb;
31017 +- if (skb_shared(skb)) {
31018 +- struct sk_buff *nskb = skb_clone(skb, allocation);
31019 +- if (!nskb)
31020 +- return skb;
31021 +- consume_skb(skb);
31022 +- skb = nskb;
31023 +- }
31025 +- if (!pskb_expand_head(skb, 0, -delta, allocation))
31026 +- skb->truesize -= delta;
31028 + return skb;
31031 diff --git a/target/linux/generic/patches-3.16/655-increase_skb_pad.patch b/target/linux/generic/patches-3.16/655-increase_skb_pad.patch
31032 new file mode 100644
31033 index 000000000000..d252754f8711
31034 --- /dev/null
31035 +++ b/target/linux/generic/patches-3.16/655-increase_skb_pad.patch
31036 @@ -0,0 +1,11 @@
31037 +--- a/include/linux/skbuff.h
31038 ++++ b/include/linux/skbuff.h
31039 +@@ -1828,7 +1828,7 @@ static inline int pskb_network_may_pull(
31040 + * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
31041 + */
31042 + #ifndef NET_SKB_PAD
31043 +-#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
31044 ++#define NET_SKB_PAD max(64, L1_CACHE_BYTES)
31045 + #endif
31047 + int ___pskb_trim(struct sk_buff *skb, unsigned int len);
31048 diff --git a/target/linux/generic/patches-3.16/656-skb_reduce_truesize-helper.patch b/target/linux/generic/patches-3.16/656-skb_reduce_truesize-helper.patch
31049 new file mode 100644
31050 index 000000000000..2c78ef8bbea3
31051 --- /dev/null
31052 +++ b/target/linux/generic/patches-3.16/656-skb_reduce_truesize-helper.patch
31053 @@ -0,0 +1,41 @@
31054 +From 4593a806e31119c5bd3faa00c7210ad862d515af Mon Sep 17 00:00:00 2001
31055 +From: Dave Taht <dave.taht@bufferbloat.net>
31056 +Date: Mon, 31 Dec 2012 10:02:21 -0800
31057 +Subject: [PATCH 3/7] skb_reduce_truesize: helper function for shrinking skbs
31058 + whenever needed
31060 +On embedded devices in particular, large queues of small packets from the rx
31061 +path with a large truesize can exist. Reducing their size can reduce
31062 +memory pressure. skb_reduce_truesize is a helper function for doing this,
31063 +when needed.
31064 +---
31065 + include/linux/skbuff.h | 18 ++++++++++++++++++
31066 + 1 file changed, 18 insertions(+)
31068 +--- a/include/linux/skbuff.h
31069 ++++ b/include/linux/skbuff.h
31070 +@@ -1873,6 +1873,24 @@ static inline void pskb_trim_unique(stru
31071 + BUG_ON(err);
31074 ++/*
31075 ++ * Caller wants to reduce memory needs before queueing skb
31076 ++ * The (expensive) copy should not be be done in fast path.
31077 ++ */
31078 ++static inline struct sk_buff *skb_reduce_truesize(struct sk_buff *skb)
31080 ++ if (skb->truesize > 2 * SKB_TRUESIZE(skb->len)) {
31081 ++ struct sk_buff *nskb;
31082 ++ nskb = skb_copy_expand(skb, skb_headroom(skb), 0,
31083 ++ GFP_ATOMIC | __GFP_NOWARN);
31084 ++ if (nskb) {
31085 ++ __kfree_skb(skb);
31086 ++ skb = nskb;
31087 ++ }
31088 ++ }
31089 ++ return skb;
31092 + /**
31093 + * skb_orphan - orphan a buffer
31094 + * @skb: buffer to orphan
31095 diff --git a/target/linux/generic/patches-3.16/657-qdisc_reduce_truesize.patch b/target/linux/generic/patches-3.16/657-qdisc_reduce_truesize.patch
31096 new file mode 100644
31097 index 000000000000..93ff7ba71d3b
31098 --- /dev/null
31099 +++ b/target/linux/generic/patches-3.16/657-qdisc_reduce_truesize.patch
31100 @@ -0,0 +1,63 @@
31101 +From bc9fec2f87d57bdbff30d296605e24504513f65c Mon Sep 17 00:00:00 2001
31102 +From: =?UTF-8?q?Dave=20T=C3=A4ht?= <dave.taht@bufferbloat.net>
31103 +Date: Mon, 17 Sep 2012 19:20:22 -0700
31104 +Subject: [PATCH 4/7] net: add skb_reduce_truesize support to common qdiscs
31106 +Reduce skb size under load when queues begin to fill on the
31107 +commont qdiscs.
31108 +---
31109 + net/sched/sch_codel.c | 2 ++
31110 + net/sched/sch_fifo.c | 12 ++++++++----
31111 + net/sched/sch_fq_codel.c | 2 ++
31112 + 3 files changed, 12 insertions(+), 4 deletions(-)
31114 +--- a/net/sched/sch_codel.c
31115 ++++ b/net/sched/sch_codel.c
31116 +@@ -96,6 +96,8 @@ static int codel_qdisc_enqueue(struct sk
31117 + struct codel_sched_data *q;
31119 + if (likely(qdisc_qlen(sch) < sch->limit)) {
31120 ++ if(qdisc_qlen(sch) > 128)
31121 ++ skb = skb_reduce_truesize(skb);
31122 + codel_set_enqueue_time(skb);
31123 + return qdisc_enqueue_tail(skb, sch);
31125 +--- a/net/sched/sch_fifo.c
31126 ++++ b/net/sched/sch_fifo.c
31127 +@@ -29,17 +29,21 @@ static int bfifo_enqueue(struct sk_buff
31129 + static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch)
31131 +- if (likely(skb_queue_len(&sch->q) < sch->limit))
31132 ++ if (likely(skb_queue_len(&sch->q) < sch->limit)) {
31133 ++ if (skb_queue_len(&sch->q) > 128)
31134 ++ skb = skb_reduce_truesize(skb);
31135 + return qdisc_enqueue_tail(skb, sch);
31137 ++ }
31138 + return qdisc_reshape_fail(skb, sch);
31141 + static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch)
31143 +- if (likely(skb_queue_len(&sch->q) < sch->limit))
31144 ++ if (likely(skb_queue_len(&sch->q) < sch->limit)) {
31145 ++ if (skb_queue_len(&sch->q) > 128)
31146 ++ skb = skb_reduce_truesize(skb);
31147 + return qdisc_enqueue_tail(skb, sch);
31149 ++ }
31150 + /* queue full, remove one skb to fulfill the limit */
31151 + __qdisc_queue_drop_head(sch, &sch->q);
31152 + sch->qstats.drops++;
31153 +--- a/net/sched/sch_fq_codel.c
31154 ++++ b/net/sched/sch_fq_codel.c
31155 +@@ -182,6 +182,8 @@ static int fq_codel_enqueue(struct sk_bu
31156 + return ret;
31158 + idx--;
31159 ++ if (sch->q.qlen > 128)
31160 ++ skb = skb_reduce_truesize(skb);
31162 + codel_set_enqueue_time(skb);
31163 + flow = &q->flows[idx];
31164 diff --git a/target/linux/generic/patches-3.16/660-fq_codel_defaults.patch b/target/linux/generic/patches-3.16/660-fq_codel_defaults.patch
31165 new file mode 100644
31166 index 000000000000..96475f05805a
31167 --- /dev/null
31168 +++ b/target/linux/generic/patches-3.16/660-fq_codel_defaults.patch
31169 @@ -0,0 +1,14 @@
31170 +--- a/net/sched/sch_fq_codel.c
31171 ++++ b/net/sched/sch_fq_codel.c
31172 +@@ -389,9 +389,9 @@ static int fq_codel_init(struct Qdisc *s
31173 + struct fq_codel_sched_data *q = qdisc_priv(sch);
31174 + int i;
31176 +- sch->limit = 10*1024;
31177 ++ sch->limit = 1024;
31178 + q->flows_cnt = 1024;
31179 +- q->quantum = psched_mtu(qdisc_dev(sch));
31180 ++ q->quantum = 300;
31181 + q->perturbation = prandom_u32();
31182 + INIT_LIST_HEAD(&q->new_flows);
31183 + INIT_LIST_HEAD(&q->old_flows);
31184 diff --git a/target/linux/generic/patches-3.16/661-fq_codel_keep_dropped_stats.patch b/target/linux/generic/patches-3.16/661-fq_codel_keep_dropped_stats.patch
31185 new file mode 100644
31186 index 000000000000..d51c7e582262
31187 --- /dev/null
31188 +++ b/target/linux/generic/patches-3.16/661-fq_codel_keep_dropped_stats.patch
31189 @@ -0,0 +1,10 @@
31190 +--- a/net/sched/sch_fq_codel.c
31191 ++++ b/net/sched/sch_fq_codel.c
31192 +@@ -195,7 +195,6 @@ static int fq_codel_enqueue(struct sk_bu
31193 + list_add_tail(&flow->flowchain, &q->new_flows);
31194 + q->new_flow_count++;
31195 + flow->deficit = q->quantum;
31196 +- flow->dropped = 0;
31198 + if (++sch->q.qlen <= sch->limit)
31199 + return NET_XMIT_SUCCESS;
31200 diff --git a/target/linux/generic/patches-3.16/662-use_fq_codel_by_default.patch b/target/linux/generic/patches-3.16/662-use_fq_codel_by_default.patch
31201 new file mode 100644
31202 index 000000000000..fcb0013c4e7e
31203 --- /dev/null
31204 +++ b/target/linux/generic/patches-3.16/662-use_fq_codel_by_default.patch
31205 @@ -0,0 +1,75 @@
31206 +--- a/net/sched/Kconfig
31207 ++++ b/net/sched/Kconfig
31208 +@@ -3,8 +3,9 @@
31209 + #
31211 + menuconfig NET_SCHED
31212 +- bool "QoS and/or fair queueing"
31213 ++ def_bool y
31214 + select NET_SCH_FIFO
31215 ++ select NET_SCH_FQ_CODEL
31216 + ---help---
31217 + When the kernel has several packets to send out over a network
31218 + device, it has to decide which ones to send first, which ones to
31219 +--- a/net/sched/sch_fq_codel.c
31220 ++++ b/net/sched/sch_fq_codel.c
31221 +@@ -594,7 +594,7 @@ static const struct Qdisc_class_ops fq_c
31222 + .walk = fq_codel_walk,
31223 + };
31225 +-static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = {
31226 ++struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = {
31227 + .cl_ops = &fq_codel_class_ops,
31228 + .id = "fq_codel",
31229 + .priv_size = sizeof(struct fq_codel_sched_data),
31230 +@@ -610,6 +610,7 @@ static struct Qdisc_ops fq_codel_qdisc_o
31231 + .dump_stats = fq_codel_dump_stats,
31232 + .owner = THIS_MODULE,
31233 + };
31234 ++EXPORT_SYMBOL(fq_codel_qdisc_ops);
31236 + static int __init fq_codel_module_init(void)
31238 +--- a/include/net/sch_generic.h
31239 ++++ b/include/net/sch_generic.h
31240 +@@ -316,6 +316,7 @@ extern struct Qdisc noop_qdisc;
31241 + extern struct Qdisc_ops noop_qdisc_ops;
31242 + extern struct Qdisc_ops pfifo_fast_ops;
31243 + extern struct Qdisc_ops mq_qdisc_ops;
31244 ++extern struct Qdisc_ops fq_codel_qdisc_ops;
31245 + extern const struct Qdisc_ops *default_qdisc_ops;
31247 + struct Qdisc_class_common {
31248 +--- a/net/sched/sch_generic.c
31249 ++++ b/net/sched/sch_generic.c
31250 +@@ -693,7 +693,7 @@ static void attach_one_default_qdisc(str
31252 + if (dev->tx_queue_len) {
31253 + qdisc = qdisc_create_dflt(dev_queue,
31254 +- default_qdisc_ops, TC_H_ROOT);
31255 ++ &fq_codel_qdisc_ops, TC_H_ROOT);
31256 + if (!qdisc) {
31257 + netdev_info(dev, "activation failed\n");
31258 + return;
31259 +--- a/net/sched/sch_mq.c
31260 ++++ b/net/sched/sch_mq.c
31261 +@@ -57,7 +57,7 @@ static int mq_init(struct Qdisc *sch, st
31263 + for (ntx = 0; ntx < dev->num_tx_queues; ntx++) {
31264 + dev_queue = netdev_get_tx_queue(dev, ntx);
31265 +- qdisc = qdisc_create_dflt(dev_queue, default_qdisc_ops,
31266 ++ qdisc = qdisc_create_dflt(dev_queue, &fq_codel_qdisc_ops,
31267 + TC_H_MAKE(TC_H_MAJ(sch->handle),
31268 + TC_H_MIN(ntx + 1)));
31269 + if (qdisc == NULL)
31270 +--- a/net/sched/sch_mqprio.c
31271 ++++ b/net/sched/sch_mqprio.c
31272 +@@ -124,7 +124,7 @@ static int mqprio_init(struct Qdisc *sch
31274 + for (i = 0; i < dev->num_tx_queues; i++) {
31275 + dev_queue = netdev_get_tx_queue(dev, i);
31276 +- qdisc = qdisc_create_dflt(dev_queue, default_qdisc_ops,
31277 ++ qdisc = qdisc_create_dflt(dev_queue, &fq_codel_qdisc_ops,
31278 + TC_H_MAKE(TC_H_MAJ(sch->handle),
31279 + TC_H_MIN(i + 1)));
31280 + if (qdisc == NULL) {
31281 diff --git a/target/linux/generic/patches-3.16/663-remove_pfifo_fast.patch b/target/linux/generic/patches-3.16/663-remove_pfifo_fast.patch
31282 new file mode 100644
31283 index 000000000000..3420d3d438bf
31284 --- /dev/null
31285 +++ b/target/linux/generic/patches-3.16/663-remove_pfifo_fast.patch
31286 @@ -0,0 +1,143 @@
31287 +--- a/net/sched/sch_generic.c
31288 ++++ b/net/sched/sch_generic.c
31289 +@@ -401,140 +401,6 @@ static struct Qdisc noqueue_qdisc = {
31290 + .busylock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.busylock),
31291 + };
31294 +-static const u8 prio2band[TC_PRIO_MAX + 1] = {
31295 +- 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1
31296 +-};
31298 +-/* 3-band FIFO queue: old style, but should be a bit faster than
31299 +- generic prio+fifo combination.
31300 +- */
31302 +-#define PFIFO_FAST_BANDS 3
31304 +-/*
31305 +- * Private data for a pfifo_fast scheduler containing:
31306 +- * - queues for the three band
31307 +- * - bitmap indicating which of the bands contain skbs
31308 +- */
31309 +-struct pfifo_fast_priv {
31310 +- u32 bitmap;
31311 +- struct sk_buff_head q[PFIFO_FAST_BANDS];
31312 +-};
31314 +-/*
31315 +- * Convert a bitmap to the first band number where an skb is queued, where:
31316 +- * bitmap=0 means there are no skbs on any band.
31317 +- * bitmap=1 means there is an skb on band 0.
31318 +- * bitmap=7 means there are skbs on all 3 bands, etc.
31319 +- */
31320 +-static const int bitmap2band[] = {-1, 0, 1, 0, 2, 0, 1, 0};
31322 +-static inline struct sk_buff_head *band2list(struct pfifo_fast_priv *priv,
31323 +- int band)
31325 +- return priv->q + band;
31328 +-static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc)
31330 +- if (skb_queue_len(&qdisc->q) < qdisc_dev(qdisc)->tx_queue_len) {
31331 +- int band = prio2band[skb->priority & TC_PRIO_MAX];
31332 +- struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
31333 +- struct sk_buff_head *list = band2list(priv, band);
31335 +- priv->bitmap |= (1 << band);
31336 +- qdisc->q.qlen++;
31337 +- return __qdisc_enqueue_tail(skb, qdisc, list);
31338 +- }
31340 +- return qdisc_drop(skb, qdisc);
31343 +-static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
31345 +- struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
31346 +- int band = bitmap2band[priv->bitmap];
31348 +- if (likely(band >= 0)) {
31349 +- struct sk_buff_head *list = band2list(priv, band);
31350 +- struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list);
31352 +- qdisc->q.qlen--;
31353 +- if (skb_queue_empty(list))
31354 +- priv->bitmap &= ~(1 << band);
31356 +- return skb;
31357 +- }
31359 +- return NULL;
31362 +-static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
31364 +- struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
31365 +- int band = bitmap2band[priv->bitmap];
31367 +- if (band >= 0) {
31368 +- struct sk_buff_head *list = band2list(priv, band);
31370 +- return skb_peek(list);
31371 +- }
31373 +- return NULL;
31376 +-static void pfifo_fast_reset(struct Qdisc *qdisc)
31378 +- int prio;
31379 +- struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
31381 +- for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
31382 +- __qdisc_reset_queue(qdisc, band2list(priv, prio));
31384 +- priv->bitmap = 0;
31385 +- qdisc->qstats.backlog = 0;
31386 +- qdisc->q.qlen = 0;
31389 +-static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
31391 +- struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
31393 +- memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
31394 +- if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
31395 +- goto nla_put_failure;
31396 +- return skb->len;
31398 +-nla_put_failure:
31399 +- return -1;
31402 +-static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
31404 +- int prio;
31405 +- struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
31407 +- for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
31408 +- skb_queue_head_init(band2list(priv, prio));
31410 +- /* Can by-pass the queue discipline */
31411 +- qdisc->flags |= TCQ_F_CAN_BYPASS;
31412 +- return 0;
31415 +-struct Qdisc_ops pfifo_fast_ops __read_mostly = {
31416 +- .id = "pfifo_fast",
31417 +- .priv_size = sizeof(struct pfifo_fast_priv),
31418 +- .enqueue = pfifo_fast_enqueue,
31419 +- .dequeue = pfifo_fast_dequeue,
31420 +- .peek = pfifo_fast_peek,
31421 +- .init = pfifo_fast_init,
31422 +- .reset = pfifo_fast_reset,
31423 +- .dump = pfifo_fast_dump,
31424 +- .owner = THIS_MODULE,
31425 +-};
31427 + static struct lock_class_key qdisc_tx_busylock;
31429 + struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
31430 diff --git a/target/linux/generic/patches-3.16/664-codel_fix_3_12.patch b/target/linux/generic/patches-3.16/664-codel_fix_3_12.patch
31431 new file mode 100644
31432 index 000000000000..31158c584844
31433 --- /dev/null
31434 +++ b/target/linux/generic/patches-3.16/664-codel_fix_3_12.patch
31435 @@ -0,0 +1,22 @@
31436 +--- a/net/sched/sch_api.c
31437 ++++ b/net/sched/sch_api.c
31438 +@@ -1914,7 +1914,7 @@ static int __init pktsched_init(void)
31439 + return err;
31442 +- register_qdisc(&pfifo_fast_ops);
31443 ++ register_qdisc(&fq_codel_qdisc_ops);
31444 + register_qdisc(&pfifo_qdisc_ops);
31445 + register_qdisc(&bfifo_qdisc_ops);
31446 + register_qdisc(&pfifo_head_drop_qdisc_ops);
31447 +--- a/net/sched/sch_generic.c
31448 ++++ b/net/sched/sch_generic.c
31449 +@@ -31,7 +31,7 @@
31450 + #include <net/dst.h>
31452 + /* Qdisc to use by default */
31453 +-const struct Qdisc_ops *default_qdisc_ops = &pfifo_fast_ops;
31454 ++const struct Qdisc_ops *default_qdisc_ops = &fq_codel_qdisc_ops;
31455 + EXPORT_SYMBOL(default_qdisc_ops);
31457 + /* Main transmission queue. */
31458 diff --git a/target/linux/generic/patches-3.16/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch b/target/linux/generic/patches-3.16/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch
31459 new file mode 100644
31460 index 000000000000..76da297bad1c
31461 --- /dev/null
31462 +++ b/target/linux/generic/patches-3.16/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch
31463 @@ -0,0 +1,481 @@
31464 +From 775d6fe74d1eaec2ba387535b068dde2dc89de9e Mon Sep 17 00:00:00 2001
31465 +From: Steven Barth <steven@midlink.org>
31466 +Date: Thu, 22 May 2014 09:49:05 +0200
31467 +Subject: [PATCH] Add support for MAP-E FMRs (mesh mode)
31469 +MAP-E FMRs (draft-ietf-softwire-map-10) are rules for IPv4-communication
31470 +between MAP CEs (mesh mode) without the need to forward such data to a
31471 +border relay. This is similar to how 6rd works but for IPv4 over IPv6.
31473 +Signed-off-by: Steven Barth <cyrus@openwrt.org>
31474 +---
31475 + include/net/ip6_tunnel.h | 13 ++
31476 + include/uapi/linux/if_tunnel.h | 13 ++
31477 + net/ipv6/ip6_tunnel.c | 276 +++++++++++++++++++++++++++++++++++++++--
31478 + 3 files changed, 291 insertions(+), 11 deletions(-)
31480 +--- a/include/net/ip6_tunnel.h
31481 ++++ b/include/net/ip6_tunnel.h
31482 +@@ -15,6 +15,18 @@
31483 + /* determine capability on a per-packet basis */
31484 + #define IP6_TNL_F_CAP_PER_PACKET 0x40000
31486 ++/* IPv6 tunnel FMR */
31487 ++struct __ip6_tnl_fmr {
31488 ++ struct __ip6_tnl_fmr *next; /* next fmr in list */
31489 ++ struct in6_addr ip6_prefix;
31490 ++ struct in_addr ip4_prefix;
31492 ++ __u8 ip6_prefix_len;
31493 ++ __u8 ip4_prefix_len;
31494 ++ __u8 ea_len;
31495 ++ __u8 offset;
31496 ++};
31498 + struct __ip6_tnl_parm {
31499 + char name[IFNAMSIZ]; /* name of tunnel device */
31500 + int link; /* ifindex of underlying L2 interface */
31501 +@@ -25,6 +37,7 @@ struct __ip6_tnl_parm {
31502 + __u32 flags; /* tunnel flags */
31503 + struct in6_addr laddr; /* local tunnel end-point address */
31504 + struct in6_addr raddr; /* remote tunnel end-point address */
31505 ++ struct __ip6_tnl_fmr *fmrs; /* FMRs */
31507 + __be16 i_flags;
31508 + __be16 o_flags;
31509 +--- a/include/uapi/linux/if_tunnel.h
31510 ++++ b/include/uapi/linux/if_tunnel.h
31511 +@@ -53,10 +53,23 @@ enum {
31512 + IFLA_IPTUN_6RD_RELAY_PREFIX,
31513 + IFLA_IPTUN_6RD_PREFIXLEN,
31514 + IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
31515 ++ IFLA_IPTUN_FMRS,
31516 + __IFLA_IPTUN_MAX,
31517 + };
31518 + #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
31520 ++enum {
31521 ++ IFLA_IPTUN_FMR_UNSPEC,
31522 ++ IFLA_IPTUN_FMR_IP6_PREFIX,
31523 ++ IFLA_IPTUN_FMR_IP4_PREFIX,
31524 ++ IFLA_IPTUN_FMR_IP6_PREFIX_LEN,
31525 ++ IFLA_IPTUN_FMR_IP4_PREFIX_LEN,
31526 ++ IFLA_IPTUN_FMR_EA_LEN,
31527 ++ IFLA_IPTUN_FMR_OFFSET,
31528 ++ __IFLA_IPTUN_FMR_MAX,
31529 ++};
31530 ++#define IFLA_IPTUN_FMR_MAX (__IFLA_IPTUN_FMR_MAX - 1)
31532 + /* SIT-mode i_flags */
31533 + #define SIT_ISATAP 0x0001
31535 +--- a/net/ipv6/ip6_tunnel.c
31536 ++++ b/net/ipv6/ip6_tunnel.c
31537 +@@ -16,6 +16,8 @@
31538 + * as published by the Free Software Foundation; either version
31539 + * 2 of the License, or (at your option) any later version.
31541 ++ * Changes:
31542 ++ * Steven Barth <cyrus@openwrt.org>: MAP-E FMR support
31543 + */
31545 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31546 +@@ -77,11 +79,9 @@ static bool log_ecn_error = true;
31547 + module_param(log_ecn_error, bool, 0644);
31548 + MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
31550 +-static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
31551 ++static u32 HASH(const struct in6_addr *addr)
31553 +- u32 hash = ipv6_addr_hash(addr1) ^ ipv6_addr_hash(addr2);
31555 +- return hash_32(hash, HASH_SIZE_SHIFT);
31556 ++ return hash_32(ipv6_addr_hash(addr), HASH_SIZE_SHIFT);
31559 + static int ip6_tnl_dev_init(struct net_device *dev);
31560 +@@ -180,15 +180,24 @@ EXPORT_SYMBOL_GPL(ip6_tnl_dst_store);
31561 + static struct ip6_tnl *
31562 + ip6_tnl_lookup(struct net *net, const struct in6_addr *remote, const struct in6_addr *local)
31564 +- unsigned int hash = HASH(remote, local);
31565 ++ unsigned int hash = HASH(local);
31566 + struct ip6_tnl *t;
31567 + struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
31568 ++ struct __ip6_tnl_fmr *fmr;
31570 + for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
31571 +- if (ipv6_addr_equal(local, &t->parms.laddr) &&
31572 +- ipv6_addr_equal(remote, &t->parms.raddr) &&
31573 +- (t->dev->flags & IFF_UP))
31574 ++ if (!ipv6_addr_equal(local, &t->parms.laddr) ||
31575 ++ !(t->dev->flags & IFF_UP))
31576 ++ continue;
31578 ++ if (ipv6_addr_equal(remote, &t->parms.raddr))
31579 + return t;
31581 ++ for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) {
31582 ++ if (ipv6_prefix_equal(remote, &fmr->ip6_prefix,
31583 ++ fmr->ip6_prefix_len))
31584 ++ return t;
31585 ++ }
31587 + t = rcu_dereference(ip6n->tnls_wc[0]);
31588 + if (t && (t->dev->flags & IFF_UP))
31589 +@@ -218,7 +227,7 @@ ip6_tnl_bucket(struct ip6_tnl_net *ip6n,
31591 + if (!ipv6_addr_any(remote) || !ipv6_addr_any(local)) {
31592 + prio = 1;
31593 +- h = HASH(remote, local);
31594 ++ h = HASH(local);
31596 + return &ip6n->tnls[prio][h];
31598 +@@ -386,6 +395,12 @@ ip6_tnl_dev_uninit(struct net_device *de
31599 + struct net *net = t->net;
31600 + struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
31602 ++ while (t->parms.fmrs) {
31603 ++ struct __ip6_tnl_fmr *next = t->parms.fmrs->next;
31604 ++ kfree(t->parms.fmrs);
31605 ++ t->parms.fmrs = next;
31606 ++ }
31608 + if (dev == ip6n->fb_tnl_dev)
31609 + RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL);
31610 + else
31611 +@@ -769,6 +784,108 @@ int ip6_tnl_rcv_ctl(struct ip6_tnl *t,
31613 + EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl);
31616 ++/**
31617 ++ * ip4ip6_fmr_calc - calculate target / source IPv6-address based on FMR
31618 ++ * @dest: destination IPv6 address buffer
31619 ++ * @skb: received socket buffer
31620 ++ * @fmr: MAP FMR
31621 ++ * @xmit: Calculate for xmit or rcv
31622 ++ **/
31623 ++static void ip4ip6_fmr_calc(struct in6_addr *dest,
31624 ++ const struct iphdr *iph, const uint8_t *end,
31625 ++ const struct __ip6_tnl_fmr *fmr, bool xmit)
31627 ++ int psidlen = fmr->ea_len - (32 - fmr->ip4_prefix_len);
31628 ++ u8 *portp = NULL;
31629 ++ bool use_dest_addr;
31630 ++ const struct iphdr *dsth = iph;
31632 ++ if ((u8*)dsth >= end)
31633 ++ return;
31635 ++ /* find significant IP header */
31636 ++ if (iph->protocol == IPPROTO_ICMP) {
31637 ++ struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4);
31638 ++ if (ih && ((u8*)&ih[1]) <= end && (
31639 ++ ih->type == ICMP_DEST_UNREACH ||
31640 ++ ih->type == ICMP_SOURCE_QUENCH ||
31641 ++ ih->type == ICMP_TIME_EXCEEDED ||
31642 ++ ih->type == ICMP_PARAMETERPROB ||
31643 ++ ih->type == ICMP_REDIRECT))
31644 ++ dsth = (const struct iphdr*)&ih[1];
31645 ++ }
31647 ++ /* in xmit-path use dest port by default and source port only if
31648 ++ this is an ICMP reply to something else; vice versa in rcv-path */
31649 ++ use_dest_addr = (xmit && dsth == iph) || (!xmit && dsth != iph);
31651 ++ /* get dst port */
31652 ++ if (((u8*)&dsth[1]) <= end && (
31653 ++ dsth->protocol == IPPROTO_UDP ||
31654 ++ dsth->protocol == IPPROTO_TCP ||
31655 ++ dsth->protocol == IPPROTO_SCTP ||
31656 ++ dsth->protocol == IPPROTO_DCCP)) {
31657 ++ /* for UDP, TCP, SCTP and DCCP source and dest port
31658 ++ follow IPv4 header directly */
31659 ++ portp = ((u8*)dsth) + dsth->ihl * 4;
31661 ++ if (use_dest_addr)
31662 ++ portp += sizeof(u16);
31663 ++ } else if (iph->protocol == IPPROTO_ICMP) {
31664 ++ struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4);
31666 ++ /* use icmp identifier as port */
31667 ++ if (((u8*)&ih) <= end && (
31668 ++ (use_dest_addr && (
31669 ++ ih->type == ICMP_ECHOREPLY ||
31670 ++ ih->type == ICMP_TIMESTAMPREPLY ||
31671 ++ ih->type == ICMP_INFO_REPLY ||
31672 ++ ih->type == ICMP_ADDRESSREPLY)) ||
31673 ++ (!use_dest_addr && (
31674 ++ ih->type == ICMP_ECHO ||
31675 ++ ih->type == ICMP_TIMESTAMP ||
31676 ++ ih->type == ICMP_INFO_REQUEST ||
31677 ++ ih->type == ICMP_ADDRESS)
31678 ++ )))
31679 ++ portp = (u8*)&ih->un.echo.id;
31680 ++ }
31682 ++ if ((portp && &portp[2] <= end) || psidlen == 0) {
31683 ++ int frombyte = fmr->ip6_prefix_len / 8;
31684 ++ int fromrem = fmr->ip6_prefix_len % 8;
31685 ++ int bytes = sizeof(struct in6_addr) - frombyte;
31686 ++ const u32 *addr = (use_dest_addr) ? &iph->daddr : &iph->saddr;
31687 ++ u64 eabits = ((u64)ntohl(*addr)) << (32 + fmr->ip4_prefix_len);
31688 ++ u64 t = 0;
31690 ++ /* extract PSID from port and add it to eabits */
31691 ++ u16 psidbits = 0;
31692 ++ if (psidlen > 0) {
31693 ++ psidbits = ((u16)portp[0]) << 8 | ((u16)portp[1]);
31694 ++ psidbits >>= 16 - psidlen - fmr->offset;
31695 ++ psidbits = (u16)(psidbits << (16 - psidlen));
31696 ++ eabits |= ((u64)psidbits) << (48 - (fmr->ea_len - psidlen));
31697 ++ }
31699 ++ /* rewrite destination address */
31700 ++ *dest = fmr->ip6_prefix;
31701 ++ memcpy(&dest->s6_addr[10], addr, sizeof(*addr));
31702 ++ dest->s6_addr16[7] = htons(psidbits >> (16 - psidlen));
31704 ++ if (bytes > sizeof(u64))
31705 ++ bytes = sizeof(u64);
31707 ++ /* insert eabits */
31708 ++ memcpy(&t, &dest->s6_addr[frombyte], bytes);
31709 ++ t = be64_to_cpu(t) & ~(((((u64)1) << fmr->ea_len) - 1)
31710 ++ << (64 - fmr->ea_len - fromrem));
31711 ++ t = cpu_to_be64(t | (eabits >> fromrem));
31712 ++ memcpy(&dest->s6_addr[frombyte], &t, bytes);
31713 ++ }
31717 + /**
31718 + * ip6_tnl_rcv - decapsulate IPv6 packet and retransmit it locally
31719 + * @skb: received socket buffer
31720 +@@ -813,6 +930,26 @@ static int ip6_tnl_rcv(struct sk_buff *s
31721 + skb_reset_network_header(skb);
31722 + skb->protocol = htons(protocol);
31723 + memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
31724 ++ if (protocol == ETH_P_IP &&
31725 ++ !ipv6_addr_equal(&ipv6h->saddr, &t->parms.raddr)) {
31726 ++ /* Packet didn't come from BR, so lookup FMR */
31727 ++ struct __ip6_tnl_fmr *fmr;
31728 ++ struct in6_addr expected = t->parms.raddr;
31729 ++ for (fmr = t->parms.fmrs; fmr; fmr = fmr->next)
31730 ++ if (ipv6_prefix_equal(&ipv6h->saddr,
31731 ++ &fmr->ip6_prefix, fmr->ip6_prefix_len))
31732 ++ break;
31734 ++ /* Check that IPv6 matches IPv4 source to prevent spoofing */
31735 ++ if (fmr)
31736 ++ ip4ip6_fmr_calc(&expected, ip_hdr(skb),
31737 ++ skb_tail_pointer(skb), fmr, false);
31739 ++ if (!ipv6_addr_equal(&ipv6h->saddr, &expected)) {
31740 ++ rcu_read_unlock();
31741 ++ goto discard;
31742 ++ }
31743 ++ }
31745 + __skb_tunnel_rx(skb, t->dev, t->net);
31747 +@@ -1073,6 +1210,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, str
31748 + __u8 dsfield;
31749 + __u32 mtu;
31750 + int err;
31751 ++ struct __ip6_tnl_fmr *fmr;
31753 + if ((t->parms.proto != IPPROTO_IPIP && t->parms.proto != 0) ||
31754 + !ip6_tnl_xmit_ctl(t))
31755 +@@ -1092,6 +1230,18 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, str
31756 + if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
31757 + fl6.flowi6_mark = skb->mark;
31759 ++ /* try to find matching FMR */
31760 ++ for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) {
31761 ++ unsigned mshift = 32 - fmr->ip4_prefix_len;
31762 ++ if (ntohl(fmr->ip4_prefix.s_addr) >> mshift ==
31763 ++ ntohl(iph->daddr) >> mshift)
31764 ++ break;
31765 ++ }
31767 ++ /* change dstaddr according to FMR */
31768 ++ if (fmr)
31769 ++ ip4ip6_fmr_calc(&fl6.daddr, iph, skb_tail_pointer(skb), fmr, true);
31771 + err = ip6_tnl_xmit2(skb, dev, dsfield, &fl6, encap_limit, &mtu);
31772 + if (err != 0) {
31773 + /* XXX: send ICMP error even if DF is not set. */
31774 +@@ -1260,6 +1410,14 @@ ip6_tnl_change(struct ip6_tnl *t, const
31775 + t->parms.flowinfo = p->flowinfo;
31776 + t->parms.link = p->link;
31777 + t->parms.proto = p->proto;
31779 ++ while (t->parms.fmrs) {
31780 ++ struct __ip6_tnl_fmr *next = t->parms.fmrs->next;
31781 ++ kfree(t->parms.fmrs);
31782 ++ t->parms.fmrs = next;
31783 ++ }
31784 ++ t->parms.fmrs = p->fmrs;
31786 + ip6_tnl_dst_reset(t);
31787 + ip6_tnl_link_config(t);
31788 + return 0;
31789 +@@ -1290,6 +1448,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_
31790 + p->flowinfo = u->flowinfo;
31791 + p->link = u->link;
31792 + p->proto = u->proto;
31793 ++ p->fmrs = NULL;
31794 + memcpy(p->name, u->name, sizeof(u->name));
31797 +@@ -1577,6 +1736,15 @@ static int ip6_tnl_validate(struct nlatt
31798 + return 0;
31801 ++static const struct nla_policy ip6_tnl_fmr_policy[IFLA_IPTUN_FMR_MAX + 1] = {
31802 ++ [IFLA_IPTUN_FMR_IP6_PREFIX] = { .len = sizeof(struct in6_addr) },
31803 ++ [IFLA_IPTUN_FMR_IP4_PREFIX] = { .len = sizeof(struct in_addr) },
31804 ++ [IFLA_IPTUN_FMR_IP6_PREFIX_LEN] = { .type = NLA_U8 },
31805 ++ [IFLA_IPTUN_FMR_IP4_PREFIX_LEN] = { .type = NLA_U8 },
31806 ++ [IFLA_IPTUN_FMR_EA_LEN] = { .type = NLA_U8 },
31807 ++ [IFLA_IPTUN_FMR_OFFSET] = { .type = NLA_U8 }
31808 ++};
31810 + static void ip6_tnl_netlink_parms(struct nlattr *data[],
31811 + struct __ip6_tnl_parm *parms)
31813 +@@ -1610,6 +1778,46 @@ static void ip6_tnl_netlink_parms(struct
31815 + if (data[IFLA_IPTUN_PROTO])
31816 + parms->proto = nla_get_u8(data[IFLA_IPTUN_PROTO]);
31818 ++ if (data[IFLA_IPTUN_FMRS]) {
31819 ++ unsigned rem;
31820 ++ struct nlattr *fmr;
31821 ++ nla_for_each_nested(fmr, data[IFLA_IPTUN_FMRS], rem) {
31822 ++ struct nlattr *fmrd[IFLA_IPTUN_FMR_MAX + 1], *c;
31823 ++ struct __ip6_tnl_fmr *nfmr;
31825 ++ nla_parse_nested(fmrd, IFLA_IPTUN_FMR_MAX,
31826 ++ fmr, ip6_tnl_fmr_policy);
31828 ++ if (!(nfmr = kzalloc(sizeof(*nfmr), GFP_KERNEL)))
31829 ++ continue;
31831 ++ nfmr->offset = 6;
31833 ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX]))
31834 ++ nla_memcpy(&nfmr->ip6_prefix, fmrd[IFLA_IPTUN_FMR_IP6_PREFIX],
31835 ++ sizeof(nfmr->ip6_prefix));
31837 ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX]))
31838 ++ nla_memcpy(&nfmr->ip4_prefix, fmrd[IFLA_IPTUN_FMR_IP4_PREFIX],
31839 ++ sizeof(nfmr->ip4_prefix));
31841 ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX_LEN]))
31842 ++ nfmr->ip6_prefix_len = nla_get_u8(c);
31844 ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX_LEN]))
31845 ++ nfmr->ip4_prefix_len = nla_get_u8(c);
31847 ++ if ((c = fmrd[IFLA_IPTUN_FMR_EA_LEN]))
31848 ++ nfmr->ea_len = nla_get_u8(c);
31850 ++ if ((c = fmrd[IFLA_IPTUN_FMR_OFFSET]))
31851 ++ nfmr->offset = nla_get_u8(c);
31853 ++ nfmr->next = parms->fmrs;
31854 ++ parms->fmrs = nfmr;
31855 ++ }
31856 ++ }
31859 + static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
31860 +@@ -1662,6 +1870,12 @@ static void ip6_tnl_dellink(struct net_d
31862 + static size_t ip6_tnl_get_size(const struct net_device *dev)
31864 ++ const struct ip6_tnl *t = netdev_priv(dev);
31865 ++ struct __ip6_tnl_fmr *c;
31866 ++ int fmrs = 0;
31867 ++ for (c = t->parms.fmrs; c; c = c->next)
31868 ++ ++fmrs;
31870 + return
31871 + /* IFLA_IPTUN_LINK */
31872 + nla_total_size(4) +
31873 +@@ -1679,6 +1893,24 @@ static size_t ip6_tnl_get_size(const str
31874 + nla_total_size(4) +
31875 + /* IFLA_IPTUN_PROTO */
31876 + nla_total_size(1) +
31877 ++ /* IFLA_IPTUN_FMRS */
31878 ++ nla_total_size(0) +
31879 ++ (
31880 ++ /* nest */
31881 ++ nla_total_size(0) +
31882 ++ /* IFLA_IPTUN_FMR_IP6_PREFIX */
31883 ++ nla_total_size(sizeof(struct in6_addr)) +
31884 ++ /* IFLA_IPTUN_FMR_IP4_PREFIX */
31885 ++ nla_total_size(sizeof(struct in_addr)) +
31886 ++ /* IFLA_IPTUN_FMR_EA_LEN */
31887 ++ nla_total_size(1) +
31888 ++ /* IFLA_IPTUN_FMR_IP6_PREFIX_LEN */
31889 ++ nla_total_size(1) +
31890 ++ /* IFLA_IPTUN_FMR_IP4_PREFIX_LEN */
31891 ++ nla_total_size(1) +
31892 ++ /* IFLA_IPTUN_FMR_OFFSET */
31893 ++ nla_total_size(1)
31894 ++ ) * fmrs +
31895 + 0;
31898 +@@ -1686,6 +1918,9 @@ static int ip6_tnl_fill_info(struct sk_b
31900 + struct ip6_tnl *tunnel = netdev_priv(dev);
31901 + struct __ip6_tnl_parm *parm = &tunnel->parms;
31902 ++ struct __ip6_tnl_fmr *c;
31903 ++ int fmrcnt = 0;
31904 ++ struct nlattr *fmrs;
31906 + if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
31907 + nla_put(skb, IFLA_IPTUN_LOCAL, sizeof(struct in6_addr),
31908 +@@ -1696,8 +1931,27 @@ static int ip6_tnl_fill_info(struct sk_b
31909 + nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) ||
31910 + nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
31911 + nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) ||
31912 +- nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto))
31913 ++ nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto) ||
31914 ++ !(fmrs = nla_nest_start(skb, IFLA_IPTUN_FMRS)))
31915 + goto nla_put_failure;
31917 ++ for (c = parm->fmrs; c; c = c->next) {
31918 ++ struct nlattr *fmr = nla_nest_start(skb, ++fmrcnt);
31919 ++ if (!fmr ||
31920 ++ nla_put(skb, IFLA_IPTUN_FMR_IP6_PREFIX,
31921 ++ sizeof(c->ip6_prefix), &c->ip6_prefix) ||
31922 ++ nla_put(skb, IFLA_IPTUN_FMR_IP4_PREFIX,
31923 ++ sizeof(c->ip4_prefix), &c->ip4_prefix) ||
31924 ++ nla_put_u8(skb, IFLA_IPTUN_FMR_IP6_PREFIX_LEN, c->ip6_prefix_len) ||
31925 ++ nla_put_u8(skb, IFLA_IPTUN_FMR_IP4_PREFIX_LEN, c->ip4_prefix_len) ||
31926 ++ nla_put_u8(skb, IFLA_IPTUN_FMR_EA_LEN, c->ea_len) ||
31927 ++ nla_put_u8(skb, IFLA_IPTUN_FMR_OFFSET, c->offset))
31928 ++ goto nla_put_failure;
31930 ++ nla_nest_end(skb, fmr);
31931 ++ }
31932 ++ nla_nest_end(skb, fmrs);
31934 + return 0;
31936 + nla_put_failure:
31937 +@@ -1713,6 +1967,7 @@ static const struct nla_policy ip6_tnl_p
31938 + [IFLA_IPTUN_FLOWINFO] = { .type = NLA_U32 },
31939 + [IFLA_IPTUN_FLAGS] = { .type = NLA_U32 },
31940 + [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
31941 ++ [IFLA_IPTUN_FMRS] = { .type = NLA_NESTED },
31942 + };
31944 + static struct rtnl_link_ops ip6_link_ops __read_mostly = {
31945 diff --git a/target/linux/generic/patches-3.16/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch b/target/linux/generic/patches-3.16/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch
31946 new file mode 100644
31947 index 000000000000..7287c8ca4991
31948 --- /dev/null
31949 +++ b/target/linux/generic/patches-3.16/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch
31950 @@ -0,0 +1,239 @@
31951 +From 1b5aaa4b16f6e6471ab1c07b38068197a1b4c395 Mon Sep 17 00:00:00 2001
31952 +From: Jonas Gorski <jogo@openwrt.org>
31953 +Date: Fri, 24 May 2013 14:40:54 +0200
31954 +Subject: [PATCH 1/2] ipv6: allow rejecting with "source address failed policy"
31956 +RFC6204 L-14 requires rejecting traffic from invalid addresses with
31957 +ICMPv6 Destination Unreachable, Code 5 (Source address failed ingress/
31958 +egress policy) on the LAN side, so add an appropriate rule for that.
31960 +Signed-off-by: Jonas Gorski <jogo@openwrt.org>
31961 +---
31963 +--- a/include/net/netns/ipv6.h
31964 ++++ b/include/net/netns/ipv6.h
31965 +@@ -58,6 +58,7 @@ struct netns_ipv6 {
31966 + unsigned long ip6_rt_last_gc;
31967 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES
31968 + struct rt6_info *ip6_prohibit_entry;
31969 ++ struct rt6_info *ip6_policy_failed_entry;
31970 + struct rt6_info *ip6_blk_hole_entry;
31971 + struct fib6_table *fib6_local_tbl;
31972 + struct fib_rules_ops *fib6_rules_ops;
31973 +--- a/include/uapi/linux/fib_rules.h
31974 ++++ b/include/uapi/linux/fib_rules.h
31975 +@@ -64,6 +64,10 @@ enum {
31976 + FR_ACT_BLACKHOLE, /* Drop without notification */
31977 + FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */
31978 + FR_ACT_PROHIBIT, /* Drop with EACCES */
31979 ++ FR_ACT_RES9,
31980 ++ FR_ACT_RES10,
31981 ++ FR_ACT_RES11,
31982 ++ FR_ACT_POLICY_FAILED, /* Drop with EACCES */
31983 + __FR_ACT_MAX,
31984 + };
31986 +--- a/include/uapi/linux/rtnetlink.h
31987 ++++ b/include/uapi/linux/rtnetlink.h
31988 +@@ -203,6 +203,7 @@ enum {
31989 + RTN_THROW, /* Not in this table */
31990 + RTN_NAT, /* Translate this address */
31991 + RTN_XRESOLVE, /* Use external resolver */
31992 ++ RTN_POLICY_FAILED, /* Failed ingress/egress policy */
31993 + __RTN_MAX
31994 + };
31996 +--- a/net/ipv4/fib_semantics.c
31997 ++++ b/net/ipv4/fib_semantics.c
31998 +@@ -138,6 +138,10 @@ const struct fib_prop fib_props[RTN_MAX
31999 + .error = -EINVAL,
32000 + .scope = RT_SCOPE_NOWHERE,
32001 + },
32002 ++ [RTN_POLICY_FAILED] = {
32003 ++ .error = -EACCES,
32004 ++ .scope = RT_SCOPE_UNIVERSE,
32005 ++ },
32006 + };
32008 + static void rt_fibinfo_free(struct rtable __rcu **rtp)
32009 +--- a/net/ipv4/fib_trie.c
32010 ++++ b/net/ipv4/fib_trie.c
32011 +@@ -2324,6 +2324,7 @@ static const char *const rtn_type_names[
32012 + [RTN_THROW] = "THROW",
32013 + [RTN_NAT] = "NAT",
32014 + [RTN_XRESOLVE] = "XRESOLVE",
32015 ++ [RTN_POLICY_FAILED] = "POLICY_FAILED",
32016 + };
32018 + static inline const char *rtn_type(char *buf, size_t len, unsigned int t)
32019 +--- a/net/ipv4/ipmr.c
32020 ++++ b/net/ipv4/ipmr.c
32021 +@@ -184,6 +184,7 @@ static int ipmr_rule_action(struct fib_r
32022 + case FR_ACT_UNREACHABLE:
32023 + return -ENETUNREACH;
32024 + case FR_ACT_PROHIBIT:
32025 ++ case FR_ACT_POLICY_FAILED:
32026 + return -EACCES;
32027 + case FR_ACT_BLACKHOLE:
32028 + default:
32029 +--- a/net/ipv6/fib6_rules.c
32030 ++++ b/net/ipv6/fib6_rules.c
32031 +@@ -73,6 +73,10 @@ static int fib6_rule_action(struct fib_r
32032 + err = -EACCES;
32033 + rt = net->ipv6.ip6_prohibit_entry;
32034 + goto discard_pkt;
32035 ++ case FR_ACT_POLICY_FAILED:
32036 ++ err = -EACCES;
32037 ++ rt = net->ipv6.ip6_policy_failed_entry;
32038 ++ goto discard_pkt;
32041 + table = fib6_get_table(net, rule->table);
32042 +--- a/net/ipv6/ip6mr.c
32043 ++++ b/net/ipv6/ip6mr.c
32044 +@@ -169,6 +169,8 @@ static int ip6mr_rule_action(struct fib_
32045 + return -ENETUNREACH;
32046 + case FR_ACT_PROHIBIT:
32047 + return -EACCES;
32048 ++ case FR_ACT_POLICY_FAILED:
32049 ++ return -EACCES;
32050 + case FR_ACT_BLACKHOLE:
32051 + default:
32052 + return -EINVAL;
32053 +--- a/net/ipv6/route.c
32054 ++++ b/net/ipv6/route.c
32055 +@@ -87,6 +87,8 @@ static int ip6_pkt_discard(struct sk_bu
32056 + static int ip6_pkt_discard_out(struct sock *sk, struct sk_buff *skb);
32057 + static int ip6_pkt_prohibit(struct sk_buff *skb);
32058 + static int ip6_pkt_prohibit_out(struct sock *sk, struct sk_buff *skb);
32059 ++static int ip6_pkt_policy_failed(struct sk_buff *skb);
32060 ++static int ip6_pkt_policy_failed_out(struct sk_buff *skb);
32061 + static void ip6_link_failure(struct sk_buff *skb);
32062 + static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
32063 + struct sk_buff *skb, u32 mtu);
32064 +@@ -283,6 +285,21 @@ static const struct rt6_info ip6_prohibi
32065 + .rt6i_ref = ATOMIC_INIT(1),
32066 + };
32068 ++static const struct rt6_info ip6_policy_failed_entry_template = {
32069 ++ .dst = {
32070 ++ .__refcnt = ATOMIC_INIT(1),
32071 ++ .__use = 1,
32072 ++ .obsolete = DST_OBSOLETE_FORCE_CHK,
32073 ++ .error = -EACCES,
32074 ++ .input = ip6_pkt_policy_failed,
32075 ++ .output = ip6_pkt_policy_failed_out,
32076 ++ },
32077 ++ .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
32078 ++ .rt6i_protocol = RTPROT_KERNEL,
32079 ++ .rt6i_metric = ~(u32) 0,
32080 ++ .rt6i_ref = ATOMIC_INIT(1),
32081 ++};
32083 + static const struct rt6_info ip6_blk_hole_entry_template = {
32084 + .dst = {
32085 + .__refcnt = ATOMIC_INIT(1),
32086 +@@ -1587,6 +1604,11 @@ int ip6_route_add(struct fib6_config *cf
32087 + rt->dst.output = ip6_pkt_prohibit_out;
32088 + rt->dst.input = ip6_pkt_prohibit;
32089 + break;
32090 ++ case RTN_POLICY_FAILED:
32091 ++ rt->dst.error = -EACCES;
32092 ++ rt->dst.output = ip6_pkt_policy_failed_out;
32093 ++ rt->dst.input = ip6_pkt_policy_failed;
32094 ++ break;
32095 + case RTN_THROW:
32096 + default:
32097 + rt->dst.error = (cfg->fc_type == RTN_THROW) ? -EAGAIN
32098 +@@ -2148,6 +2170,17 @@ static int ip6_pkt_prohibit_out(struct s
32099 + return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
32102 ++static int ip6_pkt_policy_failed(struct sk_buff *skb)
32104 ++ return ip6_pkt_drop(skb, ICMPV6_POLICY_FAIL, IPSTATS_MIB_INNOROUTES);
32107 ++static int ip6_pkt_policy_failed_out(struct sk_buff *skb)
32109 ++ skb->dev = skb_dst(skb)->dev;
32110 ++ return ip6_pkt_drop(skb, ICMPV6_POLICY_FAIL, IPSTATS_MIB_OUTNOROUTES);
32113 + /*
32114 + * Allocate a dst for local (unicast / anycast) address.
32115 + */
32116 +@@ -2371,7 +2404,8 @@ static int rtm_to_fib6_config(struct sk_
32117 + if (rtm->rtm_type == RTN_UNREACHABLE ||
32118 + rtm->rtm_type == RTN_BLACKHOLE ||
32119 + rtm->rtm_type == RTN_PROHIBIT ||
32120 +- rtm->rtm_type == RTN_THROW)
32121 ++ rtm->rtm_type == RTN_THROW ||
32122 ++ rtm->rtm_type == RTN_POLICY_FAILED)
32123 + cfg->fc_flags |= RTF_REJECT;
32125 + if (rtm->rtm_type == RTN_LOCAL)
32126 +@@ -2573,6 +2607,9 @@ static int rt6_fill_node(struct net *net
32127 + case -EACCES:
32128 + rtm->rtm_type = RTN_PROHIBIT;
32129 + break;
32130 ++ case -EPERM:
32131 ++ rtm->rtm_type = RTN_POLICY_FAILED;
32132 ++ break;
32133 + case -EAGAIN:
32134 + rtm->rtm_type = RTN_THROW;
32135 + break;
32136 +@@ -2826,6 +2863,8 @@ static int ip6_route_dev_notify(struct n
32137 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES
32138 + net->ipv6.ip6_prohibit_entry->dst.dev = dev;
32139 + net->ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(dev);
32140 ++ net->ipv6.ip6_policy_failed_entry->dst.dev = dev;
32141 ++ net->ipv6.ip6_policy_failed_entry->rt6i_idev = in6_dev_get(dev);
32142 + net->ipv6.ip6_blk_hole_entry->dst.dev = dev;
32143 + net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev);
32144 + #endif
32145 +@@ -3042,6 +3081,17 @@ static int __net_init ip6_route_net_init
32146 + net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops;
32147 + dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst,
32148 + ip6_template_metrics, true);
32150 ++ net->ipv6.ip6_policy_failed_entry =
32151 ++ kmemdup(&ip6_policy_failed_entry_template,
32152 ++ sizeof(*net->ipv6.ip6_policy_failed_entry), GFP_KERNEL);
32153 ++ if (!net->ipv6.ip6_policy_failed_entry)
32154 ++ goto out_ip6_blk_hole_entry;
32155 ++ net->ipv6.ip6_policy_failed_entry->dst.path =
32156 ++ (struct dst_entry *)net->ipv6.ip6_policy_failed_entry;
32157 ++ net->ipv6.ip6_policy_failed_entry->dst.ops = &net->ipv6.ip6_dst_ops;
32158 ++ dst_init_metrics(&net->ipv6.ip6_policy_failed_entry->dst,
32159 ++ ip6_template_metrics, true);
32160 + #endif
32162 + net->ipv6.sysctl.flush_delay = 0;
32163 +@@ -3060,6 +3110,8 @@ out:
32164 + return ret;
32166 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES
32167 ++out_ip6_blk_hole_entry:
32168 ++ kfree(net->ipv6.ip6_blk_hole_entry);
32169 + out_ip6_prohibit_entry:
32170 + kfree(net->ipv6.ip6_prohibit_entry);
32171 + out_ip6_null_entry:
32172 +@@ -3077,6 +3129,7 @@ static void __net_exit ip6_route_net_exi
32173 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES
32174 + kfree(net->ipv6.ip6_prohibit_entry);
32175 + kfree(net->ipv6.ip6_blk_hole_entry);
32176 ++ kfree(net->ipv6.ip6_policy_failed_entry);
32177 + #endif
32178 + dst_entries_destroy(&net->ipv6.ip6_dst_ops);
32180 +@@ -3173,6 +3226,9 @@ int __init ip6_route_init(void)
32181 + init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
32182 + init_net.ipv6.ip6_blk_hole_entry->dst.dev = init_net.loopback_dev;
32183 + init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
32184 ++ init_net.ipv6.ip6_policy_failed_entry->dst.dev = init_net.loopback_dev;
32185 ++ init_net.ipv6.ip6_policy_failed_entry->rt6i_idev =
32186 ++ in6_dev_get(init_net.loopback_dev);
32187 + #endif
32188 + ret = fib6_init();
32189 + if (ret)
32190 diff --git a/target/linux/generic/patches-3.16/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch b/target/linux/generic/patches-3.16/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch
32191 new file mode 100644
32192 index 000000000000..25a86393975f
32193 --- /dev/null
32194 +++ b/target/linux/generic/patches-3.16/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch
32195 @@ -0,0 +1,53 @@
32196 +From 7749b481ce5d7e232b1f7da5e6b2c44816f51681 Mon Sep 17 00:00:00 2001
32197 +From: Jonas Gorski <jogo@openwrt.org>
32198 +Date: Sun, 19 Jan 2014 20:45:51 +0100
32199 +Subject: [PATCH 2/2] net: provide defines for _POLICY_FAILED until all code is
32200 + updated
32202 +Upstream introduced ICMPV6_POLICY_FAIL for code 5 of destination
32203 +unreachable, conflicting with our name.
32205 +Add appropriate defines to allow our code to build with the new
32206 +name until we have updated our local patches for older kernels
32207 +and userspace packages.
32209 +Signed-off-by: Jonas Gorski <jogo@openwrt.org>
32210 +---
32211 + include/uapi/linux/fib_rules.h | 2 ++
32212 + include/uapi/linux/icmpv6.h | 2 ++
32213 + include/uapi/linux/rtnetlink.h | 2 ++
32214 + 3 files changed, 6 insertions(+)
32216 +--- a/include/uapi/linux/fib_rules.h
32217 ++++ b/include/uapi/linux/fib_rules.h
32218 +@@ -71,6 +71,8 @@ enum {
32219 + __FR_ACT_MAX,
32220 + };
32222 ++#define FR_ACT_FAILED_POLICY FR_ACT_POLICY_FAILED
32224 + #define FR_ACT_MAX (__FR_ACT_MAX - 1)
32226 + #endif
32227 +--- a/include/uapi/linux/icmpv6.h
32228 ++++ b/include/uapi/linux/icmpv6.h
32229 +@@ -118,6 +118,8 @@ struct icmp6hdr {
32230 + #define ICMPV6_POLICY_FAIL 5
32231 + #define ICMPV6_REJECT_ROUTE 6
32233 ++#define ICMPV6_FAILED_POLICY ICMPV6_POLICY_FAIL
32235 + /*
32236 + * Codes for Time Exceeded
32237 + */
32238 +--- a/include/uapi/linux/rtnetlink.h
32239 ++++ b/include/uapi/linux/rtnetlink.h
32240 +@@ -207,6 +207,8 @@ enum {
32241 + __RTN_MAX
32242 + };
32244 ++#define RTN_FAILED_POLICY RTN_POLICY_FAILED
32246 + #define RTN_MAX (__RTN_MAX - 1)
32249 diff --git a/target/linux/generic/patches-3.16/700-swconfig.patch b/target/linux/generic/patches-3.16/700-swconfig.patch
32250 new file mode 100644
32251 index 000000000000..a60722c27b27
32252 --- /dev/null
32253 +++ b/target/linux/generic/patches-3.16/700-swconfig.patch
32254 @@ -0,0 +1,39 @@
32255 +--- a/drivers/net/phy/Kconfig
32256 ++++ b/drivers/net/phy/Kconfig
32257 +@@ -12,6 +12,16 @@ menuconfig PHYLIB
32259 + if PHYLIB
32261 ++config SWCONFIG
32262 ++ tristate "Switch configuration API"
32263 ++ ---help---
32264 ++ Switch configuration API using netlink. This allows
32265 ++ you to configure the VLAN features of certain switches.
32267 ++config SWCONFIG_LEDS
32268 ++ bool "Switch LED trigger support"
32269 ++ depends on (SWCONFIG && LEDS_TRIGGERS)
32271 + comment "MII PHY device drivers"
32273 + config AT803X_PHY
32274 +--- a/drivers/net/phy/Makefile
32275 ++++ b/drivers/net/phy/Makefile
32276 +@@ -3,6 +3,7 @@
32277 + libphy-objs := phy.o phy_device.o mdio_bus.o
32279 + obj-$(CONFIG_PHYLIB) += libphy.o
32280 ++obj-$(CONFIG_SWCONFIG) += swconfig.o
32281 + obj-$(CONFIG_MARVELL_PHY) += marvell.o
32282 + obj-$(CONFIG_DAVICOM_PHY) += davicom.o
32283 + obj-$(CONFIG_CICADA_PHY) += cicada.o
32284 +--- a/include/uapi/linux/Kbuild
32285 ++++ b/include/uapi/linux/Kbuild
32286 +@@ -366,6 +366,7 @@ header-y += stddef.h
32287 + header-y += string.h
32288 + header-y += suspend_ioctls.h
32289 + header-y += swab.h
32290 ++header-y += switch.h
32291 + header-y += synclink.h
32292 + header-y += sysctl.h
32293 + header-y += sysinfo.h
32294 diff --git a/target/linux/generic/patches-3.16/701-phy_extension.patch b/target/linux/generic/patches-3.16/701-phy_extension.patch
32295 new file mode 100644
32296 index 000000000000..4c1841155ffe
32297 --- /dev/null
32298 +++ b/target/linux/generic/patches-3.16/701-phy_extension.patch
32299 @@ -0,0 +1,63 @@
32300 +--- a/drivers/net/phy/phy.c
32301 ++++ b/drivers/net/phy/phy.c
32302 +@@ -293,6 +293,50 @@ int phy_ethtool_gset(struct phy_device *
32304 + EXPORT_SYMBOL(phy_ethtool_gset);
32306 ++int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
32308 ++ u32 cmd;
32309 ++ int tmp;
32310 ++ struct ethtool_cmd ecmd = { ETHTOOL_GSET };
32311 ++ struct ethtool_value edata = { ETHTOOL_GLINK };
32313 ++ if (get_user(cmd, (u32 *) useraddr))
32314 ++ return -EFAULT;
32316 ++ switch (cmd) {
32317 ++ case ETHTOOL_GSET:
32318 ++ phy_ethtool_gset(phydev, &ecmd);
32319 ++ if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
32320 ++ return -EFAULT;
32321 ++ return 0;
32323 ++ case ETHTOOL_SSET:
32324 ++ if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
32325 ++ return -EFAULT;
32326 ++ return phy_ethtool_sset(phydev, &ecmd);
32328 ++ case ETHTOOL_NWAY_RST:
32329 ++ /* if autoneg is off, it's an error */
32330 ++ tmp = phy_read(phydev, MII_BMCR);
32331 ++ if (tmp & BMCR_ANENABLE) {
32332 ++ tmp |= (BMCR_ANRESTART);
32333 ++ phy_write(phydev, MII_BMCR, tmp);
32334 ++ return 0;
32335 ++ }
32336 ++ return -EINVAL;
32338 ++ case ETHTOOL_GLINK:
32339 ++ edata.data = (phy_read(phydev,
32340 ++ MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
32341 ++ if (copy_to_user(useraddr, &edata, sizeof(edata)))
32342 ++ return -EFAULT;
32343 ++ return 0;
32344 ++ }
32346 ++ return -EOPNOTSUPP;
32348 ++EXPORT_SYMBOL(phy_ethtool_ioctl);
32350 + /**
32351 + * phy_mii_ioctl - generic PHY MII ioctl interface
32352 + * @phydev: the phy_device struct
32353 +--- a/include/linux/phy.h
32354 ++++ b/include/linux/phy.h
32355 +@@ -627,6 +627,7 @@ void phy_start_machine(struct phy_device
32356 + void phy_stop_machine(struct phy_device *phydev);
32357 + int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
32358 + int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
32359 ++int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
32360 + int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd);
32361 + int phy_start_interrupts(struct phy_device *phydev);
32362 + void phy_print_status(struct phy_device *phydev);
32363 diff --git a/target/linux/generic/patches-3.16/702-phy_add_aneg_done_function.patch b/target/linux/generic/patches-3.16/702-phy_add_aneg_done_function.patch
32364 new file mode 100644
32365 index 000000000000..ea199dbc2131
32366 --- /dev/null
32367 +++ b/target/linux/generic/patches-3.16/702-phy_add_aneg_done_function.patch
32368 @@ -0,0 +1,28 @@
32369 +--- a/include/linux/phy.h
32370 ++++ b/include/linux/phy.h
32371 +@@ -484,6 +484,12 @@ struct phy_driver {
32372 + /* Determines the negotiated speed and duplex */
32373 + int (*read_status)(struct phy_device *phydev);
32375 ++ /*
32376 ++ * Update the value in phydev->link to reflect the
32377 ++ * current link value
32378 ++ */
32379 ++ int (*update_link)(struct phy_device *phydev);
32381 + /* Clears any pending interrupts */
32382 + int (*ack_interrupt)(struct phy_device *phydev);
32384 +--- a/drivers/net/phy/phy_device.c
32385 ++++ b/drivers/net/phy/phy_device.c
32386 +@@ -912,6 +912,9 @@ int genphy_update_link(struct phy_device
32388 + int status;
32390 ++ if (phydev->drv->update_link)
32391 ++ return phydev->drv->update_link(phydev);
32393 + /* Do a fake read */
32394 + status = phy_read(phydev, MII_BMSR);
32395 + if (status < 0)
32397 diff --git a/target/linux/generic/patches-3.16/703-phy-add-detach-callback-to-struct-phy_driver.patch b/target/linux/generic/patches-3.16/703-phy-add-detach-callback-to-struct-phy_driver.patch
32398 new file mode 100644
32399 index 000000000000..f41a64924ef2
32400 --- /dev/null
32401 +++ b/target/linux/generic/patches-3.16/703-phy-add-detach-callback-to-struct-phy_driver.patch
32402 @@ -0,0 +1,27 @@
32403 +--- a/drivers/net/phy/phy_device.c
32404 ++++ b/drivers/net/phy/phy_device.c
32405 +@@ -677,6 +677,9 @@ void phy_detach(struct phy_device *phyde
32406 + if (phydev->bus->dev.driver)
32407 + module_put(phydev->bus->dev.driver->owner);
32409 ++ if (phydev->drv && phydev->drv->detach)
32410 ++ phydev->drv->detach(phydev);
32412 + phydev->attached_dev->phydev = NULL;
32413 + phydev->attached_dev = NULL;
32414 + phy_suspend(phydev);
32415 +--- a/include/linux/phy.h
32416 ++++ b/include/linux/phy.h
32417 +@@ -502,6 +502,12 @@ struct phy_driver {
32418 + */
32419 + int (*did_interrupt)(struct phy_device *phydev);
32421 ++ /*
32422 ++ * Called before an ethernet device is detached
32423 ++ * from the PHY.
32424 ++ */
32425 ++ void (*detach)(struct phy_device *phydev);
32427 + /* Clears up any memory if needed */
32428 + void (*remove)(struct phy_device *phydev);
32430 diff --git a/target/linux/generic/patches-3.16/710-phy-add-mdio_register_board_info.patch b/target/linux/generic/patches-3.16/710-phy-add-mdio_register_board_info.patch
32431 new file mode 100644
32432 index 000000000000..a3789e0bdf84
32433 --- /dev/null
32434 +++ b/target/linux/generic/patches-3.16/710-phy-add-mdio_register_board_info.patch
32435 @@ -0,0 +1,192 @@
32436 +--- a/drivers/net/Makefile
32437 ++++ b/drivers/net/Makefile
32438 +@@ -15,7 +15,7 @@ obj-$(CONFIG_MII) += mii.o
32439 + obj-$(CONFIG_MDIO) += mdio.o
32440 + obj-$(CONFIG_NET) += Space.o loopback.o
32441 + obj-$(CONFIG_NETCONSOLE) += netconsole.o
32442 +-obj-$(CONFIG_PHYLIB) += phy/
32443 ++obj-y += phy/
32444 + obj-$(CONFIG_RIONET) += rionet.o
32445 + obj-$(CONFIG_NET_TEAM) += team/
32446 + obj-$(CONFIG_TUN) += tun.o
32447 +--- a/drivers/net/phy/Kconfig
32448 ++++ b/drivers/net/phy/Kconfig
32449 +@@ -12,6 +12,10 @@ menuconfig PHYLIB
32451 + if PHYLIB
32453 ++config MDIO_BOARDINFO
32454 ++ bool
32455 ++ default y
32457 + config SWCONFIG
32458 + tristate "Switch configuration API"
32459 + ---help---
32460 +--- a/drivers/net/phy/Makefile
32461 ++++ b/drivers/net/phy/Makefile
32462 +@@ -2,6 +2,8 @@
32464 + libphy-objs := phy.o phy_device.o mdio_bus.o
32466 ++obj-$(CONFIG_MDIO_BOARDINFO) += mdio-boardinfo.o
32468 + obj-$(CONFIG_PHYLIB) += libphy.o
32469 + obj-$(CONFIG_SWCONFIG) += swconfig.o
32470 + obj-$(CONFIG_MARVELL_PHY) += marvell.o
32471 +--- /dev/null
32472 ++++ b/drivers/net/phy/mdio-boardinfo.c
32473 +@@ -0,0 +1,58 @@
32474 ++/*
32475 ++ * mdio-boardinfo.c - collect pre-declarations of PHY devices
32476 ++ *
32477 ++ * This program is free software; you can redistribute it and/or modify it
32478 ++ * under the terms of the GNU General Public License as published by the
32479 ++ * Free Software Foundation; either version 2 of the License, or (at your
32480 ++ * option) any later version.
32481 ++ *
32482 ++ */
32484 ++#include <linux/kernel.h>
32485 ++#include <linux/phy.h>
32486 ++#include <linux/slab.h>
32487 ++#include <linux/export.h>
32488 ++#include <linux/mutex.h>
32489 ++#include <linux/phy.h>
32491 ++#include "mdio-boardinfo.h"
32493 ++/*
32494 ++ * These symbols are exported ONLY FOR the mdio_bus component.
32495 ++ * No other users will be supported.
32496 ++ */
32498 ++LIST_HEAD(__mdio_board_list);
32499 ++EXPORT_SYMBOL_GPL(__mdio_board_list);
32501 ++DEFINE_MUTEX(__mdio_board_lock);
32502 ++EXPORT_SYMBOL_GPL(__mdio_board_lock);
32504 ++/**
32505 ++ * mdio_register_board_info - register PHY devices for a given board
32506 ++ * @info: array of chip descriptors
32507 ++ * @n: how many descriptors are provided
32508 ++ * Context: can sleep
32509 ++ *
32510 ++ * The board info passed can safely be __initdata ... but be careful of
32511 ++ * any embedded pointers (platform_data, etc), they're copied as-is.
32512 ++ */
32513 ++int __init
32514 ++mdiobus_register_board_info(struct mdio_board_info const *info, unsigned n)
32516 ++ struct mdio_board_entry *be;
32517 ++ int i;
32519 ++ be = kzalloc(n * sizeof(*be), GFP_KERNEL);
32520 ++ if (!be)
32521 ++ return -ENOMEM;
32523 ++ for (i = 0; i < n; i++, be++, info++) {
32524 ++ memcpy(&be->board_info, info, sizeof(*info));
32525 ++ mutex_lock(&__mdio_board_lock);
32526 ++ list_add_tail(&be->list, &__mdio_board_list);
32527 ++ mutex_unlock(&__mdio_board_lock);
32528 ++ }
32530 ++ return 0;
32532 +--- /dev/null
32533 ++++ b/drivers/net/phy/mdio-boardinfo.h
32534 +@@ -0,0 +1,22 @@
32535 ++/*
32536 ++ * mdio-boardinfo.h - boardinfo interface internal to the mdio_bus component
32537 ++ *
32538 ++ * This program is free software; you can redistribute it and/or modify it
32539 ++ * under the terms of the GNU General Public License as published by the
32540 ++ * Free Software Foundation; either version 2 of the License, or (at your
32541 ++ * option) any later version.
32542 ++ *
32543 ++ */
32545 ++#include <linux/mutex.h>
32547 ++struct mdio_board_entry {
32548 ++ struct list_head list;
32549 ++ struct mdio_board_info board_info;
32550 ++};
32552 ++/* __mdio_board_lock protects __mdio_board_list
32553 ++ * only mdio_bus components are allowed to use these symbols.
32554 ++ */
32555 ++extern struct mutex __mdio_board_lock;
32556 ++extern struct list_head __mdio_board_list;
32557 +--- a/drivers/net/phy/mdio_bus.c
32558 ++++ b/drivers/net/phy/mdio_bus.c
32559 +@@ -38,6 +38,8 @@
32561 + #include <asm/irq.h>
32563 ++#include "mdio-boardinfo.h"
32565 + /**
32566 + * mdiobus_alloc_size - allocate a mii_bus structure
32567 + * @size: extra amount of memory to allocate for private storage.
32568 +@@ -335,15 +337,34 @@ void mdiobus_free(struct mii_bus *bus)
32570 + EXPORT_SYMBOL(mdiobus_free);
32572 ++static void mdiobus_setup_phydev_from_boardinfo(struct mii_bus *bus,
32573 ++ struct phy_device *phydev,
32574 ++ struct mdio_board_info *bi)
32576 ++ if (strcmp(bus->id, bi->bus_id) ||
32577 ++ bi->phy_addr != phydev->addr)
32578 ++ return;
32580 ++ phydev->dev.platform_data = (void *) bi->platform_data;
32584 + struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
32586 + struct phy_device *phydev;
32587 ++ struct mdio_board_entry *be;
32588 + int err;
32590 + phydev = get_phy_device(bus, addr, false);
32591 + if (IS_ERR(phydev) || phydev == NULL)
32592 + return phydev;
32594 ++ mutex_lock(&__mdio_board_lock);
32595 ++ list_for_each_entry(be, &__mdio_board_list, list)
32596 ++ mdiobus_setup_phydev_from_boardinfo(bus, phydev,
32597 ++ &be->board_info);
32598 ++ mutex_unlock(&__mdio_board_lock);
32600 + /*
32601 + * For DT, see if the auto-probed phy has a correspoding child
32602 + * in the bus node, and set the of_node pointer in this case.
32603 +--- a/include/linux/phy.h
32604 ++++ b/include/linux/phy.h
32605 +@@ -740,4 +740,22 @@ int __init mdio_bus_init(void);
32606 + void mdio_bus_exit(void);
32608 + extern struct bus_type mdio_bus_type;
32610 ++struct mdio_board_info {
32611 ++ const char *bus_id;
32612 ++ int phy_addr;
32614 ++ const void *platform_data;
32615 ++};
32617 ++#ifdef CONFIG_MDIO_BOARDINFO
32618 ++int mdiobus_register_board_info(const struct mdio_board_info *info, unsigned n);
32619 ++#else
32620 ++static inline int
32621 ++mdiobus_register_board_info(const struct mdio_board_info *info, unsigned n)
32623 ++ return 0;
32625 ++#endif
32627 + #endif /* __PHY_H */
32628 diff --git a/target/linux/generic/patches-3.16/720-phy_adm6996.patch b/target/linux/generic/patches-3.16/720-phy_adm6996.patch
32629 new file mode 100644
32630 index 000000000000..65b206da3e82
32631 --- /dev/null
32632 +++ b/target/linux/generic/patches-3.16/720-phy_adm6996.patch
32633 @@ -0,0 +1,26 @@
32634 +--- a/drivers/net/phy/Kconfig
32635 ++++ b/drivers/net/phy/Kconfig
32636 +@@ -120,6 +120,13 @@ config MICREL_PHY
32637 + ---help---
32638 + Supports the KSZ9021, VSC8201, KS8001 PHYs.
32640 ++config ADM6996_PHY
32641 ++ tristate "Driver for ADM6996 switches"
32642 ++ select SWCONFIG
32643 ++ ---help---
32644 ++ Currently supports the ADM6996FC and ADM6996M switches.
32645 ++ Support for FC is very limited.
32647 + config FIXED_PHY
32648 + bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
32649 + depends on PHYLIB=y
32650 +--- a/drivers/net/phy/Makefile
32651 ++++ b/drivers/net/phy/Makefile
32652 +@@ -17,6 +17,7 @@ obj-$(CONFIG_BROADCOM_PHY) += broadcom.o
32653 + obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o
32654 + obj-$(CONFIG_BCM87XX_PHY) += bcm87xx.o
32655 + obj-$(CONFIG_ICPLUS_PHY) += icplus.o
32656 ++obj-$(CONFIG_ADM6996_PHY) += adm6996.o
32657 + obj-$(CONFIG_REALTEK_PHY) += realtek.o
32658 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
32659 + obj-$(CONFIG_FIXED_PHY) += fixed.o
32660 diff --git a/target/linux/generic/patches-3.16/721-phy_packets.patch b/target/linux/generic/patches-3.16/721-phy_packets.patch
32661 new file mode 100644
32662 index 000000000000..3cedbfce634d
32663 --- /dev/null
32664 +++ b/target/linux/generic/patches-3.16/721-phy_packets.patch
32665 @@ -0,0 +1,172 @@
32666 +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
32667 +index 8d0b07256c76..ad2a6c46b30e 100644
32668 +--- a/include/linux/netdevice.h
32669 ++++ b/include/linux/netdevice.h
32670 +@@ -1204,6 +1204,7 @@ enum netdev_priv_flags {
32671 + IFF_SUPP_NOFCS = 1<<19,
32672 + IFF_LIVE_ADDR_CHANGE = 1<<20,
32673 + IFF_MACVLAN = 1<<21,
32674 ++ IFF_NO_IP_ALIGN = 1<<22,
32675 + };
32677 + #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
32678 +@@ -1228,6 +1229,7 @@ enum netdev_priv_flags {
32679 + #define IFF_SUPP_NOFCS IFF_SUPP_NOFCS
32680 + #define IFF_LIVE_ADDR_CHANGE IFF_LIVE_ADDR_CHANGE
32681 + #define IFF_MACVLAN IFF_MACVLAN
32682 ++#define IFF_NO_IP_ALIGN IFF_NO_IP_ALIGN
32684 + /*
32685 + * The DEVICE structure.
32686 +@@ -1330,6 +1332,11 @@ struct net_device {
32687 + const struct ethtool_ops *ethtool_ops;
32688 + const struct forwarding_accel_ops *fwd_ops;
32690 ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE
32691 ++ void (*eth_mangle_rx)(struct net_device *dev, struct sk_buff *skb);
32692 ++ struct sk_buff *(*eth_mangle_tx)(struct net_device *dev, struct sk_buff *skb);
32693 ++#endif
32695 + /* Hardware header description */
32696 + const struct header_ops *header_ops;
32698 +@@ -1402,6 +1409,9 @@ struct net_device {
32699 + void *ax25_ptr; /* AX.25 specific data */
32700 + struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
32701 + assign before registering */
32702 ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE
32703 ++ void *phy_ptr; /* PHY device specific data */
32704 ++#endif
32706 + /*
32707 + * Cache lines mostly used on receive path (including eth_type_trans())
32708 +diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
32709 +index 262113c4677c..36cf9ea166e8 100644
32710 +--- a/include/linux/skbuff.h
32711 ++++ b/include/linux/skbuff.h
32712 +@@ -1941,6 +1941,10 @@ static inline int pskb_trim(struct sk_buff *skb, unsigned int len)
32713 + return (len < skb->len) ? __pskb_trim(skb, len) : 0;
32716 ++extern struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev,
32717 ++ unsigned int length, gfp_t gfp);
32720 + /**
32721 + * pskb_trim_unique - remove end from a paged unique (not cloned) buffer
32722 + * @skb: buffer to alter
32723 +@@ -2067,16 +2071,6 @@ static inline struct sk_buff *dev_alloc_skb(unsigned int length)
32727 +-static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev,
32728 +- unsigned int length, gfp_t gfp)
32730 +- struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp);
32732 +- if (NET_IP_ALIGN && skb)
32733 +- skb_reserve(skb, NET_IP_ALIGN);
32734 +- return skb;
32737 + static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
32738 + unsigned int length)
32740 +diff --git a/net/Kconfig b/net/Kconfig
32741 +index d92afe4204d9..4c628dcd0bdb 100644
32742 +--- a/net/Kconfig
32743 ++++ b/net/Kconfig
32744 +@@ -24,6 +24,12 @@ menuconfig NET
32746 + if NET
32748 ++config ETHERNET_PACKET_MANGLE
32749 ++ bool
32750 ++ help
32751 ++ This option can be selected by phy drivers that need to mangle
32752 ++ packets going in or out of an ethernet device.
32754 + config WANT_COMPAT_NETLINK_MESSAGES
32755 + bool
32756 + help
32757 +diff --git a/net/core/dev.c b/net/core/dev.c
32758 +index 367a586d0c8a..548140967ad1 100644
32759 +--- a/net/core/dev.c
32760 ++++ b/net/core/dev.c
32761 +@@ -2654,10 +2654,20 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
32762 + if (!list_empty(&ptype_all))
32763 + dev_queue_xmit_nit(skb, dev);
32765 +- skb_len = skb->len;
32766 +- trace_net_dev_start_xmit(skb, dev);
32767 +- rc = ops->ndo_start_xmit(skb, dev);
32768 +- trace_net_dev_xmit(skb, rc, dev, skb_len);
32769 ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE
32770 ++ if (!dev->eth_mangle_tx ||
32771 ++ (skb = dev->eth_mangle_tx(dev, skb)) != NULL)
32772 ++#else
32773 ++ if (1)
32774 ++#endif
32775 ++ {
32776 ++ skb_len = skb->len;
32777 ++ trace_net_dev_start_xmit(skb, dev);
32778 ++ rc = ops->ndo_start_xmit(skb, dev);
32779 ++ trace_net_dev_xmit(skb, rc, dev, skb_len);
32780 ++ } else {
32781 ++ rc = NETDEV_TX_OK;
32782 ++ }
32783 + if (rc == NETDEV_TX_OK)
32784 + txq_trans_update(txq);
32785 + return rc;
32786 +diff --git a/net/core/skbuff.c b/net/core/skbuff.c
32787 +index 58ff88edbefd..44a22c4734b4 100644
32788 +--- a/net/core/skbuff.c
32789 ++++ b/net/core/skbuff.c
32790 +@@ -62,6 +62,7 @@
32791 + #include <linux/scatterlist.h>
32792 + #include <linux/errqueue.h>
32793 + #include <linux/prefetch.h>
32794 ++#include <linux/if.h>
32796 + #include <net/protocol.h>
32797 + #include <net/dst.h>
32798 +@@ -439,6 +440,22 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
32800 + EXPORT_SYMBOL(__netdev_alloc_skb);
32802 ++struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev,
32803 ++ unsigned int length, gfp_t gfp)
32805 ++ struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp);
32807 ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE
32808 ++ if (dev && (dev->priv_flags & IFF_NO_IP_ALIGN))
32809 ++ return skb;
32810 ++#endif
32812 ++ if (NET_IP_ALIGN && skb)
32813 ++ skb_reserve(skb, NET_IP_ALIGN);
32814 ++ return skb;
32816 ++EXPORT_SYMBOL(__netdev_alloc_skb_ip_align);
32818 + void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
32819 + int size, unsigned int truesize)
32821 +diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
32822 +index 5dc638cad2e1..f4fd12475055 100644
32823 +--- a/net/ethernet/eth.c
32824 ++++ b/net/ethernet/eth.c
32825 +@@ -161,6 +161,12 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
32826 + const struct ethhdr *eth;
32828 + skb->dev = dev;
32830 ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE
32831 ++ if (dev->eth_mangle_rx)
32832 ++ dev->eth_mangle_rx(dev, skb);
32833 ++#endif
32835 + skb_reset_mac_header(skb);
32836 + skb_pull_inline(skb, ETH_HLEN);
32837 + eth = eth_hdr(skb);
32838 diff --git a/target/linux/generic/patches-3.16/722-phy_mvswitch.patch b/target/linux/generic/patches-3.16/722-phy_mvswitch.patch
32839 new file mode 100644
32840 index 000000000000..d7c3d759a851
32841 --- /dev/null
32842 +++ b/target/linux/generic/patches-3.16/722-phy_mvswitch.patch
32843 @@ -0,0 +1,23 @@
32844 +--- a/drivers/net/phy/Kconfig
32845 ++++ b/drivers/net/phy/Kconfig
32846 +@@ -127,6 +127,10 @@ config ADM6996_PHY
32847 + Currently supports the ADM6996FC and ADM6996M switches.
32848 + Support for FC is very limited.
32850 ++config MVSWITCH_PHY
32851 ++ tristate "Driver for Marvell 88E6060 switches"
32852 ++ select ETHERNET_PACKET_MANGLE
32854 + config FIXED_PHY
32855 + bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
32856 + depends on PHYLIB=y
32857 +--- a/drivers/net/phy/Makefile
32858 ++++ b/drivers/net/phy/Makefile
32859 +@@ -18,6 +18,7 @@ obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o
32860 + obj-$(CONFIG_BCM87XX_PHY) += bcm87xx.o
32861 + obj-$(CONFIG_ICPLUS_PHY) += icplus.o
32862 + obj-$(CONFIG_ADM6996_PHY) += adm6996.o
32863 ++obj-$(CONFIG_MVSWITCH_PHY) += mvswitch.o
32864 + obj-$(CONFIG_REALTEK_PHY) += realtek.o
32865 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
32866 + obj-$(CONFIG_FIXED_PHY) += fixed.o
32867 diff --git a/target/linux/generic/patches-3.16/723-phy_ip175c.patch b/target/linux/generic/patches-3.16/723-phy_ip175c.patch
32868 new file mode 100644
32869 index 000000000000..5e3f6b46d591
32870 --- /dev/null
32871 +++ b/target/linux/generic/patches-3.16/723-phy_ip175c.patch
32872 @@ -0,0 +1,23 @@
32873 +--- a/drivers/net/phy/Kconfig
32874 ++++ b/drivers/net/phy/Kconfig
32875 +@@ -131,6 +131,10 @@ config MVSWITCH_PHY
32876 + tristate "Driver for Marvell 88E6060 switches"
32877 + select ETHERNET_PACKET_MANGLE
32879 ++config IP17XX_PHY
32880 ++ tristate "Driver for IC+ IP17xx switches"
32881 ++ select SWCONFIG
32883 + config FIXED_PHY
32884 + bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
32885 + depends on PHYLIB=y
32886 +--- a/drivers/net/phy/Makefile
32887 ++++ b/drivers/net/phy/Makefile
32888 +@@ -19,6 +19,7 @@ obj-$(CONFIG_BCM87XX_PHY) += bcm87xx.o
32889 + obj-$(CONFIG_ICPLUS_PHY) += icplus.o
32890 + obj-$(CONFIG_ADM6996_PHY) += adm6996.o
32891 + obj-$(CONFIG_MVSWITCH_PHY) += mvswitch.o
32892 ++obj-$(CONFIG_IP17XX_PHY) += ip17xx.o
32893 + obj-$(CONFIG_REALTEK_PHY) += realtek.o
32894 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
32895 + obj-$(CONFIG_FIXED_PHY) += fixed.o
32896 diff --git a/target/linux/generic/patches-3.16/724-phy_ar8216.patch b/target/linux/generic/patches-3.16/724-phy_ar8216.patch
32897 new file mode 100644
32898 index 000000000000..d3b238efcecc
32899 --- /dev/null
32900 +++ b/target/linux/generic/patches-3.16/724-phy_ar8216.patch
32901 @@ -0,0 +1,24 @@
32902 +--- a/drivers/net/phy/Kconfig
32903 ++++ b/drivers/net/phy/Kconfig
32904 +@@ -135,6 +135,11 @@ config IP17XX_PHY
32905 + tristate "Driver for IC+ IP17xx switches"
32906 + select SWCONFIG
32908 ++config AR8216_PHY
32909 ++ tristate "Driver for Atheros AR8216 switches"
32910 ++ select ETHERNET_PACKET_MANGLE
32911 ++ select SWCONFIG
32913 + config FIXED_PHY
32914 + bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
32915 + depends on PHYLIB=y
32916 +--- a/drivers/net/phy/Makefile
32917 ++++ b/drivers/net/phy/Makefile
32918 +@@ -21,6 +21,7 @@ obj-$(CONFIG_ADM6996_PHY) += adm6996.o
32919 + obj-$(CONFIG_MVSWITCH_PHY) += mvswitch.o
32920 + obj-$(CONFIG_IP17XX_PHY) += ip17xx.o
32921 + obj-$(CONFIG_REALTEK_PHY) += realtek.o
32922 ++obj-$(CONFIG_AR8216_PHY) += ar8216.o
32923 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
32924 + obj-$(CONFIG_FIXED_PHY) += fixed.o
32925 + obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
32926 diff --git a/target/linux/generic/patches-3.16/725-phy_rtl8306.patch b/target/linux/generic/patches-3.16/725-phy_rtl8306.patch
32927 new file mode 100644
32928 index 000000000000..56899a70ba38
32929 --- /dev/null
32930 +++ b/target/linux/generic/patches-3.16/725-phy_rtl8306.patch
32931 @@ -0,0 +1,23 @@
32932 +--- a/drivers/net/phy/Kconfig
32933 ++++ b/drivers/net/phy/Kconfig
32934 +@@ -140,6 +140,10 @@ config AR8216_PHY
32935 + select ETHERNET_PACKET_MANGLE
32936 + select SWCONFIG
32938 ++config RTL8306_PHY
32939 ++ tristate "Driver for Realtek RTL8306S switches"
32940 ++ select SWCONFIG
32942 + config FIXED_PHY
32943 + bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
32944 + depends on PHYLIB=y
32945 +--- a/drivers/net/phy/Makefile
32946 ++++ b/drivers/net/phy/Makefile
32947 +@@ -22,6 +22,7 @@ obj-$(CONFIG_MVSWITCH_PHY) += mvswitch.o
32948 + obj-$(CONFIG_IP17XX_PHY) += ip17xx.o
32949 + obj-$(CONFIG_REALTEK_PHY) += realtek.o
32950 + obj-$(CONFIG_AR8216_PHY) += ar8216.o
32951 ++obj-$(CONFIG_RTL8306_PHY) += rtl8306.o
32952 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
32953 + obj-$(CONFIG_FIXED_PHY) += fixed.o
32954 + obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
32955 diff --git a/target/linux/generic/patches-3.16/726-phy_rtl8366.patch b/target/linux/generic/patches-3.16/726-phy_rtl8366.patch
32956 new file mode 100644
32957 index 000000000000..52ef6108dcb2
32958 --- /dev/null
32959 +++ b/target/linux/generic/patches-3.16/726-phy_rtl8366.patch
32960 @@ -0,0 +1,45 @@
32961 +--- a/drivers/net/phy/Kconfig
32962 ++++ b/drivers/net/phy/Kconfig
32963 +@@ -231,6 +231,30 @@ config MDIO_BUS_MUX_MMIOREG
32965 + Currently, only 8-bit registers are supported.
32967 ++config RTL8366_SMI
32968 ++ tristate "Driver for the RTL8366 SMI interface"
32969 ++ depends on GPIOLIB
32970 ++ ---help---
32971 ++ This module implements the SMI interface protocol which is used
32972 ++ by some RTL8366 ethernet switch devices via the generic GPIO API.
32974 ++if RTL8366_SMI
32976 ++config RTL8366_SMI_DEBUG_FS
32977 ++ bool "RTL8366 SMI interface debugfs support"
32978 ++ depends on DEBUG_FS
32979 ++ default n
32981 ++config RTL8366S_PHY
32982 ++ tristate "Driver for the Realtek RTL8366S switch"
32983 ++ select SWCONFIG
32985 ++config RTL8366RB_PHY
32986 ++ tristate "Driver for the Realtek RTL8366RB switch"
32987 ++ select SWCONFIG
32989 ++endif # RTL8366_SMI
32991 + endif # PHYLIB
32993 + config MICREL_KS8995MA
32994 +--- a/drivers/net/phy/Makefile
32995 ++++ b/drivers/net/phy/Makefile
32996 +@@ -23,6 +23,9 @@ obj-$(CONFIG_IP17XX_PHY) += ip17xx.o
32997 + obj-$(CONFIG_REALTEK_PHY) += realtek.o
32998 + obj-$(CONFIG_AR8216_PHY) += ar8216.o
32999 + obj-$(CONFIG_RTL8306_PHY) += rtl8306.o
33000 ++obj-$(CONFIG_RTL8366_SMI) += rtl8366_smi.o
33001 ++obj-$(CONFIG_RTL8366S_PHY) += rtl8366s.o
33002 ++obj-$(CONFIG_RTL8366RB_PHY) += rtl8366rb.o
33003 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
33004 + obj-$(CONFIG_FIXED_PHY) += fixed.o
33005 + obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
33006 diff --git a/target/linux/generic/patches-3.16/727-phy-rtl8367.patch b/target/linux/generic/patches-3.16/727-phy-rtl8367.patch
33007 new file mode 100644
33008 index 000000000000..dfae770b4813
33009 --- /dev/null
33010 +++ b/target/linux/generic/patches-3.16/727-phy-rtl8367.patch
33011 @@ -0,0 +1,23 @@
33012 +--- a/drivers/net/phy/Kconfig
33013 ++++ b/drivers/net/phy/Kconfig
33014 +@@ -253,6 +253,10 @@ config RTL8366RB_PHY
33015 + tristate "Driver for the Realtek RTL8366RB switch"
33016 + select SWCONFIG
33018 ++config RTL8367_PHY
33019 ++ tristate "Driver for the Realtek RTL8367R/M switches"
33020 ++ select SWCONFIG
33022 + endif # RTL8366_SMI
33024 + endif # PHYLIB
33025 +--- a/drivers/net/phy/Makefile
33026 ++++ b/drivers/net/phy/Makefile
33027 +@@ -26,6 +26,7 @@ obj-$(CONFIG_RTL8306_PHY) += rtl8306.o
33028 + obj-$(CONFIG_RTL8366_SMI) += rtl8366_smi.o
33029 + obj-$(CONFIG_RTL8366S_PHY) += rtl8366s.o
33030 + obj-$(CONFIG_RTL8366RB_PHY) += rtl8366rb.o
33031 ++obj-$(CONFIG_RTL8367_PHY) += rtl8367.o
33032 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
33033 + obj-$(CONFIG_FIXED_PHY) += fixed.o
33034 + obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
33035 diff --git a/target/linux/generic/patches-3.16/728-phy-micrel.patch b/target/linux/generic/patches-3.16/728-phy-micrel.patch
33036 new file mode 100644
33037 index 000000000000..baf5a4a7fda8
33038 --- /dev/null
33039 +++ b/target/linux/generic/patches-3.16/728-phy-micrel.patch
33040 @@ -0,0 +1,24 @@
33041 +--- a/drivers/net/phy/Kconfig
33042 ++++ b/drivers/net/phy/Kconfig
33043 +@@ -144,6 +144,11 @@ config RTL8306_PHY
33044 + tristate "Driver for Realtek RTL8306S switches"
33045 + select SWCONFIG
33047 ++config MICREL_PHY
33048 ++ tristate "Drivers for Micrel/Kendin PHYs"
33049 ++ ---help---
33050 ++ Currently has a driver for the KSZ8041
33052 + config FIXED_PHY
33053 + bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
33054 + depends on PHYLIB=y
33055 +--- a/drivers/net/phy/Makefile
33056 ++++ b/drivers/net/phy/Makefile
33057 +@@ -28,6 +28,7 @@ obj-$(CONFIG_RTL8366S_PHY) += rtl8366s.o
33058 + obj-$(CONFIG_RTL8366RB_PHY) += rtl8366rb.o
33059 + obj-$(CONFIG_RTL8367_PHY) += rtl8367.o
33060 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
33061 ++obj-$(CONFIG_MICREL_PHY) += micrel.o
33062 + obj-$(CONFIG_FIXED_PHY) += fixed.o
33063 + obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
33064 + obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o
33065 diff --git a/target/linux/generic/patches-3.16/729-phy-rtl8367b.patch b/target/linux/generic/patches-3.16/729-phy-rtl8367b.patch
33066 new file mode 100644
33067 index 000000000000..d69fc89e470d
33068 --- /dev/null
33069 +++ b/target/linux/generic/patches-3.16/729-phy-rtl8367b.patch
33070 @@ -0,0 +1,23 @@
33071 +--- a/drivers/net/phy/Kconfig
33072 ++++ b/drivers/net/phy/Kconfig
33073 +@@ -262,6 +262,10 @@ config RTL8367_PHY
33074 + tristate "Driver for the Realtek RTL8367R/M switches"
33075 + select SWCONFIG
33077 ++config RTL8367B_PHY
33078 ++ tristate "Driver fot the Realtek RTL8367R-VB switch"
33079 ++ select SWCONFIG
33081 + endif # RTL8366_SMI
33083 + endif # PHYLIB
33084 +--- a/drivers/net/phy/Makefile
33085 ++++ b/drivers/net/phy/Makefile
33086 +@@ -27,6 +27,7 @@ obj-$(CONFIG_RTL8366_SMI) += rtl8366_smi
33087 + obj-$(CONFIG_RTL8366S_PHY) += rtl8366s.o
33088 + obj-$(CONFIG_RTL8366RB_PHY) += rtl8366rb.o
33089 + obj-$(CONFIG_RTL8367_PHY) += rtl8367.o
33090 ++obj-$(CONFIG_RTL8367B_PHY) += rtl8367b.o
33091 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
33092 + obj-$(CONFIG_MICREL_PHY) += micrel.o
33093 + obj-$(CONFIG_FIXED_PHY) += fixed.o
33094 diff --git a/target/linux/generic/patches-3.16/729-phy-tantos.patch b/target/linux/generic/patches-3.16/729-phy-tantos.patch
33095 new file mode 100644
33096 index 000000000000..4a9fe873a7ce
33097 --- /dev/null
33098 +++ b/target/linux/generic/patches-3.16/729-phy-tantos.patch
33099 @@ -0,0 +1,21 @@
33100 +--- a/drivers/net/phy/Kconfig
33101 ++++ b/drivers/net/phy/Kconfig
33102 +@@ -273,3 +273,8 @@ endif # PHYLIB
33103 + config MICREL_KS8995MA
33104 + tristate "Micrel KS8995MA 5-ports 10/100 managed Ethernet switch"
33105 + depends on SPI
33107 ++config PSB6970_PHY
33108 ++ tristate "Lantiq XWAY Tantos (PSB6970) Ethernet switch"
33109 ++ select SWCONFIG
33110 ++ select ETHERNET_PACKET_MANGLE
33111 +--- a/drivers/net/phy/Makefile
33112 ++++ b/drivers/net/phy/Makefile
33113 +@@ -30,6 +30,7 @@ obj-$(CONFIG_RTL8367_PHY) += rtl8367.o
33114 + obj-$(CONFIG_RTL8367B_PHY) += rtl8367b.o
33115 + obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
33116 + obj-$(CONFIG_MICREL_PHY) += micrel.o
33117 ++obj-$(CONFIG_PSB6970_PHY) += psb6970.o
33118 + obj-$(CONFIG_FIXED_PHY) += fixed.o
33119 + obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
33120 + obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o
33121 diff --git a/target/linux/generic/patches-3.16/730-phy_b53.patch b/target/linux/generic/patches-3.16/730-phy_b53.patch
33122 new file mode 100644
33123 index 000000000000..0265e26ff679
33124 --- /dev/null
33125 +++ b/target/linux/generic/patches-3.16/730-phy_b53.patch
33126 @@ -0,0 +1,18 @@
33127 +--- a/drivers/net/phy/Kconfig
33128 ++++ b/drivers/net/phy/Kconfig
33129 +@@ -280,6 +280,8 @@ config RTL8367B_PHY
33131 + endif # RTL8366_SMI
33133 ++source "drivers/net/phy/b53/Kconfig"
33135 + endif # PHYLIB
33137 + config MICREL_KS8995MA
33138 +--- a/drivers/net/phy/Makefile
33139 ++++ b/drivers/net/phy/Makefile
33140 +@@ -48,3 +48,4 @@ obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += md
33141 + obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o
33142 + obj-$(CONFIG_MDIO_MOXART) += mdio-moxart.o
33143 + obj-$(CONFIG_AMD_XGBE_PHY) += amd-xgbe-phy.o
33144 ++obj-$(CONFIG_B53) += b53/
33145 diff --git a/target/linux/generic/patches-3.16/731-phy_mvswitch_3.10_compilation.patch b/target/linux/generic/patches-3.16/731-phy_mvswitch_3.10_compilation.patch
33146 new file mode 100644
33147 index 000000000000..2053bd2f8ef2
33148 --- /dev/null
33149 +++ b/target/linux/generic/patches-3.16/731-phy_mvswitch_3.10_compilation.patch
33150 @@ -0,0 +1,35 @@
33151 +From e6a5abb9a02be0bceb4782d9f736bfb4ae217505 Mon Sep 17 00:00:00 2001
33152 +From: Jonas Gorski <jogo@openwrt.org>
33153 +Date: Sat, 21 Sep 2013 13:56:51 +0200
33154 +Subject: [PATCH] phy: mvswitch: fix 3.10 compilation
33156 +Update to API changes in 3.10.
33158 +Signed-off-by: Jonas Gorsi <jogo@openwrt.org>
33159 +---
33160 + target/linux/generic/files/drivers/net/phy/mvswitch.c | 6 +++---
33161 + 1 file changed, 3 insertions(+), 3 deletions(-)
33163 +--- a/drivers/net/phy/mvswitch.c
33164 ++++ b/drivers/net/phy/mvswitch.c
33165 +@@ -173,7 +173,7 @@ mvswitch_mangle_rx(struct net_device *de
33166 + if (vlan == -1)
33167 + return;
33169 +- __vlan_hwaccel_put_tag(skb, vlan);
33170 ++ __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan);
33174 +@@ -307,9 +307,9 @@ mvswitch_config_init(struct phy_device *
33176 + #ifdef HEADER_MODE
33177 + dev->priv_flags |= IFF_NO_IP_ALIGN;
33178 +- dev->features |= NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX;
33179 ++ dev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX;
33180 + #else
33181 +- dev->features |= NETIF_F_HW_VLAN_RX;
33182 ++ dev->features |= NETIF_F_HW_VLAN_CTAG_RX;
33183 + #endif
33185 + return 0;
33186 diff --git a/target/linux/generic/patches-3.16/750-hostap_txpower.patch b/target/linux/generic/patches-3.16/750-hostap_txpower.patch
33187 new file mode 100644
33188 index 000000000000..768c80f73bab
33189 --- /dev/null
33190 +++ b/target/linux/generic/patches-3.16/750-hostap_txpower.patch
33191 @@ -0,0 +1,154 @@
33192 +--- a/drivers/net/wireless/hostap/hostap_ap.c
33193 ++++ b/drivers/net/wireless/hostap/hostap_ap.c
33194 +@@ -2403,13 +2403,13 @@ int prism2_ap_get_sta_qual(local_info_t
33195 + addr[count].sa_family = ARPHRD_ETHER;
33196 + memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
33197 + if (sta->last_rx_silence == 0)
33198 +- qual[count].qual = sta->last_rx_signal < 27 ?
33199 +- 0 : (sta->last_rx_signal - 27) * 92 / 127;
33200 ++ qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
33201 ++ 0 : (sta->last_rx_signal - 156) * 92 / 64;
33202 + else
33203 +- qual[count].qual = sta->last_rx_signal -
33204 +- sta->last_rx_silence - 35;
33205 +- qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
33206 +- qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
33207 ++ qual[count].qual = (sta->last_rx_signal -
33208 ++ sta->last_rx_silence) * 92 / 64;
33209 ++ qual[count].level = sta->last_rx_signal;
33210 ++ qual[count].noise = sta->last_rx_silence;
33211 + qual[count].updated = sta->last_rx_updated;
33213 + sta->last_rx_updated = IW_QUAL_DBM;
33214 +@@ -2475,13 +2475,13 @@ int prism2_ap_translate_scan(struct net_
33215 + memset(&iwe, 0, sizeof(iwe));
33216 + iwe.cmd = IWEVQUAL;
33217 + if (sta->last_rx_silence == 0)
33218 +- iwe.u.qual.qual = sta->last_rx_signal < 27 ?
33219 +- 0 : (sta->last_rx_signal - 27) * 92 / 127;
33220 ++ iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
33221 ++ 0 : (sta->last_rx_signal - 156) * 92 / 64;
33222 + else
33223 +- iwe.u.qual.qual = sta->last_rx_signal -
33224 +- sta->last_rx_silence - 35;
33225 +- iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
33226 +- iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
33227 ++ iwe.u.qual.qual = (sta->last_rx_signal -
33228 ++ sta->last_rx_silence) * 92 / 64;
33229 ++ iwe.u.qual.level = sta->last_rx_signal;
33230 ++ iwe.u.qual.noise = sta->last_rx_silence;
33231 + iwe.u.qual.updated = sta->last_rx_updated;
33232 + iwe.len = IW_EV_QUAL_LEN;
33233 + current_ev = iwe_stream_add_event(info, current_ev, end_buf,
33234 +--- a/drivers/net/wireless/hostap/hostap_config.h
33235 ++++ b/drivers/net/wireless/hostap/hostap_config.h
33236 +@@ -45,4 +45,9 @@
33237 + */
33238 + /* #define PRISM2_NO_STATION_MODES */
33240 ++/* Enable TX power Setting functions
33241 ++ * (min att = -128 , max att = 127)
33242 ++ */
33243 ++#define RAW_TXPOWER_SETTING
33245 + #endif /* HOSTAP_CONFIG_H */
33246 +--- a/drivers/net/wireless/hostap/hostap.h
33247 ++++ b/drivers/net/wireless/hostap/hostap.h
33248 +@@ -90,6 +90,7 @@ extern const struct iw_handler_def hosta
33249 + extern const struct ethtool_ops prism2_ethtool_ops;
33251 + int hostap_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
33252 ++int hostap_restore_power(struct net_device *dev);
33255 + #endif /* HOSTAP_H */
33256 +--- a/drivers/net/wireless/hostap/hostap_hw.c
33257 ++++ b/drivers/net/wireless/hostap/hostap_hw.c
33258 +@@ -928,6 +928,7 @@ static int hfa384x_set_rid(struct net_de
33259 + prism2_hw_reset(dev);
33262 ++ hostap_restore_power(dev);
33263 + return res;
33266 +--- a/drivers/net/wireless/hostap/hostap_info.c
33267 ++++ b/drivers/net/wireless/hostap/hostap_info.c
33268 +@@ -435,6 +435,11 @@ static void handle_info_queue_linkstatus
33271 + /* Get BSSID if we have a valid AP address */
33273 ++ if ( val == HFA384X_LINKSTATUS_CONNECTED ||
33274 ++ val == HFA384X_LINKSTATUS_DISCONNECTED )
33275 ++ hostap_restore_power(local->dev);
33277 + if (connected) {
33278 + netif_carrier_on(local->dev);
33279 + netif_carrier_on(local->ddev);
33280 +--- a/drivers/net/wireless/hostap/hostap_ioctl.c
33281 ++++ b/drivers/net/wireless/hostap/hostap_ioctl.c
33282 +@@ -1479,23 +1479,20 @@ static int prism2_txpower_hfa386x_to_dBm
33283 + val = 255;
33285 + tmp = val;
33286 +- tmp >>= 2;
33288 +- return -12 - tmp;
33289 ++ return tmp;
33292 + static u16 prism2_txpower_dBm_to_hfa386x(int val)
33294 + signed char tmp;
33296 +- if (val > 20)
33297 +- return 128;
33298 +- else if (val < -43)
33299 ++ if (val > 127)
33300 + return 127;
33301 ++ else if (val < -128)
33302 ++ return 128;
33304 + tmp = val;
33305 +- tmp = -12 - tmp;
33306 +- tmp <<= 2;
33308 + return (unsigned char) tmp;
33310 +@@ -4052,3 +4049,35 @@ int hostap_ioctl(struct net_device *dev,
33312 + return ret;
33315 ++/* BUG FIX: Restore power setting value when lost due to F/W bug */
33317 ++int hostap_restore_power(struct net_device *dev)
33319 ++ struct hostap_interface *iface = netdev_priv(dev);
33320 ++ local_info_t *local = iface->local;
33322 ++ u16 val;
33323 ++ int ret = 0;
33325 ++ if (local->txpower_type == PRISM2_TXPOWER_OFF) {
33326 ++ val = 0xff; /* use all standby and sleep modes */
33327 ++ ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
33328 ++ HFA386X_CR_A_D_TEST_MODES2,
33329 ++ &val, NULL);
33330 ++ }
33332 ++#ifdef RAW_TXPOWER_SETTING
33333 ++ if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
33334 ++ val = HFA384X_TEST_CFG_BIT_ALC;
33335 ++ local->func->cmd(dev, HFA384X_CMDCODE_TEST |
33336 ++ (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
33337 ++ val = prism2_txpower_dBm_to_hfa386x(local->txpower);
33338 ++ ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
33339 ++ HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
33340 ++ }
33341 ++#endif /* RAW_TXPOWER_SETTING */
33342 ++ return (ret ? -EOPNOTSUPP : 0);
33345 ++EXPORT_SYMBOL(hostap_restore_power);
33346 diff --git a/target/linux/generic/patches-3.16/773-bgmac-add-srab-switch.patch b/target/linux/generic/patches-3.16/773-bgmac-add-srab-switch.patch
33347 new file mode 100644
33348 index 000000000000..fe52ccc33e38
33349 --- /dev/null
33350 +++ b/target/linux/generic/patches-3.16/773-bgmac-add-srab-switch.patch
33351 @@ -0,0 +1,72 @@
33352 +Register switch connected to srab
33354 +Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
33356 +--- a/drivers/net/ethernet/broadcom/bgmac.c
33357 ++++ b/drivers/net/ethernet/broadcom/bgmac.c
33358 +@@ -16,6 +16,7 @@
33359 + #include <linux/phy.h>
33360 + #include <linux/interrupt.h>
33361 + #include <linux/dma-mapping.h>
33362 ++#include <linux/platform_data/b53.h>
33363 + #include <bcm47xx_nvram.h>
33365 + static const struct bcma_device_id bgmac_bcma_tbl[] = {
33366 +@@ -1405,6 +1406,17 @@ static void bgmac_mii_unregister(struct
33367 + mdiobus_free(mii_bus);
33370 ++static struct b53_platform_data bgmac_b53_pdata = {
33371 ++};
33373 ++static struct platform_device bgmac_b53_dev = {
33374 ++ .name = "b53-srab-switch",
33375 ++ .id = -1,
33376 ++ .dev = {
33377 ++ .platform_data = &bgmac_b53_pdata,
33378 ++ },
33379 ++};
33381 + /**************************************************
33382 + * BCMA bus ops
33383 + **************************************************/
33384 +@@ -1521,6 +1533,16 @@ static int bgmac_probe(struct bcma_devic
33385 + goto err_dma_free;
33388 ++ if (core->id.id != BCMA_CHIP_ID_BCM4707 &&
33389 ++ core->id.id != BCMA_CHIP_ID_BCM53018 &&
33390 ++ !bgmac_b53_pdata.regs) {
33391 ++ bgmac_b53_pdata.regs = ioremap_nocache(0x18007000, 0x1000);
33393 ++ err = platform_device_register(&bgmac_b53_dev);
33394 ++ if (!err)
33395 ++ bgmac->b53_device = &bgmac_b53_dev;
33396 ++ }
33398 + err = register_netdev(bgmac->net_dev);
33399 + if (err) {
33400 + bgmac_err(bgmac, "Cannot register net device\n");
33401 +@@ -1549,6 +1571,10 @@ static void bgmac_remove(struct bcma_dev
33403 + struct bgmac *bgmac = bcma_get_drvdata(core);
33405 ++ if (bgmac->b53_device)
33406 ++ platform_device_unregister(&bgmac_b53_dev);
33407 ++ bgmac->b53_device = NULL;
33409 + netif_napi_del(&bgmac->napi);
33410 + unregister_netdev(bgmac->net_dev);
33411 + bgmac_mii_unregister(bgmac);
33412 +--- a/drivers/net/ethernet/broadcom/bgmac.h
33413 ++++ b/drivers/net/ethernet/broadcom/bgmac.h
33414 +@@ -457,6 +457,9 @@ struct bgmac {
33415 + bool has_robosw;
33417 + bool loopback;
33419 ++ /* platform device for associated switch */
33420 ++ struct platform_device *b53_device;
33421 + };
33423 + static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset)
33424 diff --git a/target/linux/generic/patches-3.16/775-bgmac-check-length-of-received-frame.patch b/target/linux/generic/patches-3.16/775-bgmac-check-length-of-received-frame.patch
33425 new file mode 100644
33426 index 000000000000..c3d63b65fa45
33427 --- /dev/null
33428 +++ b/target/linux/generic/patches-3.16/775-bgmac-check-length-of-received-frame.patch
33429 @@ -0,0 +1,39 @@
33430 +From 2d12a9abf3f81de5b51852e3cfcba8cedac82642 Mon Sep 17 00:00:00 2001
33431 +From: Hauke Mehrtens <hauke@hauke-m.de>
33432 +Date: Fri, 6 Dec 2013 01:14:52 +0100
33433 +Subject: [PATCH] bgmac: check length of received frame
33435 +---
33436 + drivers/net/ethernet/broadcom/bgmac.c | 9 ++++++++-
33437 + 1 file changed, 8 insertions(+), 1 deletion(-)
33439 +--- a/drivers/net/ethernet/broadcom/bgmac.c
33440 ++++ b/drivers/net/ethernet/broadcom/bgmac.c
33441 +@@ -363,6 +363,27 @@ static int bgmac_dma_rx_read(struct bgma
33442 + dma_addr_t old_dma_addr = slot->dma_addr;
33443 + int err;
33445 ++ if (len > BGMAC_RX_MAX_FRAME_SIZE) {
33446 ++ struct bgmac_dma_desc *dma_desc = ring->cpu_base + ring->start;
33448 ++ bgmac_err(bgmac, "Hardware reported invalid packet length %d for slot %d!\n", len, ring->start);
33449 ++ bgmac_err(bgmac, "flags: 0x%04X\n", flags);
33450 ++ bgmac_err(bgmac, "ctl0: 0x%08X\tctl1: 0x%08X\n", le32_to_cpu(dma_desc->ctl0), le32_to_cpu(dma_desc->ctl1));
33452 ++ bgmac_err(bgmac, " BGMAC_DMA_RX_CTL: 0x%08X\n", bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL));
33453 ++ bgmac_err(bgmac, " BGMAC_DMA_RX_INDEX: 0x%08X\n", bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX));
33454 ++ bgmac_err(bgmac, "BGMAC_DMA_RX_RINGLO: 0x%08X\n", bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGLO));
33455 ++ bgmac_err(bgmac, "BGMAC_DMA_RX_RINGHI: 0x%08X\n", bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGHI));
33456 ++ bgmac_err(bgmac, "BGMAC_DMA_RX_STATUS: 0x%08X\n", bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_STATUS));
33457 ++ bgmac_err(bgmac, " BGMAC_DMA_RX_ERROR: 0x%08X\n", bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_ERROR));
33459 ++ dma_sync_single_for_device(dma_dev,
33460 ++ slot->dma_addr,
33461 ++ BGMAC_RX_BUF_SIZE,
33462 ++ DMA_FROM_DEVICE);
33463 ++ break;
33464 ++ }
33466 + /* Check for poison and drop or pass the packet */
33467 + if (len == 0xdead && flags == 0xbeef) {
33468 + bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
33469 diff --git a/target/linux/generic/patches-3.16/780-igb-Fix-Null-pointer-dereference-in-igb_reset_q_vect.patch b/target/linux/generic/patches-3.16/780-igb-Fix-Null-pointer-dereference-in-igb_reset_q_vect.patch
33470 new file mode 100644
33471 index 000000000000..3beb9071e44e
33472 --- /dev/null
33473 +++ b/target/linux/generic/patches-3.16/780-igb-Fix-Null-pointer-dereference-in-igb_reset_q_vect.patch
33474 @@ -0,0 +1,40 @@
33475 +From cb06d102327eadcd1bdc480bfd9f8876251d1007 Mon Sep 17 00:00:00 2001
33476 +From: Christoph Paasch <christoph.paasch@uclouvain.be>
33477 +Date: Fri, 21 Mar 2014 03:48:19 -0700
33478 +Subject: [PATCH] igb: Fix Null-pointer dereference in igb_reset_q_vector
33480 +When igb_set_interrupt_capability() calls
33481 +igb_reset_interrupt_capability() (e.g., because CONFIG_PCI_MSI is unset),
33482 +num_q_vectors has been set but no vector has yet been allocated.
33484 +igb_reset_interrupt_capability() will then call igb_reset_q_vector,
33485 +which assumes that the vector is allocated. As this is not the case, we
33486 +are accessing a NULL-pointer.
33488 +This patch fixes it by checking that q_vector is indeed different from
33489 +NULL.
33491 +Fixes: 02ef6e1d0b0023 (igb: Fix queue allocation method to accommodate changing during runtime)
33492 +Cc: Carolyn Wyborny <carolyn.wyborny@intel.com>
33493 +Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
33494 +Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com>
33495 +Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
33496 +---
33497 + drivers/net/ethernet/intel/igb/igb_main.c | 6 ++++++
33498 + 1 file changed, 6 insertions(+)
33500 +--- a/drivers/net/ethernet/intel/igb/igb_main.c
33501 ++++ b/drivers/net/ethernet/intel/igb/igb_main.c
33502 +@@ -1020,6 +1020,12 @@ static void igb_reset_q_vector(struct ig
33503 + if (!q_vector)
33504 + return;
33506 ++ /* Coming from igb_set_interrupt_capability, the vectors are not yet
33507 ++ * allocated. So, q_vector is NULL so we should stop here.
33508 ++ */
33509 ++ if (!q_vector)
33510 ++ return;
33512 + if (q_vector->tx.ring)
33513 + adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL;
33515 diff --git a/target/linux/generic/patches-3.16/810-pci_disable_common_quirks.patch b/target/linux/generic/patches-3.16/810-pci_disable_common_quirks.patch
33516 new file mode 100644
33517 index 000000000000..e4becb38d8a0
33518 --- /dev/null
33519 +++ b/target/linux/generic/patches-3.16/810-pci_disable_common_quirks.patch
33520 @@ -0,0 +1,51 @@
33521 +--- a/drivers/pci/Kconfig
33522 ++++ b/drivers/pci/Kconfig
33523 +@@ -58,6 +58,12 @@ config XEN_PCIDEV_FRONTEND
33524 + The PCI device frontend driver allows the kernel to import arbitrary
33525 + PCI devices from a PCI backend to support PCI driver domains.
33527 ++config PCI_DISABLE_COMMON_QUIRKS
33528 ++ bool "PCI disable common quirks"
33529 ++ depends on PCI
33530 ++ help
33531 ++ If you don't know what to do here, say N.
33533 + config HT_IRQ
33534 + bool "Interrupts on hypertransport devices"
33535 + default y
33536 +--- a/drivers/pci/quirks.c
33537 ++++ b/drivers/pci/quirks.c
33538 +@@ -40,6 +40,7 @@ static void quirk_mmio_always_on(struct
33539 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_ANY_ID, PCI_ANY_ID,
33540 + PCI_CLASS_BRIDGE_HOST, 8, quirk_mmio_always_on);
33542 ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
33543 + /* The Mellanox Tavor device gives false positive parity errors
33544 + * Mark this device with a broken_parity_status, to allow
33545 + * PCI scanning code to "skip" this now blacklisted device.
33546 +@@ -2860,6 +2861,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_I
33547 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata);
33548 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata);
33550 ++#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */
33552 + /*
33553 + * Ivytown NTB BAR sizes are misreported by the hardware due to an erratum. To
33554 +@@ -2916,6 +2918,8 @@ static void fixup_debug_report(struct pc
33558 ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
33560 + /*
33561 + * Some BIOS implementations leave the Intel GPU interrupts enabled,
33562 + * even though no one is handling them (f.e. i915 driver is never loaded).
33563 +@@ -2951,6 +2955,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN
33564 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
33565 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0152, disable_igfx_irq);
33567 ++#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */
33569 + /*
33570 + * PCI devices which are on Intel chips can skip the 10ms delay
33571 + * before entering D3 mode.
33572 diff --git a/target/linux/generic/patches-3.16/811-pci_disable_usb_common_quirks.patch b/target/linux/generic/patches-3.16/811-pci_disable_usb_common_quirks.patch
33573 new file mode 100644
33574 index 000000000000..4c8ee4a7e057
33575 --- /dev/null
33576 +++ b/target/linux/generic/patches-3.16/811-pci_disable_usb_common_quirks.patch
33577 @@ -0,0 +1,101 @@
33579 +--- a/drivers/usb/host/pci-quirks.c
33580 ++++ b/drivers/usb/host/pci-quirks.c
33581 +@@ -97,6 +97,8 @@ struct amd_chipset_type {
33582 + u8 rev;
33583 + };
33585 ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
33587 + static struct amd_chipset_info {
33588 + struct pci_dev *nb_dev;
33589 + struct pci_dev *smbus_dev;
33590 +@@ -454,6 +456,10 @@ void usb_amd_dev_put(void)
33592 + EXPORT_SYMBOL_GPL(usb_amd_dev_put);
33594 ++#endif /* CONFIG_PCI_DISABLE_COMMON_QUIRKS */
33596 ++#if IS_ENABLED(CONFIG_USB_UHCI_HCD)
33598 + /*
33599 + * Make sure the controller is completely inactive, unable to
33600 + * generate interrupts or do DMA.
33601 +@@ -533,8 +539,17 @@ reset_needed:
33602 + uhci_reset_hc(pdev, base);
33603 + return 1;
33605 ++#else
33606 ++int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
33608 ++ return 0;
33611 ++#endif
33612 + EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
33614 ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
33616 + static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
33618 + u16 cmd;
33619 +@@ -1083,3 +1098,4 @@ static void quirk_usb_early_handoff(stru
33621 + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
33622 + PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
33623 ++#endif
33624 +--- a/drivers/usb/host/pci-quirks.h
33625 ++++ b/drivers/usb/host/pci-quirks.h
33626 +@@ -4,6 +4,9 @@
33627 + #ifdef CONFIG_PCI
33628 + void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
33629 + int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
33630 ++#endif /* CONFIG_PCI */
33632 ++#if defined(CONFIG_PCI) && !defined(CONFIG_PCI_DISABLE_COMMON_QUIRKS)
33633 + int usb_amd_find_chipset_info(void);
33634 + bool usb_amd_hang_symptom_quirk(void);
33635 + bool usb_amd_prefetch_quirk(void);
33636 +@@ -15,11 +18,24 @@ void usb_disable_xhci_ports(struct pci_d
33637 + void sb800_prefetch(struct device *dev, int on);
33638 + #else
33639 + struct pci_dev;
33640 ++static inline int usb_amd_find_chipset_info(void)
33642 ++ return 0;
33644 ++static inline bool usb_amd_hang_symptom_quirk(void)
33646 ++ return false;
33648 ++static inline bool usb_amd_prefetch_quirk(void)
33650 ++ return false;
33652 + static inline void usb_amd_quirk_pll_disable(void) {}
33653 + static inline void usb_amd_quirk_pll_enable(void) {}
33654 + static inline void usb_amd_dev_put(void) {}
33655 + static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
33656 + static inline void sb800_prefetch(struct device *dev, int on) {}
33657 +-#endif /* CONFIG_PCI */
33658 ++static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {}
33659 ++#endif
33661 + #endif /* __LINUX_USB_PCI_QUIRKS_H */
33662 +--- a/include/linux/usb/hcd.h
33663 ++++ b/include/linux/usb/hcd.h
33664 +@@ -439,7 +439,14 @@ extern int usb_hcd_pci_probe(struct pci_
33665 + extern void usb_hcd_pci_remove(struct pci_dev *dev);
33666 + extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
33668 ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
33669 + extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev);
33670 ++#else
33671 ++static inline int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev)
33673 ++ return 0;
33675 ++#endif
33677 + #ifdef CONFIG_PM
33678 + extern const struct dev_pm_ops usb_hcd_pci_pm_ops;
33679 diff --git a/target/linux/generic/patches-3.16/820-usb_add_usb_find_device_by_name.patch b/target/linux/generic/patches-3.16/820-usb_add_usb_find_device_by_name.patch
33680 new file mode 100644
33681 index 000000000000..99c7a3620ce6
33682 --- /dev/null
33683 +++ b/target/linux/generic/patches-3.16/820-usb_add_usb_find_device_by_name.patch
33684 @@ -0,0 +1,84 @@
33685 +--- a/drivers/usb/core/usb.c
33686 ++++ b/drivers/usb/core/usb.c
33687 +@@ -689,6 +689,71 @@ int __usb_get_extra_descriptor(char *buf
33689 + EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor);
33691 ++static struct usb_device *match_device_name(struct usb_device *dev,
33692 ++ const char *name)
33694 ++ struct usb_device *ret_dev = NULL;
33695 ++ struct usb_device *childdev = NULL;
33696 ++ int child;
33698 ++ dev_dbg(&dev->dev, "check for name %s ...\n", name);
33700 ++ /* see if this device matches */
33701 ++ if (strcmp(dev_name(&dev->dev), name) == 0 ) {
33702 ++ dev_dbg(&dev->dev, "matched this device!\n");
33703 ++ ret_dev = usb_get_dev(dev);
33704 ++ goto exit;
33705 ++ }
33706 ++ /* look through all of the children of this device */
33707 ++ usb_hub_for_each_child(dev, child, childdev) {
33708 ++ if (childdev) {
33709 ++ usb_lock_device(childdev);
33710 ++ ret_dev = match_device_name(childdev, name);
33711 ++ usb_unlock_device(childdev);
33712 ++ if (ret_dev)
33713 ++ goto exit;
33714 ++ }
33715 ++ }
33716 ++exit:
33717 ++ return ret_dev;
33720 ++/**
33721 ++ * usb_find_device_by_name - find a specific usb device in the system
33722 ++ * @name: the name of the device to find
33723 ++ *
33724 ++ * Returns a pointer to a struct usb_device if such a specified usb
33725 ++ * device is present in the system currently. The usage count of the
33726 ++ * device will be incremented if a device is found. Make sure to call
33727 ++ * usb_put_dev() when the caller is finished with the device.
33728 ++ *
33729 ++ * If a device with the specified bus id is not found, NULL is returned.
33730 ++ */
33731 ++struct usb_device *usb_find_device_by_name(const char *name)
33733 ++ struct list_head *buslist;
33734 ++ struct usb_bus *bus;
33735 ++ struct usb_device *dev = NULL;
33737 ++ mutex_lock(&usb_bus_list_lock);
33738 ++ for (buslist = usb_bus_list.next;
33739 ++ buslist != &usb_bus_list;
33740 ++ buslist = buslist->next) {
33741 ++ bus = container_of(buslist, struct usb_bus, bus_list);
33742 ++ if (!bus->root_hub)
33743 ++ continue;
33744 ++ usb_lock_device(bus->root_hub);
33745 ++ dev = match_device_name(bus->root_hub, name);
33746 ++ usb_unlock_device(bus->root_hub);
33747 ++ if (dev)
33748 ++ goto exit;
33749 ++ }
33750 ++exit:
33751 ++ mutex_unlock(&usb_bus_list_lock);
33752 ++ return dev;
33754 ++EXPORT_SYMBOL_GPL(usb_find_device_by_name);
33756 + /**
33757 + * usb_alloc_coherent - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP
33758 + * @dev: device the buffer will be used with
33759 +--- a/include/linux/usb.h
33760 ++++ b/include/linux/usb.h
33761 +@@ -692,6 +692,7 @@ static inline bool usb_device_no_sg_cons
33762 + return udev && udev->bus && udev->bus->no_sg_constraint;
33765 ++extern struct usb_device *usb_find_device_by_name(const char *name);
33767 + /*-------------------------------------------------------------------------*/
33769 diff --git a/target/linux/generic/patches-3.16/830-ledtrig_morse.patch b/target/linux/generic/patches-3.16/830-ledtrig_morse.patch
33770 new file mode 100644
33771 index 000000000000..a5dffd2d9a54
33772 --- /dev/null
33773 +++ b/target/linux/generic/patches-3.16/830-ledtrig_morse.patch
33774 @@ -0,0 +1,28 @@
33775 +--- a/drivers/leds/trigger/Kconfig
33776 ++++ b/drivers/leds/trigger/Kconfig
33777 +@@ -108,4 +108,8 @@ config LEDS_TRIGGER_CAMERA
33778 + This enables direct flash/torch on/off by the driver, kernel space.
33779 + If unsure, say Y.
33781 ++config LEDS_TRIGGER_MORSE
33782 ++ tristate "LED Morse Trigger"
33783 ++ depends on LEDS_TRIGGERS
33785 + endif # LEDS_TRIGGERS
33786 +--- a/drivers/leds/Makefile
33787 ++++ b/drivers/leds/Makefile
33788 +@@ -60,3 +60,4 @@ obj-$(CONFIG_LEDS_DAC124S085) += leds-d
33790 + # LED Triggers
33791 + obj-$(CONFIG_LEDS_TRIGGERS) += trigger/
33792 ++obj-$(CONFIG_LEDS_TRIGGER_MORSE) += ledtrig-morse.o
33793 +--- a/drivers/leds/ledtrig-morse.c
33794 ++++ b/drivers/leds/ledtrig-morse.c
33795 +@@ -26,7 +26,6 @@
33796 + #include <linux/list.h>
33797 + #include <linux/spinlock.h>
33798 + #include <linux/device.h>
33799 +-#include <linux/sysdev.h>
33800 + #include <linux/timer.h>
33801 + #include <linux/ctype.h>
33802 + #include <linux/leds.h>
33803 diff --git a/target/linux/generic/patches-3.16/831-ledtrig_netdev.patch b/target/linux/generic/patches-3.16/831-ledtrig_netdev.patch
33804 new file mode 100644
33805 index 000000000000..77bc8cc072fe
33806 --- /dev/null
33807 +++ b/target/linux/generic/patches-3.16/831-ledtrig_netdev.patch
33808 @@ -0,0 +1,60 @@
33809 +--- a/drivers/leds/trigger/Kconfig
33810 ++++ b/drivers/leds/trigger/Kconfig
33811 +@@ -112,4 +112,11 @@ config LEDS_TRIGGER_MORSE
33812 + tristate "LED Morse Trigger"
33813 + depends on LEDS_TRIGGERS
33815 ++config LEDS_TRIGGER_NETDEV
33816 ++ tristate "LED Netdev Trigger"
33817 ++ depends on NET && LEDS_TRIGGERS
33818 ++ help
33819 ++ This allows LEDs to be controlled by network device activity.
33820 ++ If unsure, say Y.
33822 + endif # LEDS_TRIGGERS
33823 +--- a/drivers/leds/Makefile
33824 ++++ b/drivers/leds/Makefile
33825 +@@ -61,3 +61,4 @@ obj-$(CONFIG_LEDS_DAC124S085) += leds-d
33826 + # LED Triggers
33827 + obj-$(CONFIG_LEDS_TRIGGERS) += trigger/
33828 + obj-$(CONFIG_LEDS_TRIGGER_MORSE) += ledtrig-morse.o
33829 ++obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
33830 +--- a/drivers/leds/ledtrig-netdev.c
33831 ++++ b/drivers/leds/ledtrig-netdev.c
33832 +@@ -22,7 +22,6 @@
33833 + #include <linux/list.h>
33834 + #include <linux/spinlock.h>
33835 + #include <linux/device.h>
33836 +-#include <linux/sysdev.h>
33837 + #include <linux/netdevice.h>
33838 + #include <linux/timer.h>
33839 + #include <linux/ctype.h>
33840 +@@ -254,7 +253,7 @@ static int netdev_trig_notify(struct not
33841 + unsigned long evt,
33842 + void *dv)
33844 +- struct net_device *dev = dv;
33845 ++ struct net_device *dev = netdev_notifier_info_to_dev((struct netdev_notifier_info *) dv);
33846 + struct led_netdev_data *trigger_data = container_of(nb, struct led_netdev_data, notifier);
33848 + if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER)
33849 +@@ -294,8 +293,9 @@ done:
33850 + static void netdev_trig_timer(unsigned long arg)
33852 + struct led_netdev_data *trigger_data = (struct led_netdev_data *)arg;
33853 +- const struct net_device_stats *dev_stats;
33854 ++ struct rtnl_link_stats64 *dev_stats;
33855 + unsigned new_activity;
33856 ++ struct rtnl_link_stats64 temp;
33858 + write_lock(&trigger_data->lock);
33860 +@@ -305,7 +305,7 @@ static void netdev_trig_timer(unsigned l
33861 + goto no_restart;
33864 +- dev_stats = dev_get_stats(trigger_data->net_dev);
33865 ++ dev_stats = dev_get_stats(trigger_data->net_dev, &temp);
33866 + new_activity =
33867 + ((trigger_data->mode & MODE_TX) ? dev_stats->tx_packets : 0) +
33868 + ((trigger_data->mode & MODE_RX) ? dev_stats->rx_packets : 0);
33869 diff --git a/target/linux/generic/patches-3.16/832-ledtrig_usbdev.patch b/target/linux/generic/patches-3.16/832-ledtrig_usbdev.patch
33870 new file mode 100644
33871 index 000000000000..c0568eb8d1c2
33872 --- /dev/null
33873 +++ b/target/linux/generic/patches-3.16/832-ledtrig_usbdev.patch
33874 @@ -0,0 +1,31 @@
33875 +--- a/drivers/leds/trigger/Kconfig
33876 ++++ b/drivers/leds/trigger/Kconfig
33877 +@@ -119,4 +119,11 @@ config LEDS_TRIGGER_NETDEV
33878 + This allows LEDs to be controlled by network device activity.
33879 + If unsure, say Y.
33881 ++config LEDS_TRIGGER_USBDEV
33882 ++ tristate "LED USB device Trigger"
33883 ++ depends on USB && LEDS_TRIGGERS
33884 ++ help
33885 ++ This allows LEDs to be controlled by the presence/activity of
33886 ++ an USB device. If unsure, say N.
33888 + endif # LEDS_TRIGGERS
33889 +--- a/drivers/leds/Makefile
33890 ++++ b/drivers/leds/Makefile
33891 +@@ -62,3 +62,4 @@ obj-$(CONFIG_LEDS_DAC124S085) += leds-d
33892 + obj-$(CONFIG_LEDS_TRIGGERS) += trigger/
33893 + obj-$(CONFIG_LEDS_TRIGGER_MORSE) += ledtrig-morse.o
33894 + obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
33895 ++obj-$(CONFIG_LEDS_TRIGGER_USBDEV) += ledtrig-usbdev.o
33896 +--- a/drivers/leds/ledtrig-usbdev.c
33897 ++++ b/drivers/leds/ledtrig-usbdev.c
33898 +@@ -24,7 +24,6 @@
33899 + #include <linux/list.h>
33900 + #include <linux/spinlock.h>
33901 + #include <linux/device.h>
33902 +-#include <linux/sysdev.h>
33903 + #include <linux/timer.h>
33904 + #include <linux/ctype.h>
33905 + #include <linux/slab.h>
33906 diff --git a/target/linux/generic/patches-3.16/840-rtc7301.patch b/target/linux/generic/patches-3.16/840-rtc7301.patch
33907 new file mode 100644
33908 index 000000000000..42cbd86aa230
33909 --- /dev/null
33910 +++ b/target/linux/generic/patches-3.16/840-rtc7301.patch
33911 @@ -0,0 +1,250 @@
33912 +--- a/drivers/rtc/Kconfig
33913 ++++ b/drivers/rtc/Kconfig
33914 +@@ -900,6 +900,15 @@ config RTC_DRV_NUC900
33915 + If you say yes here you get support for the RTC subsystem of the
33916 + NUC910/NUC920 used in embedded systems.
33918 ++config RTC_DRV_RTC7301
33919 ++ tristate "Epson RTC-7301 SF/DG"
33920 ++ help
33921 ++ If you say Y here you will get support for the
33922 ++ Epson RTC-7301 SF/DG RTC chips.
33924 ++ This driver can also be built as a module. If so, the module
33925 ++ will be called rtc-7301.
33927 + comment "on-CPU RTC drivers"
33929 + config RTC_DRV_DAVINCI
33930 +--- a/drivers/rtc/Makefile
33931 ++++ b/drivers/rtc/Makefile
33932 +@@ -104,6 +104,7 @@ obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c
33933 + obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
33934 + obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
33935 + obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
33936 ++obj-$(CONFIG_RTC_DRV_RTC7301) += rtc-rtc7301.o
33937 + obj-$(CONFIG_RTC_DRV_RV3029C2) += rtc-rv3029c2.o
33938 + obj-$(CONFIG_RTC_DRV_RX4581) += rtc-rx4581.o
33939 + obj-$(CONFIG_RTC_DRV_RX8025) += rtc-rx8025.o
33940 +--- /dev/null
33941 ++++ b/drivers/rtc/rtc-rtc7301.c
33942 +@@ -0,0 +1,219 @@
33943 ++/*
33944 ++ * Driver for Epson RTC-7301SF/DG
33945 ++ *
33946 ++ * Copyright (C) 2009 Jose Vasconcellos
33947 ++ *
33948 ++ * This program is free software; you can redistribute it and/or modify
33949 ++ * it under the terms of the GNU General Public License version 2 as
33950 ++ * published by the Free Software Foundation.
33951 ++ */
33953 ++#include <linux/module.h>
33954 ++#include <linux/rtc.h>
33955 ++#include <linux/platform_device.h>
33956 ++#include <linux/io.h>
33957 ++#include <linux/delay.h>
33958 ++#include <linux/bcd.h>
33960 ++#define RTC_NAME "rtc7301"
33961 ++#define RTC_VERSION "0.1"
33963 ++/* Epson RTC-7301 register addresses */
33964 ++#define RTC7301_SEC 0x00
33965 ++#define RTC7301_SEC10 0x01
33966 ++#define RTC7301_MIN 0x02
33967 ++#define RTC7301_MIN10 0x03
33968 ++#define RTC7301_HOUR 0x04
33969 ++#define RTC7301_HOUR10 0x05
33970 ++#define RTC7301_WEEKDAY 0x06
33971 ++#define RTC7301_DAY 0x07
33972 ++#define RTC7301_DAY10 0x08
33973 ++#define RTC7301_MON 0x09
33974 ++#define RTC7301_MON10 0x0A
33975 ++#define RTC7301_YEAR 0x0B
33976 ++#define RTC7301_YEAR10 0x0C
33977 ++#define RTC7301_YEAR100 0x0D
33978 ++#define RTC7301_YEAR1000 0x0E
33979 ++#define RTC7301_CTRLREG 0x0F
33981 ++static uint8_t __iomem *rtc7301_base;
33983 ++#define read_reg(offset) (readb(rtc7301_base + offset) & 0xf)
33984 ++#define write_reg(offset, data) writeb(data, rtc7301_base + (offset))
33986 ++#define rtc7301_isbusy() (read_reg(RTC7301_CTRLREG) & 1)
33988 ++static void rtc7301_init_settings(void)
33990 ++ int i;
33992 ++ write_reg(RTC7301_CTRLREG, 2);
33993 ++ write_reg(RTC7301_YEAR1000, 2);
33994 ++ udelay(122);
33996 ++ /* bank 1 */
33997 ++ write_reg(RTC7301_CTRLREG, 6);
33998 ++ for (i=0; i<15; i++)
33999 ++ write_reg(i, 0);
34001 ++ /* bank 2 */
34002 ++ write_reg(RTC7301_CTRLREG, 14);
34003 ++ for (i=0; i<15; i++)
34004 ++ write_reg(i, 0);
34005 ++ write_reg(RTC7301_CTRLREG, 0);
34008 ++static int rtc7301_get_datetime(struct device *dev, struct rtc_time *dt)
34010 ++ int cnt;
34011 ++ uint8_t buf[16];
34013 ++ cnt = 0;
34014 ++ while (rtc7301_isbusy()) {
34015 ++ udelay(244);
34016 ++ if (cnt++ > 100) {
34017 ++ dev_err(dev, "%s: timeout error %x\n", __func__, rtc7301_base[RTC7301_CTRLREG]);
34018 ++ return -EIO;
34019 ++ }
34020 ++ }
34022 ++ for (cnt=0; cnt<16; cnt++)
34023 ++ buf[cnt] = read_reg(cnt);
34025 ++ if (buf[RTC7301_SEC10] & 8) {
34026 ++ dev_err(dev, "%s: RTC not set\n", __func__);
34027 ++ return -EINVAL;
34028 ++ }
34030 ++ memset(dt, 0, sizeof(*dt));
34032 ++ dt->tm_sec = buf[RTC7301_SEC] + buf[RTC7301_SEC10]*10;
34033 ++ dt->tm_min = buf[RTC7301_MIN] + buf[RTC7301_MIN10]*10;
34034 ++ dt->tm_hour = buf[RTC7301_HOUR] + buf[RTC7301_HOUR10]*10;
34036 ++ dt->tm_mday = buf[RTC7301_DAY] + buf[RTC7301_DAY10]*10;
34037 ++ dt->tm_mon = buf[RTC7301_MON] + buf[RTC7301_MON10]*10 - 1;
34038 ++ dt->tm_year = buf[RTC7301_YEAR] + buf[RTC7301_YEAR10]*10 +
34039 ++ buf[RTC7301_YEAR100]*100 +
34040 ++ ((buf[RTC7301_YEAR1000] & 3)*1000) - 1900;
34042 ++ /* the rtc device may contain illegal values on power up
34043 ++ * according to the data sheet. make sure they are valid.
34044 ++ */
34046 ++ return rtc_valid_tm(dt);
34049 ++static int rtc7301_set_datetime(struct device *dev, struct rtc_time *dt)
34051 ++ int data;
34053 ++ data = dt->tm_year + 1900;
34054 ++ if (data >= 2100 || data < 1900)
34055 ++ return -EINVAL;
34057 ++ write_reg(RTC7301_CTRLREG, 2);
34058 ++ udelay(122);
34060 ++ data = bin2bcd(dt->tm_sec);
34061 ++ write_reg(RTC7301_SEC, data);
34062 ++ write_reg(RTC7301_SEC10, (data >> 4));
34064 ++ data = bin2bcd(dt->tm_min);
34065 ++ write_reg(RTC7301_MIN, data );
34066 ++ write_reg(RTC7301_MIN10, (data >> 4));
34068 ++ data = bin2bcd(dt->tm_hour);
34069 ++ write_reg(RTC7301_HOUR, data);
34070 ++ write_reg(RTC7301_HOUR10, (data >> 4));
34072 ++ data = bin2bcd(dt->tm_mday);
34073 ++ write_reg(RTC7301_DAY, data);
34074 ++ write_reg(RTC7301_DAY10, (data>> 4));
34076 ++ data = bin2bcd(dt->tm_mon + 1);
34077 ++ write_reg(RTC7301_MON, data);
34078 ++ write_reg(RTC7301_MON10, (data >> 4));
34080 ++ data = bin2bcd(dt->tm_year % 100);
34081 ++ write_reg(RTC7301_YEAR, data);
34082 ++ write_reg(RTC7301_YEAR10, (data >> 4));
34083 ++ data = bin2bcd((1900 + dt->tm_year) / 100);
34084 ++ write_reg(RTC7301_YEAR100, data);
34086 ++ data = bin2bcd(dt->tm_wday);
34087 ++ write_reg(RTC7301_WEEKDAY, data);
34089 ++ write_reg(RTC7301_CTRLREG, 0);
34091 ++ return 0;
34094 ++static const struct rtc_class_ops rtc7301_rtc_ops = {
34095 ++ .read_time = rtc7301_get_datetime,
34096 ++ .set_time = rtc7301_set_datetime,
34097 ++};
34099 ++static int rtc7301_probe(struct platform_device *pdev)
34101 ++ struct rtc_device *rtc;
34102 ++ struct resource *res;
34104 ++ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
34105 ++ if (!res)
34106 ++ return -ENOENT;
34108 ++ rtc7301_base = ioremap_nocache(res->start, 0x1000 /*res->end - res->start + 1*/);
34109 ++ if (!rtc7301_base)
34110 ++ return -EINVAL;
34112 ++ rtc = rtc_device_register(RTC_NAME, &pdev->dev,
34113 ++ &rtc7301_rtc_ops, THIS_MODULE);
34114 ++ if (IS_ERR(rtc)) {
34115 ++ iounmap(rtc7301_base);
34116 ++ return PTR_ERR(rtc);
34117 ++ }
34119 ++ platform_set_drvdata(pdev, rtc);
34121 ++ rtc7301_init_settings();
34122 ++ return 0;
34125 ++static int rtc7301_remove(struct platform_device *pdev)
34127 ++ struct rtc_device *rtc = platform_get_drvdata(pdev);
34129 ++ if (rtc)
34130 ++ rtc_device_unregister(rtc);
34131 ++ if (rtc7301_base)
34132 ++ iounmap(rtc7301_base);
34133 ++ return 0;
34136 ++static struct platform_driver rtc7301_driver = {
34137 ++ .driver = {
34138 ++ .name = RTC_NAME,
34139 ++ .owner = THIS_MODULE,
34140 ++ },
34141 ++ .probe = rtc7301_probe,
34142 ++ .remove = rtc7301_remove,
34143 ++};
34145 ++static __init int rtc7301_init(void)
34147 ++ return platform_driver_register(&rtc7301_driver);
34149 ++module_init(rtc7301_init);
34151 ++static __exit void rtc7301_exit(void)
34153 ++ platform_driver_unregister(&rtc7301_driver);
34155 ++module_exit(rtc7301_exit);
34157 ++MODULE_DESCRIPTION("Epson 7301 RTC driver");
34158 ++MODULE_AUTHOR("Jose Vasconcellos <jvasco@verizon.net>");
34159 ++MODULE_LICENSE("GPL");
34160 ++MODULE_ALIAS("platform:" RTC_NAME);
34161 ++MODULE_VERSION(RTC_VERSION);
34162 diff --git a/target/linux/generic/patches-3.16/841-rtc_pt7c4338.patch b/target/linux/generic/patches-3.16/841-rtc_pt7c4338.patch
34163 new file mode 100644
34164 index 000000000000..6391ce0236dc
34165 --- /dev/null
34166 +++ b/target/linux/generic/patches-3.16/841-rtc_pt7c4338.patch
34167 @@ -0,0 +1,247 @@
34168 +--- a/drivers/rtc/Kconfig
34169 ++++ b/drivers/rtc/Kconfig
34170 +@@ -539,6 +539,15 @@ config RTC_DRV_S5M
34171 + This driver can also be built as a module. If so, the module
34172 + will be called rtc-s5m.
34174 ++config RTC_DRV_PT7C4338
34175 ++ tristate "Pericom Technology Inc. PT7C4338 RTC"
34176 ++ help
34177 ++ If you say yes here you get support for the Pericom Technology
34178 ++ Inc. PT7C4338 RTC chip.
34180 ++ This driver can also be built as a module. If so, the module
34181 ++ will be called rtc-pt7c4338.
34183 + endif # I2C
34185 + comment "SPI RTC drivers"
34186 +--- a/drivers/rtc/Makefile
34187 ++++ b/drivers/rtc/Makefile
34188 +@@ -96,6 +96,7 @@ obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030
34189 + obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
34190 + obj-$(CONFIG_RTC_DRV_PM8XXX) += rtc-pm8xxx.o
34191 + obj-$(CONFIG_RTC_DRV_PS3) += rtc-ps3.o
34192 ++obj-$(CONFIG_RTC_DRV_PT7C4338) += rtc-pt7c4338.o
34193 + obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o
34194 + obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o
34195 + obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o
34196 +--- /dev/null
34197 ++++ b/drivers/rtc/rtc-pt7c4338.c
34198 +@@ -0,0 +1,216 @@
34199 ++/*
34200 ++ * Copyright 2010 Freescale Semiconductor, Inc.
34201 ++ *
34202 ++ * Author: Priyanka Jain <Priyanka.Jain@freescale.com>
34203 ++ *
34204 ++ * See file CREDITS for list of people who contributed to this
34205 ++ * project.
34206 ++ *
34207 ++ * This program is free software; you can redistribute it and/or
34208 ++ * modify it under the terms of the GNU General Public License as
34209 ++ * published by the Free Software Foundation; either version 2 of
34210 ++ * the License, or (at your option) any later version.
34211 ++ *
34212 ++ * This program is distributed in the hope that it will be useful,
34213 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
34214 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
34215 ++ * GNU General Public License for more details.
34216 ++ *
34217 ++ * You should have received a copy of the GNU General Public License
34218 ++ * along with this program; if not, write to the Free Software
34219 ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34220 ++ * MA 02111-1307 USA
34221 ++ */
34223 ++/*
34224 ++ * This file provides Date & Time support (no alarms) for PT7C4338 chip.
34225 ++ *
34226 ++ * This file is based on drivers/rtc/rtc-ds1307.c
34227 ++ *
34228 ++ * PT7C4338 chip is manufactured by Pericom Technology Inc.
34229 ++ * It is a serial real-time clock which provides
34230 ++ * 1)Low-power clock/calendar.
34231 ++ * 2)Programmable square-wave output.
34232 ++ * It has 56 bytes of nonvolatile RAM.
34233 ++ */
34235 ++#include <linux/kernel.h>
34236 ++#include <linux/module.h>
34237 ++#include <linux/slab.h>
34238 ++#include <linux/i2c.h>
34239 ++#include <linux/rtc.h>
34240 ++#include <linux/bcd.h>
34242 ++/* RTC register addresses */
34243 ++#define PT7C4338_REG_SECONDS 0x00
34244 ++#define PT7C4338_REG_MINUTES 0x01
34245 ++#define PT7C4338_REG_HOURS 0x02
34246 ++#define PT7C4338_REG_AMPM 0x02
34247 ++#define PT7C4338_REG_DAY 0x03
34248 ++#define PT7C4338_REG_DATE 0x04
34249 ++#define PT7C4338_REG_MONTH 0x05
34250 ++#define PT7C4338_REG_YEAR 0x06
34251 ++#define PT7C4338_REG_CTRL_STAT 0x07
34253 ++/* RTC second register address bit */
34254 ++#define PT7C4338_SEC_BIT_CH 0x80 /*Clock Halt (in Register 0)*/
34256 ++/* RTC control and status register bits */
34257 ++#define PT7C4338_CTRL_STAT_BIT_RS0 0x1 /*Rate select 0*/
34258 ++#define PT7C4338_CTRL_STAT_BIT_RS1 0x2 /*Rate select 1*/
34259 ++#define PT7C4338_CTRL_STAT_BIT_SQWE 0x10 /*Square Wave Enable*/
34260 ++#define PT7C4338_CTRL_STAT_BIT_OSF 0x20 /*Oscillator Stop Flag*/
34261 ++#define PT7C4338_CTRL_STAT_BIT_OUT 0x80 /*Output Level Control*/
34263 ++static const struct i2c_device_id pt7c4338_id[] = {
34264 ++ { "pt7c4338", 0 },
34265 ++ { }
34266 ++};
34267 ++MODULE_DEVICE_TABLE(i2c, pt7c4338_id);
34269 ++struct pt7c4338{
34270 ++ struct i2c_client *client;
34271 ++ struct rtc_device *rtc;
34272 ++};
34274 ++static int pt7c4338_read_time(struct device *dev, struct rtc_time *time)
34276 ++ struct i2c_client *client = to_i2c_client(dev);
34277 ++ int ret;
34278 ++ u8 buf[7];
34279 ++ u8 year, month, day, hour, minute, second;
34280 ++ u8 week, twelve_hr, am_pm;
34282 ++ ret = i2c_smbus_read_i2c_block_data(client,
34283 ++ PT7C4338_REG_SECONDS, 7, buf);
34284 ++ if (ret < 0)
34285 ++ return ret;
34286 ++ if (ret < 7)
34287 ++ return -EIO;
34289 ++ second = buf[0];
34290 ++ minute = buf[1];
34291 ++ hour = buf[2];
34292 ++ week = buf[3];
34293 ++ day = buf[4];
34294 ++ month = buf[5];
34295 ++ year = buf[6];
34297 ++ /* Extract additional information for AM/PM */
34298 ++ twelve_hr = hour & 0x40;
34299 ++ am_pm = hour & 0x20;
34301 ++ /* Write to rtc_time structure */
34302 ++ time->tm_sec = bcd2bin(second & 0x7f);
34303 ++ time->tm_min = bcd2bin(minute & 0x7f);
34304 ++ if (twelve_hr) {
34305 ++ /* Convert to 24 hr */
34306 ++ if (am_pm)
34307 ++ time->tm_hour = bcd2bin(hour & 0x10) + 12;
34308 ++ else
34309 ++ time->tm_hour = bcd2bin(hour & 0xBF);
34310 ++ } else {
34311 ++ time->tm_hour = bcd2bin(hour);
34312 ++ }
34314 ++ time->tm_wday = bcd2bin(week & 0x07) - 1;
34315 ++ time->tm_mday = bcd2bin(day & 0x3f);
34316 ++ time->tm_mon = bcd2bin(month & 0x1F) - 1;
34317 ++ /* assume 20YY not 19YY */
34318 ++ time->tm_year = bcd2bin(year) + 100;
34320 ++ return 0;
34323 ++static int pt7c4338_set_time(struct device *dev, struct rtc_time *time)
34325 ++ struct i2c_client *client = to_i2c_client(dev);
34326 ++ u8 buf[7];
34328 ++ /* Extract time from rtc_time and load into pt7c4338*/
34329 ++ buf[0] = bin2bcd(time->tm_sec);
34330 ++ buf[1] = bin2bcd(time->tm_min);
34331 ++ buf[2] = bin2bcd(time->tm_hour);
34332 ++ buf[3] = bin2bcd(time->tm_wday + 1); /* Day of the week */
34333 ++ buf[4] = bin2bcd(time->tm_mday); /* Date */
34334 ++ buf[5] = bin2bcd(time->tm_mon + 1);
34336 ++ /* assume 20YY not 19YY */
34337 ++ if (time->tm_year >= 100)
34338 ++ buf[6] = bin2bcd(time->tm_year - 100);
34339 ++ else
34340 ++ buf[6] = bin2bcd(time->tm_year);
34342 ++ return i2c_smbus_write_i2c_block_data(client,
34343 ++ PT7C4338_REG_SECONDS, 7, buf);
34346 ++static const struct rtc_class_ops pt7c4338_rtc_ops = {
34347 ++ .read_time = pt7c4338_read_time,
34348 ++ .set_time = pt7c4338_set_time,
34349 ++};
34351 ++static int pt7c4338_probe(struct i2c_client *client,
34352 ++ const struct i2c_device_id *id)
34354 ++ struct pt7c4338 *pt7c4338;
34355 ++ struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
34356 ++ int ret;
34358 ++ pt7c4338 = kzalloc(sizeof(struct pt7c4338), GFP_KERNEL);
34359 ++ if (!pt7c4338)
34360 ++ return -ENOMEM;
34362 ++ pt7c4338->client = client;
34363 ++ i2c_set_clientdata(client, pt7c4338);
34364 ++ pt7c4338->rtc = rtc_device_register(client->name, &client->dev,
34365 ++ &pt7c4338_rtc_ops, THIS_MODULE);
34366 ++ if (IS_ERR(pt7c4338->rtc)) {
34367 ++ ret = PTR_ERR(pt7c4338->rtc);
34368 ++ dev_err(&client->dev, "unable to register the class device\n");
34369 ++ goto out_free;
34370 ++ }
34372 ++ return 0;
34373 ++out_free:
34374 ++ i2c_set_clientdata(client, NULL);
34375 ++ kfree(pt7c4338);
34376 ++ return ret;
34379 ++static int pt7c4338_remove(struct i2c_client *client)
34381 ++ struct pt7c4338 *pt7c4338 = i2c_get_clientdata(client);
34383 ++ rtc_device_unregister(pt7c4338->rtc);
34384 ++ i2c_set_clientdata(client, NULL);
34385 ++ kfree(pt7c4338);
34386 ++ return 0;
34389 ++static struct i2c_driver pt7c4338_driver = {
34390 ++ .driver = {
34391 ++ .name = "rtc-pt7c4338",
34392 ++ .owner = THIS_MODULE,
34393 ++ },
34394 ++ .probe = pt7c4338_probe,
34395 ++ .remove = pt7c4338_remove,
34396 ++ .id_table = pt7c4338_id,
34397 ++};
34399 ++static int __init pt7c4338_init(void)
34401 ++ return i2c_add_driver(&pt7c4338_driver);
34404 ++static void __exit pt7c4338_exit(void)
34406 ++ i2c_del_driver(&pt7c4338_driver);
34409 ++module_init(pt7c4338_init);
34410 ++module_exit(pt7c4338_exit);
34412 ++MODULE_AUTHOR("Priyanka Jain <Priyanka.Jain@freescale.com>");
34413 ++MODULE_DESCRIPTION("pericom Technology Inc. PT7C4338 RTC Driver");
34414 ++MODULE_LICENSE("GPL");
34415 diff --git a/target/linux/generic/patches-3.16/861-04_spi_gpio_implement_spi_delay.patch b/target/linux/generic/patches-3.16/861-04_spi_gpio_implement_spi_delay.patch
34416 new file mode 100644
34417 index 000000000000..6cbe4c3ee3f7
34418 --- /dev/null
34419 +++ b/target/linux/generic/patches-3.16/861-04_spi_gpio_implement_spi_delay.patch
34420 @@ -0,0 +1,58 @@
34421 +Implement the SPI-GPIO delay function for busses that need speed limitation.
34423 +--mb
34427 +--- a/drivers/spi/spi-gpio.c
34428 ++++ b/drivers/spi/spi-gpio.c
34429 +@@ -22,6 +22,7 @@
34430 + #include <linux/init.h>
34431 + #include <linux/platform_device.h>
34432 + #include <linux/gpio.h>
34433 ++#include <linux/delay.h>
34434 + #include <linux/of.h>
34435 + #include <linux/of_device.h>
34436 + #include <linux/of_gpio.h>
34437 +@@ -74,6 +75,7 @@ struct spi_gpio {
34438 + * #define SPI_MOSI_GPIO 120
34439 + * #define SPI_SCK_GPIO 121
34440 + * #define SPI_N_CHIPSEL 4
34441 ++ * #undef NEED_SPIDELAY
34442 + * #include "spi-gpio.c"
34443 + */
34445 +@@ -81,6 +83,7 @@ struct spi_gpio {
34446 + #define DRIVER_NAME "spi_gpio"
34448 + #define GENERIC_BITBANG /* vs tight inlines */
34449 ++#define NEED_SPIDELAY 1
34451 + /* all functions referencing these symbols must define pdata */
34452 + #define SPI_MISO_GPIO ((pdata)->miso)
34453 +@@ -131,12 +134,20 @@ static inline int getmiso(const struct s
34454 + #undef pdata
34456 + /*
34457 +- * NOTE: this clocks "as fast as we can". It "should" be a function of the
34458 +- * requested device clock. Software overhead means we usually have trouble
34459 +- * reaching even one Mbit/sec (except when we can inline bitops), so for now
34460 +- * we'll just assume we never need additional per-bit slowdowns.
34461 ++ * NOTE: to clock "as fast as we can", set spi_device.max_speed_hz
34462 ++ * and spi_transfer.speed_hz to 0.
34463 ++ * Otherwise this is a function of the requested device clock.
34464 ++ * Software overhead means we usually have trouble
34465 ++ * reaching even one Mbit/sec (except when we can inline bitops). So on small
34466 ++ * embedded devices with fast SPI slaves you usually don't need a delay.
34467 + */
34468 +-#define spidelay(nsecs) do {} while (0)
34469 ++static inline void spidelay(unsigned nsecs)
34471 ++#ifdef NEED_SPIDELAY
34472 ++ if (unlikely(nsecs))
34473 ++ ndelay(nsecs);
34474 ++#endif /* NEED_SPIDELAY */
34477 + #include "spi-bitbang-txrx.h"
34479 diff --git a/target/linux/generic/patches-3.16/862-gpio_spi_driver.patch b/target/linux/generic/patches-3.16/862-gpio_spi_driver.patch
34480 new file mode 100644
34481 index 000000000000..304445a34314
34482 --- /dev/null
34483 +++ b/target/linux/generic/patches-3.16/862-gpio_spi_driver.patch
34484 @@ -0,0 +1,373 @@
34485 +THIS CODE IS DEPRECATED.
34487 +Please use the new mainline SPI-GPIO driver, as of 2.6.29.
34489 +--mb
34493 +---
34494 + drivers/spi/Kconfig | 9 +
34495 + drivers/spi/Makefile | 1
34496 + drivers/spi/spi_gpio_old.c | 251 +++++++++++++++++++++++++++++++++++++++
34497 + include/linux/spi/spi_gpio_old.h | 73 +++++++++++
34498 + 4 files changed, 334 insertions(+)
34500 +--- /dev/null
34501 ++++ b/include/linux/spi/spi_gpio_old.h
34502 +@@ -0,0 +1,73 @@
34503 ++/*
34504 ++ * spi_gpio interface to platform code
34505 ++ *
34506 ++ * Copyright (c) 2008 Piotr Skamruk
34507 ++ * Copyright (c) 2008 Michael Buesch
34508 ++ *
34509 ++ * This program is free software; you can redistribute it and/or modify
34510 ++ * it under the terms of the GNU General Public License version 2 as
34511 ++ * published by the Free Software Foundation.
34512 ++ */
34513 ++#ifndef _LINUX_SPI_SPI_GPIO
34514 ++#define _LINUX_SPI_SPI_GPIO
34516 ++#include <linux/types.h>
34517 ++#include <linux/spi/spi.h>
34520 ++/**
34521 ++ * struct spi_gpio_platform_data - Data definitions for a SPI-GPIO device.
34522 ++ *
34523 ++ * This structure holds information about a GPIO-based SPI device.
34524 ++ *
34525 ++ * @pin_clk: The GPIO pin number of the CLOCK pin.
34526 ++ *
34527 ++ * @pin_miso: The GPIO pin number of the MISO pin.
34528 ++ *
34529 ++ * @pin_mosi: The GPIO pin number of the MOSI pin.
34530 ++ *
34531 ++ * @pin_cs: The GPIO pin number of the CHIPSELECT pin.
34532 ++ *
34533 ++ * @cs_activelow: If true, the chip is selected when the CS line is low.
34534 ++ *
34535 ++ * @no_spi_delay: If true, no delay is done in the lowlevel bitbanging.
34536 ++ * Note that doing no delay is not standards compliant,
34537 ++ * but it might be needed to speed up transfers on some
34538 ++ * slow embedded machines.
34539 ++ *
34540 ++ * @boardinfo_setup: This callback is called after the
34541 ++ * SPI master device was registered, but before the
34542 ++ * device is registered.
34543 ++ * @boardinfo_setup_data: Data argument passed to boardinfo_setup().
34544 ++ */
34545 ++struct spi_gpio_platform_data {
34546 ++ unsigned int pin_clk;
34547 ++ unsigned int pin_miso;
34548 ++ unsigned int pin_mosi;
34549 ++ unsigned int pin_cs;
34550 ++ bool cs_activelow;
34551 ++ bool no_spi_delay;
34552 ++ int (*boardinfo_setup)(struct spi_board_info *bi,
34553 ++ struct spi_master *master,
34554 ++ void *data);
34555 ++ void *boardinfo_setup_data;
34556 ++};
34558 ++/**
34559 ++ * SPI_GPIO_PLATDEV_NAME - The platform device name string.
34560 ++ *
34561 ++ * The name string that has to be used for platform_device_alloc
34562 ++ * when allocating a spi-gpio device.
34563 ++ */
34564 ++#define SPI_GPIO_PLATDEV_NAME "spi-gpio"
34566 ++/**
34567 ++ * spi_gpio_next_id - Get another platform device ID number.
34568 ++ *
34569 ++ * This returns the next platform device ID number that has to be used
34570 ++ * for platform_device_alloc. The ID is opaque and should not be used for
34571 ++ * anything else.
34572 ++ */
34573 ++int spi_gpio_next_id(void);
34575 ++#endif /* _LINUX_SPI_SPI_GPIO */
34576 +--- /dev/null
34577 ++++ b/drivers/spi/spi_gpio_old.c
34578 +@@ -0,0 +1,251 @@
34579 ++/*
34580 ++ * Bitbanging SPI bus driver using GPIO API
34581 ++ *
34582 ++ * Copyright (c) 2008 Piotr Skamruk
34583 ++ * Copyright (c) 2008 Michael Buesch
34584 ++ *
34585 ++ * based on spi_s3c2410_gpio.c
34586 ++ * Copyright (c) 2006 Ben Dooks
34587 ++ * Copyright (c) 2006 Simtec Electronics
34588 ++ * and on i2c-gpio.c
34589 ++ * Copyright (C) 2007 Atmel Corporation
34590 ++ *
34591 ++ * This program is free software; you can redistribute it and/or modify
34592 ++ * it under the terms of the GNU General Public License version 2 as
34593 ++ * published by the Free Software Foundation.
34594 ++ */
34596 ++#include <linux/kernel.h>
34597 ++#include <linux/init.h>
34598 ++#include <linux/delay.h>
34599 ++#include <linux/spinlock.h>
34600 ++#include <linux/workqueue.h>
34601 ++#include <linux/module.h>
34602 ++#include <linux/platform_device.h>
34603 ++#include <linux/spi/spi.h>
34604 ++#include <linux/spi/spi_bitbang.h>
34605 ++#include <linux/spi/spi_gpio_old.h>
34606 ++#include <linux/gpio.h>
34607 ++#include <asm/atomic.h>
34610 ++struct spi_gpio {
34611 ++ struct spi_bitbang bitbang;
34612 ++ struct spi_gpio_platform_data *info;
34613 ++ struct platform_device *pdev;
34614 ++ struct spi_board_info bi;
34615 ++};
34618 ++static inline struct spi_gpio *spidev_to_sg(struct spi_device *dev)
34620 ++ return dev->controller_data;
34623 ++static inline void setsck(struct spi_device *dev, int val)
34625 ++ struct spi_gpio *sp = spidev_to_sg(dev);
34626 ++ gpio_set_value(sp->info->pin_clk, val ? 1 : 0);
34629 ++static inline void setmosi(struct spi_device *dev, int val)
34631 ++ struct spi_gpio *sp = spidev_to_sg(dev);
34632 ++ gpio_set_value(sp->info->pin_mosi, val ? 1 : 0);
34635 ++static inline u32 getmiso(struct spi_device *dev)
34637 ++ struct spi_gpio *sp = spidev_to_sg(dev);
34638 ++ return gpio_get_value(sp->info->pin_miso) ? 1 : 0;
34641 ++static inline void do_spidelay(struct spi_device *dev, unsigned nsecs)
34643 ++ struct spi_gpio *sp = spidev_to_sg(dev);
34645 ++ if (!sp->info->no_spi_delay)
34646 ++ ndelay(nsecs);
34649 ++#define spidelay(nsecs) do { \
34650 ++ /* Steal the spi_device pointer from our caller. \
34651 ++ * The bitbang-API should probably get fixed here... */ \
34652 ++ do_spidelay(spi, nsecs); \
34653 ++ } while (0)
34655 ++#define EXPAND_BITBANG_TXRX
34656 ++#include "spi-bitbang-txrx.h"
34658 ++static u32 spi_gpio_txrx_mode0(struct spi_device *spi,
34659 ++ unsigned nsecs, u32 word, u8 bits)
34661 ++ return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
34664 ++static u32 spi_gpio_txrx_mode1(struct spi_device *spi,
34665 ++ unsigned nsecs, u32 word, u8 bits)
34667 ++ return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
34670 ++static u32 spi_gpio_txrx_mode2(struct spi_device *spi,
34671 ++ unsigned nsecs, u32 word, u8 bits)
34673 ++ return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
34676 ++static u32 spi_gpio_txrx_mode3(struct spi_device *spi,
34677 ++ unsigned nsecs, u32 word, u8 bits)
34679 ++ return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
34682 ++static void spi_gpio_chipselect(struct spi_device *dev, int on)
34684 ++ struct spi_gpio *sp = spidev_to_sg(dev);
34686 ++ if (sp->info->cs_activelow)
34687 ++ on = !on;
34688 ++ gpio_set_value(sp->info->pin_cs, on ? 1 : 0);
34691 ++static int spi_gpio_probe(struct platform_device *pdev)
34693 ++ struct spi_master *master;
34694 ++ struct spi_gpio_platform_data *pdata;
34695 ++ struct spi_gpio *sp;
34696 ++ struct spi_device *spidev;
34697 ++ int err;
34699 ++ pdata = pdev->dev.platform_data;
34700 ++ if (!pdata)
34701 ++ return -ENXIO;
34703 ++ err = -ENOMEM;
34704 ++ master = spi_alloc_master(&pdev->dev, sizeof(struct spi_gpio));
34705 ++ if (!master)
34706 ++ goto err_alloc_master;
34708 ++ sp = spi_master_get_devdata(master);
34709 ++ platform_set_drvdata(pdev, sp);
34710 ++ sp->info = pdata;
34712 ++ err = gpio_request(pdata->pin_clk, "spi_clock");
34713 ++ if (err)
34714 ++ goto err_request_clk;
34715 ++ err = gpio_request(pdata->pin_mosi, "spi_mosi");
34716 ++ if (err)
34717 ++ goto err_request_mosi;
34718 ++ err = gpio_request(pdata->pin_miso, "spi_miso");
34719 ++ if (err)
34720 ++ goto err_request_miso;
34721 ++ err = gpio_request(pdata->pin_cs, "spi_cs");
34722 ++ if (err)
34723 ++ goto err_request_cs;
34725 ++ sp->bitbang.master = spi_master_get(master);
34726 ++ sp->bitbang.master->bus_num = -1;
34727 ++ sp->bitbang.master->num_chipselect = 1;
34728 ++ sp->bitbang.chipselect = spi_gpio_chipselect;
34729 ++ sp->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_txrx_mode0;
34730 ++ sp->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_txrx_mode1;
34731 ++ sp->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_txrx_mode2;
34732 ++ sp->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_txrx_mode3;
34734 ++ gpio_direction_output(pdata->pin_clk, 0);
34735 ++ gpio_direction_output(pdata->pin_mosi, 0);
34736 ++ gpio_direction_output(pdata->pin_cs,
34737 ++ pdata->cs_activelow ? 1 : 0);
34738 ++ gpio_direction_input(pdata->pin_miso);
34740 ++ err = spi_bitbang_start(&sp->bitbang);
34741 ++ if (err)
34742 ++ goto err_no_bitbang;
34743 ++ err = pdata->boardinfo_setup(&sp->bi, master,
34744 ++ pdata->boardinfo_setup_data);
34745 ++ if (err)
34746 ++ goto err_bi_setup;
34747 ++ sp->bi.controller_data = sp;
34748 ++ spidev = spi_new_device(master, &sp->bi);
34749 ++ if (!spidev)
34750 ++ goto err_new_dev;
34752 ++ return 0;
34754 ++err_new_dev:
34755 ++err_bi_setup:
34756 ++ spi_bitbang_stop(&sp->bitbang);
34757 ++err_no_bitbang:
34758 ++ spi_master_put(sp->bitbang.master);
34759 ++ gpio_free(pdata->pin_cs);
34760 ++err_request_cs:
34761 ++ gpio_free(pdata->pin_miso);
34762 ++err_request_miso:
34763 ++ gpio_free(pdata->pin_mosi);
34764 ++err_request_mosi:
34765 ++ gpio_free(pdata->pin_clk);
34766 ++err_request_clk:
34767 ++ kfree(master);
34769 ++err_alloc_master:
34770 ++ return err;
34773 ++static int spi_gpio_remove(struct platform_device *pdev)
34775 ++ struct spi_gpio *sp;
34776 ++ struct spi_gpio_platform_data *pdata;
34778 ++ pdata = pdev->dev.platform_data;
34779 ++ sp = platform_get_drvdata(pdev);
34781 ++ gpio_free(pdata->pin_clk);
34782 ++ gpio_free(pdata->pin_mosi);
34783 ++ gpio_free(pdata->pin_miso);
34784 ++ gpio_free(pdata->pin_cs);
34785 ++ spi_bitbang_stop(&sp->bitbang);
34786 ++ spi_master_put(sp->bitbang.master);
34788 ++ return 0;
34791 ++static struct platform_driver spi_gpio_driver = {
34792 ++ .driver = {
34793 ++ .name = SPI_GPIO_PLATDEV_NAME,
34794 ++ .owner = THIS_MODULE,
34795 ++ },
34796 ++ .probe = spi_gpio_probe,
34797 ++ .remove = spi_gpio_remove,
34798 ++};
34800 ++int spi_gpio_next_id(void)
34802 ++ static atomic_t counter = ATOMIC_INIT(-1);
34804 ++ return atomic_inc_return(&counter);
34806 ++EXPORT_SYMBOL(spi_gpio_next_id);
34808 ++static int __init spi_gpio_init(void)
34810 ++ int err;
34812 ++ err = platform_driver_register(&spi_gpio_driver);
34813 ++ if (err)
34814 ++ printk(KERN_ERR "spi-gpio: register failed: %d\n", err);
34816 ++ return err;
34818 ++module_init(spi_gpio_init);
34820 ++static void __exit spi_gpio_exit(void)
34822 ++ platform_driver_unregister(&spi_gpio_driver);
34824 ++module_exit(spi_gpio_exit);
34826 ++MODULE_AUTHOR("Piot Skamruk <piotr.skamruk at gmail.com>");
34827 ++MODULE_AUTHOR("Michael Buesch");
34828 ++MODULE_DESCRIPTION("Platform independent GPIO bitbanging SPI driver");
34829 ++MODULE_LICENSE("GPL v2");
34830 +--- a/drivers/spi/Kconfig
34831 ++++ b/drivers/spi/Kconfig
34832 +@@ -208,6 +208,15 @@ config SPI_GPIO
34833 + GPIO operations, you should be able to leverage that for better
34834 + speed with a custom version of this driver; see the source code.
34836 ++config SPI_GPIO_OLD
34837 ++ tristate "Old GPIO API based bitbanging SPI controller (DEPRECATED)"
34838 ++ depends on SPI_MASTER && GPIOLIB
34839 ++ select SPI_BITBANG
34840 ++ help
34841 ++ This code is deprecated. Please use the new mainline SPI-GPIO driver.
34843 ++ If unsure, say N.
34845 + config SPI_IMX
34846 + tristate "Freescale i.MX SPI controllers"
34847 + depends on ARCH_MXC || COMPILE_TEST
34848 +--- a/drivers/spi/Makefile
34849 ++++ b/drivers/spi/Makefile
34850 +@@ -38,6 +38,7 @@ obj-$(CONFIG_SPI_FSL_LIB) += spi-fsl-li
34851 + obj-$(CONFIG_SPI_FSL_ESPI) += spi-fsl-espi.o
34852 + obj-$(CONFIG_SPI_FSL_SPI) += spi-fsl-spi.o
34853 + obj-$(CONFIG_SPI_GPIO) += spi-gpio.o
34854 ++obj-$(CONFIG_SPI_GPIO_OLD) += spi_gpio_old.o
34855 + obj-$(CONFIG_SPI_IMX) += spi-imx.o
34856 + obj-$(CONFIG_SPI_LM70_LLP) += spi-lm70llp.o
34857 + obj-$(CONFIG_SPI_MPC512x_PSC) += spi-mpc512x-psc.o
34858 diff --git a/target/linux/generic/patches-3.16/863-gpiommc.patch b/target/linux/generic/patches-3.16/863-gpiommc.patch
34859 new file mode 100644
34860 index 000000000000..8f3022c8379a
34861 --- /dev/null
34862 +++ b/target/linux/generic/patches-3.16/863-gpiommc.patch
34863 @@ -0,0 +1,844 @@
34864 +--- /dev/null
34865 ++++ b/drivers/mmc/host/gpiommc.c
34866 +@@ -0,0 +1,609 @@
34867 ++/*
34868 ++ * Driver an MMC/SD card on a bitbanging GPIO SPI bus.
34869 ++ * This module hooks up the mmc_spi and spi_gpio modules and also
34870 ++ * provides a configfs interface.
34871 ++ *
34872 ++ * Copyright 2008 Michael Buesch <mb@bu3sch.de>
34873 ++ *
34874 ++ * Licensed under the GNU/GPL. See COPYING for details.
34875 ++ */
34877 ++#include <linux/module.h>
34878 ++#include <linux/mmc/gpiommc.h>
34879 ++#include <linux/platform_device.h>
34880 ++#include <linux/list.h>
34881 ++#include <linux/mutex.h>
34882 ++#include <linux/spi/spi_gpio_old.h>
34883 ++#include <linux/configfs.h>
34884 ++#include <linux/gpio.h>
34885 ++#include <asm/atomic.h>
34888 ++#define PFX "gpio-mmc: "
34891 ++struct gpiommc_device {
34892 ++ struct platform_device *pdev;
34893 ++ struct platform_device *spi_pdev;
34894 ++ struct spi_board_info boardinfo;
34895 ++};
34898 ++MODULE_DESCRIPTION("GPIO based MMC driver");
34899 ++MODULE_AUTHOR("Michael Buesch");
34900 ++MODULE_LICENSE("GPL");
34903 ++static int gpiommc_boardinfo_setup(struct spi_board_info *bi,
34904 ++ struct spi_master *master,
34905 ++ void *data)
34907 ++ struct gpiommc_device *d = data;
34908 ++ struct gpiommc_platform_data *pdata = d->pdev->dev.platform_data;
34910 ++ /* Bind the SPI master to the MMC-SPI host driver. */
34911 ++ strlcpy(bi->modalias, "mmc_spi", sizeof(bi->modalias));
34913 ++ bi->max_speed_hz = pdata->max_bus_speed;
34914 ++ bi->bus_num = master->bus_num;
34915 ++ bi->mode = pdata->mode;
34917 ++ return 0;
34920 ++static int gpiommc_probe(struct platform_device *pdev)
34922 ++ struct gpiommc_platform_data *mmc_pdata = pdev->dev.platform_data;
34923 ++ struct spi_gpio_platform_data spi_pdata;
34924 ++ struct gpiommc_device *d;
34925 ++ int err;
34927 ++ err = -ENXIO;
34928 ++ if (!mmc_pdata)
34929 ++ goto error;
34931 ++#ifdef CONFIG_MMC_SPI_MODULE
34932 ++ err = request_module("mmc_spi");
34933 ++ if (err) {
34934 ++ printk(KERN_WARNING PFX
34935 ++ "Failed to request mmc_spi module.\n");
34936 ++ }
34937 ++#endif /* CONFIG_MMC_SPI_MODULE */
34939 ++ /* Allocate the GPIO-MMC device */
34940 ++ err = -ENOMEM;
34941 ++ d = kzalloc(sizeof(*d), GFP_KERNEL);
34942 ++ if (!d)
34943 ++ goto error;
34944 ++ d->pdev = pdev;
34946 ++ /* Create the SPI-GPIO device */
34947 ++ d->spi_pdev = platform_device_alloc(SPI_GPIO_PLATDEV_NAME,
34948 ++ spi_gpio_next_id());
34949 ++ if (!d->spi_pdev)
34950 ++ goto err_free_d;
34952 ++ memset(&spi_pdata, 0, sizeof(spi_pdata));
34953 ++ spi_pdata.pin_clk = mmc_pdata->pins.gpio_clk;
34954 ++ spi_pdata.pin_miso = mmc_pdata->pins.gpio_do;
34955 ++ spi_pdata.pin_mosi = mmc_pdata->pins.gpio_di;
34956 ++ spi_pdata.pin_cs = mmc_pdata->pins.gpio_cs;
34957 ++ spi_pdata.cs_activelow = mmc_pdata->pins.cs_activelow;
34958 ++ spi_pdata.no_spi_delay = mmc_pdata->no_spi_delay;
34959 ++ spi_pdata.boardinfo_setup = gpiommc_boardinfo_setup;
34960 ++ spi_pdata.boardinfo_setup_data = d;
34962 ++ err = platform_device_add_data(d->spi_pdev, &spi_pdata,
34963 ++ sizeof(spi_pdata));
34964 ++ if (err)
34965 ++ goto err_free_pdev;
34966 ++ err = platform_device_add(d->spi_pdev);
34967 ++ if (err)
34968 ++ goto err_free_pdata;
34969 ++ platform_set_drvdata(pdev, d);
34971 ++ printk(KERN_INFO PFX "MMC-Card \"%s\" "
34972 ++ "attached to GPIO pins di=%u, do=%u, clk=%u, cs=%u\n",
34973 ++ mmc_pdata->name, mmc_pdata->pins.gpio_di,
34974 ++ mmc_pdata->pins.gpio_do,
34975 ++ mmc_pdata->pins.gpio_clk,
34976 ++ mmc_pdata->pins.gpio_cs);
34978 ++ return 0;
34980 ++err_free_pdata:
34981 ++ kfree(d->spi_pdev->dev.platform_data);
34982 ++ d->spi_pdev->dev.platform_data = NULL;
34983 ++err_free_pdev:
34984 ++ platform_device_put(d->spi_pdev);
34985 ++err_free_d:
34986 ++ kfree(d);
34987 ++error:
34988 ++ return err;
34991 ++static int gpiommc_remove(struct platform_device *pdev)
34993 ++ struct gpiommc_device *d = platform_get_drvdata(pdev);
34994 ++ struct gpiommc_platform_data *pdata = d->pdev->dev.platform_data;
34996 ++ platform_device_unregister(d->spi_pdev);
34997 ++ printk(KERN_INFO PFX "GPIO based MMC-Card \"%s\" removed\n",
34998 ++ pdata->name);
34999 ++ platform_device_put(d->spi_pdev);
35001 ++ return 0;
35004 ++#ifdef CONFIG_GPIOMMC_CONFIGFS
35006 ++/* A device that was created through configfs */
35007 ++struct gpiommc_configfs_device {
35008 ++ struct config_item item;
35009 ++ /* The platform device, after registration. */
35010 ++ struct platform_device *pdev;
35011 ++ /* The configuration */
35012 ++ struct gpiommc_platform_data pdata;
35013 ++};
35015 ++#define GPIO_INVALID -1
35017 ++static inline bool gpiommc_is_registered(struct gpiommc_configfs_device *dev)
35019 ++ return (dev->pdev != NULL);
35022 ++static inline struct gpiommc_configfs_device *ci_to_gpiommc(struct config_item *item)
35024 ++ return item ? container_of(item, struct gpiommc_configfs_device, item) : NULL;
35027 ++static struct configfs_attribute gpiommc_attr_DI = {
35028 ++ .ca_owner = THIS_MODULE,
35029 ++ .ca_name = "gpio_data_in",
35030 ++ .ca_mode = S_IRUGO | S_IWUSR,
35031 ++};
35033 ++static struct configfs_attribute gpiommc_attr_DO = {
35034 ++ .ca_owner = THIS_MODULE,
35035 ++ .ca_name = "gpio_data_out",
35036 ++ .ca_mode = S_IRUGO | S_IWUSR,
35037 ++};
35039 ++static struct configfs_attribute gpiommc_attr_CLK = {
35040 ++ .ca_owner = THIS_MODULE,
35041 ++ .ca_name = "gpio_clock",
35042 ++ .ca_mode = S_IRUGO | S_IWUSR,
35043 ++};
35045 ++static struct configfs_attribute gpiommc_attr_CS = {
35046 ++ .ca_owner = THIS_MODULE,
35047 ++ .ca_name = "gpio_chipselect",
35048 ++ .ca_mode = S_IRUGO | S_IWUSR,
35049 ++};
35051 ++static struct configfs_attribute gpiommc_attr_CS_activelow = {
35052 ++ .ca_owner = THIS_MODULE,
35053 ++ .ca_name = "gpio_chipselect_activelow",
35054 ++ .ca_mode = S_IRUGO | S_IWUSR,
35055 ++};
35057 ++static struct configfs_attribute gpiommc_attr_spimode = {
35058 ++ .ca_owner = THIS_MODULE,
35059 ++ .ca_name = "spi_mode",
35060 ++ .ca_mode = S_IRUGO | S_IWUSR,
35061 ++};
35063 ++static struct configfs_attribute gpiommc_attr_spidelay = {
35064 ++ .ca_owner = THIS_MODULE,
35065 ++ .ca_name = "spi_delay",
35066 ++ .ca_mode = S_IRUGO | S_IWUSR,
35067 ++};
35069 ++static struct configfs_attribute gpiommc_attr_max_bus_speed = {
35070 ++ .ca_owner = THIS_MODULE,
35071 ++ .ca_name = "max_bus_speed",
35072 ++ .ca_mode = S_IRUGO | S_IWUSR,
35073 ++};
35075 ++static struct configfs_attribute gpiommc_attr_register = {
35076 ++ .ca_owner = THIS_MODULE,
35077 ++ .ca_name = "register",
35078 ++ .ca_mode = S_IRUGO | S_IWUSR,
35079 ++};
35081 ++static struct configfs_attribute *gpiommc_config_attrs[] = {
35082 ++ &gpiommc_attr_DI,
35083 ++ &gpiommc_attr_DO,
35084 ++ &gpiommc_attr_CLK,
35085 ++ &gpiommc_attr_CS,
35086 ++ &gpiommc_attr_CS_activelow,
35087 ++ &gpiommc_attr_spimode,
35088 ++ &gpiommc_attr_spidelay,
35089 ++ &gpiommc_attr_max_bus_speed,
35090 ++ &gpiommc_attr_register,
35091 ++ NULL,
35092 ++};
35094 ++static ssize_t gpiommc_config_attr_show(struct config_item *item,
35095 ++ struct configfs_attribute *attr,
35096 ++ char *page)
35098 ++ struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
35099 ++ ssize_t count = 0;
35100 ++ unsigned int gpio;
35101 ++ int err = 0;
35103 ++ if (attr == &gpiommc_attr_DI) {
35104 ++ gpio = dev->pdata.pins.gpio_di;
35105 ++ if (gpio == GPIO_INVALID)
35106 ++ count = snprintf(page, PAGE_SIZE, "not configured\n");
35107 ++ else
35108 ++ count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
35109 ++ goto out;
35110 ++ }
35111 ++ if (attr == &gpiommc_attr_DO) {
35112 ++ gpio = dev->pdata.pins.gpio_do;
35113 ++ if (gpio == GPIO_INVALID)
35114 ++ count = snprintf(page, PAGE_SIZE, "not configured\n");
35115 ++ else
35116 ++ count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
35117 ++ goto out;
35118 ++ }
35119 ++ if (attr == &gpiommc_attr_CLK) {
35120 ++ gpio = dev->pdata.pins.gpio_clk;
35121 ++ if (gpio == GPIO_INVALID)
35122 ++ count = snprintf(page, PAGE_SIZE, "not configured\n");
35123 ++ else
35124 ++ count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
35125 ++ goto out;
35126 ++ }
35127 ++ if (attr == &gpiommc_attr_CS) {
35128 ++ gpio = dev->pdata.pins.gpio_cs;
35129 ++ if (gpio == GPIO_INVALID)
35130 ++ count = snprintf(page, PAGE_SIZE, "not configured\n");
35131 ++ else
35132 ++ count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
35133 ++ goto out;
35134 ++ }
35135 ++ if (attr == &gpiommc_attr_CS_activelow) {
35136 ++ count = snprintf(page, PAGE_SIZE, "%u\n",
35137 ++ dev->pdata.pins.cs_activelow);
35138 ++ goto out;
35139 ++ }
35140 ++ if (attr == &gpiommc_attr_spimode) {
35141 ++ count = snprintf(page, PAGE_SIZE, "%u\n",
35142 ++ dev->pdata.mode);
35143 ++ goto out;
35144 ++ }
35145 ++ if (attr == &gpiommc_attr_spidelay) {
35146 ++ count = snprintf(page, PAGE_SIZE, "%u\n",
35147 ++ !dev->pdata.no_spi_delay);
35148 ++ goto out;
35149 ++ }
35150 ++ if (attr == &gpiommc_attr_max_bus_speed) {
35151 ++ count = snprintf(page, PAGE_SIZE, "%u\n",
35152 ++ dev->pdata.max_bus_speed);
35153 ++ goto out;
35154 ++ }
35155 ++ if (attr == &gpiommc_attr_register) {
35156 ++ count = snprintf(page, PAGE_SIZE, "%u\n",
35157 ++ gpiommc_is_registered(dev));
35158 ++ goto out;
35159 ++ }
35160 ++ WARN_ON(1);
35161 ++ err = -ENOSYS;
35162 ++out:
35163 ++ return err ? err : count;
35166 ++static int gpiommc_do_register(struct gpiommc_configfs_device *dev,
35167 ++ const char *name)
35169 ++ int err;
35171 ++ if (gpiommc_is_registered(dev))
35172 ++ return 0;
35174 ++ if (!gpio_is_valid(dev->pdata.pins.gpio_di) ||
35175 ++ !gpio_is_valid(dev->pdata.pins.gpio_do) ||
35176 ++ !gpio_is_valid(dev->pdata.pins.gpio_clk) ||
35177 ++ !gpio_is_valid(dev->pdata.pins.gpio_cs)) {
35178 ++ printk(KERN_ERR PFX
35179 ++ "configfs: Invalid GPIO pin number(s)\n");
35180 ++ return -EINVAL;
35181 ++ }
35183 ++ strlcpy(dev->pdata.name, name,
35184 ++ sizeof(dev->pdata.name));
35186 ++ dev->pdev = platform_device_alloc(GPIOMMC_PLATDEV_NAME,
35187 ++ gpiommc_next_id());
35188 ++ if (!dev->pdev)
35189 ++ return -ENOMEM;
35190 ++ err = platform_device_add_data(dev->pdev, &dev->pdata,
35191 ++ sizeof(dev->pdata));
35192 ++ if (err) {
35193 ++ platform_device_put(dev->pdev);
35194 ++ return err;
35195 ++ }
35196 ++ err = platform_device_add(dev->pdev);
35197 ++ if (err) {
35198 ++ platform_device_put(dev->pdev);
35199 ++ return err;
35200 ++ }
35202 ++ return 0;
35205 ++static void gpiommc_do_unregister(struct gpiommc_configfs_device *dev)
35207 ++ if (!gpiommc_is_registered(dev))
35208 ++ return;
35210 ++ platform_device_unregister(dev->pdev);
35211 ++ dev->pdev = NULL;
35214 ++static ssize_t gpiommc_config_attr_store(struct config_item *item,
35215 ++ struct configfs_attribute *attr,
35216 ++ const char *page, size_t count)
35218 ++ struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
35219 ++ int err = -EINVAL;
35220 ++ unsigned long data;
35222 ++ if (attr == &gpiommc_attr_register) {
35223 ++ err = kstrtoul(page, 10, &data);
35224 ++ if (err)
35225 ++ goto out;
35226 ++ err = -EINVAL;
35227 ++ if (data == 1)
35228 ++ err = gpiommc_do_register(dev, item->ci_name);
35229 ++ if (data == 0) {
35230 ++ gpiommc_do_unregister(dev);
35231 ++ err = 0;
35232 ++ }
35233 ++ goto out;
35234 ++ }
35236 ++ if (gpiommc_is_registered(dev)) {
35237 ++ /* The rest of the config parameters can only be set
35238 ++ * as long as the device is not registered, yet. */
35239 ++ err = -EBUSY;
35240 ++ goto out;
35241 ++ }
35243 ++ if (attr == &gpiommc_attr_DI) {
35244 ++ err = kstrtoul(page, 10, &data);
35245 ++ if (err)
35246 ++ goto out;
35247 ++ err = -EINVAL;
35248 ++ if (!gpio_is_valid(data))
35249 ++ goto out;
35250 ++ dev->pdata.pins.gpio_di = data;
35251 ++ err = 0;
35252 ++ goto out;
35253 ++ }
35254 ++ if (attr == &gpiommc_attr_DO) {
35255 ++ err = kstrtoul(page, 10, &data);
35256 ++ if (err)
35257 ++ goto out;
35258 ++ err = -EINVAL;
35259 ++ if (!gpio_is_valid(data))
35260 ++ goto out;
35261 ++ dev->pdata.pins.gpio_do = data;
35262 ++ err = 0;
35263 ++ goto out;
35264 ++ }
35265 ++ if (attr == &gpiommc_attr_CLK) {
35266 ++ err = kstrtoul(page, 10, &data);
35267 ++ if (err)
35268 ++ goto out;
35269 ++ err = -EINVAL;
35270 ++ if (!gpio_is_valid(data))
35271 ++ goto out;
35272 ++ dev->pdata.pins.gpio_clk = data;
35273 ++ err = 0;
35274 ++ goto out;
35275 ++ }
35276 ++ if (attr == &gpiommc_attr_CS) {
35277 ++ err = kstrtoul(page, 10, &data);
35278 ++ if (err)
35279 ++ goto out;
35280 ++ err = -EINVAL;
35281 ++ if (!gpio_is_valid(data))
35282 ++ goto out;
35283 ++ dev->pdata.pins.gpio_cs = data;
35284 ++ err = 0;
35285 ++ goto out;
35286 ++ }
35287 ++ if (attr == &gpiommc_attr_CS_activelow) {
35288 ++ err = kstrtoul(page, 10, &data);
35289 ++ if (err)
35290 ++ goto out;
35291 ++ err = -EINVAL;
35292 ++ if (data != 0 && data != 1)
35293 ++ goto out;
35294 ++ dev->pdata.pins.cs_activelow = data;
35295 ++ err = 0;
35296 ++ goto out;
35297 ++ }
35298 ++ if (attr == &gpiommc_attr_spimode) {
35299 ++ err = kstrtoul(page, 10, &data);
35300 ++ if (err)
35301 ++ goto out;
35302 ++ err = -EINVAL;
35303 ++ switch (data) {
35304 ++ case 0:
35305 ++ dev->pdata.mode = SPI_MODE_0;
35306 ++ break;
35307 ++ case 1:
35308 ++ dev->pdata.mode = SPI_MODE_1;
35309 ++ break;
35310 ++ case 2:
35311 ++ dev->pdata.mode = SPI_MODE_2;
35312 ++ break;
35313 ++ case 3:
35314 ++ dev->pdata.mode = SPI_MODE_3;
35315 ++ break;
35316 ++ default:
35317 ++ goto out;
35318 ++ }
35319 ++ err = 0;
35320 ++ goto out;
35321 ++ }
35322 ++ if (attr == &gpiommc_attr_spidelay) {
35323 ++ err = kstrtoul(page, 10, &data);
35324 ++ if (err)
35325 ++ goto out;
35326 ++ err = -EINVAL;
35327 ++ if (data != 0 && data != 1)
35328 ++ goto out;
35329 ++ dev->pdata.no_spi_delay = !data;
35330 ++ err = 0;
35331 ++ goto out;
35332 ++ }
35333 ++ if (attr == &gpiommc_attr_max_bus_speed) {
35334 ++ err = kstrtoul(page, 10, &data);
35335 ++ if (err)
35336 ++ goto out;
35337 ++ err = -EINVAL;
35338 ++ if (data > UINT_MAX)
35339 ++ goto out;
35340 ++ dev->pdata.max_bus_speed = data;
35341 ++ err = 0;
35342 ++ goto out;
35343 ++ }
35344 ++ WARN_ON(1);
35345 ++ err = -ENOSYS;
35346 ++out:
35347 ++ return err ? err : count;
35350 ++static void gpiommc_config_item_release(struct config_item *item)
35352 ++ struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
35354 ++ kfree(dev);
35357 ++static struct configfs_item_operations gpiommc_config_item_ops = {
35358 ++ .release = gpiommc_config_item_release,
35359 ++ .show_attribute = gpiommc_config_attr_show,
35360 ++ .store_attribute = gpiommc_config_attr_store,
35361 ++};
35363 ++static struct config_item_type gpiommc_dev_ci_type = {
35364 ++ .ct_item_ops = &gpiommc_config_item_ops,
35365 ++ .ct_attrs = gpiommc_config_attrs,
35366 ++ .ct_owner = THIS_MODULE,
35367 ++};
35369 ++static struct config_item *gpiommc_make_item(struct config_group *group,
35370 ++ const char *name)
35372 ++ struct gpiommc_configfs_device *dev;
35374 ++ if (strlen(name) > GPIOMMC_MAX_NAMELEN) {
35375 ++ printk(KERN_ERR PFX "configfs: device name too long\n");
35376 ++ return NULL;
35377 ++ }
35379 ++ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
35380 ++ if (!dev)
35381 ++ return NULL;
35383 ++ config_item_init_type_name(&dev->item, name,
35384 ++ &gpiommc_dev_ci_type);
35386 ++ /* Assign default configuration */
35387 ++ dev->pdata.pins.gpio_di = GPIO_INVALID;
35388 ++ dev->pdata.pins.gpio_do = GPIO_INVALID;
35389 ++ dev->pdata.pins.gpio_clk = GPIO_INVALID;
35390 ++ dev->pdata.pins.gpio_cs = GPIO_INVALID;
35391 ++ dev->pdata.pins.cs_activelow = 1;
35392 ++ dev->pdata.mode = SPI_MODE_0;
35393 ++ dev->pdata.no_spi_delay = 0;
35394 ++ dev->pdata.max_bus_speed = 5000000; /* 5 MHz */
35396 ++ return &(dev->item);
35399 ++static void gpiommc_drop_item(struct config_group *group,
35400 ++ struct config_item *item)
35402 ++ struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
35404 ++ gpiommc_do_unregister(dev);
35405 ++ kfree(dev);
35408 ++static struct configfs_group_operations gpiommc_ct_group_ops = {
35409 ++ .make_item = gpiommc_make_item,
35410 ++ .drop_item = gpiommc_drop_item,
35411 ++};
35413 ++static struct config_item_type gpiommc_ci_type = {
35414 ++ .ct_group_ops = &gpiommc_ct_group_ops,
35415 ++ .ct_owner = THIS_MODULE,
35416 ++};
35418 ++static struct configfs_subsystem gpiommc_subsys = {
35419 ++ .su_group = {
35420 ++ .cg_item = {
35421 ++ .ci_namebuf = GPIOMMC_PLATDEV_NAME,
35422 ++ .ci_type = &gpiommc_ci_type,
35423 ++ },
35424 ++ },
35425 ++ .su_mutex = __MUTEX_INITIALIZER(gpiommc_subsys.su_mutex),
35426 ++};
35428 ++#endif /* CONFIG_GPIOMMC_CONFIGFS */
35430 ++static struct platform_driver gpiommc_plat_driver = {
35431 ++ .probe = gpiommc_probe,
35432 ++ .remove = gpiommc_remove,
35433 ++ .driver = {
35434 ++ .name = GPIOMMC_PLATDEV_NAME,
35435 ++ .owner = THIS_MODULE,
35436 ++ },
35437 ++};
35439 ++int gpiommc_next_id(void)
35441 ++ static atomic_t counter = ATOMIC_INIT(-1);
35443 ++ return atomic_inc_return(&counter);
35445 ++EXPORT_SYMBOL(gpiommc_next_id);
35447 ++static int __init gpiommc_modinit(void)
35449 ++ int err;
35451 ++ err = platform_driver_register(&gpiommc_plat_driver);
35452 ++ if (err)
35453 ++ return err;
35455 ++#ifdef CONFIG_GPIOMMC_CONFIGFS
35456 ++ config_group_init(&gpiommc_subsys.su_group);
35457 ++ err = configfs_register_subsystem(&gpiommc_subsys);
35458 ++ if (err) {
35459 ++ platform_driver_unregister(&gpiommc_plat_driver);
35460 ++ return err;
35461 ++ }
35462 ++#endif /* CONFIG_GPIOMMC_CONFIGFS */
35464 ++ return 0;
35466 ++module_init(gpiommc_modinit);
35468 ++static void __exit gpiommc_modexit(void)
35470 ++#ifdef CONFIG_GPIOMMC_CONFIGFS
35471 ++ configfs_unregister_subsystem(&gpiommc_subsys);
35472 ++#endif
35473 ++ platform_driver_unregister(&gpiommc_plat_driver);
35475 ++module_exit(gpiommc_modexit);
35476 +--- a/drivers/mmc/host/Kconfig
35477 ++++ b/drivers/mmc/host/Kconfig
35478 +@@ -498,6 +498,31 @@ config MMC_SDHI
35479 + This provides support for the SDHI SD/SDIO controller found in
35480 + SuperH and ARM SH-Mobile SoCs
35482 ++config GPIOMMC
35483 ++ tristate "MMC/SD over GPIO-based SPI"
35484 ++ depends on MMC && MMC_SPI && SPI_GPIO_OLD
35485 ++ help
35486 ++ This driver hooks up the mmc_spi and spi_gpio modules so that
35487 ++ MMC/SD cards can be used on a GPIO based bus by bitbanging
35488 ++ the SPI protocol in software.
35490 ++ This driver provides a configfs interface to dynamically create
35491 ++ and destroy GPIO-based MMC/SD card devices. It also provides
35492 ++ a platform device interface API.
35493 ++ See Documentation/gpiommc.txt for details.
35495 ++ The module will be called gpiommc.
35497 ++ If unsure, say N.
35499 ++config GPIOMMC_CONFIGFS
35500 ++ bool
35501 ++ depends on GPIOMMC && CONFIGFS_FS
35502 ++ default y
35503 ++ help
35504 ++ This option automatically enables configfs support for gpiommc
35505 ++ if configfs is available.
35507 + config MMC_CB710
35508 + tristate "ENE CB710 MMC/SD Interface support"
35509 + depends on PCI
35510 +--- a/drivers/mmc/host/Makefile
35511 ++++ b/drivers/mmc/host/Makefile
35512 +@@ -39,6 +39,7 @@ tmio_mmc_core-$(subst m,y,$(CONFIG_MMC_S
35513 + obj-$(CONFIG_MMC_SDHI) += sh_mobile_sdhi.o
35514 + obj-$(CONFIG_MMC_CB710) += cb710-mmc.o
35515 + obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o
35516 ++obj-$(CONFIG_GPIOMMC) += gpiommc.o
35517 + obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o
35518 + obj-$(CONFIG_MMC_DW) += dw_mmc.o
35519 + obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o
35520 +--- /dev/null
35521 ++++ b/include/linux/mmc/gpiommc.h
35522 +@@ -0,0 +1,71 @@
35523 ++/*
35524 ++ * Device driver for MMC/SD cards driven over a GPIO bus.
35525 ++ *
35526 ++ * Copyright (c) 2008 Michael Buesch
35527 ++ *
35528 ++ * Licensed under the GNU/GPL version 2.
35529 ++ */
35530 ++#ifndef LINUX_GPIOMMC_H_
35531 ++#define LINUX_GPIOMMC_H_
35533 ++#include <linux/types.h>
35536 ++#define GPIOMMC_MAX_NAMELEN 15
35537 ++#define GPIOMMC_MAX_NAMELEN_STR __stringify(GPIOMMC_MAX_NAMELEN)
35539 ++/**
35540 ++ * struct gpiommc_pins - Hardware pin assignments
35541 ++ *
35542 ++ * @gpio_di: The GPIO number of the DATA IN pin
35543 ++ * @gpio_do: The GPIO number of the DATA OUT pin
35544 ++ * @gpio_clk: The GPIO number of the CLOCK pin
35545 ++ * @gpio_cs: The GPIO number of the CHIPSELECT pin
35546 ++ * @cs_activelow: If true, the chip is considered selected if @gpio_cs is low.
35547 ++ */
35548 ++struct gpiommc_pins {
35549 ++ unsigned int gpio_di;
35550 ++ unsigned int gpio_do;
35551 ++ unsigned int gpio_clk;
35552 ++ unsigned int gpio_cs;
35553 ++ bool cs_activelow;
35554 ++};
35556 ++/**
35557 ++ * struct gpiommc_platform_data - Platform data for a MMC-over-SPI-GPIO device.
35558 ++ *
35559 ++ * @name: The unique name string of the device.
35560 ++ * @pins: The hardware pin assignments.
35561 ++ * @mode: The hardware mode. This is either SPI_MODE_0,
35562 ++ * SPI_MODE_1, SPI_MODE_2 or SPI_MODE_3. See the SPI documentation.
35563 ++ * @no_spi_delay: Do not use delays in the lowlevel SPI bitbanging code.
35564 ++ * This is not standards compliant, but may be required for some
35565 ++ * embedded machines to gain reasonable speed.
35566 ++ * @max_bus_speed: The maximum speed of the SPI bus, in Hertz.
35567 ++ */
35568 ++struct gpiommc_platform_data {
35569 ++ char name[GPIOMMC_MAX_NAMELEN + 1];
35570 ++ struct gpiommc_pins pins;
35571 ++ u8 mode;
35572 ++ bool no_spi_delay;
35573 ++ unsigned int max_bus_speed;
35574 ++};
35576 ++/**
35577 ++ * GPIOMMC_PLATDEV_NAME - The platform device name string.
35578 ++ *
35579 ++ * The name string that has to be used for platform_device_alloc
35580 ++ * when allocating a gpiommc device.
35581 ++ */
35582 ++#define GPIOMMC_PLATDEV_NAME "gpiommc"
35584 ++/**
35585 ++ * gpiommc_next_id - Get another platform device ID number.
35586 ++ *
35587 ++ * This returns the next platform device ID number that has to be used
35588 ++ * for platform_device_alloc. The ID is opaque and should not be used for
35589 ++ * anything else.
35590 ++ */
35591 ++int gpiommc_next_id(void);
35593 ++#endif /* LINUX_GPIOMMC_H_ */
35594 +--- /dev/null
35595 ++++ b/Documentation/gpiommc.txt
35596 +@@ -0,0 +1,97 @@
35597 ++GPIOMMC - Driver for an MMC/SD card on a bitbanging GPIO SPI bus
35598 ++================================================================
35600 ++The gpiommc module hooks up the mmc_spi and spi_gpio modules for running an
35601 ++MMC or SD card on GPIO pins.
35603 ++Two interfaces for registering a new MMC/SD card device are provided:
35604 ++A static platform-device based mechanism and a dynamic configfs based interface.
35607 ++Registering devices via platform-device
35608 ++=======================================
35610 ++The platform-device interface is used for registering MMC/SD devices that are
35611 ++part of the hardware platform. This is most useful only for embedded machines
35612 ++with MMC/SD devices statically connected to the platform GPIO bus.
35614 ++The data structures are declared in <linux/mmc/gpiommc.h>.
35616 ++To register a new device, define an instance of struct gpiommc_platform_data.
35617 ++This structure holds any information about how the device is hooked up to the
35618 ++GPIO pins and what hardware modes the device supports. See the docbook-style
35619 ++documentation in the header file for more information on the struct fields.
35621 ++Then allocate a new instance of a platform device by doing:
35623 ++ pdev = platform_device_alloc(GPIOMMC_PLATDEV_NAME, gpiommc_next_id());
35625 ++This will allocate the platform device data structures and hook it up to the
35626 ++gpiommc driver.
35627 ++Then add the gpiommc_platform_data to the platform device.
35629 ++ err = platform_device_add_data(pdev, pdata, sizeof(struct gpiommc_platform_data));
35631 ++You may free the local instance of struct gpiommc_platform_data now. (So the
35632 ++struct may be allocated on the stack, too).
35633 ++Now simply register the platform device.
35635 ++ err = platform_device_add(pdev);
35637 ++Done. The gpiommc probe routine will be invoked now and you should see a kernel
35638 ++log message for the added device.
35641 ++Registering devices via configfs
35642 ++================================
35644 ++MMC/SD cards connected via GPIO often are a pretty dynamic thing, as for example
35645 ++selfmade hacks for soldering an MMC/SD card to standard GPIO pins on embedded
35646 ++hardware are a common situation.
35647 ++So we provide a dynamic interface to conveniently handle adding and removing
35648 ++devices from userspace, without the need to recompile the kernel.
35650 ++The "gpiommc" subdirectory at the configfs mountpoint is used for handling
35651 ++the dynamic configuration.
35653 ++To create a new device, it must first be allocated with mkdir.
35654 ++The following command will allocate a device named "my_mmc":
35655 ++ mkdir /config/gpiommc/my_mmc
35657 ++There are several configuration files available in the new
35658 ++/config/gpiommc/my_mmc/ directory:
35660 ++gpio_data_in = The SPI data-IN GPIO pin number.
35661 ++gpio_data_out = The SPI data-OUT GPIO pin number.
35662 ++gpio_clock = The SPI Clock GPIO pin number.
35663 ++gpio_chipselect = The SPI Chipselect GPIO pin number.
35664 ++gpio_chipselect_activelow = Boolean. If 0, Chipselect is active-HIGH.
35665 ++ If 1, Chipselect is active-LOW.
35666 ++spi_mode = The SPI data mode. Can be 0-3.
35667 ++spi_delay = Enable all delays in the lowlevel bitbanging.
35668 ++max_bus_speed = The maximum SPI bus speed. In Hertz.
35670 ++register = Not a configuration parameter.
35671 ++ Used to register the configured card
35672 ++ with the kernel.
35674 ++The device must first get configured and then registered by writing "1" to
35675 ++the "register" file.
35676 ++The configuration parameters "gpio_data_in", "gpio_data_out", "gpio_clock"
35677 ++and "gpio_chipselect" are essential and _must_ be configured before writing
35678 ++"1" to the "register" file. The registration will fail, otherwise.
35680 ++The default values for the other parameters are:
35681 ++gpio_chipselect_activelow = 1 (CS active-LOW)
35682 ++spi_mode = 0 (SPI_MODE_0)
35683 ++spi_delay = 1 (enabled)
35684 ++max_bus_speed = 5000000 (5 Mhz)
35686 ++Configuration values can not be changed after registration. To unregister
35687 ++the device, write a "0" to the "register" file. The configuration can be
35688 ++changed again after unregistering.
35690 ++To completely remove the device, simply rmdir the directory
35691 ++(/config/gpiommc/my_mmc in this example).
35692 ++There's no need to first unregister the device before removing it. That will
35693 ++be done automatically.
35694 +--- a/MAINTAINERS
35695 ++++ b/MAINTAINERS
35696 +@@ -3935,6 +3935,11 @@ L: linuxppc-dev@lists.ozlabs.org
35697 + S: Odd Fixes
35698 + F: drivers/tty/hvc/
35700 ++GPIOMMC DRIVER
35701 ++P: Michael Buesch
35702 ++M: mb@bu3sch.de
35703 ++S: Maintained
35705 + HARDWARE MONITORING
35706 + M: Jean Delvare <jdelvare@suse.de>
35707 + M: Guenter Roeck <linux@roeck-us.net>
35708 diff --git a/target/linux/generic/patches-3.16/864-gpiommc_configfs_locking.patch b/target/linux/generic/patches-3.16/864-gpiommc_configfs_locking.patch
35709 new file mode 100644
35710 index 000000000000..92815d91f4cd
35711 --- /dev/null
35712 +++ b/target/linux/generic/patches-3.16/864-gpiommc_configfs_locking.patch
35713 @@ -0,0 +1,58 @@
35714 +The gpiommc configfs context structure needs locking, as configfs
35715 +does not lock access between files.
35717 +--- a/drivers/mmc/host/gpiommc.c
35718 ++++ b/drivers/mmc/host/gpiommc.c
35719 +@@ -144,6 +144,8 @@ struct gpiommc_configfs_device {
35720 + struct platform_device *pdev;
35721 + /* The configuration */
35722 + struct gpiommc_platform_data pdata;
35723 ++ /* Mutex to protect this structure */
35724 ++ struct mutex mutex;
35725 + };
35727 + #define GPIO_INVALID -1
35728 +@@ -234,6 +236,8 @@ static ssize_t gpiommc_config_attr_show(
35729 + unsigned int gpio;
35730 + int err = 0;
35732 ++ mutex_lock(&dev->mutex);
35734 + if (attr == &gpiommc_attr_DI) {
35735 + gpio = dev->pdata.pins.gpio_di;
35736 + if (gpio == GPIO_INVALID)
35737 +@@ -294,6 +298,8 @@ static ssize_t gpiommc_config_attr_show(
35738 + WARN_ON(1);
35739 + err = -ENOSYS;
35740 + out:
35741 ++ mutex_unlock(&dev->mutex);
35743 + return err ? err : count;
35746 +@@ -353,6 +359,8 @@ static ssize_t gpiommc_config_attr_store
35747 + int err = -EINVAL;
35748 + unsigned long data;
35750 ++ mutex_lock(&dev->mutex);
35752 + if (attr == &gpiommc_attr_register) {
35753 + err = kstrtoul(page, 10, &data);
35754 + if (err)
35755 +@@ -478,6 +486,8 @@ static ssize_t gpiommc_config_attr_store
35756 + WARN_ON(1);
35757 + err = -ENOSYS;
35758 + out:
35759 ++ mutex_unlock(&dev->mutex);
35761 + return err ? err : count;
35764 +@@ -514,6 +524,7 @@ static struct config_item *gpiommc_make_
35765 + if (!dev)
35766 + return NULL;
35768 ++ mutex_init(&dev->mutex);
35769 + config_item_init_type_name(&dev->item, name,
35770 + &gpiommc_dev_ci_type);
35772 diff --git a/target/linux/generic/patches-3.16/870-hifn795x_byteswap.patch b/target/linux/generic/patches-3.16/870-hifn795x_byteswap.patch
35773 new file mode 100644
35774 index 000000000000..3a37c951ec00
35775 --- /dev/null
35776 +++ b/target/linux/generic/patches-3.16/870-hifn795x_byteswap.patch
35777 @@ -0,0 +1,17 @@
35778 +--- a/drivers/crypto/hifn_795x.c
35779 ++++ b/drivers/crypto/hifn_795x.c
35780 +@@ -682,12 +682,12 @@ static inline u32 hifn_read_1(struct hif
35782 + static inline void hifn_write_0(struct hifn_device *dev, u32 reg, u32 val)
35784 +- writel((__force u32)cpu_to_le32(val), dev->bar[0] + reg);
35785 ++ writel(val, dev->bar[0] + reg);
35788 + static inline void hifn_write_1(struct hifn_device *dev, u32 reg, u32 val)
35790 +- writel((__force u32)cpu_to_le32(val), dev->bar[1] + reg);
35791 ++ writel(val, dev->bar[1] + reg);
35794 + static void hifn_wait_puc(struct hifn_device *dev)
35795 diff --git a/target/linux/generic/patches-3.16/880-gateworks_system_controller.patch b/target/linux/generic/patches-3.16/880-gateworks_system_controller.patch
35796 new file mode 100644
35797 index 000000000000..6e4ae3080984
35798 --- /dev/null
35799 +++ b/target/linux/generic/patches-3.16/880-gateworks_system_controller.patch
35800 @@ -0,0 +1,339 @@
35801 +--- a/drivers/hwmon/Kconfig
35802 ++++ b/drivers/hwmon/Kconfig
35803 +@@ -492,6 +492,15 @@ config SENSORS_GL520SM
35804 + This driver can also be built as a module. If so, the module
35805 + will be called gl520sm.
35807 ++config SENSORS_GSC
35808 ++ tristate "Gateworks System Controller"
35809 ++ depends on I2C
35810 ++ help
35811 ++ If you say yes here you get support for the Gateworks System Controller.
35813 ++ This driver can also be built as a module. If so, the module
35814 ++ will be called gsc.
35816 + config SENSORS_GPIO_FAN
35817 + tristate "GPIO fan"
35818 + depends on GPIOLIB
35819 +--- a/drivers/hwmon/Makefile
35820 ++++ b/drivers/hwmon/Makefile
35821 +@@ -142,6 +142,7 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l7
35822 + obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o
35823 + obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o
35824 + obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o
35825 ++obj-$(CONFIG_SENSORS_GSC) += gsc.o
35827 + obj-$(CONFIG_PMBUS) += pmbus/
35829 +--- /dev/null
35830 ++++ b/drivers/hwmon/gsc.c
35831 +@@ -0,0 +1,308 @@
35832 ++/*
35833 ++ * A hwmon driver for the Gateworks System Controller
35834 ++ * Copyright (C) 2009 Gateworks Corporation
35835 ++ *
35836 ++ * Author: Chris Lang <clang@gateworks.com>
35837 ++ *
35838 ++ * This program is free software; you can redistribute it and/or modify
35839 ++ * it under the terms of the GNU General Public License,
35840 ++ * as published by the Free Software Foundation - version 2.
35841 ++ */
35843 ++#include <linux/module.h>
35844 ++#include <linux/i2c.h>
35845 ++#include <linux/hwmon.h>
35846 ++#include <linux/hwmon-sysfs.h>
35847 ++#include <linux/err.h>
35848 ++#include <linux/slab.h>
35850 ++#define DRV_VERSION "0.2"
35852 ++enum chips { gsp };
35854 ++/* AD7418 registers */
35855 ++#define GSP_REG_TEMP_IN 0x00
35856 ++#define GSP_REG_VIN 0x02
35857 ++#define GSP_REG_3P3 0x05
35858 ++#define GSP_REG_BAT 0x08
35859 ++#define GSP_REG_5P0 0x0b
35860 ++#define GSP_REG_CORE 0x0e
35861 ++#define GSP_REG_CPU1 0x11
35862 ++#define GSP_REG_CPU2 0x14
35863 ++#define GSP_REG_DRAM 0x17
35864 ++#define GSP_REG_EXT_BAT 0x1a
35865 ++#define GSP_REG_IO1 0x1d
35866 ++#define GSP_REG_IO2 0x20
35867 ++#define GSP_REG_PCIE 0x23
35868 ++#define GSP_REG_CURRENT 0x26
35869 ++#define GSP_FAN_0 0x2C
35870 ++#define GSP_FAN_1 0x2E
35871 ++#define GSP_FAN_2 0x30
35872 ++#define GSP_FAN_3 0x32
35873 ++#define GSP_FAN_4 0x34
35874 ++#define GSP_FAN_5 0x36
35876 ++struct gsp_sensor_info {
35877 ++ const char* name;
35878 ++ int reg;
35879 ++};
35881 ++static const struct gsp_sensor_info gsp_sensors[] = {
35882 ++ {"temp", GSP_REG_TEMP_IN},
35883 ++ {"vin", GSP_REG_VIN},
35884 ++ {"3p3", GSP_REG_3P3},
35885 ++ {"bat", GSP_REG_BAT},
35886 ++ {"5p0", GSP_REG_5P0},
35887 ++ {"core", GSP_REG_CORE},
35888 ++ {"cpu1", GSP_REG_CPU1},
35889 ++ {"cpu2", GSP_REG_CPU2},
35890 ++ {"dram", GSP_REG_DRAM},
35891 ++ {"ext_bat", GSP_REG_EXT_BAT},
35892 ++ {"io1", GSP_REG_IO1},
35893 ++ {"io2", GSP_REG_IO2},
35894 ++ {"pci2", GSP_REG_PCIE},
35895 ++ {"current", GSP_REG_CURRENT},
35896 ++ {"fan_point0", GSP_FAN_0},
35897 ++ {"fan_point1", GSP_FAN_1},
35898 ++ {"fan_point2", GSP_FAN_2},
35899 ++ {"fan_point3", GSP_FAN_3},
35900 ++ {"fan_point4", GSP_FAN_4},
35901 ++ {"fan_point5", GSP_FAN_5},
35902 ++};
35904 ++struct gsp_data {
35905 ++ struct device *hwmon_dev;
35906 ++ struct attribute_group attrs;
35907 ++ enum chips type;
35908 ++};
35910 ++static int gsp_probe(struct i2c_client *client,
35911 ++ const struct i2c_device_id *id);
35912 ++static int gsp_remove(struct i2c_client *client);
35914 ++static const struct i2c_device_id gsp_id[] = {
35915 ++ { "gsp", 0 },
35916 ++ { }
35917 ++};
35918 ++MODULE_DEVICE_TABLE(i2c, gsp_id);
35920 ++static struct i2c_driver gsp_driver = {
35921 ++ .driver = {
35922 ++ .name = "gsp",
35923 ++ },
35924 ++ .probe = gsp_probe,
35925 ++ .remove = gsp_remove,
35926 ++ .id_table = gsp_id,
35927 ++};
35929 ++/* All registers are word-sized, except for the configuration registers.
35930 ++ * AD7418 uses a high-byte first convention. Do NOT use those functions to
35931 ++ * access the configuration registers CONF and CONF2, as they are byte-sized.
35932 ++ */
35933 ++static inline int gsp_read(struct i2c_client *client, u8 reg)
35935 ++ unsigned int adc = 0;
35936 ++ if (reg == GSP_REG_TEMP_IN || reg > GSP_REG_CURRENT)
35937 ++ {
35938 ++ adc |= i2c_smbus_read_byte_data(client, reg);
35939 ++ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8;
35940 ++ return adc;
35941 ++ }
35942 ++ else
35943 ++ {
35944 ++ adc |= i2c_smbus_read_byte_data(client, reg);
35945 ++ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8;
35946 ++ adc |= i2c_smbus_read_byte_data(client, reg + 2) << 16;
35947 ++ return adc;
35948 ++ }
35951 ++static inline int gsp_write(struct i2c_client *client, u8 reg, u16 value)
35953 ++ i2c_smbus_write_byte_data(client, reg, value & 0xff);
35954 ++ i2c_smbus_write_byte_data(client, reg + 1, ((value >> 8) & 0xff));
35955 ++ return 1;
35958 ++static ssize_t show_adc(struct device *dev, struct device_attribute *devattr,
35959 ++ char *buf)
35961 ++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
35962 ++ struct i2c_client *client = to_i2c_client(dev);
35963 ++ return sprintf(buf, "%d\n", gsp_read(client, gsp_sensors[attr->index].reg));
35966 ++static ssize_t show_label(struct device *dev,
35967 ++ struct device_attribute *devattr, char *buf)
35969 ++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
35971 ++ return sprintf(buf, "%s\n", gsp_sensors[attr->index].name);
35974 ++static ssize_t store_fan(struct device *dev,
35975 ++ struct device_attribute *devattr, const char *buf, size_t count)
35977 ++ u16 val;
35978 ++ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
35979 ++ struct i2c_client *client = to_i2c_client(dev);
35980 ++ val = simple_strtoul(buf, NULL, 10);
35981 ++ gsp_write(client, gsp_sensors[attr->index].reg, val);
35982 ++ return count;
35985 ++static SENSOR_DEVICE_ATTR(temp0_input, S_IRUGO, show_adc, NULL, 0);
35986 ++static SENSOR_DEVICE_ATTR(temp0_label, S_IRUGO, show_label, NULL, 0);
35988 ++static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_adc, NULL, 1);
35989 ++static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, 1);
35990 ++static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 2);
35991 ++static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, 2);
35992 ++static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 3);
35993 ++static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, 3);
35994 ++static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 4);
35995 ++static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 4);
35996 ++static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 5);
35997 ++static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, 5);
35998 ++static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_adc, NULL, 6);
35999 ++static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, 6);
36000 ++static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_adc, NULL, 7);
36001 ++static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, 7);
36002 ++static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_adc, NULL, 8);
36003 ++static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 8);
36004 ++static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_adc, NULL, 9);
36005 ++static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 9);
36006 ++static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_adc, NULL, 10);
36007 ++static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 10);
36008 ++static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_adc, NULL, 11);
36009 ++static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_label, NULL, 11);
36010 ++static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_adc, NULL, 12);
36011 ++static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_label, NULL, 12);
36012 ++static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_adc, NULL, 13);
36013 ++static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_label, NULL, 13);
36015 ++static SENSOR_DEVICE_ATTR(fan0_point0, S_IRUGO | S_IWUSR, show_adc, store_fan, 14);
36016 ++static SENSOR_DEVICE_ATTR(fan0_point1, S_IRUGO | S_IWUSR, show_adc, store_fan, 15);
36017 ++static SENSOR_DEVICE_ATTR(fan0_point2, S_IRUGO | S_IWUSR, show_adc, store_fan, 16);
36018 ++static SENSOR_DEVICE_ATTR(fan0_point3, S_IRUGO | S_IWUSR, show_adc, store_fan, 17);
36019 ++static SENSOR_DEVICE_ATTR(fan0_point4, S_IRUGO | S_IWUSR, show_adc, store_fan, 18);
36020 ++static SENSOR_DEVICE_ATTR(fan0_point5, S_IRUGO | S_IWUSR, show_adc, store_fan, 19);
36022 ++static struct attribute *gsp_attributes[] = {
36023 ++ &sensor_dev_attr_temp0_input.dev_attr.attr,
36024 ++ &sensor_dev_attr_in0_input.dev_attr.attr,
36025 ++ &sensor_dev_attr_in1_input.dev_attr.attr,
36026 ++ &sensor_dev_attr_in2_input.dev_attr.attr,
36027 ++ &sensor_dev_attr_in3_input.dev_attr.attr,
36028 ++ &sensor_dev_attr_in4_input.dev_attr.attr,
36029 ++ &sensor_dev_attr_in5_input.dev_attr.attr,
36030 ++ &sensor_dev_attr_in6_input.dev_attr.attr,
36031 ++ &sensor_dev_attr_in7_input.dev_attr.attr,
36032 ++ &sensor_dev_attr_in8_input.dev_attr.attr,
36033 ++ &sensor_dev_attr_in9_input.dev_attr.attr,
36034 ++ &sensor_dev_attr_in10_input.dev_attr.attr,
36035 ++ &sensor_dev_attr_in11_input.dev_attr.attr,
36036 ++ &sensor_dev_attr_in12_input.dev_attr.attr,
36038 ++ &sensor_dev_attr_temp0_label.dev_attr.attr,
36039 ++ &sensor_dev_attr_in0_label.dev_attr.attr,
36040 ++ &sensor_dev_attr_in1_label.dev_attr.attr,
36041 ++ &sensor_dev_attr_in2_label.dev_attr.attr,
36042 ++ &sensor_dev_attr_in3_label.dev_attr.attr,
36043 ++ &sensor_dev_attr_in4_label.dev_attr.attr,
36044 ++ &sensor_dev_attr_in5_label.dev_attr.attr,
36045 ++ &sensor_dev_attr_in6_label.dev_attr.attr,
36046 ++ &sensor_dev_attr_in7_label.dev_attr.attr,
36047 ++ &sensor_dev_attr_in8_label.dev_attr.attr,
36048 ++ &sensor_dev_attr_in9_label.dev_attr.attr,
36049 ++ &sensor_dev_attr_in10_label.dev_attr.attr,
36050 ++ &sensor_dev_attr_in11_label.dev_attr.attr,
36051 ++ &sensor_dev_attr_in12_label.dev_attr.attr,
36053 ++ &sensor_dev_attr_fan0_point0.dev_attr.attr,
36054 ++ &sensor_dev_attr_fan0_point1.dev_attr.attr,
36055 ++ &sensor_dev_attr_fan0_point2.dev_attr.attr,
36056 ++ &sensor_dev_attr_fan0_point3.dev_attr.attr,
36057 ++ &sensor_dev_attr_fan0_point4.dev_attr.attr,
36058 ++ &sensor_dev_attr_fan0_point5.dev_attr.attr,
36059 ++ NULL
36060 ++};
36063 ++static int gsp_probe(struct i2c_client *client,
36064 ++ const struct i2c_device_id *id)
36066 ++ struct i2c_adapter *adapter = client->adapter;
36067 ++ struct gsp_data *data;
36068 ++ int err;
36070 ++ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
36071 ++ I2C_FUNC_SMBUS_WORD_DATA)) {
36072 ++ err = -EOPNOTSUPP;
36073 ++ goto exit;
36074 ++ }
36076 ++ if (!(data = kzalloc(sizeof(struct gsp_data), GFP_KERNEL))) {
36077 ++ err = -ENOMEM;
36078 ++ goto exit;
36079 ++ }
36081 ++ i2c_set_clientdata(client, data);
36083 ++ data->type = id->driver_data;
36085 ++ switch (data->type) {
36086 ++ case 0:
36087 ++ data->attrs.attrs = gsp_attributes;
36088 ++ break;
36089 ++ }
36091 ++ dev_info(&client->dev, "%s chip found\n", client->name);
36093 ++ /* Register sysfs hooks */
36094 ++ if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs)))
36095 ++ goto exit_free;
36097 ++ data->hwmon_dev = hwmon_device_register(&client->dev);
36098 ++ if (IS_ERR(data->hwmon_dev)) {
36099 ++ err = PTR_ERR(data->hwmon_dev);
36100 ++ goto exit_remove;
36101 ++ }
36103 ++ return 0;
36105 ++exit_remove:
36106 ++ sysfs_remove_group(&client->dev.kobj, &data->attrs);
36107 ++exit_free:
36108 ++ kfree(data);
36109 ++exit:
36110 ++ return err;
36113 ++static int gsp_remove(struct i2c_client *client)
36115 ++ struct gsp_data *data = i2c_get_clientdata(client);
36116 ++ hwmon_device_unregister(data->hwmon_dev);
36117 ++ sysfs_remove_group(&client->dev.kobj, &data->attrs);
36118 ++ kfree(data);
36119 ++ return 0;
36122 ++static int __init gsp_init(void)
36124 ++ return i2c_add_driver(&gsp_driver);
36127 ++static void __exit gsp_exit(void)
36129 ++ i2c_del_driver(&gsp_driver);
36132 ++module_init(gsp_init);
36133 ++module_exit(gsp_exit);
36135 ++MODULE_AUTHOR("Chris Lang <clang@gateworks.com>");
36136 ++MODULE_DESCRIPTION("GSC HWMON driver");
36137 ++MODULE_LICENSE("GPL");
36138 ++MODULE_VERSION(DRV_VERSION);
36140 diff --git a/target/linux/generic/patches-3.16/890-8250_optional_sysrq.patch b/target/linux/generic/patches-3.16/890-8250_optional_sysrq.patch
36141 new file mode 100644
36142 index 000000000000..8815e4c6449a
36143 --- /dev/null
36144 +++ b/target/linux/generic/patches-3.16/890-8250_optional_sysrq.patch
36145 @@ -0,0 +1,24 @@
36146 +--- a/drivers/tty/serial/8250/8250_core.c
36147 ++++ b/drivers/tty/serial/8250/8250_core.c
36148 +@@ -16,7 +16,7 @@
36149 + * membase is an 'ioremapped' cookie.
36150 + */
36152 +-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
36153 ++#if defined(CONFIG_SERIAL_8250_SYSRQ) && defined(CONFIG_MAGIC_SYSRQ)
36154 + #define SUPPORT_SYSRQ
36155 + #endif
36157 +--- a/drivers/tty/serial/8250/Kconfig
36158 ++++ b/drivers/tty/serial/8250/Kconfig
36159 +@@ -91,6 +91,10 @@ config SERIAL_8250_CONSOLE
36161 + If unsure, say N.
36163 ++config SERIAL_8250_SYSRQ
36164 ++ bool "Magic sysrq support on 8250/16550 devices"
36165 ++ depends on SERIAL_8250_CONSOLE
36167 + config SERIAL_8250_GSC
36168 + tristate
36169 + depends on SERIAL_8250 && GSC
36170 diff --git a/target/linux/generic/patches-3.16/900-slab_maxsize.patch b/target/linux/generic/patches-3.16/900-slab_maxsize.patch
36171 new file mode 100644
36172 index 000000000000..9a96d1007e70
36173 --- /dev/null
36174 +++ b/target/linux/generic/patches-3.16/900-slab_maxsize.patch
36175 @@ -0,0 +1,13 @@
36176 +--- a/include/linux/slab.h
36177 ++++ b/include/linux/slab.h
36178 +@@ -195,8 +195,8 @@ struct kmem_cache {
36179 + * to do various tricks to work around compiler limitations in order to
36180 + * ensure proper constant folding.
36181 + */
36182 +-#define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT - 1) <= 25 ? \
36183 +- (MAX_ORDER + PAGE_SHIFT - 1) : 25)
36184 ++#define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT - 1) <= 17 ? \
36185 ++ (MAX_ORDER + PAGE_SHIFT - 1) : 17)
36186 + #define KMALLOC_SHIFT_MAX KMALLOC_SHIFT_HIGH
36187 + #ifndef KMALLOC_SHIFT_LOW
36188 + #define KMALLOC_SHIFT_LOW 5
36189 diff --git a/target/linux/generic/patches-3.16/901-debloat_sock_diag.patch b/target/linux/generic/patches-3.16/901-debloat_sock_diag.patch
36190 new file mode 100644
36191 index 000000000000..13b3d370c5e2
36192 --- /dev/null
36193 +++ b/target/linux/generic/patches-3.16/901-debloat_sock_diag.patch
36194 @@ -0,0 +1,45 @@
36195 +--- a/net/Kconfig
36196 ++++ b/net/Kconfig
36197 +@@ -88,6 +88,9 @@ source "net/netlabel/Kconfig"
36199 + endif # if INET
36201 ++config SOCK_DIAG
36202 ++ bool
36204 + config NETWORK_SECMARK
36205 + bool "Security Marking"
36206 + help
36207 +--- a/net/core/Makefile
36208 ++++ b/net/core/Makefile
36209 +@@ -9,8 +9,9 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.
36211 + obj-y += dev.o ethtool.o dev_addr_lists.o dst.o netevent.o \
36212 + neighbour.o rtnetlink.o utils.o link_watch.o filter.o \
36213 +- sock_diag.o dev_ioctl.o tso.o
36214 ++ dev_ioctl.o tso.o
36216 ++obj-$(CONFIG_SOCK_DIAG) += sock_diag.o
36217 + obj-$(CONFIG_XFRM) += flow.o
36218 + obj-y += net-sysfs.o
36219 + obj-$(CONFIG_PROC_FS) += net-procfs.o
36220 +--- a/net/ipv4/Kconfig
36221 ++++ b/net/ipv4/Kconfig
36222 +@@ -390,6 +390,7 @@ config INET_LRO
36224 + config INET_DIAG
36225 + tristate "INET: socket monitoring interface"
36226 ++ select SOCK_DIAG
36227 + default y
36228 + ---help---
36229 + Support for INET (TCP, DCCP, etc) socket monitoring interface used by
36230 +--- a/net/unix/Kconfig
36231 ++++ b/net/unix/Kconfig
36232 +@@ -22,6 +22,7 @@ config UNIX
36233 + config UNIX_DIAG
36234 + tristate "UNIX: socket monitoring interface"
36235 + depends on UNIX
36236 ++ select SOCK_DIAG
36237 + default n
36238 + ---help---
36239 + Support for UNIX socket monitoring interface used by the ss tool.
36240 diff --git a/target/linux/generic/patches-3.16/902-debloat_proc.patch b/target/linux/generic/patches-3.16/902-debloat_proc.patch
36241 new file mode 100644
36242 index 000000000000..541f04620f88
36243 --- /dev/null
36244 +++ b/target/linux/generic/patches-3.16/902-debloat_proc.patch
36245 @@ -0,0 +1,341 @@
36246 +--- a/fs/locks.c
36247 ++++ b/fs/locks.c
36248 +@@ -2429,6 +2429,8 @@ static const struct file_operations proc
36250 + static int __init proc_locks_init(void)
36252 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36253 ++ return 0;
36254 + proc_create("locks", 0, NULL, &proc_locks_operations);
36255 + return 0;
36257 +--- a/fs/proc/Kconfig
36258 ++++ b/fs/proc/Kconfig
36259 +@@ -71,3 +71,8 @@ config PROC_PAGE_MONITOR
36260 + /proc/pid/smaps, /proc/pid/clear_refs, /proc/pid/pagemap,
36261 + /proc/kpagecount, and /proc/kpageflags. Disabling these
36262 + interfaces will reduce the size of the kernel by approximately 4kb.
36264 ++config PROC_STRIPPED
36265 ++ default n
36266 ++ depends on EXPERT
36267 ++ bool "Strip non-essential /proc functionality to reduce code size"
36268 +--- a/fs/proc/consoles.c
36269 ++++ b/fs/proc/consoles.c
36270 +@@ -106,6 +106,9 @@ static const struct file_operations proc
36272 + static int __init proc_consoles_init(void)
36274 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36275 ++ return 0;
36277 + proc_create("consoles", 0, NULL, &proc_consoles_operations);
36278 + return 0;
36280 +--- a/fs/proc/proc_tty.c
36281 ++++ b/fs/proc/proc_tty.c
36282 +@@ -143,7 +143,10 @@ static const struct file_operations proc
36283 + void proc_tty_register_driver(struct tty_driver *driver)
36285 + struct proc_dir_entry *ent;
36288 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36289 ++ return;
36291 + if (!driver->driver_name || driver->proc_entry ||
36292 + !driver->ops->proc_fops)
36293 + return;
36294 +@@ -160,6 +163,9 @@ void proc_tty_unregister_driver(struct t
36296 + struct proc_dir_entry *ent;
36298 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36299 ++ return;
36301 + ent = driver->proc_entry;
36302 + if (!ent)
36303 + return;
36304 +@@ -174,6 +180,9 @@ void proc_tty_unregister_driver(struct t
36305 + */
36306 + void __init proc_tty_init(void)
36308 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36309 ++ return;
36311 + if (!proc_mkdir("tty", NULL))
36312 + return;
36313 + proc_tty_ldisc = proc_mkdir("tty/ldisc", NULL);
36314 +--- a/kernel/exec_domain.c
36315 ++++ b/kernel/exec_domain.c
36316 +@@ -173,6 +173,8 @@ static const struct file_operations exec
36318 + static int __init proc_execdomains_init(void)
36320 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36321 ++ return 0;
36322 + proc_create("execdomains", 0, NULL, &execdomains_proc_fops);
36323 + return 0;
36325 +--- a/kernel/irq/proc.c
36326 ++++ b/kernel/irq/proc.c
36327 +@@ -311,6 +311,9 @@ void register_irq_proc(unsigned int irq,
36329 + char name [MAX_NAMELEN];
36331 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP))
36332 ++ return;
36334 + if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir)
36335 + return;
36337 +@@ -347,6 +350,9 @@ void unregister_irq_proc(unsigned int ir
36339 + char name [MAX_NAMELEN];
36341 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP))
36342 ++ return;
36344 + if (!root_irq_dir || !desc->dir)
36345 + return;
36346 + #ifdef CONFIG_SMP
36347 +@@ -382,6 +388,9 @@ void init_irq_proc(void)
36348 + unsigned int irq;
36349 + struct irq_desc *desc;
36351 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP))
36352 ++ return;
36354 + /* create /proc/irq */
36355 + root_irq_dir = proc_mkdir("irq", NULL);
36356 + if (!root_irq_dir)
36357 +--- a/kernel/time/timer_list.c
36358 ++++ b/kernel/time/timer_list.c
36359 +@@ -362,6 +362,8 @@ static int __init init_timer_list_procfs
36361 + struct proc_dir_entry *pe;
36363 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36364 ++ return 0;
36365 + pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
36366 + if (!pe)
36367 + return -ENOMEM;
36368 +--- a/mm/vmalloc.c
36369 ++++ b/mm/vmalloc.c
36370 +@@ -2665,6 +2665,8 @@ static const struct file_operations proc
36372 + static int __init proc_vmalloc_init(void)
36374 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36375 ++ return 0;
36376 + proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
36377 + return 0;
36379 +--- a/mm/vmstat.c
36380 ++++ b/mm/vmstat.c
36381 +@@ -1302,10 +1302,12 @@ static int __init setup_vmstat(void)
36382 + put_online_cpus();
36383 + #endif
36384 + #ifdef CONFIG_PROC_FS
36385 +- proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
36386 +- proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
36387 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) {
36388 ++ proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
36389 ++ proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
36390 ++ proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
36391 ++ }
36392 + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
36393 +- proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
36394 + #endif
36395 + return 0;
36397 +--- a/net/8021q/vlanproc.c
36398 ++++ b/net/8021q/vlanproc.c
36399 +@@ -127,6 +127,9 @@ void vlan_proc_cleanup(struct net *net)
36401 + struct vlan_net *vn = net_generic(net, vlan_net_id);
36403 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36404 ++ return;
36406 + if (vn->proc_vlan_conf)
36407 + remove_proc_entry(name_conf, vn->proc_vlan_dir);
36409 +@@ -146,6 +149,9 @@ int __net_init vlan_proc_init(struct net
36411 + struct vlan_net *vn = net_generic(net, vlan_net_id);
36413 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36414 ++ return 0;
36416 + vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net);
36417 + if (!vn->proc_vlan_dir)
36418 + goto err;
36419 +--- a/net/core/sock.c
36420 ++++ b/net/core/sock.c
36421 +@@ -2985,6 +2985,8 @@ static __net_initdata struct pernet_oper
36423 + static int __init proto_init(void)
36425 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36426 ++ return 0;
36427 + return register_pernet_subsys(&proto_net_ops);
36430 +--- a/net/ipv4/fib_trie.c
36431 ++++ b/net/ipv4/fib_trie.c
36432 +@@ -2581,10 +2581,12 @@ static const struct file_operations fib_
36434 + int __net_init fib_proc_init(struct net *net)
36436 +- if (!proc_create("fib_trie", S_IRUGO, net->proc_net, &fib_trie_fops))
36437 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
36438 ++ !proc_create("fib_trie", S_IRUGO, net->proc_net, &fib_trie_fops))
36439 + goto out1;
36441 +- if (!proc_create("fib_triestat", S_IRUGO, net->proc_net,
36442 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
36443 ++ !proc_create("fib_triestat", S_IRUGO, net->proc_net,
36444 + &fib_triestat_fops))
36445 + goto out2;
36447 +@@ -2594,17 +2596,21 @@ int __net_init fib_proc_init(struct net
36448 + return 0;
36450 + out3:
36451 +- remove_proc_entry("fib_triestat", net->proc_net);
36452 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
36453 ++ remove_proc_entry("fib_triestat", net->proc_net);
36454 + out2:
36455 +- remove_proc_entry("fib_trie", net->proc_net);
36456 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
36457 ++ remove_proc_entry("fib_trie", net->proc_net);
36458 + out1:
36459 + return -ENOMEM;
36462 + void __net_exit fib_proc_exit(struct net *net)
36464 +- remove_proc_entry("fib_trie", net->proc_net);
36465 +- remove_proc_entry("fib_triestat", net->proc_net);
36466 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) {
36467 ++ remove_proc_entry("fib_trie", net->proc_net);
36468 ++ remove_proc_entry("fib_triestat", net->proc_net);
36469 ++ }
36470 + remove_proc_entry("route", net->proc_net);
36473 +--- a/net/ipv4/proc.c
36474 ++++ b/net/ipv4/proc.c
36475 +@@ -517,6 +517,9 @@ static __net_initdata struct pernet_oper
36477 + int __init ip_misc_proc_init(void)
36479 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36480 ++ return 0;
36482 + return register_pernet_subsys(&ip_proc_ops);
36485 +--- a/net/ipv4/route.c
36486 ++++ b/net/ipv4/route.c
36487 +@@ -422,6 +422,9 @@ static struct pernet_operations ip_rt_pr
36489 + static int __init ip_rt_proc_init(void)
36491 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36492 ++ return 0;
36494 + return register_pernet_subsys(&ip_rt_proc_ops);
36497 +--- a/ipc/msg.c
36498 ++++ b/ipc/msg.c
36499 +@@ -134,6 +134,9 @@ void __init msg_init(void)
36500 + printk(KERN_INFO "msgmni has been set to %d\n",
36501 + init_ipc_ns.msg_ctlmni);
36503 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36504 ++ return;
36506 + ipc_init_proc_interface("sysvipc/msg",
36507 + " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n",
36508 + IPC_MSG_IDS, sysvipc_msg_proc_show);
36509 +--- a/ipc/sem.c
36510 ++++ b/ipc/sem.c
36511 +@@ -191,6 +191,8 @@ void sem_exit_ns(struct ipc_namespace *n
36512 + void __init sem_init(void)
36514 + sem_init_ns(&init_ipc_ns);
36515 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36516 ++ return;
36517 + ipc_init_proc_interface("sysvipc/sem",
36518 + " key semid perms nsems uid gid cuid cgid otime ctime\n",
36519 + IPC_SEM_IDS, sysvipc_sem_proc_show);
36520 +--- a/ipc/shm.c
36521 ++++ b/ipc/shm.c
36522 +@@ -118,6 +118,8 @@ pure_initcall(ipc_ns_init);
36524 + void __init shm_init(void)
36526 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36527 ++ return;
36528 + ipc_init_proc_interface("sysvipc/shm",
36529 + #if BITS_PER_LONG <= 32
36530 + " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n",
36531 +--- a/ipc/util.c
36532 ++++ b/ipc/util.c
36533 +@@ -161,6 +161,9 @@ void __init ipc_init_proc_interface(cons
36534 + struct proc_dir_entry *pde;
36535 + struct ipc_proc_iface *iface;
36537 ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED))
36538 ++ return;
36540 + iface = kmalloc(sizeof(*iface), GFP_KERNEL);
36541 + if (!iface)
36542 + return;
36543 +--- a/net/core/net-procfs.c
36544 ++++ b/net/core/net-procfs.c
36545 +@@ -318,10 +318,12 @@ static int __net_init dev_proc_net_init(
36547 + if (!proc_create("dev", S_IRUGO, net->proc_net, &dev_seq_fops))
36548 + goto out;
36549 +- if (!proc_create("softnet_stat", S_IRUGO, net->proc_net,
36550 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
36551 ++ !proc_create("softnet_stat", S_IRUGO, net->proc_net,
36552 + &softnet_seq_fops))
36553 + goto out_dev;
36554 +- if (!proc_create("ptype", S_IRUGO, net->proc_net, &ptype_seq_fops))
36555 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
36556 ++ !proc_create("ptype", S_IRUGO, net->proc_net, &ptype_seq_fops))
36557 + goto out_softnet;
36559 + if (wext_proc_init(net))
36560 +@@ -330,9 +332,11 @@ static int __net_init dev_proc_net_init(
36561 + out:
36562 + return rc;
36563 + out_ptype:
36564 +- remove_proc_entry("ptype", net->proc_net);
36565 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
36566 ++ remove_proc_entry("ptype", net->proc_net);
36567 + out_softnet:
36568 +- remove_proc_entry("softnet_stat", net->proc_net);
36569 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
36570 ++ remove_proc_entry("softnet_stat", net->proc_net);
36571 + out_dev:
36572 + remove_proc_entry("dev", net->proc_net);
36573 + goto out;
36574 +@@ -342,8 +346,10 @@ static void __net_exit dev_proc_net_exit
36576 + wext_proc_exit(net);
36578 +- remove_proc_entry("ptype", net->proc_net);
36579 +- remove_proc_entry("softnet_stat", net->proc_net);
36580 ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) {
36581 ++ remove_proc_entry("ptype", net->proc_net);
36582 ++ remove_proc_entry("softnet_stat", net->proc_net);
36583 ++ }
36584 + remove_proc_entry("dev", net->proc_net);
36587 diff --git a/target/linux/generic/patches-3.16/903-debloat_direct_io.patch b/target/linux/generic/patches-3.16/903-debloat_direct_io.patch
36588 new file mode 100644
36589 index 000000000000..4beebd6ef239
36590 --- /dev/null
36591 +++ b/target/linux/generic/patches-3.16/903-debloat_direct_io.patch
36592 @@ -0,0 +1,84 @@
36593 +--- a/fs/Kconfig
36594 ++++ b/fs/Kconfig
36595 +@@ -62,6 +62,11 @@ config FILE_LOCKING
36596 + for filesystems like NFS and for the flock() system
36597 + call. Disabling this option saves about 11k.
36599 ++config DIRECT_IO
36600 ++ bool "Enable O_DIRECT support" if EXPERT
36601 ++ depends on BLOCK
36602 ++ default y
36604 + source "fs/notify/Kconfig"
36606 + source "fs/quota/Kconfig"
36607 +--- a/fs/Makefile
36608 ++++ b/fs/Makefile
36609 +@@ -14,7 +14,8 @@ obj-y := open.o read_write.o file_table.
36610 + stack.o fs_struct.o statfs.o
36612 + ifeq ($(CONFIG_BLOCK),y)
36613 +-obj-y += buffer.o block_dev.o direct-io.o mpage.o
36614 ++obj-y += buffer.o block_dev.o mpage.o
36615 ++obj-$(CONFIG_DIRECT_IO) += direct-io.o
36616 + else
36617 + obj-y += no-block.o
36618 + endif
36619 +--- a/include/linux/fs.h
36620 ++++ b/include/linux/fs.h
36621 +@@ -2521,12 +2521,25 @@ enum {
36622 + DIO_ASYNC_EXTEND = 0x04,
36623 + };
36625 ++#ifdef CONFIG_DIRECT_IO
36626 + void dio_end_io(struct bio *bio, int error);
36628 + ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
36629 + struct block_device *bdev, struct iov_iter *iter, loff_t offset,
36630 + get_block_t get_block, dio_iodone_t end_io,
36631 + dio_submit_t submit_io, int flags);
36632 ++#else
36633 ++static inline void dio_end_io(struct bio *bio, int error)
36636 ++static inline ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
36637 ++ struct block_device *bdev, struct iov_iter *iter, loff_t offset,
36638 ++ get_block_t get_block, dio_iodone_t end_io,
36639 ++ dio_submit_t submit_io, int flags)
36641 ++ return -EOPNOTSUPP;
36643 ++#endif
36645 + static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
36646 + struct inode *inode, struct iov_iter *iter, loff_t offset,
36648 +--- a/fs/fcntl.c
36649 ++++ b/fs/fcntl.c
36650 +@@ -51,8 +51,10 @@ static int setfl(int fd, struct file * f
36651 + arg |= O_NONBLOCK;
36653 + if (arg & O_DIRECT) {
36654 ++#ifdef CONFIG_DIRECT_IO
36655 + if (!filp->f_mapping || !filp->f_mapping->a_ops ||
36656 + !filp->f_mapping->a_ops->direct_IO)
36657 ++#endif
36658 + return -EINVAL;
36661 +--- a/fs/open.c
36662 ++++ b/fs/open.c
36663 +@@ -655,9 +655,12 @@ int open_check_o_direct(struct file *f)
36665 + /* NB: we're sure to have correct a_ops only after f_op->open */
36666 + if (f->f_flags & O_DIRECT) {
36667 ++#ifdef CONFIG_DIRECT_IO
36668 + if (!f->f_mapping->a_ops ||
36669 + ((!f->f_mapping->a_ops->direct_IO) &&
36670 +- (!f->f_mapping->a_ops->get_xip_mem))) {
36671 ++ (!f->f_mapping->a_ops->get_xip_mem)))
36672 ++#endif
36673 ++ {
36674 + return -EINVAL;
36677 diff --git a/target/linux/generic/patches-3.16/910-kobject_uevent.patch b/target/linux/generic/patches-3.16/910-kobject_uevent.patch
36678 new file mode 100644
36679 index 000000000000..9ee9cff6701d
36680 --- /dev/null
36681 +++ b/target/linux/generic/patches-3.16/910-kobject_uevent.patch
36682 @@ -0,0 +1,21 @@
36683 +--- a/lib/kobject_uevent.c
36684 ++++ b/lib/kobject_uevent.c
36685 +@@ -51,6 +51,18 @@ static const char *kobject_actions[] = {
36686 + [KOBJ_OFFLINE] = "offline",
36687 + };
36689 ++u64 uevent_next_seqnum(void)
36691 ++ u64 seq;
36693 ++ mutex_lock(&uevent_sock_mutex);
36694 ++ seq = ++uevent_seqnum;
36695 ++ mutex_unlock(&uevent_sock_mutex);
36697 ++ return seq;
36699 ++EXPORT_SYMBOL_GPL(uevent_next_seqnum);
36701 + /**
36702 + * kobject_action_type - translate action string to numeric type
36704 diff --git a/target/linux/generic/patches-3.16/911-kobject_add_broadcast_uevent.patch b/target/linux/generic/patches-3.16/911-kobject_add_broadcast_uevent.patch
36705 new file mode 100644
36706 index 000000000000..6e4c14029186
36707 --- /dev/null
36708 +++ b/target/linux/generic/patches-3.16/911-kobject_add_broadcast_uevent.patch
36709 @@ -0,0 +1,65 @@
36710 +--- a/include/linux/kobject.h
36711 ++++ b/include/linux/kobject.h
36712 +@@ -32,6 +32,8 @@
36713 + #define UEVENT_NUM_ENVP 32 /* number of env pointers */
36714 + #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
36716 ++struct sk_buff;
36718 + #ifdef CONFIG_UEVENT_HELPER
36719 + /* path to the userspace helper executed on an event */
36720 + extern char uevent_helper[];
36721 +@@ -221,4 +223,7 @@ int add_uevent_var(struct kobj_uevent_en
36722 + int kobject_action_type(const char *buf, size_t count,
36723 + enum kobject_action *type);
36725 ++int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
36726 ++ gfp_t allocation);
36728 + #endif /* _KOBJECT_H_ */
36729 +--- a/lib/kobject_uevent.c
36730 ++++ b/lib/kobject_uevent.c
36731 +@@ -424,6 +424,43 @@ int add_uevent_var(struct kobj_uevent_en
36732 + EXPORT_SYMBOL_GPL(add_uevent_var);
36734 + #if defined(CONFIG_NET)
36735 ++int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
36736 ++ gfp_t allocation)
36738 ++ struct uevent_sock *ue_sk;
36739 ++ int err = 0;
36741 ++ /* send netlink message */
36742 ++ mutex_lock(&uevent_sock_mutex);
36743 ++ list_for_each_entry(ue_sk, &uevent_sock_list, list) {
36744 ++ struct sock *uevent_sock = ue_sk->sk;
36745 ++ struct sk_buff *skb2;
36747 ++ skb2 = skb_clone(skb, allocation);
36748 ++ if (!skb2)
36749 ++ break;
36751 ++ err = netlink_broadcast(uevent_sock, skb2, pid, group,
36752 ++ allocation);
36753 ++ if (err)
36754 ++ break;
36755 ++ }
36756 ++ mutex_unlock(&uevent_sock_mutex);
36758 ++ kfree_skb(skb);
36759 ++ return err;
36761 ++#else
36762 ++int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
36763 ++ gfp_t allocation)
36765 ++ kfree_skb(skb);
36766 ++ return 0;
36768 ++#endif
36769 ++EXPORT_SYMBOL_GPL(broadcast_uevent);
36771 ++#if defined(CONFIG_NET)
36772 + static int uevent_net_init(struct net *net)
36774 + struct uevent_sock *ue_sk;
36775 diff --git a/target/linux/generic/patches-3.16/921-use_preinit_as_init.patch b/target/linux/generic/patches-3.16/921-use_preinit_as_init.patch
36776 new file mode 100644
36777 index 000000000000..df703a7587cb
36778 --- /dev/null
36779 +++ b/target/linux/generic/patches-3.16/921-use_preinit_as_init.patch
36780 @@ -0,0 +1,12 @@
36781 +--- a/init/main.c
36782 ++++ b/init/main.c
36783 +@@ -872,7 +872,8 @@ static int __ref kernel_init(void *unuse
36784 + pr_err("Failed to execute %s (error %d). Attempting defaults...\n",
36785 + execute_command, ret);
36787 +- if (!try_to_run_init_process("/sbin/init") ||
36788 ++ if (!try_to_run_init_process("/etc/preinit") ||
36789 ++ !try_to_run_init_process("/sbin/init") ||
36790 + !try_to_run_init_process("/etc/init") ||
36791 + !try_to_run_init_process("/bin/init") ||
36792 + !try_to_run_init_process("/bin/sh"))
36793 diff --git a/target/linux/generic/patches-3.16/922-always-create-console-node-in-initramfs.patch b/target/linux/generic/patches-3.16/922-always-create-console-node-in-initramfs.patch
36794 new file mode 100644
36795 index 000000000000..988de35ce01a
36796 --- /dev/null
36797 +++ b/target/linux/generic/patches-3.16/922-always-create-console-node-in-initramfs.patch
36798 @@ -0,0 +1,30 @@
36799 +--- a/scripts/gen_initramfs_list.sh
36800 ++++ b/scripts/gen_initramfs_list.sh
36801 +@@ -59,6 +59,18 @@ default_initramfs() {
36802 + EOF
36805 ++list_openwrt_initramfs() {
36806 ++ :
36809 ++openwrt_initramfs() {
36810 ++ # make sure that /dev/console exists
36811 ++ cat <<-EOF >> ${output}
36812 ++ dir /dev 0755 0 0
36813 ++ nod /dev/console 0600 0 0 c 5 1
36814 ++ EOF
36817 + filetype() {
36818 + local argv1="$1"
36820 +@@ -177,6 +189,8 @@ dir_filelist() {
36821 + if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
36822 + ${dep_list}print_mtime "$1"
36824 ++ ${dep_list}openwrt_initramfs
36826 + echo "${dirlist}" | \
36827 + while read x; do
36828 + ${dep_list}parse ${x}
36829 diff --git a/target/linux/generic/patches-3.16/930-crashlog.patch b/target/linux/generic/patches-3.16/930-crashlog.patch
36830 new file mode 100644
36831 index 000000000000..2278912ecb7e
36832 --- /dev/null
36833 +++ b/target/linux/generic/patches-3.16/930-crashlog.patch
36834 @@ -0,0 +1,276 @@
36835 +--- /dev/null
36836 ++++ b/include/linux/crashlog.h
36837 +@@ -0,0 +1,17 @@
36838 ++#ifndef __CRASHLOG_H
36839 ++#define __CRASHLOG_H
36841 ++#ifdef CONFIG_CRASHLOG
36842 ++void crashlog_init_bootmem(struct bootmem_data *bdata);
36843 ++void crashlog_init_memblock(phys_addr_t addr, phys_addr_t size);
36844 ++#else
36845 ++static inline void crashlog_init_bootmem(struct bootmem_data *bdata)
36849 ++static inline void crashlog_init_memblock(phys_addr_t addr, phys_addr_t size)
36852 ++#endif
36854 ++#endif
36855 +--- a/init/Kconfig
36856 ++++ b/init/Kconfig
36857 +@@ -1234,6 +1234,10 @@ config RELAY
36859 + If unsure, say N.
36861 ++config CRASHLOG
36862 ++ bool "Crash logging"
36863 ++ depends on (!NO_BOOTMEM || HAVE_MEMBLOCK) && !(ARM || SPARC || PPC)
36865 + config BLK_DEV_INITRD
36866 + bool "Initial RAM filesystem and RAM disk (initramfs/initrd) support"
36867 + depends on BROKEN || !FRV
36868 +--- a/kernel/Makefile
36869 ++++ b/kernel/Makefile
36870 +@@ -96,6 +96,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
36871 + obj-$(CONFIG_JUMP_LABEL) += jump_label.o
36872 + obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o
36873 + obj-$(CONFIG_TORTURE_TEST) += torture.o
36874 ++obj-$(CONFIG_CRASHLOG) += crashlog.o
36876 + $(obj)/configs.o: $(obj)/config_data.h
36878 +--- /dev/null
36879 ++++ b/kernel/crashlog.c
36880 +@@ -0,0 +1,181 @@
36881 ++/*
36882 ++ * Crash information logger
36883 ++ * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
36884 ++ *
36885 ++ * Based on ramoops.c
36886 ++ * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com>
36887 ++ *
36888 ++ * This program is free software; you can redistribute it and/or
36889 ++ * modify it under the terms of the GNU General Public License
36890 ++ * version 2 as published by the Free Software Foundation.
36891 ++ *
36892 ++ * This program is distributed in the hope that it will be useful, but
36893 ++ * WITHOUT ANY WARRANTY; without even the implied warranty of
36894 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36895 ++ * General Public License for more details.
36896 ++ *
36897 ++ * You should have received a copy of the GNU General Public License
36898 ++ * along with this program; if not, write to the Free Software
36899 ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
36900 ++ * 02110-1301 USA
36901 ++ *
36902 ++ */
36904 ++#include <linux/module.h>
36905 ++#include <linux/bootmem.h>
36906 ++#include <linux/memblock.h>
36907 ++#include <linux/debugfs.h>
36908 ++#include <linux/crashlog.h>
36909 ++#include <linux/kmsg_dump.h>
36910 ++#include <linux/module.h>
36911 ++#include <linux/pfn.h>
36912 ++#include <asm/io.h>
36914 ++#define CRASHLOG_PAGES 4
36915 ++#define CRASHLOG_SIZE (CRASHLOG_PAGES * PAGE_SIZE)
36916 ++#define CRASHLOG_MAGIC 0xa1eedead
36918 ++/*
36919 ++ * Start the log at 1M before the end of RAM, as some boot loaders like
36920 ++ * to use the end of the RAM for stack usage and other things
36921 ++ * If this fails, fall back to using the last part.
36922 ++ */
36923 ++#define CRASHLOG_OFFSET (1024 * 1024)
36925 ++struct crashlog_data {
36926 ++ u32 magic;
36927 ++ u32 len;
36928 ++ u8 data[];
36929 ++};
36931 ++static struct debugfs_blob_wrapper crashlog_blob;
36932 ++static unsigned long crashlog_addr = 0;
36933 ++static struct crashlog_data *crashlog_buf;
36934 ++static struct kmsg_dumper dump;
36935 ++static bool first = true;
36937 ++extern struct list_head *crashlog_modules;
36939 ++#ifndef CONFIG_NO_BOOTMEM
36940 ++void __init crashlog_init_bootmem(bootmem_data_t *bdata)
36942 ++ unsigned long addr;
36944 ++ if (crashlog_addr)
36945 ++ return;
36947 ++ addr = PFN_PHYS(bdata->node_low_pfn) - CRASHLOG_OFFSET;
36948 ++ if (reserve_bootmem(addr, CRASHLOG_SIZE, BOOTMEM_EXCLUSIVE) < 0) {
36949 ++ printk("Crashlog failed to allocate RAM at address 0x%lx\n", addr);
36950 ++ bdata->node_low_pfn -= CRASHLOG_PAGES;
36951 ++ addr = PFN_PHYS(bdata->node_low_pfn);
36952 ++ }
36953 ++ crashlog_addr = addr;
36955 ++#endif
36957 ++#ifdef CONFIG_HAVE_MEMBLOCK
36958 ++void __meminit crashlog_init_memblock(phys_addr_t addr, phys_addr_t size)
36960 ++ if (crashlog_addr)
36961 ++ return;
36963 ++ addr += size - CRASHLOG_OFFSET;
36964 ++ if (memblock_reserve(addr, CRASHLOG_SIZE)) {
36965 ++ printk("Crashlog failed to allocate RAM at address 0x%lx\n", (unsigned long) addr);
36966 ++ return;
36967 ++ }
36969 ++ crashlog_addr = addr;
36971 ++#endif
36973 ++static void __init crashlog_copy(void)
36975 ++ if (crashlog_buf->magic != CRASHLOG_MAGIC)
36976 ++ return;
36978 ++ if (!crashlog_buf->len || crashlog_buf->len >
36979 ++ CRASHLOG_SIZE - sizeof(*crashlog_buf))
36980 ++ return;
36982 ++ crashlog_blob.size = crashlog_buf->len;
36983 ++ crashlog_blob.data = kmemdup(crashlog_buf->data,
36984 ++ crashlog_buf->len, GFP_KERNEL);
36986 ++ debugfs_create_blob("crashlog", 0700, NULL, &crashlog_blob);
36989 ++static int get_maxlen(void)
36991 ++ return CRASHLOG_SIZE - sizeof(*crashlog_buf) - crashlog_buf->len;
36994 ++static void crashlog_printf(const char *fmt, ...)
36996 ++ va_list args;
36997 ++ int len = get_maxlen();
36999 ++ if (!len)
37000 ++ return;
37002 ++ va_start(args, fmt);
37003 ++ crashlog_buf->len += vscnprintf(
37004 ++ &crashlog_buf->data[crashlog_buf->len],
37005 ++ len, fmt, args);
37006 ++ va_end(args);
37009 ++static void crashlog_do_dump(struct kmsg_dumper *dumper,
37010 ++ enum kmsg_dump_reason reason)
37012 ++ struct timeval tv;
37013 ++ struct module *m;
37014 ++ char *buf;
37015 ++ size_t len;
37017 ++ if (!first)
37018 ++ crashlog_printf("\n===================================\n");
37020 ++ do_gettimeofday(&tv);
37021 ++ crashlog_printf("Time: %lu.%lu\n",
37022 ++ (long)tv.tv_sec, (long)tv.tv_usec);
37024 ++ if (first) {
37025 ++ crashlog_printf("Modules:");
37026 ++ list_for_each_entry(m, crashlog_modules, list) {
37027 ++ crashlog_printf("\t%s@%p+%x", m->name,
37028 ++ m->module_core, m->core_size,
37029 ++ m->module_init, m->init_size);
37030 ++ }
37031 ++ crashlog_printf("\n");
37032 ++ first = false;
37033 ++ }
37035 ++ buf = (char *)&crashlog_buf->data[crashlog_buf->len];
37037 ++ kmsg_dump_get_buffer(dumper, true, buf, get_maxlen(), &len);
37039 ++ crashlog_buf->len += len;
37043 ++int __init crashlog_init_fs(void)
37045 ++ if (!crashlog_addr)
37046 ++ return -ENOMEM;
37048 ++ crashlog_buf = ioremap(crashlog_addr, CRASHLOG_SIZE);
37050 ++ crashlog_copy();
37052 ++ crashlog_buf->magic = CRASHLOG_MAGIC;
37053 ++ crashlog_buf->len = 0;
37055 ++ dump.max_reason = KMSG_DUMP_OOPS;
37056 ++ dump.dump = crashlog_do_dump;
37057 ++ kmsg_dump_register(&dump);
37059 ++ return 0;
37061 ++module_init(crashlog_init_fs);
37062 +--- a/mm/bootmem.c
37063 ++++ b/mm/bootmem.c
37064 +@@ -15,6 +15,7 @@
37065 + #include <linux/export.h>
37066 + #include <linux/kmemleak.h>
37067 + #include <linux/range.h>
37068 ++#include <linux/crashlog.h>
37069 + #include <linux/memblock.h>
37071 + #include <asm/bug.h>
37072 +@@ -177,6 +178,7 @@ static unsigned long __init free_all_boo
37073 + if (!bdata->node_bootmem_map)
37074 + return 0;
37076 ++ crashlog_init_bootmem(bdata);
37077 + map = bdata->node_bootmem_map;
37078 + start = bdata->node_min_pfn;
37079 + end = bdata->node_low_pfn;
37080 +--- a/kernel/module.c
37081 ++++ b/kernel/module.c
37082 +@@ -106,6 +106,9 @@ static LIST_HEAD(modules);
37083 + #ifdef CONFIG_KGDB_KDB
37084 + struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */
37085 + #endif /* CONFIG_KGDB_KDB */
37086 ++#ifdef CONFIG_CRASHLOG
37087 ++struct list_head *crashlog_modules = &modules;
37088 ++#endif
37090 + #ifdef CONFIG_MODULE_SIG
37091 + #ifdef CONFIG_MODULE_SIG_FORCE
37092 +--- a/mm/memblock.c
37093 ++++ b/mm/memblock.c
37094 +@@ -19,6 +19,7 @@
37095 + #include <linux/debugfs.h>
37096 + #include <linux/seq_file.h>
37097 + #include <linux/memblock.h>
37098 ++#include <linux/crashlog.h>
37100 + #include <asm-generic/sections.h>
37101 + #include <linux/io.h>
37102 +@@ -478,6 +479,8 @@ static void __init_memblock memblock_ins
37103 + memblock_set_region_node(rgn, nid);
37104 + type->cnt++;
37105 + type->total_size += size;
37106 ++ if (type == &memblock.memory && idx == 0)
37107 ++ crashlog_init_memblock(base, size);
37110 + /**
37111 diff --git a/target/linux/generic/patches-3.16/940-ocf_kbuild_integration.patch b/target/linux/generic/patches-3.16/940-ocf_kbuild_integration.patch
37112 new file mode 100644
37113 index 000000000000..a7dd5fadb00f
37114 --- /dev/null
37115 +++ b/target/linux/generic/patches-3.16/940-ocf_kbuild_integration.patch
37116 @@ -0,0 +1,20 @@
37117 +--- a/crypto/Kconfig
37118 ++++ b/crypto/Kconfig
37119 +@@ -1415,3 +1415,6 @@ source "drivers/crypto/Kconfig"
37120 + source crypto/asymmetric_keys/Kconfig
37122 + endif # if CRYPTO
37124 ++source "crypto/ocf/Kconfig"
37126 +--- a/crypto/Makefile
37127 ++++ b/crypto/Makefile
37128 +@@ -99,6 +99,8 @@ obj-$(CONFIG_CRYPTO_USER_API) += af_alg.
37129 + obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
37130 + obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
37132 ++obj-$(CONFIG_OCF_OCF) += ocf/
37135 + # generic algorithms and the async_tx api
37137 diff --git a/target/linux/generic/patches-3.16/941-ocf_20120127.patch b/target/linux/generic/patches-3.16/941-ocf_20120127.patch
37138 new file mode 100644
37139 index 000000000000..769cbe8a3712
37140 --- /dev/null
37141 +++ b/target/linux/generic/patches-3.16/941-ocf_20120127.patch
37142 @@ -0,0 +1,166 @@
37143 +--- a/drivers/char/random.c
37144 ++++ b/drivers/char/random.c
37145 +@@ -139,6 +139,9 @@
37146 + * that might otherwise be identical and have very little entropy
37147 + * available to them (particularly common in the embedded world).
37149 ++ * void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
37150 ++ * int random_input_wait(void);
37151 ++ *
37152 + * add_input_randomness() uses the input layer interrupt timing, as well as
37153 + * the event type information from the hardware.
37155 +@@ -152,6 +155,13 @@
37156 + * seek times do not make for good sources of entropy, as their seek
37157 + * times are usually fairly consistent.
37159 ++ * random_input_words() just provides a raw block of entropy to the input
37160 ++ * pool, such as from a hardware entropy generator.
37161 ++ *
37162 ++ * random_input_wait() suspends the caller until such time as the
37163 ++ * entropy pool falls below the write threshold, and returns a count of how
37164 ++ * much entropy (in bits) is needed to sustain the pool.
37165 ++ *
37166 + * All of these routines try to estimate how many bits of randomness a
37167 + * particular randomness source. They do this by keeping track of the
37168 + * first and second order deltas of the event timings.
37169 +@@ -905,6 +915,63 @@ void add_disk_randomness(struct gendisk
37170 + EXPORT_SYMBOL_GPL(add_disk_randomness);
37171 + #endif
37173 ++/*
37174 ++ * random_input_words - add bulk entropy to pool
37175 ++ *
37176 ++ * @buf: buffer to add
37177 ++ * @wordcount: number of __u32 words to add
37178 ++ * @ent_count: total amount of entropy (in bits) to credit
37179 ++ *
37180 ++ * this provides bulk input of entropy to the input pool
37181 ++ *
37182 ++ */
37183 ++void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
37185 ++ mix_pool_bytes(&input_pool, buf, wordcount*4, NULL);
37187 ++ credit_entropy_bits(&input_pool, ent_count);
37189 ++ pr_notice("crediting %d bits => %d\n",
37190 ++ ent_count, input_pool.entropy_count);
37191 ++ /*
37192 ++ * Wake up waiting processes if we have enough
37193 ++ * entropy.
37194 ++ */
37195 ++ if (input_pool.entropy_count >= random_read_wakeup_bits)
37196 ++ wake_up_interruptible(&random_read_wait);
37198 ++EXPORT_SYMBOL(random_input_words);
37200 ++/*
37201 ++ * random_input_wait - wait until random needs entropy
37202 ++ *
37203 ++ * this function sleeps until the /dev/random subsystem actually
37204 ++ * needs more entropy, and then return the amount of entropy
37205 ++ * that it would be nice to have added to the system.
37206 ++ */
37207 ++int random_input_wait(void)
37209 ++ int count;
37211 ++ wait_event_interruptible(random_write_wait,
37212 ++ input_pool.entropy_count < random_write_wakeup_bits);
37214 ++ count = random_write_wakeup_bits - input_pool.entropy_count;
37216 ++ /* likely we got woken up due to a signal */
37217 ++ if (count <= 0) count = random_read_wakeup_bits;
37219 ++ pr_notice("requesting %d bits from input_wait()er %d<%d\n",
37220 ++ count,
37221 ++ input_pool.entropy_count, random_write_wakeup_bits);
37223 ++ return count;
37225 ++EXPORT_SYMBOL(random_input_wait);
37228 ++#define EXTRACT_SIZE 10
37230 + /*********************************************************************
37232 + * Entropy extraction routines
37233 +--- a/fs/fcntl.c
37234 ++++ b/fs/fcntl.c
37235 +@@ -147,6 +147,7 @@ pid_t f_getown(struct file *filp)
37236 + read_unlock(&filp->f_owner.lock);
37237 + return pid;
37239 ++EXPORT_SYMBOL(sys_dup);
37241 + static int f_setown_ex(struct file *filp, unsigned long arg)
37243 +--- a/include/linux/miscdevice.h
37244 ++++ b/include/linux/miscdevice.h
37245 +@@ -19,6 +19,7 @@
37246 + #define APOLLO_MOUSE_MINOR 7 /* unused */
37247 + #define PC110PAD_MINOR 9 /* unused */
37248 + /*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
37249 ++#define CRYPTODEV_MINOR 70 /* /dev/crypto */
37250 + #define WATCHDOG_MINOR 130 /* Watchdog timer */
37251 + #define TEMP_MINOR 131 /* Temperature Sensor */
37252 + #define RTC_MINOR 135
37253 +--- a/include/linux/random.h
37254 ++++ b/include/linux/random.h
37255 +@@ -13,6 +13,10 @@ extern void add_input_randomness(unsigne
37256 + unsigned int value);
37257 + extern void add_interrupt_randomness(int irq, int irq_flags);
37259 ++extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
37260 ++extern int random_input_wait(void);
37261 ++#define HAS_RANDOM_INPUT_WAIT 1
37263 + extern void get_random_bytes(void *buf, int nbytes);
37264 + extern void get_random_bytes_arch(void *buf, int nbytes);
37265 + void generate_random_uuid(unsigned char uuid_out[16]);
37266 +--- a/include/uapi/linux/random.h
37267 ++++ b/include/uapi/linux/random.h
37268 +@@ -34,6 +34,30 @@
37269 + /* Clear the entropy pool and associated counters. (Superuser only.) */
37270 + #define RNDCLEARPOOL _IO( 'R', 0x06 )
37272 ++#ifdef CONFIG_FIPS_RNG
37274 ++/* Size of seed value - equal to AES blocksize */
37275 ++#define AES_BLOCK_SIZE_BYTES 16
37276 ++#define SEED_SIZE_BYTES AES_BLOCK_SIZE_BYTES
37277 ++/* Size of AES key */
37278 ++#define KEY_SIZE_BYTES 16
37280 ++/* ioctl() structure used by FIPS 140-2 Tests */
37281 ++struct rand_fips_test {
37282 ++ unsigned char key[KEY_SIZE_BYTES]; /* Input */
37283 ++ unsigned char datetime[SEED_SIZE_BYTES]; /* Input */
37284 ++ unsigned char seed[SEED_SIZE_BYTES]; /* Input */
37285 ++ unsigned char result[SEED_SIZE_BYTES]; /* Output */
37286 ++};
37288 ++/* FIPS 140-2 RNG Variable Seed Test. (Superuser only.) */
37289 ++#define RNDFIPSVST _IOWR('R', 0x10, struct rand_fips_test)
37291 ++/* FIPS 140-2 RNG Monte Carlo Test. (Superuser only.) */
37292 ++#define RNDFIPSMCT _IOWR('R', 0x11, struct rand_fips_test)
37294 ++#endif /* #ifdef CONFIG_FIPS_RNG */
37296 + struct rand_pool_info {
37297 + int entropy_count;
37298 + int buf_size;
37299 +--- a/kernel/pid.c
37300 ++++ b/kernel/pid.c
37301 +@@ -425,6 +425,7 @@ void transfer_pid(struct task_struct *ol
37302 + new->pids[type].pid = old->pids[type].pid;
37303 + hlist_replace_rcu(&old->pids[type].node, &new->pids[type].node);
37305 ++EXPORT_SYMBOL(find_task_by_vpid);
37307 + struct task_struct *pid_task(struct pid *pid, enum pid_type type)
37309 diff --git a/target/linux/generic/patches-3.16/950-vm_exports.patch b/target/linux/generic/patches-3.16/950-vm_exports.patch
37310 new file mode 100644
37311 index 000000000000..0ea24d2edd02
37312 --- /dev/null
37313 +++ b/target/linux/generic/patches-3.16/950-vm_exports.patch
37314 @@ -0,0 +1,93 @@
37315 +--- a/mm/shmem.c
37316 ++++ b/mm/shmem.c
37317 +@@ -2965,6 +2965,15 @@ put_memory:
37318 + return res;
37321 ++void shmem_set_file(struct vm_area_struct *vma, struct file *file)
37323 ++ if (vma->vm_file)
37324 ++ fput(vma->vm_file);
37325 ++ vma->vm_file = file;
37326 ++ vma->vm_ops = &shmem_vm_ops;
37328 ++EXPORT_SYMBOL_GPL(shmem_set_file);
37330 + /**
37331 + * shmem_kernel_file_setup - get an unlinked file living in tmpfs which must be
37332 + * kernel internal. There will be NO LSM permission checks against the
37333 +@@ -3004,11 +3013,8 @@ int shmem_zero_setup(struct vm_area_stru
37334 + file = shmem_file_setup("dev/zero", size, vma->vm_flags);
37335 + if (IS_ERR(file))
37336 + return PTR_ERR(file);
37337 ++ shmem_set_file(vma, file);
37339 +- if (vma->vm_file)
37340 +- fput(vma->vm_file);
37341 +- vma->vm_file = file;
37342 +- vma->vm_ops = &shmem_vm_ops;
37343 + return 0;
37346 +--- a/fs/file.c
37347 ++++ b/fs/file.c
37348 +@@ -216,6 +216,7 @@ static inline void __set_open_fd(int fd,
37350 + __set_bit(fd, fdt->open_fds);
37352 ++EXPORT_SYMBOL_GPL(expand_files);
37354 + static inline void __clear_open_fd(int fd, struct fdtable *fdt)
37356 +--- a/kernel/exit.c
37357 ++++ b/kernel/exit.c
37358 +@@ -456,6 +456,8 @@ static void exit_mm(struct task_struct *
37359 + mm_update_next_owner(mm);
37360 + mmput(mm);
37362 ++EXPORT_SYMBOL_GPL(get_files_struct);
37363 ++EXPORT_SYMBOL_GPL(put_files_struct);
37365 + /*
37366 + * When we die, we re-parent all our children, and try to:
37367 +--- a/kernel/sched/core.c
37368 ++++ b/kernel/sched/core.c
37369 +@@ -3084,6 +3084,7 @@ int can_nice(const struct task_struct *p
37370 + return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
37371 + capable(CAP_SYS_NICE));
37373 ++EXPORT_SYMBOL_GPL(can_nice);
37375 + #ifdef __ARCH_WANT_SYS_NICE
37377 +--- a/mm/memory.c
37378 ++++ b/mm/memory.c
37379 +@@ -1404,6 +1404,7 @@ void zap_page_range(struct vm_area_struc
37380 + mmu_notifier_invalidate_range_end(mm, start, end);
37381 + tlb_finish_mmu(&tlb, start, end);
37383 ++EXPORT_SYMBOL_GPL(zap_page_range);
37385 + /**
37386 + * zap_page_range_single - remove user pages in a given range
37387 +--- a/mm/vmalloc.c
37388 ++++ b/mm/vmalloc.c
37389 +@@ -1376,6 +1376,7 @@ struct vm_struct *get_vm_area(unsigned l
37390 + NUMA_NO_NODE, GFP_KERNEL,
37391 + __builtin_return_address(0));
37393 ++EXPORT_SYMBOL_GPL(get_vm_area);
37395 + struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags,
37396 + const void *caller)
37397 +--- a/include/linux/shmem_fs.h
37398 ++++ b/include/linux/shmem_fs.h
37399 +@@ -47,6 +47,8 @@ extern int shmem_init(void);
37400 + extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
37401 + extern struct file *shmem_file_setup(const char *name,
37402 + loff_t size, unsigned long flags);
37404 ++extern void shmem_set_file(struct vm_area_struct *vma, struct file *file);
37405 + extern struct file *shmem_kernel_file_setup(const char *name, loff_t size,
37406 + unsigned long flags);
37407 + extern int shmem_zero_setup(struct vm_area_struct *);
37408 diff --git a/target/linux/generic/patches-3.16/960-decompress_unlzo_fix.patch b/target/linux/generic/patches-3.16/960-decompress_unlzo_fix.patch
37409 new file mode 100644
37410 index 000000000000..ee7c118ef06b
37411 --- /dev/null
37412 +++ b/target/linux/generic/patches-3.16/960-decompress_unlzo_fix.patch
37413 @@ -0,0 +1,23 @@
37414 +--- /dev/null
37415 ++++ b/include/linux/decompress/unlzo_mm.h
37416 +@@ -0,0 +1,10 @@
37417 ++#ifndef UNLZO_MM_H
37418 ++#define UNLZO_MM_H
37420 ++#ifdef STATIC
37421 ++#define INIT
37422 ++#else
37423 ++#define INIT __init
37424 ++#endif
37426 ++#endif
37427 +--- a/lib/decompress_unlzo.c
37428 ++++ b/lib/decompress_unlzo.c
37429 +@@ -38,6 +38,7 @@
37431 + #include <linux/types.h>
37432 + #include <linux/lzo.h>
37433 ++#include <linux/decompress/unlzo_mm.h>
37434 + #include <linux/decompress/mm.h>
37436 + #include <linux/compiler.h>
37437 diff --git a/target/linux/generic/patches-3.16/970-remove-unsane-filenames-from-deps_initramfs-list.patch b/target/linux/generic/patches-3.16/970-remove-unsane-filenames-from-deps_initramfs-list.patch
37438 new file mode 100644
37439 index 000000000000..ac13c9e67368
37440 --- /dev/null
37441 +++ b/target/linux/generic/patches-3.16/970-remove-unsane-filenames-from-deps_initramfs-list.patch
37442 @@ -0,0 +1,29 @@
37443 +--- a/usr/Makefile
37444 ++++ b/usr/Makefile
37445 +@@ -53,6 +53,8 @@ ifneq ($(wildcard $(obj)/.initramfs_data
37446 + include $(obj)/.initramfs_data.cpio.d
37447 + endif
37449 ++deps_initramfs_sane := $(foreach v,$(deps_initramfs),$(if $(findstring :,$(v)),,$(v)))
37451 + quiet_cmd_initfs = GEN $@
37452 + cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
37454 +@@ -61,14 +63,14 @@ targets := initramfs_data.cpio.gz initra
37455 + initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
37456 + initramfs_data.cpio
37457 + # do not try to update files included in initramfs
37458 +-$(deps_initramfs): ;
37459 ++$(deps_initramfs_sane): ;
37461 +-$(deps_initramfs): klibcdirs
37462 ++$(deps_initramfs_sane): klibcdirs
37463 + # We rebuild initramfs_data.cpio if:
37464 + # 1) Any included file is newer then initramfs_data.cpio
37465 + # 2) There are changes in which files are included (added or deleted)
37466 + # 3) If gen_init_cpio are newer than initramfs_data.cpio
37467 + # 4) arguments to gen_initramfs.sh changes
37468 +-$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
37469 ++$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs_sane) klibcdirs
37470 + $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
37471 + $(call if_changed,initfs)
37472 diff --git a/target/linux/generic/patches-3.16/980-arm_openwrt_machtypes.patch b/target/linux/generic/patches-3.16/980-arm_openwrt_machtypes.patch
37473 new file mode 100644
37474 index 000000000000..5e9718b61d7d
37475 --- /dev/null
37476 +++ b/target/linux/generic/patches-3.16/980-arm_openwrt_machtypes.patch
37477 @@ -0,0 +1,32 @@
37478 +--- a/arch/arm/tools/mach-types
37479 ++++ b/arch/arm/tools/mach-types
37480 +@@ -1007,3 +1007,29 @@ eco5_bx2 MACH_ECO5_BX2 ECO5_BX2 4572
37481 + eukrea_cpuimx28sd MACH_EUKREA_CPUIMX28SD EUKREA_CPUIMX28SD 4573
37482 + domotab MACH_DOMOTAB DOMOTAB 4574
37483 + pfla03 MACH_PFLA03 PFLA03 4575
37485 ++# Additional mach-types supported by OpenWrt
37487 ++wg302v1 MACH_WG302V1 WG302V1 889
37488 ++pronghorn MACH_PRONGHORN PRONGHORN 928
37489 ++pronghorn_metro MACH_PRONGHORNMETRO PRONGHORNMETRO 1040
37490 ++sidewinder MACH_SIDEWINDER SIDEWINDER 1041
37491 ++wrt300nv2 MACH_WRT300NV2 WRT300NV2 1077
37492 ++compex42x MACH_COMPEXWP18 COMPEXWP18 1273
37493 ++goldfish MACH_GOLDFISH GOLDFISH 1441
37494 ++cambria MACH_CAMBRIA CAMBRIA 1468
37495 ++dt2 MACH_DT2 DT2 1514
37496 ++ap1000 MACH_AP1000 AP1000 1543
37497 ++tw2662 MACH_TW2662 TW2662 1658
37498 ++tw5334 MACH_TW5334 TW5334 1664
37499 ++usr8200 MACH_USR8200 USR8200 1762
37500 ++mi424wr MACH_MI424WR MI424WR 1778
37501 ++gw2388 MACH_GW2388 GW2388 2635
37502 ++iconnect MACH_ICONNECT ICONNECT 2870
37503 ++nsb3ast MACH_NSB3AST NSB3AST 2917
37504 ++goflexnet MACH_GOFLEXNET GOFLEXNET 3089
37505 ++nas6210 MACH_NAS6210 NAS6210 3104
37506 ++ns_k330 MACH_NS_K330 NS_K330 3108
37507 ++bcm2708 MACH_BCM2708 BCM2708 3138
37508 ++wn802t MACH_WN802T WN802T 3306
37509 ++nsa310 MACH_NSA310 NSA310 4022
37510 diff --git a/target/linux/generic/patches-3.16/990-gpio_wdt.patch b/target/linux/generic/patches-3.16/990-gpio_wdt.patch
37511 new file mode 100644
37512 index 000000000000..203f7cf00049
37513 --- /dev/null
37514 +++ b/target/linux/generic/patches-3.16/990-gpio_wdt.patch
37515 @@ -0,0 +1,360 @@
37516 +This generic GPIO watchdog is used on Huawei E970 (brcm47xx)
37518 +Signed-off-by: Mathias Adam <m.adam--openwrt@adamis.de>
37520 +--- a/drivers/watchdog/Kconfig
37521 ++++ b/drivers/watchdog/Kconfig
37522 +@@ -1084,6 +1084,15 @@ config WDT_MTX1
37523 + Hardware driver for the MTX-1 boards. This is a watchdog timer that
37524 + will reboot the machine after a 100 seconds timer expired.
37526 ++config GPIO_WDT
37527 ++ tristate "GPIO Hardware Watchdog"
37528 ++ help
37529 ++ Hardware driver for GPIO-controlled watchdogs. GPIO pin and
37530 ++ toggle interval settings are platform-specific. The driver
37531 ++ will stop toggling the GPIO (i.e. machine reboots) after a
37532 ++ 100 second timer expired and no process has written to
37533 ++ /dev/watchdog during that time.
37535 + config PNX833X_WDT
37536 + tristate "PNX833x Hardware Watchdog"
37537 + depends on SOC_PNX8335
37538 +--- a/drivers/watchdog/Makefile
37539 ++++ b/drivers/watchdog/Makefile
37540 +@@ -130,6 +130,7 @@ obj-$(CONFIG_RC32434_WDT) += rc32434_wdt
37541 + obj-$(CONFIG_INDYDOG) += indydog.o
37542 + obj-$(CONFIG_JZ4740_WDT) += jz4740_wdt.o
37543 + obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o
37544 ++obj-$(CONFIG_GPIO_WDT) += old_gpio_wdt.o
37545 + obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o
37546 + obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
37547 + obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
37548 +--- /dev/null
37549 ++++ b/drivers/watchdog/old_gpio_wdt.c
37550 +@@ -0,0 +1,301 @@
37551 ++/*
37552 ++ * Driver for GPIO-controlled Hardware Watchdogs.
37553 ++ *
37554 ++ * Copyright (C) 2013 Mathias Adam <m.adam--linux@adamis.de>
37555 ++ *
37556 ++ * Replaces mtx1_wdt (driver for the MTX-1 Watchdog):
37557 ++ *
37558 ++ * (C) Copyright 2005 4G Systems <info@4g-systems.biz>,
37559 ++ * All Rights Reserved.
37560 ++ * http://www.4g-systems.biz
37561 ++ *
37562 ++ * (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org>
37563 ++ *
37564 ++ * This program is free software; you can redistribute it and/or
37565 ++ * modify it under the terms of the GNU General Public License
37566 ++ * as published by the Free Software Foundation; either version
37567 ++ * 2 of the License, or (at your option) any later version.
37568 ++ *
37569 ++ * Neither Michael Stickel nor 4G Systems admit liability nor provide
37570 ++ * warranty for any of this software. This material is provided
37571 ++ * "AS-IS" and at no charge.
37572 ++ *
37573 ++ * (c) Copyright 2005 4G Systems <info@4g-systems.biz>
37574 ++ *
37575 ++ * Release 0.01.
37576 ++ * Author: Michael Stickel michael.stickel@4g-systems.biz
37577 ++ *
37578 ++ * Release 0.02.
37579 ++ * Author: Florian Fainelli florian@openwrt.org
37580 ++ * use the Linux watchdog/timer APIs
37581 ++ *
37582 ++ * Release 0.03.
37583 ++ * Author: Mathias Adam <m.adam--linux@adamis.de>
37584 ++ * make it a generic gpio watchdog driver
37585 ++ *
37586 ++ * The Watchdog is configured to reset the MTX-1
37587 ++ * if it is not triggered for 100 seconds.
37588 ++ * It should not be triggered more often than 1.6 seconds.
37589 ++ *
37590 ++ * A timer triggers the watchdog every 5 seconds, until
37591 ++ * it is opened for the first time. After the first open
37592 ++ * it MUST be triggered every 2..95 seconds.
37593 ++ */
37595 ++#include <linux/module.h>
37596 ++#include <linux/moduleparam.h>
37597 ++#include <linux/types.h>
37598 ++#include <linux/errno.h>
37599 ++#include <linux/miscdevice.h>
37600 ++#include <linux/fs.h>
37601 ++#include <linux/init.h>
37602 ++#include <linux/ioport.h>
37603 ++#include <linux/timer.h>
37604 ++#include <linux/completion.h>
37605 ++#include <linux/jiffies.h>
37606 ++#include <linux/watchdog.h>
37607 ++#include <linux/platform_device.h>
37608 ++#include <linux/io.h>
37609 ++#include <linux/uaccess.h>
37610 ++#include <linux/gpio.h>
37611 ++#include <linux/old_gpio_wdt.h>
37613 ++static int ticks = 100 * HZ;
37615 ++static struct {
37616 ++ struct completion stop;
37617 ++ spinlock_t lock;
37618 ++ int running;
37619 ++ struct timer_list timer;
37620 ++ int queue;
37621 ++ int default_ticks;
37622 ++ unsigned long inuse;
37623 ++ unsigned gpio;
37624 ++ unsigned int gstate;
37625 ++ int interval;
37626 ++ int first_interval;
37627 ++} gpio_wdt_device;
37629 ++static void gpio_wdt_trigger(unsigned long unused)
37631 ++ spin_lock(&gpio_wdt_device.lock);
37632 ++ if (gpio_wdt_device.running && ticks > 0)
37633 ++ ticks -= gpio_wdt_device.interval;
37635 ++ /* toggle wdt gpio */
37636 ++ gpio_wdt_device.gstate = !gpio_wdt_device.gstate;
37637 ++ gpio_set_value(gpio_wdt_device.gpio, gpio_wdt_device.gstate);
37639 ++ if (gpio_wdt_device.queue && ticks > 0)
37640 ++ mod_timer(&gpio_wdt_device.timer, jiffies + gpio_wdt_device.interval);
37641 ++ else
37642 ++ complete(&gpio_wdt_device.stop);
37643 ++ spin_unlock(&gpio_wdt_device.lock);
37646 ++static void gpio_wdt_reset(void)
37648 ++ ticks = gpio_wdt_device.default_ticks;
37652 ++static void gpio_wdt_start(void)
37654 ++ unsigned long flags;
37656 ++ spin_lock_irqsave(&gpio_wdt_device.lock, flags);
37657 ++ if (!gpio_wdt_device.queue) {
37658 ++ gpio_wdt_device.queue = 1;
37659 ++ gpio_wdt_device.gstate = 1;
37660 ++ gpio_set_value(gpio_wdt_device.gpio, 1);
37661 ++ mod_timer(&gpio_wdt_device.timer, jiffies + gpio_wdt_device.first_interval);
37662 ++ }
37663 ++ gpio_wdt_device.running++;
37664 ++ spin_unlock_irqrestore(&gpio_wdt_device.lock, flags);
37667 ++static int gpio_wdt_stop(void)
37669 ++ unsigned long flags;
37671 ++ spin_lock_irqsave(&gpio_wdt_device.lock, flags);
37672 ++ if (gpio_wdt_device.queue) {
37673 ++ gpio_wdt_device.queue = 0;
37674 ++ gpio_wdt_device.gstate = 0;
37675 ++ gpio_set_value(gpio_wdt_device.gpio, 0);
37676 ++ }
37677 ++ ticks = gpio_wdt_device.default_ticks;
37678 ++ spin_unlock_irqrestore(&gpio_wdt_device.lock, flags);
37679 ++ return 0;
37682 ++/* Filesystem functions */
37684 ++static int gpio_wdt_open(struct inode *inode, struct file *file)
37686 ++ if (test_and_set_bit(0, &gpio_wdt_device.inuse))
37687 ++ return -EBUSY;
37688 ++ return nonseekable_open(inode, file);
37692 ++static int gpio_wdt_release(struct inode *inode, struct file *file)
37694 ++ clear_bit(0, &gpio_wdt_device.inuse);
37695 ++ return 0;
37698 ++static long gpio_wdt_ioctl(struct file *file, unsigned int cmd,
37699 ++ unsigned long arg)
37701 ++ void __user *argp = (void __user *)arg;
37702 ++ int __user *p = (int __user *)argp;
37703 ++ unsigned int value;
37704 ++ static const struct watchdog_info ident = {
37705 ++ .options = WDIOF_CARDRESET,
37706 ++ .identity = "GPIO WDT",
37707 ++ };
37709 ++ switch (cmd) {
37710 ++ case WDIOC_GETSUPPORT:
37711 ++ if (copy_to_user(argp, &ident, sizeof(ident)))
37712 ++ return -EFAULT;
37713 ++ break;
37714 ++ case WDIOC_GETSTATUS:
37715 ++ case WDIOC_GETBOOTSTATUS:
37716 ++ put_user(0, p);
37717 ++ break;
37718 ++ case WDIOC_SETOPTIONS:
37719 ++ if (get_user(value, p))
37720 ++ return -EFAULT;
37721 ++ if (value & WDIOS_ENABLECARD)
37722 ++ gpio_wdt_start();
37723 ++ else if (value & WDIOS_DISABLECARD)
37724 ++ gpio_wdt_stop();
37725 ++ else
37726 ++ return -EINVAL;
37727 ++ return 0;
37728 ++ case WDIOC_KEEPALIVE:
37729 ++ gpio_wdt_reset();
37730 ++ break;
37731 ++ default:
37732 ++ return -ENOTTY;
37733 ++ }
37734 ++ return 0;
37738 ++static ssize_t gpio_wdt_write(struct file *file, const char *buf,
37739 ++ size_t count, loff_t *ppos)
37741 ++ if (!count)
37742 ++ return -EIO;
37743 ++ gpio_wdt_reset();
37744 ++ return count;
37747 ++static const struct file_operations gpio_wdt_fops = {
37748 ++ .owner = THIS_MODULE,
37749 ++ .llseek = no_llseek,
37750 ++ .unlocked_ioctl = gpio_wdt_ioctl,
37751 ++ .open = gpio_wdt_open,
37752 ++ .write = gpio_wdt_write,
37753 ++ .release = gpio_wdt_release,
37754 ++};
37757 ++static struct miscdevice gpio_wdt_misc = {
37758 ++ .minor = WATCHDOG_MINOR,
37759 ++ .name = "watchdog",
37760 ++ .fops = &gpio_wdt_fops,
37761 ++};
37764 ++static int gpio_wdt_probe(struct platform_device *pdev)
37766 ++ int ret;
37767 ++ struct gpio_wdt_platform_data *gpio_wdt_data = pdev->dev.platform_data;
37769 ++ gpio_wdt_device.gpio = gpio_wdt_data->gpio;
37770 ++ gpio_wdt_device.interval = gpio_wdt_data->interval;
37771 ++ gpio_wdt_device.first_interval = gpio_wdt_data->first_interval;
37772 ++ if (gpio_wdt_device.first_interval <= 0) {
37773 ++ gpio_wdt_device.first_interval = gpio_wdt_device.interval;
37774 ++ }
37776 ++ ret = gpio_request(gpio_wdt_device.gpio, "gpio-wdt");
37777 ++ if (ret < 0) {
37778 ++ dev_err(&pdev->dev, "failed to request gpio");
37779 ++ return ret;
37780 ++ }
37782 ++ spin_lock_init(&gpio_wdt_device.lock);
37783 ++ init_completion(&gpio_wdt_device.stop);
37784 ++ gpio_wdt_device.queue = 0;
37785 ++ clear_bit(0, &gpio_wdt_device.inuse);
37786 ++ setup_timer(&gpio_wdt_device.timer, gpio_wdt_trigger, 0L);
37787 ++ gpio_wdt_device.default_ticks = ticks;
37789 ++ gpio_wdt_start();
37790 ++ dev_info(&pdev->dev, "GPIO Hardware Watchdog driver (gpio=%i interval=%i/%i)\n",
37791 ++ gpio_wdt_data->gpio, gpio_wdt_data->first_interval, gpio_wdt_data->interval);
37792 ++ return 0;
37795 ++static int gpio_wdt_remove(struct platform_device *pdev)
37797 ++ /* FIXME: do we need to lock this test ? */
37798 ++ if (gpio_wdt_device.queue) {
37799 ++ gpio_wdt_device.queue = 0;
37800 ++ wait_for_completion(&gpio_wdt_device.stop);
37801 ++ }
37803 ++ gpio_free(gpio_wdt_device.gpio);
37804 ++ misc_deregister(&gpio_wdt_misc);
37805 ++ return 0;
37808 ++static struct platform_driver gpio_wdt_driver = {
37809 ++ .probe = gpio_wdt_probe,
37810 ++ .remove = gpio_wdt_remove,
37811 ++ .driver.name = "gpio-wdt",
37812 ++ .driver.owner = THIS_MODULE,
37813 ++};
37815 ++static int __init gpio_wdt_init(void)
37817 ++ return platform_driver_register(&gpio_wdt_driver);
37819 ++arch_initcall(gpio_wdt_init);
37821 ++/*
37822 ++ * We do wdt initialization in two steps: arch_initcall probes the wdt
37823 ++ * very early to start pinging the watchdog (misc devices are not yet
37824 ++ * available), and later module_init() just registers the misc device.
37825 ++ */
37826 ++static int gpio_wdt_init_late(void)
37828 ++ int ret;
37830 ++ ret = misc_register(&gpio_wdt_misc);
37831 ++ if (ret < 0) {
37832 ++ pr_err("GPIO_WDT: failed to register misc device\n");
37833 ++ return ret;
37834 ++ }
37835 ++ return 0;
37837 ++#ifndef MODULE
37838 ++module_init(gpio_wdt_init_late);
37839 ++#endif
37841 ++static void __exit gpio_wdt_exit(void)
37843 ++ platform_driver_unregister(&gpio_wdt_driver);
37845 ++module_exit(gpio_wdt_exit);
37847 ++MODULE_AUTHOR("Michael Stickel, Florian Fainelli, Mathias Adam");
37848 ++MODULE_DESCRIPTION("Driver for GPIO hardware watchdogs");
37849 ++MODULE_LICENSE("GPL");
37850 ++MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
37851 ++MODULE_ALIAS("platform:gpio-wdt");
37852 +--- /dev/null
37853 ++++ b/include/linux/old_gpio_wdt.h
37854 +@@ -0,0 +1,21 @@
37855 ++/*
37856 ++ * Definitions for the GPIO watchdog driver
37857 ++ *
37858 ++ * Copyright (C) 2013 Mathias Adam <m.adam--linux@adamis.de>
37859 ++ *
37860 ++ * This program is free software; you can redistribute it and/or modify
37861 ++ * it under the terms of the GNU General Public License version 2 as
37862 ++ * published by the Free Software Foundation.
37863 ++ *
37864 ++ */
37866 ++#ifndef _GPIO_WDT_H_
37867 ++#define _GPIO_WDT_H_
37869 ++struct gpio_wdt_platform_data {
37870 ++ int gpio; /* GPIO line number */
37871 ++ int interval; /* watchdog reset interval in system ticks */
37872 ++ int first_interval; /* first wd reset interval in system ticks */
37873 ++};
37875 ++#endif /* _GPIO_WDT_H_ */
37876 diff --git a/target/linux/generic/patches-3.16/997-device_tree_cmdline.patch b/target/linux/generic/patches-3.16/997-device_tree_cmdline.patch
37877 new file mode 100644
37878 index 000000000000..bc8e7091d5d8
37879 --- /dev/null
37880 +++ b/target/linux/generic/patches-3.16/997-device_tree_cmdline.patch
37881 @@ -0,0 +1,12 @@
37882 +--- a/drivers/of/fdt.c
37883 ++++ b/drivers/of/fdt.c
37884 +@@ -817,6 +817,9 @@ int __init early_init_dt_scan_chosen(uns
37885 + p = of_get_flat_dt_prop(node, "bootargs", &l);
37886 + if (p != NULL && l > 0)
37887 + strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
37888 ++ p = of_get_flat_dt_prop(node, "bootargs-append", &l);
37889 ++ if (p != NULL && l > 0)
37890 ++ strlcat(data, p, min_t(int, strlen(data) + (int)l, COMMAND_LINE_SIZE));
37892 + /*
37893 + * CONFIG_CMDLINE is meant to be a default in case nothing else
37894 diff --git a/target/linux/generic/patches-3.16/998-enable_wilink_platform_without_drivers.patch b/target/linux/generic/patches-3.16/998-enable_wilink_platform_without_drivers.patch
37895 new file mode 100644
37896 index 000000000000..d317de1102ca
37897 --- /dev/null
37898 +++ b/target/linux/generic/patches-3.16/998-enable_wilink_platform_without_drivers.patch
37899 @@ -0,0 +1,15 @@
37900 +We use backports for driver updates - make sure we can compile in the glue code regardless
37902 +Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
37904 +--- a/drivers/net/wireless/ti/Kconfig
37905 ++++ b/drivers/net/wireless/ti/Kconfig
37906 +@@ -15,7 +15,7 @@ source "drivers/net/wireless/ti/wlcore/K
37908 + config WILINK_PLATFORM_DATA
37909 + bool "TI WiLink platform data"
37910 +- depends on WLCORE_SDIO || WL1251_SDIO
37911 ++ depends on WLCORE_SDIO || WL1251_SDIO || ARCH_OMAP2PLUS
37912 + default y
37913 + ---help---
37914 + Small platform data bit needed to pass data to the sdio modules.
37916 2.1.1