2002-06-26 20:45:27 +04:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
Patch name: patch.blkdevsize
|
2002-07-04 14:40:10 +04:00
|
|
|
Author: Ph. Marek, updated by cbothamy
|
2002-07-29 14:00:10 +04:00
|
|
|
Date: July 29th 2002
|
2002-06-26 20:45:27 +04:00
|
|
|
|
|
|
|
Detailed description:
|
2002-07-04 14:40:10 +04:00
|
|
|
I added a configure check so the code will be included only
|
|
|
|
on system that supports it.
|
|
|
|
|
|
|
|
Original Detailed description:
|
2002-06-26 20:45:27 +04:00
|
|
|
I'm currently working to get bochs to support block devices (eg. /dev/hda) as
|
|
|
|
harddisks. I downloaded the current release
|
|
|
|
http://prdownloads.sourceforge.net/bochs/bochs-1.4.tar.gz
|
|
|
|
and found that size detection doesn't work.
|
|
|
|
|
|
|
|
Here's a patch to get the detection working.
|
|
|
|
|
|
|
|
Patch was created with:
|
|
|
|
cvs diff -u
|
|
|
|
Apply patch to what version:
|
2002-07-29 14:00:10 +04:00
|
|
|
cvs checked out on July 29th 2002
|
2002-06-26 20:45:27 +04:00
|
|
|
Instructions:
|
|
|
|
To patch, go to main bochs directory.
|
|
|
|
Type "patch -p0 < THIS_PATCH_FILE".
|
|
|
|
----------------------------------------------------------------------
|
2002-07-04 14:40:10 +04:00
|
|
|
Index: bochs.h
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/bochs/bochs/bochs.h,v
|
2002-07-29 14:00:10 +04:00
|
|
|
retrieving revision 1.73
|
|
|
|
diff -u -r1.73 bochs.h
|
|
|
|
--- bochs.h 29 Jul 2002 09:52:03 -0000 1.73
|
|
|
|
+++ bochs.h 29 Jul 2002 09:58:34 -0000
|
|
|
|
@@ -62,6 +62,9 @@
|
2002-07-04 14:40:10 +04:00
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/stat.h>
|
2002-07-29 14:00:10 +04:00
|
|
|
#endif
|
|
|
|
+#if BX_HAVE_BLKGETSIZE
|
|
|
|
+# include <sys/mount.h>
|
|
|
|
+#endif
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
2002-07-04 14:40:10 +04:00
|
|
|
Index: config.h.in
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/bochs/bochs/config.h.in,v
|
|
|
|
retrieving revision 1.50
|
|
|
|
diff -u -r1.50 config.h.in
|
|
|
|
--- config.h.in 5 Jun 2002 03:59:30 -0000 1.50
|
2002-07-29 14:00:10 +04:00
|
|
|
+++ config.h.in 29 Jul 2002 09:58:34 -0000
|
2002-07-04 14:40:10 +04:00
|
|
|
@@ -207,6 +207,7 @@
|
|
|
|
#define BX_HAVE_NANOSLEEP 0
|
|
|
|
#define BX_HAVE_ABORT 0
|
|
|
|
#define BX_HAVE_SOCKLEN_T 0
|
|
|
|
+#define BX_HAVE_BLKGETSIZE 0
|
|
|
|
|
|
|
|
// This turns on Roland Mainz's idle hack. Presently it is specific to the X11
|
|
|
|
// gui. If people try to enable it elsewhere, give a compile error after the
|
|
|
|
Index: configure
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/bochs/bochs/configure,v
|
2002-07-29 14:00:10 +04:00
|
|
|
retrieving revision 1.82
|
|
|
|
diff -u -r1.82 configure
|
|
|
|
--- configure 16 Jul 2002 12:10:05 -0000 1.82
|
|
|
|
+++ configure 29 Jul 2002 09:58:36 -0000
|
|
|
|
@@ -844,7 +844,7 @@
|
2002-07-04 14:40:10 +04:00
|
|
|
--enable-new-pit use Greg Alexander's new PIT model
|
|
|
|
--enable-slowdown use Greg Alexander's slowdown timer
|
|
|
|
--enable-idle-hack use Roland Mainz's idle hack
|
|
|
|
- --enable-processors select number of processors (1,2,4)
|
|
|
|
+ --enable-processors select number of processors (1,2,4,8)
|
|
|
|
--enable-cpu-level select cpu level (3,4,5,6)
|
|
|
|
--enable-dynamic enable dynamic translation support
|
|
|
|
--enable-fetchdecode-cache enable fetchdecode-cache support
|
2002-07-29 14:00:10 +04:00
|
|
|
@@ -7559,6 +7559,62 @@
|
2002-07-04 14:40:10 +04:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
+echo "$as_me:$LINENO: checking whether BLKGETSIZE is declared" >&5
|
|
|
|
+echo $ECHO_N "checking whether BLKGETSIZE is declared... $ECHO_C" >&6
|
|
|
|
+if test "${ac_cv_have_decl_BLKGETSIZE+set}" = set; then
|
|
|
|
+ echo $ECHO_N "(cached) $ECHO_C" >&6
|
|
|
|
+else
|
|
|
|
+ cat >conftest.$ac_ext <<_ACEOF
|
|
|
|
+#line $LINENO "configure"
|
|
|
|
+#include "confdefs.h"
|
|
|
|
+#include <sys/mount.h>
|
|
|
|
+
|
|
|
|
+#ifdef F77_DUMMY_MAIN
|
|
|
|
+# ifdef __cplusplus
|
|
|
|
+ extern "C"
|
|
|
|
+# endif
|
|
|
|
+ int F77_DUMMY_MAIN() { return 1; }
|
|
|
|
+#endif
|
|
|
|
+int
|
|
|
|
+main ()
|
|
|
|
+{
|
|
|
|
+#ifndef BLKGETSIZE
|
|
|
|
+ char *p = (char *) BLKGETSIZE;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ ;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+_ACEOF
|
|
|
|
+rm -f conftest.$ac_objext
|
|
|
|
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
|
|
|
+ (eval $ac_compile) 2>&5
|
|
|
|
+ ac_status=$?
|
|
|
|
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
|
|
+ (exit $ac_status); } &&
|
|
|
|
+ { ac_try='test -s conftest.$ac_objext'
|
|
|
|
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
|
|
|
+ (eval $ac_try) 2>&5
|
|
|
|
+ ac_status=$?
|
|
|
|
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
|
|
+ (exit $ac_status); }; }; then
|
|
|
|
+ ac_cv_have_decl_BLKGETSIZE=yes
|
|
|
|
+else
|
|
|
|
+ echo "$as_me: failed program was:" >&5
|
|
|
|
+cat conftest.$ac_ext >&5
|
|
|
|
+ac_cv_have_decl_BLKGETSIZE=no
|
|
|
|
+fi
|
|
|
|
+rm -f conftest.$ac_objext conftest.$ac_ext
|
|
|
|
+fi
|
|
|
|
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_BLKGETSIZE" >&5
|
|
|
|
+echo "${ECHO_T}$ac_cv_have_decl_BLKGETSIZE" >&6
|
|
|
|
+if test $ac_cv_have_decl_BLKGETSIZE = yes; then
|
|
|
|
+ cat >>confdefs.h <<\_ACEOF
|
|
|
|
+#define BX_HAVE_BLKGETSIZE 1
|
|
|
|
+_ACEOF
|
|
|
|
+
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
|
|
|
|
echo "$as_me:$LINENO: checking for struct timeval" >&5
|
|
|
|
echo $ECHO_N "checking for struct timeval... $ECHO_C" >&6
|
2002-07-29 14:00:10 +04:00
|
|
|
@@ -7989,7 +8045,7 @@
|
2002-07-04 14:40:10 +04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo " "
|
|
|
|
- echo "WARNING: processors != 1,2,4 can work, but you need to modify rombios.c manually"
|
|
|
|
+ echo "WARNING: processors != 1,2,4,8 can work, but you need to modify rombios.c manually"
|
|
|
|
echo "$as_me:$LINENO: result: $enable_val" >&5
|
|
|
|
echo "${ECHO_T}$enable_val" >&6
|
|
|
|
cat >>confdefs.h <<\_ACEOF
|
|
|
|
Index: configure.in
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/bochs/bochs/configure.in,v
|
2002-07-29 14:00:10 +04:00
|
|
|
retrieving revision 1.83
|
|
|
|
diff -u -r1.83 configure.in
|
|
|
|
--- configure.in 16 Jul 2002 12:08:38 -0000 1.83
|
|
|
|
+++ configure.in 29 Jul 2002 09:58:36 -0000
|
|
|
|
@@ -104,6 +104,7 @@
|
2002-07-04 14:40:10 +04:00
|
|
|
AC_CHECK_FUNCS(nanosleep, AC_DEFINE(BX_HAVE_NANOSLEEP))
|
|
|
|
AC_CHECK_FUNCS(abort, AC_DEFINE(BX_HAVE_ABORT))
|
|
|
|
AC_CHECK_TYPE(socklen_t, AC_DEFINE(BX_HAVE_SOCKLEN_T), , [#include <sys/socket.h>])
|
|
|
|
+AC_CHECK_DECL(BLKGETSIZE, AC_DEFINE(BX_HAVE_BLKGETSIZE), , [#include <sys/mount.h>])
|
|
|
|
|
|
|
|
AC_MSG_CHECKING(for struct timeval)
|
|
|
|
AC_TRY_COMPILE([#include <sys/time.h>],
|
2002-07-29 14:00:10 +04:00
|
|
|
@@ -216,7 +217,7 @@
|
2002-07-04 14:40:10 +04:00
|
|
|
|
|
|
|
AC_MSG_CHECKING(for number of processors)
|
|
|
|
AC_ARG_ENABLE(processors,
|
|
|
|
- [ --enable-processors select number of processors (1,2,4)],
|
|
|
|
+ [ --enable-processors select number of processors (1,2,4,8)],
|
|
|
|
[case "$enableval" in
|
|
|
|
1)
|
|
|
|
AC_MSG_RESULT(1)
|
2002-07-29 14:00:10 +04:00
|
|
|
@@ -247,7 +248,7 @@
|
2002-07-04 14:40:10 +04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo " "
|
|
|
|
- echo "WARNING: processors != [1,2,4] can work, but you need to modify rombios.c manually"
|
|
|
|
+ echo "WARNING: processors != [1,2,4,8] can work, but you need to modify rombios.c manually"
|
|
|
|
AC_MSG_RESULT($enable_val)
|
|
|
|
AC_DEFINE(BX_SMP_PROCESSORS, $enable_val)
|
|
|
|
AC_DEFINE(BX_BOOTSTRAP_PROCESSOR, 0)
|
2002-06-26 20:45:27 +04:00
|
|
|
Index: iodev/harddrv.cc
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/bochs/bochs/iodev/harddrv.cc,v
|
2002-07-29 14:00:10 +04:00
|
|
|
retrieving revision 1.63
|
|
|
|
diff -u -r1.63 harddrv.cc
|
|
|
|
--- iodev/harddrv.cc 27 Jul 2002 18:42:31 -0000 1.63
|
|
|
|
+++ iodev/harddrv.cc 29 Jul 2002 09:58:37 -0000
|
|
|
|
@@ -2839,6 +2839,23 @@
|
2002-06-26 20:45:27 +04:00
|
|
|
if (ret) {
|
|
|
|
BX_PANIC(("fstat() returns error!"));
|
|
|
|
}
|
2002-07-04 14:40:10 +04:00
|
|
|
+#if BX_HAVE_BLKGETSIZE
|
|
|
|
+ // On some systems we can use block devices as harddrives. Get the size
|
2002-06-26 20:45:27 +04:00
|
|
|
+ if (S_ISBLK(stat_buf.st_mode))
|
|
|
|
+ {
|
2002-07-04 14:40:10 +04:00
|
|
|
+ // it's a block device. st_size will be 0, so set it to the correct size.
|
2002-06-26 20:45:27 +04:00
|
|
|
+ if (ioctl(fd_table[i],BLKGETSIZE,&(stat_buf.st_size))==-1)
|
|
|
|
+ BX_PANIC(("size of block device %s can't be read",pathname));
|
|
|
|
+ if (stat_buf.st_size > (0x7ffffff/512))
|
|
|
|
+ {
|
|
|
|
+ BX_ERROR(("size of disk image is too big, rounded down"));
|
2002-07-04 14:40:10 +04:00
|
|
|
+ stat_buf.st_size=0x7ffffe00; // maximum size without overflow
|
2002-06-26 20:45:27 +04:00
|
|
|
+ }
|
|
|
|
+ else
|
2002-07-04 14:40:10 +04:00
|
|
|
+ stat_buf.st_size*=512; // returned value is sectors
|
|
|
|
+ // what about an overflow here? should possibly use fstat64
|
2002-06-26 20:45:27 +04:00
|
|
|
+ }
|
2002-07-04 14:40:10 +04:00
|
|
|
+#endif
|
2002-06-26 20:45:27 +04:00
|
|
|
if ((stat_buf.st_size % 512) != 0) {
|
|
|
|
BX_PANIC(("size of disk image must be multiple of 512 bytes"));
|
|
|
|
}
|