From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7097 invoked by alias); 20 Jul 2005 17:02:55 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 7073 invoked by uid 22791); 20 Jul 2005 17:02:49 -0000 Received: from smtp1.libero.it (HELO smtp1.libero.it) (193.70.192.51) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 20 Jul 2005 17:02:49 +0000 Received: from localhost (172.16.1.84) by smtp1.libero.it (7.0.027-DD01) id 42C16E9D004CBB55 for ecos-discuss@sourceware.org; Wed, 20 Jul 2005 19:02:46 +0200 Received: from libero.it (172.16.1.88) by smtp1.libero.it (7.0.027-DD01) id 42C16E5C00337615 for ecos-discuss@sourceware.org; Wed, 20 Jul 2005 19:02:45 +0200 Date: Wed, 20 Jul 2005 17:02:00 -0000 Message-Id: MIME-Version: 1.0 X-Sensitivity: 3 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable From: "Enrico Piria" To: "ecos-discuss" X-XaM3-API-Version: 4.1 (B27pl2) X-type: 0 X-SenderIP: 62.101.126.208 Subject: [ECOS] Memory mapped IO X-SW-Source: 2005-07/txt/msg00201.txt.bz2 Hello. I'm rewriting the port of eCos to ColdFire. This processor has a large number of IO registers mapped to memory. I have two alternatives in writing code to manage the IO registers. The first one is to use a data structure that maps all the registers, like the following: typedef volatile struct { cyg_uint32 reg1; cyg_uint16 reg2; cyg_uint16 pad;=0D } __attribute__ ((aligned (4), packed)) regs_t; Then I can assign the base address of the registers to a pointer of type regs_t: regs_t *regs =3D (regs_t *)BASE_ADDRESS; and start using the structure: regs->reg2 =3D regs->reg2 + VALUE; However, although the GCC produces the correct code, nothing guarantees that read/write accesses to the registers will be done in a single instruction (ColdFire permits 8, 16, or 32 bit read or write accesses to memory). The alternative is to use the=0D HAL_READ_UINTx/HAL_WRITE_UINTx macros. However, the code this way becomes much less readable: cyg_uint16 tmpvariable; HAL_READ_UINT16(®s->reg2, tmpvariable); HAL_WRITE_UINT16(®s->reg2, tmpvariable + VALUE); Moreover, this code is error prone, because I need to specify the size of the access. What is the better thing to do? Thank you Enrico ____________________________________________________________ Libero Flat, sempre a 4 Mega a 19,95 euro al mese!=20 Abbonati subito su http://www.libero.it -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss