From owner-svn-soc-all@FreeBSD.ORG Mon Jul 2 21:29:21 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 45140106566C for ; Mon, 2 Jul 2012 21:29:19 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 02 Jul 2012 21:29:19 +0000 Date: Mon, 02 Jul 2012 21:29:19 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120702212919.45140106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r238855 - soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jul 2012 21:29:21 -0000 Author: syuu Date: Mon Jul 2 21:29:18 2012 New Revision: 238855 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238855 Log: Install real mode interrupt handler, support loading bootsector from disk image. 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 Jul 2 21:28:42 2012 (r238854) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload/bhyvebiosload.c Mon Jul 2 21:29:18 2012 (r238855) @@ -274,6 +274,11 @@ if (argc != 1) usage(); + if (!disk_image) { + printf("disk image is required.\n"); + exit(1); + } + vmname = argv[0]; error = vm_create(vmname); @@ -309,9 +314,15 @@ term.c_iflag &= ~ICRNL; tcsetattr(0, TCSAFLUSH, &term); - if (disk_image) { - disk_fd = open(disk_image, O_RDONLY); + disk_fd = open(disk_image, O_RDONLY); + buf = malloc(512); + if (read(disk_fd, buf, 512) != 512) { + perror("read "); + return (1); } + cb_copyin(NULL, buf, 0x7c00, 512); + free(buf); + close(disk_fd); if (cb_open(NULL, "/pseudobios.bin", &h)) { perror("cb_open "); @@ -319,15 +330,24 @@ } cf = h; buf = malloc(6); - if (cb_read(NULL, cf, buf, 3, &res) != 0 || res != 0) { + if (cb_read(NULL, cf, buf, 6, &res) != 0 || res != 0) { fprintf(stderr, "cb_read\n"); return (1); } -#if 0 - cb_copyin(NULL, buf, 0xFFFFFFF0, 3); -#endif - cb_copyin(NULL, buf, 0x0, 3); + + int addr = 0x400; + for (int i = 0x0; i < 0x400; i += 0x4) { + uint16_t *p = (uint16_t *)&membase[i]; + cb_copyin(NULL, buf, addr, 6); + *p = addr; + p = (uint16_t *)&membase[i + 0x2]; + *p = 0x0; + addr += 0x10; + } + + free(buf); cb_close(NULL, cf); cb_exec(NULL, 0); + return (0); }