Date: Mon, 02 Jul 2012 21:29:19 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r238855 - soc2012/syuu/bhyve-bios/usr.sbin/bhyvebiosload Message-ID: <20120702212919.45140106566C@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120702212919.45140106566C>