This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: REG macros in hal_xscale.h


On Tue, 2004-09-28 at 18:20, Moseley, Drew wrote:
> Are the REG8/REG16/REG32 macros in hal_xscale.h misdefined for assembler
> code?  I attempted to use these in assembler code w/ a base register and
> obvoously the code failed.
...
>  #ifdef __ASSEMBLER__
>  
> -#define REG8(a,b)  (b)
> -#define REG16(a,b) (b)
> -#define REG32(a,b) (b)

These are the intended definitions where 'a' is a base address
and "b" is the offset. For instance, hal_ixp425.h has:

// SDRAM Registers  (Chapter 7)
#define IXP425_SDRAM_CFG_BASE      0xCC000000
#define IXP425_SDRAM_CFG_SIZE      0x00100000
#define IXP425_SDRAM_CONFIG        REG32(IXP425_SDRAM_CFG_BASE,0x00)
#define IXP425_SDRAM_REFRESH       REG32(IXP425_SDRAM_CFG_BASE,0x04)
#define IXP425_SDRAM_IR            REG32(IXP425_SDRAM_CFG_BASE,0x08)

The address of the SDRAM_REFRESH reg is 0xCC000004. To access the
SDRAM controller registers in asm, you'd load a register with the
base address and then use a constant offset from that register.
Something like:

   ldr r0, =IXP425_SDRAM_CFG_BASE
   ldr r1, [r0, #IXP425_SDRAM_CONFIG]
   ldr r2, [r0, #IXP425_SDRAM_REFRESH]

For C code, the macros add the base and offset together so you 
access like:

  *IXP425_SDRAM_CONFIG = 0;

--Mark




-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]