socsvn commit: r238303 - soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload

syuu at FreeBSD.org syuu at FreeBSD.org
Mon Jun 25 23:05:04 UTC 2012


Author: syuu
Date: Mon Jun 25 23:05:03 2012
New Revision: 238303
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238303

Log:
  remove unnecessary codes, set entry point to 0x0 temporarily

Modified:
  soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload/bhyvebiosload.c

Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload/bhyvebiosload.c
==============================================================================
--- soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload/bhyvebiosload.c	Mon Jun 25 22:39:37 2012	(r238302)
+++ soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload/bhyvebiosload.c	Mon Jun 25 23:05:03 2012	(r238303)
@@ -91,45 +91,9 @@
 static uint64_t lowmem, highmem;
 static struct vmctx *ctx;
 
-static uint64_t gdtbase, cr3, rsp;
-
 static void cb_exit(void *arg, int v);
 
 /*
- * Console i/o callbacks
- */
-
-#if 0
-static void
-cb_putc(void *arg, int ch)
-{
-	char c = ch;
-
-	write(1, &c, 1);
-}
-
-static int
-cb_getc(void *arg)
-{
-	char c;
-
-	if (read(0, &c, 1) == 1)
-		return (c);
-	return (-1);
-}
-
-static int
-cb_poll(void *arg)
-{
-	int n;
-
-	if (ioctl(0, FIONREAD, &n) >= 0)
-		return (n > 0);
-	return (0);
-}
-#endif
-
-/*
  * Host filesystem i/o callbacks
  */
 
@@ -200,16 +164,6 @@
 	return (0);
 }
 
-#if 0
-static int
-cb_isdir(void *arg, void *h)
-{
-	struct cb_file *cf = h;
-
-	return (cf->cf_isdir);
-}
-#endif
-
 static int
 cb_read(void *arg, void *h, void *buf, size_t size, size_t *resid)
 {
@@ -225,78 +179,6 @@
 	return (0);
 }
 
-#if 0
-static int
-cb_readdir(void *arg, void *h, uint32_t *fileno_return, uint8_t *type_return,
-	   size_t *namelen_return, char *name)
-{
-	struct cb_file *cf = h;
-	struct dirent *dp;
-
-	if (!cf->cf_isdir)
-		return (EINVAL);
-
-	dp = readdir(cf->cf_u.dir);
-	if (!dp)
-		return (ENOENT);
-
-	/*
-	 * Note: d_namlen is in the range 0..255 and therefore less
-	 * than PATH_MAX so we don't need to test before copying.
-	 */
-	*fileno_return = dp->d_fileno;
-	*type_return = dp->d_type;
-	*namelen_return = dp->d_namlen;
-	memcpy(name, dp->d_name, dp->d_namlen);
-	name[dp->d_namlen] = 0;
-
-	return (0);
-}
-
-static int
-cb_seek(void *arg, void *h, uint64_t offset, int whence)
-{
-	struct cb_file *cf = h;
-
-	if (cf->cf_isdir)
-		return (EINVAL);
-	if (lseek(cf->cf_u.fd, offset, whence) < 0)
-		return (errno);
-	return (0);
-}
-
-static int
-cb_stat(void *arg, void *h, int *mode, int *uid, int *gid, uint64_t *size)
-{
-	struct cb_file *cf = h;
-
-	*mode = cf->cf_stat.st_mode;
-	*uid = cf->cf_stat.st_uid;
-	*gid = cf->cf_stat.st_gid;
-	*size = cf->cf_stat.st_size;
-	return (0);
-}
-
-/*
- * Disk image i/o callbacks
- */
-
-static int
-cb_diskread(void *arg, int unit, uint64_t from, void *to, size_t size,
-	    size_t *resid)
-{
-	ssize_t n;
-
-	if (unit != 0 || disk_fd == -1)
-		return (EIO);
-	n = pread(disk_fd, to, size, from);
-	if (n < 0)
-		return (errno);
-	*resid = size - n;
-	return (0);
-}
-#endif
-
 /*
  * Guest virtual machine i/o callbacks
  */
@@ -315,135 +197,12 @@
 	return (0);
 }
 
-#if 0
-static int
-cb_copyout(void *arg, uint64_t from, void *to, size_t size)
-{
-
-	from &= 0x7fffffff;
-	if (from > lowmem)
-		return (EFAULT);
-	if (from + size > lowmem)
-		size = lowmem - from;
-
-	memcpy(to, &membase[from], size);
-
-	return (0);
-}
-
-static void
-cb_setreg(void *arg, int r, uint64_t v)
-{
-	int error;
-	enum vm_reg_name vmreg;
-	
-	vmreg = VM_REG_LAST;
-
-	switch (r) {
-	case 4:
-		vmreg = VM_REG_GUEST_RSP;
-		rsp = v;
-		break;
-	default:
-		break;
-	}
-
-	if (vmreg == VM_REG_LAST) {
-		printf("test_setreg(%d): not implemented\n", r);
-		cb_exit(NULL, USERBOOT_EXIT_QUIT);
-	}
-
-	error = vm_set_register(ctx, BSP, vmreg, v);
-	if (error) {
-		perror("vm_set_register");
-		cb_exit(NULL, USERBOOT_EXIT_QUIT);
-	}
-}
-
-static void
-cb_setmsr(void *arg, int r, uint64_t v)
-{
-	int error;
-	enum vm_reg_name vmreg;
-	
-	vmreg = VM_REG_LAST;
-
-	switch (r) {
-	case MSR_EFER:
-		vmreg = VM_REG_GUEST_EFER;
-		break;
-	default:
-		break;
-	}
-
-	if (vmreg == VM_REG_LAST) {
-		printf("test_setmsr(%d): not implemented\n", r);
-		cb_exit(NULL, USERBOOT_EXIT_QUIT);
-	}
-
-	error = vm_set_register(ctx, BSP, vmreg, v);
-	if (error) {
-		perror("vm_set_msr");
-		cb_exit(NULL, USERBOOT_EXIT_QUIT);
-	}
-}
-
-static void
-cb_setcr(void *arg, int r, uint64_t v)
-{
-	int error;
-	enum vm_reg_name vmreg;
-	
-	vmreg = VM_REG_LAST;
-
-	switch (r) {
-	case 0:
-		vmreg = VM_REG_GUEST_CR0;
-		break;
-	case 3:
-		vmreg = VM_REG_GUEST_CR3;
-		cr3 = v;
-		break;
-	case 4:
-		vmreg = VM_REG_GUEST_CR4;
-		break;
-	default:
-		break;
-	}
-
-	if (vmreg == VM_REG_LAST) {
-		printf("test_setcr(%d): not implemented\n", r);
-		cb_exit(NULL, USERBOOT_EXIT_QUIT);
-	}
-
-	error = vm_set_register(ctx, BSP, vmreg, v);
-	if (error) {
-		perror("vm_set_cr");
-		cb_exit(NULL, USERBOOT_EXIT_QUIT);
-	}
-}
-#endif
-
-static void
-cb_setgdt(void *arg, uint64_t base, size_t size)
-{
-	int error;
-
-	error = vm_set_desc(ctx, BSP, VM_REG_GUEST_GDTR, base, size - 1, 0);
-	if (error != 0) {
-		perror("vm_set_desc(gdt)");
-		cb_exit(NULL, USERBOOT_EXIT_QUIT);
-	}
-
-	gdtbase = base;
-}
-
 static void
 cb_exec(void *arg, uint64_t rip)
 {
 	int error;
 
-	error = vm_setup_bios_registers(ctx, BSP, rip, cr3, gdtbase, rsp);
+	error = vm_setup_bios_registers(ctx, BSP);
 	if (error) {
 		perror("vm_setup_freebsd_registers");
 		cb_exit(NULL, USERBOOT_EXIT_QUIT);
@@ -452,19 +211,6 @@
 	cb_exit(NULL, 0);
 }
 
-#if 0
-/*
- * Misc
- */
-
-static void
-cb_delay(void *arg, int usec)
-{
-
-	usleep(usec);
-}
-#endif
-
 static void
 cb_exit(void *arg, int v)
 {
@@ -473,44 +219,6 @@
 	exit(v);
 }
 
-#if 0
-static void
-cb_getmem(void *arg, uint64_t *ret_lowmem, uint64_t *ret_highmem)
-{
-
-	*ret_lowmem = lowmem;
-	*ret_highmem = highmem;
-}
-
-static struct loader_callbacks_v1 cb = {
-	.getc = cb_getc,
-	.putc = cb_putc,
-	.poll = cb_poll,
-
-	.open = cb_open,
-	.close = cb_close,
-	.isdir = cb_isdir,
-	.read = cb_read,
-	.readdir = cb_readdir,
-	.seek = cb_seek,
-	.stat = cb_stat,
-
-	.diskread = cb_diskread,
-
-	.copyin = cb_copyin,
-	.copyout = cb_copyout,
-	.setreg = cb_setreg,
-	.setmsr = cb_setmsr,
-	.setcr = cb_setcr,
-	.setgdt = cb_setgdt,
-	.exec = cb_exec,
-
-	.delay = cb_delay,
-	.exit = cb_exit,
-	.getmem = cb_getmem,
-};
-#endif
-
 static void
 usage(void)
 {
@@ -530,7 +238,6 @@
 	struct cb_file *cf;
 	char *buf;
 	size_t res;
-	uint64_t		gdtr[3];
 
 	progname = argv[0];
 
@@ -616,11 +323,11 @@
 		fprintf(stderr, "cb_read\n");
 		return (1);
 	}
+#if 0
+	cb_copyin(NULL, buf, 0xFFFFFFF0, 3);
+#endif
 	cb_copyin(NULL, buf, 0x0, 3);
 	cb_close(NULL, cf);
-	vm_setup_bios_gdt(gdtr);
-	cb_copyin(NULL, gdtr, 0x5000, sizeof(gdtr));
-	cb_setgdt(NULL, 0x5000, sizeof(gdtr));
-	cb_exec(NULL, 0x0);
+	cb_exec(NULL, 0);
 	return (0);
 }


More information about the svn-soc-all mailing list