PDA

View Full Version : Hardware Interfacing


Jones
2006.09.15, 10:02 PM
Hardware programming has always been a subject that fascinates me. The closest thing I've come to it is a little robotic owl I have that you plug into a computer and then program with using C. I didn't use it much because I never managed to get it to use the compiled firmware the manual tells you to upload.

Recently I've been interested in how a computer interfaces with it's hardware. (Audio, graphics cards, etc...) I wondered how OS's talked to the computer so I downloaded the sources to Linux and ReactOS and poked around inside them. I understood none of it, naturally. :p

How does one send a message/signal to hardware using C or C++ (higher level languages I mean, rather than assembly) ? I assume that in all PC's there are standards like "Video card is at bus id 0x000034A" or something but at some stage there must be a way to send stuff to that bus to execute.

Does OpenGL do this directly or handle it through the OS?

I'm looking for texts on the subject and maybe a bit of sample code to look at. I took a peek at Apple's Kernel Extensions sample code for audio drivers but once again, understood none of it. It also appeared to use apple driver frameworks which is not what I want to learn about. I want to learn about how those frameworks were written, not how to use them.

So anyways, like I said, know of any texts or resources on the subject?

Thanks!

BinarySpike
2006.09.16, 12:59 AM
What kind of hardware interfacing?
Drivers?
LCD displays...
USB communication...
Robotics...

LCD and robotics like that owl are mostly the same though... fun... but the same :-P

akb825
2006.09.16, 01:08 AM
I know OS X is a little more restrictive with its access than other systems. For example, they don't allow you to interface directly with the VRAM on your video card. However, if you were to have a USB peripheral, for example, you'd be completely free to implement it. It's just a matter of finding the address for it, then sending and receiving data. Unfortunately, I don't have any texts to explain it.

Jones
2006.09.16, 01:35 PM
That's one of things I'd like to learn to do. Driver coding, as boring as it may sound.

akb825
2006.09.16, 02:30 PM
Well, if everybody found it boring, then likely nobody would do it and we'd have a real problem. :p

unknown
2006.09.16, 03:08 PM
I suppose the best thing to do would be to learn to program with assembly and also learn in detail how a computer works (at the hardware level, acessing memory, fetch execute etc etc).
Then maybe take a look at macam source code, there is also probably a huge amount you could learn from various linux drivers as well.

sh4ggy87
2006.09.16, 07:45 PM
http://en.wikipedia.org/wiki/Memory-mapped_I/O

Though, you can't directly write to memory from a userspace program. To really understand drivers for OS X, you'll need to have a decent understanding of computer architecture and OS design.

IMHO, an easy (maybe) first step would be learning embedded systems programming with something like PIC, AVR, 6812, etc. This would give you a good start on computer architecture and how to use assembly as well as how to interface with hardware in a system without an OS.

Then you could learn OS principles, and hopefully, the linux code would start making sense ;)

Stalin55
2006.09.17, 01:00 AM
Hardware programming has always been a subject that fascinates me.

Go and by the book "Code". The books first explains to you all of the basic foundations that you will need to know to gain a basic understanding of computer software and hardware. I cannot stress strongly enough how good a book this is.