tags:

views:

186

answers:

5

Im a bit confused on how software interacts with the hardware even though Ive taken a computer organization class.

Where can I find the code from a OS like Linux or BSD, or even of C that allows the abstraction of hardware.

Are there any good material's which I can read to fully understand the interaction of hardware and software.

A: 

Any OS kernel, like, uhm, Linux or *BSD kernel.

dottedmag
+1  A: 

A great (although pricey) introduction that goes from C to assembly to machine code to logic circuits is Introduction to Computing Systems: From bits & gates to C & beyond by Yale Patt. This book really help me understand how things build upon each other and how computer hardware works.

Introduction to Computing Systems

John Paulett
+1  A: 

Well, you can get the Linux source from www.kernel.org and NetBSD source from http://cvsweb.netbsd.org/ but those are very large kernels with over one million lines of code; not really great introductory material.

Here is a thought: read Wikipedia's list of computer system emulators and find one that looks interesting, works on a platform you have, and comes with example code and stand-alone programs. Write some stand-alone code.

You can do this on a real PC but it's a slower process with less debugging and less visibility.

DigitalRoss
+1  A: 

The overwhelmingly most common abstraction is through a device driver, a software component which is responsible for directly dealing with the hardware and providing a standard interface to the operating system. Typically the o/s interface has functions like init(), uninit(), start_io(), handle_interrupt(), and some control and status functions.

A device driver has intimate knowledge of the device as well as the hardware interface to the device. For example, a typical disk interface has five or so sequential memory locations somewhere which constitute the controller's interface. The first is typically a status and control register. That is, reading returns a bit indicating whether it is busy executing a command; another bit indicates whether it has extended status information available. Writing to the "CSR" (as it is typically TLAified, control status register) initiates commands such as "send a command to disk controller", "read extended status from disk controller", etc. Another register takes a command code (reset, read data, write data, etc.). The other registers are typically address pointers indicating where within the computer's physical memory space to transfer data to or from.

Be warned: attempting to read a device driver to figure out how a computer system works is like trying to figure out how a forest works by studying the roots of a sapling. It's one of many important components, but follow where it leads and eventually you'll see the whole picture.

wallyk
+2  A: 

I found this lecture to be pretty damned amazing: http://video.google.com/videoplay?docid=7654043762021156507#

Crowe T. Robot