/* * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ #include #define CPLUSPLUS typedef long unsigned int uint_t; #include "floppy.h" // kIOMessageMediaStateHasChanged // call message(kIOMessageMediaStateHasChanged); when state has changed. extern "C" { #include //This is for debugging purposes ONLY io_return_t fdsetstat(dev_t dev, dev_flavor_t flavor, dev_status_t data, natural_t count); } // virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, // UInt32 block,UInt32 nblks, // IOStorageCompletion completion) = 0; IOReturn org_mklinux_iokit_swim3_driver::doEjectMedia(void) { dev_t dev; dev=(this->busdev->unit << 6); if (fdsetstat(dev, (dev_flavor_t)V_EJECT, NULL, 0) == D_SUCCESS) return kIOReturnSuccess; else return kIOReturnError; } IOReturn org_mklinux_iokit_swim3_driver::doFormatMedia(UInt64 byteCapacity) { /* @@@ WRITE ME! @@@*/ return kIOReturnUnsupported; } UInt32 org_mklinux_iokit_swim3_driver::doGetFormatCapacities(UInt64 * capacities, UInt32 capacitiesMaxCount) { /* @@@ WRITE ME! @@@*/ return kIOReturnUnsupported; } IOReturn org_mklinux_iokit_swim3_driver::doLockUnlockMedia(bool doLock) { /* @@@ WRITE ME! @@@*/ return kIOReturnUnsupported; } IOReturn org_mklinux_iokit_swim3_driver::doSyncReadWrite(IOMemoryDescriptor *buffer, UInt32 block,UInt32 nblks) { /* @@@ WRITE ME! @@@ */ return kIOReturnUnsupported; } // virtual IOReturn doSynchronizeCache(void) = 0; // virtual char * getAdditionalDeviceInfoString(void) = 0; // virtual char * getProductString(void) = 0; // virtual char * getRevisionString(void) = 0; // virtual char * getVendorString(void) = 0; // virtual bool init(OSDictionary * properties); extern "C" { OSStatus FloppyPluginGetInfo(BSStorePtr infoStore, struct BSStoreMPIInfo *info); } IOReturn org_mklinux_iokit_swim3_driver::reportBlockSize(UInt64 *blockSize) { struct BSStoreMPIInfo info; #if 0 BSStorePtr infoStore; #endif OSStatus ret; ret=FloppyPluginGetInfo(NULL, &info); *blockSize=info.writeBlockSize; if (ret == E_BSSuccess) return kIOReturnSuccess; else return kIOReturnError; } IOReturn org_mklinux_iokit_swim3_driver::reportEjectability(bool *isEjectable) { *isEjectable=1; return kIOReturnSuccess; } IOReturn org_mklinux_iokit_swim3_driver::reportLockability(bool *isLockable) { *isLockable=1; return kIOReturnSuccess; } IOReturn org_mklinux_iokit_swim3_driver::reportMaxReadTransfer(UInt64 blockSize,UInt64 *max) { /* It's the same for floppies, so why screw with two functions? */ return reportMaxWriteTransfer(blockSize, max); } IOReturn org_mklinux_iokit_swim3_driver::reportMaxValidBlock(UInt64 *maxBlock) { struct BSStoreMPIInfo info; #if 0 BSStorePtr infoStore; #endif OSStatus ret; ret=FloppyPluginGetInfo(NULL, &info); *maxBlock=info.storeSize / info.writeBlockSize; if (ret == E_BSSuccess) return kIOReturnSuccess; else return kIOReturnError; } IOReturn org_mklinux_iokit_swim3_driver::reportMaxWriteTransfer(UInt64 blockSize,UInt64 *max) { *max=MAX_PHYS / blockSize; return kIOReturnSuccess; } IOReturn org_mklinux_iokit_swim3_driver::reportMediaState(bool *mediaPresent,bool *changedState) { struct BSStoreMPIInfo info; #if 0 BSStorePtr infoStore; #endif OSStatus ret; IOLog("Polling swim3\n"); ret=FloppyPluginGetInfo(NULL, &info); if (info.curState == kBSOnline) *mediaPresent = true; else *mediaPresent = false; if (media_present != *mediaPresent) *changedState = true; else *changedState = false; media_present = mediaPresent; IOLog("mediaPresent = %s, changedState = %s\n", (*mediaPresent == true) ? "true" : "false", (*changedState == true) ? "true" : "false"); if (ret == E_BSSuccess) return kIOReturnSuccess; else return kIOReturnError; } IOReturn org_mklinux_iokit_swim3_driver::reportPollRequirements(bool *pollRequired, bool *pollIsExpensive) { /* @@@ Should this really be true? I mean, we already have a polling thread. Shouldn't we just notify upstream somehow? Seems obvious, but it isn't obvious how to do it outside of the usual families (SCSI, ATA, etc.) @@@ */ *pollRequired=true; *pollIsExpensive=false; return kIOReturnSuccess; } IOReturn org_mklinux_iokit_swim3_driver::reportRemovability(bool *isRemovable) { *isRemovable=false; return kIOReturnSuccess; } IOReturn org_mklinux_iokit_swim3_driver::reportWriteProtection(bool *isWriteProtected) { struct BSStoreMPIInfo info; #if 0 BSStorePtr infoStore; #endif OSStatus ret; ret=FloppyPluginGetInfo(NULL, &info); if (!info.isWriteable) *isWriteProtected = true; else *isWriteProtected = false; if (ret == E_BSSuccess) return kIOReturnSuccess; else return kIOReturnError; }