开发者

Code Connecting Hardware and Software in Modern OS

开发者 https://www.devze.com 2022-12-11 08:36 出处:网络
Im a bit confused on how software interacts with the hardware even though Ive taken a computer organization class.开发者_运维技巧

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.


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


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.

Code Connecting Hardware and Software in Modern OS


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消