Skip to contentSkip to conversation

various eli patches

PATCH Andreas Schwab 1 participant 1 message Sep 5, 2000

lore
Share & tools
lore
#0 lore raw

Bill Nottingham <[email protected]> writes:

|> These are against CVS of a couple of weeks ago.
|> 
|> - eli-initrd-fix.patch:  fixes initrd support, and a couple of compilation
|>   tweaks. virt_to_phys() on an already physical address doesn't yeild a
|>   working initrd location.

IMHO it is better to change read_file to expect a physical address for the buffer, since this is all it uses anyway. That way there is no need to convert from physical address to virtual address and back again.

Here is the patch to implement this:

eli.c renamed from eli.c~ +7 -6
@@ -370,7 +370,7 @@
 }
 
 static EFI_STATUS read_file(EFI_FILE_HANDLE fs, EFI_FILE_HANDLE file,
-		UINT64 vbuffer, UINT64 total_size)
+		EFI_PHYSICAL_ADDRESS buffer, UINT64 total_size)
 {
 	EFI_STATUS status;
 
@@ -383,10 +383,8 @@
 	 * needed.
 	 */
 	{
-		EFI_PHYSICAL_ADDRESS buffer;
 		UINTN j = 0;
 
-		buffer = virt_to_phys(vbuffer);
 		while (total_size > 0) {
 			CHAR8 helicopter[4] = { '|' , '/' , '-' , '\\' };
 			UINT64 size;
@@ -411,7 +409,7 @@
 	}
 #else	
 	size = total_size;
-	status = fs->Read(file, &size, (VOID *) virt_to_phys(start_addr));
+	status = fs->Read(file, &size, (VOID *) buffer);
 	if (EFI_ERROR(status))
 		return EFI_LOAD_ERROR;
 
@@ -422,7 +420,7 @@
 }
 
 static INTN load_ramdisk(EFI_FILE_HANDLE fs, CHAR16 *filename,
-		UINT64 start_addr, struct allocated_memory *memory)
+		EFI_PHYSICAL_ADDRESS start_addr, struct allocated_memory *memory)
 {
 	EFI_FILE_HANDLE file;
 	EFI_STATUS status;
@@ -613,7 +611,7 @@
 	    		return EFI_LOAD_ERROR;
 		}
 
-		status = read_file(fs, file, phdr.p_vaddr, phdr.p_filesz);
+		status = read_file(fs, file, virt_to_phys(phdr.p_vaddr), phdr.p_filesz);
 		if (EFI_ERROR(status)) {
 			Print(W2U(L"%s: read failed: %r\n"), filename, status);
 			BS->FreePages(min_addr, pages);
@@ -1263,6 +1261,9 @@
 		case EFI_LOAD_ERROR:
 			goto free_kernel_image;
 		}
+	} else {
+		initrd.start_addr = 0;
+		initrd.pages = 0;
 	}
 
 	/* Must free the ACPI before creating the boot params so the */

Andreas.

Signature · 4 lines
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
[email protected]
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg