Memory mapped hardware registers

From: Simon Paradis (see.end.of.message_at_globetotter.net)
Date: 01/23/05


Date: Sun, 23 Jan 2005 16:03:29 GMT

Hi,

I'm developping board support code for an embedded m68k system. The actual
MCU is a MC68331 that has a CPU32 core (more or less a 68020). This MCU
define hardware registers at specific memory locations. My toolchain is
composed of GCC 3.4.3 and binutils 2.15.

It possible to define a variable that would be placed at specific location
using gcc or linker script hacks ? It would avoid using a pointer to access
a register. I don't care if this is non portable and/or gcc/binutils
specific.

For example, the CPU32 has the SIMCR 16-bits register placed at 0xFFFA00.

typedef unsigned short word;

/* SIMCR (0xYFFA00): SIM Configuration */
typedef struct _SIMCR {
    word exoff : 1;
    word frzsw : 1;
    word frzbm : 1;
    word _UNUSED_1 : 1;
    word slven : 1;
    word _UNUSED_2 : 1;
    word shen : 2;
    word supv : 1;
    word mm : 1;
    word _UNUSED_3 : 2;
    word iarb : 4;
} SIMCR;

How can I place a single SIMCR structure at 0xFFFA00 ? I guess some linker
magic is involved ? Also, the actual variable must be left uninitialized;
you don't want init code to overwrite the register with zeros as this will
crash the MCU.

Thanks,

Simon Paradis
simon _dot_ paradis _at_ usherbrooke _dot_ ca



Relevant Pages

  • Re: gcc return reg on inline asm
    ... gcc ended up using eax as ... It was valid code as far as gcc was concerned ... way I know of to tell GCC that the result is in the flags register, ... way to do it, but as you've probably noticed by now, the only register pair ...
    (comp.lang.asm.x86)
  • Re: [klibc 37/43] x86_64 support for klibc
    ... +#undef NSIG ... I can't remove the workaround just yet, since I have active users of the ... were hard-coded in the patterns (using register variables, ... on older gcc versions. ...
    (Linux-Kernel)
  • Re: gcc inline assembly: when should one use the `% modifier?
    ... register and one is in memory then the register has to be listed first ... Describe one set and tell gcc that it doesn't matter which operand ... int main ...
    (comp.lang.asm.x86)
  • Re: [tip:x86/asm] x86/i386: Make sure stack-protector segment base is cache aligned
    ... developers to allow different segment register and offset in newer gcc ... get to keep the separate segment register from the userland. ... sane thing and having a symbol for an offset is probably worse. ...
    (Linux-Kernel)
  • Re: clobbered registers
    ... as you can notice there is no reload of the register edx between the ... I use gcc 3.4.4 with the following options: ... movl %esp, %ebp ... movb %dl,16 ...
    (comp.lang.asm.x86)