| 1 |
/* |
| 2 |
* Copyright (c) 2010-2014 Richard Braun. |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef _X86_BIOSMEM_H |
| 19 |
#define _X86_BIOSMEM_H |
| 20 |
|
| 21 |
#include <mach/machine/vm_types.h> |
| 22 |
#include <mach/machine/multiboot.h> |
| 23 |
|
| 24 |
/* |
| 25 |
* Address where the address of the Extended BIOS Data Area segment can be |
| 26 |
* found. |
| 27 |
*/ |
| 28 |
#define BIOSMEM_EBDA_PTR 0x40e |
| 29 |
|
| 30 |
/* |
| 31 |
* Significant low memory addresses. |
| 32 |
* |
| 33 |
* The first 64 KiB are reserved for various reasons (e.g. to preserve BIOS |
| 34 |
* data and to work around data corruption on some hardware). |
| 35 |
*/ |
| 36 |
#define BIOSMEM_BASE 0x010000 |
| 37 |
#define BIOSMEM_BASE_END 0x0a0000 |
| 38 |
#define BIOSMEM_EXT_ROM 0x0e0000 |
| 39 |
#define BIOSMEM_ROM 0x0f0000 |
| 40 |
#define BIOSMEM_END 0x100000 |
| 41 |
|
| 42 |
/* |
| 43 |
* Report reserved addresses to the biosmem module. |
| 44 |
* |
| 45 |
* Once all boot data have been registered, the user can set up the |
| 46 |
* early page allocator. |
| 47 |
* |
| 48 |
* If the range is marked temporary, it will be unregistered when |
| 49 |
* biosmem_free_usable() is called, so that pages that used to store |
| 50 |
* these boot data may be released to the VM system. |
| 51 |
*/ |
| 52 |
void biosmem_register_boot_data(phys_addr_t start, phys_addr_t end, |
| 53 |
boolean_t temporary); |
| 54 |
|
| 55 |
/* |
| 56 |
* Initialize the early page allocator. |
| 57 |
* |
| 58 |
* This function uses the memory map provided by the boot loader along |
| 59 |
* with the registered boot data addresses to set up a heap of free pages |
| 60 |
* of physical memory. |
| 61 |
* |
| 62 |
* Note that on Xen, this function registers all the Xen boot information |
| 63 |
* as boot data itself. |
| 64 |
*/ |
| 65 |
#ifdef MACH_HYP |
| 66 |
void biosmem_xen_bootstrap(void); |
| 67 |
#else /* MACH_HYP */ |
| 68 |
void biosmem_bootstrap(const struct multiboot_raw_info *mbi); |
| 69 |
#endif /* MACH_HYP */ |
| 70 |
|
| 71 |
/* |
| 72 |
* Allocate contiguous physical pages during bootstrap. |
| 73 |
* |
| 74 |
* The pages returned are guaranteed to be part of the direct physical |
| 75 |
* mapping when paging is enabled. |
| 76 |
* |
| 77 |
* This function should only be used to allocate initial page table pages. |
| 78 |
* Those pages are later loaded into the VM system (as reserved pages) |
| 79 |
* which means they can be freed like other regular pages. Users should |
| 80 |
* fix up the type of those pages once the VM system is initialized. |
| 81 |
*/ |
| 82 |
unsigned long biosmem_bootalloc(unsigned int nr_pages); |
| 83 |
|
| 84 |
/* |
| 85 |
* Return the limit of physical memory that can be directly mapped. |
| 86 |
*/ |
| 87 |
phys_addr_t biosmem_directmap_end(void); |
| 88 |
|
| 89 |
/* |
| 90 |
* Set up physical memory based on the information obtained during bootstrap |
| 91 |
* and load it in the VM system. |
| 92 |
*/ |
| 93 |
void biosmem_setup(void); |
| 94 |
|
| 95 |
/* |
| 96 |
* Free all usable memory. |
| 97 |
* |
| 98 |
* This function releases all pages that aren't used by boot data and have |
| 99 |
* not already been loaded into the VM system. |
| 100 |
*/ |
| 101 |
void biosmem_free_usable(void); |
| 102 |
|
| 103 |
/* |
| 104 |
* Tell whether this address is marked as available in the biosmem and thus used |
| 105 |
* for usable memory. |
| 106 |
*/ |
| 107 |
boolean_t biosmem_addr_available(phys_addr_t addr); |
| 108 |
|
| 109 |
#endif /* _X86_BIOSMEM_H */ |