[Prev][Next][Index][Thread]

repost of compantion patch for the netboot fixes



oh well, it seems that I can't get my patches right.

The patch I sent to the oskit-users list previously missed a few parts.
But then I used the wrong list to send the companion patch to.  Sorry about
that.  And sorry for those who get this patch more than once.  By the way:
which list is the correct one to send public patches to?

Attached is a patch for the oskit (as you need the previous patches it
must be at least partially the 990402 snapshot) that contains the pieces
I forgot in my previous patches.  It needs to be applied with patch -p1.
If you have questions or problems - just ask.

-- 
Klaus Espenlaub                      Email:  espenlaub@informatik.uni-ulm.de
Universitaet Ulm                     Phone:  +49 731 50-24178
Abteilung Rechnerstrukturen          Fax:    +49 731 50-24182
D-89069 Ulm                          Office: Building O27, Room 316
diff -rupN src/oskit-0.97/boot/bsd/main.c oskit-0.97/boot/bsd/main.c
--- src/oskit-0.97/boot/bsd/main.c	Fri Jan  8 07:40:58 1999
+++ oskit-0.97/boot/bsd/main.c	Thu May 20 11:35:01 1999
@@ -235,7 +235,8 @@ int kimg_read(void *handle, oskit_addr_t
 }
 
 static
-int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
@@ -254,7 +255,8 @@ int kimg_read_exec_1(void *handle, oskit
 }
 
 static
-int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
@@ -276,7 +278,8 @@ int kimg_read_exec_2(void *handle, oskit
  * Callback for reading the symbol table.
  */
 static
-int kimg_read_exec_3(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_3(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
diff -rupN src/oskit-0.97/boot/dos/main.c oskit-0.97/boot/dos/main.c
--- src/oskit-0.97/boot/dos/main.c	Fri Oct  2 04:46:16 1998
+++ oskit-0.97/boot/dos/main.c	Thu May 20 11:37:22 1999
@@ -57,7 +57,8 @@ int kimg_read(void *handle, oskit_addr_t
 }
 
 static
-int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
@@ -76,7 +77,8 @@ int kimg_read_exec_1(void *handle, oskit
 }
 
 static
-int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
diff -rupN src/oskit-0.97/boot/linux/misc.c oskit-0.97/boot/linux/misc.c
--- src/oskit-0.97/boot/linux/misc.c	Fri Oct 16 04:16:22 1998
+++ oskit-0.97/boot/linux/misc.c	Thu May 20 11:38:32 1999
@@ -30,6 +30,7 @@
 #include <oskit/debug.h>
 #include <oskit/lmm.h>
 #include <oskit/exec/exec.h>
+#include <oskit/x86/eflags.h>
 #include <oskit/x86/base_vm.h>
 #include <oskit/x86/base_trap.h>
 #include <oskit/x86/pc/base_i16.h>
@@ -297,7 +298,8 @@ int kimg_read(void *handle, oskit_addr_t
 }
 
 static
-int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
@@ -316,7 +318,8 @@ int kimg_read_exec_1(void *handle, oskit
 }
 
 static
-int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
@@ -470,21 +473,69 @@ static void init_boot_info(void)
 		base_real_int(&ts);
 		boot_info->mem_lower = ts.eax & 0xFFFF;
 
-		/* Find the top of extended memory (up to 64MB).  */
+		/* Find the top of extended memory.  */
 		ts.trapno = 0x15;
-		ts.eax = 0x8800;
+		ts.eax = 0xe801;
+		ts.eflags &= ~EFL_CF;
 		base_real_int(&ts);
-		boot_info->mem_upper = ts.eax & 0xFFFF;
+		if (ts.eflags & EFL_CF) {
+			ts.trapno = 0x15;
+			ts.eax = 0x8800;
+			base_real_int(&ts);
+			boot_info->mem_upper = ts.eax & 0xFFFF;
+		} else {
+			ts.eax &= 0xffff;
+			ts.ebx &= 0xffff;
+			boot_info->mem_upper = ts.eax + 64 * ts.ebx;
+		}
 	}
 
-	/* Build the kernel command line.  */
+	/* Build the kernel command line.  Make things understandable for the
+	 * oskit multiboot code.  This means that a kernel name has to be
+	 * added as the first argument, and that all Linux-style kernel
+	 * parameters without arguments (auto, rw, ...) that may come
+	 * before the user specified command line are replaced by something
+	 * that's understandable by a multiboot kernel.  Big hack.  */
 	if (*((unsigned short*)phystokv(0x90020)) == 0xA33F) /* CL_MAGIC */
 	{
-		void *src = (void*)phystokv(0x90000 +
+		char *src = (void*)phystokv(0x90000 +
 			*((unsigned short*)phystokv(0x90022)));
 		void *dest = mustcalloc(2048, 1);
+		char *curr = src;
+		char c;
 		boot_info->cmdline = kvtophys(dest);
-		memcpy(dest, src, 2048);
+		/* We don't have a better choice, really. */
+		strcpy(dest, "kernel ");
+		/* Hacking on... */
+		if ((strlen(curr) >= 4) && ((curr[4] = ' ') || (curr[4] = '\0'))) {
+			c = curr[4];
+			curr[4] = '\0';
+			if (strcmp(curr, "auto") == 0) {
+				strcat(dest, "boottype=");
+				strcat(dest, curr);
+				strcat(dest, " ");
+				curr[4] = c;
+				if (c != 0) curr += 5; else curr += 4;
+			} else {
+				curr[4] = c;
+			}
+		}
+		if ((strlen(curr) >= 2) && ((curr[2] = ' ') || (curr[2] = '\0'))) {
+			c = curr[2];
+			curr[2] = '\0';
+			if ((curr[0] == 'r') && ((curr[1] == 'o') || (curr[1] == 'w'))) {
+				strcat(dest, "rootmnt=");
+				strcat(dest, curr);
+				strcat(dest, " ");
+				curr[2] = c;
+				if (c != 0) curr += 3; else curr += 2;
+			} else {
+				curr[2] = c;
+			}
+		}
+		src[2047 - strlen(dest)] = '\0';
+		/* Hacking off... */
+		strcat(dest, curr);
 		boot_info->flags |= MULTIBOOT_CMDLINE;
 	}
 
@@ -550,10 +601,6 @@ void main(int argc, char **argv)
 	load_kernel();
 	init_boot_info();
 	boot_start(boot_info);
-}
-
-void idt_irq_init()
-{
 }
 
 /* ========================================================================
diff -rupN src/oskit-0.97/boot/multiboot/main.c oskit-0.97/boot/multiboot/main.c
--- src/oskit-0.97/boot/multiboot/main.c	Fri Jan  8 07:49:45 1999
+++ oskit-0.97/boot/multiboot/main.c	Thu May 20 11:39:59 1999
@@ -167,7 +167,8 @@ int kimg_read(void *handle, oskit_addr_t
 }
 
 static
-int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_1(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
@@ -186,7 +187,8 @@ int kimg_read_exec_1(void *handle, oskit
 }
 
 static
-int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_2(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
@@ -208,7 +210,8 @@ int kimg_read_exec_2(void *handle, oskit
  * Callback for reading the symbol table.
  */
 static
-int kimg_read_exec_3(void *handle, oskit_addr_t file_ofs, oskit_size_t file_size,
+int kimg_read_exec_3(void *handle, oskit_addr_t file_ofs,
+		     oskit_size_t file_size, oskit_addr_t load_addr,
 		     oskit_addr_t mem_addr, oskit_size_t mem_size,
 		     exec_sectype_t section_type)
 {
diff -rupN src/oskit-0.97/exec/elf.c oskit-0.97/exec/elf.c
--- src/oskit-0.97/exec/elf.c	Thu Apr  9 00:43:38 1998
+++ oskit-0.97/exec/elf.c	Thu May 20 14:37:11 1999
@@ -95,7 +95,8 @@ int exec_load_elf(exec_read_func_t *read
 			if (ph->p_flags & PF_X) type |= EXEC_SECTYPE_EXECUTE;
 			result = (*read_exec)(handle,
 					      ph->p_offset, ph->p_filesz,
-					      ph->p_vaddr, ph->p_memsz, type);
+					      ph->p_paddr, ph->p_vaddr,
+					      ph->p_memsz, type);
 		}
 	}
 
diff -rupN src/oskit-0.97/exec/x86/aout.c oskit-0.97/exec/x86/aout.c
--- src/oskit-0.97/exec/x86/aout.c	Thu Apr  9 00:43:41 1998
+++ oskit-0.97/exec/x86/aout.c	Thu May 20 11:51:23 1999
@@ -161,7 +161,7 @@ int exec_load_aout(exec_read_func_t *rea
 	if (text_size > 0)
 	{
 		err = (*read_exec)(handle, text_offset, text_size,
-				   text_start, text_size,
+				   text_start, text_start, text_size,
 				   EXEC_SECTYPE_READ |
 				   EXEC_SECTYPE_EXECUTE |
 				   EXEC_SECTYPE_ALLOC |
@@ -177,6 +177,7 @@ int exec_load_aout(exec_read_func_t *rea
 				   text_offset + text_size,
 				   data_size,
 				   text_start + text_size,
+				   text_start + text_size,
 				   data_size + x.a_bss,
 				   EXEC_SECTYPE_READ |
 				   EXEC_SECTYPE_WRITE |
@@ -199,7 +200,7 @@ int exec_load_aout(exec_read_func_t *rea
 		err = (*read_exec)(handle,
 				   text_offset + text_size + data_size,
 				   x.a_syms,
-				   0, 0,
+				   0, 0, 0,
 				   EXEC_SECTYPE_AOUT_SYMTAB);
 		if (err)
 			return err;
@@ -222,7 +223,7 @@ int exec_load_aout(exec_read_func_t *rea
 		err = (*read_exec)(handle,
 				   text_offset + text_size + data_size + x.a_syms,
 				   strtabsize,
-				   0, 0,
+				   0, 0, 0,
 				   EXEC_SECTYPE_AOUT_STRTAB);
 		if (err)
 			return err;
diff -rupN src/oskit-0.97/oskit/exec/exec.h oskit-0.97/oskit/exec/exec.h
--- src/oskit-0.97/oskit/exec/exec.h	Mon Dec  7 08:10:20 1998
+++ oskit-0.97/oskit/exec/exec.h	Thu May 20 11:27:40 1999
@@ -73,7 +73,8 @@ typedef int exec_read_func_t(void *handl
 
 typedef int exec_read_exec_func_t(void *handle,
 				  oskit_addr_t file_ofs, oskit_size_t file_size,
-			          oskit_addr_t mem_addr, oskit_size_t mem_size,
+				  oskit_addr_t pmem_addr,
+			          oskit_addr_t vmem_addr, oskit_size_t mem_size,
 				  exec_sectype_t section_type);
 
 /*
diff -rupN src/oskit-0.97/oskit/x86/multiboot.h oskit-0.97/oskit/x86/multiboot.h
--- src/oskit-0.97/oskit/x86/multiboot.h	Thu Apr  9 00:47:36 1998
+++ oskit-0.97/oskit/x86/multiboot.h	Fri May 28 16:45:45 1999
@@ -17,6 +17,8 @@
 #ifndef _OSKIT_X86_MULTIBOOT_H_
 #define _OSKIT_X86_MULTIBOOT_H_
 
+#ifndef ASSEMBLER
+
 #include <oskit/x86/types.h>
 
 /* For a.out kernel boot images, the following header must appear
@@ -40,6 +42,8 @@ struct multiboot_header
 	oskit_addr_t		entry;
 };
 
+#endif /* !ASSEMBLER */
+
 /* The entire multiboot_header must be contained
    within the first MULTIBOOT_SEARCH bytes of the kernel image.  */
 #define MULTIBOOT_SEARCH	8192
@@ -68,6 +72,8 @@ struct multiboot_header
    that the multiboot method is being used */
 #define MULTIBOOT_VALID         0x2badb002
 
+#ifndef ASSEMBLER
+
 /* The boot loader passes this data structure to the kernel in
    register EBX on entry.  */
 struct multiboot_info
@@ -167,6 +173,8 @@ struct AddrRangeDesc
 
   /* unspecified optional padding... */
 };
+
+#endif /* !ASSEMBLER */
 
 /* usable memory "Type", all others are reserved.  */
 #define MB_ARD_MEMORY       1

References: