Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe205bdd authored by Thomas Meyer's avatar Thomas Meyer Committed by Richard Weinberger
Browse files

um: Print minimum physical memory requirement



Print a more sensible message about the minimum physical memory
requirement.

Signed-off-by: default avatarThomas Meyer <thomas@m3y3r.de>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 33bbc306
Loading
Loading
Loading
Loading
+35 −6
Original line number Original line Diff line number Diff line
@@ -57,22 +57,51 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,


extern int __syscall_stub_start;
extern int __syscall_stub_start;


/**
 * setup_physmem() - Setup physical memory for UML
 * @start:	Start address of the physical kernel memory,
 *		i.e start address of the executable image.
 * @reserve_end:	end address of the physical kernel memory.
 * @len:	Length of total physical memory that should be mapped/made
 *		available, in bytes.
 * @highmem:	Number of highmem bytes that should be mapped/made available.
 *
 * Creates an unlinked temporary file of size (len + highmem) and memory maps
 * it on the last executable image address (uml_reserved).
 *
 * The offset is needed as the length of the total physical memory
 * (len + highmem) includes the size of the memory used be the executable image,
 * but the mapped-to address is the last address of the executable image
 * (uml_reserved == end address of executable image).
 *
 * The memory mapped memory of the temporary file is used as backing memory
 * of all user space processes/kernel tasks.
 */
void __init setup_physmem(unsigned long start, unsigned long reserve_end,
void __init setup_physmem(unsigned long start, unsigned long reserve_end,
			  unsigned long len, unsigned long long highmem)
			  unsigned long len, unsigned long long highmem)
{
{
	unsigned long reserve = reserve_end - start;
	unsigned long reserve = reserve_end - start;
	int pfn = PFN_UP(__pa(reserve_end));
	unsigned long pfn = PFN_UP(__pa(reserve_end));
	int delta = (len - reserve) >> PAGE_SHIFT;
	unsigned long delta = (len - reserve) >> PAGE_SHIFT;
	int err, offset, bootmap_size;
	unsigned long offset, bootmap_size;
	long map_size;
	int err;

	offset = uml_reserved - uml_physmem;
	map_size = len - offset;
	if(map_size <= 0) {
		printf("Too few physical memory! Needed=%d, given=%d\n",
		       offset, len);
		exit(1);
	}


	physmem_fd = create_mem_file(len + highmem);
	physmem_fd = create_mem_file(len + highmem);


	offset = uml_reserved - uml_physmem;
	err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
	err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
			    len - offset, 1, 1, 1);
			    map_size, 1, 1, 1);
	if (err < 0) {
	if (err < 0) {
		printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
		printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
		       "failed - errno = %d\n", len - offset,
		       "failed - errno = %d\n", map_size,
		       (void *) uml_reserved, err);
		       (void *) uml_reserved, err);
		exit(1);
		exit(1);
	}
	}