* All rights reserved.
*/
+#define UFS_SUPPORT 1
+
#include "bootstruct.h"
#include "libsaio.h"
#include "fdisk.h"
+#if UFS_SUPPORT
#include "ufs.h"
+#endif
#include "hfs.h"
#include "ntfs.h"
#include "msdos.h"
cc = get_drive_info(biosdev, &cached_di);
if (cc < 0) {
cached_di.valid = 0;
+ DEBUG_DISK(("get_drive_info returned error\n"));
return (-1); // BIOS call error
}
}
//==========================================================================
static int readBytes( int biosdev, unsigned int blkno,
+ unsigned int byteoff,
unsigned int byteCount, void * buffer )
{
DEBUG_DISK(("%s: dev %x block %x [%d] -> 0x%x...", __FUNCTION__,
biosdev, blkno, byteCount, (unsigned)cbuf));
- for ( ; byteCount; cbuf += BPS, blkno++ )
+ for ( ; byteCount; cbuf += copy_len, blkno++ )
{
error = Biosread( biosdev, blkno );
if ( error )
return (-1);
}
- copy_len = (byteCount > BPS) ? BPS : byteCount;
- bcopy( biosbuf, cbuf, copy_len );
+ copy_len = ((byteCount + byteoff) > BPS) ? (BPS - byteoff) : byteCount;
+ bcopy( biosbuf + byteoff, cbuf, copy_len );
byteCount -= copy_len;
+ byteoff = 0;
}
DEBUG_DISK(("done\n"));
FSReadFile readFunc,
FSGetDirEntry getdirFunc,
FSGetFileBlock getBlockFunc,
+ FSGetUUID getUUIDFunc,
BVGetDescription getDescriptionFunc,
int probe, int type )
{
bvr->fs_readfile = readFunc;
bvr->fs_getdirentry = getdirFunc;
bvr->fs_getfileblock= getBlockFunc;
+ bvr->fs_getuuid = getUUIDFunc;
bvr->description = getDescriptionFunc ?
getDescriptionFunc : getVolumeDescription;
bvr->type = type;
FSReadFile readFunc,
FSGetDirEntry getdirFunc,
FSGetFileBlock getBlockFunc,
+ FSGetUUID getUUIDFunc,
BVGetDescription getDescriptionFunc,
int probe, int type )
{
bvr->fs_readfile = readFunc;
bvr->fs_getdirentry = getdirFunc;
bvr->fs_getfileblock= getBlockFunc;
+ bvr->fs_getuuid = getUUIDFunc;
bvr->description = getDescriptionFunc ?
getDescriptionFunc : getVolumeDescription;
bvr->type = type;
struct DiskBVMap * map;
int partno = -1;
BVRef bvr;
+#if UFS_SUPPORT
BVRef booterUFS = NULL;
+#endif
int spc;
struct driveInfo di;
boot_drive_info_t *dp;
switch ( part->systid )
{
+#if UFS_SUPPORT
case FDISK_UFS:
bvr = newFDiskBVRef(
biosdev, partno,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
+ UFSGetUUID,
UFSGetDescription,
0,
kBIOSDevTypeHardDrive);
break;
+#endif
case FDISK_HFS:
bvr = newFDiskBVRef(
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
+ HFSGetUUID,
HFSGetDescription,
0,
kBIOSDevTypeHardDrive);
break;
+#if UFS_SUPPORT
case FDISK_BOOTER:
booterUFS = newFDiskBVRef(
biosdev, partno,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
+ UFSGetUUID,
UFSGetDescription,
0,
kBIOSDevTypeHardDrive);
break;
+#endif
case FDISK_NTFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
- 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0,
NTFSGetDescription,
0,
kBIOSDevTypeHardDrive);
biosdev, partno,
part->relsect,
part,
- 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
kBIOSDevTypeHardDrive);
break;
}
}
}
+#if UFS_SUPPORT
// Booting from a CD with an UFS filesystem embedded
// in a booter partition.
}
else free( booterUFS );
}
+#endif
}
} while (0);
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
+ HFSGetUUID,
0,
kBIOSDevTypeHardDrive);
bvr->next = map->bvr;
void *buffer = malloc(BPS);
/* Check for alternate block size */
- if (readBytes( biosdev, 0, BPS, buffer ) != 0) {
+ if (readBytes( biosdev, 0, 0, BPS, buffer ) != 0) {
return NULL;
}
block0_p = buffer;
gDiskBVMap = map;
for (i=0; i<npart; i++) {
- error = readBytes( biosdev, (kAPMSector + i) * factor, blksize, buffer );
+ error = readBytes( biosdev, (kAPMSector + i) * factor, 0, blksize, buffer );
if (error || OSSwapBigToHostInt16(dpme_p->dpme_signature) != DPME_SIGNATURE) {
break;
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
+ HFSGetUUID,
HFSGetDescription,
0,
kBIOSDevTypeHardDrive);
bootSector = gBootSector;
}
- error = readBytes( biosdev, secno, BPS, bootSector );
+ error = readBytes( biosdev, secno, 0, BPS, bootSector );
if ( error || bootSector->signature != DISK_SIGNATURE )
return -1;
void diskSeek( BVRef bvr, long long position )
{
bvr->fs_boff = position / BPS;
+ bvr->fs_byteoff = position % BPS;
}
//==========================================================================
{
return readBytes( bvr->biosdev,
bvr->fs_boff + bvr->part_boff,
+ bvr->fs_byteoff,
length,
(void *) addr );
}
return 0;
}
-void turnOffFloppy(void)
+
+int diskIsCDROM(BVRef bvr)
{
- /*
- * Disable floppy:
- * Hold controller in reset,
- * disable DMA and IRQ,
- * turn off floppy motors.
- */
- outb(0x3F2, 0x00);
+ struct driveInfo di;
+
+ if (getDriveInfo(bvr->biosdev, &di) == 0 && di.no_emulation) {
+ return 1;
+ }
+ return 0;
}