src/kernel/mm/vmm.c
/**
 * Allocate a virtual page and sets it to zero.
 * 
 * @see vMapPage()
 * @see vAllocPages()
 * 
 * @param virt Address to map
 * @param man If that address is mandatory or could be anyone else
 * 
 * @return returns the virtual mapped address
 */
Allocate a virtual page and sets it to zero.



@param virt Address to map
@param man If that address is mandatory or could be anyone else

@return returns the virtual mapped address
Allocate a virtual page and sets it to zero . @param virt Address to map @param man If that address is mandatory or could be anyone else @return returns the virtual mapped address
void *vAllocPage(void *virt, uint32_t flags, bool man) {
	uint32_t paddr = pAllocPage();
	if (vMapPage(paddr, virt, flags))
		return virt;
	else if (man) {
		pFreePage(paddr);
		return (void *)0;
	} else {
		uint32_t vaddr;
		for (vaddr = 0x100000; vaddr < (_RAMSize * 1024); vaddr += PAGE_SIZE) {
			if (vMapPage(paddr, vaddr, flags))
				return vaddr;
		}
	}
	pFreePage(paddr);
	return (void *)0;
}
void * vAllocPage ( void * virt , uint32_t flags , bool man ) { uint32_t paddr = pAllocPage ( ) ; if ( vMapPage ( paddr , virt , flags ) ) return virt ; else if ( man ) { pFreePage ( paddr ) ; return ( void * ) 0 ; } else { uint32_t vaddr ; for ( vaddr = 0x100000 ; vaddr < ( _RAMSize * 1024 ) ; vaddr += PAGE_SIZE ) { if ( vMapPage ( paddr , vaddr , flags ) ) return vaddr ; } } pFreePage ( paddr ) ; return ( void * ) 0 ; }
Allocate a virtual page and sets it to zero.
Allocate a virtual page and sets it to zero .
// If that address was needed, unmap the physical address and return a null pointer // Try to map from 1MB to the end of the memory