473,320 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help needed with bus access classes

4
I am trying to write a set of classes, probably template classes, to allow "pretty" and safe access to low level machine words.

The syntax I would like to end up with is something like:
Expand|Select|Wrap|Line Numbers
  1. foo = handle.vendor_id.get();
where handle would represent, in this case, the PCI config space, vendor_id is a particular offset into that space, and get is a method to retrieve the current value.

To add complexity, some registers are a set of bits or bit fields. The command register in PCI config space is a good example. So I would like to be able to also say
Expand|Select|Wrap|Line Numbers
  1. dog = handle.IO_enable.get();
In this case, IO_enable is a particular bit from the command register which is a particular offset from the base of the handle.

The dream is to be able to define sets of classes. One type of class would provide the basic access method to the bus. Another set of classes would provide full register access but the registers come in 1, 2, 4, and 8 byte sizes. The third set would provide bit access for a particular register where the bit fields would require a bit offset and a size in bits of the field.

Once these classes are defined, then I could do things like:
Expand|Select|Wrap|Line Numbers
  1. class pcicfg {
  2.   pcicfg_access acc;
  3.   field<acc, uint16_t, 0> vendor_id;
  4.   field<acc, uint16_t, 2> device_id;
  5.   field<acc, uint16_t, 4> command;
  6.   bitfield<command, 0, 1> IO_enable;
  7. };
The key is that fields need to reference the access method and bit fields need to reference fields. I can not figure out a way to accomplish this -- a way that one member can reference another member.

I've attempted to use some metaprogramming concepts but I never got anything useful. It sounds really complex but the key that I'd like to keep is all of the information after the access method is constant. And, sometimes, the access method will simply be traversing a pointer. So I'd like to get the access to a bit field to able to compile down to what you would normally get from straight C.

For example, for the case that the PCI bus is mapped, then this:
Expand|Select|Wrap|Line Numbers
  1. foo = other_handle.some_bitfield.get();
could be boiled down to
Expand|Select|Wrap|Line Numbers
  1. foo = ((*(uint16_t *)(other_handle.c_ptr + offset)) >> shift) & mask;
where offset, shift, and mask are constants.

I hope all this makes some sense. Any help or guidence would greatly be appreciated.
Oct 19 '06 #1
0 1389

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ken Varn | last post by:
I have a named mutex object that is accessed by both an asp.net application and a Windows executable .net application. The Windows executable runs under the administrator logon, while the asp.net...
8
by: M O J O | last post by:
Hi, I'm creating an CRM solution for my company. I want to split up the solution into several classlibraries, so I dont need to build the entire solution every time I run my project. First...
14
by: away | last post by:
1. It is showed in a book that a class has all member variables declared as protected. What's the reason for doing this? 2. Unnamed namespace and global scope, are they equivalent to each other?...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: cm500 | last post by:
I'm very new to databases so bear with me. What I need is a way to track the training for the employees at my firm. I have 40 classes that I will be teaching on various subjects and various...
10
by: Angel | last post by:
I'm using several C functions (in a dll) that receive a struct as parameter. Since I'm doing it in C#, I assume I need to recreate the struct in C# in order to call the function with the required...
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
9
by: Chrissy | last post by:
I took a C# class as an elective and received an incomplete in it and am desparate for help. I have two assignments left (arrays and inheritance) and would gladly pay anyone that can assist me with...
5
by: alck1234 | last post by:
Hi, I need help on my mini project on object orientated programming. The question goes like this: A mini-mart has just installed a bar code reader to improve efficiency at their checkouts....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.