summaryrefslogtreecommitdiff
path: root/src/pmm.c
Commit message (Collapse)AuthorAgeFilesLines
* pmm: use tmp zone on oomGerd Hoffmann2018-06-221-0/+13
| | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* malloc: Don't mix virtual and physical addressesKevin O'Connor2015-10-151-8/+8
| | | | | | | | | Consistently use 'u32' for physical addresses and pointers for virtual addresses in the malloc code. Introduce and use memremap() where a physical address needs to be converted to a virtual address. Use virt_to_phys() for the inverse. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Remove the pmm handle argument from _malloc().Kevin O'Connor2013-12-271-7/+12
| | | | | | | | | The PMM handle argument will almost always be 0xffffffff. Use separate code for the few rare cases where it may not be the default value. Gcc produces better code if _malloc() only requires three parameters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move pmm definitions to new file std/pmm.h.Kevin O'Connor2013-09-181-13/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move definition of struct segoff_s from farptr.h to types.h.Kevin O'Connor2013-09-181-1/+0
| | | | | | | The segoff_s definition is used by a number of header files that would not otherwise need farptr.h, so move it to a more central location. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move function definitions for output.c from util.h to new file output.h.Kevin O'Connor2013-09-181-1/+2
| | | | | | Also, sort the order of include files in the c files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move malloc code from pmm.c to new files malloc.c and malloc.h.Kevin O'Connor2013-09-181-541/+17
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move stacks.c definitions from util.h to new file stacks.h.Kevin O'Connor2013-09-181-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Rename util.c to string.c and introduce string.h.Kevin O'Connor2013-09-181-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Split x86 specific functions out of util.c/h to new files x86.c/h.Kevin O'Connor2013-09-181-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Minor - simplify rom_reserve().Kevin O'Connor2013-08-141-10/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Add config option to support memory allocations in 9-segment.Kevin O'Connor2013-08-101-9/+104
| | | | | | | | | | | Internal "low memory" allocations are currently placed in the UMB region (0xc0000-0xf0000). However, there have been reports of some real machines that do not support DMA to this area of memory. So, add a compile time config option (off by default) to support placing all internal low-memory allocations at the end of the 640K real-memory area (0x90000-0xa0000). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Another fix for hlist_for_each_entry_safe.Kevin O'Connor2013-06-131-1/+1
| | | | | | | | | | | Although the previous patch does fix hlist_for_each_entry_safe for the common case, it doesn't work correctly when deleting the current node. To fix this, introduce two macros - hlist_for_each_entry_safe for iterating through a list that can be modified, and hlist_for_each_entry_pprev for those users that only need access to the "pprev" pointer. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Introduce and convert pmm code to use standard list helpers.Kevin O'Connor2013-06-081-48/+29
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Minor - move "tracked memory alloc" code in pmm.c.Kevin O'Connor2013-06-081-98/+98
| | | | | | | Move the "pmm_malloc" code closer to the low level alloc functions it calls. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Use VARVERIFY32INIT on global variables that point to "tmp" memory.Kevin O'Connor2013-03-081-2/+4
| | | | | | | | Enable the recently added build check on global variables that are (or contain) pointers to memory allocated by malloc_tmp(). This helps detect cases where temporary memory is accessed after POST. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Use CONFIG_ prefix for Kconfig variables; use BUILD_ for others.Kevin O'Connor2013-02-201-6/+6
| | | | | | | Rename remaining "build" settings in config.h that used the CONFIG_ prefix to use a BUILD_ prefix. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Eliminate separate BiosTableSpace[] space for f-segment allocations.Kevin O'Connor2013-02-191-9/+3
| | | | | | | | | | | | | | The BiosTableSpace variable was used to ensure there was sufficient space in the f-segment for malloc_fseg() calls. However, it added 2K to the final image size to reserve that space. Update the build to determine where to put the f-segment allocations. In most cases (when code relocation is enabled) allocations can be done in the space free'd from the "init" sections and no additional space needs to be reserved in the final image. This also has the benefit of not fragmenting the f-segment allocation space. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Calculate "RamSize" needed by 16bit interface dynamically.Kevin O'Connor2013-02-191-2/+24
| | | | | | | | | | Calculate a LegacyRamSize directly from the e820 map for use by handle_1588() and handle_15e801() (the only two external interfaces that require "RamSize"). All other users of the existing RamSize (and RamSizeOver4G) variables are specific to QEMU, so move the declarations to paravirt.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Move malloc's ZoneFSeg and ZoneLow setup to malloc_init.Kevin O'Connor2013-02-191-10/+5
| | | | | | | This reduces some duplicate code between malloc_preinit() and csm_malloc_preinit(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Don't relocate "varlow" variable references at runtime.Kevin O'Connor2013-02-191-12/+13
| | | | | | | | | Since the final location of the "varlow" variables are known at build time, link the final locations into the binary during the build. The 16bit code was already done at link time - update the build so the 32bit code is also done at link time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Convert VAR16VISIBLE, VAR16EXPORT, and VAR32VISIBLE to VARFSEG.Kevin O'Connor2013-02-181-1/+4
| | | | | | | | | | | Convert all users of the alternative variable exports to VARFSEG. There isn't a significant distinction between the existing types of exports, so it's simpler to just use one type going forward. The new VARFSEG declaration is only emitting when in 32bit mode, so update and move some variables as needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Clarify build generated "zone low" values.Kevin O'Connor2013-02-171-8/+8
| | | | | | | | | Rename datalow_base (and similar) to zonelow_base, and datalow_start (and similar) to varlow_start. This helps distinguish between the bounds for the runtime dynamic memory pool and the compile time global variables. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Report on f-segment UMB ram also.Kevin O'Connor2013-02-171-1/+2
| | | | | | | | Some old DOS programs can also use f-segment space as Upper Memory Blocks (UMB), so also report on what space is available in debug messages. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Rename rom_get_top() to rom_get_max().Kevin O'Connor2013-02-171-4/+4
| | | | | | | Rename rom_get_top and try to make the difference between it and rom_get_last more clear. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* POST: Reorganize post entry and "preinit" functions.Kevin O'Connor2013-02-071-0/+8
| | | | | | | | | | | | Unlocking ram in handle_post() is tricky and only needed under qemu. Separate out that logic from the coreboot/xen paths by invoking handle_elf_post separately. This simplifies both the qemu and non-qemu code paths. Also, organize all the "pre-init" functions into one section of the file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Add CSM supportDavid Woodhouse2013-02-071-0/+19
| | | | | Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Fix rebase error in commit 8a0a972f that broke LOWMEM variables.Kevin O'Connor2013-02-071-0/+4
| | | | | | | Due to a rebase error, commit 8a0a972f caused LOWMEM variables to not be initialized correctly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Normalize POST initialization function name suffixes.Kevin O'Connor2013-02-051-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The POST phase has to invoke many initialization functions, and these functions can have complex inter-dependencies. Try to categorize the functions into 4 classes: preinit - functions called very early in POST where function ordering is very important and the code has limited access to other interfaces. init - functions that initialize internal interfaces and standard external interfaces. This code is generally not dependent on particular hardware and typically does not communicate directly with any hardware devices. setup - functions which access hardware or are dependent on particular hardware or platform devices. prepboot - functions that finalize internal interfaces and that prepare for the boot phase. This patch attempts to normalize the suffixes - functions that used _init(), _setup(), _finalize(), or similar that did not follow the above pattern were renamed. Other than function name changes, there should be no code impact to this patch. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pmm: Use 'struct segoff_s' in pmm header.Kevin O'Connor2013-01-201-9/+4
| | | | | | | | | | | Minor cleanup - use 'struct segoff_s' instead of a manual segment/offset pair. Also, while at it, define the header signature at compile time instead of at run-time. (Defining at run-time is a hold over from when variable changes were persistent across soft-reboots.) Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Minor - clear unused f-segment data at start of f-segment.Kevin O'Connor2012-07-211-1/+4
| | | | | | | Zero the space - some old applications can use the space for UMB if it is zeroed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Avoid runtime relocation of 16bit "low" mem - calculate at build instead.Kevin O'Connor2012-06-081-10/+4
| | | | | | | | | | | | | Some 16bit accesses to "low" mem variables use 16bit relocations instead of the normal 32bit relocations. This causes build problems if the "low" mem sections move more than 64K during relocation. The final location of the "low" memory can be determined during the build, so link the 16bit code with the final post-reloc location of the "low" mem variables instead. This eliminates the need to do these runtime relocations on the 16bit code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Remove CanPreempt check from pmm code.Kevin O'Connor2012-05-301-10/+0
| | | | | | | The CanPreempt check in pmm is a leftover from when memory could be allocated from the 9-segment. It is no longer needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Minor - verify UMB dummy optionrom header size doesn't overflow.Kevin O'Connor2012-05-231-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Allow optionroms and "low mem" to share space.Kevin O'Connor2012-05-211-14/+58
| | | | | | | | | | Allow both optionroms and "low mem" allocations to use the e-segment. (Space is allocated on a "first come, first serve" basis). This allows more flexibility in resource assignment. Also, allow the "low mem" area to use a full 64K. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Use the e-segment instead of the 9-segment for bios "low mem".Kevin O'Connor2012-05-131-89/+27
| | | | | | | | | Use the e-segment for ZoneLow allocations. There is plenty of e-segment space (there has been since SeaBIOS supported code relocation), while using the 9-segment space can impact old real-mode applications. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Fix missing NULL pointer checks causing boot failure on 1meg machines.Kevin O'Connor2012-02-151-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Allow free space in f-segment to be used by malloc_fseg().Kevin O'Connor2011-08-031-0/+7
|
* Remove 16bit wrappers from PMM code.Kevin O'Connor2011-07-161-76/+55
| | | | | | | Now that the PMM code is only run in 32bit mode, remove the GET/SET_PMMVAR macros and other 16bit wrappers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Run option rom visible PMM code in 32bit mode instead of 16bit mode.Kevin O'Connor2011-07-161-11/+40
| | | | | | | Use call32() to jump into handle_pmm(). This reduces the amount of 16bit code needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Cleanup - it's no longer necessary to manually reset global variables.Kevin O'Connor2010-09-251-6/+0
| | | | | Now that a soft-reboot forces a hard-reboot, it is no longer necessary to manually reset global variables.
* Enable optionroms to use freed space due to CONFIG_RELOCATE_INIT.Kevin O'Connor2010-09-251-5/+0
| | | | | | | The space in the e-segment is available for option roms after relocating the init code. Also, zero all of the option rom space when !CONFIG_OPTIONROMS_DEPLOYED.
* Move init code from _start() to post().Kevin O'Connor2010-09-151-3/+0
| | | | | | | | | | Move the shadow calls from _start() to post() - this ensures all the one time init code is in post(). Also, reorg post so that malloc setup is done before ivt/bda/ebda setup. This is in preparation for relocating the 32bit flat init code.
* Introduce memcpy_fl - a memcpy on "flat" pointers.Kevin O'Connor2010-06-061-15/+5
|
* Rework malloc to use a "first fit" algorithm.Kevin O'Connor2010-06-061-217/+313
| | | | | | | | | | | | | | | | | The existing malloc implementation effectively uses a stack - all new allocations come from the top of the stack. When allocating memory with a large alignment, the pad used to align the new memory is unavailable to other users. Also, memory released by calling free() is only available to other users when all memory allocated after it is also freed. This new malloc scheme uses a first fit approach to finding available memory. It makes it possible to use alignment padding and freed space for new allocations. This helps reduce the required memory in the permanent memory zones (ZoneHigh and ZoneLow) where users have the need to allocate structures with high alignment (eg, virtio and usb).
* Add __attribute__((__malloc__)) declaration to internal malloc funcs.Kevin O'Connor2010-04-171-2/+2
|
* Don't move EBDA while an optionrom is running (CONFIG_THREAD_OPTIONROMS).Kevin O'Connor2010-03-201-6/+12
| | | | | Moving the ebda while an optionrom is running could confuse it. So, avoid doing that.
* Be sure to add "void" to all function prototypes that take no args.Kevin O'Connor2010-01-031-6/+6
| | | | Omitting "void" leads to a K&R style declaration which was not intended.
* Add support for 32bit PCI BIOS entry.Kevin O'Connor2009-12-301-3/+4
| | | | | | | | | Create a new code blob (code32seg) with support for 32bit functions that need to utilize explicit segment accesses. This code blob uses global variables relative to %gs and with a dynamic code offset (determined by get_global_offset()). Add BIOS32 structure and code. Add code for 32bit PCI BIOS code.
* Only add "addr32" to memory accesses that require them.Kevin O'Connor2009-12-271-2/+7
| | | | Extract out addr32 to a parameter to the READx/WRITEx_SEG macros.