http://lxr.linux.no/source/init/do_mounts.c#L270
This is the function which does it, do_mount_root()
It is called by mount_block_root() or mount_nfs_root() depending on where the root filesystem is located.
These functions are called by mount_root() which should be called from the initrd functions.
.... mount_root() -> mount_block_root() -> do_mount_root()
Depending on what you're interested in finding out, those should be the functions you look at.