uefi: Share the code which extracts the UEFI memory map.

This makes it easier to plumb the map key from the GetMemoryMap function
through to the ExitBootServices function without just manually rereading the
key again. Not only is this less redundant, it also lets that value perform
its intended function, detecting whether we're using a stale memory map.

Since the memory map may have never been read at all, we detect whether that
happened and read the map again, throwing away the map data. It's fine to
reread the map key in this case since nobody has a copy of it to be stale in
the first place.

Change-Id: Ifbeb543d1d9abbed5764878bcf74627f806035b0
3 files changed