When a 32-bit machine can access max. 4 GB of RAM, how it connects to a 150 GB hard drive

I understand that the memory that a 32-bit machine can access is limited to 4 GB. Since there are I / O ports such as PCIe, USB, Serial, Parallel, PS / 2, Audio I / O, CD drive, floppy drive, memory card readers, etc., which also need to be solved, RAM 4 GB is supported by the CPU itself. Everything that I just mentioned, and others also take up a lot of memory.

Now I'm confused about how it can support several GB of hard disk space? How can it access even 1 TB of external storage through these SATA / ATA interfaces. The same thing happens with USB storage devices, such as external USB hard drives, I am surprised that the large storage can be accessed by the CPU with a limit of up to 32 bits. Are there any restrictions on how a large hard drive can be supported by a 32-bit processor?

+4
source share
3 answers

I don’t know where to start :-)

This is a very, very simplified explanation, not entirely true since 286, but can help you understand the basic concepts:

Memory addressing is done via the address bus: the 32-bit address bus can express 2 ^ 32 different addresses. The smallest amount of memory manipulated in one operation is called the size of the "word", which is limited by the width of the data bus.

The maximum amount of address memory is the size of a word times the number of addresses.

In "block IO" operations, the equivalent of the word size is the block size, usually much larger. This is a compromise: larger data can be accessed with the same address length, but to drag a single bit, you need to rewrite the entire block.

The big difference is that the address does not have to be present simultaneously on the "address bus", as in memory: commands (and responses) are transmitted in sequential "packets", for example, on the network. Thus, there is no hardware limitation on the size of the address, although I am sure that the protocol indicates a reasonable upper bound.

As you can see, the address size of the disk is not completely related to the width of the CPU bus and the size of the register.

+4
source

Currently, application developers prefer to deal with 64-bit file pointers. For example, lseek64 for linux or SetFilePointer for Windows - therefore, from the point of view of the file, you can refer to a 2 ^ 64 single file.

But from the hardware level this is more interesting - because each disk is divided (in logical units on clusters, in disk units by sector). Each cluster has many bytes that can be addressed and read by a single request. Operating systems hide these operations from you. But terabytes are much easier to handle from a cluster perspective.

+1
source

A 32-bit processor can process much larger numbers than 32 bits (for example, using the "add with wrap" instructions). The processor can write large address values ​​to the address register of the I / O controller (for example, using several 32-bit instructions for storing data). Due to this indirect addressing, the disk I / O address is independent of the processor bus address.

+1
source

Source: https://habr.com/ru/post/1478962/


All Articles