The
boot(8) program gets a memory map from the BIOS, the BIOS is both mapped into address space and copied to RAM, and the BIOS itself reserves memory for structures that get used by the OS, for ACPI/SMBIOS and various other things.
So, "real mem" is what is calculated from all the free ranges passed to the kernel in the memory map.. on 32-bit systems and 64-bit with buggy chipsets, RAM that can't be mapped into 4G of address space is simply unconnected or lost. There is more than just RAM in physical address space such as memory mapped devices, ROM, and special reverse areas for legacy reasons.
The kernel allocates memory for the size of the kernel image along with various structures, buffers/caches, stack space... some is dynamically allocated, and some is static.
It's really not as simple as "used" or "free" on paged virtual memory systems, there are several different "pools".