[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MiNT] [PATCH][1/3] USB mass storage driver returns wrong FS limits for MiNT kernel
When running as MiNT module, the USB mass storage driver is returning
wrong file system limits when XHDI function XHDOSLimits( ) is called,
it's returning limits for TOS 4 gemdos.
With this patch it will return the limits taken from MiNT's XHDI
pseudo-driver. I have copied those limits into the USB driver, Ideally
instead of copy them we should get them calling XHDOSLimits( ), to do
that we should add that XHDI function to the kentry structure so it
would be exported for modules as we did with XHNewCookie( ), but I'm
not sure if it's worth the trouble. We could also get the XHDI cookie
to get the XHDI handle but I don't like this way because the kernel
will see us as some external application.
In the XHDI psuedo-handle all MiNT's limits but XH_DL_BFLAGS are hard
coded, MiNT's asks for XH_DL_BFLAGS to the other drivers in the XHDI
chain. (I have no idea why). So from the USB driver we can't know that
value without implementing XHDOSLimits ( ) or using the XHDI cookie to
get the XHDI handle (as explained above). So I've hard coded it with
the value 0x00000001.
If you don't agree with this patch and you think it's better to add
XHDOSLimits( ) to kentry, or you think BS_FLAGS should have another
value, please you just tell me.
Commit message:
When running as MiNT module USB mass storage driver is returning wrong
file system limits when XHDI function XHDOSLimits( ) is called. Add
MiNT real limits.
Contributed by David Gálvez
diff -r c2411beec1e2 -r 8028d7046bc9 sys/usb/src.km/udd/storage/xhdi.c
--- a/sys/usb/src.km/udd/storage/xhdi.c Wed Apr 08 20:06:24 2015 +0200
+++ b/sys/usb/src.km/udd/storage/xhdi.c Thu Apr 16 19:26:28 2015 +0200
@@ -86,6 +86,7 @@
long
sys_XHDOSLimits(ushort which,ulong limit)
{
+#ifdef TOSONLY
static long dl_secsiz, dl_clusts, dl_maxsec, dl_clusts12;
static int first_time = 1;
@@ -178,7 +179,65 @@
return 0x00000001L;
}
}
+#else
+ if (limit == 0)
+ {
+ switch (which)
+ {
+ /* maximal sector size (BIOS level) */
+ case XH_DL_SECSIZ:
+ return 32768L;
+ /* minimal number of FATs */
+ case XH_DL_MINFAT:
+ return 1L;
+
+ /* maximal number of FATs */
+ case XH_DL_MAXFAT:
+ return 4L;
+
+ /* sectors per cluster minimal */
+ case XH_DL_MINSPC:
+ return 1L;
+
+ /* sectors per cluster maximal */
+ case XH_DL_MAXSPC:
+ return 128L;
+
+ /* maximal number of clusters of a 16 bit FAT */
+ case XH_DL_CLUSTS:
+ return 65518L; /* 0xffee */
+
+ /* maximal number of sectors */
+ case XH_DL_MAXSEC:
+ return 2147483647L; /* LONG_MAX */
+
+ /* maximal number of BIOS drives supported by the DOS */
+ case XH_DL_DRIVES:
+ return 32L;
+
+ /* maximal clustersize */
+ case XH_DL_CLSIZB:
+ return 65536L;
+
+ /* maximal (bpb->rdlen * bpb->recsiz / 32) */
+ case XH_DL_RDLEN:
+ return 2048; /* ??? */
+
+ /* maximal number of clusters of a 12 bit FAT */
+ case XH_DL_CLUSTS12:
+ return 4078L; /* 0xfee */
+
+ /* maximal number of clusters of a 32 bit FAT */
+ case XH_DL_CLUSTS32:
+ return 268435455L; /* 0x0fffffff */
+
+ /* supported bits in bpb->bflags */
+ case XH_DL_BFLAGS:
+ return 0x00000001L;
+ }
+ }
+#endif /* TOSONLY */
return ENOSYS;
}