From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 20 20:22:11 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EECA0106566C for ; Tue, 20 Jan 2009 20:22:11 +0000 (UTC) (envelope-from gonzo@bluezbox.com) Received: from core.tav.kiev.ua (tavex.colocall.com [62.149.10.42]) by mx1.freebsd.org (Postfix) with ESMTP id 8AEE58FC12 for ; Tue, 20 Jan 2009 20:22:11 +0000 (UTC) (envelope-from gonzo@bluezbox.com) Received: from [209.52.235.211] (helo=[10.80.5.136]) by core.tav.kiev.ua with esmtpsa (SSLv3:AES256-SHA:256) (Exim 4.52 (FreeBSD)) id 1LPMXY-000A3d-VZ for freebsd-hackers@freebsd.org; Tue, 20 Jan 2009 21:45:38 +0200 Message-ID: <4976297C.7020405@bluezbox.com> Date: Tue, 20 Jan 2009 11:43:56 -0800 From: Oleksandr Tymoshenko User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Core-Spam-Level: ---- X-Core-Spam-Report: Spam detection software, running on the system "core.tav.kiev.ua", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Yesterday I ran into a "problem" with uart(4) on big-endian MIPS board. uart code treats registers as bytes and reads/writes them using bus_space_read_1/bus_space_write_1. To handle word-aligned registers we have regshft in uart_bas structure. It works for little-endian flags where lowest byte resides at uart_base + (regnum << regshft) address but for big endian targets actual data resides at uart_base + ((regnum + 1) << regshft) - 1. [...] Content analysis details: (-4.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] Subject: uart and big-endian targets X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jan 2009 20:22:12 -0000 Yesterday I ran into a "problem" with uart(4) on big-endian MIPS board. uart code treats registers as bytes and reads/writes them using bus_space_read_1/bus_space_write_1. To handle word-aligned registers we have regshft in uart_bas structure. It works for little-endian flags where lowest byte resides at uart_base + (regnum << regshft) address but for big endian targets actual data resides at uart_base + ((regnum + 1) << regshft) - 1. One way to solve it is to increase uart_base when setting uart_bas, but it's not obvious and requires knowledge of uart(4) internals. I think better solution would be to take into account endianess when defining uart_regofs. Or if other BE devices have data in highest byte new field should be added to uart_bas (defaulted to 0) Any thoughts? -- gonzo