Home |
RTTarget-32 Programming Manual Function RTExtendHeap Function RTReserveVirtualAddress Function RTReleaseVirtualAddress Function RTAllocPhysPageAligned Function RTGetProcessPhysMemHeap System Management BIOS (SMBIOS) Advanced Programmable Interrupt Controller (APIC) |
Function RTExtendHeapFunction RTExtendHeap can add memory to the heap at run-time. RTExtendHeap allows a program built with the same hardware configuration to use more heap memory if it finds more installed: int RTExtendHeap(const void * Physical, unsigned Bytes); ParametersPhysicalSpecifies the address of the physical memory to be added to the heap. BytesSpecifies the size of the physical memory to be added to the heap. return valueIf the function succeeds, the number of pages (not bytes) added to the heap is returned. For error return codes, see the RT_MAP... function codes given for function RTReserveVirtualAddress. In addition, the following return codes are possible:
If paging is not enabled, parameter Physical must match the end of the heap section. In this case, the heap is simply extended by Bytes bytes. If paging is used, the given physical memory is mapped to the virtual address immediately following the heap. The function checks that no memory after the current heap is overlapped. Thus, less memory than requested could be appended (possibly zero if some other section is right after the heap). If the program uses the virtual memory manager, RTExtendHeap will not add pages above address 2G, unless RTTarget-32 flag RT_EXTEND_All_RAM has been set. This prevents the virtual address space from being used up by many physical pages. Note that this function cannot perform any checks on the passed parameters. If the specified memory does not exist or it has already been used by RTLoc, memory will be corrupted. In general, RTExtendHeap can only be called within an Init function before any heap allocation functions have been called to avoid problem RT_MAP_HEAP_TOP_USED. RTTarget-32 will never set up virtual memory at addresses which have physical memory. Thus, if you intend to use RTExtendHeap or RTCMOSExtendHeap, the address range to add to the heap should not be used by RTLoc. For example, if your configuration file specifies extended memory to end at 2M, and you want to add additional extended memory to the heap at run time, no program entities should be mapped in the address range 2M - 64M through virtual regions. For systems equipped with a BIOS and CMOS RAM, function RTCMOSExtendHeap is recommended instead.
|