199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 2004, 2006 Marcel Moolenaar
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome {0xc41b6531,0x97b9,0x11d3,{0x9a,0x29,0x00,0x90,0x27,0x3f,0xc1,0x4d}}
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* DIG64 Headless Console & Debug Port Table. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome {0xf951938d,0x620b,0x42ef,{0x82,0x79,0xa8,0x4b,0x79,0x61,0x78,0x98}}
199767f8919635c4928607450d9e0abb932109ceToomas Soomeldr_bootinfo(struct bootinfo *bi, uint64_t *bi_addr)
199767f8919635c4928607450d9e0abb932109ceToomas Soome bi->bi_hcdp = (uint64_t)efi_get_table(&hcdp_guid);
199767f8919635c4928607450d9e0abb932109ceToomas Soome status = BS->LocateHandle(ByProtocol, &fpswa_guid, 0, &sz, &handle);
199767f8919635c4928607450d9e0abb932109ceToomas Soome status = BS->HandleProtocol(handle, &fpswa_guid, &fpswa);
199767f8919635c4928607450d9e0abb932109ceToomas Soome bi->bi_fpswa = (status == 0) ? (uint64_t)fpswa : 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome bisz = (sizeof(struct bootinfo) + 0x0f) & ~0x0f;
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Allocate enough pages to hold the bootinfo block and the memory
199767f8919635c4928607450d9e0abb932109ceToomas Soome * map EFI will return to us. The memory map has an unknown size,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * so we have to determine that first. Note that the AllocatePages
199767f8919635c4928607450d9e0abb932109ceToomas Soome * call can itself modify the memory map, so we have to take that
199767f8919635c4928607450d9e0abb932109ceToomas Soome * into account as well. The changes to the memory map are caused
199767f8919635c4928607450d9e0abb932109ceToomas Soome * by splitting a range of free memory into two (AFAICT), so that
199767f8919635c4928607450d9e0abb932109ceToomas Soome * one is marked as being loader data.
199767f8919635c4928607450d9e0abb932109ceToomas Soome BS->GetMemoryMap(&sz, NULL, &mapkey, &mmsz, &mmver);
199767f8919635c4928607450d9e0abb932109ceToomas Soome status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, pages,
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf("%s: AllocatePages() returned 0x%lx\n", __func__,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read the memory map and stash it after bootinfo. Align the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * memory map on a 16-byte boundary (the bootinfo block is page
199767f8919635c4928607450d9e0abb932109ceToomas Soome status = BS->GetMemoryMap(&sz, mm, &mapkey, &mmsz, &mmver);
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf("%s: GetMemoryMap() returned 0x%lx\n", __func__,
199767f8919635c4928607450d9e0abb932109ceToomas Soome printf("%s: ExitBootServices() returned 0x%lx\n", __func__,