Understanding Hardware

  • SpinRite v6.1 Release #3
    Guest:
    The 3rd release of SpinRite v6.1 is published and may be obtained by all SpinRite v6.0 owners at the SpinRite v6.1 Pre-Release page. (SpinRite will shortly be officially updated to v6.1 so this page will be renamed.) The primary new feature, and the reason for this release, was the discovery of memory problems in some systems that were affecting SpinRite's operation. So SpinRite now incorporates a built-in test of the system's memory. For the full story, please see this page in the "Pre-Release Announcements & Feedback" forum.
    /Steve.
  • Be sure to checkout “Tips & Tricks”
    Dear Guest Visitor → Once you register and log-in please checkout the “Tips & Tricks” page for some very handy tips!

    /Steve.
  • BootAble – FreeDOS boot testing freeware

    To obtain direct, low-level access to a system's mass storage drives, SpinRite runs under a GRC-customized version of FreeDOS which has been modified to add compatibility with all file systems. In order to run SpinRite it must first be possible to boot FreeDOS.

    GRC's “BootAble” freeware allows anyone to easily create BIOS-bootable media in order to workout and confirm the details of getting a machine to boot FreeDOS through a BIOS. Once the means of doing that has been determined, the media created by SpinRite can be booted and run in the same way.

    The participants here, who have taken the time to share their knowledge and experience, their successes and some frustrations with booting their computers into FreeDOS, have created a valuable knowledgebase which will benefit everyone who follows.

    You may click on the image to the right to obtain your own copy of BootAble. Then use the knowledge and experience documented here to boot your computer(s) into FreeDOS. And please do not hesitate to ask questions – nowhere else can better answers be found.

    (You may permanently close this reminder with the 'X' in the upper right.)

coffeeprogrammer

Well-known member
Jul 19, 2021
127
12
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
 
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.
 
... 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
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
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