![]() Главная страница Случайная страница КАТЕГОРИИ: АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника |
How to allocate memory
The ACPI specification describes system memory-map-reporting interfaces that boot firmware must implement in order to describe the physical address map to an operating system. ACPI specifies that an older BIOS implement the int 15h, E820h interface to report the physical address map to an operating system. And ACPI specifies that UEFI firmware implements the UEFI GetMemoryMap() boot service to report the physical address map to an operating system. Both interfaces are used by the Windows boot loader to obtain an accurate description of physical memory prior to initializing the operating system. They each describe the physical address map as a series of memory ranges, each with a memory type indicating the usage of the memory. Some of the examples of memory type include operating system available memory, unusable memory, and platform reserved memory. Windows uses the description to determine the ranges of physical memory that are available to the operating system and the ranges of physical memory that are in use by the firmware. Allocations for the RSDT/XSDT, the WPBT, and the WPBT’s handoff memory buffer must be described in the respective BIOS or UEFI physical address maps. Each allocation must be described as memory that can be reclaimed by the operating system after its contents are read. The process for allocating memory differs on UEFI platforms and older BIOS platforms. The next two subsections outline the process in further detail. UEFI The core UEFI boot firmware provides memory allocation services to firmware components. A firmware component allocating memory for the WPBT or the binary handoff memory buffer must use the firmware service, AllocatePages() with the allocation type AllocateAnyPages. For all three allocations — the RSDT/XSDT, the WPBT, and the handoff memory buffer allocation — the firmware must use the EfiACPIReclaimMemory memory type. Windows may reclaim the physical memory for these allocations after copying the contents into operating system memory. BIOS Unlike UEFI, BIOS does not provide a service for memory allocations. Allocations made by a firmware component require the firmware to hook int 15h, E820h to ensure the memory map returned to the operating system describes all platform allocations made by the firmware. The hooking process is not described in detail in this paper. It is assumed that a firmware developer writing this code is familiar with the process of hooking a BIOS interrupt service. The process for hooking the BIOS service is not trivial and should be taken into consideration when designing a BIOS solution that publishes a WPBT. In general, it is advantageous to minimize allocations made by the publishing component. If possible, it is better to pre-reserve additional memory for the RSDT/XSDT, WPBT, and handoff memory buffer. For the RSDT/XSDT, WPBT, and handoff memory buffer allocations, the firmware must use the AddressRangeACPI memory type. Windows may reclaim the physical memory for these allocations after copying the contents into operating system memory.
|