The OS cannot detect memory on its own. It typically must utilize BIOS functions. The reason for this is that the only way to reliably detect the amount of memory (in a PC) is to actually program the memory controller to query the RAM chips. Since main memory cannot be used during this process, the BIOS, which lives in ROM, is the only software capable of doing this (again, we're talking PCs).
Thus, an OS will call into the BIOS (INT 0x15 E820), to get a map of memory that is free/reserved. The way this map looks depends on the chipset and the devices in the system. It is the BIOS's job to setup this memory map an program the chipset to direct physical address references on the FSB to the correct devices.
There are several well-known address locations for devices, e.g. text-mode video memory. These are mostly historical and many live in the classic hole between 640K and 1MB. This is because, originally, there was no protected mode, and the BIOS (and OS) was limited to 1MB of addressable memory, so device memory would be mapped up in the high area. As more devices got added, and the BIOSes got bigger and bigger for functionality, this hole became bigger.