I got it!!!
In the gcc compiler book (5.33 Specifying Attributes of Types):
I needed: __attribute__ ((packed))
Like so:
typedef struct Reg_struct
{
int32_t isConn;
int32_t cfgIdx;
int32_t cfgOff;
int32_t regOff;
int32_t regNum;
int32_t regDir;
} __attribute__ ((packed)) Reg;
Thank you everyone for all your help!!!!!!!!!!!!!
Eric
--- In Triffid Hunter <> wrote:
>
> On Tue, 1 Apr 2008, berryma4 wrote:
>
> >
> >
> > Hello!
> >
> > I'm still having problems understanding what's wrong. I've made some
> > changes (below is a new code snippet), adding the volatile and my g++
> > looks like this:
> >
> > It seems like I don't understand what I'm writing to.
> > preg->regOff = (TS_OUTB_DPORT_A) //This doesn't work
> > preg->regOff = (TS_OUTB_DPORT_A << 16) //While this does
>
> try the functions from peekpoke.h on ts' ftp. gcc occasionally uses the
> wrong instructions to read and write instead of 32 bit atomic ones,
which
> does strange things to word aligned registers.
>
>
ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7250-linux/samples/peekpoke.h is
> the address.
>
> > /* Declare register info structure */
> > typedef struct Reg_struct
> > {
> > volatile unsigned int isConn;
> > volatile unsigned int cfgIdx;
> > volatile unsigned int cfgOff;
> > volatile unsigned int regOff;
> > volatile unsigned int regNum;
> > volatile unsigned int regDir;
> > } Reg;
>
> You may want to be explicit about how large these are, as int is
different
> sizes on different platforms. #include <stdint.h> and declare them as
> volatile uint32_t (uint32_t is unsigned 32 bit integer type).
>
> > static asynStatus create(void* ppvt,asynUser* pasynUser,const char*
> > drvInfo, const char** pptypeName,size_t* psize)
> > {
> > int addr = -1;
> > volatile Reg* preg = NULL;
> > volatile Port* pport = (Port*)ppvt;
> >
> > switch( pport->type )
> > {
> > case TS_7200:
> > printf("XX0: 0x%x\n",preg->cfgOff);
> > printf("XX1: 0x%x\n",preg->regOff);
>
> Looks like preg is being used here while initialised to NULL - is that
> really what you want?
>
> > if( addr < 1 ){
> > preg->cfgOff = (TS_DIOCR_DIRA << 16);
>
> try PEEK32 here, see if it makes a difference
>
> > printf("DirA: 0x%x 0x%x\n",preg->cfgOff,TS_DIOCR_DIRA);}
>
> It would be interesting to disassemble the results (with objdump) and
> compare
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|