Understanding Hardware

  • Be sure to checkout “Tips & Tricks”
    Dear Guest Visitor → Once you register and log-in:

    This forum does not automatically send notices of new content. So if, for example, you would like to be notified by mail when Steve posts an update to his blog (or of any other specific activity anywhere else), you need to tell the system what to “Watch” for you. Please checkout the “Tips & Tricks” page for details about that... and other tips!

    /Steve.
  • A Patch for SpinRite 6.0's Division Overflow
    Please see my blog posting for the whole story!

coffeeprogrammer

Well-known member
Jul 19, 2021
87
7
So this might be a somewhat lengthy post but I'm trying to figure something out about computer hardware. I am attempting to understand more clearly how software such as drivers, but I guess in the technical sense it wouldn't have to be a driver, communicates with a given piece of hardware (video card, sound card, ethernet card, web cam). A few weeks ago Steve recommended the humble bundle book package which included Introduction to Computer Organization. That book answered some of my questions as chapter 20 talks about port-mapped i/o and memory mapped i/o which am assuming drivers use this technique. I can see in my device manager under the resources tab of my video card memory ranges and I/O ranges which must be what this is referring to. So basically using these memory mappings i/o ranges do typical hardware devices such as video cards or web cams, ethernet cards have something like registers the way CPU has registers and that's how you write data to these devices? Particular drivers know about particular registers and other hardware in devices such as a realtek chipset in a ethernet card? I believe that in some ways Windows drivers basically treat a piece of hardware like a file, writing and reading to it for input and output. We also know that Linux treats every device as a file. But how is it one would know exactly what read or write in terms of the bits? Again, registers and what else perhaps? If a person knew the chips and on a classic sound blaster card, could you in theory produce sound on it using an assembler program. I know as "in" and "out" are assembler instructions for hardware. I also noticed in the SpinRite dev folder a SATA-AHCI-Spec pdf. Is this needed to write the spinrite assembler code that talks to a hard disk, does this document discuss non-processor registers? If so, do all devices that sit on a bus have there own kind of registers? What about DMA? I think Steve has talked about that in regards to SpinRite. Is this what the Windows HAL api are for? Abstracting these things from different kinds of hardware? I apologize in advance if this is just too confusing of a post. I've been reading multiple sources and in many cases speed reading to get some generic answers. Thanks.


Chad
 

PHolder

Well-known member
Sep 16, 2020
1,063
2
472
Ontario, Canada
A computer has a bus. All the devices, the ROM and the RAM and the CPU and GPU and everything in the system connect to the bus. The bus is basically a series of address lines and data lines and signalling lines. When the CPU wants to read memory, it puts the address on the bus, sets the signal for a read, and waits for the RAM to signal the availability of the data, and then it gets the data off the data lines. (This is overly simplistic, especially with DMA and other things possible, but that is still the basic framing of the system.) Different I/O devices can exist at different addresses, and this day in age there are protocols to detect devices so they can be moved around to avoid address collisions (so called plug and play.)

I recommend you seek out the videos by Ben Eater, as he builds a 6502 computer from the basics. He even builds a VGA card, of sorts.
 

Paul F

Well-known member
Sep 17, 2020
47
12
Toronto
... I can see in my device manager under the resources tab of my video card memory ranges and I/O ranges which must be what this is referring to. So basically using these memory mappings i/o ranges do typical hardware devices such as video cards or web cams, ethernet cards have something like registers the way CPU has registers and that's how you write data to these devices? ...

Yes. Here is an example of the many registers in a video controller chip:
It's common to have an address register and a data register. They use up two PC I/O addresses but the address register can address many internal data registers in the chip.
 
  • Like
Reactions: fcgreg

FredBrehm

New member
Sep 24, 2020
1
1
New Jersey
Here's an example of how to program a simple device. A UART has 8 8-bit registers that are memory mapped somewhere in memory. Usually there is some memory range where all I/O device registers are mapped. You have to know the base address of the device registers. Then you program the device registers to perform the functions you need to use.

 
  • Like
Reactions: fcgreg

coffeeprogrammer

Well-known member
Jul 19, 2021
87
7
A computer has a bus. All the devices, the ROM and the RAM and the CPU and GPU and everything in the system connect to the bus. The bus is basically a series of address lines and data lines and signalling lines. When the CPU wants to read memory, it puts the address on the bus, sets the signal for a read, and waits for the RAM to signal the availability of the data, and then it gets the data off the data lines. (This is overly simplistic, especially with DMA and other things possible, but that is still the basic framing of the system.) Different I/O devices can exist at different addresses, and this day in age there are protocols to detect devices so they can be moved around to avoid address collisions (so called plug and play.)

I recommend you seek out the videos by Ben Eater, as he builds a 6502 computer from the basics. He even builds a VGA card, of sorts.
Ya the Ben Eater stuff is a must, I watched a different youtuber (EE Professor from the UK) he design a ALU. Had a multiplexer going to gates that was either the arithmetic or the logic. I don’t know exactly was a multiplexer is, but I think it amounted to making control lines for whatever operation and maybe the control lines are indicated by the machine code. Just my guess. But did remind me of Ben Eater and where he design a ALU, he had a quite long playlist as I recall. So much material, just wonderful.
 
  • Like
Reactions: fcgreg