Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Apr 2003 03:09:08 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 28311 for review
Message-ID:  <200304061009.h36A980O005682@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28311

Change 28311 by peter@peter_overcee on 2003/04/06 03:08:19

	Quick and dirty hack working towards starting the kernel with
	long mode enabled and running at the virtual address.  Not
	quite finished yet - the trampoline isn't quite connected yet.

Affected files ...

.. //depot/projects/hammer/sys/boot/i386/libi386/Makefile#4 edit
.. //depot/projects/hammer/sys/boot/i386/libi386/elf64_freebsd.c#3 edit
.. //depot/projects/hammer/sys/boot/i386/libi386/x86_64_tramp.S#1 add

Differences ...

==== //depot/projects/hammer/sys/boot/i386/libi386/Makefile#4 (text+ko) ====

@@ -7,7 +7,7 @@
 	biospci.c bootinfo.c comconsole.c devicename.c elf32_freebsd.c \
 	elf64_freebsd.c gatea20.c \
 	i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \
-	time.c vidconsole.c
+	time.c vidconsole.c x86_64_tramp.S
 
 CFLAGS+=	-ffreestanding
 BOOT_COMCONSOLE_PORT?= 0x3f8

==== //depot/projects/hammer/sys/boot/i386/libi386/elf64_freebsd.c#3 (text+ko) ====

@@ -43,6 +43,16 @@
 
 struct file_format x86_64_elf = { elf64_loadfile, elf64_exec };
 
+typedef u_int64_t p4_entry_t;
+typedef u_int64_t p3_entry_t;
+typedef u_int64_t p2_entry_t;
+extern p4_entry_t PT4[];
+extern p3_entry_t PT3[];
+extern p2_entry_t PT2[];
+
+u_int32_t entry_hi;
+u_int32_t entry_lo;
+
 /*
  * There is an a.out kernel and one or more a.out modules loaded.  
  * We wish to start executing the kernel image, so make such 
@@ -57,6 +67,7 @@
     int				boothowto, err, bootdev;
     struct bootinfo		*bi;
     vm_offset_t			ssym, esym;
+    int				i;
 
     if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
 	return(EFTYPE);			/* XXX actually EFUCKUP */
@@ -77,10 +88,32 @@
     bi->bi_symtab = ssym;	/* XXX this is only the primary kernel symtab */
     bi->bi_esymtab = esym;
 
+printf("initializing trampoline, __base=%#x\n", __base);
+#define PG_V	0x001
+#define PG_RW	0x002
+#define PG_U	0x004
+#define PG_PS	0x080
+	bzero(PT4, PAGE_SIZE);
+	bzero(PT3, PAGE_SIZE);
+	bzero(PT2, PAGE_SIZE);
 
-#ifdef DEBUG
+	/* single PML4 entry */
+	PT4[0] = (p4_entry_t)&PT3[0];
+	PT4[0] |= PG_V | PG_RW | PG_U;
+
+	/* four PDP entries, 1G each */
+	for (i = 0; i < 4; i++) {
+		PT3[i] = (p3_entry_t)&PT2[i * 512];
+		PT3[i] |= PG_V | PG_RW | PG_U;
+	}
+
+	/* 2048 PG_PS (2MB) page mappings */
+	for (i = 0; i < 2048; i++) {
+		PT2[i] = i * (2 * 1024 * 1024);
+		PT2[i] |= PG_V | PG_RW | PG_PS | PG_U;
+	}
+
     printf("Start @ 0x%lx ...\n", entry);
-#endif
 
     dev_cleanup();
     __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop, modulep, bi->bi_kernend);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304061009.h36A980O005682>