From owner-freebsd-hackers Sat Dec 14 3:34: 9 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D044537B401 for ; Sat, 14 Dec 2002 03:34:08 -0800 (PST) Received: from smtp-relay.omnis.com (smtp-relay.omnis.com [216.239.128.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 80FAB43E4A for ; Sat, 14 Dec 2002 03:34:08 -0800 (PST) (envelope-from wes@softweyr.com) Received: from softweyr.com (dslpool2-019.networldnoc.net [209.63.227.179]) by smtp-relay.omnis.com (Postfix) with ESMTP id E32F743A04; Sat, 14 Dec 2002 03:31:12 -0800 (PST) Message-ID: <3DFB1714.C98D3F75@softweyr.com> Date: Sat, 14 Dec 2002 03:33:40 -0800 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.2 i386) X-Accept-Language: en MIME-Version: 1.0 To: "M. Warner Losh" Cc: langd-freebsd-hackers@leo.org, freebsd-hackers@FreeBSD.ORG Subject: Re: more kernel programming style questions References: <20021213115507.GE84493@atrbg11.informatik.tu-muenchen.de> <20021213.182741.39658511.imp@bsdimp.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG "M. Warner Losh" wrote: > > You are better off defining a series of macros that do proper > bus_space_readN/bus_space_writeN for each of the fields in the > register set. This will ensure that your driver works unaltered on > other architectures. > > Directly accessing memory mapped devices is a bad idea. While it > works on i386, there are some platforms that have special alignment > constraints that the underlying hardware doesn't always follow. As an example, I/O devices on the SPARC architecture are almost always placed in an "alternate address space" which means they have to be accessed using different instructions (LDA/STA) than those that access memory (LD/ST). Attempting memory I/O to devices on SPARC is doomed to failure. It's a whole new (portable) world, folks... -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message