Design engineers know where memory and peripherals live in the address space of processors. So this is what is known because these addresses were chosen by someone and documented so that others could write drivers.
The processor does not know peripheral devices from RAM. The instructions simply use addresses that are ultimately determined by the programmers who wrote the software on which the processor runs. Thus, it is correct that peripherals and ram (and rom) are just addresses. If you were writing a video driver and changing the screen resolution, there would be several addresses that you would need to write. At some point, there will be hardware between the processor core and the peripheral device (video card) that checks the address and basically directs it to the right place. This is how the hardware was designed, it analyzes the addresses, some ranges of addresses are marked and sent to the memory that needs to be processed, and some peripheral devices are sent there for processing. Sometimes memory ranges are programmed on their own, so you can organize your memory space for any reason. Just as you move from the place where you live now, somewhere else, you are still in your house, but it has a different address, and the postal people who deliver the mail know how to find your new address. And then there are MMUs that add a layer of protection and other features. MMU (memory management unit) can also virtualize the address, so the processor can be programmed to write to the address 0x100000, but mmu transfers it to 0x2300000 before it goes off on a regular bus, which will be sorted as a memory or peripheral device, Why do you need to do this , and even two main reasons. One of them is that, for example, when you compile an application to work on your operating system, all programs for this OS can be compiled to work at the same address, for example, address 0x8000. But there is only one physical address 0x8000 (suggesting) what happens when the operating system configured mmu for your program, so that your program things work at that address, also the operating system can, if it chooses, and mmu has this function to add protection, so if your program tries to access something outside the allocated memory space, then an error occurs and your program fails to do this. Prevention of hacking or memory failure of other programs. Similarly, if the operating system supports this, it can also use this error to swap some data from ram to disk, and then provide you with more virtual memory, allowing programs to think that they have more memory than they actually are. MMM is not the only way to do all this, but it is a popular way. Therefore, when you have a pointer to C ++ running on some operating system, most likely it is a virtual address, not a physical address, mmu converts this address that was transferred to your program into a real memory address. When os decides to disable your program for another, it is relatively easy to tell mmu so that the other task thinks this is a small numbered address space of 0x8000, for example, now belongs to another program. And your program falls asleep (not executed) for a while.
old_timer
source share