Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-28-2006, 03:06 PM   #1
Registered: May 2005
Location: PA
Distribution: Ubuntu
Posts: 204

Rep: Reputation: 30
Question register offset?


I m trying to make sense of the following code, what does the register offset mean?

/* register offset */

Old 07-28-2006, 03:20 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.

That said - I assume it's a macro that makes that piece of code
more machine independent?

Old 07-28-2006, 05:49 PM   #3
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Well, the definitions are a little strange. It looks to me like a register map. REG_OFFSET is likely defined somewhere to be 4 or 8 (depending on whether the processor is 32- or 64-bit).

In essence it's saying that the values for OFS_RCV_BUFFER, OFS_TRANS_HOLD, and OFS_SEND_BUFFER are all stored in the same register. The next line suggests that OFS_INTR_ENABLE is stored in the next available register. I've seen many hardware designs where the device's control registers occupy a block of memory (memory-mapped that is) and each individual register is addressed by adding the register's offset to the base address of the memory block. Something like this:

send_buffer = *(volatile unsigned *)(REGISTER_BASE + OFS_SEND_BUFFER); /* Register read */

*(volatile unsigned *)(REGISTER_BASE + OFS_INTR_ENABLE) = 0xFFFFFFF0;  /* Register write */
It's odd to do things that way unless the programmer expects the size of the registers to change (which is what I believe Tinkster was referring to). However, changing the register size has tons of other implications: do the individual fields within the same register change their bit widths, or are the extra bits added simply wasted? If they change, the bit masks need to be updated, etc.

I find it odd, but then again, I haven't seen everything so...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
offset on lm-sensor? bobbens Linux - Hardware 3 01-20-2005 03:34 PM
Download-Offset possible? Cornholio Linux - Software 0 01-10-2005 03:47 AM
monitor offset moschi Linux - Newbie 3 04-18-2004 11:09 AM
Print-out is offset Cichlid Linux - Hardware 1 05-06-2002 04:54 AM
Mouse Offset Problem AgedMan Linux - General 1 12-03-2001 11:08 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:46 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration