From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from inx.pm.waw.pl ([195.116.170.130]) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1Parip-0004id-3A for barebox@lists.infradead.org; Thu, 06 Jan 2011 15:25:52 +0000 From: Krzysztof Halasa References: Date: Thu, 06 Jan 2011 16:25:20 +0100 In-Reply-To: (Krzysztof Halasa's message of "Thu, 06 Jan 2011 15:48:38 +0100") Message-ID: MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 2/3] ARM: support big/little endian switching in "bootX". To: barebox@lists.infradead.org Q3VycmVudGx5IGltcGxlbWVudGVkIG9ubHkgaW4gImJvb3R6Ii4KClNpZ25lZC1vZmYtYnk6IEty enlzenRvZiBIYcWCYXNhIDxraGNAcG0ud2F3LnBsPgoKZGlmZiAtLWdpdCBhL2FyY2gvYXJtL2Nw dS9LY29uZmlnIGIvYXJjaC9hcm0vY3B1L0tjb25maWcKaW5kZXggMzU3MmExZi4uOGVlN2Q2YyAx MDA2NDQKLS0tIGEvYXJjaC9hcm0vY3B1L0tjb25maWcKKysrIGIvYXJjaC9hcm0vY3B1L0tjb25m aWcKQEAgLTczLDYgKzczLDE1IEBAIGNvbmZpZyBDUFVfQklHX0VORElBTgogCSAgcG9ydCBtdXN0 IHByb3Blcmx5IGVuYWJsZSBhbnkgYmlnLWVuZGlhbiByZWxhdGVkIGZlYXR1cmVzCiAJICBvZiB5 b3VyIGNoaXBzZXQvYm9hcmQvcHJvY2Vzc29yLgogCitjb25maWcgQk9PVF9FTkRJQU5ORVNTX1NX SVRDSAorCWJvb2wgIlN1cHBvcnQgc3dpdGNoaW5nIG9mIExpbnV4IGtlcm5lbCBlbmRpYW5uZXNz IgorCWhlbHA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